Commit 50a9569b591a83071052614f2ff497ff2f2aa2ef
1 parent
703243a0
Mark host pages as reserved (Magnus Damm).
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3813 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
3 changed files
with
23 additions
and
1 deletions
cpu-all.h
| @@ -716,6 +716,7 @@ extern unsigned long qemu_host_page_mask; | @@ -716,6 +716,7 @@ extern unsigned long qemu_host_page_mask; | ||
| 716 | /* original state of the write flag (used when tracking self-modifying | 716 | /* original state of the write flag (used when tracking self-modifying |
| 717 | code */ | 717 | code */ |
| 718 | #define PAGE_WRITE_ORG 0x0010 | 718 | #define PAGE_WRITE_ORG 0x0010 |
| 719 | +#define PAGE_RESERVED 0x0020 | ||
| 719 | 720 | ||
| 720 | void page_dump(FILE *f); | 721 | void page_dump(FILE *f); |
| 721 | int page_get_flags(target_ulong address); | 722 | int page_get_flags(target_ulong address); |
exec.c
| @@ -209,6 +209,27 @@ static void page_init(void) | @@ -209,6 +209,27 @@ static void page_init(void) | ||
| 209 | qemu_host_page_mask = ~(qemu_host_page_size - 1); | 209 | qemu_host_page_mask = ~(qemu_host_page_size - 1); |
| 210 | l1_phys_map = qemu_vmalloc(L1_SIZE * sizeof(void *)); | 210 | l1_phys_map = qemu_vmalloc(L1_SIZE * sizeof(void *)); |
| 211 | memset(l1_phys_map, 0, L1_SIZE * sizeof(void *)); | 211 | memset(l1_phys_map, 0, L1_SIZE * sizeof(void *)); |
| 212 | + | ||
| 213 | +#if !defined(_WIN32) && defined(CONFIG_USER_ONLY) | ||
| 214 | + { | ||
| 215 | + long long startaddr, endaddr; | ||
| 216 | + FILE *f; | ||
| 217 | + int n; | ||
| 218 | + | ||
| 219 | + f = fopen("/proc/self/maps", "r"); | ||
| 220 | + if (f) { | ||
| 221 | + do { | ||
| 222 | + n = fscanf (f, "%llx-%llx %*[^\n]\n", &startaddr, &endaddr); | ||
| 223 | + if (n == 2) { | ||
| 224 | + page_set_flags(TARGET_PAGE_ALIGN(startaddr), | ||
| 225 | + TARGET_PAGE_ALIGN(endaddr), | ||
| 226 | + PAGE_RESERVED); | ||
| 227 | + } | ||
| 228 | + } while (!feof(f)); | ||
| 229 | + fclose(f); | ||
| 230 | + } | ||
| 231 | + } | ||
| 232 | +#endif | ||
| 212 | } | 233 | } |
| 213 | 234 | ||
| 214 | static inline PageDesc *page_find_alloc(unsigned int index) | 235 | static inline PageDesc *page_find_alloc(unsigned int index) |
linux-user/mmap.c
| @@ -162,7 +162,7 @@ static abi_ulong mmap_next_start = 0x40000000; | @@ -162,7 +162,7 @@ static abi_ulong mmap_next_start = 0x40000000; | ||
| 162 | 'start'. If 'start' == 0, then a default start address is used. | 162 | 'start'. If 'start' == 0, then a default start address is used. |
| 163 | Return -1 if error. | 163 | Return -1 if error. |
| 164 | */ | 164 | */ |
| 165 | -/* XXX: should mark pages used by the host as reserved to be sure not | 165 | +/* page_init() marks pages used by the host as reserved to be sure not |
| 166 | to use them. */ | 166 | to use them. */ |
| 167 | static abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size) | 167 | static abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size) |
| 168 | { | 168 | { |