diff options
author | Philippe Mathieu-Daudé <philmd@linaro.org> | 2025-03-07 14:02:21 +0100 |
---|---|---|
committer | Philippe Mathieu-Daudé <philmd@linaro.org> | 2025-03-09 14:54:32 +0100 |
commit | 019b4e84eda27a006f94ed0faa024babd0a97e97 (patch) | |
tree | 8ae1339709de564904da3f7dcff5b16d9da9de85 /bsd-user | |
parent | c9ce8a1ffdedbc55d107c4b5629eca5d1e219165 (diff) | |
download | qemu-019b4e84eda27a006f94ed0faa024babd0a97e97.zip qemu-019b4e84eda27a006f94ed0faa024babd0a97e97.tar.gz qemu-019b4e84eda27a006f94ed0faa024babd0a97e97.tar.bz2 |
bsd-user: Always use mmap_find_vma_aligned() in target_mmap()
Massage target_mmap(): calculate alignment once, then
unconditionally call mmap_find_vma_aligned().
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Warner Losh <imp@bsdimp.com>
Message-Id: <20250308122842.76377-2-philmd@linaro.org>
Diffstat (limited to 'bsd-user')
-rw-r--r-- | bsd-user/mmap.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/bsd-user/mmap.c b/bsd-user/mmap.c index 346f2ce..dfa6e72 100644 --- a/bsd-user/mmap.c +++ b/bsd-user/mmap.c @@ -489,13 +489,12 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, * before we truncate the length for mapping files below. */ if (!(flags & MAP_FIXED)) { + abi_ulong alignment; + host_len = len + offset - host_offset; host_len = HOST_PAGE_ALIGN(host_len); - if ((flags & MAP_ALIGNMENT_MASK) != 0) - start = mmap_find_vma_aligned(real_start, host_len, - (flags & MAP_ALIGNMENT_MASK) >> MAP_ALIGNMENT_SHIFT); - else - start = mmap_find_vma(real_start, host_len); + alignment = (flags & MAP_ALIGNMENT_MASK) >> MAP_ALIGNMENT_SHIFT; + start = mmap_find_vma_aligned(real_start, host_len, alignment); if (start == (abi_ulong)-1) { errno = ENOMEM; goto fail; |