qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v6] target/loongarch: fix vldi/xvldi raise wrong error


From: Bibo Mao
Subject: Re: [PATCH v6] target/loongarch: fix vldi/xvldi raise wrong error
Date: Thu, 19 Jun 2025 09:44:04 +0800
User-agent: Mozilla/5.0 (X11; Linux loongarch64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0

It will be better if check_vldi_mode() is renamed as check_valid_vldi_mode().

Reviewed-by: Bibo Mao <maobibo@loongson.cn>

On 2025/6/18 下午3:49, gaosong wrote:
Ping ! :-)
在 2025/6/5 上午9:53, Song Gao 写道:
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: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Song Gao <gaosong@loongson.cn>
---
  target/loongarch/tcg/insn_trans/trans_vec.c.inc | 13 +++++++++++--
  1 file 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 dff92772ad..7e50fa7541 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_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_vldi_mode(a)) {
+        generate_exception(ctx, EXCCODE_INE);
+        return true;
+    }
+
      if (!check_vec(ctx, oprsz)) {
          return true;
      }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]