summary refs log tree commit diff stats
path: root/results/classifier/105/other/1895080
diff options
context:
space:
mode:
Diffstat (limited to 'results/classifier/105/other/1895080')
-rw-r--r--results/classifier/105/other/18950801340
1 files changed, 1340 insertions, 0 deletions
diff --git a/results/classifier/105/other/1895080 b/results/classifier/105/other/1895080
new file mode 100644
index 000000000..101b5ac75
--- /dev/null
+++ b/results/classifier/105/other/1895080
@@ -0,0 +1,1340 @@
+other: 0.927
+instruction: 0.921
+device: 0.912
+socket: 0.911
+semantic: 0.906
+KVM: 0.899
+assembly: 0.898
+vnc: 0.897
+graphic: 0.897
+network: 0.882
+boot: 0.842
+mistranslation: 0.796
+
+pgb_reserved_va: Assertion `addr == test' failed
+
+This problem occurs on CentOS-7.5 (64-bit) with qemu-5.1.0, qemu head (commit 9435a8b3dd35f1f926f1b9127e8a906217a5518a) for riscv32-linux-user.
+
+Firstly, compile fails:
+Compiling C object libqemu-riscv32-linux-user.fa.p/linux-user_strace.c.o
+../qemu.git/linux-user/strace.c:1210:18: error: ‘FALLOC_FL_KEEP_SIZE’ undeclared here (not in a function)
+     FLAG_GENERIC(FALLOC_FL_KEEP_SIZE),
+
+I have to add below include to linux-user/strace.c
+diff --git a/linux-user/strace.c b/linux-user/strace.c
+index 11fea14fba..22e51d4a8a 100644
+--- a/linux-user/strace.c
++++ b/linux-user/strace.c
+@@ -7,6 +7,7 @@
+ #include <sys/mount.h>
+ #include <arpa/inet.h>
+ #include <netinet/tcp.h>
++#include <linux/falloc.h>
+ #include <linux/if_packet.h>
+ #include <linux/netlink.h>
+ #include <sched.h>
+
+Then trying qemu-riscv32 with a simple ELF, I get:
+linux-user/elfload.c:2341: pgb_reserved_va: Assertion `addr == test' failed.
+
+strace shows that:
+mmap(0x1000, 4294963200, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x10000
+write(2, "qemu-riscv32: ../qemu.git/linux-"..., 103qemu-riscv32: ../qemu.git/linux-user/elfload.c:2341: pgb_reserved_va: Assertion `addr == test' failed.
+) = 103
+
+The source code is in the function pgb_reserved_va (linux-user/elfload.c). I think mmap cannot guarantee that the returned pointer (test) equals to the parameter of addr. So is this a bug to assert (addr == test)?
+
+Attached configure script and test ELF file.
+
+Thanks.
+
+
+
+Le 10/09/2020 à 07:21, Launchpad Bug Tracker a écrit :
+> This problem occurs on CentOS-7.5 (64-bit) with qemu-5.1.0, qemu head
+> (commit 9435a8b3dd35f1f926f1b9127e8a906217a5518a) for riscv32-linux-
+> user.
+
+I tried to build qemu-5.1 on CentOS-7.5.1 but as python 3.5 is not
+available, I gave up.
+
+> Firstly, compile fails:
+> Compiling C object libqemu-riscv32-linux-user.fa.p/linux-user_strace.c.o
+> ../qemu.git/linux-user/strace.c:1210:18: error: ‘FALLOC_FL_KEEP_SIZE’ undeclared here (not in a function)
+>      FLAG_GENERIC(FALLOC_FL_KEEP_SIZE),
+> 
+> I have to add below include to linux-user/strace.c
+> diff --git a/linux-user/strace.c b/linux-user/strace.c
+> index 11fea14fba..22e51d4a8a 100644
+> --- a/linux-user/strace.c
+> +++ b/linux-user/strace.c
+> @@ -7,6 +7,7 @@
+>  #include <sys/mount.h>
+>  #include <arpa/inet.h>
+>  #include <netinet/tcp.h>
+> +#include <linux/falloc.h>
+>  #include <linux/if_packet.h>
+>  #include <linux/netlink.h>
+>  #include <sched.h>
+
+In fact, fallocate(2) says fcntl.h must be included.
+And qemu/osdep.h includes it.
+So you should not have this problem.
+
+> 
+> Then trying qemu-riscv32 with a simple ELF, I get:
+> linux-user/elfload.c:2341: pgb_reserved_va: Assertion `addr == test' failed.
+> 
+> strace shows that:
+> mmap(0x1000, 4294963200, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x10000
+> write(2, "qemu-riscv32: ../qemu.git/linux-"..., 103qemu-riscv32: ../qemu.git/linux-user/elfload.c:2341: pgb_reserved_va: Assertion `addr == test' failed.
+> ) = 103
+> 
+> The source code is in the function pgb_reserved_va (linux-
+> user/elfload.c). I think mmap cannot guarantee that the returned pointer
+> (test) equals to the parameter of addr. So is this a bug to assert (addr
+> == test)?
+
+I think Alex Bennée knows better this code than I do, so cc'ing him.
+
+Thnaks
+Laurent
+
+
+> This problem occurs on CentOS-7.5 (64-bit) with qemu-5.1.0, qemu head
+> > (commit 9435a8b3dd35f1f926f1b9127e8a906217a5518a) for riscv32-linux-
+> > user.
+>
+> I tried to build qemu-5.1 on CentOS-7.5.1 but as python 3.5 is not
+> available, I gave up.
+>
+
+Thank you for your effort. I installed python3 with yum:
+python3.x86_64                           3.6.8-10.el7              @centos
+Then maybe you can specify python3 in configure with
+"--python=/bin/python3" in case configure cannot find it.
+
+
+>
+> > Firstly, compile fails:
+> > Compiling C object libqemu-riscv32-linux-user.fa.p/linux-user_strace.c.o
+> > ../qemu.git/linux-user/strace.c:1210:18: error: ‘FALLOC_FL_KEEP_SIZE’
+> undeclared here (not in a function)
+> >      FLAG_GENERIC(FALLOC_FL_KEEP_SIZE),
+> >
+> > I have to add below include to linux-user/strace.c
+> > diff --git a/linux-user/strace.c b/linux-user/strace.c
+> > index 11fea14fba..22e51d4a8a 100644
+> > --- a/linux-user/strace.c
+> > +++ b/linux-user/strace.c
+> > @@ -7,6 +7,7 @@
+> >  #include <sys/mount.h>
+> >  #include <arpa/inet.h>
+> >  #include <netinet/tcp.h>
+> > +#include <linux/falloc.h>
+> >  #include <linux/if_packet.h>
+> >  #include <linux/netlink.h>
+> >  #include <sched.h>
+>
+> In fact, fallocate(2) says fcntl.h must be included.
+> And qemu/osdep.h includes it.
+> So you should not have this problem.
+>
+
+I tried to save the file after pre-processing, namely strace.i. Though
+_GNU_SOURCE is defined and fcntl.h is included, falloc.h is not included,
+in which FALLOC_FL_KEEP_SIZE is defined. I'm not sure if it's some
+environmental problem.
+
+Thanks.
+
+>
+> > Then trying qemu-riscv32 with a simple ELF, I get:
+> > linux-user/elfload.c:2341: pgb_reserved_va: Assertion `addr == test'
+> failed.
+> >
+> > strace shows that:
+> > mmap(0x1000, 4294963200, PROT_NONE,
+> MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x10000
+> > write(2, "qemu-riscv32: ../qemu.git/linux-"..., 103qemu-riscv32:
+> ../qemu.git/linux-user/elfload.c:2341: pgb_reserved_va: Assertion `addr ==
+> test' failed.
+> > ) = 103
+> >
+> > The source code is in the function pgb_reserved_va (linux-
+> > user/elfload.c). I think mmap cannot guarantee that the returned pointer
+> > (test) equals to the parameter of addr. So is this a bug to assert (addr
+> > == test)?
+>
+> I think Alex Bennée knows better this code than I do, so cc'ing him.
+>
+> Thnaks
+> Laurent
+>
+> --
+> You received this bug notification because you are subscribed to the bug
+> report.
+> https://bugs.launchpad.net/bugs/1895080
+>
+> Title:
+>   pgb_reserved_va: Assertion `addr == test' failed
+>
+> Status in QEMU:
+>   New
+>
+> Bug description:
+>   This problem occurs on CentOS-7.5 (64-bit) with qemu-5.1.0, qemu head
+>   (commit 9435a8b3dd35f1f926f1b9127e8a906217a5518a) for riscv32-linux-
+>   user.
+>
+>   Firstly, compile fails:
+>   Compiling C object libqemu-riscv32-linux-user.fa.p/linux-user_strace.c.o
+>   ../qemu.git/linux-user/strace.c:1210:18: error: ‘FALLOC_FL_KEEP_SIZE’
+> undeclared here (not in a function)
+>        FLAG_GENERIC(FALLOC_FL_KEEP_SIZE),
+>
+>   I have to add below include to linux-user/strace.c
+>   diff --git a/linux-user/strace.c b/linux-user/strace.c
+>   index 11fea14fba..22e51d4a8a 100644
+>   --- a/linux-user/strace.c
+>   +++ b/linux-user/strace.c
+>   @@ -7,6 +7,7 @@
+>    #include <sys/mount.h>
+>    #include <arpa/inet.h>
+>    #include <netinet/tcp.h>
+>   +#include <linux/falloc.h>
+>    #include <linux/if_packet.h>
+>    #include <linux/netlink.h>
+>    #include <sched.h>
+>
+>   Then trying qemu-riscv32 with a simple ELF, I get:
+>   linux-user/elfload.c:2341: pgb_reserved_va: Assertion `addr == test'
+> failed.
+>
+>   strace shows that:
+>   mmap(0x1000, 4294963200, PROT_NONE,
+> MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x10000
+>   write(2, "qemu-riscv32: ../qemu.git/linux-"..., 103qemu-riscv32:
+> ../qemu.git/linux-user/elfload.c:2341: pgb_reserved_va: Assertion `addr ==
+> test' failed.
+>   ) = 103
+>
+>   The source code is in the function pgb_reserved_va (linux-
+>   user/elfload.c). I think mmap cannot guarantee that the returned
+>   pointer (test) equals to the parameter of addr. So is this a bug to
+>   assert (addr == test)?
+>
+>   Attached configure script and test ELF file.
+>
+>   Thanks.
+>
+> To manage notifications about this bug go to:
+> https://bugs.launchpad.net/qemu/+bug/1895080/+subscriptions
+>
+
+
+Have you got a static version of the test binary (or a mini rootfs with the libraries it needs)?
+
+Have you got a static version of the test binary (or a mini rootfs with
+> the libraries it needs)?
+>
+
+If the problem occurs, it does not reach the stage of the dependent
+libraries  of the test ELF. Anyway, I've attached the static test binary as
+hello.static.elf.
+Thanks
+
+
+> --
+> You received this bug notification because you are subscribed to the bug
+> report.
+> https://bugs.launchpad.net/bugs/1895080
+>
+> Title:
+>   pgb_reserved_va: Assertion `addr == test' failed
+>
+> Status in QEMU:
+>   New
+>
+> Bug description:
+>   This problem occurs on CentOS-7.5 (64-bit) with qemu-5.1.0, qemu head
+>   (commit 9435a8b3dd35f1f926f1b9127e8a906217a5518a) for riscv32-linux-
+>   user.
+>
+>   Firstly, compile fails:
+>   Compiling C object libqemu-riscv32-linux-user.fa.p/linux-user_strace.c.o
+>   ../qemu.git/linux-user/strace.c:1210:18: error: ‘FALLOC_FL_KEEP_SIZE’
+> undeclared here (not in a function)
+>        FLAG_GENERIC(FALLOC_FL_KEEP_SIZE),
+>
+>   I have to add below include to linux-user/strace.c
+>   diff --git a/linux-user/strace.c b/linux-user/strace.c
+>   index 11fea14fba..22e51d4a8a 100644
+>   --- a/linux-user/strace.c
+>   +++ b/linux-user/strace.c
+>   @@ -7,6 +7,7 @@
+>    #include <sys/mount.h>
+>    #include <arpa/inet.h>
+>    #include <netinet/tcp.h>
+>   +#include <linux/falloc.h>
+>    #include <linux/if_packet.h>
+>    #include <linux/netlink.h>
+>    #include <sched.h>
+>
+>   Then trying qemu-riscv32 with a simple ELF, I get:
+>   linux-user/elfload.c:2341: pgb_reserved_va: Assertion `addr == test'
+> failed.
+>
+>   strace shows that:
+>   mmap(0x1000, 4294963200, PROT_NONE,
+> MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x10000
+>   write(2, "qemu-riscv32: ../qemu.git/linux-"..., 103qemu-riscv32:
+> ../qemu.git/linux-user/elfload.c:2341: pgb_reserved_va: Assertion `addr ==
+> test' failed.
+>   ) = 103
+>
+>   The source code is in the function pgb_reserved_va (linux-
+>   user/elfload.c). I think mmap cannot guarantee that the returned
+>   pointer (test) equals to the parameter of addr. So is this a bug to
+>   assert (addr == test)?
+>
+>   Attached configure script and test ELF file.
+>
+>   Thanks.
+>
+> To manage notifications about this bug go to:
+> https://bugs.launchpad.net/qemu/+bug/1895080/+subscriptions
+>
+
+
+
+Laurent Vivier <email address hidden> writes:
+
+> Le 10/09/2020 à 07:21, Launchpad Bug Tracker a écrit :
+>> This problem occurs on CentOS-7.5 (64-bit) with qemu-5.1.0, qemu head
+>> (commit 9435a8b3dd35f1f926f1b9127e8a906217a5518a) for riscv32-linux-
+>> user.
+>
+> I tried to build qemu-5.1 on CentOS-7.5.1 but as python 3.5 is not
+> available, I gave up.
+>
+>> Firstly, compile fails:
+>> Compiling C object libqemu-riscv32-linux-user.fa.p/linux-user_strace.c.o
+>> ../qemu.git/linux-user/strace.c:1210:18: error: ‘FALLOC_FL_KEEP_SIZE’ undeclared here (not in a function)
+>>      FLAG_GENERIC(FALLOC_FL_KEEP_SIZE),
+>> 
+>> I have to add below include to linux-user/strace.c
+>> diff --git a/linux-user/strace.c b/linux-user/strace.c
+>> index 11fea14fba..22e51d4a8a 100644
+>> --- a/linux-user/strace.c
+>> +++ b/linux-user/strace.c
+>> @@ -7,6 +7,7 @@
+>>  #include <sys/mount.h>
+>>  #include <arpa/inet.h>
+>>  #include <netinet/tcp.h>
+>> +#include <linux/falloc.h>
+>>  #include <linux/if_packet.h>
+>>  #include <linux/netlink.h>
+>>  #include <sched.h>
+>
+> In fact, fallocate(2) says fcntl.h must be included.
+> And qemu/osdep.h includes it.
+> So you should not have this problem.
+>
+>> 
+>> Then trying qemu-riscv32 with a simple ELF, I get:
+>> linux-user/elfload.c:2341: pgb_reserved_va: Assertion `addr == test' failed.
+>> 
+>> strace shows that:
+>> mmap(0x1000, 4294963200, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x10000
+>> write(2, "qemu-riscv32: ../qemu.git/linux-"..., 103qemu-riscv32: ../qemu.git/linux-user/elfload.c:2341: pgb_reserved_va: Assertion `addr == test' failed.
+>> ) = 103
+>> 
+>> The source code is in the function pgb_reserved_va (linux-
+>> user/elfload.c). I think mmap cannot guarantee that the returned pointer
+>> (test) equals to the parameter of addr. So is this a bug to assert (addr
+>> == test)?
+>
+> I think Alex Bennée knows better this code than I do, so cc'ing him.
+
+It should be able to do so because the earlier code (pgb_static) checks
+for a hole the size of reserved_va in the host memory map. This should
+be fairly easy for 32 bit guests given the amount of spare address space
+you have on a 64 bit system.
+
+I'm assuming CentOS 7.5 actually has a definition for
+MAP_FIXED_NOREPLACE which should ensure we get what we asked for -
+otherwise we are in the position of hoping the kernel honours what we
+asked for.
+
+>
+> Thnaks
+> Laurent
+
+
+-- 
+Alex Bennée
+
+
+
+Alex Bennée <email address hidden> writes:
+
+> Laurent Vivier <email address hidden> writes:
+>
+<snip>
+>>> Then trying qemu-riscv32 with a simple ELF, I get:
+>>> linux-user/elfload.c:2341: pgb_reserved_va: Assertion `addr == test' failed.
+>>> 
+>>> strace shows that:
+>>> mmap(0x1000, 4294963200, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x10000
+>>> write(2, "qemu-riscv32: ../qemu.git/linux-"..., 103qemu-riscv32: ../qemu.git/linux-user/elfload.c:2341: pgb_reserved_va: Assertion `addr == test' failed.
+>>> ) = 103
+>>> 
+>>> The source code is in the function pgb_reserved_va (linux-
+>>> user/elfload.c). I think mmap cannot guarantee that the returned pointer
+>>> (test) equals to the parameter of addr. So is this a bug to assert (addr
+>>> == test)?
+>>
+> I'm assuming CentOS 7.5 actually has a definition for
+> MAP_FIXED_NOREPLACE which should ensure we get what we asked for -
+> otherwise we are in the position of hoping the kernel honours what we
+> asked for.
+
+Doh re-reading I see it's not set in the strace output. Maybe we should
+promote the assert case to the failure leg so we have:
+
+    if (addr == MAP_FAILED || addr != test) {
+        error_report(...)
+    }
+
+so we at least fail with a user friendly error rather than an abort?
+
+-- 
+Alex Bennée
+
+
+No, it's not set by CentOS-7.5.
+Does it mean that we just cannot run the ELF in such a case? I've tried
+many times, the assert always fails. Maybe, we can blame CentOS-7.5.
+BTW: with the option "-p 65536", the case runs successfully.
+
+On Fri, Sep 11, 2020 at 5:50 PM Alex Bennée <email address hidden>
+wrote:
+
+> Alex Bennée <email address hidden> writes:
+>
+> > Laurent Vivier <email address hidden> writes:
+> >
+> <snip>
+> >>> Then trying qemu-riscv32 with a simple ELF, I get:
+> >>> linux-user/elfload.c:2341: pgb_reserved_va: Assertion `addr == test'
+> failed.
+> >>>
+> >>> strace shows that:
+> >>> mmap(0x1000, 4294963200, PROT_NONE,
+> MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x10000
+> >>> write(2, "qemu-riscv32: ../qemu.git/linux-"..., 103qemu-riscv32:
+> ../qemu.git/linux-user/elfload.c:2341: pgb_reserved_va: Assertion `addr ==
+> test' failed.
+> >>> ) = 103
+> >>>
+> >>> The source code is in the function pgb_reserved_va (linux-
+> >>> user/elfload.c). I think mmap cannot guarantee that the returned
+> pointer
+> >>> (test) equals to the parameter of addr. So is this a bug to assert
+> (addr
+> >>> == test)?
+> >>
+> > I'm assuming CentOS 7.5 actually has a definition for
+> > MAP_FIXED_NOREPLACE which should ensure we get what we asked for -
+> > otherwise we are in the position of hoping the kernel honours what we
+> > asked for.
+>
+> Doh re-reading I see it's not set in the strace output. Maybe we should
+> promote the assert case to the failure leg so we have:
+>
+>     if (addr == MAP_FAILED || addr != test) {
+>         error_report(...)
+>     }
+>
+> so we at least fail with a user friendly error rather than an abort?
+>
+> --
+> Alex Bennée
+>
+> --
+> You received this bug notification because you are subscribed to the bug
+> report.
+> https://bugs.launchpad.net/bugs/1895080
+>
+> Title:
+>   pgb_reserved_va: Assertion `addr == test' failed
+>
+> Status in QEMU:
+>   New
+>
+> Bug description:
+>   This problem occurs on CentOS-7.5 (64-bit) with qemu-5.1.0, qemu head
+>   (commit 9435a8b3dd35f1f926f1b9127e8a906217a5518a) for riscv32-linux-
+>   user.
+>
+>   Firstly, compile fails:
+>   Compiling C object libqemu-riscv32-linux-user.fa.p/linux-user_strace.c.o
+>   ../qemu.git/linux-user/strace.c:1210:18: error: ‘FALLOC_FL_KEEP_SIZE’
+> undeclared here (not in a function)
+>        FLAG_GENERIC(FALLOC_FL_KEEP_SIZE),
+>
+>   I have to add below include to linux-user/strace.c
+>   diff --git a/linux-user/strace.c b/linux-user/strace.c
+>   index 11fea14fba..22e51d4a8a 100644
+>   --- a/linux-user/strace.c
+>   +++ b/linux-user/strace.c
+>   @@ -7,6 +7,7 @@
+>    #include <sys/mount.h>
+>    #include <arpa/inet.h>
+>    #include <netinet/tcp.h>
+>   +#include <linux/falloc.h>
+>    #include <linux/if_packet.h>
+>    #include <linux/netlink.h>
+>    #include <sched.h>
+>
+>   Then trying qemu-riscv32 with a simple ELF, I get:
+>   linux-user/elfload.c:2341: pgb_reserved_va: Assertion `addr == test'
+> failed.
+>
+>   strace shows that:
+>   mmap(0x1000, 4294963200, PROT_NONE,
+> MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x10000
+>   write(2, "qemu-riscv32: ../qemu.git/linux-"..., 103qemu-riscv32:
+> ../qemu.git/linux-user/elfload.c:2341: pgb_reserved_va: Assertion `addr ==
+> test' failed.
+>   ) = 103
+>
+>   The source code is in the function pgb_reserved_va (linux-
+>   user/elfload.c). I think mmap cannot guarantee that the returned
+>   pointer (test) equals to the parameter of addr. So is this a bug to
+>   assert (addr == test)?
+>
+>   Attached configure script and test ELF file.
+>
+>   Thanks.
+>
+> To manage notifications about this bug go to:
+> https://bugs.launchpad.net/qemu/+bug/1895080/+subscriptions
+>
+
+
+
+Hansni Bu <email address hidden> writes:
+
+> No, it's not set by CentOS-7.5.
+> Does it mean that we just cannot run the ELF in such a case? I've tried
+> many times, the assert always fails. Maybe, we can blame CentOS-7.5.
+
+The trouble is without MAP_FIXED_NOREPLACE we are at the mercy of the
+host kernel to allow the address request to be honoured. A plain
+MAP_FIXED won't do as it can clober existing mappings. In theory a
+suitable hole has been identified but sometimes the kernel makes a
+decision to offset the suggested mapping for it's own reasons. 
+
+> BTW: with the option "-p 65536", the case runs successfully.
+
+Hmm interesting. I wonder if we are seeing a fail due to mmap_min_addr?
+What does:
+
+  /proc/sys/vm/mmap_min_addr
+
+give you on the system?
+
+You can manually set the reserved_va and the base address using -R and
+-B although that is more of a developer work around. I think moving the
+assert to the condition above would be an improvement just because it
+tells us what the requested base address was and what the kernel decided
+to give us.
+
+>
+> On Fri, Sep 11, 2020 at 5:50 PM Alex Bennée <email address hidden>
+> wrote:
+>
+>> Alex Bennée <email address hidden> writes:
+>>
+>> > Laurent Vivier <email address hidden> writes:
+>> >
+>> <snip>
+>> >>> Then trying qemu-riscv32 with a simple ELF, I get:
+>> >>> linux-user/elfload.c:2341: pgb_reserved_va: Assertion `addr == test'
+>> failed.
+>> >>>
+>> >>> strace shows that:
+>> >>> mmap(0x1000, 4294963200, PROT_NONE,
+>> MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x10000
+>> >>> write(2, "qemu-riscv32: ../qemu.git/linux-"..., 103qemu-riscv32:
+>> ../qemu.git/linux-user/elfload.c:2341: pgb_reserved_va: Assertion `addr ==
+>> test' failed.
+>> >>> ) = 103
+>> >>>
+>> >>> The source code is in the function pgb_reserved_va (linux-
+>> >>> user/elfload.c). I think mmap cannot guarantee that the returned
+>> pointer
+>> >>> (test) equals to the parameter of addr. So is this a bug to assert
+>> (addr
+>> >>> == test)?
+>> >>
+>> > I'm assuming CentOS 7.5 actually has a definition for
+>> > MAP_FIXED_NOREPLACE which should ensure we get what we asked for -
+>> > otherwise we are in the position of hoping the kernel honours what we
+>> > asked for.
+>>
+>> Doh re-reading I see it's not set in the strace output. Maybe we should
+>> promote the assert case to the failure leg so we have:
+>>
+>>     if (addr == MAP_FAILED || addr != test) {
+>>         error_report(...)
+>>     }
+>>
+>> so we at least fail with a user friendly error rather than an abort?
+>>
+>> --
+>> Alex Bennée
+>>
+>> --
+>> You received this bug notification because you are subscribed to the bug
+>> report.
+>> https://bugs.launchpad.net/bugs/1895080
+>>
+>> Title:
+>>   pgb_reserved_va: Assertion `addr == test' failed
+>>
+>> Status in QEMU:
+>>   New
+>>
+>> Bug description:
+>>   This problem occurs on CentOS-7.5 (64-bit) with qemu-5.1.0, qemu head
+>>   (commit 9435a8b3dd35f1f926f1b9127e8a906217a5518a) for riscv32-linux-
+>>   user.
+>>
+>>   Firstly, compile fails:
+>>   Compiling C object libqemu-riscv32-linux-user.fa.p/linux-user_strace.c.o
+>>   ../qemu.git/linux-user/strace.c:1210:18: error: ‘FALLOC_FL_KEEP_SIZE’
+>> undeclared here (not in a function)
+>>        FLAG_GENERIC(FALLOC_FL_KEEP_SIZE),
+>>
+>>   I have to add below include to linux-user/strace.c
+>>   diff --git a/linux-user/strace.c b/linux-user/strace.c
+>>   index 11fea14fba..22e51d4a8a 100644
+>>   --- a/linux-user/strace.c
+>>   +++ b/linux-user/strace.c
+>>   @@ -7,6 +7,7 @@
+>>    #include <sys/mount.h>
+>>    #include <arpa/inet.h>
+>>    #include <netinet/tcp.h>
+>>   +#include <linux/falloc.h>
+>>    #include <linux/if_packet.h>
+>>    #include <linux/netlink.h>
+>>    #include <sched.h>
+>>
+>>   Then trying qemu-riscv32 with a simple ELF, I get:
+>>   linux-user/elfload.c:2341: pgb_reserved_va: Assertion `addr == test'
+>> failed.
+>>
+>>   strace shows that:
+>>   mmap(0x1000, 4294963200, PROT_NONE,
+>> MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x10000
+>>   write(2, "qemu-riscv32: ../qemu.git/linux-"..., 103qemu-riscv32:
+>> ../qemu.git/linux-user/elfload.c:2341: pgb_reserved_va: Assertion `addr ==
+>> test' failed.
+>>   ) = 103
+>>
+>>   The source code is in the function pgb_reserved_va (linux-
+>>   user/elfload.c). I think mmap cannot guarantee that the returned
+>>   pointer (test) equals to the parameter of addr. So is this a bug to
+>>   assert (addr == test)?
+>>
+>>   Attached configure script and test ELF file.
+>>
+>>   Thanks.
+>>
+>> To manage notifications about this bug go to:
+>> https://bugs.launchpad.net/qemu/+bug/1895080/+subscriptions
+>>
+
+
+-- 
+Alex Bennée
+
+
+> > No, it's not set by CentOS-7.5.
+> > Does it mean that we just cannot run the ELF in such a case? I've tried
+> > many times, the assert always fails. Maybe, we can blame CentOS-7.5.
+>
+> The trouble is without MAP_FIXED_NOREPLACE we are at the mercy of the
+> host kernel to allow the address request to be honoured. A plain
+> MAP_FIXED won't do as it can clober existing mappings. In theory a
+> suitable hole has been identified but sometimes the kernel makes a
+> decision to offset the suggested mapping for it's own reasons.
+>
+
+MAP_FIXED_NOREPLACE is quite a new feature.
+
+
+> > BTW: with the option "-p 65536", the case runs successfully.
+>
+> Hmm interesting. I wonder if we are seeing a fail due to mmap_min_addr?
+> What does:
+>
+>   /proc/sys/vm/mmap_min_addr
+>
+> give you on the system?
+>
+
+It gives me 4096. And guest_base has this value. Maybe that's the strange
+point. mmap_min_addr give us 0x1000. While we are requesting this address,
+the kernel gives us 0x10000.
+
+
+>
+> You can manually set the reserved_va and the base address using -R and
+> -B although that is more of a developer work around. I think moving the
+> assert to the condition above would be an improvement just because it
+> tells us what the requested base address was and what the kernel decided
+> to give us.
+>
+
+Setting guest_base with -B to 0x10000 works. Tried some -R values, no luck.
+Agree to print a more hintful message.
+
+
+>
+> >
+> > On Fri, Sep 11, 2020 at 5:50 PM Alex Bennée <email address hidden>
+> > wrote:
+> >
+> >> Alex Bennée <email address hidden> writes:
+> >>
+> >> > Laurent Vivier <email address hidden> writes:
+> >> >
+> >> <snip>
+> >> >>> Then trying qemu-riscv32 with a simple ELF, I get:
+> >> >>> linux-user/elfload.c:2341: pgb_reserved_va: Assertion `addr == test'
+> >> failed.
+> >> >>>
+> >> >>> strace shows that:
+> >> >>> mmap(0x1000, 4294963200, PROT_NONE,
+> >> MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x10000
+> >> >>> write(2, "qemu-riscv32: ../qemu.git/linux-"..., 103qemu-riscv32:
+> >> ../qemu.git/linux-user/elfload.c:2341: pgb_reserved_va: Assertion `addr
+> ==
+> >> test' failed.
+> >> >>> ) = 103
+> >> >>>
+> >> >>> The source code is in the function pgb_reserved_va (linux-
+> >> >>> user/elfload.c). I think mmap cannot guarantee that the returned
+> >> pointer
+> >> >>> (test) equals to the parameter of addr. So is this a bug to assert
+> >> (addr
+> >> >>> == test)?
+> >> >>
+> >> > I'm assuming CentOS 7.5 actually has a definition for
+> >> > MAP_FIXED_NOREPLACE which should ensure we get what we asked for -
+> >> > otherwise we are in the position of hoping the kernel honours what we
+> >> > asked for.
+> >>
+> >> Doh re-reading I see it's not set in the strace output. Maybe we should
+> >> promote the assert case to the failure leg so we have:
+> >>
+> >>     if (addr == MAP_FAILED || addr != test) {
+> >>         error_report(...)
+> >>     }
+> >>
+> >> so we at least fail with a user friendly error rather than an abort?
+> >>
+> >> --
+> >> Alex Bennée
+> >>
+> >> --
+> >> You received this bug notification because you are subscribed to the bug
+> >> report.
+> >> https://bugs.launchpad.net/bugs/1895080
+> >>
+> >> Title:
+> >>   pgb_reserved_va: Assertion `addr == test' failed
+> >>
+> >> Status in QEMU:
+> >>   New
+> >>
+> >> Bug description:
+> >>   This problem occurs on CentOS-7.5 (64-bit) with qemu-5.1.0, qemu head
+> >>   (commit 9435a8b3dd35f1f926f1b9127e8a906217a5518a) for riscv32-linux-
+> >>   user.
+> >>
+> >>   Firstly, compile fails:
+> >>   Compiling C object
+> libqemu-riscv32-linux-user.fa.p/linux-user_strace.c.o
+> >>   ../qemu.git/linux-user/strace.c:1210:18: error: ‘FALLOC_FL_KEEP_SIZE’
+> >> undeclared here (not in a function)
+> >>        FLAG_GENERIC(FALLOC_FL_KEEP_SIZE),
+> >>
+> >>   I have to add below include to linux-user/strace.c
+> >>   diff --git a/linux-user/strace.c b/linux-user/strace.c
+> >>   index 11fea14fba..22e51d4a8a 100644
+> >>   --- a/linux-user/strace.c
+> >>   +++ b/linux-user/strace.c
+> >>   @@ -7,6 +7,7 @@
+> >>    #include <sys/mount.h>
+> >>    #include <arpa/inet.h>
+> >>    #include <netinet/tcp.h>
+> >>   +#include <linux/falloc.h>
+> >>    #include <linux/if_packet.h>
+> >>    #include <linux/netlink.h>
+> >>    #include <sched.h>
+> >>
+> >>   Then trying qemu-riscv32 with a simple ELF, I get:
+> >>   linux-user/elfload.c:2341: pgb_reserved_va: Assertion `addr == test'
+> >> failed.
+> >>
+> >>   strace shows that:
+> >>   mmap(0x1000, 4294963200, PROT_NONE,
+> >> MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x10000
+> >>   write(2, "qemu-riscv32: ../qemu.git/linux-"..., 103qemu-riscv32:
+> >> ../qemu.git/linux-user/elfload.c:2341: pgb_reserved_va: Assertion `addr
+> ==
+> >> test' failed.
+> >>   ) = 103
+> >>
+> >>   The source code is in the function pgb_reserved_va (linux-
+> >>   user/elfload.c). I think mmap cannot guarantee that the returned
+> >>   pointer (test) equals to the parameter of addr. So is this a bug to
+> >>   assert (addr == test)?
+> >>
+> >>   Attached configure script and test ELF file.
+> >>
+> >>   Thanks.
+> >>
+> >> To manage notifications about this bug go to:
+> >> https://bugs.launchpad.net/qemu/+bug/1895080/+subscriptions
+> >>
+>
+>
+> --
+> Alex Bennée
+>
+> --
+> You received this bug notification because you are subscribed to the bug
+> report.
+> https://bugs.launchpad.net/bugs/1895080
+>
+> Title:
+>   pgb_reserved_va: Assertion `addr == test' failed
+>
+> Status in QEMU:
+>   New
+>
+> Bug description:
+>   This problem occurs on CentOS-7.5 (64-bit) with qemu-5.1.0, qemu head
+>   (commit 9435a8b3dd35f1f926f1b9127e8a906217a5518a) for riscv32-linux-
+>   user.
+>
+>   Firstly, compile fails:
+>   Compiling C object libqemu-riscv32-linux-user.fa.p/linux-user_strace.c.o
+>   ../qemu.git/linux-user/strace.c:1210:18: error: ‘FALLOC_FL_KEEP_SIZE’
+> undeclared here (not in a function)
+>        FLAG_GENERIC(FALLOC_FL_KEEP_SIZE),
+>
+>   I have to add below include to linux-user/strace.c
+>   diff --git a/linux-user/strace.c b/linux-user/strace.c
+>   index 11fea14fba..22e51d4a8a 100644
+>   --- a/linux-user/strace.c
+>   +++ b/linux-user/strace.c
+>   @@ -7,6 +7,7 @@
+>    #include <sys/mount.h>
+>    #include <arpa/inet.h>
+>    #include <netinet/tcp.h>
+>   +#include <linux/falloc.h>
+>    #include <linux/if_packet.h>
+>    #include <linux/netlink.h>
+>    #include <sched.h>
+>
+>   Then trying qemu-riscv32 with a simple ELF, I get:
+>   linux-user/elfload.c:2341: pgb_reserved_va: Assertion `addr == test'
+> failed.
+>
+>   strace shows that:
+>   mmap(0x1000, 4294963200, PROT_NONE,
+> MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x10000
+>   write(2, "qemu-riscv32: ../qemu.git/linux-"..., 103qemu-riscv32:
+> ../qemu.git/linux-user/elfload.c:2341: pgb_reserved_va: Assertion `addr ==
+> test' failed.
+>   ) = 103
+>
+>   The source code is in the function pgb_reserved_va (linux-
+>   user/elfload.c). I think mmap cannot guarantee that the returned
+>   pointer (test) equals to the parameter of addr. So is this a bug to
+>   assert (addr == test)?
+>
+>   Attached configure script and test ELF file.
+>
+>   Thanks.
+>
+> To manage notifications about this bug go to:
+> https://bugs.launchpad.net/qemu/+bug/1895080/+subscriptions
+>
+
+
+
+Hansni Bu <email address hidden> writes:
+
+>> > No, it's not set by CentOS-7.5.
+>> > Does it mean that we just cannot run the ELF in such a case? I've tried
+>> > many times, the assert always fails. Maybe, we can blame CentOS-7.5.
+>>
+>> The trouble is without MAP_FIXED_NOREPLACE we are at the mercy of the
+>> host kernel to allow the address request to be honoured. A plain
+>> MAP_FIXED won't do as it can clober existing mappings. In theory a
+>> suitable hole has been identified but sometimes the kernel makes a
+>> decision to offset the suggested mapping for it's own reasons.
+>>
+>
+> MAP_FIXED_NOREPLACE is quite a new feature.
+>
+>
+>> > BTW: with the option "-p 65536", the case runs successfully.
+>>
+>> Hmm interesting. I wonder if we are seeing a fail due to mmap_min_addr?
+>> What does:
+>>
+>>   /proc/sys/vm/mmap_min_addr
+>>
+>> give you on the system?
+>>
+>
+> It gives me 4096. And guest_base has this value. Maybe that's the strange
+> point. mmap_min_addr give us 0x1000. While we are requesting this address,
+> the kernel gives us 0x10000.
+
+Yeah the meaning of mmap_min_addr should be exactly that which is odd
+why the kernel doesn't honour the request. That said it seems to be a
+user tweakable knob so you could just up it.
+
+>>
+>> You can manually set the reserved_va and the base address using -R and
+>> -B although that is more of a developer work around. I think moving the
+>> assert to the condition above would be an improvement just because it
+>> tells us what the requested base address was and what the kernel decided
+>> to give us.
+>>
+>
+> Setting guest_base with -B to 0x10000 works. Tried some -R values, no luck.
+> Agree to print a more hintful message.
+
+OK - one other test you try is running inside a chroot which *does not*
+have visibility of /proc. That will cause it to fall back to the old
+probing technique of trying multiple mmap operations to find the hole. I
+suspect that works because the attempt to map 0x1000 would fail the
+check. The reason we default to probing /proc/self/map now is that brute
+force technique falls over when trying to probe for a hole on 64 bit
+systems, especially when built with stack protection/clang debug
+instrumentation.
+
+In the meantime I'll spin up a patch to improve the failure mode.
+
+>
+>
+>>
+>> >
+>> > On Fri, Sep 11, 2020 at 5:50 PM Alex Bennée <email address hidden>
+>> > wrote:
+>> >
+>> >> Alex Bennée <email address hidden> writes:
+>> >>
+>> >> > Laurent Vivier <email address hidden> writes:
+>> >> >
+>> >> <snip>
+>> >> >>> Then trying qemu-riscv32 with a simple ELF, I get:
+>> >> >>> linux-user/elfload.c:2341: pgb_reserved_va: Assertion `addr == test'
+>> >> failed.
+>> >> >>>
+>> >> >>> strace shows that:
+>> >> >>> mmap(0x1000, 4294963200, PROT_NONE,
+>> >> MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x10000
+>> >> >>> write(2, "qemu-riscv32: ../qemu.git/linux-"..., 103qemu-riscv32:
+>> >> ../qemu.git/linux-user/elfload.c:2341: pgb_reserved_va: Assertion `addr
+>> ==
+>> >> test' failed.
+>> >> >>> ) = 103
+>> >> >>>
+>> >> >>> The source code is in the function pgb_reserved_va (linux-
+>> >> >>> user/elfload.c). I think mmap cannot guarantee that the returned
+>> >> pointer
+>> >> >>> (test) equals to the parameter of addr. So is this a bug to assert
+>> >> (addr
+>> >> >>> == test)?
+>> >> >>
+>> >> > I'm assuming CentOS 7.5 actually has a definition for
+>> >> > MAP_FIXED_NOREPLACE which should ensure we get what we asked for -
+>> >> > otherwise we are in the position of hoping the kernel honours what we
+>> >> > asked for.
+>> >>
+>> >> Doh re-reading I see it's not set in the strace output. Maybe we should
+>> >> promote the assert case to the failure leg so we have:
+>> >>
+>> >>     if (addr == MAP_FAILED || addr != test) {
+>> >>         error_report(...)
+>> >>     }
+>> >>
+>> >> so we at least fail with a user friendly error rather than an abort?
+>> >>
+>> >> --
+>> >> Alex Bennée
+>> >>
+>> >> --
+>> >> You received this bug notification because you are subscribed to the bug
+>> >> report.
+>> >> https://bugs.launchpad.net/bugs/1895080
+>> >>
+>> >> Title:
+>> >>   pgb_reserved_va: Assertion `addr == test' failed
+>> >>
+>> >> Status in QEMU:
+>> >>   New
+>> >>
+>> >> Bug description:
+>> >>   This problem occurs on CentOS-7.5 (64-bit) with qemu-5.1.0, qemu head
+>> >>   (commit 9435a8b3dd35f1f926f1b9127e8a906217a5518a) for riscv32-linux-
+>> >>   user.
+>> >>
+>> >>   Firstly, compile fails:
+>> >>   Compiling C object
+>> libqemu-riscv32-linux-user.fa.p/linux-user_strace.c.o
+>> >>   ../qemu.git/linux-user/strace.c:1210:18: error: ‘FALLOC_FL_KEEP_SIZE’
+>> >> undeclared here (not in a function)
+>> >>        FLAG_GENERIC(FALLOC_FL_KEEP_SIZE),
+>> >>
+>> >>   I have to add below include to linux-user/strace.c
+>> >>   diff --git a/linux-user/strace.c b/linux-user/strace.c
+>> >>   index 11fea14fba..22e51d4a8a 100644
+>> >>   --- a/linux-user/strace.c
+>> >>   +++ b/linux-user/strace.c
+>> >>   @@ -7,6 +7,7 @@
+>> >>    #include <sys/mount.h>
+>> >>    #include <arpa/inet.h>
+>> >>    #include <netinet/tcp.h>
+>> >>   +#include <linux/falloc.h>
+>> >>    #include <linux/if_packet.h>
+>> >>    #include <linux/netlink.h>
+>> >>    #include <sched.h>
+>> >>
+>> >>   Then trying qemu-riscv32 with a simple ELF, I get:
+>> >>   linux-user/elfload.c:2341: pgb_reserved_va: Assertion `addr == test'
+>> >> failed.
+>> >>
+>> >>   strace shows that:
+>> >>   mmap(0x1000, 4294963200, PROT_NONE,
+>> >> MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x10000
+>> >>   write(2, "qemu-riscv32: ../qemu.git/linux-"..., 103qemu-riscv32:
+>> >> ../qemu.git/linux-user/elfload.c:2341: pgb_reserved_va: Assertion `addr
+>> ==
+>> >> test' failed.
+>> >>   ) = 103
+>> >>
+>> >>   The source code is in the function pgb_reserved_va (linux-
+>> >>   user/elfload.c). I think mmap cannot guarantee that the returned
+>> >>   pointer (test) equals to the parameter of addr. So is this a bug to
+>> >>   assert (addr == test)?
+>> >>
+>> >>   Attached configure script and test ELF file.
+>> >>
+>> >>   Thanks.
+>> >>
+>> >> To manage notifications about this bug go to:
+>> >> https://bugs.launchpad.net/qemu/+bug/1895080/+subscriptions
+>> >>
+>>
+>>
+>> --
+>> Alex Bennée
+>>
+>> --
+>> You received this bug notification because you are subscribed to the bug
+>> report.
+>> https://bugs.launchpad.net/bugs/1895080
+>>
+>> Title:
+>>   pgb_reserved_va: Assertion `addr == test' failed
+>>
+>> Status in QEMU:
+>>   New
+>>
+>> Bug description:
+>>   This problem occurs on CentOS-7.5 (64-bit) with qemu-5.1.0, qemu head
+>>   (commit 9435a8b3dd35f1f926f1b9127e8a906217a5518a) for riscv32-linux-
+>>   user.
+>>
+>>   Firstly, compile fails:
+>>   Compiling C object libqemu-riscv32-linux-user.fa.p/linux-user_strace.c.o
+>>   ../qemu.git/linux-user/strace.c:1210:18: error: ‘FALLOC_FL_KEEP_SIZE’
+>> undeclared here (not in a function)
+>>        FLAG_GENERIC(FALLOC_FL_KEEP_SIZE),
+>>
+>>   I have to add below include to linux-user/strace.c
+>>   diff --git a/linux-user/strace.c b/linux-user/strace.c
+>>   index 11fea14fba..22e51d4a8a 100644
+>>   --- a/linux-user/strace.c
+>>   +++ b/linux-user/strace.c
+>>   @@ -7,6 +7,7 @@
+>>    #include <sys/mount.h>
+>>    #include <arpa/inet.h>
+>>    #include <netinet/tcp.h>
+>>   +#include <linux/falloc.h>
+>>    #include <linux/if_packet.h>
+>>    #include <linux/netlink.h>
+>>    #include <sched.h>
+>>
+>>   Then trying qemu-riscv32 with a simple ELF, I get:
+>>   linux-user/elfload.c:2341: pgb_reserved_va: Assertion `addr == test'
+>> failed.
+>>
+>>   strace shows that:
+>>   mmap(0x1000, 4294963200, PROT_NONE,
+>> MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x10000
+>>   write(2, "qemu-riscv32: ../qemu.git/linux-"..., 103qemu-riscv32:
+>> ../qemu.git/linux-user/elfload.c:2341: pgb_reserved_va: Assertion `addr ==
+>> test' failed.
+>>   ) = 103
+>>
+>>   The source code is in the function pgb_reserved_va (linux-
+>>   user/elfload.c). I think mmap cannot guarantee that the returned
+>>   pointer (test) equals to the parameter of addr. So is this a bug to
+>>   assert (addr == test)?
+>>
+>>   Attached configure script and test ELF file.
+>>
+>>   Thanks.
+>>
+>> To manage notifications about this bug go to:
+>> https://bugs.launchpad.net/qemu/+bug/1895080/+subscriptions
+>>
+
+
+-- 
+Alex Bennée
+
+
+On older kernels which don't implement MAP_FIXED_NOREPLACE the kernel
+may still fail to give us the address we asked for despite having
+already probed the map for a valid hole. Asserting isn't particularly
+useful to the user so let us move the check up and expand the
+error_report a little to give them a fighting chance of working around
+the problem.
+
+Ameliorates: ee94743034
+Cc: Bug 1895080 <email address hidden>
+Signed-off-by: Alex Bennée <email address hidden>
+---
+ linux-user/elfload.c | 9 ++++-----
+ 1 file changed, 4 insertions(+), 5 deletions(-)
+
+diff --git a/linux-user/elfload.c b/linux-user/elfload.c
+index 4961e6119e2..f6022fd7049 100644
+--- a/linux-user/elfload.c
++++ b/linux-user/elfload.c
+@@ -2331,14 +2331,13 @@ static void pgb_reserved_va(const char *image_name, abi_ulong guest_loaddr,
+     assert(guest_base != 0);
+     test = g2h(0);
+     addr = mmap(test, reserved_va, PROT_NONE, flags, -1, 0);
+-    if (addr == MAP_FAILED) {
++    if (addr == MAP_FAILED || addr != test) {
+         error_report("Unable to reserve 0x%lx bytes of virtual address "
+-                     "space (%s) for use as guest address space (check your "
+-                     "virtual memory ulimit setting or reserve less "
+-                     "using -R option)", reserved_va, strerror(errno));
++                     "space at %p (%s) for use as guest address space (check your"
++                     "virtual memory ulimit setting, min_mmap_addr or reserve less "
++                     "using -R option)", reserved_va, test, strerror(errno));
+         exit(EXIT_FAILURE);
+     }
+-    assert(addr == test);
+ }
+ 
+ void probe_guest_base(const char *image_name, abi_ulong guest_loaddr,
+-- 
+2.20.1
+
+
+
+On older kernels which don't implement MAP_FIXED_NOREPLACE the kernel
+may still fail to give us the address we asked for despite having
+already probed the map for a valid hole. Asserting isn't particularly
+useful to the user so let us move the check up and expand the
+error_report a little to give them a fighting chance of working around
+the problem.
+
+Ameliorates: ee94743034
+Cc: Bug 1895080 <email address hidden>
+Signed-off-by: Alex Bennée <email address hidden>
+---
+ linux-user/elfload.c | 9 ++++-----
+ 1 file changed, 4 insertions(+), 5 deletions(-)
+
+diff --git a/linux-user/elfload.c b/linux-user/elfload.c
+index 4961e6119e24..f6022fd70493 100644
+--- a/linux-user/elfload.c
++++ b/linux-user/elfload.c
+@@ -2331,14 +2331,13 @@ static void pgb_reserved_va(const char *image_name, abi_ulong guest_loaddr,
+     assert(guest_base != 0);
+     test = g2h(0);
+     addr = mmap(test, reserved_va, PROT_NONE, flags, -1, 0);
+-    if (addr == MAP_FAILED) {
++    if (addr == MAP_FAILED || addr != test) {
+         error_report("Unable to reserve 0x%lx bytes of virtual address "
+-                     "space (%s) for use as guest address space (check your "
+-                     "virtual memory ulimit setting or reserve less "
+-                     "using -R option)", reserved_va, strerror(errno));
++                     "space at %p (%s) for use as guest address space (check your"
++                     "virtual memory ulimit setting, min_mmap_addr or reserve less "
++                     "using -R option)", reserved_va, test, strerror(errno));
+         exit(EXIT_FAILURE);
+     }
+-    assert(addr == test);
+ }
+ 
+ void probe_guest_base(const char *image_name, abi_ulong guest_loaddr,
+-- 
+2.20.1
+
+
+
+chroot works as you expected.
+And the patch makes sense.
+Thanks.
+
+On older kernels which don't implement MAP_FIXED_NOREPLACE the kernel
+may still fail to give us the address we asked for despite having
+already probed the map for a valid hole. Asserting isn't particularly
+useful to the user so let us move the check up and expand the
+error_report a little to give them a fighting chance of working around
+the problem.
+
+Ameliorates: ee94743034
+Cc: Bug 1895080 <email address hidden>
+Signed-off-by: Alex Bennée <email address hidden>
+---
+ linux-user/elfload.c | 9 ++++-----
+ 1 file changed, 4 insertions(+), 5 deletions(-)
+
+diff --git a/linux-user/elfload.c b/linux-user/elfload.c
+index 4961e6119e24..f6022fd70493 100644
+--- a/linux-user/elfload.c
++++ b/linux-user/elfload.c
+@@ -2331,14 +2331,13 @@ static void pgb_reserved_va(const char *image_name, abi_ulong guest_loaddr,
+     assert(guest_base != 0);
+     test = g2h(0);
+     addr = mmap(test, reserved_va, PROT_NONE, flags, -1, 0);
+-    if (addr == MAP_FAILED) {
++    if (addr == MAP_FAILED || addr != test) {
+         error_report("Unable to reserve 0x%lx bytes of virtual address "
+-                     "space (%s) for use as guest address space (check your "
+-                     "virtual memory ulimit setting or reserve less "
+-                     "using -R option)", reserved_va, strerror(errno));
++                     "space at %p (%s) for use as guest address space (check your"
++                     "virtual memory ulimit setting, min_mmap_addr or reserve less "
++                     "using -R option)", reserved_va, test, strerror(errno));
+         exit(EXIT_FAILURE);
+     }
+-    assert(addr == test);
+ }
+ 
+ void probe_guest_base(const char *image_name, abi_ulong guest_loaddr,
+-- 
+2.20.1
+
+
+
+Le 15/09/2020 à 15:43, Alex Bennée a écrit :
+> On older kernels which don't implement MAP_FIXED_NOREPLACE the kernel
+> may still fail to give us the address we asked for despite having
+> already probed the map for a valid hole. Asserting isn't particularly
+> useful to the user so let us move the check up and expand the
+> error_report a little to give them a fighting chance of working around
+> the problem.
+> 
+> Ameliorates: ee94743034
+> Cc: Bug 1895080 <email address hidden>
+> Signed-off-by: Alex Bennée <email address hidden>
+> ---
+>  linux-user/elfload.c | 9 ++++-----
+>  1 file changed, 4 insertions(+), 5 deletions(-)
+> 
+> diff --git a/linux-user/elfload.c b/linux-user/elfload.c
+> index 4961e6119e24..f6022fd70493 100644
+> --- a/linux-user/elfload.c
+> +++ b/linux-user/elfload.c
+> @@ -2331,14 +2331,13 @@ static void pgb_reserved_va(const char *image_name, abi_ulong guest_loaddr,
+>      assert(guest_base != 0);
+>      test = g2h(0);
+>      addr = mmap(test, reserved_va, PROT_NONE, flags, -1, 0);
+> -    if (addr == MAP_FAILED) {
+> +    if (addr == MAP_FAILED || addr != test) {
+>          error_report("Unable to reserve 0x%lx bytes of virtual address "
+> -                     "space (%s) for use as guest address space (check your "
+> -                     "virtual memory ulimit setting or reserve less "
+> -                     "using -R option)", reserved_va, strerror(errno));
+> +                     "space at %p (%s) for use as guest address space (check your"
+> +                     "virtual memory ulimit setting, min_mmap_addr or reserve less "
+> +                     "using -R option)", reserved_va, test, strerror(errno));
+>          exit(EXIT_FAILURE);
+>      }
+> -    assert(addr == test);
+>  }
+>  
+>  void probe_guest_base(const char *image_name, abi_ulong guest_loaddr,
+> 
+
+Reviewed-by: Laurent Vivier <email address hidden>
+
+
+On older kernels which don't implement MAP_FIXED_NOREPLACE the kernel
+may still fail to give us the address we asked for despite having
+already probed the map for a valid hole. Asserting isn't particularly
+useful to the user so let us move the check up and expand the
+error_report a little to give them a fighting chance of working around
+the problem.
+
+Signed-off-by: Alex Bennée <email address hidden>
+Reviewed-by: Laurent Vivier <email address hidden>
+Reviewed-by: Richard Henderson <email address hidden>
+Cc: Bug 1895080 <email address hidden>
+Ameliorates: ee94743034
+Message-Id: <email address hidden>
+
+diff --git a/linux-user/elfload.c b/linux-user/elfload.c
+index 4961e6119e24..f6022fd70493 100644
+--- a/linux-user/elfload.c
++++ b/linux-user/elfload.c
+@@ -2331,14 +2331,13 @@ static void pgb_reserved_va(const char *image_name, abi_ulong guest_loaddr,
+     assert(guest_base != 0);
+     test = g2h(0);
+     addr = mmap(test, reserved_va, PROT_NONE, flags, -1, 0);
+-    if (addr == MAP_FAILED) {
++    if (addr == MAP_FAILED || addr != test) {
+         error_report("Unable to reserve 0x%lx bytes of virtual address "
+-                     "space (%s) for use as guest address space (check your "
+-                     "virtual memory ulimit setting or reserve less "
+-                     "using -R option)", reserved_va, strerror(errno));
++                     "space at %p (%s) for use as guest address space (check your"
++                     "virtual memory ulimit setting, min_mmap_addr or reserve less "
++                     "using -R option)", reserved_va, test, strerror(errno));
+         exit(EXIT_FAILURE);
+     }
+-    assert(addr == test);
+ }
+ 
+ void probe_guest_base(const char *image_name, abi_ulong guest_loaddr,
+-- 
+2.20.1
+
+
+
+https://git.qemu.org/?p=qemu.git;a=commitdiff;h=fb730c8683807d549c4a
+
+Released with QEMU v5.2.0.
+