Skip to contentSkip to conversation

target/ppc: regression fixes

PATCH In review Nicholas Piggin 2 participants 4 messages Mar 31, 2025

lore
Share & tools
lore
#0 lore raw

cover target/ppc: regression fixes

Couple of minor regression fixes for powernv registers. Minor because they aren't bad enough to affect Skiboot/Linux (PowerVM makes more use of these).

Thanks,
Nick

Nicholas Piggin (2):
target/ppc: Big-core scratch register fix
target/ppc: Fix SPRC/SPRD SPRs for P9/10

 target/ppc/cpu_init.c    | 23 ++++++++++++-----------
 target/ppc/misc_helper.c |  9 ++++++++-
 2 files changed, 20 insertions(+), 12 deletions(-)
Signature · 1 line
2.47.1
#1 lore raw

PATCH 1/2 target/ppc: Big-core scratch register fix

The per-core SCRATCH0-7 registers are shared between big cores, which was missed in the big-core implementation. It is difficult to model well with the big-core == 2xPnvCore scheme we moved to, this fix uses the even PnvCore to store the scrach data.

Also remove a stray log message that came in with the same patch that introduced patch.

Fixes c26504afd5f5c ("ppc/pnv: Add a big-core mode that joins two regular cores")
---
 target/ppc/misc_helper.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
target/ppc/misc_helper.c +8 -1
index 2d9512c116b..46ae454afd3 100644
@@ -332,6 +332,10 @@ target_ulong helper_load_sprd(CPUPPCState *env)
     PnvCore *pc = pnv_cpu_state(cpu)->pnv_core;
     target_ulong sprc = env->spr[SPR_POWER_SPRC];
 
+    if (pc->big_core) {
+        pc = pnv_chip_find_core(pc->chip, CPU_CORE(pc)->core_id & ~0x1);
+    }
+
     switch (sprc & 0x3e0) {
     case 0: /* SCRATCH0-3 */
     case 1: /* SCRATCH4-7 */
@@ -368,6 +372,10 @@ void helper_store_sprd(CPUPPCState *env, target_ulong val)
     PnvCore *pc = pnv_cpu_state(cpu)->pnv_core;
     int nr;
 
+    if (pc->big_core) {
+        pc = pnv_chip_find_core(pc->chip, CPU_CORE(pc)->core_id & ~0x1);
+    }
+
     switch (sprc & 0x3e0) {
     case 0: /* SCRATCH0-3 */
     case 1: /* SCRATCH4-7 */
@@ -378,7 +386,6 @@ void helper_store_sprd(CPUPPCState *env, target_ulong val)
          * information. Could also dump these upon checkstop.
          */
         nr = (sprc >> 3) & 0x7;
-        qemu_log("SPRD write 0x" TARGET_FMT_lx " to SCRATCH%d\n", val, nr);
         pc->scratch[nr] = val;
         break;
     default:
Signature · 1 line
2.47.1
#2 lore raw

PATCH 2/2 target/ppc: Fix SPRC/SPRD SPRs for P9/10

In reply to Nicholas Piggin

Commit 60d30cff847 ("target/ppc: Move SPR indirect registers into PnvCore") was mismerged and moved the SPRs to power8-only, instead of power9/10-only.

Fixes 60d30cff847 ("target/ppc: Move SPR indirect registers into PnvCore")
---
 target/ppc/cpu_init.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)
target/ppc/cpu_init.c +12 -11
index 7decc09aec8..f81cb680fc3 100644
@@ -5801,6 +5801,18 @@ static void register_power9_book4_sprs(CPUPPCState *env)
                  &spr_read_generic, &spr_write_generic,
                  &spr_read_generic, &spr_write_generic,
                  0x00000000);
+
+    /* SPRC/SPRD exist in earlier CPUs but only tested on POWER9/10 */
+    spr_register_hv(env, SPR_POWER_SPRC, "SPRC",
+                 SPR_NOACCESS, SPR_NOACCESS,
+                 SPR_NOACCESS, SPR_NOACCESS,
+                 &spr_read_generic, &spr_write_sprc,
+                 0x00000000);
+    spr_register_hv(env, SPR_POWER_SPRD, "SPRD",
+                 SPR_NOACCESS, SPR_NOACCESS,
+                 SPR_NOACCESS, SPR_NOACCESS,
+                 &spr_read_sprd, &spr_write_sprd,
+                 0x00000000);
 #endif
 }
 
@@ -5822,17 +5834,6 @@ static void register_power8_book4_sprs(CPUPPCState *env)
                      SPR_NOACCESS, SPR_NOACCESS,
                      &spr_read_generic, &spr_write_generic,
                      KVM_REG_PPC_WORT, 0);
-    /* SPRC/SPRD exist in earlier CPUs but only tested on POWER9/10 */
-    spr_register_hv(env, SPR_POWER_SPRC, "SPRC",
-                 SPR_NOACCESS, SPR_NOACCESS,
-                 SPR_NOACCESS, SPR_NOACCESS,
-                 &spr_read_generic, &spr_write_sprc,
-                 0x00000000);
-    spr_register_hv(env, SPR_POWER_SPRD, "SPRD",
-                 SPR_NOACCESS, SPR_NOACCESS,
-                 SPR_NOACCESS, SPR_NOACCESS,
-                 &spr_read_sprd, &spr_write_sprd,
-                 0x00000000);
 #endif
 }
 
Signature · 1 line
2.47.1
Reviewed-by on v1 2/2
#3 lore raw

Re: [PATCH 2/2] target/ppc: Fix SPRC/SPRD SPRs for P9/10

Quoted 10 lines · Nicholas Piggin

Commit 60d30cff847 ("target/ppc: Move SPR indirect registers into PnvCore") was mismerged and moved the SPRs to power8-only, instead of power9/10-only.

Fixes 60d30cff847 ("target/ppc: Move SPR indirect registers into PnvCore")
---
  target/ppc/cpu_init.c | 23 ++++++++++++-----------
  1 file changed, 12 insertions(+), 11 deletions(-)