[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 20/24] linux-user: Simplify target_munmap
From: |
Richard Henderson |
Subject: |
[PATCH 20/24] linux-user: Simplify target_munmap |
Date: |
Fri, 30 Jun 2023 15:21:55 +0200 |
All of the guest to host page adjustment is handled by
mmap_reserve_or_unmap; there is no need to duplicate that.
There are no failure modes for munmap after alignment and
guest address range have been validated.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
linux-user/mmap.c | 47 ++++-------------------------------------------
1 file changed, 4 insertions(+), 43 deletions(-)
diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index 8c90a690dd..e6463ecd8d 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -789,9 +789,6 @@ static void mmap_reserve_or_unmap(abi_ulong start,
abi_ulong len)
int target_munmap(abi_ulong start, abi_ulong len)
{
- abi_ulong end, real_start, real_end, addr;
- int prot, ret;
-
trace_target_munmap(start, len);
if (start & ~TARGET_PAGE_MASK) {
@@ -803,47 +800,11 @@ int target_munmap(abi_ulong start, abi_ulong len)
}
mmap_lock();
- end = start + len;
- real_start = start & qemu_host_page_mask;
- real_end = HOST_PAGE_ALIGN(end);
-
- if (start > real_start) {
- /* handle host page containing start */
- prot = 0;
- for (addr = real_start; addr < start; addr += TARGET_PAGE_SIZE) {
- prot |= page_get_flags(addr);
- }
- if (real_end == real_start + qemu_host_page_size) {
- for (addr = end; addr < real_end; addr += TARGET_PAGE_SIZE) {
- prot |= page_get_flags(addr);
- }
- end = real_end;
- }
- if (prot != 0) {
- real_start += qemu_host_page_size;
- }
- }
- if (end < real_end) {
- prot = 0;
- for (addr = end; addr < real_end; addr += TARGET_PAGE_SIZE) {
- prot |= page_get_flags(addr);
- }
- if (prot != 0) {
- real_end -= qemu_host_page_size;
- }
- }
-
- ret = 0;
- /* unmap what we can */
- if (real_start < real_end) {
- mmap_reserve_or_unmap(real_start, real_end - real_start);
- }
-
- if (ret == 0) {
- page_set_flags(start, start + len - 1, 0);
- }
+ mmap_reserve_or_unmap(start, len);
+ page_set_flags(start, start + len - 1, 0);
mmap_unlock();
- return ret;
+
+ return 0;
}
abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size,
--
2.34.1
- [PATCH 11/24] linux-user: Widen target_mmap offset argument to off_t, (continued)
- [PATCH 11/24] linux-user: Widen target_mmap offset argument to off_t, Richard Henderson, 2023/06/30
- [PATCH 12/24] linux-user: Rewrite target_mprotect, Richard Henderson, 2023/06/30
- [PATCH 09/24] linux-user: Implement MAP_FIXED_NOREPLACE, Richard Henderson, 2023/06/30
- [PATCH 10/24] linux-user: Split out target_to_host_prot, Richard Henderson, 2023/06/30
- [PATCH 14/24] accel/tcg: Introduce page_find_range_empty, Richard Henderson, 2023/06/30
- [PATCH 13/24] linux-user: Rewrite mmap_frag, Richard Henderson, 2023/06/30
- [PATCH 18/24] linux-user: Rewrite mmap_reserve, Richard Henderson, 2023/06/30
- [PATCH 15/24] bsd-user: Use page_find_range_empty for mmap_find_vma_reserved, Richard Henderson, 2023/06/30
- [PATCH 16/24] linux-user: Use page_find_range_empty for mmap_find_vma_reserved, Richard Henderson, 2023/06/30
- [PATCH 17/24] linux-user: Use 'last' instead of 'end' in target_mmap, Richard Henderson, 2023/06/30
- [PATCH 20/24] linux-user: Simplify target_munmap,
Richard Henderson <=
- [PATCH 21/24] accel/tcg: Accept more page flags in page_check_range, Richard Henderson, 2023/06/30
- [PATCH 19/24] linux-user: Rename mmap_reserve to mmap_reserve_or_unmap, Richard Henderson, 2023/06/30
- [PATCH 22/24] accel/tcg: Return bool from page_check_range, Richard Henderson, 2023/06/30
- [PATCH 23/24] linux-user: Remove can_passthrough_madvise, Richard Henderson, 2023/06/30
- [PATCH 24/24] linux-user: Simplify target_madvise, Richard Henderson, 2023/06/30