Skip to contentSkip to conversation

ppc: New reviewers and KVM cleanups

PATCH Applied Cédric Le Goater 6 participants 32 messages Jun 20, 2023 – Jun 23, 2023

lore
Share & tools
lore
#0 lore raw

cover ppc: New reviewers and KVM cleanups

Hello,

Please welcome new reviewers on baremetal POWER systems !

Follow cleanups to report an error when KVM is used on non-KVM machines.

Thanks,

C.

Cédric Le Goater (9):
MAINTAINERS: Add reviewers for PowerNV baremetal emulation
MAINTAINERS: Add reviewer for PowerPC TCG CPUs
MAINTAINERS: Add reviewer for XIVE
ppc/prep: Report an error when run with KVM ppc/pegasos2: Report an error when run with KVM ppc/sam460ex: Report an error when run with KVM ppc/bamboo: Report an error when run with KVM ppc/pnv: Rephrase error when run with KVM target/ppc: Fix timer register accessors when !KVM

 MAINTAINERS            |  4 ++++
 hw/ppc/pegasos2.c      |  7 ++++++-
 hw/ppc/pnv.c           |  3 ++-
 hw/ppc/ppc440_bamboo.c | 17 ++++++-----------
 hw/ppc/prep.c          | 20 +++++++-------------
 hw/ppc/sam460ex.c      | 15 ++++++---------
 target/ppc/kvm.c       | 12 ++++++++++++
 7 files changed, 43 insertions(+), 35 deletions(-)
Signature · 1 line
2.41.0
#1 lore raw

PATCH 1/9 MAINTAINERS: Add reviewers for PowerNV baremetal emulation

Fred and Nick have been hacking baremetal POWER systems (OPAL) for many years. They use and modify the QEMU models regularly. Add them as PowerNV reviewers.

Cc Frédéric Barrat <[email protected]>
Cc Nicholas Piggin <[email protected]>
---
 MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)
MAINTAINERS +2 -0
index 88b5a7ee0a79..e6f3dade2230 100644
@@ -1448,6 +1448,8 @@ F: tests/avocado/ppc_pseries.py
 
 PowerNV (Non-Virtualized)
 M: Cédric Le Goater <[email protected]>
+R: Frédéric Barrat <[email protected]>
+R: Nicholas Piggin <[email protected]>
 L: [email protected]
 S: Odd Fixes
 F: docs/system/ppc/powernv.rst
Signature · 1 line
2.41.0
Acked-by on v1 1/9
#2 lore raw

Re: [PATCH 1/9] MAINTAINERS: Add reviewers for PowerNV baremetal emulation

Quoted 8 lines · Cédric Le Goater

Fred and Nick have been hacking baremetal POWER systems (OPAL) for many years. They use and modify the QEMU models regularly. Add them as PowerNV reviewers.

Cc Frédéric Barrat <[email protected]>
Cc Nicholas Piggin <[email protected]>

---

Fred

Quoted 16 lines
  MAINTAINERS | 2 ++
  1 file changed, 2 insertions(+)
MAINTAINERS +2 -0
index 88b5a7ee0a79..e6f3dade2230 100644
@@ -1448,6 +1448,8 @@ F: tests/avocado/ppc_pseries.py
 
  PowerNV (Non-Virtualized)
  M: Cédric Le Goater <[email protected]>
+R: Frédéric Barrat <[email protected]>
+R: Nicholas Piggin <[email protected]>
  L: [email protected]
  S: Odd Fixes
  F: docs/system/ppc/powernv.rst
Reviewed-by on v1 1/9
#3 lore raw

Re: [PATCH 1/9] MAINTAINERS: Add reviewers for PowerNV baremetal emulation

In reply to Cédric Le Goater
Quoted 10 lines · Cédric Le Goater

Fred and Nick have been hacking baremetal POWER systems (OPAL) for many years. They use and modify the QEMU models regularly. Add them as PowerNV reviewers.

Cc Frédéric Barrat<[email protected]>
Cc Nicholas Piggin<[email protected]>
---
  MAINTAINERS | 2 ++
  1 file changed, 2 insertions(+)

r~

Reviewed-by on v1 1/9
#4 lore raw

Re: [PATCH 1/9] MAINTAINERS: Add reviewers for PowerNV baremetal emulation

In reply to Cédric Le Goater
Quoted 4 lines · Cédric Le Goater

Fred and Nick have been hacking baremetal POWER systems (OPAL) for many years. They use and modify the QEMU models regularly. Add them as PowerNV reviewers.

Quoted 22 lines
Cc Frédéric Barrat <[email protected]>
Cc Nicholas Piggin <[email protected]>
---
 MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)
MAINTAINERS +2 -0
index 88b5a7ee0a79..e6f3dade2230 100644
@@ -1448,6 +1448,8 @@ F: tests/avocado/ppc_pseries.py
 
 PowerNV (Non-Virtualized)
 M: Cédric Le Goater <[email protected]>
+R: Frédéric Barrat <[email protected]>
+R: Nicholas Piggin <[email protected]>
 L: [email protected]
 S: Odd Fixes
 F: docs/system/ppc/powernv.rst
Signature · 1 line
2.41.0
#5 lore raw

PATCH 2/9 MAINTAINERS: Add reviewer for PowerPC TCG CPUs

In reply to Cédric Le Goater

Nick has great knowledge of the PowerPC CPUs, software and hardware. Add him as a reviewer on CPU TCG modeling.

---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
index e6f3dade2230..90fb83c4cb58 100644
@@ -302,6 +302,7 @@ M: Daniel Henrique Barboza <[email protected]>
 R: Cédric Le Goater <[email protected]>
 R: David Gibson <[email protected]>
 R: Greg Kurz <[email protected]>
+R: Nicholas Piggin <[email protected]>
 L: [email protected]
 S: Odd Fixes
 F: target/ppc/
Signature · 1 line
2.41.0
Reviewed-by on v1 2/9
#7 lore raw

Re: [PATCH 2/9] MAINTAINERS: Add reviewer for PowerPC TCG CPUs

In reply to Cédric Le Goater
Quoted 2 lines · Cédric Le Goater

Nick has great knowledge of the PowerPC CPUs, software and hardware. Add him as a reviewer on CPU TCG modeling.

Quoted 21 lines
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
index e6f3dade2230..90fb83c4cb58 100644
@@ -302,6 +302,7 @@ M: Daniel Henrique Barboza <[email protected]>
 R: Cédric Le Goater <[email protected]>
 R: David Gibson <[email protected]>
 R: Greg Kurz <[email protected]>
+R: Nicholas Piggin <[email protected]>
 L: [email protected]
 S: Odd Fixes
 F: target/ppc/
Signature · 1 line
2.41.0
Reviewed-by on v1 2/9
#8 lore raw

Re: [PATCH 2/9] MAINTAINERS: Add reviewer for PowerPC TCG CPUs

In reply to Cédric Le Goater
Quoted 8 lines · Cédric Le Goater

Nick has great knowledge of the PowerPC CPUs, software and hardware. Add him as a reviewer on CPU TCG modeling.

---
  MAINTAINERS | 1 +
  1 file changed, 1 insertion(+)
#9 lore raw

PATCH 3/9 MAINTAINERS: Add reviewer for XIVE

In reply to Cédric Le Goater

Fred discusses frequently with the IBM HW designers, he is fluent in XIVE logic, add him as a reviewer.

---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
index 90fb83c4cb58..2e8c715eaca4 100644
@@ -2445,6 +2445,7 @@ T: git https://github.com/philmd/qemu.git fw_cfg-next
 
 XIVE
 M: Cédric Le Goater <[email protected]>
+R: Frédéric Barrat <[email protected]>
 L: [email protected]
 S: Odd Fixes
 F: hw/*/*xive*
Signature · 1 line
2.41.0
Acked-by on v1 3/9
#10 lore raw

Re: [PATCH 3/9] MAINTAINERS: Add reviewer for XIVE

Quoted 6 lines · Cédric Le Goater

Fred discusses frequently with the IBM HW designers, he is fluent in XIVE logic, add him as a reviewer.

---

Fred

Quoted 15 lines
  MAINTAINERS | 1 +
  1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
index 90fb83c4cb58..2e8c715eaca4 100644
@@ -2445,6 +2445,7 @@ T: git https://github.com/philmd/qemu.git fw_cfg-next
 
  XIVE
  M: Cédric Le Goater <[email protected]>
+R: Frédéric Barrat <[email protected]>
  L: [email protected]
  S: Odd Fixes
  F: hw/*/*xive*
#12 lore raw

PATCH 4/9 ppc/prep: Report an error when run with KVM

In reply to Cédric Le Goater

The 'prep' machine never supported KVM. This piece of code was probably inherited from another model.

---
 hw/ppc/prep.c | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)
hw/ppc/prep.c +7 -13
index 33bf232f8b0d..d9231c731775 100644
@@ -45,7 +45,6 @@
 #include "trace.h"
 #include "elf.h"
 #include "qemu/units.h"
-#include "kvm_ppc.h"
 
 /* SMP is not enabled, for now */
 #define MAX_CPUS 1
@@ -245,6 +244,12 @@ static void ibm_40p_init(MachineState *machine)
     long kernel_size = 0, initrd_size = 0;
     char boot_device;
 
+    if (kvm_enabled()) {
+        error_report("machine %s does not support the KVM accelerator",
+                     MACHINE_GET_CLASS(machine)->name);
+        exit(EXIT_FAILURE);
+    }
+
     /* init CPU */
     cpu = POWERPC_CPU(cpu_create(machine->cpu_type));
     env = &cpu->env;
@@ -392,18 +397,7 @@ static void ibm_40p_init(MachineState *machine)
     fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, graphic_height);
     fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, graphic_depth);
 
-    fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_IS_KVM, kvm_enabled());
-    if (kvm_enabled()) {
-        uint8_t *hypercall;
-
-        fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, kvmppc_get_tbfreq());
-        hypercall = g_malloc(16);
-        kvmppc_get_hypercall(env, hypercall, 16);
-        fw_cfg_add_bytes(fw_cfg, FW_CFG_PPC_KVM_HC, hypercall, 16);
-        fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_KVM_PID, getpid());
-    } else {
-        fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, NANOSECONDS_PER_SECOND);
-    }
+    fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, NANOSECONDS_PER_SECOND);
     fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, boot_device);
     qemu_register_boot_set(fw_cfg_boot_set, fw_cfg);
 
Signature · 1 line
2.41.0
Reviewed-by on v1 4/9
#13 lore raw

Re: [PATCH 4/9] ppc/prep: Report an error when run with KVM

Quoted 8 lines · Cédric Le Goater

The 'prep' machine never supported KVM. This piece of code was probably inherited from another model.

---
  hw/ppc/prep.c | 20 +++++++-------------
  1 file changed, 7 insertions(+), 13 deletions(-)

r~

#14 lore raw

PATCH 5/9 ppc/pegasos2: Report an error when run with KVM

In reply to Cédric Le Goater

The 'pegasos2' machine never supported KVM. This piece of code was inherited from another model.

---
 hw/ppc/pegasos2.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
hw/ppc/pegasos2.c +6 -1
index af5489de26ed..830323cc7849 100644
@@ -29,7 +29,6 @@
 #include "qemu/log.h"
 #include "qemu/error-report.h"
 #include "sysemu/kvm.h"
-#include "kvm_ppc.h"
 #include "exec/address-spaces.h"
 #include "qom/qom-qobject.h"
 #include "qapi/qmp/qdict.h"
@@ -120,6 +119,12 @@ static void pegasos2_init(MachineState *machine)
     int i, sz;
     uint8_t *spd_data;
 
+    if (kvm_enabled()) {
+        error_report("machine %s does not support the KVM accelerator",
+                     MACHINE_GET_CLASS(machine)->name);
+        exit(EXIT_FAILURE);
+    }
+
     /* init CPU */
     pm->cpu = POWERPC_CPU(cpu_create(machine->cpu_type));
     env = &pm->cpu->env;
Signature · 1 line
2.41.0
#16 lore raw

Re: [PATCH 5/9] ppc/pegasos2: Report an error when run with KVM

In reply to Cédric Le Goater
Quoted 2 lines · Cédric Le Goater

The 'pegasos2' machine never supported KVM. This piece of code was inherited from another model.

Why? These machines are supposed to run with KVM they were just not tested yet. I think pegasos2 should work on a G4 host with KVM-PR but you need to use the firmware rom for -bios now because VOF uses sc 1 which will not work with KVM on G4, it's only supported with TCG. (I plan to solve this eventually when needed by replacing that with another hypercall method such as OSI used by MOL but that would need two vof binaries or carry some unneeded code if using single binary.)

So please drop this patch.

Regards,
BALATON Zoltan

Quoted 32 lines

---
hw/ppc/pegasos2.c | 7 ++++++-

1 file changed, 6 insertions(+), 1 deletion(-)
hw/ppc/pegasos2.c +6 -1
index af5489de26ed..830323cc7849 100644
@@ -29,7 +29,6 @@
 #include "qemu/log.h"
 #include "qemu/error-report.h"
 #include "sysemu/kvm.h"
-#include "kvm_ppc.h"
 #include "exec/address-spaces.h"
 #include "qom/qom-qobject.h"
 #include "qapi/qmp/qdict.h"
@@ -120,6 +119,12 @@ static void pegasos2_init(MachineState *machine)
    int i, sz;
    uint8_t *spd_data;
 
+    if (kvm_enabled()) {
+        error_report("machine %s does not support the KVM accelerator",
+                     MACHINE_GET_CLASS(machine)->name);
+        exit(EXIT_FAILURE);
+    }
+
    /* init CPU */
    pm->cpu = POWERPC_CPU(cpu_create(machine->cpu_type));
    env = &pm->cpu->env;
#17 lore raw

PATCH 6/9 ppc/sam460ex: Report an error when run with KVM

In reply to Cédric Le Goater

The 'sam460ex' machine never supported KVM. This piece of code was inherited from another model.

---
 hw/ppc/sam460ex.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)
hw/ppc/sam460ex.c +6 -9
index cf065aae0eae..24f25e5897b7 100644
@@ -18,7 +18,6 @@
 #include "qapi/error.h"
 #include "hw/boards.h"
 #include "sysemu/kvm.h"
-#include "kvm_ppc.h"
 #include "sysemu/device_tree.h"
 #include "sysemu/block-backend.h"
 #include "hw/loader.h"
@@ -165,14 +164,6 @@ static int sam460ex_load_device_tree(MachineState *machine,
     qemu_fdt_setprop_string(fdt, "/chosen", "bootargs",
                             machine->kernel_cmdline);
 
-    /* Copy data from the host device tree into the guest. Since the guest can
-     * directly access the timebase without host involvement, we must expose
-     * the correct frequencies. */
-    if (kvm_enabled()) {
-        tb_freq = kvmppc_get_tbfreq();
-        clock_freq = kvmppc_get_clockfreq();
-    }
-
     qemu_fdt_setprop_cell(fdt, "/cpus/cpu@0", "clock-frequency",
                               clock_freq);
     qemu_fdt_setprop_cell(fdt, "/cpus/cpu@0", "timebase-frequency",
@@ -283,6 +274,12 @@ static void sam460ex_init(MachineState *machine)
     uint8_t *spd_data;
     int success;
 
+    if (kvm_enabled()) {
+        error_report("machine %s does not support the KVM accelerator",
+                     MACHINE_GET_CLASS(machine)->name);
+        exit(EXIT_FAILURE);
+    }
+
     cpu = POWERPC_CPU(cpu_create(machine->cpu_type));
     env = &cpu->env;
     if (env->mmu_model != POWERPC_MMU_BOOKE) {
Signature · 1 line
2.41.0
Reviewed-by on v1 6/9
#18 lore raw

Re: [PATCH 6/9] ppc/sam460ex: Report an error when run with KVM

Quoted 8 lines · Cédric Le Goater

The 'sam460ex' machine never supported KVM. This piece of code was inherited from another model.

---
  hw/ppc/sam460ex.c | 15 ++++++---------
  1 file changed, 6 insertions(+), 9 deletions(-)

r~

#19 lore raw

Re: [PATCH 6/9] ppc/sam460ex: Report an error when run with KVM

In reply to Cédric Le Goater
Quoted 2 lines · Cédric Le Goater

The 'sam460ex' machine never supported KVM. This piece of code was inherited from another model.

This is the same as for pegasos2, it might work on a BookE host if KVM-PR on that host is still supported so please keep this around unless there's a known problem that can't be fixed.

Regards,
BALATON Zoltan

Quoted 47 lines

---
hw/ppc/sam460ex.c | 15 ++++++---------

1 file changed, 6 insertions(+), 9 deletions(-)
hw/ppc/sam460ex.c +6 -9
index cf065aae0eae..24f25e5897b7 100644
@@ -18,7 +18,6 @@
 #include "qapi/error.h"
 #include "hw/boards.h"
 #include "sysemu/kvm.h"
-#include "kvm_ppc.h"
 #include "sysemu/device_tree.h"
 #include "sysemu/block-backend.h"
 #include "hw/loader.h"
@@ -165,14 +164,6 @@ static int sam460ex_load_device_tree(MachineState *machine,
    qemu_fdt_setprop_string(fdt, "/chosen", "bootargs",
                            machine->kernel_cmdline);
 
-    /* Copy data from the host device tree into the guest. Since the guest can
-     * directly access the timebase without host involvement, we must expose
-     * the correct frequencies. */
-    if (kvm_enabled()) {
-        tb_freq = kvmppc_get_tbfreq();
-        clock_freq = kvmppc_get_clockfreq();
-    }
-
    qemu_fdt_setprop_cell(fdt, "/cpus/cpu@0", "clock-frequency",
                              clock_freq);
    qemu_fdt_setprop_cell(fdt, "/cpus/cpu@0", "timebase-frequency",
@@ -283,6 +274,12 @@ static void sam460ex_init(MachineState *machine)
    uint8_t *spd_data;
    int success;
 
+    if (kvm_enabled()) {
+        error_report("machine %s does not support the KVM accelerator",
+                     MACHINE_GET_CLASS(machine)->name);
+        exit(EXIT_FAILURE);
+    }
+
    cpu = POWERPC_CPU(cpu_create(machine->cpu_type));
    env = &cpu->env;
    if (env->mmu_model != POWERPC_MMU_BOOKE) {
#20 lore raw

Re: [PATCH 6/9] ppc/sam460ex: Report an error when run with KVM

Quoted 5 lines · BALATON Zoltan
Quoted 2 lines · Cédric Le Goater

The 'sam460ex' machine never supported KVM. This piece of code was inherited from another model.

This is the same as for pegasos2, it might work on a BookE host if KVM-PR on that host is still supported so please keep this around unless there's a known problem that can't be fixed.

That sounds like a lot of 'if' for 2 decade old HW and an abandoned HV implementation. Nevertheless, if KVM is supported one day, we can remove easily the couple of lines below. I am sure there will be more changes.

Same comment for the pegasos2,

Thanks,

C.

Quoted 51 lines

Regards,
BALATON Zoltan

Quoted 47 lines

---
hw/ppc/sam460ex.c | 15 ++++++---------

1 file changed, 6 insertions(+), 9 deletions(-)
hw/ppc/sam460ex.c +6 -9
index cf065aae0eae..24f25e5897b7 100644
@@ -18,7 +18,6 @@
 #include "qapi/error.h"
 #include "hw/boards.h"
 #include "sysemu/kvm.h"
-#include "kvm_ppc.h"
 #include "sysemu/device_tree.h"
 #include "sysemu/block-backend.h"
 #include "hw/loader.h"
@@ -165,14 +164,6 @@ static int sam460ex_load_device_tree(MachineState *machine,
     qemu_fdt_setprop_string(fdt, "/chosen", "bootargs",
                             machine->kernel_cmdline);
 
-    /* Copy data from the host device tree into the guest. Since the guest can
-     * directly access the timebase without host involvement, we must expose
-     * the correct frequencies. */
-    if (kvm_enabled()) {
-        tb_freq = kvmppc_get_tbfreq();
-        clock_freq = kvmppc_get_clockfreq();
-    }
-
     qemu_fdt_setprop_cell(fdt, "/cpus/cpu@0", "clock-frequency",
                               clock_freq);
     qemu_fdt_setprop_cell(fdt, "/cpus/cpu@0", "timebase-frequency",
@@ -283,6 +274,12 @@ static void sam460ex_init(MachineState *machine)
     uint8_t *spd_data;
     int success;
 
+    if (kvm_enabled()) {
+        error_report("machine %s does not support the KVM accelerator",
+                     MACHINE_GET_CLASS(machine)->name);
+        exit(EXIT_FAILURE);
+    }
+
     cpu = POWERPC_CPU(cpu_create(machine->cpu_type));
     env = &cpu->env;
     if (env->mmu_model != POWERPC_MMU_BOOKE) {
#21 lore raw

Re: [PATCH 6/9] ppc/sam460ex: Report an error when run with KVM

Quoted 5 lines · Cédric Le Goater
Quoted 4 lines · BALATON Zoltan
Quoted 2 lines · Cédric Le Goater

The 'sam460ex' machine never supported KVM. This piece of code was inherited from another model.

Quoted 7 lines
Quoted 1 line

This is the same as for pegasos2, it might work on a BookE host if KVM-PR on that host is still supported so please keep this around unless there's a known problem that can't be fixed.

That sounds like a lot of 'if' for 2 decade old HW and an abandoned HV implementation. Nevertheless, if KVM is supported one day, we can remove easily the couple of lines below. I am sure there will be more changes.

Same comment for the pegasos2,

If you disable it then nobody can test it so it can't be supported. I need people to be able to test it to support it so please leave this enabled. (People using these machines don't normally compile their binaries from source and don't want to.)

Regards,
BALATON Zoltan

Quoted 61 lines

Thanks,

C.

Quoted 54 lines

Regards,
BALATON Zoltan

Quoted 50 lines

---
hw/ppc/sam460ex.c | 15 ++++++---------

1 file changed, 6 insertions(+), 9 deletions(-)
hw/ppc/sam460ex.c +0 -2
index cf065aae0eae..24f25e5897b7 100644
@@ -18,7 +18,6 @@
 #include "qapi/error.h"
 #include "hw/boards.h"
 #include "sysemu/kvm.h"
-#include "kvm_ppc.h"
 #include "sysemu/device_tree.h"
 #include "sysemu/block-backend.h"
 #include "hw/loader.h"
@@ -165,14 +164,6 @@ static int sam460ex_load_device_tree(MachineState 
 *machine,
     qemu_fdt_setprop_string(fdt, "/chosen", "bootargs",
                             machine->kernel_cmdline);
 
-    /* Copy data from the host device tree into the guest. Since the 

guest can
-     * directly access the timebase without host involvement, we must expose
-     * the correct frequencies. */
-    if (kvm_enabled()) {
-        tb_freq = kvmppc_get_tbfreq();
-        clock_freq = kvmppc_get_clockfreq();
-    }
-
    qemu_fdt_setprop_cell(fdt, "/cpus/cpu@0", "clock-frequency", clock_freq); qemu_fdt_setprop_cell(fdt, "/cpus/cpu@0", "timebase-frequency",

hw/ppc/sam460ex.c +6 -0
@@ -283,6 +274,12 @@ static void sam460ex_init(MachineState *machine)
     uint8_t *spd_data;
     int success;
 
+    if (kvm_enabled()) {
+        error_report("machine %s does not support the KVM accelerator",
+                     MACHINE_GET_CLASS(machine)->name);
+        exit(EXIT_FAILURE);
+    }
+
     cpu = POWERPC_CPU(cpu_create(machine->cpu_type));
     env = &cpu->env;
     if (env->mmu_model != POWERPC_MMU_BOOKE) {
#22 lore raw

PATCH 7/9 ppc/bamboo: Report an error when run with KVM

In reply to Cédric Le Goater

The 'bamboo' machine was used as a KVM platform in the early days (~2008). It clearly doesn't support it anymore.

---
 hw/ppc/ppc440_bamboo.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)
hw/ppc/ppc440_bamboo.c +6 -11
index f969fa3c29ca..f061b8cf3ba3 100644
@@ -19,7 +19,6 @@
 #include "hw/pci/pci.h"
 #include "hw/boards.h"
 #include "sysemu/kvm.h"
-#include "kvm_ppc.h"
 #include "sysemu/device_tree.h"
 #include "hw/loader.h"
 #include "elf.h"
@@ -97,16 +96,6 @@ static int bamboo_load_device_tree(MachineState *machine,
         fprintf(stderr, "couldn't set /chosen/bootargs\n");
     }
 
-    /*
-     * Copy data from the host device tree into the guest. Since the guest can
-     * directly access the timebase without host involvement, we must expose
-     * the correct frequencies.
-     */
-    if (kvm_enabled()) {
-        tb_freq = kvmppc_get_tbfreq();
-        clock_freq = kvmppc_get_clockfreq();
-    }
-
     qemu_fdt_setprop_cell(fdt, "/cpus/cpu@0", "clock-frequency",
                           clock_freq);
     qemu_fdt_setprop_cell(fdt, "/cpus/cpu@0", "timebase-frequency",
@@ -175,6 +164,12 @@ static void bamboo_init(MachineState *machine)
     int success;
     int i;
 
+    if (kvm_enabled()) {
+        error_report("machine %s does not support the KVM accelerator",
+                     MACHINE_GET_CLASS(machine)->name);
+        exit(EXIT_FAILURE);
+    }
+
     cpu = POWERPC_CPU(cpu_create(machine->cpu_type));
     env = &cpu->env;
 
Signature · 1 line
2.41.0
#24 lore raw

PATCH 8/9 ppc/pnv: Rephrase error when run with KVM

In reply to Cédric Le Goater
---
 hw/ppc/pnv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/ppc/pnv.c +2 -1
index 590fc64b32e9..fc083173f346 100644
@@ -799,7 +799,8 @@ static void pnv_init(MachineState *machine)
     DeviceState *dev;
 
     if (kvm_enabled()) {
-        error_report("The powernv machine does not work with KVM acceleration");
+        error_report("machine %s does not support the KVM accelerator",
+                     mc->name);
         exit(EXIT_FAILURE);
     }
 
Signature · 1 line
2.41.0
Reviewed-by on v1 8/9
#26 lore raw

Re: [PATCH 8/9] ppc/pnv: Rephrase error when run with KVM

In reply to Cédric Le Goater
Quoted 10 lines · Cédric Le Goater
---
  hw/ppc/pnv.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
hw/ppc/pnv.c +0 -0
index 590fc64b32e9..fc083173f346 100644

hw/ppc/pnv.c static void pnv_init(MachineState *machine) · line 806

Quoted 9 lines
hw/ppc/pnv.c +2 -1
@@ -799,7 +799,8 @@ static void pnv_init(MachineState *machine)
      DeviceState *dev;
 
      if (kvm_enabled()) {
-        error_report("The powernv machine does not work with KVM acceleration");
+        error_report("machine %s does not support the KVM accelerator",
+                     mc->name);
          exit(EXIT_FAILURE);
      }
 

Now thinking loudly, we could have an array of allowed accelerators in MachineClass, similarly to allowed_dynamic_sysbus_devices[], then handle this generically.

#27 lore raw

Re: [SPAM] Re: [PATCH 8/9] ppc/pnv: Rephrase error when run with KVM

Quoted 21 lines · Philippe Mathieu-Daudé
Quoted 10 lines · Cédric Le Goater

---
  hw/ppc/pnv.c | 3 ++-

  1 file changed, 2 insertions(+), 1 deletion(-)
hw/ppc/pnv.c +0 -0
index 590fc64b32e9..fc083173f346 100644

hw/ppc/pnv.c static void pnv_init(MachineState *machine) · line 804

Quoted 7 lines
hw/ppc/pnv.c +2 -1
@@ -799,7 +799,8 @@ static void pnv_init(MachineState *machine)
       DeviceState *dev;
       if (kvm_enabled()) {
-        error_report("The powernv machine does not work with KVM acceleration");
+        error_report("machine %s does not support the KVM accelerator",
+                     mc->name);
           exit(EXIT_FAILURE);
       }
Quoted 3 lines

Now thinking loudly, we could have an array of allowed accelerators in MachineClass, similarly to allowed_dynamic_sysbus_devices[], then handle this generically.

I agree. I had something like that in mind as a followup.

C.

#28 lore raw

PATCH 9/9 target/ppc: Fix timer register accessors when !KVM

In reply to Cédric Le Goater

When the Timer Control and Timer Status registers are modified, avoid calling the KVM backend when not available

---
 target/ppc/kvm.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
target/ppc/kvm.c +12 -0
index a7f2de9d1018..a8a935e26726 100644
@@ -1728,6 +1728,10 @@ int kvmppc_or_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits)
         .addr = (uintptr_t) &bits,
     };
 
+    if (!kvm_enabled()) {
+        return 0;
+    }
+
     return kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &reg);
 }
 
@@ -1741,6 +1745,10 @@ int kvmppc_clear_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits)
         .addr = (uintptr_t) &bits,
     };
 
+    if (!kvm_enabled()) {
+        return 0;
+    }
+
     return kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &reg);
 }
 
@@ -1755,6 +1763,10 @@ int kvmppc_set_tcr(PowerPCCPU *cpu)
         .addr = (uintptr_t) &tcr,
     };
 
+    if (!kvm_enabled()) {
+        return 0;
+    }
+
     return kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &reg);
 }
 
Signature · 1 line
2.41.0
#29 lore raw

Re: [PATCH 9/9] target/ppc: Fix timer register accessors when !KVM

Quoted 13 lines · Cédric Le Goater

When the Timer Control and Timer Status registers are modified, avoid calling the KVM backend when not available

---
  target/ppc/kvm.c | 12 ++++++++++++
  1 file changed, 12 insertions(+)
target/ppc/kvm.c +0 -0
index a7f2de9d1018..a8a935e26726 100644

target/ppc/kvm.c int kvmppc_or_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits) · line 1733

Quoted 6 lines
target/ppc/kvm.c +3 -0
@@ -1728,6 +1728,10 @@ int kvmppc_or_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits)
          .addr = (uintptr_t) &bits,
      };
 
+    if (!kvm_enabled()) {
+        return 0;
+    }

assert(kvm_enabled()) ?

r~

#30 lore raw

Re: [PATCH 9/9] target/ppc: Fix timer register accessors when !KVM

Quoted 9 lines · Richard Henderson
Quoted 8 lines · Cédric Le Goater

When the Timer Control and Timer Status registers are modified, avoid calling the KVM backend when not available

---
  target/ppc/kvm.c | 12 ++++++++++++

  1 file changed, 12 insertions(+)
Quoted 13 lines

target/ppc/kvm.c int kvmppc_or_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits) · line 1732

Quoted 10 lines
target/ppc/kvm.c +3 -0
index a7f2de9d1018..a8a935e26726 100644
@@ -1728,6 +1728,10 @@ int kvmppc_or_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits)
           .addr = (uintptr_t) &bits,
       };
+    if (!kvm_enabled()) {
+        return 0;
+    }

assert(kvm_enabled()) ?

Well, the callers store_booke_t[cs]r() can be called from instruction implementation and from the timer reset handler, which is common to all accelerators.

This is only important when running some of the emulated BookE machines on a PPC64 host, which enables KVM. This is not the most common host config but nevertheless, the machines should run and this fixes it.

Thanks,

C.

author Applied
#31 lore raw
In reply to Cédric Le Goater
Quoted 22 lines · Cédric Le Goater

Hello,

Please welcome new reviewers on baremetal POWER systems !

Follow cleanups to report an error when KVM is used on non-KVM machines.

Thanks,

C.

Cédric Le Goater (9):
MAINTAINERS: Add reviewers for PowerNV baremetal emulation
MAINTAINERS: Add reviewer for PowerPC TCG CPUs
MAINTAINERS: Add reviewer for XIVE
ppc/prep: Report an error when run with KVM ppc/pegasos2: Report an error when run with KVM ppc/sam460ex: Report an error when run with KVM ppc/bamboo: Report an error when run with KVM ppc/pnv: Rephrase error when run with KVM target/ppc: Fix timer register accessors when !KVM

Quoted 9 lines
  MAINTAINERS            |  4 ++++
  hw/ppc/pegasos2.c      |  7 ++++++-
  hw/ppc/pnv.c           |  3 ++-
  hw/ppc/ppc440_bamboo.c | 17 ++++++-----------
  hw/ppc/prep.c          | 20 +++++++-------------
  hw/ppc/sam460ex.c      | 15 ++++++---------
  target/ppc/kvm.c       | 12 ++++++++++++
  7 files changed, 43 insertions(+), 35 deletions(-)

Applied to ppc-next, without the sam460ex and pegasos2 changes as requested by Zoltan.

Thanks,

C.