The XTheadBb th.srri instruction uses the low log2(XLEN) bits of imm6. The generic shift helper rejects values greater than or equal to XLEN, which incorrectly rejects imm6 values 32 through 63 on RV32. Normalize the operand before calling the helper.
Tested: RV32 imm6 0, 31, 32, and 63 witnesses with XTheadBb enabled and disabled. Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4413 Reviewed-by: Daniel Henrique Barboza <[email protected]> Signed-off-by: wangyang <[email protected]> --- target/riscv/tcg/insn_trans/trans_xthead.c.inc | 1 + 1 file changed, 1 insertion(+) diff --git a/target/riscv/tcg/insn_trans/trans_xthead.c.inc b/target/riscv/tcg/insn_trans/trans_xthead.c.inc index 681f70e5bc..34226b1be5 100644 --- a/target/riscv/tcg/insn_trans/trans_xthead.c.inc +++ b/target/riscv/tcg/insn_trans/trans_xthead.c.inc @@ -141,6 +141,7 @@ GEN_TRANS_TH_ADDSL(3) static bool trans_th_srri(DisasContext *ctx, arg_th_srri * a) { REQUIRE_XTHEADBB(ctx); + a->shamt &= get_olen(ctx) - 1; return gen_shift_imm_fn_per_ol(ctx, a, EXT_NONE, tcg_gen_rotri_tl, gen_roriw, NULL); } -- 2.55.0.windows.2
