[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 30/34] target/riscv: Fix shift count overflow
From: |
Alistair Francis |
Subject: |
[PULL 30/34] target/riscv: Fix shift count overflow |
Date: |
Fri, 8 Mar 2024 21:11:48 +1000 |
From: "demin.han" <demin.han@starfivetech.com>
The result of (8 - 3 - vlmul) is negative when vlmul >= 6,
and results in wrong vill.
Signed-off-by: demin.han <demin.han@starfivetech.com>
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Message-ID: <20240225174114.5298-1-demin.han@starfivetech.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
target/riscv/vector_helper.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c
index 84cec73eb2..fe56c007d5 100644
--- a/target/riscv/vector_helper.c
+++ b/target/riscv/vector_helper.c
@@ -44,6 +44,7 @@ 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) {
@@ -53,10 +54,8 @@ target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong
s1,
* VLEN * LMUL >= SEW
* VLEN >> (8 - lmul) >= sew
* (vlenb << 3) >> (8 - lmul) >= sew
- * vlenb >> (8 - 3 - lmul) >= sew
*/
- if (vlmul == 4 ||
- cpu->cfg.vlenb >> (8 - 3 - vlmul) < sew) {
+ if (vlmul == 4 || (vlen >> (8 - vlmul)) < sew) {
vill = true;
}
}
--
2.44.0
- Re: [PULL 20/34] tests/libqos: add riscv/virt machine nodes, (continued)
- [PULL 21/34] RISC-V: Add support for Ztso, Alistair Francis, 2024/03/08
- [PULL 22/34] linux-user/riscv: Add Ztso extension to hwprobe, Alistair Francis, 2024/03/08
- [PULL 23/34] tests: riscv64: Use 'zfa' instead of 'Zfa', Alistair Francis, 2024/03/08
- [PULL 24/34] linux-headers: Update to Linux v6.8-rc6, Alistair Francis, 2024/03/08
- [PULL 25/34] target/riscv/kvm: update KVM exts to Linux 6.8, Alistair Francis, 2024/03/08
- [PULL 26/34] target/riscv: move ratified/frozen exts to non-experimental, Alistair Francis, 2024/03/08
- [PULL 27/34] target/riscv: mcountinhibit, mcounteren, scounteren, hcounteren is 32-bit, Alistair Francis, 2024/03/08
- [PULL 28/34] trans_rvv.c.inc: mark_vs_dirty() before loads and stores, Alistair Francis, 2024/03/08
- [PULL 29/34] trans_rvv.c.inc: remove 'is_store' bool from load/store fns, Alistair Francis, 2024/03/08
- [PULL 30/34] target/riscv: Fix shift count overflow,
Alistair Francis <=
- [PULL 31/34] hw/intc/riscv_aplic: Fix setipnum_le write emulation for APLIC MSI-mode, Alistair Francis, 2024/03/08
- [PULL 32/34] hw/intc/riscv_aplic: Fix in_clrip[x] read emulation, Alistair Francis, 2024/03/08
- [PULL 33/34] target/riscv: Fix privilege mode of G-stage translation for debugging, Alistair Francis, 2024/03/08
- [PULL 34/34] target/riscv: fix ACPI MCFG table, Alistair Francis, 2024/03/08
- Re: [PULL 00/34] riscv-to-apply queue, Peter Maydell, 2024/03/08