Commit 8d00627955 for qemu.org
commit 8d00627955b05628dd5e498eb8f6734e55fcfdc7
Author: Peter Maydell <peter.maydell@linaro.org>
Date: Thu Apr 30 10:38:04 2026 +0100
hw/i386/vapic.c: Use cpu_translate_for_debug()
We would like to remove the cpu_get_phys_addr_debug() function, by
moving all callers to cpu_translate_for_debug(). Update the callsites
in vapic.c.
In the process we can drop the old "OR the page offset back in"
workaround that we had for when cpu_get_phys_page_addr() returned
the physaddr of the page base rather than the exact physaddr of
the input virtual address.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20260430093810.2762539-20-peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
diff --git a/hw/i386/vapic.c b/hw/i386/vapic.c
index 225f19a75c..781bf2a7fa 100644
--- a/hw/i386/vapic.c
+++ b/hw/i386/vapic.c
@@ -161,7 +161,6 @@ static void update_guest_rom_state(VAPICROMState *s)
static int find_real_tpr_addr(VAPICROMState *s, CPUX86State *env)
{
CPUState *cs = env_cpu(env);
- hwaddr paddr;
target_ulong addr;
if (s->state == VAPIC_ACTIVE) {
@@ -173,8 +172,10 @@ static int find_real_tpr_addr(VAPICROMState *s, CPUX86State *env)
* virtual address space for the APIC mapping.
*/
for (addr = 0xfffff000; addr >= 0x80000000; addr -= TARGET_PAGE_SIZE) {
- paddr = cpu_get_phys_addr_debug(cs, addr);
- if (paddr != APIC_DEFAULT_ADDRESS) {
+ TranslateForDebugResult tres;
+
+ if (!cpu_translate_for_debug(cs, addr, &tres) ||
+ tres.physaddr != APIC_DEFAULT_ADDRESS) {
continue;
}
s->real_tpr_addr = addr + 0x80;
@@ -292,6 +293,7 @@ static int update_rom_mapping(VAPICROMState *s, CPUX86State *env, target_ulong i
hwaddr paddr;
uint32_t rom_state_vaddr;
uint32_t pos, patch, offset;
+ TranslateForDebugResult tres;
/* nothing to do if already activated */
if (s->state == VAPIC_ACTIVE) {
@@ -305,11 +307,10 @@ static int update_rom_mapping(VAPICROMState *s, CPUX86State *env, target_ulong i
/* find out virtual address of the ROM */
rom_state_vaddr = s->rom_state_paddr + (ip & 0xf0000000);
- paddr = cpu_get_phys_addr_debug(cs, rom_state_vaddr);
- if (paddr == -1) {
+ if (!cpu_translate_for_debug(cs, rom_state_vaddr, &tres)) {
return -1;
}
- paddr |= rom_state_vaddr & ~TARGET_PAGE_MASK;
+ paddr = tres.physaddr;
if (paddr != s->rom_state_paddr) {
return -1;
}