Skip to content

Commit

Permalink
target/s390x: Fix relative long instructions with large offsets
Browse files Browse the repository at this point in the history
The expression "imm * 2" in gen_ri2() can wrap around if imm is large
enough.

Fix by casting imm to int64_t, like it's done in disas_jdest().

Fixes: e8ecdfe ("Fix EXECUTE of relative branches")
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Message-Id: <20230704081506.276055-8-iii@linux.ibm.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
  • Loading branch information
iii-i authored and huth committed Jul 10, 2023
1 parent b0ef810 commit 349372f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion target/s390x/tcg/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -5794,7 +5794,7 @@ static TCGv gen_ri2(DisasContext *s)

disas_jdest(s, i2, is_imm, imm, ri2);
if (is_imm) {
ri2 = tcg_constant_i64(s->base.pc_next + imm * 2);
ri2 = tcg_constant_i64(s->base.pc_next + (int64_t)imm * 2);
}

return ri2;
Expand Down

0 comments on commit 349372f

Please sign in to comment.