Commit 0776590d70565df4165b328f3cb80d29d21d52a5
1 parent
1090e7a2
Mark host brk() area as reserved.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4637 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
3 changed files
with
18 additions
and
0 deletions
exec.c
linux-user/mmap.c
... | ... | @@ -157,6 +157,8 @@ static abi_ulong mmap_next_start = 0x18000000; |
157 | 157 | static abi_ulong mmap_next_start = 0x40000000; |
158 | 158 | #endif |
159 | 159 | |
160 | +unsigned long last_brk; | |
161 | + | |
160 | 162 | /* find a free memory area of size 'size'. The search starts at |
161 | 163 | 'start'. If 'start' == 0, then a default start address is used. |
162 | 164 | Return -1 if error. |
... | ... | @@ -167,6 +169,20 @@ static abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size) |
167 | 169 | { |
168 | 170 | abi_ulong addr, addr1, addr_start; |
169 | 171 | int prot; |
172 | + unsigned long new_brk; | |
173 | + | |
174 | + new_brk = (unsigned long)sbrk(0); | |
175 | + if (last_brk && last_brk < new_brk && last_brk == (target_ulong)last_brk) { | |
176 | + /* This is a hack to catch the host allocating memory with brk(). | |
177 | + If it uses mmap then we loose. | |
178 | + FIXME: We really want to avoid the host allocating memory in | |
179 | + the first place, and maybe leave some slack to avoid switching | |
180 | + to mmap. */ | |
181 | + page_set_flags(last_brk & TARGET_PAGE_MASK, | |
182 | + TARGET_PAGE_ALIGN(new_brk), | |
183 | + PAGE_RESERVED); | |
184 | + } | |
185 | + last_brk = new_brk; | |
170 | 186 | |
171 | 187 | size = HOST_PAGE_ALIGN(size); |
172 | 188 | start = start & qemu_host_page_mask; | ... | ... |
linux-user/qemu.h
... | ... | @@ -232,6 +232,7 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size, |
232 | 232 | abi_ulong new_size, unsigned long flags, |
233 | 233 | abi_ulong new_addr); |
234 | 234 | int target_msync(abi_ulong start, abi_ulong len, int flags); |
235 | +extern unsigned long last_brk; | |
235 | 236 | |
236 | 237 | /* user access */ |
237 | 238 | ... | ... |