qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: Bug 1895080 <1895080@bugs.launchpad.net>
Cc: qemu-devel@nongnu.org
Subject: Re: [Bug 1895080] [NEW] pgb_reserved_va: Assertion `addr == test' failed
Date: Fri, 11 Sep 2020 12:54:42 +0100	[thread overview]
Message-ID: <87o8mco7el.fsf@linaro.org> (raw)
In-Reply-To: <CAGTPX+DAoJcw2y9gPjkP6kGXEQW7=e1tohM8vND9j9Qtxuc5vw@mail.gmail.com>


Hansni Bu <1895080@bugs.launchpad.net> 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 <1895080@bugs.launchpad.net>
> wrote:
>
>> Alex Bennée <alex.bennee@linaro.org> writes:
>>
>> > Laurent Vivier <laurent@vivier.eu> 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


WARNING: multiple messages have this Message-ID (diff)
From: "Alex Bennée" <1895080@bugs.launchpad.net>
To: qemu-devel@nongnu.org
Subject: Re: [Bug 1895080] [NEW] pgb_reserved_va: Assertion `addr == test' failed
Date: Fri, 11 Sep 2020 11:54:42 -0000	[thread overview]
Message-ID: <87o8mco7el.fsf@linaro.org> (raw)
Message-ID: <20200911115442.V8E42AkwQe9pssgPWO-iEVhO1faqXftL58DWz2LJXXU@z> (raw)
In-Reply-To: CAGTPX+DAoJcw2y9gPjkP6kGXEQW7=e1tohM8vND9j9Qtxuc5vw@mail.gmail.com

Hansni Bu <1895080@bugs.launchpad.net> 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 <1895080@bugs.launchpad.net>
> wrote:
>
>> Alex Bennée <alex.bennee@linaro.org> writes:
>>
>> > Laurent Vivier <laurent@vivier.eu> 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 a member of qemu-
devel-ml, which is subscribed to QEMU.
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


  reply	other threads:[~2020-09-11 11:55 UTC|newest]

Thread overview: 73+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-10  3:46 [Bug 1895080] [NEW] pgb_reserved_va: Assertion `addr == test' failed Hansni Bu
2020-09-10  6:18 ` [Bug 1895080] " Laurent Vivier
2020-09-10 19:04 ` [Bug 1895080] [NEW] " Laurent Vivier
2020-09-11  5:57   ` Hansni Bu
2020-09-11  9:34   ` Alex Bennée
2020-09-11  9:38     ` Alex Bennée
2020-09-11 10:18       ` Hansni Bu
2020-09-11 11:54         ` Alex Bennée [this message]
2020-09-11 11:54           ` Alex Bennée
2020-09-11 12:32           ` Hansni Bu
2020-09-11 14:47             ` Alex Bennée
2020-09-11 14:47               ` Alex Bennée
2020-09-11  8:30 ` [Bug 1895080] " Alex Bennée
2020-09-11  9:31   ` Hansni Bu
2020-09-11 14:56 ` [RFC PATCH] linux-user: test, don't assert addr != test in pgb_reserved_va Alex Bennée
2020-09-11 14:56   ` [Bug 1895080] Re: pgb_reserved_va: Assertion `addr == test' failed Alex Bennée
2020-09-15  2:09 ` Hansni Bu
2020-11-08  9:43 ` Thomas Huth
2020-12-10  9:17 ` Thomas Huth
  -- strict thread matches above, loose matches on Subject: below --
2020-09-14 15:07 [PATCH v1 0/6] deprecation and linux-user tweaks (+test fix) Alex Bennée
2020-09-14 15:07 ` [PATCH v1 1/6] linux-user: test, don't assert addr != test in pgb_reserved_va Alex Bennée
2020-09-14 15:07   ` [Bug 1895080] " Alex Bennée
2020-09-14 15:07 ` [PATCH v1 2/6] configure: use add_to for tweaking deprecated_features Alex Bennée
2020-09-14 16:14   ` Thomas Huth
2020-09-14 15:07 ` [PATCH v1 3/6] configure: also skip deprecated targets with target-list-exclude Alex Bennée
2020-09-14 19:17   ` Peter Maydell
2020-09-15  9:22     ` Alex Bennée
2020-09-14 15:07 ` [PATCH v1 4/6] configure: include tilegx-linux-user in the auto-exclude logic Alex Bennée
2020-09-15 12:58   ` Philippe Mathieu-Daudé
2020-09-14 15:07 ` [PATCH v1 5/6] gitlab: create a build-deprecated target Alex Bennée
2020-09-14 15:15   ` Philippe Mathieu-Daudé
2020-09-14 16:16   ` Thomas Huth
2020-09-14 15:07 ` [PATCH v1 6/6] iotests: Work around failing readlink -f Alex Bennée
2020-09-15 13:43 [PATCH v2 0/8] configure deprecation, linux-user and iotest fixes Alex Bennée
2020-09-15 13:43 ` [PATCH v2 1/8] linux-user: test, don't assert addr != test in pgb_reserved_va Alex Bennée
2020-09-15 13:43   ` [Bug 1895080] " Alex Bennée
2020-09-15 15:58   ` Laurent Vivier
2020-09-15 15:58     ` [Bug 1895080] " Laurent Vivier
2020-09-15 17:13   ` Richard Henderson
2020-09-15 13:43 ` [PATCH v2 2/8] iotests: Drop readlink -f Alex Bennée
2020-09-15 17:14   ` Richard Henderson
2020-09-15 13:43 ` [PATCH v2 3/8] configure: move deprecated feature processing to supported_target Alex Bennée
2020-09-15 13:51   ` Michael Tokarev
2020-09-15 13:43 ` [PATCH v2 4/8] configure: also skip deprecated targets with target-list-exclude Alex Bennée
2020-09-15 17:16   ` Richard Henderson
2020-09-15 13:43 ` [PATCH v2 5/8] configure: clean-up the target-list-exclude logic Alex Bennée
2020-09-15 17:17   ` Richard Henderson
2020-09-15 13:43 ` [PATCH v2 6/8] configure: include tilegx-linux-user in the deprecation logic Alex Bennée
2020-09-15 17:17   ` Richard Henderson
2020-09-15 17:47   ` Philippe Mathieu-Daudé
2020-09-15 13:43 ` [PATCH v2 7/8] gitlab: create a build-deprecated target Alex Bennée
2020-09-15 13:43 ` [PATCH v2 8/8] configure: add [lm32|unicore32]-softmmu to deprecation logic Alex Bennée
2020-09-15 17:20   ` Richard Henderson
2020-10-29 12:25   ` Thomas Huth
2020-10-29 14:42     ` Alex Bennée
2020-10-29 15:28       ` Thomas Huth
2020-09-16 12:26 [PULL 0/8] configure deprecation, linux-user and test fix Alex Bennée
2020-09-16 12:26 ` [PULL 1/8] linux-user: test, don't assert addr != test in pgb_reserved_va Alex Bennée
2020-09-16 12:26   ` [Bug 1895080] " Alex Bennée
2020-09-16 12:26 ` [PULL 2/8] iotests: Drop readlink -f Alex Bennée
2020-09-16 12:26 ` [PULL 3/8] configure: move deprecated feature processing to supported_target Alex Bennée
2020-09-16 12:26 ` [PULL 4/8] configure: also skip deprecated targets with target-list-exclude Alex Bennée
2020-09-16 12:26 ` [PULL 5/8] configure: clean-up the target-list-exclude logic Alex Bennée
2020-09-16 12:26 ` [PULL 6/8] configure: include tilegx-linux-user in the deprecation logic Alex Bennée
2020-09-16 12:26 ` [PULL 7/8] gitlab: create a build-deprecated target Alex Bennée
2020-09-16 12:40   ` Peter Maydell
2020-09-16 13:23     ` Alex Bennée
2020-09-16 13:52       ` Philippe Mathieu-Daudé
2020-09-25 15:54         ` Peter Maydell
2020-09-25 18:34           ` Richard Henderson
2020-09-25 18:47             ` Peter Maydell
2020-09-16 12:26 ` [PULL 8/8] configure: add [lm32|unicore32]-softmmu to deprecation logic Alex Bennée
2020-09-17 19:40 ` [PULL 0/8] configure deprecation, linux-user and test fix Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87o8mco7el.fsf@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=1895080@bugs.launchpad.net \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).