aboutsummaryrefslogtreecommitdiff
path: root/target
diff options
context:
space:
mode:
authorIlya Leoshkevich <iii@linux.ibm.com>2023-03-16 22:07:50 +0100
committerThomas Huth <thuth@redhat.com>2023-03-20 09:32:50 +0100
commit703d03a4aaf38f285555ef5422ba5ce075416fc4 (patch)
treed288ab0eec917cc3c26114d1c54e4a32e6f12d3c /target
parent04fce706bd227c66738e965fc14b575edde598ed (diff)
downloadqemu-703d03a4aaf38f285555ef5422ba5ce075416fc4.zip
qemu-703d03a4aaf38f285555ef5422ba5ce075416fc4.tar.gz
qemu-703d03a4aaf38f285555ef5422ba5ce075416fc4.tar.bz2
target/s390x: Fix EXECUTE of relative long instructions
The code uses the wrong base for relative addressing: it should use the target instruction address and not the EXECUTE's address. Fix by storing the target instruction address in the new CPUS390XState member and loading it from the code generated by gen_ri2(). Reported-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: David Hildenbrand <david@redhat.com> Message-Id: <20230316210751.302423-2-iii@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'target')
-rw-r--r--target/s390x/cpu.h1
-rw-r--r--target/s390x/tcg/mem_helper.c1
-rw-r--r--target/s390x/tcg/translate.c13
3 files changed, 14 insertions, 1 deletions
diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
index 16f6354..82c2f57 100644
--- a/target/s390x/cpu.h
+++ b/target/s390x/cpu.h
@@ -87,6 +87,7 @@ struct CPUArchState {
uint64_t cc_vr;
uint64_t ex_value;
+ uint64_t ex_target;
uint64_t __excp_addr;
uint64_t psa;
diff --git a/target/s390x/tcg/mem_helper.c b/target/s390x/tcg/mem_helper.c
index 6835c26..00afae2 100644
--- a/target/s390x/tcg/mem_helper.c
+++ b/target/s390x/tcg/mem_helper.c
@@ -2530,6 +2530,7 @@ void HELPER(ex)(CPUS390XState *env, uint32_t ilen, uint64_t r1, uint64_t addr)
that ex_value is non-zero, which flags that we are in a state
that requires such execution. */
env->ex_value = insn | ilen;
+ env->ex_target = addr;
}
uint32_t HELPER(mvcos)(CPUS390XState *env, uint64_t dest, uint64_t src,
diff --git a/target/s390x/tcg/translate.c b/target/s390x/tcg/translate.c
index 6758d9f..a6d81ed 100644
--- a/target/s390x/tcg/translate.c
+++ b/target/s390x/tcg/translate.c
@@ -5769,7 +5769,18 @@ static void in2_a2(DisasContext *s, DisasOps *o)
static TCGv gen_ri2(DisasContext *s)
{
- return tcg_constant_i64(s->base.pc_next + (int64_t)get_field(s, i2) * 2);
+ int64_t delta = (int64_t)get_field(s, i2) * 2;
+ TCGv ri2;
+
+ if (unlikely(s->ex_value)) {
+ ri2 = tcg_temp_new_i64();
+ tcg_gen_ld_i64(ri2, cpu_env, offsetof(CPUS390XState, ex_target));
+ tcg_gen_addi_i64(ri2, ri2, delta);
+ } else {
+ ri2 = tcg_constant_i64(s->base.pc_next + delta);
+ }
+
+ return ri2;
}
static void in2_ri2(DisasContext *s, DisasOps *o)