qemu: Refresh mmap fixes patch status/content
PATCH 1/1 qemu: Refresh mmap fixes patch status/content
One mmap patch was merged upstream, the other is in progress but after discussion has been amended and resent. Update the patches as such.
--- meta/recipes-devtools/qemu/qemu/mmap.patch | 2 +- meta/recipes-devtools/qemu/qemu/mmap2.patch | 26 ++++++++++++++++----- 2 files changed, 21 insertions(+), 7 deletions(-)
meta/recipes-devtools/qemu/qemu/mmap.patch +1 -1
@@ -9,7 +9,7 @@ avoid asserting binaries when reserved_va is set. This meant a test case now gives the same behaviour regardless of whether reserved_va is set or not. -Upstream-Status: Pending +Upstream-Status: Backport [https://github.com/qemu/qemu/commit/ccc5ccc17f8cfbfd87d9aede5d12a2d47c56e712] Signed-off-by: Richard Purdie <[email protected] Index: qemu-5.2.0/linux-user/mmap.c
meta/recipes-devtools/qemu/qemu/mmap2.patch +20 -6
@@ -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 <[email protected] 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; }
Signature · 1 line
2.27.0
I am seeing musl builds are hung in qemu now, I suspect this change is causing it.
Quoted 75 lines · Richard Purdie
One mmap patch was merged upstream, the other is in progress but after discussion has been amended and resent. Update the patches as such.
Signed-off-by Richard Purdie <[email protected]>--- meta/recipes-devtools/qemu/qemu/mmap.patch | 2 +- meta/recipes-devtools/qemu/qemu/mmap2.patch | 26 ++++++++++++++++----- 2 files changed, 21 insertions(+), 7 deletions(-)meta/recipes-devtools/qemu/qemu/mmap.patch +1
-1@@ -9,7 +9,7 @@ avoid asserting binaries when reserved_va is set. This meant a test case now gives the same behaviour regardless of whether reserved_va is set or not. -Upstream-Status: Pending +Upstream-Status: Backport [https://github.com/qemu/qemu/commit/ccc5ccc17f8cfbfd87d9aede5d12a2d47c56e712] Signed-off-by: Richard Purdie <[email protected] Index: qemu-5.2.0/linux-user/mmap.cmeta/recipes-devtools/qemu/qemu/mmap2.patch +20
-7@@ -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 <[email protected] 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; } --2.27.0
Quoted 2 lines · Khem Raj
I am seeing musl builds are hung in qemu now, I suspect this change is causing it.
Are you using master or a master-next? I did revert this patch in one of the -nexts just to test the bug reproduced ok. I did test the revised patch with the change and things seemed ok.
Cheers,
Richard
I am always on master next and rebasing my branch onto it often sometimes multiple times a day I am trying latest master-next and let’s see what happens
Quoted 13 lines · Richard Purdie
Quoted 2 lines · Khem Raj
I am seeing musl builds are hung in qemu now, I suspect this change is causing it.
Are you using master or a master-next? I did revert this patch in one of the -nexts just to test the bug reproduced ok. I did test the revised patch with the change and things seemed ok.
Cheers,
Richard
Quoted 2 lines · Khem Raj
I am always on master next and rebasing my branch onto it often sometimes multiple times a day I am trying latest master-next and let’s see what happens
So was an effective revert of the qemu patch in there or not?
Perhaps test with the current master-next and see if that is ok?
Cheers,
Richard
yes I am testing latest master-next as of 30mins ago :) so lets see if this blocks the build too. it will take few hrs to reach there
Quoted 17 lines · Richard Purdie
Quoted 2 lines · Khem Raj
I am always on master next and rebasing my branch onto it often sometimes multiple times a day I am trying latest master-next and let’s see what happens
So was an effective revert of the qemu patch in there or not?
Perhaps test with the current master-next and see if that is ok?
Cheers,
Richard