QEMU-Riscv Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Chao Liu <chao.liu@processmission.com>
To: wangyang <wangyang25@otcaix.iscas.ac.cn>
Cc: qemu-devel@nongnu.org, Palmer Dabbelt <palmer@dabbelt.com>,
	 Alistair Francis <alistair.francis@wdc.com>,
	Weiwei Li <liwei1518@gmail.com>,
	 Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>,
	Liu Zhiwei <zhiwei_liu@linux.alibaba.com>,
	qemu-riscv@nongnu.org
Subject: Re: [PATCH v3 2/5] target/riscv: mask RV32 XTheadBb th.srri shift amount
Date: Fri, 11 Sep 2026 13:22:29 +0800	[thread overview]
Message-ID: <aqOKQ0WfB0vTTFMG@MacBook-Pro-4.local> (raw)
In-Reply-To: <20260908124755-v3-2-wangyang25@otcaix.iscas.ac.cn>

On Tue, Sep 08, 2026 at 12:47:55PM +0800, wangyang wrote:
> 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 <daniel.barboza@oss.qualcomm.com>
> 
> Signed-off-by: wangyang <wangyang25@otcaix.iscas.ac.cn>
> ---
>  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;
Looks right, but usually we handle this in decodetree. We don't
normally modify the decoded arguments directly, so could you move
the normalization into decodetree instead—e.g. a dedicated RV32
pattern/trans like zext_h_32/pack?

just like:

{
  th_srri_rv32  000100 -..... ..... 001 ..... 0001011 @sh5
  th_srri       000100 ...... ..... 001 ..... 0001011 @sh6
}

Thanks,
Chao
>      return gen_shift_imm_fn_per_ol(ctx, a, EXT_NONE,
>                                     tcg_gen_rotri_tl, gen_roriw, NULL);
>  }
> -- 
> 2.55.0.windows.2
> 


  reply	other threads:[~2026-09-11  5:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-08  4:47 [PATCH v3 0/5] target/riscv: fix privilege, PMP, CFI, envcfg checks wangyang
2026-09-08  4:47 ` [PATCH v3 2/5] target/riscv: mask RV32 XTheadBb th.srri shift amount wangyang
2026-09-11  5:22   ` Chao Liu [this message]
2026-09-08  4:47 ` [PATCH v3 4/5] target/riscv: prioritize Zicfilp checks for misaligned JALR wangyang
2026-09-08  4:47 ` [PATCH v3 5/5] target/riscv: canonicalize reserved CBIE encoding wangyang
2026-09-09 20:03   ` Daniel Henrique Barboza
2026-09-08  4:47 ` [PATCH v3 1/5] target/riscv: enforce XTheadCmo U-mode privilege checks wangyang
2026-09-08  4:47 ` [PATCH v3 3/5] target/riscv: require read permission for HLVX accesses wangyang
2026-09-09 20:02   ` Daniel Henrique Barboza

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aqOKQ0WfB0vTTFMG@MacBook-Pro-4.local \
    --to=chao.liu@processmission.com \
    --cc=alistair.francis@wdc.com \
    --cc=daniel.barboza@oss.qualcomm.com \
    --cc=liwei1518@gmail.com \
    --cc=palmer@dabbelt.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=wangyang25@otcaix.iscas.ac.cn \
    --cc=zhiwei_liu@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox