linux-user: Fix stale tbs after mmap
authorAlexander Graf <agraf@suse.de>
Thu, 10 May 2012 22:40:10 +0000 (22:40 +0000)
committerBlue Swirl <blauwirbel@gmail.com>
Sat, 19 May 2012 15:49:40 +0000 (15:49 +0000)
commit77a8f1a5125457d845fac6aa0c2e1e2681d94f07
tree48ebe6991720d75db8c9b952dc4ed474ef586acd
parent4636b9d1466adde156d469c92d6e7cae7311b81e
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 <peter.maydell@linaro.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Acked-by: Riku Voipio <riku.voipio@linaro.org>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
exec-all.h
exec.c
linux-user/mmap.c