@samitouri / QOSamiQemu / commits / d9a1e19c16

target/microblaze: Make get_phys_page_attrs_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. For microblaze, we just need to remove the explicit rounding down to the page boundary that we were doing in mb_cpu_get_phys_page_attrs_debug() when calculating the output physaddr from the results of the MMU lookup. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20260417173105.1648172-4-peter.maydell@linaro.org Message-ID: <20260430093810.2762539-5-peter.maydell@linaro.org> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Peter Maydell committed Apr 30, 2026 at 10:37 UTC d9a1e19c1699fcaa9b088beaebe167a2ffea11f9
1 file changed +4 -5
target/microblaze/helper.c
+4 -5
@@ -284,7 +284,6 @@ hwaddr mb_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr,
284 MemTxAttrs *attrs)
285 {
286 MicroBlazeCPU *cpu = MICROBLAZE_CPU(cs);
287 - vaddr vaddr;
287 hwaddr paddr = 0;
288 MicroBlazeMMULookup lu;
289 int mmu_idx = cpu_mmu_index(cs, false);
@@ -297,12 +296,12 @@ hwaddr mb_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr,
296 if (mmu_idx != MMU_NOMMU_IDX) {
297 hit = mmu_translate(cpu, &lu, addr, 0, 0);
298 if (hit) {
300 - vaddr = addr & TARGET_PAGE_MASK;
301 - paddr = lu.paddr + vaddr - lu.vaddr;
299 + paddr = lu.paddr + addr - lu.vaddr;
300 } else
301 paddr = 0; /* ???. */
304 - } else
305 - paddr = addr & TARGET_PAGE_MASK;
302 + } else {
303 + paddr = addr;
304 + }
305
306 return paddr;
307 }