Skip to contentSkip to conversation

ppc/pnv.c: add a friendly warning when accel=kvm is used

PATCH Applied Daniel Henrique Barboza 3 participants 5 messages Nov 30, 2021 – Dec 15, 2021 PowerPC

lore
Share & tools
lore
#0 lore raw

v2 cover ppc/pnv.c: add a friendly warning when accel=kvm is used

Hi,

In this version a documentation patch was added to explain our motivations to officially disable KVM accel in the powernv machine.

Changes from v1:
- added a doc patch
- v1 link: https://lists.gnu.org/archive/html/qemu-devel/2021-11/msg05207.html

Daniel Henrique Barboza (2):
ppc/pnv.c: add a friendly warning when accel=kvm is used docs/system/ppc/powernv.rst: document KVM support status

 docs/system/ppc/powernv.rst | 13 +++++++++++++
 hw/ppc/pnv.c                |  5 +++++
 2 files changed, 18 insertions(+)
Signature · 1 line
2.31.1
#1 lore raw

PATCH v2 1/2 ppc/pnv.c: add a friendly warning when accel=kvm is used

If one tries to use -machine powernv9,accel=kvm in a Power9 host, a cryptic error will be shown:

qemu-system-ppc64: Register sync failed... If you're using kvm-hv.ko, only "-cpu host" is possible
qemu-system-ppc64: kvm_init_vcpu: kvm_arch_init_vcpu failed (0): Invalid argument

Appending '-cpu host' will throw another error:

qemu-system-ppc64: invalid chip model 'host' for powernv9 machine

The root cause is that in IBM PowerPC we have different specs for the bare-metal and the guests. The bare-metal follows OPAL, the guests follow PAPR. The kernel KVM modules presented in the ppc kernels implements PAPR. This means that we can't use KVM accel when using the powernv machine, which is the emulation of the bare-metal host.

All that said, let's give a more informative error in this case.

---
 hw/ppc/pnv.c | 5 +++++
 1 file changed, 5 insertions(+)
hw/ppc/pnv.c +5 -0
index 71e45515f1..e5b87e8730 100644
@@ -742,6 +742,11 @@ static void pnv_init(MachineState *machine)
     DriveInfo *pnor = drive_get(IF_MTD, 0, 0);
     DeviceState *dev;
 
+    if (kvm_enabled()) {
+        error_report("The powernv machine does not work with KVM acceleration");
+        exit(EXIT_FAILURE);
+    }
+
     /* allocate RAM */
     if (machine->ram_size < mc->default_ram_size) {
         char *sz = size_to_str(mc->default_ram_size);
Signature · 1 line
2.31.1
Reviewed-by on v2 1/2
#2 lore raw
Quoted 16 lines · Daniel Henrique Barboza

If one tries to use -machine powernv9,accel=kvm in a Power9 host, a cryptic error will be shown:

qemu-system-ppc64: Register sync failed... If you're using kvm-hv.ko, only "-cpu host" is possible
qemu-system-ppc64: kvm_init_vcpu: kvm_arch_init_vcpu failed (0): Invalid argument

Appending '-cpu host' will throw another error:

qemu-system-ppc64: invalid chip model 'host' for powernv9 machine

The root cause is that in IBM PowerPC we have different specs for the bare-metal and the guests. The bare-metal follows OPAL, the guests follow PAPR. The kernel KVM modules presented in the ppc kernels implements PAPR. This means that we can't use KVM accel when using the powernv machine, which is the emulation of the bare-metal host.

Quoted 3 lines

All that said, let's give a more informative error in this case.

Quoted 20 lines
---
 hw/ppc/pnv.c | 5 +++++
 1 file changed, 5 insertions(+)
hw/ppc/pnv.c +5 -0
index 71e45515f1..e5b87e8730 100644
@@ -742,6 +742,11 @@ static void pnv_init(MachineState *machine)
     DriveInfo *pnor = drive_get(IF_MTD, 0, 0);
     DeviceState *dev;
 
+    if (kvm_enabled()) {
+        error_report("The powernv machine does not work with KVM acceleration");
+        exit(EXIT_FAILURE);
+    }
+
     /* allocate RAM */
     if (machine->ram_size < mc->default_ram_size) {
         char *sz = size_to_str(mc->default_ram_size);
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
#3 lore raw

PATCH v2 2/2 docs/system/ppc/powernv.rst: document KVM support status

In reply to Daniel Henrique Barboza

Put in a more accessible place the reasoning behind our decision to officially drop KVM support in the powernv machine.

---
 docs/system/ppc/powernv.rst | 13 +++++++++++++
 1 file changed, 13 insertions(+)
docs/system/ppc/powernv.rst +13 -0
index 86186b7d2c..8304e85c51 100644
@@ -58,6 +58,19 @@ Prebuilt images of ``skiboot`` and ``skiroot`` are made available on the `OpenPO
 QEMU includes a prebuilt image of ``skiboot`` which is updated when a
 more recent version is required by the models.
 
+Current acceleration status
+---------------------------
+
+KVM acceleration in Linux Power hosts is provided by the kvm-hv and
+kvm-pr modules. kvm-hv is adherent to PAPR and it's not compliant with
+powernv. kvm-pr in theory could be used as a valid accel option but
+this isn't supported by kvm-pr at this moment.
+
+To spare users from dealing with not so informative errors when attempting
+to use accel=kvm, the powernv machine will throw an error informing that
+KVM is not supported. This can be revisited in the future if kvm-pr (or
+any other KVM alternative) is usable as KVM accel for this machine.
+
 Boot options
 ------------
 
Signature · 1 line
2.31.1