* [PATCH v2] target/loongarch: Fix [X]VLDI raising exception incorrectly
@ 2025-08-04 13:22 WANG Rui
2025-08-06 7:28 ` gaosong
0 siblings, 1 reply; 2+ messages in thread
From: WANG Rui @ 2025-08-04 13:22 UTC (permalink / raw)
To: gaosong, bibo mao
Cc: Richard Henderson, Philippe Mathieu-Daudé, qemu-devel, qemu,
WANG Rui, Zhou Qiankang
According to the specification, [X]VLDI should trigger an invalid instruction
exception only when Bit[12] is 1 and Bit[11:8] > 12. This patch fixes an issue
where an exception was incorrectly raised even when Bit[12] was 0.
Test case:
```
.global main
main:
vldi $vr0, 3328
ret
```
Reported-by: Zhou Qiankang <wszqkzqk@qq.com>
Signed-off-by: WANG Rui <wangrui@loongson.cn>
---
v1 -> v2:
- Keep the INE exception prioritized over the [A]SXD.
---
target/loongarch/tcg/insn_trans/trans_vec.c.inc | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/target/loongarch/tcg/insn_trans/trans_vec.c.inc b/target/loongarch/tcg/insn_trans/trans_vec.c.inc
index 78730029cb..38bccf2838 100644
--- a/target/loongarch/tcg/insn_trans/trans_vec.c.inc
+++ b/target/loongarch/tcg/insn_trans/trans_vec.c.inc
@@ -3585,7 +3585,9 @@ static bool gen_vldi(DisasContext *ctx, arg_vldi *a, uint32_t oprsz)
int sel, vece;
uint64_t value;
- if (!check_valid_vldi_mode(a)) {
+ sel = (a->imm >> 12) & 0x1;
+
+ if (sel && !check_valid_vldi_mode(a)) {
generate_exception(ctx, EXCCODE_INE);
return true;
}
@@ -3594,8 +3596,6 @@ static bool gen_vldi(DisasContext *ctx, arg_vldi *a, uint32_t oprsz)
return true;
}
- sel = (a->imm >> 12) & 0x1;
-
if (sel) {
value = vldi_get_value(ctx, a->imm);
vece = MO_64;
--
2.50.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] target/loongarch: Fix [X]VLDI raising exception incorrectly
2025-08-04 13:22 [PATCH v2] target/loongarch: Fix [X]VLDI raising exception incorrectly WANG Rui
@ 2025-08-06 7:28 ` gaosong
0 siblings, 0 replies; 2+ messages in thread
From: gaosong @ 2025-08-06 7:28 UTC (permalink / raw)
To: WANG Rui, bibo mao
Cc: Richard Henderson, Philippe Mathieu-Daudé, qemu-devel, qemu,
Zhou Qiankang
在 2025/8/4 下午9:22, WANG Rui 写道:
> According to the specification, [X]VLDI should trigger an invalid instruction
> exception only when Bit[12] is 1 and Bit[11:8] > 12. This patch fixes an issue
> where an exception was incorrectly raised even when Bit[12] was 0.
>
> Test case:
>
> ```
> .global main
> main:
> vldi $vr0, 3328
> ret
> ```
>
> Reported-by: Zhou Qiankang <wszqkzqk@qq.com>
> Signed-off-by: WANG Rui <wangrui@loongson.cn>
> ---
> v1 -> v2:
> - Keep the INE exception prioritized over the [A]SXD.
> ---
> target/loongarch/tcg/insn_trans/trans_vec.c.inc | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
Reviewed-by: Song Gao <gaosong@loongson.cn>
Thanks
Song Gao
> diff --git a/target/loongarch/tcg/insn_trans/trans_vec.c.inc b/target/loongarch/tcg/insn_trans/trans_vec.c.inc
> index 78730029cb..38bccf2838 100644
> --- a/target/loongarch/tcg/insn_trans/trans_vec.c.inc
> +++ b/target/loongarch/tcg/insn_trans/trans_vec.c.inc
> @@ -3585,7 +3585,9 @@ static bool gen_vldi(DisasContext *ctx, arg_vldi *a, uint32_t oprsz)
> int sel, vece;
> uint64_t value;
>
> - if (!check_valid_vldi_mode(a)) {
> + sel = (a->imm >> 12) & 0x1;
> +
> + if (sel && !check_valid_vldi_mode(a)) {
> generate_exception(ctx, EXCCODE_INE);
> return true;
> }
> @@ -3594,8 +3596,6 @@ static bool gen_vldi(DisasContext *ctx, arg_vldi *a, uint32_t oprsz)
> return true;
> }
>
> - sel = (a->imm >> 12) & 0x1;
> -
> if (sel) {
> value = vldi_get_value(ctx, a->imm);
> vece = MO_64;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-08-06 7:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-04 13:22 [PATCH v2] target/loongarch: Fix [X]VLDI raising exception incorrectly WANG Rui
2025-08-06 7:28 ` gaosong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).