aboutsummaryrefslogtreecommitdiff
path: root/bsd-user
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé <philmd@linaro.org>2025-03-07 13:47:21 +0100
committerPhilippe Mathieu-Daudé <philmd@linaro.org>2025-03-09 14:54:32 +0100
commit84d66261bef3cdfea3bd1fb052a7ba38abb34b18 (patch)
treefe24c81b2dfdf6fe723849bf42edbb9a01849d4d /bsd-user
parent019b4e84eda27a006f94ed0faa024babd0a97e97 (diff)
downloadqemu-84d66261bef3cdfea3bd1fb052a7ba38abb34b18.zip
qemu-84d66261bef3cdfea3bd1fb052a7ba38abb34b18.tar.gz
qemu-84d66261bef3cdfea3bd1fb052a7ba38abb34b18.tar.bz2
bsd-user: Propagate alignment argument to mmap_find_vma()
Propagate the alignment to mmap_find_vma(), effectively embedding mmap_find_vma_aligned() within mmap_find_vma(). Add a comment in do_bsd_shmat() to clarify alignment above page size is not required. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Warner Losh <imp@bsdimp.com> Message-Id: <20250308122842.76377-3-philmd@linaro.org>
Diffstat (limited to 'bsd-user')
-rw-r--r--bsd-user/bsd-mem.h4
-rw-r--r--bsd-user/mmap.c10
-rw-r--r--bsd-user/qemu.h2
3 files changed, 6 insertions, 10 deletions
diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h
index f5ec0de..90ca0e3 100644
--- a/bsd-user/bsd-mem.h
+++ b/bsd-user/bsd-mem.h
@@ -370,9 +370,11 @@ static inline abi_long do_bsd_shmat(int shmid, abi_ulong shmaddr, int shmflg)
if (shmaddr) {
host_raddr = shmat(shmid, (void *)g2h_untagged(shmaddr), shmflg);
} else {
+ abi_ulong alignment;
abi_ulong mmap_start;
- mmap_start = mmap_find_vma(0, shm_info.shm_segsz);
+ alignment = 0; /* alignment above page size not required */
+ mmap_start = mmap_find_vma(0, shm_info.shm_segsz, alignment);
if (mmap_start == -1) {
return -TARGET_ENOMEM;
diff --git a/bsd-user/mmap.c b/bsd-user/mmap.c
index dfa6e72..3f0df79 100644
--- a/bsd-user/mmap.c
+++ b/bsd-user/mmap.c
@@ -275,8 +275,7 @@ static abi_ulong mmap_find_vma_reserved(abi_ulong start, abi_ulong size,
* It must be called with mmap_lock() held.
* Return -1 if error.
*/
-static abi_ulong mmap_find_vma_aligned(abi_ulong start, abi_ulong size,
- abi_ulong alignment)
+abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size, abi_ulong alignment)
{
void *ptr, *prev;
abi_ulong addr;
@@ -395,11 +394,6 @@ static abi_ulong mmap_find_vma_aligned(abi_ulong start, abi_ulong size,
}
}
-abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size)
-{
- return mmap_find_vma_aligned(start, size, 0);
-}
-
/* NOTE: all the constants are the HOST ones */
abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
int flags, int fd, off_t offset)
@@ -494,7 +488,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
host_len = len + offset - host_offset;
host_len = HOST_PAGE_ALIGN(host_len);
alignment = (flags & MAP_ALIGNMENT_MASK) >> MAP_ALIGNMENT_SHIFT;
- start = mmap_find_vma_aligned(real_start, host_len, alignment);
+ start = mmap_find_vma(real_start, host_len, alignment);
if (start == (abi_ulong)-1) {
errno = ENOMEM;
goto fail;
diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
index 4e97c79..0b3bd65 100644
--- a/bsd-user/qemu.h
+++ b/bsd-user/qemu.h
@@ -242,7 +242,7 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size,
abi_ulong new_addr);
int target_msync(abi_ulong start, abi_ulong len, int flags);
extern abi_ulong mmap_next_start;
-abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size);
+abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size, abi_ulong alignment);
void mmap_reserve(abi_ulong start, abi_ulong size);
void TSA_NO_TSA mmap_fork_start(void);
void TSA_NO_TSA mmap_fork_end(int child);