@samitouri / QOSamiQemu / commits / 2ae8467854

target/riscv: Make get_phys_page_debug handle non-page-aligned addrs

Currently our implementations of SysemuCPUOps::get_phys_page_debug and SysemuCPUOps::get_phys_page_attrs_debug are a mix of "accepts a non-page-aligned virtual address and returns the corresponding non-page-aligned physical address" and "only returns a page-aligned physical address". This is awkward for callsites, which in practice all want the physical address for an arbitrary virtual address and have to work around the possibility of getting a page-aligned address, and it doesn't account for protection being possibly on a sub-page-sized granularity. We want to standardize on the implementation having to handle non-page-aligned addresses. The only thing in the riscv implementation that we need to fix is the place where we explicitly round the return value down to a page boundary before returning it. Drop that. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Chao Liu <chao.liu.zevorn@gmail.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20260417173105.1648172-2-peter.maydell@linaro.org Message-ID: <20260430093810.2762539-3-peter.maydell@linaro.org> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Peter Maydell committed Apr 30, 2026 at 10:37 UTC 2ae8467854d71a774cdd2017a803428c77ec13c3
1 file changed +1 -1
target/riscv/cpu_helper.c
+1 -1
@@ -1730,7 +1730,7 @@ hwaddr riscv_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)
1730 }
1731 }
1732
1733 - return phys_addr & TARGET_PAGE_MASK;
1733 + return phys_addr;
1734 }
1735
1736 void riscv_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,