* [PATCH] kvm: ppc: Print meaningful message on KVM_CREATE_VM failure
@ 2021-07-22 14:13 Fabiano Rosas
2021-07-26 2:25 ` David Gibson
0 siblings, 1 reply; 2+ messages in thread
From: Fabiano Rosas @ 2021-07-22 14:13 UTC (permalink / raw)
To: qemu-devel; +Cc: pbonzini, qemu-ppc, groug, david
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'.
Signed-off-by: Fabiano Rosas <farosas@linux.ibm.com>
---
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 3bd17135ce..4d9a7c7bfc 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 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.29.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] kvm: ppc: Print meaningful message on KVM_CREATE_VM failure
2021-07-22 14:13 [PATCH] kvm: ppc: Print meaningful message on KVM_CREATE_VM failure Fabiano Rosas
@ 2021-07-26 2:25 ` David Gibson
0 siblings, 0 replies; 2+ messages in thread
From: David Gibson @ 2021-07-26 2:25 UTC (permalink / raw)
To: Fabiano Rosas; +Cc: pbonzini, qemu-ppc, qemu-devel, groug
[-- Attachment #1: Type: text/plain, Size: 2113 bytes --]
On Thu, Jul 22, 2021 at 11:13:40AM -0300, Fabiano Rosas wrote:
> 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'.
>
> Signed-off-by: Fabiano Rosas <farosas@linux.ibm.com>
Applied to ppc-for-6.1, thanks.
> ---
> 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 3bd17135ce..4d9a7c7bfc 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 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;
> }
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-07-26 2:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-22 14:13 [PATCH] kvm: ppc: Print meaningful message on KVM_CREATE_VM failure Fabiano Rosas
2021-07-26 2:25 ` David Gibson
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.