Received: from eggs.gnu.org ([208.118.235.92]:49799) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SRKGq-0000Pz-LG for qemu-devel@nongnu.org; Mon, 07 May 2012 05:30:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SRKGk-0002Af-Cx for qemu-devel@nongnu.org; Mon, 07 May 2012 05:30:20 -0400 Received: from cantor2.suse.de ([195.135.220.15]:38044 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SRKGk-0002AP-6g for qemu-devel@nongnu.org; Mon, 07 May 2012 05:30:14 -0400 From: Alexander Graf Date: Mon, 7 May 2012 11:30:10 +0200 Message-Id: <1336383010-28692-1-git-send-email-agraf@suse.de> Subject: [Qemu-devel] [PATCH] linux-user: Fix stale tbs after mmap List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel Developers Cc: Peter Maydell , Riku Voipio 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. Reported-by: Peter Maydell Signed-off-by: Alexander Graf --- linux-user/mmap.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 2620f88..390e940 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -587,6 +587,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, page_dump(stdout); printf("\n"); #endif + tb_invalidate_phys_page_range(start, start + len, 0); mmap_unlock(); return start; fail: @@ -768,6 +769,7 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size, page_set_flags(old_addr, old_addr + old_size, 0); page_set_flags(new_addr, new_addr + new_size, prot | PAGE_VALID); } + tb_invalidate_phys_page_range(new_addr, new_addr + new_size, 0); mmap_unlock(); return new_addr; } -- 1.6.0.2