Skip to content

Commit 46cdfdf

Browse files
gaosong-loongsonMichael Tokarev
authored andcommitted
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: 29bb5d7 ("target/loongarch: Implement vldi") Cc: [email protected] Reviewed-by: Bibo Mao <[email protected]> Reviewed-by: Richard Henderson <[email protected]> Signed-off-by: Song Gao <[email protected]> (cherry picked from commit c2a2e1ad2a749caa864281b1d4dc3f16c3f344f6) Signed-off-by: Michael Tokarev <[email protected]>
1 parent fdd2028 commit 46cdfdf

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

target/loongarch/tcg/insn_trans/trans_vec.c.inc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3465,7 +3465,7 @@ TRANS(xvmsknz_b, LASX, gen_xx, gen_helper_vmsknz_b)
34653465
static uint64_t vldi_get_value(DisasContext *ctx, uint32_t imm)
34663466
{
34673467
int mode;
3468-
uint64_t data, t;
3468+
uint64_t data = 0, t;
34693469

34703470
/*
34713471
* 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)
35703570
}
35713571
break;
35723572
default:
3573-
generate_exception(ctx, EXCCODE_INE);
35743573
g_assert_not_reached();
35753574
}
35763575
return data;
35773576
}
35783577

3578+
static bool check_valid_vldi_mode(arg_vldi *a)
3579+
{
3580+
return extract32(a->imm, 8, 4) <= 12;
3581+
}
3582+
35793583
static bool gen_vldi(DisasContext *ctx, arg_vldi *a, uint32_t oprsz)
35803584
{
35813585
int sel, vece;
35823586
uint64_t value;
35833587

3588+
if (!check_valid_vldi_mode(a)) {
3589+
generate_exception(ctx, EXCCODE_INE);
3590+
return true;
3591+
}
3592+
35843593
if (!check_vec(ctx, oprsz)) {
35853594
return true;
35863595
}

0 commit comments

Comments
 (0)