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

Chen Qun posted 1 patch 3 years, 6 months ago
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20201028041620.2168707-1-kuhn.chenqun@huawei.com
target/ppc/excp_helper.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] target/ppc/excp_helper: Add a missing break for POWERPC_EXCP_HISI
Posted by Chen Qun 3 years, 6 months ago
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.

Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>

---
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(+)

diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c
index a988ba15f4..5e69ac1b33 100644
--- a/target/ppc/excp_helper.c
+++ b/target/ppc/excp_helper.c
@@ -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        */
-- 
2.27.0


Re: [PATCH] target/ppc/excp_helper: Add a missing break for POWERPC_EXCP_HISI
Posted by David Gibson 3 years, 6 months ago
On Wed, Oct 28, 2020 at 12:16:20PM +0800, Chen Qun wrote:
> 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.
> 
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>

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.

> 
> ---
> 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(+)
> 
> diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c
> index a988ba15f4..5e69ac1b33 100644
> --- a/target/ppc/excp_helper.c
> +++ b/target/ppc/excp_helper.c
> @@ -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        */

-- 
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
RE: [PATCH] target/ppc/excp_helper: Add a missing break for POWERPC_EXCP_HISI
Posted by Chenqun (kuhn) 3 years, 6 months ago
> -----Original Message-----
> From: David Gibson [mailto:david@gibson.dropbear.id.au]
> Sent: Wednesday, October 28, 2020 12:28 PM
> To: Chenqun (kuhn) <kuhn.chenqun@huawei.com>
> Cc: qemu-devel@nongnu.org; qemu-trivial@nongnu.org; clg@kaod.org;
> Zhanghailiang <zhang.zhanghailiang@huawei.com>; ganqixin
> <ganqixin@huawei.com>; Euler Robot <euler.robot@huawei.com>
> Subject: Re: [PATCH] target/ppc/excp_helper: Add a missing break for
> POWERPC_EXCP_HISI
> 
> On Wed, Oct 28, 2020 at 12:16:20PM +0800, Chen Qun wrote:
> > 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.
> >
> > Reported-by: Euler Robot <euler.robot@huawei.com>
> > Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
> 
> 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
> >
> > ---
> > 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(+)
> >
> > diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index
> > a988ba15f4..5e69ac1b33 100644
> > --- a/target/ppc/excp_helper.c
> > +++ b/target/ppc/excp_helper.c
> > @@ -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        */
> 
> --
> 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