mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2024-12-24 12:35:42 +00:00
translate-all.c: Don't pass puc, locked to tb_invalidate_phys_page()
The user-mode-only function tb_invalidate_phys_page() is only called from two places: * page_unprotect(), which passes in a non-zero pc, a puc pointer and the value 'true' for the locked argument * page_set_flags(), which passes in a zero pc, a NULL puc pointer and a 'false' locked argument If the pc is non-zero then we may call cpu_resume_from_signal(), which does a longjmp out of the calling code (and out of the signal handler); this is to cover the case of a target CPU with "precise self-modifying code" (currently only x86) executing a store instruction which modifies code in the same TB as the store itself. Rather than doing the longjump directly here, return a flag to the caller which indicates whether the current TB was modified, and move the longjump to page_unprotect. Backports commit 75809229bbf28b371afce14921ff5be98ddc5faa from qemu
This commit is contained in:
parent
1db22b5889
commit
37b7538d85
|
@ -1548,9 +1548,13 @@ void tb_invalidate_phys_page_fast(struct uc_struct* uc, tb_page_addr_t start, in
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static void tb_invalidate_phys_page(struct uc_struct *uc, tb_page_addr_t addr,
|
/* Called with mmap_lock held. If pc is not 0 then it indicates the
|
||||||
uintptr_t pc, void *puc,
|
* host PC of the faulting store instruction that caused this invalidate.
|
||||||
bool locked)
|
* Returns true if the caller needs to abort execution of the current
|
||||||
|
* TB (because it was modified by this store and the guest CPU has
|
||||||
|
* precise-SMC semantics).
|
||||||
|
*/
|
||||||
|
static bool tb_invalidate_phys_page(tb_page_addr_t addr, uintptr_t pc)
|
||||||
{
|
{
|
||||||
TranslationBlock *tb;
|
TranslationBlock *tb;
|
||||||
PageDesc *p;
|
PageDesc *p;
|
||||||
|
@ -1568,7 +1572,7 @@ static void tb_invalidate_phys_page(struct uc_struct *uc, tb_page_addr_t addr,
|
||||||
addr &= TARGET_PAGE_MASK;
|
addr &= TARGET_PAGE_MASK;
|
||||||
p = page_find(addr >> TARGET_PAGE_BITS);
|
p = page_find(addr >> TARGET_PAGE_BITS);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
tb = p->first_tb;
|
tb = p->first_tb;
|
||||||
#ifdef TARGET_HAS_PRECISE_SMC
|
#ifdef TARGET_HAS_PRECISE_SMC
|
||||||
|
@ -1607,12 +1611,10 @@ static void tb_invalidate_phys_page(struct uc_struct *uc, tb_page_addr_t addr,
|
||||||
modifying the memory. It will ensure that it cannot modify
|
modifying the memory. It will ensure that it cannot modify
|
||||||
itself */
|
itself */
|
||||||
tb_gen_code(cpu, current_pc, current_cs_base, current_flags, 1);
|
tb_gen_code(cpu, current_pc, current_cs_base, current_flags, 1);
|
||||||
if (locked) {
|
return true;
|
||||||
mmap_unlock();
|
|
||||||
}
|
|
||||||
cpu_resume_from_signal(cpu, puc);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -2005,7 +2007,7 @@ static void page_set_flags(struct uc_struct *uc, target_ulong start, target_ulon
|
||||||
if (!(p->flags & PAGE_WRITE) &&
|
if (!(p->flags & PAGE_WRITE) &&
|
||||||
(flags & PAGE_WRITE) &&
|
(flags & PAGE_WRITE) &&
|
||||||
p->first_tb) {
|
p->first_tb) {
|
||||||
tb_invalidate_phys_page(addr, 0, NULL, false);
|
tb_invalidate_phys_page(addr, 0);
|
||||||
}
|
}
|
||||||
p->flags = flags;
|
p->flags = flags;
|
||||||
}
|
}
|
||||||
|
@ -2099,7 +2101,10 @@ static int page_unprotect(target_ulong address, uintptr_t pc, void *puc)
|
||||||
|
|
||||||
/* and since the content will be modified, we must invalidate
|
/* and since the content will be modified, we must invalidate
|
||||||
the corresponding translated code. */
|
the corresponding translated code. */
|
||||||
tb_invalidate_phys_page(addr, pc, puc, true);
|
if (tb_invalidate_phys_page(addr, pc)) {
|
||||||
|
mmap_unlock();
|
||||||
|
cpu_resume_from_signal(current_cpu, puc);
|
||||||
|
}
|
||||||
#ifdef DEBUG_TB_CHECK
|
#ifdef DEBUG_TB_CHECK
|
||||||
tb_invalidate_check(addr);
|
tb_invalidate_check(addr);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue