Skip to content

Commit 84d6626

Browse files
committed
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é <[email protected]> Reviewed-by: Warner Losh <[email protected]> Message-Id: <[email protected]>
1 parent 019b4e8 commit 84d6626

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

bsd-user/bsd-mem.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,11 @@ static inline abi_long do_bsd_shmat(int shmid, abi_ulong shmaddr, int shmflg)
370370
if (shmaddr) {
371371
host_raddr = shmat(shmid, (void *)g2h_untagged(shmaddr), shmflg);
372372
} else {
373+
abi_ulong alignment;
373374
abi_ulong mmap_start;
374375

375-
mmap_start = mmap_find_vma(0, shm_info.shm_segsz);
376+
alignment = 0; /* alignment above page size not required */
377+
mmap_start = mmap_find_vma(0, shm_info.shm_segsz, alignment);
376378

377379
if (mmap_start == -1) {
378380
return -TARGET_ENOMEM;

bsd-user/mmap.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,7 @@ static abi_ulong mmap_find_vma_reserved(abi_ulong start, abi_ulong size,
275275
* It must be called with mmap_lock() held.
276276
* Return -1 if error.
277277
*/
278-
static abi_ulong mmap_find_vma_aligned(abi_ulong start, abi_ulong size,
279-
abi_ulong alignment)
278+
abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size, abi_ulong alignment)
280279
{
281280
void *ptr, *prev;
282281
abi_ulong addr;
@@ -395,11 +394,6 @@ static abi_ulong mmap_find_vma_aligned(abi_ulong start, abi_ulong size,
395394
}
396395
}
397396

398-
abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size)
399-
{
400-
return mmap_find_vma_aligned(start, size, 0);
401-
}
402-
403397
/* NOTE: all the constants are the HOST ones */
404398
abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
405399
int flags, int fd, off_t offset)
@@ -494,7 +488,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
494488
host_len = len + offset - host_offset;
495489
host_len = HOST_PAGE_ALIGN(host_len);
496490
alignment = (flags & MAP_ALIGNMENT_MASK) >> MAP_ALIGNMENT_SHIFT;
497-
start = mmap_find_vma_aligned(real_start, host_len, alignment);
491+
start = mmap_find_vma(real_start, host_len, alignment);
498492
if (start == (abi_ulong)-1) {
499493
errno = ENOMEM;
500494
goto fail;

bsd-user/qemu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size,
242242
abi_ulong new_addr);
243243
int target_msync(abi_ulong start, abi_ulong len, int flags);
244244
extern abi_ulong mmap_next_start;
245-
abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size);
245+
abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size, abi_ulong alignment);
246246
void mmap_reserve(abi_ulong start, abi_ulong size);
247247
void TSA_NO_TSA mmap_fork_start(void);
248248
void TSA_NO_TSA mmap_fork_end(int child);

0 commit comments

Comments
 (0)