[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 23/39] linux-user: Do early mmap placement only for reserved_va
From: |
Richard Henderson |
Subject: |
[PULL 23/39] linux-user: Do early mmap placement only for reserved_va |
Date: |
Thu, 22 Feb 2024 10:43:07 -1000 |
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>
---
linux-user/mmap.c | 12 +++++++-----
1 file 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;
}
/*
--
2.34.1
- [PULL 12/39] linux-user: Remove REAL_HOST_PAGE_ALIGN from mmap.c, (continued)
- [PULL 12/39] linux-user: Remove REAL_HOST_PAGE_ALIGN from mmap.c, Richard Henderson, 2024/02/22
- [PULL 13/39] linux-user: Remove HOST_PAGE_ALIGN from mmap.c, Richard Henderson, 2024/02/22
- [PULL 14/39] migration: Remove qemu_host_page_size, Richard Henderson, 2024/02/22
- [PULL 15/39] hw/tpm: Remove HOST_PAGE_ALIGN from tpm_ppi_init, Richard Henderson, 2024/02/22
- [PULL 16/39] softmmu/physmem: Remove qemu_host_page_size, Richard Henderson, 2024/02/22
- [PULL 17/39] softmmu/physmem: Remove HOST_PAGE_ALIGN, Richard Henderson, 2024/02/22
- [PULL 18/39] linux-user: Remove qemu_host_page_size from main, Richard Henderson, 2024/02/22
- [PULL 19/39] linux-user: Split out target_mmap__locked, Richard Henderson, 2024/02/22
- [PULL 20/39] linux-user: Move some mmap checks outside the lock, Richard Henderson, 2024/02/22
- [PULL 21/39] linux-user: Fix sub-host-page mmap, Richard Henderson, 2024/02/22
- [PULL 23/39] linux-user: Do early mmap placement only for reserved_va,
Richard Henderson <=
- [PULL 22/39] linux-user: Split out mmap_end, Richard Henderson, 2024/02/22
- [PULL 25/39] linux-user: Use do_munmap for target_mmap failure, Richard Henderson, 2024/02/22
- [PULL 24/39] linux-user: Split out do_munmap, Richard Henderson, 2024/02/22
- [PULL 26/39] linux-user: Split out mmap_h_eq_g, Richard Henderson, 2024/02/22
- [PULL 27/39] linux-user: Split out mmap_h_lt_g, Richard Henderson, 2024/02/22
- [PULL 28/39] linux-user: Split out mmap_h_gt_g, Richard Henderson, 2024/02/22
- [PULL 30/39] tests/tcg: Extend file in linux-madvise.c, Richard Henderson, 2024/02/22
- [PULL 29/39] tests/tcg: Remove run-test-mmap-*, Richard Henderson, 2024/02/22
- [PULL 31/39] *-user: Deprecate and disable -p pagesize, Richard Henderson, 2024/02/22
- [PULL 32/39] cpu: Remove page_size_init, Richard Henderson, 2024/02/22