Commit d5a8f07c52161a5d8021ace23029397475286eb2
1 parent
345fbaa3
no data exec support
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1074 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
29 additions
and
4 deletions
exec.c
... | ... | @@ -18,6 +18,11 @@ |
18 | 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 | 19 | */ |
20 | 20 | #include "config.h" |
21 | +#ifdef _WIN32 | |
22 | +#include <windows.h> | |
23 | +#else | |
24 | +#include <sys/mman.h> | |
25 | +#endif | |
21 | 26 | #include <stdlib.h> |
22 | 27 | #include <stdio.h> |
23 | 28 | #include <stdarg.h> |
... | ... | @@ -25,9 +30,6 @@ |
25 | 30 | #include <errno.h> |
26 | 31 | #include <unistd.h> |
27 | 32 | #include <inttypes.h> |
28 | -#if !defined(CONFIG_SOFTMMU) | |
29 | -#include <sys/mman.h> | |
30 | -#endif | |
31 | 33 | |
32 | 34 | #include "cpu.h" |
33 | 35 | #include "exec-all.h" |
... | ... | @@ -130,10 +132,33 @@ static void page_init(void) |
130 | 132 | /* NOTE: we can always suppose that qemu_host_page_size >= |
131 | 133 | TARGET_PAGE_SIZE */ |
132 | 134 | #ifdef _WIN32 |
133 | - qemu_real_host_page_size = 4096; | |
135 | + { | |
136 | + SYSTEM_INFO system_info; | |
137 | + DWORD old_protect; | |
138 | + | |
139 | + GetSystemInfo(&system_info); | |
140 | + qemu_real_host_page_size = system_info.dwPageSize; | |
141 | + | |
142 | + VirtualProtect(code_gen_buffer, sizeof(code_gen_buffer), | |
143 | + PAGE_EXECUTE_READWRITE, &old_protect); | |
144 | + } | |
134 | 145 | #else |
135 | 146 | qemu_real_host_page_size = getpagesize(); |
147 | + { | |
148 | + unsigned long start, end; | |
149 | + | |
150 | + start = (unsigned long)code_gen_buffer; | |
151 | + start &= ~(qemu_real_host_page_size - 1); | |
152 | + | |
153 | + end = (unsigned long)code_gen_buffer + sizeof(code_gen_buffer); | |
154 | + end += qemu_real_host_page_size - 1; | |
155 | + end &= ~(qemu_real_host_page_size - 1); | |
156 | + | |
157 | + mprotect((void *)start, end - start, | |
158 | + PROT_READ | PROT_WRITE | PROT_EXEC); | |
159 | + } | |
136 | 160 | #endif |
161 | + | |
137 | 162 | if (qemu_host_page_size == 0) |
138 | 163 | qemu_host_page_size = qemu_real_host_page_size; |
139 | 164 | if (qemu_host_page_size < TARGET_PAGE_SIZE) | ... | ... |