From: Peter Maydell <[email protected]> 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.
For alpha, the get_physical_address() function accepts arbitrary input addresses but may return an output rounded down to a page boundary, so in alpha_cpu_get_phys_page_debug() we OR the within-page offset into it before returning it. Signed-off-by: Peter Maydell <[email protected]> Reviewed-by: Richard Henderson <[email protected]> Message-id: [email protected] Message-ID: <[email protected]> Signed-off-by: Philippe Mathieu-Daudé <[email protected]> --- target/alpha/helper.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/alpha/helper.c b/target/alpha/helper.c index 179dc2dc7ae..af6d7847d50 100644 --- a/target/alpha/helper.c +++ b/target/alpha/helper.c @@ -301,6 +301,7 @@ hwaddr alpha_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) int prot, fail; fail = get_physical_address(cpu_env(cs), addr, 0, 0, &phys, &prot); + phys |= addr & ~TARGET_PAGE_MASK; return (fail >= 0 ? -1 : phys); } -- 2.53.0
