aboutsummaryrefslogtreecommitdiff
path: root/linux-user/mmap.c
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2024-01-02 12:57:55 +1100
committerRichard Henderson <richard.henderson@linaro.org>2024-02-29 11:35:36 -1000
commitad87d26e6bb13257409f412224c862fc54025e8b (patch)
treea3138731f20a58383c3cf54e5e2a90ab5da34c43 /linux-user/mmap.c
parent6ecc25570f2ef691def1c9d1583c4a3586e56f3a (diff)
linux-user: Do early mmap placement only for reserved_va
For reserved_va, place all non-fixed maps then proceed as for MAP_FIXED. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> Reviewed-by: Ilya Leoshkevich <iii@linux.ibm.com> Acked-by: Helge Deller <deller@gmx.de> Message-Id: <20240102015808.132373-21-richard.henderson@linaro.org>
Diffstat (limited to 'linux-user/mmap.c')
-rw-r--r--linux-user/mmap.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index cc983bedbd..1bbfeb25b1 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -540,17 +540,19 @@ static abi_long target_mmap__locked(abi_ulong start, abi_ulong len,
host_offset = offset & -host_page_size;
/*
- * If the user is asking for the kernel to find a location, do that
- * before we truncate the length for mapping files below.
+ * For reserved_va, we are in full control of the allocation.
+ * Find a suitable hole and convert to MAP_FIXED.
*/
- if (!(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) {
+ if (reserved_va && !(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) {
host_len = len + offset - host_offset;
- host_len = ROUND_UP(host_len, host_page_size);
- start = mmap_find_vma(real_start, host_len, TARGET_PAGE_SIZE);
+ start = mmap_find_vma(real_start, host_len,
+ MAX(host_page_size, TARGET_PAGE_SIZE));
if (start == (abi_ulong)-1) {
errno = ENOMEM;
return -1;
}
+ start += offset - host_offset;
+ flags |= MAP_FIXED;
}
/*