From: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
To: alistair23@gmail.com, palmer@dabbelt.com, liwei1518@gmail.com,
daniel.barboza@oss.qualcomm.com, chao.liu.zevorn@gmail.com,
qemu-riscv@nongnu.org, qemu-devel@nongnu.org
Cc: Alistair Francis <alistair.francis@wdc.com>
Subject: Re: [PATCH 5/5] target/riscv: Use ELEN for Fractional LMUL check
Date: Tue, 7 Apr 2026 20:13:17 +0800 [thread overview]
Message-ID: <ce3cde01-d4cf-4e01-befb-e9631dcf7757@linux.alibaba.com> (raw)
In-Reply-To: <20260407043614.372871-6-alistair.francis@wdc.com>
[-- Attachment #1: Type: text/plain, Size: 2317 bytes --]
Hi Alistair,
On 4/7/26 12:36 PM, alistair23@gmail.com wrote:
> From: Alistair Francis<alistair.francis@wdc.com>
>
> The RISC-V spec states that
>
> """
> For a given supported fractional LMUL setting, implementations
> must support SEW settings between SEWMIN and LMUL * ELEN, inclusive.
> """
I think the meaning of "must support" in specification is "must at
least support" instead of "must only support".
Sail or Spike have the same check as this patch to prevent user program
can run on them, but
can't run on RTLs, as RTLs implementation may support SEW besides the
SEWMIN and LMUL * ELEN range.
We can refer to discussion here:
https://github.com/riscv-software-src/riscv-isa-sim/pull/620
In my opinion, we had better add a option such as "frac_sew_check" to
make user set right value for their RTL implementation.
Otherwise,
Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
Thanks,
Zhiwei
> We were previously checking VLEN, instead of ELEN, so let's update to
> check ELEN instead of VLEN for fractional scaling.
>
> Resolves:https://gitlab.com/qemu-project/qemu/-/work_items/3196
> Signed-off-by: Alistair Francis<alistair.francis@wdc.com>
> ---
> target/riscv/vector_helper.c | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c
> index 83dd26314d..b4fc791eb7 100644
> --- a/target/riscv/vector_helper.c
> +++ b/target/riscv/vector_helper.c
> @@ -47,18 +47,17 @@ target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1,
> target_ulong reserved = s2 &
> MAKE_64BIT_MASK(R_VTYPE_RESERVED_SHIFT,
> xlen - 1 - R_VTYPE_RESERVED_SHIFT);
> - uint16_t vlen = cpu->cfg.vlenb << 3;
> int8_t lmul;
>
> if (vlmul & 4) {
> /*
> * Fractional LMUL, check:
> *
> - * VLEN * LMUL >= SEW
> - * VLEN >> (8 - lmul) >= sew
> - * (vlenb << 3) >> (8 - lmul) >= sew
> + * ELEN * LMUL >= SEW
> + * ELEN >> (8 - vlmul) >= sew
> */
> - if (vlmul == 4 || (vlen >> (8 - vlmul)) < sew) {
> + if (vlmul == 4 ||
> + (cpu->cfg.elen >> (8 - vlmul)) < sew) {
> vill = true;
> }
> }
[-- Attachment #2: Type: text/html, Size: 3568 bytes --]
next prev parent reply other threads:[~2026-04-07 19:30 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-07 4:36 [PATCH 0/5] target/riscv: A collection of bug fixes alistair23
2026-04-07 4:36 ` [PATCH 1/5] target/riscv: Generate access fault if sc comparison fails alistair23
2026-04-07 9:38 ` Daniel Henrique Barboza
2026-04-08 8:48 ` Philippe Mathieu-Daudé
2026-04-09 6:21 ` Alistair Francis
2026-04-09 10:00 ` Philippe Mathieu-Daudé
2026-04-09 5:38 ` Alistair Francis
2026-04-09 10:02 ` Daniel Henrique Barboza
2026-04-09 23:29 ` Alistair Francis
2026-04-07 16:23 ` Chao Liu
2026-04-07 4:36 ` [PATCH 2/5] linux-user/strace: Add a wrapper for read and write alistair23
2026-04-07 9:38 ` Daniel Henrique Barboza
2026-04-07 16:55 ` Chao Liu
2026-04-08 8:37 ` Philippe Mathieu-Daudé
2026-04-08 1:40 ` Richard Henderson
2026-04-07 4:36 ` [PATCH 3/5] target/riscv: Don't OR mip.SEIP when mvien is one alistair23
2026-04-07 9:41 ` Daniel Henrique Barboza
2026-04-08 2:49 ` Chao Liu
2026-04-07 4:36 ` [PATCH 4/5] hw/timer: ibex_timer: Update IRQs after writing CTRL alistair23
2026-04-07 9:42 ` Daniel Henrique Barboza
2026-04-08 2:50 ` Chao Liu
2026-04-08 8:38 ` Philippe Mathieu-Daudé
2026-04-09 3:11 ` Nutty.Liu
2026-04-07 4:36 ` [PATCH 5/5] target/riscv: Use ELEN for Fractional LMUL check alistair23
2026-04-07 9:31 ` Daniel Henrique Barboza
2026-04-07 12:13 ` LIU Zhiwei [this message]
2026-04-09 5:32 ` Alistair Francis
2026-04-09 6:05 ` LIU Zhiwei
2026-04-08 2:51 ` Chao Liu
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=ce3cde01-d4cf-4e01-befb-e9631dcf7757@linux.alibaba.com \
--to=zhiwei_liu@linux.alibaba.com \
--cc=alistair.francis@wdc.com \
--cc=alistair23@gmail.com \
--cc=chao.liu.zevorn@gmail.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 \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.