Commit 44d1829c6c for qemu.org
commit 44d1829c6cb1c9bb2c9c451a63412a615acd7d54
Author: Matheus Tavares Bernardino <matheus.bernardino@oss.qualcomm.com>
Date: Mon Jul 13 13:07:09 2026 -0700
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>
diff --git a/target/hexagon/cpu.c b/target/hexagon/cpu.c
index e2af736a99..12d27ce138 100644
--- a/target/hexagon/cpu.c
+++ b/target/hexagon/cpu.c
@@ -569,7 +569,9 @@ static hwaddr hexagon_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr)
if (get_physical_address(env, &phys_addr, &prot, &page_size, &excp,
addr, 0, mmu_idx)) {
+ vaddr page_offset = addr & (TARGET_PAGE_SIZE - 1);
find_qemu_subpage(&addr, &phys_addr, page_size);
+ phys_addr += hexagon_cpu_mmu_enabled(env) ? page_offset : 0;
return phys_addr;
}