Skip to contentSkip to conversation

kvm: ppc: Print meaningful message on KVM_CREATE_VM failure

PATCH Applied Fabiano Rosas 2 participants 2 messages Jul 22, 2021 – Jul 26, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kvm: ppc: Print meaningful message on KVM_CREATE_VM failure

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'.

---
 accel/kvm/kvm-all.c | 6 ++++++
 1 file changed, 6 insertions(+)
accel/kvm/kvm-all.c +6 -0
index 3bd17135ce..4d9a7c7bfc 100644
@@ -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;
     }
Signature · 1 line
2.29.2
Applied
#1 lore raw
Quoted 21 lines · Fabiano Rosas

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:

Quoted 4 lines

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

Applied to ppc-for-6.1, thanks.

Quoted 21 lines
---
 accel/kvm/kvm-all.c | 6 ++++++
 1 file changed, 6 insertions(+)
accel/kvm/kvm-all.c +6 -0
index 3bd17135ce..4d9a7c7bfc 100644
@@ -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;
     }
Signature · 4 lines
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