accel/tcg: Fix tb_invalidate_phys_page_unwind

When called from syscall(), we are not within a TB and pc == 0.
We can skip the check for invalidating the current TB.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Richard Henderson 2022-12-24 04:35:22 -08:00
parent cee44b037b
commit 1b660f42ef
1 changed files with 43 additions and 35 deletions

View File

@ -1024,16 +1024,28 @@ void tb_invalidate_phys_page(tb_page_addr_t addr)
*/ */
bool tb_invalidate_phys_page_unwind(tb_page_addr_t addr, uintptr_t pc) bool tb_invalidate_phys_page_unwind(tb_page_addr_t addr, uintptr_t pc)
{ {
assert(pc != 0); TranslationBlock *current_tb;
#ifdef TARGET_HAS_PRECISE_SMC bool current_tb_modified;
assert_memory_lock();
{
TranslationBlock *current_tb = tcg_tb_lookup(pc);
bool current_tb_modified = false;
TranslationBlock *tb; TranslationBlock *tb;
PageForEachNext n; PageForEachNext n;
/*
* Without precise smc semantics, or when outside of a TB,
* we can skip to invalidate.
*/
#ifndef TARGET_HAS_PRECISE_SMC
pc = 0;
#endif
if (!pc) {
tb_invalidate_phys_page(addr);
return false;
}
assert_memory_lock();
current_tb = tcg_tb_lookup(pc);
addr &= TARGET_PAGE_MASK; addr &= TARGET_PAGE_MASK;
current_tb_modified = false;
PAGE_FOR_EACH_TB(addr, addr + TARGET_PAGE_SIZE, unused, tb, n) { PAGE_FOR_EACH_TB(addr, addr + TARGET_PAGE_SIZE, unused, tb, n) {
if (current_tb == tb && if (current_tb == tb &&
@ -1057,10 +1069,6 @@ bool tb_invalidate_phys_page_unwind(tb_page_addr_t addr, uintptr_t pc)
cpu->cflags_next_tb = 1 | CF_NOIRQ | curr_cflags(current_cpu); cpu->cflags_next_tb = 1 | CF_NOIRQ | curr_cflags(current_cpu);
return true; return true;
} }
}
#else
tb_invalidate_phys_page(addr);
#endif /* TARGET_HAS_PRECISE_SMC */
return false; return false;
} }
#else #else