A legal ZALASR load-acquire with rd=x0 must retire while discarding the loaded value. gen_load_acquire() currently obtains the destination with get_gpr(), which returns the constant-zero TCG value for x0 and cannot be used as a load target. Use dest_gpr() so the result is written to a discardable temporary.
Tested with the 4-case RV32/RV64 linux-user witness and control matrix on a clean patched QEMU build. Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4406 Signed-off-by: wangyang <[email protected]> --- target/riscv/tcg/insn_trans/trans_rvzalasr.c.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/riscv/tcg/insn_trans/trans_rvzalasr.c.inc b/target/riscv/tcg/insn_trans/trans_rvzalasr.c.inc index 79b0b2c63b..2de1777cab 100644 --- a/target/riscv/tcg/insn_trans/trans_rvzalasr.c.inc +++ b/target/riscv/tcg/insn_trans/trans_rvzalasr.c.inc @@ -21,7 +21,7 @@ static bool gen_load_acquire(DisasContext *ctx, arg_lb_aqrl *a, MemOp memop) decode_save_opc(ctx, 0); TCGv addr = get_address(ctx, a->rs1, 0); - TCGv dest = get_gpr(ctx, a->rd, EXT_NONE); + TCGv dest = dest_gpr(ctx, a->rd); TCGBar bar = (a->rl) ? TCG_BAR_STRL : 0; /* Check that AQ is set, as this is mandatory */ -- 2.55.0.windows.2
