Skip to contentSkip to conversation

target/ppc/excp_helper: Add a missing break for POWERPC_EXCP_HISI

PATCH In review Chen Qun 2 participants 3 messages Oct 28, 2020

lore
Share & tools
lore

Chen Qun

author
#0 lore raw

PATCH 1/1 target/ppc/excp_helper: Add a missing break for POWERPC_EXCP_HISI

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed warning:
../target/ppc/excp_helper.c: In function ‘powerpc_excp’:
../target/ppc/excp_helper.c:529:13: warning: this statement may fall through [-Wimplicit-fallthrough=]

  529 |         msr |= env->error_code;
      |         ~~~~^~~~~~~~~~~~~~~~~~
../target/ppc/excp_helper.c:530:5: note: here
  530 |     case POWERPC_EXCP_HDECR:     /* Hypervisor decrementer exception         */
      |     ^~~~

A break statement may be required to enter this exception.

---
I guess there's a break missing in 'POWERPC_EXCP_HISI' branch, just like the 'POWERPC_EXCP_ISI' branch.

---
 target/ppc/excp_helper.c | 1 +
 1 file changed, 1 insertion(+)
target/ppc/excp_helper.c +1 -0
index a988ba15f4..5e69ac1b33 100644
@@ -527,6 +527,7 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int excp_model, int excp)
         break;
     case POWERPC_EXCP_HISI:      /* Hypervisor instruction storage exception */
         msr |= env->error_code;
+        break;
     case POWERPC_EXCP_HDECR:     /* Hypervisor decrementer exception         */
     case POWERPC_EXCP_HDSI:      /* Hypervisor data storage exception        */
     case POWERPC_EXCP_HDSEG:     /* Hypervisor data segment exception        */
Signature · 1 line
2.27.0
#1 lore raw
Quoted 9 lines · Chen Qun

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed warning:
../target/ppc/excp_helper.c: In function ‘powerpc_excp’:
../target/ppc/excp_helper.c:529:13: warning: this statement may fall through [-Wimplicit-fallthrough=]

  529 |         msr |= env->error_code;
      |         ~~~~^~~~~~~~~~~~~~~~~~
../target/ppc/excp_helper.c:530:5: note: here
  530 |     case POWERPC_EXCP_HDECR:     /* Hypervisor decrementer exception         */
      |     ^~~~
Quoted 4 lines

A break statement may be required to enter this exception.

This change is incorrect. We definitely need the fallthrough to set srr[01] properly. So the correct fix is to annotate the fallthrough, not remove it.

Quoted 20 lines

---
I guess there's a break missing in 'POWERPC_EXCP_HISI' branch, just like the 'POWERPC_EXCP_ISI' branch.

---
 target/ppc/excp_helper.c | 1 +
 1 file changed, 1 insertion(+)
target/ppc/excp_helper.c +1 -0
index a988ba15f4..5e69ac1b33 100644
@@ -527,6 +527,7 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int excp_model, int excp)
         break;
     case POWERPC_EXCP_HISI:      /* Hypervisor instruction storage exception */
         msr |= env->error_code;
+        break;
     case POWERPC_EXCP_HDECR:     /* Hypervisor decrementer exception         */
     case POWERPC_EXCP_HDSI:      /* Hypervisor data storage exception        */
     case POWERPC_EXCP_HDSEG:     /* Hypervisor data segment exception        */
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#2 lore raw
Quoted 23 lines

-----Original Message-----
From: David Gibson [mailto:[email protected]]
Sent: Wednesday, October 28, 2020 12:28 PM
To: Chenqun (kuhn) <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Zhanghailiang <[email protected]>; ganqixin <[email protected]>; Euler Robot <[email protected]>
Subject: Re: [PATCH] target/ppc/excp_helper: Add a missing break for POWERPC_EXCP_HISI

Quoted 1 line · Chen Qun

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed

warning:

Quoted 2 lines

../target/ppc/excp_helper.c: In function ‘powerpc_excp’:
../target/ppc/excp_helper.c:529:13: warning: this statement may fall through

[-Wimplicit-fallthrough=]

Quoted 4 lines
  529 |         msr |= env->error_code;
      |         ~~~~^~~~~~~~~~~~~~~~~~

../target/ppc/excp_helper.c:530:5: note: here
530 | case POWERPC_EXCP_HDECR: /* Hypervisor

decrementer exception */

Quoted 2 lines
      |     ^~~~
Quoted 8 lines
Quoted 4 lines

A break statement may be required to enter this exception.

This change is incorrect. We definitely need the fallthrough to set srr[01] properly. So the correct fix is to annotate the fallthrough, not remove it.

OK, I'll modify it later.
'
Thanks,
Chen Qun

Quoted 32 lines

target/ppc/excp_helper.c static inline void powerpc_excp(PowerPCCPU *cpu,

Quoted 13 lines

---
I guess there's a break missing in 'POWERPC_EXCP_HISI' branch, just like the 'POWERPC_EXCP_ISI' branch.

---
 target/ppc/excp_helper.c | 1 +
 1 file changed, 1 insertion(+)
target/ppc/excp_helper.c index renamed from target/ppc/excp_helper.c +0 -0

a988ba15f4..5e69ac1b33 100644

target/ppc/excp_helper.c +0 -0
@@ -527,6 +527,7 @@ static inline void powerpc_excp(PowerPCCPU *cpu,

int excp_model, int excp)

target/ppc/excp_helper.c static inline void powerpc_excp(PowerPCCPU *cpu, · line 528

Quoted 2 lines
target/ppc/excp_helper.c +0 -0
         break;
     case POWERPC_EXCP_HISI:      /* Hypervisor instruction storage

exception */

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

Quoted 3 lines
target/ppc/excp_helper.c +1 -0
         msr |= env->error_code;
+        break;
     case POWERPC_EXCP_HDECR:     /* Hypervisor decrementer

exception */

target/ppc/excp_helper.c static inline void powerpc_excp(PowerPCCPU *cpu, · line 532

Quoted 1 line
target/ppc/excp_helper.c +0 -0
     case POWERPC_EXCP_HDSI:      /* Hypervisor data storage

exception */

target/ppc/excp_helper.c static inline void powerpc_excp(PowerPCCPU *cpu, · line 533

Quoted 1 line
target/ppc/excp_helper.c +0 -0
     case POWERPC_EXCP_HDSEG:     /* Hypervisor data segment

exception */

--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_
_other_

				| _way_ _around_!

http://www.ozlabs.org/~dgibson