All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Jones <drjones@redhat.com>
To: qemu-devel@nongnu.org, qemu-arm@nongnu.org
Cc: peter.maydell@linaro.org, maz@kernel.org, eric.auger@redhat.com
Subject: [PATCH] hw/arm/virt: KVM: The IPA lower bound is 32
Date: Tue,  9 Mar 2021 19:59:39 +0100	[thread overview]
Message-ID: <20210309185939.188431-1-drjones@redhat.com> (raw)

The virt machine already checks KVM_CAP_ARM_VM_IPA_SIZE to get the
upper bound of the IPA size. If that bound is lower than the highest
possible GPA for the machine, then QEMU will error out. However, the
IPA is set to 40 when the highest GPA is less than or equal to 40,
even when KVM may only support an IPA limit as low as 32. This means
KVM may fail the VM creation unnecessarily. Additionally, 40 is
selected with the value 0, which means use the default, and that gets
around a check in some versions of KVM, causing a difficult to debug
fail. Always use the IPA size that corresponds to the highest possible
GPA, unless it's lower than 32, in which case use 32.

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 hw/arm/virt.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 371147f3ae9c..7bf563715b4e 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -2547,14 +2547,13 @@ static int virt_kvm_type(MachineState *ms, const char *type_str)
                      "require an IPA range (%d bits) larger than "
                      "the one supported by the host (%d bits)",
                      requested_pa_size, max_vm_pa_size);
-       exit(1);
+        exit(1);
     }
+
     /*
-     * By default we return 0 which corresponds to an implicit legacy
-     * 40b IPA setting. Otherwise we return the actual requested PA
-     * logsize
+     * KVM requires the IPA size to be at least 32 bits.
      */
-    return requested_pa_size > 40 ? requested_pa_size : 0;
+    return requested_pa_size < 32 ? 32 : requested_pa_size;
 }
 
 static void virt_machine_class_init(ObjectClass *oc, void *data)
-- 
2.27.0



             reply	other threads:[~2021-03-09 19:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-09 18:59 Andrew Jones [this message]
2021-03-09 19:21 ` [PATCH] hw/arm/virt: KVM: The IPA lower bound is 32 Marc Zyngier
2021-03-09 20:06   ` Andrew Jones
2021-03-09 21:35     ` Marc Zyngier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210309185939.188431-1-drjones@redhat.com \
    --to=drjones@redhat.com \
    --cc=eric.auger@redhat.com \
    --cc=maz@kernel.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.