]> git.ipfire.org Git - thirdparty/qemu.git/commit
target/riscv32: Fix masking of physical address
authorAndrew Jones <ajones@ventanamicro.com>
Mon, 9 Sep 2024 08:32:42 +0000 (10:32 +0200)
committerAlistair Francis <alistair.francis@wdc.com>
Wed, 2 Oct 2024 05:11:51 +0000 (15:11 +1000)
commitb27402813e7007ab82ddd914c092777f11fab6ed
tree312c73af2537348775e3c0463390c5c0ef0e6074
parent5b8764193be027b2298133a819358f636ff53962
target/riscv32: Fix masking of physical address

C doesn't extend the sign bit for unsigned types since there isn't a
sign bit to extend. This means a promotion of a u32 to a u64 results
in the upper 32 bits of the u64 being zero. If that result is then
used as a mask on another u64 the upper 32 bits will be cleared. rv32
physical addresses may be up to 34 bits wide, so we don't want to
clear the high bits while page aligning the address. The fix is to
use hwaddr for the mask, which, even on rv32, is 64-bits wide.

Fixes: af3fc195e3c8 ("target/riscv: Change the TLB page size depends on PMP entries.")
Signed-off-by: Andrew Jones <ajones@ventanamicro.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20240909083241.43836-2-ajones@ventanamicro.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
target/riscv/cpu_helper.c