Skip to content

Commit f9a56c5

Browse files
rpurdiestephanosio
authored andcommitted
qemu: Add some user space mmap tweaks to address musl 32 bit
When using qemu-i386 to build qemux86 webkitgtk on musl, it sits in an infinite loop of mremap calls of ever decreasing/increasing addresses. I suspect something in the musl memory allocation code loops indefinitely if it only sees ENOMEM and only exits when it hits EFAULT. According to the docs, trying to mremap outside the address space can/should return EFAULT and changing this allows the build to succeed. A better return value for the other cases of invalid addresses is EINVAL rather than ENOMEM so adjust the other part of the test to this. Upstream-Status: Submitted [https://lists.gnu.org/archive/html/qemu-devel/2021-01/msg01355.html] Signed-off-by: Richard Purdie <[email protected]
1 parent ed5112b commit f9a56c5

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

linux-user/mmap.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,12 +1108,16 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size,
11081108
int prot;
11091109
void *host_addr;
11101110

1111-
if (!guest_range_valid_untagged(old_addr, old_size) ||
1112-
((flags & MREMAP_FIXED) &&
1111+
if (!guest_range_valid_untagged(old_addr, old_size)) {
1112+
errno = EFAULT;
1113+
return -1;
1114+
}
1115+
1116+
if (((flags & MREMAP_FIXED) &&
11131117
!guest_range_valid_untagged(new_addr, new_size)) ||
11141118
((flags & MREMAP_MAYMOVE) == 0 &&
11151119
!guest_range_valid_untagged(old_addr, new_size))) {
1116-
errno = ENOMEM;
1120+
errno = EINVAL;
11171121
return -1;
11181122
}
11191123

0 commit comments

Comments
 (0)