Skip to contentSkip to conversation

target/arm: Add missing break statement for Hypervisor Trap Exception

Qemu-arm Philippe Mathieu-Daudé 2 participants 3 messages Jul 19, 2019

lore
Share & tools
lore
#0 lore raw

Reported by GCC9 when building with -Wimplicit-fallthrough=2:

target/arm/helper.c: In function ‘arm_cpu_do_interrupt_aarch32_hyp’:
target/arm/helper.c:7958:14: error: this statement may fall through [-Werror=implicit-fallthrough=]

   7958 |         addr = 0x14;
        |         ~~~~~^~~~~~
  target/arm/helper.c:7959:5: note: here
   7959 |     default:
        |     ^~~~~~~

cc1: all warnings being treated as errors

Fixes b9bc21ff9f9
---
 target/arm/helper.c | 1 +
 1 file changed, 1 insertion(+)
target/arm/helper.c +1 -0
index 20f8728be1..b74c23a9bc 100644
@@ -7956,6 +7956,7 @@ static void arm_cpu_do_interrupt_aarch32_hyp(CPUState *cs)
         break;
     case EXCP_HYP_TRAP:
         addr = 0x14;
+        break;
     default:
         cpu_abort(cs, "Unhandled exception 0x%x\n", cs->exception_index);
     }
Signature · 1 line
2.20.1
Reviewed-by
#1 lore raw
Quoted 23 lines · Philippe Mathieu-Daudé

Reported by GCC9 when building with -Wimplicit-fallthrough=2:

target/arm/helper.c: In function ‘arm_cpu_do_interrupt_aarch32_hyp’:
target/arm/helper.c:7958:14: error: this statement may fall through [-Werror=implicit-fallthrough=]

   7958 |         addr = 0x14;
        |         ~~~~~^~~~~~
  target/arm/helper.c:7959:5: note: here
   7959 |     default:
        |     ^~~~~~~

cc1: all warnings being treated as errors

Fixes b9bc21ff9f9
---
 target/arm/helper.c | 1 +
 1 file changed, 1 insertion(+)
target/arm/helper.c +0 -0
index 20f8728be1..b74c23a9bc 100644

target/arm/helper.c static void arm_cpu_do_interrupt_aarch32_hyp(CPUState *cs) · line 7962

Quoted 7 lines
target/arm/helper.c +1 -0
@@ -7956,6 +7956,7 @@ static void arm_cpu_do_interrupt_aarch32_hyp(CPUState *cs)
         break;
     case EXCP_HYP_TRAP:
         addr = 0x14;
+        break;
     default:
         cpu_abort(cs, "Unhandled exception 0x%x\n", cs->exception_index);
     }

I think this is right, but EXCP_HYP_TRAP is a bit odd -- we appear to use this only for the case of "SMC instruction is trapped from NS EL1 to EL2 by HCR.TSC". I was expecting more traps-to-EL2 to use this EXCP_ variable... Mostly we seem to use EXCP_UDEF, eg for CP_ACCESS_TRAP_UNCATEGORIZED_EL2 coprocessor/sysreg accesses:
this has the same behaviour as EXCP_HYP_TRAP as long as we know we are going from an EL below 2 to EL2. Which I think we could also use in the one place we use EXCP_HYP_TRAP; or we could make wider use of EXCP_HYP_TRAP, since feeding everything through EXCP_UDEF is rather confusing.

Anyway, for 4.1 we should do this.

thanks
-- PMM

#2 lore raw
Quoted 43 lines · Peter Maydell
Quoted 23 lines · Philippe Mathieu-Daudé

Reported by GCC9 when building with -Wimplicit-fallthrough=2:

target/arm/helper.c: In function ‘arm_cpu_do_interrupt_aarch32_hyp’:
target/arm/helper.c:7958:14: error: this statement may fall through [-Werror=implicit-fallthrough=]

   7958 |         addr = 0x14;
        |         ~~~~~^~~~~~
  target/arm/helper.c:7959:5: note: here
   7959 |     default:
        |     ^~~~~~~

cc1: all warnings being treated as errors

Fixes b9bc21ff9f9
---
 target/arm/helper.c | 1 +
 1 file changed, 1 insertion(+)
target/arm/helper.c +0 -0
index 20f8728be1..b74c23a9bc 100644

target/arm/helper.c static void arm_cpu_do_interrupt_aarch32_hyp(CPUState *cs) · line 7962

Quoted 7 lines
target/arm/helper.c +1 -0
@@ -7956,6 +7956,7 @@ static void arm_cpu_do_interrupt_aarch32_hyp(CPUState *cs)
         break;
     case EXCP_HYP_TRAP:
         addr = 0x14;
+        break;
     default:
         cpu_abort(cs, "Unhandled exception 0x%x\n", cs->exception_index);
     }

I think this is right, but EXCP_HYP_TRAP is a bit odd -- we appear to use this only for the case of "SMC instruction is trapped from NS EL1 to EL2 by HCR.TSC". I was expecting more traps-to-EL2 to use this EXCP_ variable... Mostly we seem to use EXCP_UDEF, eg for CP_ACCESS_TRAP_UNCATEGORIZED_EL2 coprocessor/sysreg accesses:
this has the same behaviour as EXCP_HYP_TRAP as long as we know we are going from an EL below 2 to EL2. Which I think we could also use in the one place we use EXCP_HYP_TRAP; or we could make wider use of EXCP_HYP_TRAP, since feeding everything through EXCP_UDEF is rather confusing.

Quoted 2 lines

Anyway, for 4.1 we should do this.

Thanks, if you take this I forgot to mention:

Regards,

Phil.