diff options
author | pbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162> | 2008-05-31 16:33:53 +0000 |
---|---|---|
committer | pbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162> | 2008-05-31 16:33:53 +0000 |
commit | 0776590d70565df4165b328f3cb80d29d21d52a5 (patch) | |
tree | eb9c0e2d263071cecc9ed3cbff40dad6ab5de8fa /linux-user | |
parent | 1090e7a2c62a5b829ba947fd0e004b29c446d22f (diff) | |
download | qemu-0776590d70565df4165b328f3cb80d29d21d52a5.zip qemu-0776590d70565df4165b328f3cb80d29d21d52a5.tar.gz qemu-0776590d70565df4165b328f3cb80d29d21d52a5.tar.bz2 |
Mark host brk() area as reserved.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4637 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'linux-user')
-rw-r--r-- | linux-user/mmap.c | 16 | ||||
-rw-r--r-- | linux-user/qemu.h | 1 |
2 files changed, 17 insertions, 0 deletions
diff --git a/linux-user/mmap.c b/linux-user/mmap.c index b5e31f5..794b1d0 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -157,6 +157,8 @@ static abi_ulong mmap_next_start = 0x18000000; static abi_ulong mmap_next_start = 0x40000000; #endif +unsigned long last_brk; + /* find a free memory area of size 'size'. The search starts at 'start'. If 'start' == 0, then a default start address is used. Return -1 if error. @@ -167,6 +169,20 @@ static abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size) { abi_ulong addr, addr1, addr_start; int prot; + unsigned long new_brk; + + new_brk = (unsigned long)sbrk(0); + if (last_brk && last_brk < new_brk && last_brk == (target_ulong)last_brk) { + /* This is a hack to catch the host allocating memory with brk(). + If it uses mmap then we loose. + FIXME: We really want to avoid the host allocating memory in + the first place, and maybe leave some slack to avoid switching + to mmap. */ + page_set_flags(last_brk & TARGET_PAGE_MASK, + TARGET_PAGE_ALIGN(new_brk), + PAGE_RESERVED); + } + last_brk = new_brk; size = HOST_PAGE_ALIGN(size); start = start & qemu_host_page_mask; diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 8b11495..093b8ff 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -232,6 +232,7 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size, abi_ulong new_size, unsigned long flags, abi_ulong new_addr); int target_msync(abi_ulong start, abi_ulong len, int flags); +extern unsigned long last_brk; /* user access */ |