Skip to contentSkip to conversation

target/ppc: Removal of the unusable e200 CPUs

PATCH In review Thomas Huth 3 participants 5 messages Oct 24, 2025

lore
Share & tools
lore
#1 lore raw

PATCH v2 1/2 target/ppc/cpu_init: Simplify the setup of the TLBxCFG SPR registers

In reply to Thomas Huth

From: Thomas Huth <[email protected]>

The next commit is going to remove init_proc_e200(), which is one of the two calling sites of register_BookE206_sprs(). This causes recent versions of GCC to inline the register_BookE206_sprs() function into the other only remaining calling site, init_proc_e500(), which in turn causes some false-positives compiler warnings:

In file included from ../../devel/qemu/target/ppc/cpu_init.c:46:
In function ‘register_BookE206_sprs’,

     inlined from ‘init_proc_e500’ at ../../devel/qemu/target/ppc/cpu_init.c:2910:5:
 ../../devel/qemu/target/ppc/cpu_init.c:897:29: error:
  array subscript 3 is outside array bounds of ‘uint32_t[2]’ {aka ‘unsigned int[2]’}
  [-Werror=array-bounds=]
   897 |                      tlbncfg[3]);
       |                      ~~~~~~~^~~
 ../../devel/qemu/target/ppc/spr_common.h:61:39: note: in definition of macro ‘spr_register_kvm_hv’
    61 |                   KVM_ARG(one_reg_id) initial_value)
       |                                       ^~~~~~~~~~~~~
 ../../devel/qemu/target/ppc/spr_common.h:77:5: note: in expansion of macro ‘spr_register_kvm’
    77 |     spr_register_kvm(env, num, name, uea_read, uea_write,                    \
       |     ^~~~~~~~~~~~~~~~
 ../../devel/qemu/target/ppc/cpu_init.c:894:9: note: in expansion of macro ‘spr_register’
   894 |         spr_register(env, SPR_BOOKE_TLB3CFG, "TLB3CFG",
       |         ^~~~~~~~~~~~
 ../../devel/qemu/target/ppc/cpu_init.c: In function ‘init_proc_e500’:
 ../../devel/qemu/target/ppc/cpu_init.c:2809:14: note: at offset 12 into object ‘tlbncfg’ of size 8
  2809 |     uint32_t tlbncfg[2];
       |              ^~~~~~~

cc1: all warnings being treated as errors

init_proc_e500() only defines "uint32_t tlbncfg[2];", but it is OK since it also sets "env->nb_ways = 2", so the code that GCC warns about in register_BookE206_sprs() is never reached. Unfortunately, GCC is not smart enough to see this, so it emits these warnings.

To fix it, let's simplify the code in register_BookE206_sprs() a little bit to set up the SPRs in a loop, so we don't reference the tlbncfg[3] entry directly anymore.

---
 target/ppc/cpu_init.c | 38 ++++++++++++--------------------------
 1 file changed, 12 insertions(+), 26 deletions(-)
target/ppc/cpu_init.c +12 -26
index 3aa3aefc136..12c645699e8 100644
@@ -850,6 +850,13 @@ static void register_BookE206_sprs(CPUPPCState *env, uint32_t mas_mask,
         SPR_BOOKE_MAS0, SPR_BOOKE_MAS1, SPR_BOOKE_MAS2, SPR_BOOKE_MAS3,
         SPR_BOOKE_MAS4, SPR_BOOKE_MAS5, SPR_BOOKE_MAS6, SPR_BOOKE_MAS7,
     };
+    const char *tlbcfg_names[4] = {
+        "TLB0CFG", "TLB1CFG", "TLB2CFG", "TLB3CFG",
+    };
+    const int tlbcfg_sprn[4] = {
+        SPR_BOOKE_TLB0CFG, SPR_BOOKE_TLB1CFG,
+        SPR_BOOKE_TLB2CFG, SPR_BOOKE_TLB3CFG,
+    };
     int i;
 
     /* TLB assist registers */
@@ -889,34 +896,13 @@ static void register_BookE206_sprs(CPUPPCState *env, uint32_t mas_mask,
                  SPR_NOACCESS, SPR_NOACCESS,
                  &spr_read_generic, SPR_NOACCESS,
                  mmucfg);
-    switch (env->nb_ways) {
-    case 4:
-        spr_register(env, SPR_BOOKE_TLB3CFG, "TLB3CFG",
-                     SPR_NOACCESS, SPR_NOACCESS,
-                     &spr_read_generic, SPR_NOACCESS,
-                     tlbncfg[3]);
-        /* Fallthru */
-    case 3:
-        spr_register(env, SPR_BOOKE_TLB2CFG, "TLB2CFG",
-                     SPR_NOACCESS, SPR_NOACCESS,
-                     &spr_read_generic, SPR_NOACCESS,
-                     tlbncfg[2]);
-        /* Fallthru */
-    case 2:
-        spr_register(env, SPR_BOOKE_TLB1CFG, "TLB1CFG",
-                     SPR_NOACCESS, SPR_NOACCESS,
-                     &spr_read_generic, SPR_NOACCESS,
-                     tlbncfg[1]);
-        /* Fallthru */
-    case 1:
-        spr_register(env, SPR_BOOKE_TLB0CFG, "TLB0CFG",
+
+    assert(env->nb_ways <= ARRAY_SIZE(tlbcfg_names));
+    for (i = 0; i < env->nb_ways; i++) {
+        spr_register(env, tlbcfg_sprn[i], tlbcfg_names[i],
                      SPR_NOACCESS, SPR_NOACCESS,
                      &spr_read_generic, SPR_NOACCESS,
-                     tlbncfg[0]);
-        /* Fallthru */
-    case 0:
-    default:
-        break;
+                     tlbncfg[i]);
     }
 #endif
 }
Signature · 1 line
2.51.0
#0 lore raw

v2 cover target/ppc: Removal of the unusable e200 CPUs

The second patch removes the unused e200 CPUs, see its patch description for the rationale.

Since the removal of the code causes GCC to inline another function, this suddenly triggered a false compiler warning, so we have to rework the related code first (see the first patch).

Thomas Huth (2):
target/ppc/cpu_init: Simplify the setup of the TLBxCFG SPR registers target/ppc: Remove the unusable e200 CPUs

 target/ppc/cpu-models.h |   4 -
 target/ppc/cpu-models.c |   5 --
 target/ppc/cpu_init.c   | 185 +++-------------------------------------
 3 files changed, 14 insertions(+), 180 deletions(-)
Signature · 1 line
2.51.0
#2 lore raw

PATCH v2 2/2 target/ppc: Remove the unusable e200 CPUs

From: Thomas Huth <[email protected]>

There is currently no machine in QEMU (except the "none" machine) that can be run with with one of the e200 ppc CPUs - all machines either complain about an invalid CPU type or crash QEMU immediately.

Looking at the history of this CPU type, it seems like it has never been used in QEMU and only implemented as a placeholder (see e.g. the comment about unimplemented instructions in the POWERPC_FAMILY(e200) section of cpu_init.c). Being completely unused and unusable since such a long time, let's just remove it now (without deprecation phase, since there were no users of this dead code anyway).

Note: The init_excp_e200() is used by the e500 CPUs, too, so we rename this function to init_excp_e500() instead of removing it.

---
 target/ppc/cpu-models.h |   4 --
 target/ppc/cpu-models.c |   5 --
 target/ppc/cpu_init.c   | 147 +---------------------------------------
 3 files changed, 2 insertions(+), 154 deletions(-)
target/ppc/cpu-models.h +0 -4
index c6cd27f390e..a439eb37ee4 100644
@@ -120,10 +120,6 @@ enum {
 #define CPU_POWERPC_MPC5200_v12      CPU_POWERPC_G2LEgp1
 #define CPU_POWERPC_MPC5200B_v20     CPU_POWERPC_G2LEgp1
 #define CPU_POWERPC_MPC5200B_v21     CPU_POWERPC_G2LEgp1
-    /* e200 family */
-    /* e200 cores */
-    CPU_POWERPC_e200z5             = 0x81000000,
-    CPU_POWERPC_e200z6             = 0x81120000,
     /* e300 family */
     /* e300 cores */
     CPU_POWERPC_e300c1             = 0x00830010,
target/ppc/cpu-models.c +0 -5
index 89ae763c7f6..26b6debcfc9 100644
@@ -244,11 +244,6 @@
                     CPU_POWERPC_MPC5200B_v20, POWERPC_SVR_5200B_v20, G2LE)
     POWERPC_DEF_SVR("mpc5200b_v21", "MPC5200B v2.1",
                     CPU_POWERPC_MPC5200B_v21, POWERPC_SVR_5200B_v21, G2LE)
-    /* e200 family                                                           */
-    POWERPC_DEF("e200z5",        CPU_POWERPC_e200z5,                 e200,
-                "PowerPC e200z5 core")
-    POWERPC_DEF("e200z6",        CPU_POWERPC_e200z6,                 e200,
-                "PowerPC e200z6 core")
     /* e300 family                                                           */
     POWERPC_DEF("e300c1",        CPU_POWERPC_e300c1,                 e300,
                 "PowerPC e300c1 core")
target/ppc/cpu_init.c +2 -145

165 lines not on this page · raw message

Signature · 1 line
2.51.0
Reviewed-by on v2 2/2
#3 lore raw

Re: [PATCH v2 2/2] target/ppc: Remove the unusable e200 CPUs

Quoted 16 lines · Thomas Huth

From: Thomas Huth <[email protected]>

There is currently no machine in QEMU (except the "none" machine) that can be run with with one of the e200 ppc CPUs - all machines either complain about an invalid CPU type or crash QEMU immediately.

Looking at the history of this CPU type, it seems like it has never been used in QEMU and only implemented as a placeholder (see e.g. the comment about unimplemented instructions in the POWERPC_FAMILY(e200) section of cpu_init.c). Being completely unused and unusable since such a long time, let's just remove it now (without deprecation phase, since there were no users of this dead code anyway).

Note: The init_excp_e200() is used by the e500 CPUs, too, so we rename this function to init_excp_e500() instead of removing it.

Quoted 7 lines
---
  target/ppc/cpu-models.h |   4 --
  target/ppc/cpu-models.c |   5 --
  target/ppc/cpu_init.c   | 147 +---------------------------------------
  3 files changed, 2 insertions(+), 154 deletions(-)
#4 lore raw
In reply to Thomas Huth
Quoted 7 lines · Thomas Huth

The second patch removes the unused e200 CPUs, see its patch description for the rationale.

Since the removal of the code causes GCC to inline another function, this suddenly triggered a false compiler warning, so we have to rework the related code first (see the first patch).

Quoted 9 lines

Thomas Huth (2):
target/ppc/cpu_init: Simplify the setup of the TLBxCFG SPR registers target/ppc: Remove the unusable e200 CPUs

  target/ppc/cpu-models.h |   4 -
  target/ppc/cpu-models.c |   5 --
  target/ppc/cpu_init.c   | 185 +++-------------------------------------
  3 files changed, 14 insertions(+), 180 deletions(-)

Queued.