diff options
author | Song Gao <gaosong@loongson.cn> | 2023-05-15 21:00:42 +0800 |
---|---|---|
committer | Song Gao <gaosong@loongson.cn> | 2023-05-26 17:21:12 +0800 |
commit | 2e2ca3c8fa52c03c3725edfdd726972a223b74f3 (patch) | |
tree | 0fa2388f4282f2aad3f893399aee9fce758293e9 /target/loongarch/op_helper.c | |
parent | a3cb6d5004ff638aefe686ecd540718a793bd1b1 (diff) |
target/loongarch: Fix LD/ST{LE/GT} instructions get wrong CSR_ERA and CSR_BADV
1.helper_asrtle_d/helper_asrtgt_d need use GETPC() to get PC;
2 LD/ST{LE/GT} need set CSR_BADV = gpr[rj];
3 ASRTLE.D/ASRTGT.D also write CSR_BADV, but this value is random
and has no reference value.
Signed-off-by: Song Gao <gaosong@loongson.cn>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20230515130042.2719712-1-gaosong@loongson.cn>
Diffstat (limited to 'target/loongarch/op_helper.c')
-rw-r--r-- | target/loongarch/op_helper.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/target/loongarch/op_helper.c b/target/loongarch/op_helper.c index 568c071601..60335a05e2 100644 --- a/target/loongarch/op_helper.c +++ b/target/loongarch/op_helper.c @@ -49,14 +49,16 @@ target_ulong helper_bitswap(target_ulong v) void helper_asrtle_d(CPULoongArchState *env, target_ulong rj, target_ulong rk) { if (rj > rk) { - do_raise_exception(env, EXCCODE_BCE, 0); + env->CSR_BADV = rj; + do_raise_exception(env, EXCCODE_BCE, GETPC()); } } void helper_asrtgt_d(CPULoongArchState *env, target_ulong rj, target_ulong rk) { if (rj <= rk) { - do_raise_exception(env, EXCCODE_BCE, 0); + env->CSR_BADV = rj; + do_raise_exception(env, EXCCODE_BCE, GETPC()); } } |