Skip to contentSkip to conversation

target/s390x: Fix the accumulation of ccm in op_icm

PATCH In review Richard Henderson 3 participants 5 messages Apr 1, 2022 – Apr 27, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/s390x: Fix the accumulation of ccm in op_icm

Coverity rightly reports that 0xff << pos can overflow. This would affect the ICMH instruction.

Fixes Coverity CID 1487161
---
 target/s390x/tcg/translate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/s390x/tcg/translate.c +1 -1
index 5acfc0ff9b..ea7baf0832 100644
@@ -2622,7 +2622,7 @@ static DisasJumpType op_icm(DisasContext *s, DisasOps *o)
                 tcg_gen_qemu_ld8u(tmp, o->in2, get_mem_index(s));
                 tcg_gen_addi_i64(o->in2, o->in2, 1);
                 tcg_gen_deposit_i64(o->out, o->out, tmp, pos, 8);
-                ccm |= 0xff << pos;
+                ccm |= 0xffull << pos;
             }
             m3 = (m3 << 1) & 0xf;
             pos -= 8;
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 14 lines · Richard Henderson

Coverity rightly reports that 0xff << pos can overflow. This would affect the ICMH instruction.

Fixes Coverity CID 1487161
---
  target/s390x/tcg/translate.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
target/s390x/tcg/translate.c +0 -0
index 5acfc0ff9b..ea7baf0832 100644

target/s390x/tcg/translate.c static DisasJumpType op_icm(DisasContext *s, DisasOps *o) · line 2628

Quoted 8 lines
target/s390x/tcg/translate.c +1 -1
@@ -2622,7 +2622,7 @@ static DisasJumpType op_icm(DisasContext *s, DisasOps *o)
                  tcg_gen_qemu_ld8u(tmp, o->in2, get_mem_index(s));
                  tcg_gen_addi_i64(o->in2, o->in2, 1);
                  tcg_gen_deposit_i64(o->out, o->out, tmp, pos, 8);
-                ccm |= 0xff << pos;
+                ccm |= 0xffull << pos;
              }
              m3 = (m3 << 1) & 0xf;
              pos -= 8;

Is this still something for 7.0, or can it wait for the 7.1 cycle?

#2 lore raw
Quoted 26 lines · Thomas Huth
Quoted 14 lines · Richard Henderson

Coverity rightly reports that 0xff << pos can overflow. This would affect the ICMH instruction.

Fixes Coverity CID 1487161

---
  target/s390x/tcg/translate.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
target/s390x/tcg/translate.c +0 -0
index 5acfc0ff9b..ea7baf0832 100644

target/s390x/tcg/translate.c static DisasJumpType op_icm(DisasContext *s, DisasOps *o) · line 2628

Quoted 8 lines
target/s390x/tcg/translate.c +1 -1
@@ -2622,7 +2622,7 @@ static DisasJumpType op_icm(DisasContext *s, DisasOps *o)
                   tcg_gen_qemu_ld8u(tmp, o->in2, get_mem_index(s));
                   tcg_gen_addi_i64(o->in2, o->in2, 1);
                   tcg_gen_deposit_i64(o->out, o->out, tmp, pos, 8);
-                ccm |= 0xff << pos;
+                ccm |= 0xffull << pos;
               }
               m3 = (m3 << 1) & 0xf;
               pos -= 8;
Quoted 1 line

Is this still something for 7.0, or can it wait for the 7.1 cycle?

The bug has been present since 2012, affecting only the cc value of icmh. It could wait for 7.1.

r~

Reviewed-by on v1 1/1
#3 lore raw
In reply to Richard Henderson
Quoted 14 lines · Richard Henderson

Coverity rightly reports that 0xff << pos can overflow. This would affect the ICMH instruction.

Fixes Coverity CID 1487161
---
 target/s390x/tcg/translate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/s390x/tcg/translate.c +0 -0
index 5acfc0ff9b..ea7baf0832 100644

target/s390x/tcg/translate.c static DisasJumpType op_icm(DisasContext *s, DisasOps *o) · line 2628

Quoted 8 lines
target/s390x/tcg/translate.c +1 -1
@@ -2622,7 +2622,7 @@ static DisasJumpType op_icm(DisasContext *s, DisasOps *o)
                 tcg_gen_qemu_ld8u(tmp, o->in2, get_mem_index(s));
                 tcg_gen_addi_i64(o->in2, o->in2, 1);
                 tcg_gen_deposit_i64(o->out, o->out, tmp, pos, 8);
-                ccm |= 0xff << pos;
+                ccm |= 0xffull << pos;
             }
             m3 = (m3 << 1) & 0xf;
             pos -= 8;
Signature · 3 lines
Thanks,

David / dhildenb
#4 lore raw
In reply to Richard Henderson
Quoted 14 lines · Richard Henderson

Coverity rightly reports that 0xff << pos can overflow. This would affect the ICMH instruction.

Fixes Coverity CID 1487161
---
  target/s390x/tcg/translate.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
target/s390x/tcg/translate.c +0 -0
index 5acfc0ff9b..ea7baf0832 100644

target/s390x/tcg/translate.c static DisasJumpType op_icm(DisasContext *s, DisasOps *o) · line 2628

Quoted 8 lines
target/s390x/tcg/translate.c +1 -1
@@ -2622,7 +2622,7 @@ static DisasJumpType op_icm(DisasContext *s, DisasOps *o)
                  tcg_gen_qemu_ld8u(tmp, o->in2, get_mem_index(s));
                  tcg_gen_addi_i64(o->in2, o->in2, 1);
                  tcg_gen_deposit_i64(o->out, o->out, tmp, pos, 8);
-                ccm |= 0xff << pos;
+                ccm |= 0xffull << pos;
              }
              m3 = (m3 << 1) & 0xf;
              pos -= 8;

Queuing to tcg-next.

r~