Skip to contentSkip to conversation

target/riscv: rvv: Fix missing exit TB flow for ldff_trans

PATCH Applied Max Chou 3 participants 3 messages Jun 27, 2025 – Jun 30, 2025 RISC-V

lore
Share & tools
lore

Max Chou

author
#0 lore raw

PATCH 1/1 target/riscv: rvv: Fix missing exit TB flow for ldff_trans

According to the V spec, the vector fault-only-first load instructions may change the VL CSR.
So the ldff_trans TCG translation function should generate the lookup_and_goto_ptr flow as the vsetvl/vsetvli translation function to make sure the vl_eq_vlmax TB flag is correct.

---
 target/riscv/insn_trans/trans_rvv.c.inc | 6 ++++++
 1 file changed, 6 insertions(+)
target/riscv/insn_trans/trans_rvv.c.inc +6 -0
index 2b6077ac067..4cd030c7eb3 100644
@@ -1361,6 +1361,12 @@ static bool ldff_trans(uint32_t vd, uint32_t rs1, uint32_t data,
     fn(dest, mask, base, tcg_env, desc);
 
     finalize_rvv_inst(s);
+
+    /* vector unit-stride fault-only-first load may modify vl CSR */
+    gen_update_pc(s, s->cur_insn_len);
+    lookup_and_goto_ptr(s);
+    s->base.is_jmp = DISAS_NORETURN;
+
     return true;
 }
 
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 18 lines · Max Chou

According to the V spec, the vector fault-only-first load instructions may change the VL CSR.
So the ldff_trans TCG translation function should generate the lookup_and_goto_ptr flow as the vsetvl/vsetvli translation function to make sure the vl_eq_vlmax TB flag is correct.

---
  target/riscv/insn_trans/trans_rvv.c.inc | 6 ++++++
  1 file changed, 6 insertions(+)
target/riscv/insn_trans/trans_rvv.c.inc +0 -0
index 2b6077ac067..4cd030c7eb3 100644
@@ -1361,6 +1361,12 @@ static bool ldff_trans(uint32_t vd, uint32_t rs1, uint32_t data,
      fn(dest, mask, base, tcg_env, desc);
 

target/riscv/insn_trans/trans_rvv.c.inc static bool ldff_trans(uint32_t vd, uint32_t rs1, uint32_t data, · line 1372

Quoted 10 lines
target/riscv/insn_trans/trans_rvv.c.inc +6 -0
      finalize_rvv_inst(s);
+
+    /* vector unit-stride fault-only-first load may modify vl CSR */
+    gen_update_pc(s, s->cur_insn_len);
+    lookup_and_goto_ptr(s);
+    s->base.is_jmp = DISAS_NORETURN;
+
      return true;
  }
 

r~

#2 lore raw
In reply to Max Chou
Quoted 8 lines · Max Chou

According to the V spec, the vector fault-only-first load instructions may change the VL CSR.
So the ldff_trans TCG translation function should generate the lookup_and_goto_ptr flow as the vsetvl/vsetvli translation function to make sure the vl_eq_vlmax TB flag is correct.

Thanks!

Applied to riscv-to-apply.next

Alistair

Quoted 25 lines
---
 target/riscv/insn_trans/trans_rvv.c.inc | 6 ++++++
 1 file changed, 6 insertions(+)
target/riscv/insn_trans/trans_rvv.c.inc +6 -1
index 2b6077ac067..4cd030c7eb3 100644
@@ -1361,6 +1361,12 @@ static bool ldff_trans(uint32_t vd, uint32_t rs1, uint32_t data,
     fn(dest, mask, base, tcg_env, desc);
 
     finalize_rvv_inst(s);
+
+    /* vector unit-stride fault-only-first load may modify vl CSR */
+    gen_update_pc(s, s->cur_insn_len);
+    lookup_and_goto_ptr(s);
+    s->base.is_jmp = DISAS_NORETURN;
+
     return true;
 }
 
--

2.43.0