All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: peter.maydell@linaro.org
Cc: Fabiano Rosas <farosas@linux.ibm.com>,
	qemu-ppc@nongnu.org, groug@kaod.org,
	David Gibson <david@gibson.dropbear.id.au>,
	qemu-devel@nongnu.org
Subject: [PULL 5/5] kvm: ppc: Print meaningful message on KVM_CREATE_VM failure
Date: Thu, 29 Jul 2021 17:01:35 +1000	[thread overview]
Message-ID: <20210729070135.422262-6-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20210729070135.422262-1-david@gibson.dropbear.id.au>

From: Fabiano Rosas <farosas@linux.ibm.com>

PowerPC has two KVM types (HV, PR) that translate into three kernel
modules:

kvm.ko - common kvm code
kvm_hv.ko - kvm running with MSR_HV=1 or MSR_HV|PR=0 in a nested guest.
kvm_pr.ko - kvm running in usermode MSR_PR=1.

Since the two KVM types can both be running at the same time, this
creates a situation in which it is possible for one or both of the
modules to fail to initialize, leaving the generic one behind. This
leads QEMU to think it can create a guest, but KVM will fail when
calling the type-specific code:

 ioctl(KVM_CREATE_VM) failed: 22 Invalid argument
 qemu-kvm: failed to initialize KVM: Invalid argument

Ideally this would be solved kernel-side, but it might be a while
until we can get rid of one of the modules. So in the meantime this
patch tries to make this less confusing for the end user by adding a
more elucidative message:

 ioctl(KVM_CREATE_VM) failed: 22 Invalid argument
 PPC KVM module is not loaded. Try 'modprobe kvm_hv'.

[dwg: Fixed error in #elif which failed compile on !ppc hosts]
Signed-off-by: Fabiano Rosas <farosas@linux.ibm.com>
Message-Id: <20210722141340.2367905-1-farosas@linux.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 accel/kvm/kvm-all.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index e5b10dd129..0125c17edb 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -2397,6 +2397,12 @@ static int kvm_init(MachineState *ms)
                     "- for kernels supporting the vm.allocate_pgste sysctl, "
                     "whether it is enabled\n");
         }
+#elif defined(TARGET_PPC)
+        if (ret == -EINVAL) {
+            fprintf(stderr,
+                    "PPC KVM module is not loaded. Try modprobe kvm_%s.\n",
+                    (type == 2) ? "pr" : "hv");
+        }
 #endif
         goto err;
     }
-- 
2.31.1



  parent reply	other threads:[~2021-07-29  7:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-29  7:01 [PULL 0/5] ppc-for-6.1 queue 20210729 David Gibson
2021-07-29  7:01 ` [PULL 1/5] ppc/pegasos2: Fix spurious warning with -bios David Gibson
2021-07-29  7:01 ` [PULL 2/5] i2c/smbus_eeprom: Add feature bit to SPD data David Gibson
2021-07-29  7:01 ` [PULL 3/5] target/ppc: Ease L=0 requirement on cmp/cmpi/cmpl/cmpli for ppc32 David Gibson
2021-07-29  7:01 ` [PULL 4/5] ppc/vof: Fix Coverity issues David Gibson
2021-07-29  7:01 ` David Gibson [this message]
2021-07-29 12:16 ` [PULL 0/5] ppc-for-6.1 queue 20210729 Peter Maydell

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=20210729070135.422262-6-david@gibson.dropbear.id.au \
    --to=david@gibson.dropbear.id.au \
    --cc=farosas@linux.ibm.com \
    --cc=groug@kaod.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@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.