Skip to contentSkip to conversation

target/ppc: powerpc_excp: Guard ALIGNMENT interrupt with CONFIG_TCG

PATCH In review Fabiano Rosas 3 participants 8 messages Dec 8, 2021 – Dec 9, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/ppc: powerpc_excp: Guard ALIGNMENT interrupt with CONFIG_TCG

We cannot have TCG code in powerpc_excp because the function is called from kvm-only code via ppc_cpu_do_interrupt:

../target/ppc/excp_helper.c:463:29: error: implicit declaration of function ‘cpu_ldl_code’ [-Werror=implicit-function-declaration]

Fortunately, the Alignment interrupt is not among the ones dispatched from kvm-only code, so we can keep it out of the disable-tcg build for now.

Fixes 336e91f853 ("target/ppc: Move SPR_DSISR setting to powerpc_excp")

---

Perhaps we could make powerpc_excp TCG only and have a separate function that only knows the two interrupts that we use with KVM (Program, Machine check). But for now this fix will do, I think.

---
 target/ppc/excp_helper.c | 2 ++
 1 file changed, 2 insertions(+)
target/ppc/excp_helper.c +2 -0
index 17607adbe4..dcf22440cc 100644
@@ -453,6 +453,7 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int excp_model, int excp)
         }
         break;
     }
+#ifdef CONFIG_TCG
     case POWERPC_EXCP_ALIGN:     /* Alignment exception                      */
         /*
          * Get rS/rD and rA from faulting opcode.
@@ -464,6 +465,7 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int excp_model, int excp)
             env->spr[SPR_DSISR] |= (insn & 0x03FF0000) >> 16;
         }
         break;
+#endif
     case POWERPC_EXCP_PROGRAM:   /* Program exception                        */
         switch (env->error_code & ~0xF) {
         case POWERPC_EXCP_FP:
Signature · 1 line
2.33.1
#1 lore raw
Quoted 10 lines · Fabiano Rosas

We cannot have TCG code in powerpc_excp because the function is called from kvm-only code via ppc_cpu_do_interrupt:

../target/ppc/excp_helper.c:463:29: error: implicit declaration of function ‘cpu_ldl_code’ [-Werror=implicit-function-declaration]

Fortunately, the Alignment interrupt is not among the ones dispatched from kvm-only code, so we can keep it out of the disable-tcg build for now.

Quoted 8 lines
Fixes 336e91f853 ("target/ppc: Move SPR_DSISR setting to powerpc_excp")

---

Perhaps we could make powerpc_excp TCG only and have a separate function that only knows the two interrupts that we use with KVM (Program, Machine check). But for now this fix will do, I think.

If KVM only uses 2 exception vectors, you could guard the enum in target/ppc/cpu.h using #ifdef'ry. While making the include uglier, it will helps to catch vector misused at compile time.

Quoted 3 lines
---
 target/ppc/excp_helper.c | 2 ++
 1 file changed, 2 insertions(+)
#2 lore raw
Quoted 16 lines · Philippe Mathieu-Daudé
Quoted 15 lines · Fabiano Rosas

We cannot have TCG code in powerpc_excp because the function is called from kvm-only code via ppc_cpu_do_interrupt:

../target/ppc/excp_helper.c:463:29: error: implicit declaration of function ‘cpu_ldl_code’ [-Werror=implicit-function-declaration]

Fortunately, the Alignment interrupt is not among the ones dispatched from kvm-only code, so we can keep it out of the disable-tcg build for now.

Fixes 336e91f853 ("target/ppc: Move SPR_DSISR setting to powerpc_excp")

---

Quoted 8 lines
Quoted 3 lines

Perhaps we could make powerpc_excp TCG only and have a separate function that only knows the two interrupts that we use with KVM (Program, Machine check). But for now this fix will do, I think.

If KVM only uses 2 exception vectors, you could guard the enum in target/ppc/cpu.h using #ifdef'ry. While making the include uglier, it will helps to catch vector misused at compile time.

Yes, good point.

I just noticed that we also use System Reset with KVM. The other two are kvm-only, but this one is in code shared with TCG, so it will need a bit more work to disentangle. But should still be doable.

Quoted 3 lines
Quoted 3 lines
---
 target/ppc/excp_helper.c | 2 ++
 1 file changed, 2 insertions(+)
#3 lore raw
In reply to Fabiano Rosas
Quoted 36 lines · Fabiano Rosas

We cannot have TCG code in powerpc_excp because the function is called from kvm-only code via ppc_cpu_do_interrupt:

../target/ppc/excp_helper.c:463:29: error: implicit declaration of function ‘cpu_ldl_code’ [-Werror=implicit-function-declaration]

Fortunately, the Alignment interrupt is not among the ones dispatched from kvm-only code, so we can keep it out of the disable-tcg build for now.

Fixes 336e91f853 ("target/ppc: Move SPR_DSISR setting to powerpc_excp")

---

Perhaps we could make powerpc_excp TCG only and have a separate function that only knows the two interrupts that we use with KVM (Program, Machine check). But for now this fix will do, I think.

---
  target/ppc/excp_helper.c | 2 ++
  1 file changed, 2 insertions(+)
target/ppc/excp_helper.c +1 -0
index 17607adbe4..dcf22440cc 100644
@@ -453,6 +453,7 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int excp_model, int excp)
          }
          break;
      }
+#ifdef CONFIG_TCG
      case POWERPC_EXCP_ALIGN:     /* Alignment exception                      */
          /*
           * Get rS/rD and rA from faulting opcode.

target/ppc/excp_helper.c static inline void powerpc_excp(PowerPCCPU *cpu, int excp_model, int excp) · line 471

Quoted 7 lines
target/ppc/excp_helper.c +1 -0
@@ -464,6 +465,7 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int excp_model, int excp)
              env->spr[SPR_DSISR] |= (insn & 0x03FF0000) >> 16;
          }
          break;
+#endif
      case POWERPC_EXCP_PROGRAM:   /* Program exception                        */
          switch (env->error_code & ~0xF) {
          case POWERPC_EXCP_FP:

Shouldn't we move that code under ppc_cpu_do_unaligned_access ?

Thanks,

C.

#4 lore raw
Quoted 38 lines · Cédric Le Goater
Quoted 37 lines · Fabiano Rosas

We cannot have TCG code in powerpc_excp because the function is called from kvm-only code via ppc_cpu_do_interrupt:

../target/ppc/excp_helper.c:463:29: error: implicit declaration of function ‘cpu_ldl_code’ [-Werror=implicit-function-declaration]

Fortunately, the Alignment interrupt is not among the ones dispatched from kvm-only code, so we can keep it out of the disable-tcg build for now.

Fixes 336e91f853 ("target/ppc: Move SPR_DSISR setting to powerpc_excp")

---

Perhaps we could make powerpc_excp TCG only and have a separate function that only knows the two interrupts that we use with KVM (Program, Machine check). But for now this fix will do, I think.

---
  target/ppc/excp_helper.c | 2 ++
  1 file changed, 2 insertions(+)
target/ppc/excp_helper.c +1 -0
index 17607adbe4..dcf22440cc 100644
@@ -453,6 +453,7 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int excp_model, int excp)
          }
          break;
      }
+#ifdef CONFIG_TCG
      case POWERPC_EXCP_ALIGN:     /* Alignment exception                      */
          /*
           * Get rS/rD and rA from faulting opcode.
@@ -464,6 +465,7 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int excp_model, int excp)
              env->spr[SPR_DSISR] |= (insn & 0x03FF0000) >> 16;
          }
Quoted 8 lines

target/ppc/excp_helper.c static inline void powerpc_excp(PowerPCCPU *cpu, int excp_model, int excp) · line 471

Quoted 6 lines
target/ppc/excp_helper.c +1 -0
          break;
+#endif
      case POWERPC_EXCP_PROGRAM:   /* Program exception                        */
          switch (env->error_code & ~0xF) {
          case POWERPC_EXCP_FP:

Shouldn't we move that code under ppc_cpu_do_unaligned_access ?

Well, it came from there initially. We could revert 336e91f853 and that would fix the issue as well.

Quoted 4 lines

Thanks,

C.

#5 lore raw

Richard,

Quoted 49 lines · Fabiano Rosas
Quoted 38 lines · Cédric Le Goater
Quoted 37 lines · Fabiano Rosas

We cannot have TCG code in powerpc_excp because the function is called from kvm-only code via ppc_cpu_do_interrupt:

../target/ppc/excp_helper.c:463:29: error: implicit declaration of function ‘cpu_ldl_code’ [-Werror=implicit-function-declaration]

Fortunately, the Alignment interrupt is not among the ones dispatched from kvm-only code, so we can keep it out of the disable-tcg build for now.

Fixes 336e91f853 ("target/ppc: Move SPR_DSISR setting to powerpc_excp")

---

Perhaps we could make powerpc_excp TCG only and have a separate function that only knows the two interrupts that we use with KVM (Program, Machine check). But for now this fix will do, I think.

---
   target/ppc/excp_helper.c | 2 ++
   1 file changed, 2 insertions(+)
target/ppc/excp_helper.c +1 -0
index 17607adbe4..dcf22440cc 100644
@@ -453,6 +453,7 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int excp_model, int excp)
           }
           break;
       }
+#ifdef CONFIG_TCG
       case POWERPC_EXCP_ALIGN:     /* Alignment exception                      */
           /*
            * Get rS/rD and rA from faulting opcode.
@@ -464,6 +465,7 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int excp_model, int excp)
               env->spr[SPR_DSISR] |= (insn & 0x03FF0000) >> 16;
           }
Quoted 8 lines

target/ppc/excp_helper.c static inline void powerpc_excp(PowerPCCPU *cpu, int excp_model, int excp) · line 471

Quoted 6 lines
target/ppc/excp_helper.c +1 -0
           break;
+#endif
       case POWERPC_EXCP_PROGRAM:   /* Program exception                        */
           switch (env->error_code & ~0xF) {
           case POWERPC_EXCP_FP:

Shouldn't we move that code under ppc_cpu_do_unaligned_access ?

Quoted 2 lines

Well, it came from there initially. We could revert 336e91f853 and that would fix the issue as well.

What would you prefer ?

Thanks,

C.

#6 lore raw
Quoted 52 lines · Cédric Le Goater

Richard,

Quoted 49 lines · Fabiano Rosas
Quoted 46 lines · Cédric Le Goater
Quoted 36 lines · Fabiano Rosas

We cannot have TCG code in powerpc_excp because the function is called from kvm-only code via ppc_cpu_do_interrupt:

../target/ppc/excp_helper.c:463:29: error: implicit declaration of function ‘cpu_ldl_code’ [-Werror=implicit-function-declaration]

Fortunately, the Alignment interrupt is not among the ones dispatched from kvm-only code, so we can keep it out of the disable-tcg build for now.

Fixes 336e91f853 ("target/ppc: Move SPR_DSISR setting to powerpc_excp")

---

Perhaps we could make powerpc_excp TCG only and have a separate function that only knows the two interrupts that we use with KVM (Program, Machine check). But for now this fix will do, I think.

---
   target/ppc/excp_helper.c | 2 ++
   1 file changed, 2 insertions(+)
target/ppc/excp_helper.c +1 -0
index 17607adbe4..dcf22440cc 100644
@@ -453,6 +453,7 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int excp_model, int excp)
           }
           break;
       }
+#ifdef CONFIG_TCG
       case POWERPC_EXCP_ALIGN:     /* Alignment exception                      */
           /*
            * Get rS/rD and rA from faulting opcode.

target/ppc/excp_helper.c static inline void powerpc_excp(PowerPCCPU *cpu, int excp_model, int excp) · line 471

Quoted 7 lines
target/ppc/excp_helper.c +1 -0
@@ -464,6 +465,7 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int excp_model, int excp)
               env->spr[SPR_DSISR] |= (insn & 0x03FF0000) >> 16;
           }
           break;
+#endif
       case POWERPC_EXCP_PROGRAM:   /* Program exception                        */
           switch (env->error_code & ~0xF) {
           case POWERPC_EXCP_FP:

Shouldn't we move that code under ppc_cpu_do_unaligned_access ?

Quoted 4 lines
Quoted 2 lines

Well, it came from there initially. We could revert 336e91f853 and that would fix the issue as well.

What would you prefer ?

Well none of this interfere with the work I'm doing, so it really makes no difference. I guess reverting the patch is cleaner than having an ifdef loose in the middle of the code. I'll send a v2 with the revert.

Quoted 4 lines

Thanks,

C.

#7 lore raw
Quoted 54 lines · Fabiano Rosas
Quoted 52 lines · Cédric Le Goater

Richard,

Quoted 49 lines · Fabiano Rosas
Quoted 46 lines · Cédric Le Goater
Quoted 36 lines · Fabiano Rosas

We cannot have TCG code in powerpc_excp because the function is called from kvm-only code via ppc_cpu_do_interrupt:

../target/ppc/excp_helper.c:463:29: error: implicit declaration of function ‘cpu_ldl_code’ [-Werror=implicit-function-declaration]

Fortunately, the Alignment interrupt is not among the ones dispatched from kvm-only code, so we can keep it out of the disable-tcg build for now.

Fixes 336e91f853 ("target/ppc: Move SPR_DSISR setting to powerpc_excp")

---

Perhaps we could make powerpc_excp TCG only and have a separate function that only knows the two interrupts that we use with KVM (Program, Machine check). But for now this fix will do, I think.

---
   target/ppc/excp_helper.c | 2 ++
   1 file changed, 2 insertions(+)
target/ppc/excp_helper.c +1 -0
index 17607adbe4..dcf22440cc 100644
@@ -453,6 +453,7 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int excp_model, int excp)
           }
           break;
       }
+#ifdef CONFIG_TCG
       case POWERPC_EXCP_ALIGN:     /* Alignment exception                      */
           /*
            * Get rS/rD and rA from faulting opcode.

target/ppc/excp_helper.c static inline void powerpc_excp(PowerPCCPU *cpu, int excp_model, int excp) · line 471

Quoted 7 lines
target/ppc/excp_helper.c +1 -0
@@ -464,6 +465,7 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int excp_model, int excp)
               env->spr[SPR_DSISR] |= (insn & 0x03FF0000) >> 16;
           }
           break;
+#endif
       case POWERPC_EXCP_PROGRAM:   /* Program exception                        */
           switch (env->error_code & ~0xF) {
           case POWERPC_EXCP_FP:

Shouldn't we move that code under ppc_cpu_do_unaligned_access ?

Quoted 9 lines
Quoted 4 lines
Quoted 2 lines

Well, it came from there initially. We could revert 336e91f853 and that would fix the issue as well.

What would you prefer ?

Well none of this interfere with the work I'm doing, so it really makes no difference. I guess reverting the patch is cleaner than having an ifdef loose in the middle of the code. I'll send a v2 with the revert.

Ah I missed that you were talking to Richard! That first line got kind of hidden.

I already sent a v2, but as I said, I have no preference either way. Let's hear from Richard.

Sorry for the confusion =)

Quoted 4 lines
Quoted 4 lines

Thanks,

C.