Skip to contentSkip to conversation

linux-user/ppc: Narrow type of ccr in save_user_regs

PATCH In review Richard Henderson 3 participants 6 messages Apr 1, 2022 – Apr 4, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux-user/ppc: Narrow type of ccr in save_user_regs

Coverity warns that we shift a 32-bit value by N, and then accumulate it into a 64-bit type (target_ulong on ppc64).

The ccr is always 8 * 4-bit fields, and thus is always a 32-bit quantity; narrow the type to avoid the warning.

Fixes Coverity CID 1487223
---
 linux-user/ppc/signal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/ppc/signal.c +1 -1
index ec0b9c0df3..ce5a4682cd 100644
@@ -229,7 +229,7 @@ static void save_user_regs(CPUPPCState *env, struct target_mcontext *frame)
 {
     target_ulong msr = env->msr;
     int i;
-    target_ulong ccr = 0;
+    uint32_t ccr = 0;
 
     /* In general, the kernel attempts to be intelligent about what it
        needs to save for Altivec/FP/SPE registers.  We don't care that
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Richard Henderson

Coverity warns that we shift a 32-bit value by N, and then accumulate it into a 64-bit type (target_ulong on ppc64).

The ccr is always 8 * 4-bit fields, and thus is always a 32-bit quantity; narrow the type to avoid the warning.

Fixes Coverity CID 1487223

Thanks,

C.

Quoted 17 lines
---
  linux-user/ppc/signal.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/ppc/signal.c +1 -1
index ec0b9c0df3..ce5a4682cd 100644
@@ -229,7 +229,7 @@ static void save_user_regs(CPUPPCState *env, struct target_mcontext *frame)
  {
      target_ulong msr = env->msr;
      int i;
-    target_ulong ccr = 0;
+    uint32_t ccr = 0;
 
      /* In general, the kernel attempts to be intelligent about what it
         needs to save for Altivec/FP/SPE registers.  We don't care that
#2 lore raw
In reply to Richard Henderson
Quoted 11 lines · Richard Henderson

Coverity warns that we shift a 32-bit value by N, and then accumulate it into a 64-bit type (target_ulong on ppc64).

The ccr is always 8 * 4-bit fields, and thus is always a 32-bit quantity; narrow the type to avoid the warning.

Fixes Coverity CID 1487223
---
  linux-user/ppc/signal.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

Queued for ppc-7.0

Thanks,

C.

Quoted 14 lines
linux-user/ppc/signal.c +1 -1
index ec0b9c0df3..ce5a4682cd 100644
@@ -229,7 +229,7 @@ static void save_user_regs(CPUPPCState *env, struct target_mcontext *frame)
  {
      target_ulong msr = env->msr;
      int i;
-    target_ulong ccr = 0;
+    uint32_t ccr = 0;
 
      /* In general, the kernel attempts to be intelligent about what it
         needs to save for Altivec/FP/SPE registers.  We don't care that
#3 lore raw
Quoted 8 lines · Cédric Le Goater
Quoted 6 lines · Richard Henderson

Coverity warns that we shift a 32-bit value by N, and then accumulate it into a 64-bit type (target_ulong on ppc64).

The ccr is always 8 * 4-bit fields, and thus is always a 32-bit quantity; narrow the type to avoid the warning.

Quoted 7 lines
Quoted 5 lines
Fixes Coverity CID 1487223
---
  linux-user/ppc/signal.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

Queued for ppc-7.0

NB that this is only suppressing a coverity warning, not correcting any incorrect behaviour, so if you don't have anything else you were planning to send for 7.0 it could also wait til 7.1.

thanks
-- PMM

#4 lore raw
Quoted 15 lines · Peter Maydell
Quoted 14 lines · Cédric Le Goater
Quoted 11 lines · Richard Henderson

Coverity warns that we shift a 32-bit value by N, and then accumulate it into a 64-bit type (target_ulong on ppc64).

The ccr is always 8 * 4-bit fields, and thus is always a 32-bit quantity; narrow the type to avoid the warning.

Fixes Coverity CID 1487223
---
   linux-user/ppc/signal.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 6 lines
Quoted 1 line

Queued for ppc-7.0

NB that this is only suppressing a coverity warning, not correcting any incorrect behaviour, so if you don't have anything else you were planning to send for 7.0 it could also wait til 7.1.

I have a couple of small fixes in :

https://github.com/legoater/qemu/commits/ppc-for-upstream

linux-user/ppc: Narrow type of ccr in save_user_regs ppc/pnv: Fix number of registers in the PCIe controller on POWER9 hw/ppc: free env->tb_env in spapr_unrealize_vcpu()

Nothing critical indeed. So these can wait 7.1 ?

Thanks,

C.

#5 lore raw
Quoted 26 lines · Cédric Le Goater
Quoted 15 lines · Peter Maydell
Quoted 14 lines · Cédric Le Goater
Quoted 11 lines · Richard Henderson

Coverity warns that we shift a 32-bit value by N, and then accumulate it into a 64-bit type (target_ulong on ppc64).

The ccr is always 8 * 4-bit fields, and thus is always a 32-bit quantity; narrow the type to avoid the warning.

Fixes Coverity CID 1487223
---
   linux-user/ppc/signal.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 6 lines
Quoted 1 line

Queued for ppc-7.0

NB that this is only suppressing a coverity warning, not correcting any incorrect behaviour, so if you don't have anything else you were planning to send for 7.0 it could also wait til 7.1.

I have a couple of small fixes in :

Quoted 7 lines

https://github.com/legoater/qemu/commits/ppc-for-upstream

linux-user/ppc: Narrow type of ccr in save_user_regs ppc/pnv: Fix number of registers in the PCIe controller on POWER9 hw/ppc: free env->tb_env in spapr_unrealize_vcpu()

Nothing critical indeed. So these can wait 7.1 ?

Up to you -- they're all small enough to be OK going into 7.0, and the other two are fixing real bugs.

thanks
-- PMM