aboutsummaryrefslogtreecommitdiff
path: root/linux-user/mmap.c
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2020-05-19 11:56:45 -0700
committerLaurent Vivier <laurent@vivier.eu>2020-08-23 16:57:58 +0200
commit4eaa960dbcd3fbd51047eacbbc20a9882a0eca63 (patch)
treec8acf9cb9083e51ded70b3e106a98acd94f18c57 /linux-user/mmap.c
parent9dba3ca5af80a7d4b5269685ceaa27ca04199cf4 (diff)
linux-user: Adjust guest page protection for the host
Executable guest pages are never directly executed by the host, but do need to be readable for translation. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Message-Id: <20200519185645.3915-3-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Diffstat (limited to 'linux-user/mmap.c')
-rw-r--r--linux-user/mmap.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index 46c7eeba9b..f261563420 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -76,8 +76,12 @@ static int validate_prot_to_pageflags(int *host_prot, int prot)
* don't bother transforming guest bit to host bit. Any other
* target-specific prot bits will not be understood by the host
* and will need to be encoded into page_flags for qemu emulation.
+ *
+ * Pages that are executable by the guest will never be executed
+ * by the host, but the host will need to be able to read them.
*/
- *host_prot = prot & (PROT_READ | PROT_WRITE | PROT_EXEC);
+ *host_prot = (prot & (PROT_READ | PROT_WRITE))
+ | (prot & PROT_EXEC ? PROT_READ : 0);
return prot & ~valid ? 0 : page_flags;
}