Skip to contentSkip to conversation

hw/ppc/e500: Check for compatible CPU type instead of aborting ungracefully

PATCH Applied Thomas Huth 5 participants 5 messages Oct 15, 2025 – Oct 22, 2025

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 hw/ppc/e500: Check for compatible CPU type instead of aborting ungracefully

From: Thomas Huth <[email protected]>

When using the ppce500 machine with an embedded CPU type that has the right MMU model, but is not part of the e500 CPU family, QEMU currently aborts ungracefully:

 $ ./qemu-system-ppc -machine ppce500 -cpu e200z5 -nographic
 qemu-system-ppc: ../qemu/hw/core/gpio.c:108: qdev_get_gpio_in_named:
  Assertion `n >= 0 && n < gpio_list->num_in' failed.
 Aborted (core dumped)

The ppce500 machine expects a CPU with certain GPIO interrupt pins, so let's replace the coarse check for the MMU_BOOKE206 model with a more precise check that only allows CPUs from the e500 family.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3162

---
v2: Drop the old check for the MMU_BOOKE206 model

 hw/ppc/e500.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
hw/ppc/e500.c +3 -3
index 723c97fad2e..3d69428f31c 100644
@@ -20,6 +20,7 @@
 #include "qemu/guest-random.h"
 #include "exec/target_page.h"
 #include "qapi/error.h"
+#include "cpu-models.h"
 #include "e500.h"
 #include "e500-ccsr.h"
 #include "net/net.h"
@@ -942,9 +943,8 @@ void ppce500_init(MachineState *machine)
         env = &cpu->env;
         cs = CPU(cpu);
 
-        if (env->mmu_model != POWERPC_MMU_BOOKE206) {
-            error_report("MMU model %i not supported by this machine",
-                         env->mmu_model);
+        if (!(POWERPC_CPU_GET_CLASS(cpu)->svr & POWERPC_SVR_E500)) {
+            error_report("This machine needs a CPU from the e500 family");
             exit(1);
         }
 
Signature · 1 line
2.51.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 11 lines · Thomas Huth

From: Thomas Huth <[email protected]>

When using the ppce500 machine with an embedded CPU type that has the right MMU model, but is not part of the e500 CPU family, QEMU currently aborts ungracefully:

$ ./qemu-system-ppc -machine ppce500 -cpu e200z5 -nographic
qemu-system-ppc: ../qemu/hw/core/gpio.c:108: qdev_get_gpio_in_named:
 Assertion `n >= 0 && n < gpio_list->num_in' failed.
Aborted (core dumped)
Quoted 6 lines

The ppce500 machine expects a CPU with certain GPIO interrupt pins, so let's replace the coarse check for the MMU_BOOKE206 model with a more precise check that only allows CPUs from the e500 family.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3162

Quoted 31 lines

---
v2: Drop the old check for the MMU_BOOKE206 model

hw/ppc/e500.c | 6 +++---

1 file changed, 3 insertions(+), 3 deletions(-)
hw/ppc/e500.c +3 -3
index 723c97fad2e..3d69428f31c 100644
@@ -20,6 +20,7 @@
 #include "qemu/guest-random.h"
 #include "exec/target_page.h"
 #include "qapi/error.h"
+#include "cpu-models.h"
 #include "e500.h"
 #include "e500-ccsr.h"
 #include "net/net.h"
@@ -942,9 +943,8 @@ void ppce500_init(MachineState *machine)
        env = &cpu->env;
        cs = CPU(cpu);
 
-        if (env->mmu_model != POWERPC_MMU_BOOKE206) {
-            error_report("MMU model %i not supported by this machine",
-                         env->mmu_model);
+        if (!(POWERPC_CPU_GET_CLASS(cpu)->svr & POWERPC_SVR_E500)) {
+            error_report("This machine needs a CPU from the e500 family");
            exit(1);
        }
 
Acked-by on v2 1/1
#2 lore raw
In reply to Thomas Huth

Am 15. Oktober 2025 11:12:43 UTC schrieb Thomas Huth <[email protected]>:

Quoted 11 lines

From: Thomas Huth <[email protected]>

When using the ppce500 machine with an embedded CPU type that has the right MMU model, but is not part of the e500 CPU family, QEMU currently aborts ungracefully:

$ ./qemu-system-ppc -machine ppce500 -cpu e200z5 -nographic
qemu-system-ppc: ../qemu/hw/core/gpio.c:108: qdev_get_gpio_in_named:
 Assertion `n >= 0 && n < gpio_list->num_in' failed.
Aborted (core dumped)
Quoted 6 lines

The ppce500 machine expects a CPU with certain GPIO interrupt pins, so let's replace the coarse check for the MMU_BOOKE206 model with a more precise check that only allows CPUs from the e500 family.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3162

Thanks for caring, Thomas!

Quoted 30 lines

---
v2: Drop the old check for the MMU_BOOKE206 model

hw/ppc/e500.c | 6 +++---

1 file changed, 3 insertions(+), 3 deletions(-)
hw/ppc/e500.c +3 -3
index 723c97fad2e..3d69428f31c 100644
@@ -20,6 +20,7 @@
 #include "qemu/guest-random.h"
 #include "exec/target_page.h"
 #include "qapi/error.h"
+#include "cpu-models.h"
 #include "e500.h"
 #include "e500-ccsr.h"
 #include "net/net.h"
@@ -942,9 +943,8 @@ void ppce500_init(MachineState *machine)
        env = &cpu->env;
        cs = CPU(cpu);
 
-        if (env->mmu_model != POWERPC_MMU_BOOKE206) {
-            error_report("MMU model %i not supported by this machine",
-                         env->mmu_model);
+        if (!(POWERPC_CPU_GET_CLASS(cpu)->svr & POWERPC_SVR_E500)) {
+            error_report("This machine needs a CPU from the e500 family");
            exit(1);
        }
 
Reviewed-by on v2 1/1
#3 lore raw
In reply to Thomas Huth
Quoted 36 lines · Thomas Huth

From: Thomas Huth <[email protected]>

When using the ppce500 machine with an embedded CPU type that has the right MMU model, but is not part of the e500 CPU family, QEMU currently aborts ungracefully:

  $ ./qemu-system-ppc -machine ppce500 -cpu e200z5 -nographic
  qemu-system-ppc: ../qemu/hw/core/gpio.c:108: qdev_get_gpio_in_named:
   Assertion `n >= 0 && n < gpio_list->num_in' failed.
  Aborted (core dumped)

The ppce500 machine expects a CPU with certain GPIO interrupt pins, so let's replace the coarse check for the MMU_BOOKE206 model with a more precise check that only allows CPUs from the e500 family.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3162

---
v2: Drop the old check for the MMU_BOOKE206 model

  hw/ppc/e500.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
hw/ppc/e500.c +1 -0
index 723c97fad2e..3d69428f31c 100644
@@ -20,6 +20,7 @@
  #include "qemu/guest-random.h"
  #include "exec/target_page.h"
  #include "qapi/error.h"
+#include "cpu-models.h"
  #include "e500.h"
  #include "e500-ccsr.h"
  #include "net/net.h"

hw/ppc/e500.c void ppce500_init(MachineState *machine) · line 948

Quoted 9 lines
hw/ppc/e500.c +2 -3
@@ -942,9 +943,8 @@ void ppce500_init(MachineState *machine)
          env = &cpu->env;
          cs = CPU(cpu);
 
-        if (env->mmu_model != POWERPC_MMU_BOOKE206) {
-            error_report("MMU model %i not supported by this machine",
-                         env->mmu_model);
+        if (!(POWERPC_CPU_GET_CLASS(cpu)->svr & POWERPC_SVR_E500)) {
+            error_report("This machine needs a CPU from the e500 family");
              exit(1);

This indeed seems to be more appropriate check than checking against mmu_model. Thanks to you and BALATON for catching this.

Quoted 2 lines
hw/ppc/e500.c +0 -0
          }
 
#4 lore raw
In reply to Thomas Huth
Quoted 15 lines · Thomas Huth

From: Thomas Huth <[email protected]>

When using the ppce500 machine with an embedded CPU type that has the right MMU model, but is not part of the e500 CPU family, QEMU currently aborts ungracefully:

  $ ./qemu-system-ppc -machine ppce500 -cpu e200z5 -nographic
  qemu-system-ppc: ../qemu/hw/core/gpio.c:108: qdev_get_gpio_in_named:
   Assertion `n >= 0 && n < gpio_list->num_in' failed.
  Aborted (core dumped)

The ppce500 machine expects a CPU with certain GPIO interrupt pins, so let's replace the coarse check for the MMU_BOOKE206 model with a more precise check that only allows CPUs from the e500 family.

Quoted 7 lines

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3162

---
v2: Drop the old check for the MMU_BOOKE206 model

  hw/ppc/e500.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)

Queued and merged, thanks!