qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PULL 00/10] ppc queue
@ 2023-05-28 16:49 Daniel Henrique Barboza
  2023-05-28 16:49 ` [PULL 01/10] target/ppc: Fix fallback to MFSS for MFFS* instructions on pre 3.0 ISAs Daniel Henrique Barboza
                   ` (11 more replies)
  0 siblings, 12 replies; 19+ messages in thread
From: Daniel Henrique Barboza @ 2023-05-28 16:49 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-ppc, danielhb413, peter.maydell, richard.henderson

The following changes since commit ac84b57b4d74606f7f83667a0606deef32b2049d:

  Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging (2023-05-26 14:40:55 -0700)

are available in the Git repository at:

  https://gitlab.com/danielhb/qemu.git tags/pull-ppc-20230528

for you to fetch changes up to 56b8bfe9bb6b94184b8bbfc4be9196404a81e450:

  ppc/pegasos2: Change default CPU to 7457 (2023-05-28 13:25:45 -0300)

----------------------------------------------------------------
ppc patch queue for 2023-05-28:

This queue includes several assorted fixes for PowerPC SPR
emulation, a change in the default Pegasos2 CPU, the addition
of AIL mode 3 for spapr, a PIC->CPU interrupt fix for prep and
performance enhancements in fpu_helper.c.

----------------------------------------------------------------
Alexander Bulekov (1):
      pnv_lpc: disable reentrancy detection for lpc-hc

BALATON Zoltan (1):
      ppc/pegasos2: Change default CPU to 7457

Bernhard Beschow (1):
      hw/ppc/prep: Fix wiring of PIC -> CPU interrupt

Nicholas Piggin (5):
      target/ppc: Fix width of some 32-bit SPRs
      target/ppc: Alignment faults do not set DSISR in ISA v3.0 onward
      spapr: Add SPAPR_CAP_AIL_MODE_3 for AIL mode 3 support for H_SET_MODE hcall
      target/ppc: Use SMT4 small core chip type in POWER9/10 PVRs
      target/ppc: Add POWER9 DD2.2 model

Richard Henderson (1):
      target/ppc: Merge COMPUTE_CLASS and COMPUTE_FPRF

Richard Purdie (1):
      target/ppc: Fix fallback to MFSS for MFFS* instructions on pre 3.0 ISAs

 hw/ppc/pegasos2.c                  |  2 +-
 hw/ppc/pnv.c                       |  2 +-
 hw/ppc/pnv_core.c                  |  2 +-
 hw/ppc/pnv_lpc.c                   |  3 ++
 hw/ppc/prep.c                      |  4 +-
 hw/ppc/spapr.c                     |  9 ++++-
 hw/ppc/spapr_caps.c                | 37 ++++++++++++++++++
 hw/ppc/spapr_cpu_core.c            |  1 +
 hw/ppc/spapr_hcall.c               | 24 ++++++------
 include/hw/ppc/pnv.h               |  2 +-
 include/hw/ppc/spapr.h             |  4 +-
 target/ppc/cpu-models.c            |  4 +-
 target/ppc/cpu-models.h            |  7 ++--
 target/ppc/cpu_init.c              | 39 +++++++++++++------
 target/ppc/excp_helper.c           | 17 +++++----
 target/ppc/fpu_helper.c            | 78 +++++++++++---------------------------
 target/ppc/helper_regs.c           |  2 +-
 target/ppc/insn32.decode           | 20 ++++++----
 target/ppc/kvm.c                   |  7 ++++
 target/ppc/kvm_ppc.h               |  6 +++
 target/ppc/misc_helper.c           |  4 +-
 target/ppc/power8-pmu.c            |  2 +-
 target/ppc/spr_common.h            |  2 +-
 target/ppc/translate.c             | 26 ++++++-------
 target/ppc/translate/fp-impl.c.inc | 22 ++++++++---
 tests/qtest/device-plug-test.c     |  4 +-
 26 files changed, 201 insertions(+), 129 deletions(-)


^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PULL 01/10] target/ppc: Fix fallback to MFSS for MFFS* instructions on pre 3.0 ISAs
  2023-05-28 16:49 [PULL 00/10] ppc queue Daniel Henrique Barboza
@ 2023-05-28 16:49 ` Daniel Henrique Barboza
  2023-05-28 16:49 ` [PULL 02/10] target/ppc: Fix width of some 32-bit SPRs Daniel Henrique Barboza
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 19+ messages in thread
From: Daniel Henrique Barboza @ 2023-05-28 16:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-ppc, danielhb413, peter.maydell, richard.henderson,
	Richard Purdie, Matheus Ferst

From: Richard Purdie <richard.purdie@linuxfoundation.org>

The following commits changed the code such that the fallback to MFSS for MFFSCRN,
MFFSCRNI, MFFSCE and MFFSL on pre 3.0 ISAs was removed and became an illegal instruction:

  bf8adfd88b547680aa857c46098f3a1e94373160 - target/ppc: Move mffscrn[i] to decodetree
  394c2e2fda70da722f20fb60412d6c0ca4bfaa03 - target/ppc: Move mffsce to decodetree
  3e5bce70efe6bd1f684efbb21fd2a316cbf0657e - target/ppc: Move mffsl to decodetree

The hardware will handle them as a MFFS instruction as the code did previously.
This means applications that were segfaulting under qemu when encountering these
instructions which is used in glibc libm functions for example.

The fallback for MFFSCDRN and MFFSCDRNI added in a later patch was also missing.

This patch restores the fallback to MFSS for these instructions on pre 3.0s ISAs
as the hardware decoder would, fixing the segfaulting libm code. It doesn't have
the fallback for 3.0 onwards to match hardware behaviour.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Reviewed-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20230510111913.1718734-1-richard.purdie@linuxfoundation.org>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 target/ppc/insn32.decode           | 20 +++++++++++++-------
 target/ppc/translate/fp-impl.c.inc | 22 ++++++++++++++++------
 2 files changed, 29 insertions(+), 13 deletions(-)

diff --git a/target/ppc/insn32.decode b/target/ppc/insn32.decode
index f8f589e9fd..4fcf3af8d0 100644
--- a/target/ppc/insn32.decode
+++ b/target/ppc/insn32.decode
@@ -390,13 +390,19 @@ SETNBCR         011111 ..... ..... ----- 0111100000 -   @X_bi
 
 ### Move To/From FPSCR
 
-MFFS            111111 ..... 00000 ----- 1001000111 .   @X_t_rc
-MFFSCE          111111 ..... 00001 ----- 1001000111 -   @X_t
-MFFSCRN         111111 ..... 10110 ..... 1001000111 -   @X_tb
-MFFSCDRN        111111 ..... 10100 ..... 1001000111 -   @X_tb
-MFFSCRNI        111111 ..... 10111 ---.. 1001000111 -   @X_imm2
-MFFSCDRNI       111111 ..... 10101 --... 1001000111 -   @X_imm3
-MFFSL           111111 ..... 11000 ----- 1001000111 -   @X_t
+{
+  # Before Power ISA v3.0, MFFS bits 11~15 were reserved and should be ignored
+  MFFS_ISA207     111111 ..... ----- ----- 1001000111 .   @X_t_rc
+  [
+    MFFS            111111 ..... 00000 ----- 1001000111 .   @X_t_rc
+    MFFSCE          111111 ..... 00001 ----- 1001000111 -   @X_t
+    MFFSCRN         111111 ..... 10110 ..... 1001000111 -   @X_tb
+    MFFSCDRN        111111 ..... 10100 ..... 1001000111 -   @X_tb
+    MFFSCRNI        111111 ..... 10111 ---.. 1001000111 -   @X_imm2
+    MFFSCDRNI       111111 ..... 10101 --... 1001000111 -   @X_imm3
+    MFFSL           111111 ..... 11000 ----- 1001000111 -   @X_t
+  ]
+}
 
 ### Decimal Floating-Point Arithmetic Instructions
 
diff --git a/target/ppc/translate/fp-impl.c.inc b/target/ppc/translate/fp-impl.c.inc
index 57d8437851..874774eade 100644
--- a/target/ppc/translate/fp-impl.c.inc
+++ b/target/ppc/translate/fp-impl.c.inc
@@ -568,6 +568,22 @@ static void store_fpscr_masked(TCGv_i64 fpscr, uint64_t clear_mask,
     gen_helper_store_fpscr(cpu_env, fpscr_masked, st_mask);
 }
 
+static bool trans_MFFS_ISA207(DisasContext *ctx, arg_X_t_rc *a)
+{
+    if (!(ctx->insns_flags2 & PPC2_ISA300)) {
+        /*
+         * Before Power ISA v3.0, MFFS bits 11~15 were reserved, any instruction
+         * with OPCD=63 and XO=583 should be decoded as MFFS.
+         */
+        return trans_MFFS(ctx, a);
+    }
+    /*
+     * For Power ISA v3.0+, return false and let the pattern group
+     * select the correct instruction.
+     */
+    return false;
+}
+
 static bool trans_MFFS(DisasContext *ctx, arg_X_t_rc *a)
 {
     REQUIRE_FPU(ctx);
@@ -584,7 +600,6 @@ static bool trans_MFFSCE(DisasContext *ctx, arg_X_t *a)
 {
     TCGv_i64 fpscr;
 
-    REQUIRE_INSNS_FLAGS2(ctx, ISA300);
     REQUIRE_FPU(ctx);
 
     gen_reset_fpstatus();
@@ -597,7 +612,6 @@ static bool trans_MFFSCRN(DisasContext *ctx, arg_X_tb *a)
 {
     TCGv_i64 t1, fpscr;
 
-    REQUIRE_INSNS_FLAGS2(ctx, ISA300);
     REQUIRE_FPU(ctx);
 
     t1 = tcg_temp_new_i64();
@@ -614,7 +628,6 @@ static bool trans_MFFSCDRN(DisasContext *ctx, arg_X_tb *a)
 {
     TCGv_i64 t1, fpscr;
 
-    REQUIRE_INSNS_FLAGS2(ctx, ISA300);
     REQUIRE_FPU(ctx);
 
     t1 = tcg_temp_new_i64();
@@ -631,7 +644,6 @@ static bool trans_MFFSCRNI(DisasContext *ctx, arg_X_imm2 *a)
 {
     TCGv_i64 t1, fpscr;
 
-    REQUIRE_INSNS_FLAGS2(ctx, ISA300);
     REQUIRE_FPU(ctx);
 
     t1 = tcg_temp_new_i64();
@@ -647,7 +659,6 @@ static bool trans_MFFSCDRNI(DisasContext *ctx, arg_X_imm3 *a)
 {
     TCGv_i64 t1, fpscr;
 
-    REQUIRE_INSNS_FLAGS2(ctx, ISA300);
     REQUIRE_FPU(ctx);
 
     t1 = tcg_temp_new_i64();
@@ -661,7 +672,6 @@ static bool trans_MFFSCDRNI(DisasContext *ctx, arg_X_imm3 *a)
 
 static bool trans_MFFSL(DisasContext *ctx, arg_X_t *a)
 {
-    REQUIRE_INSNS_FLAGS2(ctx, ISA300);
     REQUIRE_FPU(ctx);
 
     gen_reset_fpstatus();
-- 
2.40.1



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PULL 02/10] target/ppc: Fix width of some 32-bit SPRs
  2023-05-28 16:49 [PULL 00/10] ppc queue Daniel Henrique Barboza
  2023-05-28 16:49 ` [PULL 01/10] target/ppc: Fix fallback to MFSS for MFFS* instructions on pre 3.0 ISAs Daniel Henrique Barboza
@ 2023-05-28 16:49 ` Daniel Henrique Barboza
  2023-05-28 16:49 ` [PULL 03/10] target/ppc: Alignment faults do not set DSISR in ISA v3.0 onward Daniel Henrique Barboza
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 19+ messages in thread
From: Daniel Henrique Barboza @ 2023-05-28 16:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-ppc, danielhb413, peter.maydell, richard.henderson,
	Nicholas Piggin, Harsh Prateek Bora

From: Nicholas Piggin <npiggin@gmail.com>

Some 32-bit SPRs are incorrectly implemented as 64-bits on 64-bit
targets.

This changes VRSAVE, DSISR, HDSISR, DAWRX0, PIDR, LPIDR, DEXCR,
HDEXCR, CTRL, TSCR, MMCRH, and PMC[1-6] from to be 32-bit registers.

This only goes by the 32/64 classification in the architecture, it
does not try to implement finer details of SPR implementation (e.g.,
not all bits implemented as simple read/write storage).

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
Message-Id: <20230515092655.171206-2-npiggin@gmail.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 target/ppc/cpu_init.c    | 18 +++++++++---------
 target/ppc/helper_regs.c |  2 +-
 target/ppc/misc_helper.c |  4 ++--
 target/ppc/power8-pmu.c  |  2 +-
 target/ppc/spr_common.h  |  2 +-
 target/ppc/translate.c   | 26 +++++++++++++-------------
 6 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
index 0ce2e3c91d..5aa0b3f0f1 100644
--- a/target/ppc/cpu_init.c
+++ b/target/ppc/cpu_init.c
@@ -5085,8 +5085,8 @@ static void register_book3s_altivec_sprs(CPUPPCState *env)
     }
 
     spr_register_kvm(env, SPR_VRSAVE, "VRSAVE",
-                     &spr_read_generic, &spr_write_generic,
-                     &spr_read_generic, &spr_write_generic,
+                     &spr_read_generic, &spr_write_generic32,
+                     &spr_read_generic, &spr_write_generic32,
                      KVM_REG_PPC_VRSAVE, 0x00000000);
 
 }
@@ -5120,7 +5120,7 @@ static void register_book3s_207_dbg_sprs(CPUPPCState *env)
     spr_register_kvm_hv(env, SPR_DAWRX0, "DAWRX0",
                         SPR_NOACCESS, SPR_NOACCESS,
                         SPR_NOACCESS, SPR_NOACCESS,
-                        &spr_read_generic, &spr_write_generic,
+                        &spr_read_generic, &spr_write_generic32,
                         KVM_REG_PPC_DAWRX, 0x00000000);
     spr_register_kvm_hv(env, SPR_CIABR, "CIABR",
                         SPR_NOACCESS, SPR_NOACCESS,
@@ -5376,7 +5376,7 @@ static void register_book3s_ids_sprs(CPUPPCState *env)
     spr_register_hv(env, SPR_TSCR, "TSCR",
                  SPR_NOACCESS, SPR_NOACCESS,
                  SPR_NOACCESS, SPR_NOACCESS,
-                 &spr_read_generic, &spr_write_generic,
+                 &spr_read_generic, &spr_write_generic32,
                  0x00000000);
     spr_register_hv(env, SPR_HMER, "HMER",
                  SPR_NOACCESS, SPR_NOACCESS,
@@ -5406,7 +5406,7 @@ static void register_book3s_ids_sprs(CPUPPCState *env)
     spr_register_hv(env, SPR_MMCRC, "MMCRC",
                  SPR_NOACCESS, SPR_NOACCESS,
                  SPR_NOACCESS, SPR_NOACCESS,
-                 &spr_read_generic, &spr_write_generic,
+                 &spr_read_generic, &spr_write_generic32,
                  0x00000000);
     spr_register_hv(env, SPR_MMCRH, "MMCRH",
                  SPR_NOACCESS, SPR_NOACCESS,
@@ -5441,7 +5441,7 @@ static void register_book3s_ids_sprs(CPUPPCState *env)
     spr_register_hv(env, SPR_HDSISR, "HDSISR",
                  SPR_NOACCESS, SPR_NOACCESS,
                  SPR_NOACCESS, SPR_NOACCESS,
-                 &spr_read_generic, &spr_write_generic,
+                 &spr_read_generic, &spr_write_generic32,
                  0x00000000);
     spr_register_hv(env, SPR_HRMOR, "HRMOR",
                  SPR_NOACCESS, SPR_NOACCESS,
@@ -5665,7 +5665,7 @@ static void register_power7_book4_sprs(CPUPPCState *env)
                      KVM_REG_PPC_ACOP, 0);
     spr_register_kvm(env, SPR_BOOKS_PID, "PID",
                      SPR_NOACCESS, SPR_NOACCESS,
-                     &spr_read_generic, &spr_write_generic,
+                     &spr_read_generic, &spr_write_generic32,
                      KVM_REG_PPC_PID, 0);
 #endif
 }
@@ -5730,7 +5730,7 @@ static void register_power10_dexcr_sprs(CPUPPCState *env)
 {
     spr_register(env, SPR_DEXCR, "DEXCR",
             SPR_NOACCESS, SPR_NOACCESS,
-            &spr_read_generic, &spr_write_generic,
+            &spr_read_generic, &spr_write_generic32,
             0);
 
     spr_register(env, SPR_UDEXCR, "DEXCR",
@@ -5741,7 +5741,7 @@ static void register_power10_dexcr_sprs(CPUPPCState *env)
     spr_register_hv(env, SPR_HDEXCR, "HDEXCR",
             SPR_NOACCESS, SPR_NOACCESS,
             SPR_NOACCESS, SPR_NOACCESS,
-            &spr_read_generic, &spr_write_generic,
+            &spr_read_generic, &spr_write_generic32,
             0);
 
     spr_register(env, SPR_UHDEXCR, "HDEXCR",
diff --git a/target/ppc/helper_regs.c b/target/ppc/helper_regs.c
index 779e7db513..fb351c303f 100644
--- a/target/ppc/helper_regs.c
+++ b/target/ppc/helper_regs.c
@@ -448,7 +448,7 @@ void register_non_embedded_sprs(CPUPPCState *env)
     /* Exception processing */
     spr_register_kvm(env, SPR_DSISR, "DSISR",
                      SPR_NOACCESS, SPR_NOACCESS,
-                     &spr_read_generic, &spr_write_generic,
+                     &spr_read_generic, &spr_write_generic32,
                      KVM_REG_PPC_DSISR, 0x00000000);
     spr_register_kvm(env, SPR_DAR, "DAR",
                      SPR_NOACCESS, SPR_NOACCESS,
diff --git a/target/ppc/misc_helper.c b/target/ppc/misc_helper.c
index a9bc1522e2..40ddc5c08c 100644
--- a/target/ppc/misc_helper.c
+++ b/target/ppc/misc_helper.c
@@ -190,13 +190,13 @@ void helper_store_dpdes(CPUPPCState *env, target_ulong val)
 
 void helper_store_pidr(CPUPPCState *env, target_ulong val)
 {
-    env->spr[SPR_BOOKS_PID] = val;
+    env->spr[SPR_BOOKS_PID] = (uint32_t)val;
     tlb_flush(env_cpu(env));
 }
 
 void helper_store_lpidr(CPUPPCState *env, target_ulong val)
 {
-    env->spr[SPR_LPIDR] = val;
+    env->spr[SPR_LPIDR] = (uint32_t)val;
 
     /*
      * We need to flush the TLB on LPID changes as we only tag HV vs
diff --git a/target/ppc/power8-pmu.c b/target/ppc/power8-pmu.c
index 1381072b9e..64a64865d7 100644
--- a/target/ppc/power8-pmu.c
+++ b/target/ppc/power8-pmu.c
@@ -272,7 +272,7 @@ void helper_store_pmc(CPUPPCState *env, uint32_t sprn, uint64_t value)
 {
     pmu_update_cycles(env);
 
-    env->spr[sprn] = value;
+    env->spr[sprn] = (uint32_t)value;
 
     pmc_update_overflow_timer(env, sprn);
 }
diff --git a/target/ppc/spr_common.h b/target/ppc/spr_common.h
index 8437eb0340..4c0f2bed77 100644
--- a/target/ppc/spr_common.h
+++ b/target/ppc/spr_common.h
@@ -81,6 +81,7 @@ void _spr_register(CPUPPCState *env, int num, const char *name,
 void spr_noaccess(DisasContext *ctx, int gprn, int sprn);
 void spr_read_generic(DisasContext *ctx, int gprn, int sprn);
 void spr_write_generic(DisasContext *ctx, int sprn, int gprn);
+void spr_write_generic32(DisasContext *ctx, int sprn, int gprn);
 void spr_write_MMCR0(DisasContext *ctx, int sprn, int gprn);
 void spr_write_MMCR1(DisasContext *ctx, int sprn, int gprn);
 void spr_write_PMC(DisasContext *ctx, int sprn, int gprn);
@@ -109,7 +110,6 @@ void spr_write_PMC14_ureg(DisasContext *ctx, int sprn, int gprn);
 void spr_write_PMC56_ureg(DisasContext *ctx, int sprn, int gprn);
 
 #ifndef CONFIG_USER_ONLY
-void spr_write_generic32(DisasContext *ctx, int sprn, int gprn);
 void spr_write_clear(DisasContext *ctx, int sprn, int gprn);
 void spr_access_nop(DisasContext *ctx, int sprn, int gprn);
 void spr_read_decr(DisasContext *ctx, int gprn, int sprn);
diff --git a/target/ppc/translate.c b/target/ppc/translate.c
index 1720570b9b..9b7884586c 100644
--- a/target/ppc/translate.c
+++ b/target/ppc/translate.c
@@ -411,19 +411,6 @@ void spr_write_generic(DisasContext *ctx, int sprn, int gprn)
     spr_store_dump_spr(sprn);
 }
 
-void spr_write_CTRL(DisasContext *ctx, int sprn, int gprn)
-{
-    spr_write_generic(ctx, sprn, gprn);
-
-    /*
-     * SPR_CTRL writes must force a new translation block,
-     * allowing the PMU to calculate the run latch events with
-     * more accuracy.
-     */
-    ctx->base.is_jmp = DISAS_EXIT_UPDATE;
-}
-
-#if !defined(CONFIG_USER_ONLY)
 void spr_write_generic32(DisasContext *ctx, int sprn, int gprn)
 {
 #ifdef TARGET_PPC64
@@ -436,6 +423,19 @@ void spr_write_generic32(DisasContext *ctx, int sprn, int gprn)
 #endif
 }
 
+void spr_write_CTRL(DisasContext *ctx, int sprn, int gprn)
+{
+    spr_write_generic32(ctx, sprn, gprn);
+
+    /*
+     * SPR_CTRL writes must force a new translation block,
+     * allowing the PMU to calculate the run latch events with
+     * more accuracy.
+     */
+    ctx->base.is_jmp = DISAS_EXIT_UPDATE;
+}
+
+#if !defined(CONFIG_USER_ONLY)
 void spr_write_clear(DisasContext *ctx, int sprn, int gprn)
 {
     TCGv t0 = tcg_temp_new();
-- 
2.40.1



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PULL 03/10] target/ppc: Alignment faults do not set DSISR in ISA v3.0 onward
  2023-05-28 16:49 [PULL 00/10] ppc queue Daniel Henrique Barboza
  2023-05-28 16:49 ` [PULL 01/10] target/ppc: Fix fallback to MFSS for MFFS* instructions on pre 3.0 ISAs Daniel Henrique Barboza
  2023-05-28 16:49 ` [PULL 02/10] target/ppc: Fix width of some 32-bit SPRs Daniel Henrique Barboza
@ 2023-05-28 16:49 ` Daniel Henrique Barboza
  2023-05-28 16:49 ` [PULL 04/10] spapr: Add SPAPR_CAP_AIL_MODE_3 for AIL mode 3 support for H_SET_MODE hcall Daniel Henrique Barboza
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 19+ messages in thread
From: Daniel Henrique Barboza @ 2023-05-28 16:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-ppc, danielhb413, peter.maydell, richard.henderson,
	Nicholas Piggin, Fabiano Rosas

From: Nicholas Piggin <npiggin@gmail.com>

This optional behavior was removed from the ISA in v3.0, see
Summary of Changes preface:

  Data Storage Interrupt Status Register for Alignment Interrupt:
  Simplifies the Alignment interrupt by remov- ing the Data Storage
  Interrupt Status Register (DSISR) from the set of registers modified
  by the Alignment interrupt.

Reviewed-by: Fabiano Rosas <farosas@suse.de>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Message-Id: <20230515092655.171206-5-npiggin@gmail.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 target/ppc/excp_helper.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c
index 199328f4b6..fea9221501 100644
--- a/target/ppc/excp_helper.c
+++ b/target/ppc/excp_helper.c
@@ -1431,13 +1431,16 @@ static void powerpc_excp_books(PowerPCCPU *cpu, int excp)
         break;
     }
     case POWERPC_EXCP_ALIGN:     /* Alignment exception                      */
-        /* Get rS/rD and rA from faulting opcode */
-        /*
-         * Note: the opcode fields will not be set properly for a
-         * direct store load/store, but nobody cares as nobody
-         * actually uses direct store segments.
-         */
-        env->spr[SPR_DSISR] |= (env->error_code & 0x03FF0000) >> 16;
+        /* Optional DSISR update was removed from ISA v3.0 */
+        if (!(env->insns_flags2 & PPC2_ISA300)) {
+            /* Get rS/rD and rA from faulting opcode */
+            /*
+             * Note: the opcode fields will not be set properly for a
+             * direct store load/store, but nobody cares as nobody
+             * actually uses direct store segments.
+             */
+            env->spr[SPR_DSISR] |= (env->error_code & 0x03FF0000) >> 16;
+        }
         break;
     case POWERPC_EXCP_PROGRAM:   /* Program exception                        */
         switch (env->error_code & ~0xF) {
-- 
2.40.1



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PULL 04/10] spapr: Add SPAPR_CAP_AIL_MODE_3 for AIL mode 3 support for H_SET_MODE hcall
  2023-05-28 16:49 [PULL 00/10] ppc queue Daniel Henrique Barboza
                   ` (2 preceding siblings ...)
  2023-05-28 16:49 ` [PULL 03/10] target/ppc: Alignment faults do not set DSISR in ISA v3.0 onward Daniel Henrique Barboza
@ 2023-05-28 16:49 ` Daniel Henrique Barboza
  2023-05-28 16:49 ` [PULL 05/10] hw/ppc/prep: Fix wiring of PIC -> CPU interrupt Daniel Henrique Barboza
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 19+ messages in thread
From: Daniel Henrique Barboza @ 2023-05-28 16:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-ppc, danielhb413, peter.maydell, richard.henderson,
	Nicholas Piggin, David Gibson

From: Nicholas Piggin <npiggin@gmail.com>

The behaviour of the Address Translation Mode on Interrupt resource is
not consistently supported by all CPU versions or all KVM versions: KVM
HV does not support mode 2, and does not support mode 3 on POWER7 or
early POWER9 processesors. KVM PR only supports mode 0. TCG supports all
modes (0, 2, 3) on CPUs with support for the corresonding LPCR[AIL] mode.
This leads to inconsistencies in guest behaviour and could cause problems
migrating guests.

This was not noticable for Linux guests for a long time because the
kernel only uses modes 0 and 3, and it used to consider AIL-3 to be
advisory in that it would always keep the AIL-0 vectors around, so it
did not matter whether or not interrupts were delivered according to
the AIL mode. Recent Linux guests depend on AIL mode 3 working as
specified in order to support the SCV facility interrupt. If AIL-3 can
not be provided, then H_SET_MODE must return an error to Linux so it can
disable the SCV facility (failure to do so can lead to userspace being
able to crash the guest kernel).

Add the ail-mode-3 capability to specify that AIL-3 is supported. AIL-0
is implied as the baseline, and AIL-2 is no longer supported by spapr.
AIL-2 is not known to be used by any software, but support in TCG could
be restored with an ail-mode-2 capability quite easily if a regression
is reported.

Modify the H_SET_MODE Address Translation Mode on Interrupt resource
handler to check capabilities and correctly return error if not
supported.

KVM has a cap to advertise support for AIL-3.

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Message-Id: <20230515160216.394612-1-npiggin@gmail.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 hw/ppc/spapr.c         |  7 +++++++
 hw/ppc/spapr_caps.c    | 37 +++++++++++++++++++++++++++++++++++++
 hw/ppc/spapr_hcall.c   | 24 +++++++++++++-----------
 include/hw/ppc/spapr.h |  4 +++-
 target/ppc/kvm.c       |  7 +++++++
 target/ppc/kvm_ppc.h   |  6 ++++++
 6 files changed, 73 insertions(+), 12 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 1baea16c96..b623e23d6c 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -4673,6 +4673,13 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
     smc->default_caps.caps[SPAPR_CAP_CCF_ASSIST] = SPAPR_CAP_ON;
     smc->default_caps.caps[SPAPR_CAP_FWNMI] = SPAPR_CAP_ON;
     smc->default_caps.caps[SPAPR_CAP_RPT_INVALIDATE] = SPAPR_CAP_OFF;
+
+    /*
+     * This cap specifies whether the AIL 3 mode for
+     * H_SET_RESOURCE is supported. The default is modified
+     * by default_caps_with_cpu().
+     */
+    smc->default_caps.caps[SPAPR_CAP_AIL_MODE_3] = SPAPR_CAP_ON;
     spapr_caps_add_properties(smc);
     smc->irq = &spapr_irq_dual;
     smc->dr_phb_enabled = true;
diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c
index b4283055c1..3fd45a6dec 100644
--- a/hw/ppc/spapr_caps.c
+++ b/hw/ppc/spapr_caps.c
@@ -614,6 +614,33 @@ static void cap_rpt_invalidate_apply(SpaprMachineState *spapr,
     }
 }
 
+static void cap_ail_mode_3_apply(SpaprMachineState *spapr,
+                                     uint8_t val, Error **errp)
+{
+    ERRP_GUARD();
+    PowerPCCPU *cpu = POWERPC_CPU(first_cpu);
+    PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
+
+    if (!val) {
+        return;
+    }
+
+    if (tcg_enabled()) {
+        /* AIL-3 is only supported on POWER8 and above CPUs. */
+        if (!(pcc->insns_flags2 & PPC2_ISA207S)) {
+            error_setg(errp, "TCG only supports cap-ail-mode-3 on POWER8 and later CPUs");
+            error_append_hint(errp, "Try appending -machine cap-ail-mode-3=off\n");
+            return;
+        }
+    } else if (kvm_enabled()) {
+        if (!kvmppc_supports_ail_3()) {
+            error_setg(errp, "KVM implementation does not support cap-ail-mode-3");
+            error_append_hint(errp, "Try appending -machine cap-ail-mode-3=off\n");
+            return;
+        }
+    }
+}
+
 SpaprCapabilityInfo capability_table[SPAPR_CAP_NUM] = {
     [SPAPR_CAP_HTM] = {
         .name = "htm",
@@ -731,6 +758,15 @@ SpaprCapabilityInfo capability_table[SPAPR_CAP_NUM] = {
         .type = "bool",
         .apply = cap_rpt_invalidate_apply,
     },
+    [SPAPR_CAP_AIL_MODE_3] = {
+        .name = "ail-mode-3",
+        .description = "Alternate Interrupt Location (AIL) mode 3 support",
+        .index = SPAPR_CAP_AIL_MODE_3,
+        .get = spapr_cap_get_bool,
+        .set = spapr_cap_set_bool,
+        .type = "bool",
+        .apply = cap_ail_mode_3_apply,
+    },
 };
 
 static SpaprCapabilities default_caps_with_cpu(SpaprMachineState *spapr,
@@ -750,6 +786,7 @@ static SpaprCapabilities default_caps_with_cpu(SpaprMachineState *spapr,
                                0, spapr->max_compat_pvr)) {
         caps.caps[SPAPR_CAP_HTM] = SPAPR_CAP_OFF;
         caps.caps[SPAPR_CAP_CFPC] = SPAPR_CAP_BROKEN;
+        caps.caps[SPAPR_CAP_AIL_MODE_3] = SPAPR_CAP_OFF;
     }
 
     if (!ppc_type_check_compat(cputype, CPU_POWERPC_LOGICAL_2_06_PLUS,
diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
index 1c102c8c0d..b904755575 100644
--- a/hw/ppc/spapr_hcall.c
+++ b/hw/ppc/spapr_hcall.c
@@ -817,30 +817,32 @@ static target_ulong h_set_mode_resource_le(PowerPCCPU *cpu,
 }
 
 static target_ulong h_set_mode_resource_addr_trans_mode(PowerPCCPU *cpu,
+                                                        SpaprMachineState *spapr,
                                                         target_ulong mflags,
                                                         target_ulong value1,
                                                         target_ulong value2)
 {
-    PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
-
-    if (!(pcc->insns_flags2 & PPC2_ISA207S)) {
-        return H_P2;
-    }
     if (value1) {
         return H_P3;
     }
+
     if (value2) {
         return H_P4;
     }
 
-    if (mflags == 1) {
-        /* AIL=1 is reserved in POWER8/POWER9/POWER10 */
+    /*
+     * AIL-1 is not architected, and AIL-2 is not supported by QEMU spapr.
+     * It is supported for faithful emulation of bare metal systems, but for
+     * compatibility concerns we leave it out of the pseries machine.
+     */
+    if (mflags != 0 && mflags != 3) {
         return H_UNSUPPORTED_FLAG;
     }
 
-    if (mflags == 2 && (pcc->insns_flags2 & PPC2_ISA310)) {
-        /* AIL=2 is reserved in POWER10 (ISA v3.1) */
-        return H_UNSUPPORTED_FLAG;
+    if (mflags == 3) {
+        if (!spapr_get_cap(spapr, SPAPR_CAP_AIL_MODE_3)) {
+            return H_UNSUPPORTED_FLAG;
+        }
     }
 
     spapr_set_all_lpcrs(mflags << LPCR_AIL_SHIFT, LPCR_AIL);
@@ -859,7 +861,7 @@ static target_ulong h_set_mode(PowerPCCPU *cpu, SpaprMachineState *spapr,
         ret = h_set_mode_resource_le(cpu, spapr, args[0], args[2], args[3]);
         break;
     case H_SET_MODE_RESOURCE_ADDR_TRANS_MODE:
-        ret = h_set_mode_resource_addr_trans_mode(cpu, args[0],
+        ret = h_set_mode_resource_addr_trans_mode(cpu, spapr, args[0],
                                                   args[2], args[3]);
         break;
     }
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
index 5c8aabd444..bd5a6c4780 100644
--- a/include/hw/ppc/spapr.h
+++ b/include/hw/ppc/spapr.h
@@ -78,8 +78,10 @@ typedef enum {
 #define SPAPR_CAP_FWNMI                 0x0A
 /* Support H_RPT_INVALIDATE */
 #define SPAPR_CAP_RPT_INVALIDATE        0x0B
+/* Support for AIL modes */
+#define SPAPR_CAP_AIL_MODE_3            0x0C
 /* Num Caps */
-#define SPAPR_CAP_NUM                   (SPAPR_CAP_RPT_INVALIDATE + 1)
+#define SPAPR_CAP_NUM                   (SPAPR_CAP_AIL_MODE_3 + 1)
 
 /*
  * Capability Values
diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
index 336e663bc3..a7f2de9d10 100644
--- a/target/ppc/kvm.c
+++ b/target/ppc/kvm.c
@@ -88,6 +88,7 @@ static int cap_ppc_nested_kvm_hv;
 static int cap_large_decr;
 static int cap_fwnmi;
 static int cap_rpt_invalidate;
+static int cap_ail_mode_3;
 
 static uint32_t debug_inst_opcode;
 
@@ -152,6 +153,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
     }
 
     cap_rpt_invalidate = kvm_vm_check_extension(s, KVM_CAP_PPC_RPT_INVALIDATE);
+    cap_ail_mode_3 = kvm_vm_check_extension(s, KVM_CAP_PPC_AIL_MODE_3);
     kvm_ppc_register_host_cpu_type();
 
     return 0;
@@ -2560,6 +2562,11 @@ int kvmppc_has_cap_rpt_invalidate(void)
     return cap_rpt_invalidate;
 }
 
+bool kvmppc_supports_ail_3(void)
+{
+    return cap_ail_mode_3;
+}
+
 PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void)
 {
     uint32_t host_pvr = mfpvr();
diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h
index 5fd9753953..611debc3ce 100644
--- a/target/ppc/kvm_ppc.h
+++ b/target/ppc/kvm_ppc.h
@@ -76,6 +76,7 @@ int kvmppc_set_cap_nested_kvm_hv(int enable);
 int kvmppc_get_cap_large_decr(void);
 int kvmppc_enable_cap_large_decr(PowerPCCPU *cpu, int enable);
 int kvmppc_has_cap_rpt_invalidate(void);
+bool kvmppc_supports_ail_3(void);
 int kvmppc_enable_hwrng(void);
 int kvmppc_put_books_sregs(PowerPCCPU *cpu);
 PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void);
@@ -396,6 +397,11 @@ static inline int kvmppc_has_cap_rpt_invalidate(void)
     return false;
 }
 
+static inline bool kvmppc_supports_ail_3(void)
+{
+    return false;
+}
+
 static inline int kvmppc_enable_hwrng(void)
 {
     return -1;
-- 
2.40.1



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PULL 05/10] hw/ppc/prep: Fix wiring of PIC -> CPU interrupt
  2023-05-28 16:49 [PULL 00/10] ppc queue Daniel Henrique Barboza
                   ` (3 preceding siblings ...)
  2023-05-28 16:49 ` [PULL 04/10] spapr: Add SPAPR_CAP_AIL_MODE_3 for AIL mode 3 support for H_SET_MODE hcall Daniel Henrique Barboza
@ 2023-05-28 16:49 ` Daniel Henrique Barboza
  2023-05-28 16:49 ` [PULL 06/10] target/ppc: Use SMT4 small core chip type in POWER9/10 PVRs Daniel Henrique Barboza
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 19+ messages in thread
From: Daniel Henrique Barboza @ 2023-05-28 16:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-ppc, danielhb413, peter.maydell, richard.henderson,
	Bernhard Beschow

From: Bernhard Beschow <shentey@gmail.com>

Commit cef2e7148e32 ("hw/isa/i82378: Remove intermediate IRQ forwarder")
passes s->cpu_intr to i8259_init() in i82378_realize() directly. However, s-
>cpu_intr isn't initialized yet since that happens after the south bridge's
pci_realize_and_unref() in board code. Fix this by initializing s->cpu_intr
before realizing the south bridge.

Fixes: cef2e7148e32 ("hw/isa/i82378: Remove intermediate IRQ forwarder")
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <20230304114043.121024-4-shentey@gmail.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 hw/ppc/prep.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
index 4610abddbd..33bf232f8b 100644
--- a/hw/ppc/prep.c
+++ b/hw/ppc/prep.c
@@ -271,9 +271,11 @@ static void ibm_40p_init(MachineState *machine)
     }
 
     /* PCI -> ISA bridge */
-    i82378_dev = DEVICE(pci_create_simple(pci_bus, PCI_DEVFN(11, 0), "i82378"));
+    i82378_dev = DEVICE(pci_new(PCI_DEVFN(11, 0), "i82378"));
     qdev_connect_gpio_out(i82378_dev, 0,
                           qdev_get_gpio_in(DEVICE(cpu), PPC6xx_INPUT_INT));
+    qdev_realize_and_unref(i82378_dev, BUS(pci_bus), &error_fatal);
+
     sysbus_connect_irq(pcihost, 0, qdev_get_gpio_in(i82378_dev, 15));
     isa_bus = ISA_BUS(qdev_get_child_bus(i82378_dev, "isa.0"));
 
-- 
2.40.1



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PULL 06/10] target/ppc: Use SMT4 small core chip type in POWER9/10 PVRs
  2023-05-28 16:49 [PULL 00/10] ppc queue Daniel Henrique Barboza
                   ` (4 preceding siblings ...)
  2023-05-28 16:49 ` [PULL 05/10] hw/ppc/prep: Fix wiring of PIC -> CPU interrupt Daniel Henrique Barboza
@ 2023-05-28 16:49 ` Daniel Henrique Barboza
  2023-05-28 16:49 ` [PULL 07/10] pnv_lpc: disable reentrancy detection for lpc-hc Daniel Henrique Barboza
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 19+ messages in thread
From: Daniel Henrique Barboza @ 2023-05-28 16:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-ppc, danielhb413, peter.maydell, richard.henderson,
	Nicholas Piggin

From: Nicholas Piggin <npiggin@gmail.com>

QEMU's PVR value for POWER9 DD2.0 has chip type 1, which is the SMT4
"small core" type that OpenPOWER processors use. QEMU's PVR for all
other POWER9/10 have chip type 0, which "enterprise" systems use.

The difference does not really matter to QEMU (because it does not care
about SMT mode in the target), but for consistency all PVRs should use
the same chip type. We'll go with the SMT4 OpenPOWER type.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <20230515160131.394562-1-npiggin@gmail.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 target/ppc/cpu-models.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/target/ppc/cpu-models.h b/target/ppc/cpu-models.h
index 1326493a9a..a77e036b3a 100644
--- a/target/ppc/cpu-models.h
+++ b/target/ppc/cpu-models.h
@@ -348,11 +348,11 @@ enum {
     CPU_POWERPC_POWER8NVL_BASE     = 0x004C0000,
     CPU_POWERPC_POWER8NVL_v10      = 0x004C0100,
     CPU_POWERPC_POWER9_BASE        = 0x004E0000,
-    CPU_POWERPC_POWER9_DD1         = 0x004E0100,
+    CPU_POWERPC_POWER9_DD1         = 0x004E1100,
     CPU_POWERPC_POWER9_DD20        = 0x004E1200,
     CPU_POWERPC_POWER10_BASE       = 0x00800000,
-    CPU_POWERPC_POWER10_DD1        = 0x00800100,
-    CPU_POWERPC_POWER10_DD20       = 0x00800200,
+    CPU_POWERPC_POWER10_DD1        = 0x00801100,
+    CPU_POWERPC_POWER10_DD20       = 0x00801200,
     CPU_POWERPC_970_v22            = 0x00390202,
     CPU_POWERPC_970FX_v10          = 0x00391100,
     CPU_POWERPC_970FX_v20          = 0x003C0200,
-- 
2.40.1



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PULL 07/10] pnv_lpc: disable reentrancy detection for lpc-hc
  2023-05-28 16:49 [PULL 00/10] ppc queue Daniel Henrique Barboza
                   ` (5 preceding siblings ...)
  2023-05-28 16:49 ` [PULL 06/10] target/ppc: Use SMT4 small core chip type in POWER9/10 PVRs Daniel Henrique Barboza
@ 2023-05-28 16:49 ` Daniel Henrique Barboza
  2023-05-28 16:49 ` [PULL 08/10] target/ppc: Merge COMPUTE_CLASS and COMPUTE_FPRF Daniel Henrique Barboza
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 19+ messages in thread
From: Daniel Henrique Barboza @ 2023-05-28 16:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-ppc, danielhb413, peter.maydell, richard.henderson,
	Alexander Bulekov, Thomas Huth, Cédric Le Goater,
	Frederic Barrat

From: Alexander Bulekov <alxndr@bu.edu>

As lpc-hc is designed for re-entrant calls from xscom, mark it
re-entrancy safe.

Reported-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexander Bulekov <alxndr@bu.edu>
[clg: mark opb_master_regs as re-entrancy safe also ]
Signed-off-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Frederic Barrat <fbarrat@linux.ibm.com>
Tested-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20230526073850.2772197-1-clg@kaod.org>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 hw/ppc/pnv_lpc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/hw/ppc/pnv_lpc.c b/hw/ppc/pnv_lpc.c
index 01f44c19eb..605d390861 100644
--- a/hw/ppc/pnv_lpc.c
+++ b/hw/ppc/pnv_lpc.c
@@ -734,10 +734,13 @@ static void pnv_lpc_realize(DeviceState *dev, Error **errp)
     /* Create MMIO regions for LPC HC and OPB registers */
     memory_region_init_io(&lpc->opb_master_regs, OBJECT(dev), &opb_master_ops,
                           lpc, "lpc-opb-master", LPC_OPB_REGS_OPB_SIZE);
+    lpc->opb_master_regs.disable_reentrancy_guard = true;
     memory_region_add_subregion(&lpc->opb_mr, LPC_OPB_REGS_OPB_ADDR,
                                 &lpc->opb_master_regs);
     memory_region_init_io(&lpc->lpc_hc_regs, OBJECT(dev), &lpc_hc_ops, lpc,
                           "lpc-hc", LPC_HC_REGS_OPB_SIZE);
+    /* xscom writes to lpc-hc. As such mark lpc-hc re-entrancy safe */
+    lpc->lpc_hc_regs.disable_reentrancy_guard = true;
     memory_region_add_subregion(&lpc->opb_mr, LPC_HC_REGS_OPB_ADDR,
                                 &lpc->lpc_hc_regs);
 
-- 
2.40.1



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PULL 08/10] target/ppc: Merge COMPUTE_CLASS and COMPUTE_FPRF
  2023-05-28 16:49 [PULL 00/10] ppc queue Daniel Henrique Barboza
                   ` (6 preceding siblings ...)
  2023-05-28 16:49 ` [PULL 07/10] pnv_lpc: disable reentrancy detection for lpc-hc Daniel Henrique Barboza
@ 2023-05-28 16:49 ` Daniel Henrique Barboza
  2023-05-28 16:49 ` [PULL 09/10] target/ppc: Add POWER9 DD2.2 model Daniel Henrique Barboza
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 19+ messages in thread
From: Daniel Henrique Barboza @ 2023-05-28 16:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-ppc, danielhb413, peter.maydell, richard.henderson,
	Alex Bennée

From: Richard Henderson <richard.henderson@linaro.org>

Instead of computing an artificial "class" bitmask then converting that
to the fprf value, compute the final value from the start.

Reorder the tests to check the most likely cases first.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Tested-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20230523202507.688859-1-richard.henderson@linaro.org>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 target/ppc/fpu_helper.c | 78 ++++++++++++-----------------------------
 1 file changed, 22 insertions(+), 56 deletions(-)

diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c
index a66e16c212..03150a0f10 100644
--- a/target/ppc/fpu_helper.c
+++ b/target/ppc/fpu_helper.c
@@ -141,62 +141,28 @@ static inline int ppc_float64_get_unbiased_exp(float64 f)
     return ((f >> 52) & 0x7FF) - 1023;
 }
 
-/* Classify a floating-point number.  */
-enum {
-    is_normal   = 1,
-    is_zero     = 2,
-    is_denormal = 4,
-    is_inf      = 8,
-    is_qnan     = 16,
-    is_snan     = 32,
-    is_neg      = 64,
-};
-
-#define COMPUTE_CLASS(tp)                                      \
-static int tp##_classify(tp arg)                               \
-{                                                              \
-    int ret = tp##_is_neg(arg) * is_neg;                       \
-    if (unlikely(tp##_is_any_nan(arg))) {                      \
-        float_status dummy = { };  /* snan_bit_is_one = 0 */   \
-        ret |= (tp##_is_signaling_nan(arg, &dummy)             \
-                ? is_snan : is_qnan);                          \
-    } else if (unlikely(tp##_is_infinity(arg))) {              \
-        ret |= is_inf;                                         \
-    } else if (tp##_is_zero(arg)) {                            \
-        ret |= is_zero;                                        \
-    } else if (tp##_is_zero_or_denormal(arg)) {                \
-        ret |= is_denormal;                                    \
-    } else {                                                   \
-        ret |= is_normal;                                      \
-    }                                                          \
-    return ret;                                                \
-}
-
-COMPUTE_CLASS(float16)
-COMPUTE_CLASS(float32)
-COMPUTE_CLASS(float64)
-COMPUTE_CLASS(float128)
-
-static void set_fprf_from_class(CPUPPCState *env, int class)
-{
-    static const uint8_t fprf[6][2] = {
-        { 0x04, 0x08 },  /* normalized */
-        { 0x02, 0x12 },  /* zero */
-        { 0x14, 0x18 },  /* denormalized */
-        { 0x05, 0x09 },  /* infinity */
-        { 0x11, 0x11 },  /* qnan */
-        { 0x00, 0x00 },  /* snan -- flags are undefined */
-    };
-    bool isneg = class & is_neg;
-
-    env->fpscr &= ~FP_FPRF;
-    env->fpscr |= fprf[ctz32(class)][isneg] << FPSCR_FPRF;
-}
-
-#define COMPUTE_FPRF(tp)                                \
-void helper_compute_fprf_##tp(CPUPPCState *env, tp arg) \
-{                                                       \
-    set_fprf_from_class(env, tp##_classify(arg));       \
+#define COMPUTE_FPRF(tp)                                          \
+void helper_compute_fprf_##tp(CPUPPCState *env, tp arg)           \
+{                                                                 \
+    bool neg = tp##_is_neg(arg);                                  \
+    target_ulong fprf;                                            \
+    if (likely(tp##_is_normal(arg))) {                            \
+        fprf = neg ? 0x08 << FPSCR_FPRF : 0x04 << FPSCR_FPRF;     \
+    } else if (tp##_is_zero(arg)) {                               \
+        fprf = neg ? 0x12 << FPSCR_FPRF : 0x02 << FPSCR_FPRF;     \
+    } else if (tp##_is_zero_or_denormal(arg)) {                   \
+        fprf = neg ? 0x18 << FPSCR_FPRF : 0x14 << FPSCR_FPRF;     \
+    } else if (tp##_is_infinity(arg)) {                           \
+        fprf = neg ? 0x09 << FPSCR_FPRF : 0x05 << FPSCR_FPRF;     \
+    } else {                                                      \
+        float_status dummy = { };  /* snan_bit_is_one = 0 */      \
+        if (tp##_is_signaling_nan(arg, &dummy)) {                 \
+            fprf = 0x00 << FPSCR_FPRF;                            \
+        } else {                                                  \
+            fprf = 0x11 << FPSCR_FPRF;                            \
+        }                                                         \
+    }                                                             \
+    env->fpscr = (env->fpscr & ~FP_FPRF) | fprf;                  \
 }
 
 COMPUTE_FPRF(float16)
-- 
2.40.1



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PULL 09/10] target/ppc: Add POWER9 DD2.2 model
  2023-05-28 16:49 [PULL 00/10] ppc queue Daniel Henrique Barboza
                   ` (7 preceding siblings ...)
  2023-05-28 16:49 ` [PULL 08/10] target/ppc: Merge COMPUTE_CLASS and COMPUTE_FPRF Daniel Henrique Barboza
@ 2023-05-28 16:49 ` Daniel Henrique Barboza
  2023-05-28 16:49 ` [PULL 10/10] ppc/pegasos2: Change default CPU to 7457 Daniel Henrique Barboza
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 19+ messages in thread
From: Daniel Henrique Barboza @ 2023-05-28 16:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-ppc, danielhb413, peter.maydell, richard.henderson,
	Nicholas Piggin, Frederic Barrat, Harsh Prateek Bora

From: Nicholas Piggin <npiggin@gmail.com>

POWER9 DD2.1 and earlier had significant limitations when running KVM,
including lack of "mixed mode" MMU support (ability to run HPT and RPT
mode on threads of the same core), and a translation prefetch issue
which is worked around by disabling "AIL" mode for the guest.

These processors are not widely available, and it's difficult to deal
with all these quirks in qemu +/- KVM, so create a POWER9 DD2.2 CPU
and make it the default POWER9 CPU.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Frederic Barrat <fbarrat@linux.ibm.com>
Reviewed-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
Message-Id: <20230515160201.394587-1-npiggin@gmail.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 hw/ppc/pnv.c                   |  2 +-
 hw/ppc/pnv_core.c              |  2 +-
 hw/ppc/spapr.c                 |  2 +-
 hw/ppc/spapr_cpu_core.c        |  1 +
 include/hw/ppc/pnv.h           |  2 +-
 target/ppc/cpu-models.c        |  4 +++-
 target/ppc/cpu-models.h        |  1 +
 target/ppc/cpu_init.c          | 21 +++++++++++++++++++--
 tests/qtest/device-plug-test.c |  4 ++--
 9 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index 11cb48af2f..590fc64b32 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -2171,7 +2171,7 @@ static void pnv_machine_power9_class_init(ObjectClass *oc, void *data)
     };
 
     mc->desc = "IBM PowerNV (Non-Virtualized) POWER9";
-    mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("power9_v2.0");
+    mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("power9_v2.2");
     compat_props_add(mc->compat_props, phb_compat, G_N_ELEMENTS(phb_compat));
 
     xfc->match_nvt = pnv_match_nvt;
diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c
index 410f31bdf8..0bc3ad41c8 100644
--- a/hw/ppc/pnv_core.c
+++ b/hw/ppc/pnv_core.c
@@ -348,7 +348,7 @@ static const TypeInfo pnv_core_infos[] = {
     DEFINE_PNV_CORE_TYPE(power8, "power8e_v2.1"),
     DEFINE_PNV_CORE_TYPE(power8, "power8_v2.0"),
     DEFINE_PNV_CORE_TYPE(power8, "power8nvl_v1.0"),
-    DEFINE_PNV_CORE_TYPE(power9, "power9_v2.0"),
+    DEFINE_PNV_CORE_TYPE(power9, "power9_v2.2"),
     DEFINE_PNV_CORE_TYPE(power10, "power10_v2.0"),
 };
 
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index b623e23d6c..dcb7f1c70a 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -4631,7 +4631,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
 
     smc->dr_lmb_enabled = true;
     smc->update_dt_enabled = true;
-    mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("power9_v2.0");
+    mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("power9_v2.2");
     mc->has_hotpluggable_cpus = true;
     mc->nvdimm_supported = true;
     smc->resize_hpt_default = SPAPR_RESIZE_HPT_ENABLED;
diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
index 8a4861f45a..9b88dd549a 100644
--- a/hw/ppc/spapr_cpu_core.c
+++ b/hw/ppc/spapr_cpu_core.c
@@ -390,6 +390,7 @@ static const TypeInfo spapr_cpu_core_type_infos[] = {
     DEFINE_SPAPR_CPU_CORE_TYPE("power8nvl_v1.0"),
     DEFINE_SPAPR_CPU_CORE_TYPE("power9_v1.0"),
     DEFINE_SPAPR_CPU_CORE_TYPE("power9_v2.0"),
+    DEFINE_SPAPR_CPU_CORE_TYPE("power9_v2.2"),
     DEFINE_SPAPR_CPU_CORE_TYPE("power10_v1.0"),
     DEFINE_SPAPR_CPU_CORE_TYPE("power10_v2.0"),
 #ifdef CONFIG_KVM
diff --git a/include/hw/ppc/pnv.h b/include/hw/ppc/pnv.h
index 409f3bf763..7e5fef7c43 100644
--- a/include/hw/ppc/pnv.h
+++ b/include/hw/ppc/pnv.h
@@ -48,7 +48,7 @@ DECLARE_INSTANCE_CHECKER(PnvChip, PNV_CHIP_POWER8,
 DECLARE_INSTANCE_CHECKER(PnvChip, PNV_CHIP_POWER8NVL,
                          TYPE_PNV_CHIP_POWER8NVL)
 
-#define TYPE_PNV_CHIP_POWER9 PNV_CHIP_TYPE_NAME("power9_v2.0")
+#define TYPE_PNV_CHIP_POWER9 PNV_CHIP_TYPE_NAME("power9_v2.2")
 DECLARE_INSTANCE_CHECKER(PnvChip, PNV_CHIP_POWER9,
                          TYPE_PNV_CHIP_POWER9)
 
diff --git a/target/ppc/cpu-models.c b/target/ppc/cpu-models.c
index 912b037c63..7dbb47de64 100644
--- a/target/ppc/cpu-models.c
+++ b/target/ppc/cpu-models.c
@@ -732,6 +732,8 @@
                 "POWER9 v1.0")
     POWERPC_DEF("power9_v2.0",   CPU_POWERPC_POWER9_DD20,            POWER9,
                 "POWER9 v2.0")
+    POWERPC_DEF("power9_v2.2",   CPU_POWERPC_POWER9_DD22,            POWER9,
+                "POWER9 v2.2")
     POWERPC_DEF("power10_v1.0",  CPU_POWERPC_POWER10_DD1,            POWER10,
                 "POWER10 v1.0")
     POWERPC_DEF("power10_v2.0",  CPU_POWERPC_POWER10_DD20,           POWER10,
@@ -907,7 +909,7 @@ PowerPCCPUAlias ppc_cpu_aliases[] = {
     { "power8e", "power8e_v2.1" },
     { "power8", "power8_v2.0" },
     { "power8nvl", "power8nvl_v1.0" },
-    { "power9", "power9_v2.0" },
+    { "power9", "power9_v2.2" },
     { "power10", "power10_v2.0" },
 #endif
 
diff --git a/target/ppc/cpu-models.h b/target/ppc/cpu-models.h
index a77e036b3a..572b5e553a 100644
--- a/target/ppc/cpu-models.h
+++ b/target/ppc/cpu-models.h
@@ -350,6 +350,7 @@ enum {
     CPU_POWERPC_POWER9_BASE        = 0x004E0000,
     CPU_POWERPC_POWER9_DD1         = 0x004E1100,
     CPU_POWERPC_POWER9_DD20        = 0x004E1200,
+    CPU_POWERPC_POWER9_DD22        = 0x004E1202,
     CPU_POWERPC_POWER10_BASE       = 0x00800000,
     CPU_POWERPC_POWER10_DD1        = 0x00801100,
     CPU_POWERPC_POWER10_DD20       = 0x00801200,
diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
index 5aa0b3f0f1..05bf73296b 100644
--- a/target/ppc/cpu_init.c
+++ b/target/ppc/cpu_init.c
@@ -6284,9 +6284,26 @@ static bool ppc_pvr_match_power9(PowerPCCPUClass *pcc, uint32_t pvr, bool best)
         return false;
     }
 
-    if ((pvr & 0x0f00) == (pcc->pvr & 0x0f00)) {
-        /* Major DD version matches to power9_v1.0 and power9_v2.0 */
+    if ((pvr & 0x0f00) != (pcc->pvr & 0x0f00)) {
+        /* Major DD version does not match */
+        return false;
+    }
+
+    if ((pvr & 0x0f00) == 0x100) {
+        /* DD1.x always matches power9_v1.0 */
         return true;
+    } else if ((pvr & 0x0f00) == 0x200) {
+        if ((pvr & 0xf) < 2) {
+            /* DD2.0, DD2.1 match power9_v2.0 */
+            if ((pcc->pvr & 0xf) == 0) {
+                return true;
+            }
+        } else {
+            /* DD2.2, DD2.3 match power9_v2.2 */
+            if ((pcc->pvr & 0xf) == 2) {
+                return true;
+            }
+        }
     }
 
     return false;
diff --git a/tests/qtest/device-plug-test.c b/tests/qtest/device-plug-test.c
index abd544b70c..c6f33153eb 100644
--- a/tests/qtest/device-plug-test.c
+++ b/tests/qtest/device-plug-test.c
@@ -175,8 +175,8 @@ static void test_spapr_cpu_unplug_request(void)
 {
     QTestState *qtest;
 
-    qtest = qtest_initf("-cpu power9_v2.0 -smp 1,maxcpus=2 "
-                        "-device power9_v2.0-spapr-cpu-core,core-id=1,id=dev0");
+    qtest = qtest_initf("-cpu power9_v2.2 -smp 1,maxcpus=2 "
+                        "-device power9_v2.2-spapr-cpu-core,core-id=1,id=dev0");
 
     /* similar to test_pci_unplug_request */
     process_device_remove(qtest, "dev0");
-- 
2.40.1



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PULL 10/10] ppc/pegasos2: Change default CPU to 7457
  2023-05-28 16:49 [PULL 00/10] ppc queue Daniel Henrique Barboza
                   ` (8 preceding siblings ...)
  2023-05-28 16:49 ` [PULL 09/10] target/ppc: Add POWER9 DD2.2 model Daniel Henrique Barboza
@ 2023-05-28 16:49 ` Daniel Henrique Barboza
  2023-05-28 17:36 ` [PULL 00/10] ppc queue Michael Tokarev
  2023-05-29 23:02 ` Richard Henderson
  11 siblings, 0 replies; 19+ messages in thread
From: Daniel Henrique Barboza @ 2023-05-28 16:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-ppc, danielhb413, peter.maydell, richard.henderson,
	BALATON Zoltan, Rene Engel

From: BALATON Zoltan <balaton@eik.bme.hu>

Previously 7400 was selected as a safe choice as that is used by other
machines so it's better tested but AmigaOS does not know this CPU and
disables some features when running on it. The real hardware has
7447/7457 G4 CPU so change the default to match that now that it was
confirmed to work better with AmigaOS.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Tested-by: Rene Engel <ReneEngel80@emailn.de>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <20230528152937.B8DAD74633D@zero.eik.bme.hu>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 hw/ppc/pegasos2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c
index f1650be5ee..af5489de26 100644
--- a/hw/ppc/pegasos2.c
+++ b/hw/ppc/pegasos2.c
@@ -524,7 +524,7 @@ static void pegasos2_machine_class_init(ObjectClass *oc, void *data)
     mc->block_default_type = IF_IDE;
     mc->default_boot_order = "cd";
     mc->default_display = "std";
-    mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("7400_v2.9");
+    mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("7457_v1.2");
     mc->default_ram_id = "pegasos2.ram";
     mc->default_ram_size = 512 * MiB;
 
-- 
2.40.1



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [PULL 00/10] ppc queue
  2023-05-28 16:49 [PULL 00/10] ppc queue Daniel Henrique Barboza
                   ` (9 preceding siblings ...)
  2023-05-28 16:49 ` [PULL 10/10] ppc/pegasos2: Change default CPU to 7457 Daniel Henrique Barboza
@ 2023-05-28 17:36 ` Michael Tokarev
  2023-05-29  2:18   ` Nicholas Piggin
  2023-05-29  9:42   ` Daniel Henrique Barboza
  2023-05-29 23:02 ` Richard Henderson
  11 siblings, 2 replies; 19+ messages in thread
From: Michael Tokarev @ 2023-05-28 17:36 UTC (permalink / raw)
  To: Daniel Henrique Barboza, qemu-devel
  Cc: qemu-ppc, peter.maydell, richard.henderson, Richard Purdie,
	Nicholas Piggin, Bernhard Beschow

28.05.2023 19:49, Daniel Henrique Barboza wrote:
> 
>    https://gitlab.com/danielhb/qemu.git tags/pull-ppc-20230528
> 
> ppc patch queue for 2023-05-28:
> 
> This queue includes several assorted fixes for PowerPC SPR
> emulation, a change in the default Pegasos2 CPU, the addition
> of AIL mode 3 for spapr, a PIC->CPU interrupt fix for prep and
> performance enhancements in fpu_helper.c.

 From the patch description, it looks like the following changes
are suitable for -stable:

01/10 target/ppc: Fix fallback to MFSS for MFFS* instructions on pre 3.0 ISAs
02/10 target/ppc: Fix width of some 32-bit SPRs
03/10 target/ppc: Alignment faults do not set DSISR in ISA v3.0 onward
05/10 hw/ppc/prep: Fix wiring of PIC -> CPU interrupt

Or are these not important for -stable?  Or maybe there are other changes
which should be picked too?

Please add "Cc: qemu-stable@nongnu.org" tag for the future patches which
needs to be backported to previous/stable version of qemu.

Thanks!

/mjt
> ---------------------------------------------------------------
> Alexander Bulekov (1):
>        pnv_lpc: disable reentrancy detection for lpc-hc
> 
> BALATON Zoltan (1):
>        ppc/pegasos2: Change default CPU to 7457
> 
> Bernhard Beschow (1):
>        hw/ppc/prep: Fix wiring of PIC -> CPU interrupt
> 
> Nicholas Piggin (5):
>        target/ppc: Fix width of some 32-bit SPRs
>        target/ppc: Alignment faults do not set DSISR in ISA v3.0 onward
>        spapr: Add SPAPR_CAP_AIL_MODE_3 for AIL mode 3 support for H_SET_MODE hcall
>        target/ppc: Use SMT4 small core chip type in POWER9/10 PVRs
>        target/ppc: Add POWER9 DD2.2 model
> 
> Richard Henderson (1):
>        target/ppc: Merge COMPUTE_CLASS and COMPUTE_FPRF
> 
> Richard Purdie (1):
>        target/ppc: Fix fallback to MFSS for MFFS* instructions on pre 3.0 ISAs
> 



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PULL 00/10] ppc queue
  2023-05-28 17:36 ` [PULL 00/10] ppc queue Michael Tokarev
@ 2023-05-29  2:18   ` Nicholas Piggin
  2023-05-29  6:01     ` Michael Tokarev
  2023-05-29  9:42   ` Daniel Henrique Barboza
  1 sibling, 1 reply; 19+ messages in thread
From: Nicholas Piggin @ 2023-05-29  2:18 UTC (permalink / raw)
  To: Michael Tokarev, Daniel Henrique Barboza, qemu-devel
  Cc: qemu-ppc, peter.maydell, richard.henderson, Richard Purdie,
	Bernhard Beschow

On Mon May 29, 2023 at 3:36 AM AEST, Michael Tokarev wrote:
> 28.05.2023 19:49, Daniel Henrique Barboza wrote:
> > 
> >    https://gitlab.com/danielhb/qemu.git tags/pull-ppc-20230528
> > 
> > ppc patch queue for 2023-05-28:
> > 
> > This queue includes several assorted fixes for PowerPC SPR
> > emulation, a change in the default Pegasos2 CPU, the addition
> > of AIL mode 3 for spapr, a PIC->CPU interrupt fix for prep and
> > performance enhancements in fpu_helper.c.
>
>  From the patch description, it looks like the following changes
> are suitable for -stable:
>
> 01/10 target/ppc: Fix fallback to MFSS for MFFS* instructions on pre 3.0 ISAs
> 02/10 target/ppc: Fix width of some 32-bit SPRs
> 03/10 target/ppc: Alignment faults do not set DSISR in ISA v3.0 onward
> 05/10 hw/ppc/prep: Fix wiring of PIC -> CPU interrupt
>
> Or are these not important for -stable?  Or maybe there are other changes
> which should be picked too?

They certainly fix some parts of target emulation, but what is the
guidance for backporting those type of fixes? Most of the patches I sent
including 2,3 were just found from inspection or new test code and not
real software failing.

Should just simple ones go in? 32-bit SPRs do not fix entirely the
behaviour of all SPRs, just one aspect. In another fix I had (that
didn't make it in this merge), was a bit more complicated and the
first iteration caused a deadlock that didn't show up in basic test
like booting Linux.

My guess is that fixes that correct an issue with real software running
on the target should be ported to stable. Perhaps "obviously correct"
small fixes as well. But not sure about larger changes.

Thanks,
Nick


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PULL 00/10] ppc queue
  2023-05-29  2:18   ` Nicholas Piggin
@ 2023-05-29  6:01     ` Michael Tokarev
  2023-05-29  6:30       ` Nicholas Piggin
  0 siblings, 1 reply; 19+ messages in thread
From: Michael Tokarev @ 2023-05-29  6:01 UTC (permalink / raw)
  To: Nicholas Piggin, Daniel Henrique Barboza, qemu-devel
  Cc: qemu-ppc, peter.maydell, richard.henderson, Richard Purdie,
	Bernhard Beschow

29.05.2023 05:18, Nicholas Piggin wrote:
..

>> 01/10 target/ppc: Fix fallback to MFSS for MFFS* instructions on pre 3.0 ISAs
>> 02/10 target/ppc: Fix width of some 32-bit SPRs
>> 03/10 target/ppc: Alignment faults do not set DSISR in ISA v3.0 onward
>> 05/10 hw/ppc/prep: Fix wiring of PIC -> CPU interrupt
>>
>> Or are these not important for -stable?  Or maybe there are other changes
>> which should be picked too?
> 
> They certainly fix some parts of target emulation, but what is the
> guidance for backporting those type of fixes? Most of the patches I sent
> including 2,3 were just found from inspection or new test code and not
> real software failing.
> 
> Should just simple ones go in? 32-bit SPRs do not fix entirely the
> behaviour of all SPRs, just one aspect. In another fix I had (that
> didn't make it in this merge), was a bit more complicated and the
> first iteration caused a deadlock that didn't show up in basic test
> like booting Linux.
> 
> My guess is that fixes that correct an issue with real software running
> on the target should be ported to stable. Perhaps "obviously correct"
> small fixes as well. But not sure about larger changes.

This is exactly why I asked, - because I don't clearly understand how
important these to have in -stable. And also to remind that -stable
exist, just in case.. ;)

So be it, no actual issue so not applying to -stable.

Thank you for the clarification!

/mjt


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PULL 00/10] ppc queue
  2023-05-29  6:01     ` Michael Tokarev
@ 2023-05-29  6:30       ` Nicholas Piggin
  2023-05-29  7:00         ` Richard Purdie
  2023-05-29 14:16         ` Michael Tokarev
  0 siblings, 2 replies; 19+ messages in thread
From: Nicholas Piggin @ 2023-05-29  6:30 UTC (permalink / raw)
  To: Michael Tokarev, Daniel Henrique Barboza, qemu-devel
  Cc: qemu-ppc, peter.maydell, richard.henderson, Richard Purdie,
	Bernhard Beschow

On Mon May 29, 2023 at 4:01 PM AEST, Michael Tokarev wrote:
> 29.05.2023 05:18, Nicholas Piggin wrote:
> ..
>
> >> 01/10 target/ppc: Fix fallback to MFSS for MFFS* instructions on pre 3.0 ISAs
> >> 02/10 target/ppc: Fix width of some 32-bit SPRs
> >> 03/10 target/ppc: Alignment faults do not set DSISR in ISA v3.0 onward
> >> 05/10 hw/ppc/prep: Fix wiring of PIC -> CPU interrupt
> >>
> >> Or are these not important for -stable?  Or maybe there are other changes
> >> which should be picked too?
> > 
> > They certainly fix some parts of target emulation, but what is the
> > guidance for backporting those type of fixes? Most of the patches I sent
> > including 2,3 were just found from inspection or new test code and not
> > real software failing.
> > 
> > Should just simple ones go in? 32-bit SPRs do not fix entirely the
> > behaviour of all SPRs, just one aspect. In another fix I had (that
> > didn't make it in this merge), was a bit more complicated and the
> > first iteration caused a deadlock that didn't show up in basic test
> > like booting Linux.
> > 
> > My guess is that fixes that correct an issue with real software running
> > on the target should be ported to stable. Perhaps "obviously correct"
> > small fixes as well. But not sure about larger changes.
>
> This is exactly why I asked, - because I don't clearly understand how
> important these to have in -stable. And also to remind that -stable
> exist, just in case.. ;)

Ah okay, makes sense. I was just clarifying myself since I wasn't
too sure.

> So be it, no actual issue so not applying to -stable.

I will think about it and try to keep -stable in mind. Of my patches
there are one or two coming up that could probably go in there, if
not these ones.

Thanks,
Nick


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PULL 00/10] ppc queue
  2023-05-29  6:30       ` Nicholas Piggin
@ 2023-05-29  7:00         ` Richard Purdie
  2023-05-29 14:16         ` Michael Tokarev
  1 sibling, 0 replies; 19+ messages in thread
From: Richard Purdie @ 2023-05-29  7:00 UTC (permalink / raw)
  To: Nicholas Piggin, Michael Tokarev, Daniel Henrique Barboza,
	qemu-devel
  Cc: qemu-ppc, peter.maydell, richard.henderson, Bernhard Beschow

On Mon, 2023-05-29 at 16:30 +1000, Nicholas Piggin wrote:
> On Mon May 29, 2023 at 4:01 PM AEST, Michael Tokarev wrote:
> > 29.05.2023 05:18, Nicholas Piggin wrote:
> > ..
> > 
> > > > 01/10 target/ppc: Fix fallback to MFSS for MFFS* instructions on pre 3.0 ISAs
> > > > 02/10 target/ppc: Fix width of some 32-bit SPRs
> > > > 03/10 target/ppc: Alignment faults do not set DSISR in ISA v3.0 onward
> > > > 05/10 hw/ppc/prep: Fix wiring of PIC -> CPU interrupt
> > > > 
> > > > Or are these not important for -stable?  Or maybe there are other changes
> > > > which should be picked too?
> > > 
> > > They certainly fix some parts of target emulation, but what is the
> > > guidance for backporting those type of fixes? Most of the patches I sent
> > > including 2,3 were just found from inspection or new test code and not
> > > real software failing.
> > > 
> > > Should just simple ones go in? 32-bit SPRs do not fix entirely the
> > > behaviour of all SPRs, just one aspect. In another fix I had (that
> > > didn't make it in this merge), was a bit more complicated and the
> > > first iteration caused a deadlock that didn't show up in basic test
> > > like booting Linux.
> > > 
> > > My guess is that fixes that correct an issue with real software running
> > > on the target should be ported to stable. Perhaps "obviously correct"
> > > small fixes as well. But not sure about larger changes.
> > 
> > This is exactly why I asked, - because I don't clearly understand how
> > important these to have in -stable. And also to remind that -stable
> > exist, just in case.. ;)
> 
> Ah okay, makes sense. I was just clarifying myself since I wasn't
> too sure.
> 
> > So be it, no actual issue so not applying to -stable.
> 
> I will think about it and try to keep -stable in mind. Of my patches
> there are one or two coming up that could probably go in there, if
> not these ones.

1/10 from me (fallback to MFSS) did fix software failures for Yocto
Project so might be a good candidate for stable. We're carrying that
patch against the last release for now.

Cheers,

Richard




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PULL 00/10] ppc queue
  2023-05-28 17:36 ` [PULL 00/10] ppc queue Michael Tokarev
  2023-05-29  2:18   ` Nicholas Piggin
@ 2023-05-29  9:42   ` Daniel Henrique Barboza
  1 sibling, 0 replies; 19+ messages in thread
From: Daniel Henrique Barboza @ 2023-05-29  9:42 UTC (permalink / raw)
  To: Michael Tokarev, qemu-devel
  Cc: qemu-ppc, peter.maydell, richard.henderson, Richard Purdie,
	Nicholas Piggin, Bernhard Beschow



On 5/28/23 14:36, Michael Tokarev wrote:
> 28.05.2023 19:49, Daniel Henrique Barboza wrote:
>>
>>    https://gitlab.com/danielhb/qemu.git tags/pull-ppc-20230528
>>
>> ppc patch queue for 2023-05-28:
>>
>> This queue includes several assorted fixes for PowerPC SPR
>> emulation, a change in the default Pegasos2 CPU, the addition
>> of AIL mode 3 for spapr, a PIC->CPU interrupt fix for prep and
>> performance enhancements in fpu_helper.c.
> 
>  From the patch description, it looks like the following changes
> are suitable for -stable:
> 
> 01/10 target/ppc: Fix fallback to MFSS for MFFS* instructions on pre 3.0 ISAs
> 02/10 target/ppc: Fix width of some 32-bit SPRs
> 03/10 target/ppc: Alignment faults do not set DSISR in ISA v3.0 onward
> 05/10 hw/ppc/prep: Fix wiring of PIC -> CPU interrupt
> 
> Or are these not important for -stable?  Or maybe there are other changes
> which should be picked too?

Patch 1 and perhaps 5 is stable material, and by "stable material" I'm
interpreting as "bug fixes for issues that were detected in the field
by users and predates the current release"

Let me know if this is the right approach or not.

> 
> Please add "Cc: qemu-stable@nongnu.org" tag for the future patches which
> needs to be backported to previous/stable version of qemu.

I'll keep that in mind next time. Thanks,


Daniel

> 
> Thanks!
> 
> /mjt
>> ---------------------------------------------------------------
>> Alexander Bulekov (1):
>>        pnv_lpc: disable reentrancy detection for lpc-hc
>>
>> BALATON Zoltan (1):
>>        ppc/pegasos2: Change default CPU to 7457
>>
>> Bernhard Beschow (1):
>>        hw/ppc/prep: Fix wiring of PIC -> CPU interrupt
>>
>> Nicholas Piggin (5):
>>        target/ppc: Fix width of some 32-bit SPRs
>>        target/ppc: Alignment faults do not set DSISR in ISA v3.0 onward
>>        spapr: Add SPAPR_CAP_AIL_MODE_3 for AIL mode 3 support for H_SET_MODE hcall
>>        target/ppc: Use SMT4 small core chip type in POWER9/10 PVRs
>>        target/ppc: Add POWER9 DD2.2 model
>>
>> Richard Henderson (1):
>>        target/ppc: Merge COMPUTE_CLASS and COMPUTE_FPRF
>>
>> Richard Purdie (1):
>>        target/ppc: Fix fallback to MFSS for MFFS* instructions on pre 3.0 ISAs
>>
> 


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PULL 00/10] ppc queue
  2023-05-29  6:30       ` Nicholas Piggin
  2023-05-29  7:00         ` Richard Purdie
@ 2023-05-29 14:16         ` Michael Tokarev
  1 sibling, 0 replies; 19+ messages in thread
From: Michael Tokarev @ 2023-05-29 14:16 UTC (permalink / raw)
  To: Nicholas Piggin, Daniel Henrique Barboza, qemu-devel
  Cc: qemu-ppc, peter.maydell, richard.henderson, Richard Purdie,
	Bernhard Beschow

29.05.2023 09:30, Nicholas Piggin wrote:
> On Mon May 29, 2023 at 4:01 PM AEST, Michael Tokarev wrote:
..
>>> They certainly fix some parts of target emulation, but what is the
>>> guidance for backporting those type of fixes? Most of the patches I sent
>>> including 2,3 were just found from inspection or new test code and not
>>> real software failing.
>>>
>>> Should just simple ones go in? 32-bit SPRs do not fix entirely the
>>> behaviour of all SPRs, just one aspect. In another fix I had (that
>>> didn't make it in this merge), was a bit more complicated and the
>>> first iteration caused a deadlock that didn't show up in basic test
>>> like booting Linux.
>>>
>>> My guess is that fixes that correct an issue with real software running
>>> on the target should be ported to stable. Perhaps "obviously correct"
>>> small fixes as well. But not sure about larger changes.
>>
>> This is exactly why I asked, - because I don't clearly understand how
>> important these to have in -stable. And also to remind that -stable
>> exist, just in case.. ;)
> 
> Ah okay, makes sense. I was just clarifying myself since I wasn't
> too sure.

We do not have strict rules for stuff which should go to -stable.
In the wiki - https://www.qemu.org/docs/master/devel/stable-process.html -
it is stated as vague as

   If you think the patch would be important for users of the current release
   (or for a distribution picking fixes), it is usually a good candidate for stable.

so things are decided on a case-by-case basis.  Sometimes even spelling
fixes gets picked up, sometimes much larger and invasive changes has to
be picked to fix a real bug.  Once again, there's no strict rules.

Myself, I haven't been in this process before, but I see it from a
downstream PoV, as I maintain qemu in debian for quite some years.

A bug might not be reported by actual users, but if it has good potential
for breaking something, - *maybe* like in this case when qemu behaves
differently than an actual HW (once again, I don't know what the impact
of *these* fixes, or lack thereof, are), - and at the same time the
fix is small, self-contained and "obviously correct" (in other words,
has low potential of breaking something else), - I tend to pick it up,
to bring behavior to match the specs like in this case.

We had this numerous times: something is broken, but apparently no one
uses that. And out of the sudden people start hitting it in real life,
like even qemu itself which uses debian-provided packages in its own CI.
Just to discover this bug is known for a long time and is fixed in master
long ago too.

Sure thing there might be changes which fix more serious issues, but which
are based on some subsystem rewrite, - with these, it's more difficult to
decide what to do - to keep bug or to risk breaking other stuff.  I omitted
a few fixes for 7.2 due to this very situation: when the infrastructure
used in new code did not exist in 7.2 and quite a lot of other changes
needs to be back-ported.

There's always a tradeoff: the "importance" of the bug and the amount of
stuff it requires to back-port. Unimportant fixes (eg, a missing free()
in error path in init function) which require other code changes are
obviously not for -stable.  On the other end, small but important changes
(eg a fix for a crash/deadlock which many users are hitting) is obviously
a good fit for -stable.  And anything in-between is, sure thing, grey,
with all its shades.

This is why we're more dependent on the subsystem maintainers or authors
of the particular changes, - since they know much better when any given
fix is important or not, know much better about possible impact and so on.
Maybe it's just cosmetics which can safely be ignored, or maybe it's a
big thing which is worth to backport other stuff for it to work.
It is also much easier to think about this when you have the context
which you just fixed, still in your mind.

And this is why I'm asking.

Thank you!

/mjt


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PULL 00/10] ppc queue
  2023-05-28 16:49 [PULL 00/10] ppc queue Daniel Henrique Barboza
                   ` (10 preceding siblings ...)
  2023-05-28 17:36 ` [PULL 00/10] ppc queue Michael Tokarev
@ 2023-05-29 23:02 ` Richard Henderson
  11 siblings, 0 replies; 19+ messages in thread
From: Richard Henderson @ 2023-05-29 23:02 UTC (permalink / raw)
  To: Daniel Henrique Barboza, qemu-devel; +Cc: qemu-ppc, peter.maydell

On 5/28/23 09:49, Daniel Henrique Barboza wrote:
> The following changes since commit ac84b57b4d74606f7f83667a0606deef32b2049d:
> 
>    Merge tag 'for-upstream' ofhttps://gitlab.com/bonzini/qemu  into staging (2023-05-26 14:40:55 -0700)
> 
> are available in the Git repository at:
> 
>    https://gitlab.com/danielhb/qemu.git  tags/pull-ppc-20230528
> 
> for you to fetch changes up to 56b8bfe9bb6b94184b8bbfc4be9196404a81e450:
> 
>    ppc/pegasos2: Change default CPU to 7457 (2023-05-28 13:25:45 -0300)
> 
> ----------------------------------------------------------------
> ppc patch queue for 2023-05-28:
> 
> This queue includes several assorted fixes for PowerPC SPR
> emulation, a change in the default Pegasos2 CPU, the addition
> of AIL mode 3 for spapr, a PIC->CPU interrupt fix for prep and
> performance enhancements in fpu_helper.c.

Applied, thanks.  Please update https://wiki.qemu.org/ChangeLog/8.1 as appropriate.


r~



^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2023-05-29 23:04 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-28 16:49 [PULL 00/10] ppc queue Daniel Henrique Barboza
2023-05-28 16:49 ` [PULL 01/10] target/ppc: Fix fallback to MFSS for MFFS* instructions on pre 3.0 ISAs Daniel Henrique Barboza
2023-05-28 16:49 ` [PULL 02/10] target/ppc: Fix width of some 32-bit SPRs Daniel Henrique Barboza
2023-05-28 16:49 ` [PULL 03/10] target/ppc: Alignment faults do not set DSISR in ISA v3.0 onward Daniel Henrique Barboza
2023-05-28 16:49 ` [PULL 04/10] spapr: Add SPAPR_CAP_AIL_MODE_3 for AIL mode 3 support for H_SET_MODE hcall Daniel Henrique Barboza
2023-05-28 16:49 ` [PULL 05/10] hw/ppc/prep: Fix wiring of PIC -> CPU interrupt Daniel Henrique Barboza
2023-05-28 16:49 ` [PULL 06/10] target/ppc: Use SMT4 small core chip type in POWER9/10 PVRs Daniel Henrique Barboza
2023-05-28 16:49 ` [PULL 07/10] pnv_lpc: disable reentrancy detection for lpc-hc Daniel Henrique Barboza
2023-05-28 16:49 ` [PULL 08/10] target/ppc: Merge COMPUTE_CLASS and COMPUTE_FPRF Daniel Henrique Barboza
2023-05-28 16:49 ` [PULL 09/10] target/ppc: Add POWER9 DD2.2 model Daniel Henrique Barboza
2023-05-28 16:49 ` [PULL 10/10] ppc/pegasos2: Change default CPU to 7457 Daniel Henrique Barboza
2023-05-28 17:36 ` [PULL 00/10] ppc queue Michael Tokarev
2023-05-29  2:18   ` Nicholas Piggin
2023-05-29  6:01     ` Michael Tokarev
2023-05-29  6:30       ` Nicholas Piggin
2023-05-29  7:00         ` Richard Purdie
2023-05-29 14:16         ` Michael Tokarev
2023-05-29  9:42   ` Daniel Henrique Barboza
2023-05-29 23:02 ` Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).