diff options
author | Akihiko Odaki <akihiko.odaki@daynix.com> | 2023-08-02 16:17:50 +0900 |
---|---|---|
committer | Richard Henderson <richard.henderson@linaro.org> | 2023-08-06 16:44:52 -0700 |
commit | e69e032d1a8ee8d754ca119009a3c2c997f8bb30 (patch) | |
tree | 23160daa5c75ee1706421b1da75eeea475279eb7 /linux-user/syscall.c | |
parent | c6cc059eca18d9f6e4e26bb8b6d1135ddb35d81a (diff) | |
download | qemu-e69e032d1a8ee8d754ca119009a3c2c997f8bb30.zip qemu-e69e032d1a8ee8d754ca119009a3c2c997f8bb30.tar.gz qemu-e69e032d1a8ee8d754ca119009a3c2c997f8bb30.tar.bz2 |
linux-user: Use MAP_FIXED_NOREPLACE for do_brk()
MAP_FIXED_NOREPLACE can ensure the mapped address is fixed without
concerning that the new mapping overwrites something else.
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Message-Id: <20230802071754.14876-5-akihiko.odaki@daynix.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'linux-user/syscall.c')
-rw-r--r-- | linux-user/syscall.c | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/linux-user/syscall.c b/linux-user/syscall.c index b08276b..f640242 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -854,17 +854,12 @@ abi_long do_brk(abi_ulong brk_val) return target_brk; } - /* We need to allocate more memory after the brk... Note that - * we don't use MAP_FIXED because that will map over the top of - * any existing mapping (like the one with the host libc or qemu - * itself); instead we treat "mapped but at wrong address" as - * a failure and unmap again. - */ if (new_host_brk_page > brk_page) { new_alloc_size = new_host_brk_page - brk_page; mapped_addr = target_mmap(brk_page, new_alloc_size, PROT_READ | PROT_WRITE, - MAP_ANON | MAP_PRIVATE, -1, 0); + MAP_FIXED_NOREPLACE | MAP_ANON | MAP_PRIVATE, + -1, 0); } else { new_alloc_size = 0; mapped_addr = brk_page; @@ -883,12 +878,6 @@ abi_long do_brk(abi_ulong brk_val) target_brk = brk_val; brk_page = new_host_brk_page; return target_brk; - } else if (mapped_addr != -1) { - /* Mapped but at wrong address, meaning there wasn't actually - * enough space for this brk. - */ - target_munmap(mapped_addr, new_alloc_size); - mapped_addr = -1; } #if defined(TARGET_ALPHA) |