[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 41/45] translate-all: use qemu_protect_rwx/none h
From: |
Emilio G. Cota |
Subject: |
[Qemu-devel] [PATCH v2 41/45] translate-all: use qemu_protect_rwx/none helpers |
Date: |
Sun, 16 Jul 2017 16:04:24 -0400 |
Signed-off-by: Emilio G. Cota <address@hidden>
---
accel/tcg/translate-all.c | 49 ++++++-----------------------------------------
1 file changed, 6 insertions(+), 43 deletions(-)
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
index fd3e4a0..913b1c5 100644
--- a/accel/tcg/translate-all.c
+++ b/accel/tcg/translate-all.c
@@ -604,47 +604,6 @@ static inline void *split_cross_256mb(void *buf1, size_t
size1)
static uint8_t static_code_gen_buffer[DEFAULT_CODE_GEN_BUFFER_SIZE]
__attribute__((aligned(CODE_GEN_ALIGN)));
-# ifdef _WIN32
-static inline void do_protect(void *addr, long size, int prot)
-{
- DWORD old_protect;
- VirtualProtect(addr, size, prot, &old_protect);
-}
-
-static inline void map_exec(void *addr, long size)
-{
- do_protect(addr, size, PAGE_EXECUTE_READWRITE);
-}
-
-static inline void map_none(void *addr, long size)
-{
- do_protect(addr, size, PAGE_NOACCESS);
-}
-# else
-static inline void do_protect(void *addr, long size, int prot)
-{
- uintptr_t start, end;
-
- start = (uintptr_t)addr;
- start &= qemu_real_host_page_mask;
-
- end = (uintptr_t)addr + size;
- end = ROUND_UP(end, qemu_real_host_page_size);
-
- mprotect((void *)start, end - start, prot);
-}
-
-static inline void map_exec(void *addr, long size)
-{
- do_protect(addr, size, PROT_READ | PROT_WRITE | PROT_EXEC);
-}
-
-static inline void map_none(void *addr, long size)
-{
- do_protect(addr, size, PROT_NONE);
-}
-# endif /* WIN32 */
-
static inline void *alloc_code_gen_buffer(void)
{
void *buf = static_code_gen_buffer;
@@ -671,8 +630,12 @@ static inline void *alloc_code_gen_buffer(void)
}
#endif
- map_exec(buf, size);
- map_none(buf + size, qemu_real_host_page_size);
+ if (qemu_mprotect_rwx(buf, size)) {
+ abort();
+ }
+ if (qemu_mprotect_none(buf + size, qemu_real_host_page_size)) {
+ abort();
+ }
qemu_madvise(buf, size, QEMU_MADV_HUGEPAGE);
return buf;
--
2.7.4
- [Qemu-devel] [PATCH v2 34/45] tcg: define tcg_init_ctx and make tcg_ctx a pointer, (continued)
- [Qemu-devel] [PATCH v2 17/45] target/i386: check CF_PARALLEL instead of parallel_cpus, Emilio G. Cota, 2017/07/16
- [Qemu-devel] [PATCH v2 13/45] tcg: consolidate TB lookups in tb_lookup__cpu_state, Emilio G. Cota, 2017/07/16
- [Qemu-devel] [PATCH v2 41/45] translate-all: use qemu_protect_rwx/none helpers,
Emilio G. Cota <=
- [Qemu-devel] [PATCH v2 44/45] translate-all: do not allocate a guard page for code_gen_buffer, Emilio G. Cota, 2017/07/16
- [Qemu-devel] [PATCH v2 28/45] translate-all: use a binary search tree to track TBs in TBContext, Emilio G. Cota, 2017/07/16
- [Qemu-devel] [PATCH v2 30/45] translate-all: report correct avg host TB size, Emilio G. Cota, 2017/07/16
- [Qemu-devel] [PATCH v2 19/45] target/s390x: check CF_PARALLEL instead of parallel_cpus, Emilio G. Cota, 2017/07/16
- [Qemu-devel] [PATCH v2 27/45] exec-all: extract tb->tc_* into a separate struct tc_tb, Emilio G. Cota, 2017/07/16