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,6 +18,11 @@ | ||
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | */ | 19 | */ |
| 20 | #include "config.h" | 20 | #include "config.h" |
| 21 | +#ifdef _WIN32 | ||
| 22 | +#include <windows.h> | ||
| 23 | +#else | ||
| 24 | +#include <sys/mman.h> | ||
| 25 | +#endif | ||
| 21 | #include <stdlib.h> | 26 | #include <stdlib.h> |
| 22 | #include <stdio.h> | 27 | #include <stdio.h> |
| 23 | #include <stdarg.h> | 28 | #include <stdarg.h> |
| @@ -25,9 +30,6 @@ | @@ -25,9 +30,6 @@ | ||
| 25 | #include <errno.h> | 30 | #include <errno.h> |
| 26 | #include <unistd.h> | 31 | #include <unistd.h> |
| 27 | #include <inttypes.h> | 32 | #include <inttypes.h> |
| 28 | -#if !defined(CONFIG_SOFTMMU) | ||
| 29 | -#include <sys/mman.h> | ||
| 30 | -#endif | ||
| 31 | 33 | ||
| 32 | #include "cpu.h" | 34 | #include "cpu.h" |
| 33 | #include "exec-all.h" | 35 | #include "exec-all.h" |
| @@ -130,10 +132,33 @@ static void page_init(void) | @@ -130,10 +132,33 @@ static void page_init(void) | ||
| 130 | /* NOTE: we can always suppose that qemu_host_page_size >= | 132 | /* NOTE: we can always suppose that qemu_host_page_size >= |
| 131 | TARGET_PAGE_SIZE */ | 133 | TARGET_PAGE_SIZE */ |
| 132 | #ifdef _WIN32 | 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 | #else | 145 | #else |
| 135 | qemu_real_host_page_size = getpagesize(); | 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 | #endif | 160 | #endif |
| 161 | + | ||
| 137 | if (qemu_host_page_size == 0) | 162 | if (qemu_host_page_size == 0) |
| 138 | qemu_host_page_size = qemu_real_host_page_size; | 163 | qemu_host_page_size = qemu_real_host_page_size; |
| 139 | if (qemu_host_page_size < TARGET_PAGE_SIZE) | 164 | if (qemu_host_page_size < TARGET_PAGE_SIZE) |