Skip to contentSkip to conversation

target/ppc: Add ISA v3.1 LEV indication in SRR1 for system call interrupts

PATCH Applied Nicholas Piggin 3 participants 4 messages Jun 20, 2023 – Jun 23, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/ppc: Add ISA v3.1 LEV indication in SRR1 for system call interrupts

System call interrupts in ISA v3.1 CPUs add a LEV indication in SRR1 that corresponds with the LEV field of the instruction that caused the interrupt.

---
This is unchanged, just taken out of the bigger series since it is independent.

Thanks,
Nick

 target/ppc/excp_helper.c | 4 ++++
 1 file changed, 4 insertions(+)
target/ppc/excp_helper.c +4 -0
index 77bfc18734..c7550fea13 100644
@@ -1591,6 +1591,10 @@ static void powerpc_excp_books(PowerPCCPU *cpu, int excp)
             vhc->hypercall(cpu->vhyp, cpu);
             return;
         }
+        if (env->insns_flags2 & PPC2_ISA310) {
+            /* ISAv3.1 puts LEV into SRR1 */
+            msr |= lev << 20;
+        }
         if (lev == 1) {
             new_msr |= (target_ulong)MSR_HVB;
         }
Signature · 1 line
2.40.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Nicholas Piggin

System call interrupts in ISA v3.1 CPUs add a LEV indication in SRR1 that corresponds with the LEV field of the instruction that caused the interrupt.

Did we encounter any issue without this patch leading to this fix? If so, it will be great to talk about it in short if possible.

Quoted 16 lines

---
This is unchanged, just taken out of the bigger series since it is independent.

Thanks,
Nick

  target/ppc/excp_helper.c | 4 ++++
  1 file changed, 4 insertions(+)
target/ppc/excp_helper.c +0 -0
index 77bfc18734..c7550fea13 100644

target/ppc/excp_helper.c static void powerpc_excp_books(PowerPCCPU *cpu, int excp) · line 1596

Quoted 6 lines
target/ppc/excp_helper.c +3 -0
@@ -1591,6 +1591,10 @@ static void powerpc_excp_books(PowerPCCPU *cpu, int excp)
              vhc->hypercall(cpu->vhyp, cpu);
              return;
          }
+        if (env->insns_flags2 & PPC2_ISA310) {
+            /* ISAv3.1 puts LEV into SRR1 */
+            msr |= lev << 20;

Since LEV values greater than 2 are reserved, should we do:

               msr |= (lev <= 2) ? lev << 20 : 0;

Otherwise,

Quoted 4 lines
target/ppc/excp_helper.c +1 -0
+        }
          if (lev == 1) {
              new_msr |= (target_ulong)MSR_HVB;
          }
#2 lore raw
Quoted 9 lines · Harsh Prateek Bora
Quoted 4 lines · Nicholas Piggin

System call interrupts in ISA v3.1 CPUs add a LEV indication in SRR1 that corresponds with the LEV field of the instruction that caused the interrupt.

Did we encounter any issue without this patch leading to this fix?

No, I just noticed it.

Quoted 26 lines

If so, it will be great to talk about it in short if possible.

Quoted 16 lines

---
This is unchanged, just taken out of the bigger series since it is independent.

Thanks,
Nick

  target/ppc/excp_helper.c | 4 ++++
  1 file changed, 4 insertions(+)
target/ppc/excp_helper.c +0 -0
index 77bfc18734..c7550fea13 100644

target/ppc/excp_helper.c static void powerpc_excp_books(PowerPCCPU *cpu, int excp) · line 1596

Quoted 6 lines
target/ppc/excp_helper.c +3 -0
@@ -1591,6 +1591,10 @@ static void powerpc_excp_books(PowerPCCPU *cpu, int excp)
              vhc->hypercall(cpu->vhyp, cpu);
              return;
          }
+        if (env->insns_flags2 & PPC2_ISA310) {
+            /* ISAv3.1 puts LEV into SRR1 */
+            msr |= lev << 20;

Since LEV values greater than 2 are reserved, should we do:

Quoted 1 line
                msr |= (lev <= 2) ? lev << 20 : 0;

Oh good point. Actually I think we want this which would be a separate patch going before this one, as it is a fix for sc even for pre-v3.1:

Thanks
Nick

target/ppc/translate.c +6 -1
index 15a00bd4fa..297159280e 100644
@@ -4424,7 +4424,18 @@ static void gen_sc(DisasContext *ctx)
 {
     uint32_t lev;
 
-    lev = (ctx->opcode >> 5) & 0x7F;
+    /*
+     * LEV is a 7-bit field, but the top 6 bits are treated as a reserved
+     * field (i.e., ignored). ISA v3.1 changes that to 5 bits, but that
+     * is for Ultravisor is not not supported, so keep using 6 and 1.
+     */
+    lev = (ctx->opcode >> 5) & 0x1;
     gen_exception_err(ctx, POWERPC_SYSCALL, lev);
 }
 
#3 lore raw
In reply to Nicholas Piggin
Quoted 5 lines · Nicholas Piggin

System call interrupts in ISA v3.1 CPUs add a LEV indication in SRR1 that corresponds with the LEV field of the instruction that caused the interrupt.

Applied to ppc-next.

Thanks,

C.

Quoted 25 lines

---
This is unchanged, just taken out of the bigger series since it is independent.

Thanks,
Nick

  target/ppc/excp_helper.c | 4 ++++
  1 file changed, 4 insertions(+)
target/ppc/excp_helper.c +4 -0
index 77bfc18734..c7550fea13 100644
@@ -1591,6 +1591,10 @@ static void powerpc_excp_books(PowerPCCPU *cpu, int excp)
              vhc->hypercall(cpu->vhyp, cpu);
              return;
          }
+        if (env->insns_flags2 & PPC2_ISA310) {
+            /* ISAv3.1 puts LEV into SRR1 */
+            msr |= lev << 20;
+        }
          if (lev == 1) {
              new_msr |= (target_ulong)MSR_HVB;
          }