@samitouri / QOSamiQemu / commits / 44d1829c6c

target/hexagon: fix get_phys_addr_debug with in-page offset

As documented: * @get_phys_addr_debug: Callback for obtaining a physical address. * This must be able to handle a non-page-aligned address, and will * return the physical address corresponding to that address. When MMU is enabled, hexagon_cpu_get_phys_addr_debug() returns the physical address page-aligned, not corrected to reflect the exact byte the virtual addr maps to within the page. Let's fix that. The MMU-disabled case is already correct. This would break semihosting argument reads when it is added for Hexagon. Signed-off-by: Matheus Tavares Bernardino <matheus.bernardino@oss.qualcomm.com> Reviewed-by: Brian Cain <brian.cain@oss.qualcomm.com> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com> Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>

Matheus Tavares Bernardino committed Jul 13, 2026 at 13:07 UTC 44d1829c6cb1c9bb2c9c451a63412a615acd7d54
1 file changed +2
target/hexagon/cpu.c
+2
@@ -569,7 +569,9 @@ static hwaddr hexagon_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr)
569
570 if (get_physical_address(env, &phys_addr, &prot, &page_size, &excp,
571 addr, 0, mmu_idx)) {
572 + vaddr page_offset = addr & (TARGET_PAGE_SIZE - 1);
573 find_qemu_subpage(&addr, &phys_addr, page_size);
574 + phys_addr += hexagon_cpu_mmu_enabled(env) ? page_offset : 0;
575 return phys_addr;
576 }
577