1When using qemu-i386 to build qemux86 webkitgtk on musl, it sits in an 2infinite loop of mremap calls of ever decreasing/increasing addresses. 3 4I suspect something in the musl memory allocation code loops indefinitely 5if it only sees ENOMEM and only exits when it hits EFAULT. 6 7According to the docs, trying to mremap outside the address space 8can/should return EFAULT and changing this allows the build to succeed. 9 10A better return value for the other cases of invalid addresses is EINVAL 11rather than ENOMEM so adjust the other part of the test to this. 12 13Upstream-Status: Submitted [https://lists.gnu.org/archive/html/qemu-devel/2021-01/msg01355.html] 14Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org 15 16Index: qemu-6.0.0/linux-user/mmap.c 17=================================================================== 18--- qemu-6.0.0.orig/linux-user/mmap.c 19+++ qemu-6.0.0/linux-user/mmap.c 20@@ -733,12 +733,16 @@ abi_long target_mremap(abi_ulong old_add 21 int prot; 22 void *host_addr; 23 24- if (!guest_range_valid_untagged(old_addr, old_size) || 25- ((flags & MREMAP_FIXED) && 26+ if (!guest_range_valid_untagged(old_addr, old_size)) { 27+ errno = EFAULT; 28+ return -1; 29+ } 30+ 31+ if (((flags & MREMAP_FIXED) && 32 !guest_range_valid_untagged(new_addr, new_size)) || 33 ((flags & MREMAP_MAYMOVE) == 0 && 34 !guest_range_valid_untagged(old_addr, new_size))) { 35- errno = ENOMEM; 36+ errno = EINVAL; 37 return -1; 38 } 39 40