From 77a8f1a5125457d845fac6aa0c2e1e2681d94f07 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Thu, 10 May 2012 22:40:10 +0000 Subject: linux-user: Fix stale tbs after mmap If we execute linux-user code that does the following: * A = mmap() * execute code in A * munmap(A) * B = mmap(), but mmap returns the same address as A * execute code in B we end up executing a stale cached tb that contains translated code from A, while we want new code from B. This patch adds a TB flush for mmap'ed regions, before we return them, avoiding the whole issue. It also adds a flush for munmap, so that we don't execute stale TBs instead of getting a segfault. Reported-by: Peter Maydell Signed-off-by: Alexander Graf Reviewed-by: Peter Maydell Acked-by: Riku Voipio Signed-off-by: Blue Swirl --- exec-all.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'exec-all.h') diff --git a/exec-all.h b/exec-all.h index c1b7e1f263..9bda7f7354 100644 --- a/exec-all.h +++ b/exec-all.h @@ -96,6 +96,8 @@ void QEMU_NORETURN cpu_loop_exit(CPUArchState *env1); int page_unprotect(target_ulong address, uintptr_t pc, void *puc); void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t end, int is_cpu_write_access); +void tb_invalidate_phys_range(tb_page_addr_t start, tb_page_addr_t end, + int is_cpu_write_access); #if !defined(CONFIG_USER_ONLY) /* cputlb.c */ void tlb_flush_page(CPUArchState *env, target_ulong addr); -- cgit v1.2.1