@samitouri / QOSamiQemu / commits / fb9d616819

target/riscv: fix address masking

The pmlen should get the corresponding value before shifting address. Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com> Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-ID: <20260421093715.2995067-2-frank.chang@sifive.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>

Yong-Xuan Wang committed Apr 21, 2026 at 17:37 UTC fb9d616819a563a6956482055e1cbe2f053130db
1 file changed +1 -1
target/riscv/internals.h
+1 -1
@@ -222,8 +222,8 @@ static inline target_ulong adjust_addr_body(CPURISCVState *env,
222 if (!is_virt_addr) {
223 signext = riscv_cpu_virt_mem_enabled(env);
224 }
225 - addr = addr << pmlen;
225 pmlen = riscv_pm_get_pmlen(pmm);
226 + addr = addr << pmlen;
227
228 /* sign/zero extend masked address by N-1 bit */
229 if (signext) {