@samitouri / QOSamiQemu / commits / 8d00627955

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>

Peter Maydell committed Apr 30, 2026 at 10:38 UTC 8d00627955b05628dd5e498eb8f6734e55fcfdc7
1 file changed +7 -6
hw/i386/vapic.c
+7 -6
@@ -161,7 +161,6 @@ static void update_guest_rom_state(VAPICROMState *s)
161 static int find_real_tpr_addr(VAPICROMState *s, CPUX86State *env)
162 {
163 CPUState *cs = env_cpu(env);
164 - hwaddr paddr;
164 target_ulong addr;
165
166 if (s->state == VAPIC_ACTIVE) {
@@ -173,8 +172,10 @@ static int find_real_tpr_addr(VAPICROMState *s, CPUX86State *env)
172 * virtual address space for the APIC mapping.
173 */
174 for (addr = 0xfffff000; addr >= 0x80000000; addr -= TARGET_PAGE_SIZE) {
176 - paddr = cpu_get_phys_addr_debug(cs, addr);
177 - if (paddr != APIC_DEFAULT_ADDRESS) {
175 + TranslateForDebugResult tres;
176 +
177 + if (!cpu_translate_for_debug(cs, addr, &tres) ||
178 + tres.physaddr != APIC_DEFAULT_ADDRESS) {
179 continue;
180 }
181 s->real_tpr_addr = addr + 0x80;
@@ -292,6 +293,7 @@ static int update_rom_mapping(VAPICROMState *s, CPUX86State *env, target_ulong i
293 hwaddr paddr;
294 uint32_t rom_state_vaddr;
295 uint32_t pos, patch, offset;
296 + TranslateForDebugResult tres;
297
298 /* nothing to do if already activated */
299 if (s->state == VAPIC_ACTIVE) {
@@ -305,11 +307,10 @@ static int update_rom_mapping(VAPICROMState *s, CPUX86State *env, target_ulong i
307
308 /* find out virtual address of the ROM */
309 rom_state_vaddr = s->rom_state_paddr + (ip & 0xf0000000);
308 - paddr = cpu_get_phys_addr_debug(cs, rom_state_vaddr);
309 - if (paddr == -1) {
310 + if (!cpu_translate_for_debug(cs, rom_state_vaddr, &tres)) {
311 return -1;
312 }
312 - paddr |= rom_state_vaddr & ~TARGET_PAGE_MASK;
313 + paddr = tres.physaddr;
314 if (paddr != s->rom_state_paddr) {
315 return -1;
316 }