diff options
author | Song Gao <gaosong@loongson.cn> | 2025-06-04 16:40:05 +0800 |
---|---|---|
committer | Song Gao <gaosong@loongson.cn> | 2025-06-19 15:57:31 +0800 |
commit | c2a2e1ad2a749caa864281b1d4dc3f16c3f344f6 (patch) | |
tree | b55df5d2fd4163ede36bc0e70433c9acf078ab22 | |
parent | 27f5d500c2259650076e3abd72f092b566fd81ac (diff) | |
download | qemu-c2a2e1ad2a749caa864281b1d4dc3f16c3f344f6.zip qemu-c2a2e1ad2a749caa864281b1d4dc3f16c3f344f6.tar.gz qemu-c2a2e1ad2a749caa864281b1d4dc3f16c3f344f6.tar.bz2 |
target/loongarch: fix vldi/xvldi raise wrong error
on qemu we got an aborted error
**
ERROR:../target/loongarch/tcg/insn_trans/trans_vec.c.inc:3574:vldi_get_value: code should not be reached
Bail out! ERROR:../target/loongarch/tcg/insn_trans/trans_vec.c.inc:3574:vldi_get_value: code should not be reached
Aborted (core dumped)
but on 3A600/3A5000 we got a "Illegal instruction" error.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2971
Fixes: 29bb5d727ff ("target/loongarch: Implement vldi")
Cc: qemu-stable@nongnu.org
Reviewed-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Song Gao <gaosong@loongson.cn>
-rw-r--r-- | target/loongarch/tcg/insn_trans/trans_vec.c.inc | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/target/loongarch/tcg/insn_trans/trans_vec.c.inc b/target/loongarch/tcg/insn_trans/trans_vec.c.inc index d6f0560..7873002 100644 --- a/target/loongarch/tcg/insn_trans/trans_vec.c.inc +++ b/target/loongarch/tcg/insn_trans/trans_vec.c.inc @@ -3465,7 +3465,7 @@ TRANS(xvmsknz_b, LASX, gen_xx, gen_helper_vmsknz_b) static uint64_t vldi_get_value(DisasContext *ctx, uint32_t imm) { int mode; - uint64_t data, t; + uint64_t data = 0, t; /* * imm bit [11:8] is mode, mode value is 0-12. @@ -3570,17 +3570,26 @@ static uint64_t vldi_get_value(DisasContext *ctx, uint32_t imm) } break; default: - generate_exception(ctx, EXCCODE_INE); g_assert_not_reached(); } return data; } +static bool check_valid_vldi_mode(arg_vldi *a) +{ + return extract32(a->imm, 8, 4) <= 12; +} + static bool gen_vldi(DisasContext *ctx, arg_vldi *a, uint32_t oprsz) { int sel, vece; uint64_t value; + if (!check_valid_vldi_mode(a)) { + generate_exception(ctx, EXCCODE_INE); + return true; + } + if (!check_vec(ctx, oprsz)) { return true; } |