summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/qemu/qemu/mmap2.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/qemu/qemu/mmap2.patch')
-rw-r--r--meta/recipes-devtools/qemu/qemu/mmap2.patch26
1 files changed, 20 insertions, 6 deletions
diff --git a/meta/recipes-devtools/qemu/qemu/mmap2.patch b/meta/recipes-devtools/qemu/qemu/mmap2.patch
index 9d40565938..1652131757 100644
--- a/meta/recipes-devtools/qemu/qemu/mmap2.patch
+++ b/meta/recipes-devtools/qemu/qemu/mmap2.patch
@@ -6,21 +6,35 @@ 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.
-Whether this should be fixed in qemu and/or musl, not sure.
-Upstream-Status: Pending
+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 <richard.purdie@linuxfoundation.org
Index: qemu-5.2.0/linux-user/mmap.c
===================================================================
--- qemu-5.2.0.orig/linux-user/mmap.c
+++ qemu-5.2.0/linux-user/mmap.c
-@@ -727,7 +727,7 @@ abi_long target_mremap(abi_ulong old_add
- !guest_range_valid(new_addr, new_size)) ||
- ((flags & MREMAP_MAYMOVE) == 0 &&
- !guest_range_valid(old_addr, new_size))) {
+@@ -722,12 +722,14 @@ abi_long target_mremap(abi_ulong old_add
+ int prot;
+ void *host_addr;
+
+- if (!guest_range_valid(old_addr, old_size) ||
+- ((flags & MREMAP_FIXED) &&
+- !guest_range_valid(new_addr, new_size)) ||
+- ((flags & MREMAP_MAYMOVE) == 0 &&
+- !guest_range_valid(old_addr, new_size))) {
- errno = ENOMEM;
++ if (!guest_range_valid(old_addr, old_size)) {
+ errno = EFAULT;
++ return -1;
++ }
++
++ if (((flags & MREMAP_FIXED) && !guest_range_valid(new_addr, new_size)) ||
++ ((flags & MREMAP_MAYMOVE) == 0 && !guest_range_valid(old_addr, new_size))) {
++ errno = EINVAL;
return -1;
}