All of lore.kernel.org
 help / color / mirror / Atom feed
* [Bug 1895080] [NEW] pgb_reserved_va: Assertion `addr == test' failed
@ 2020-09-10  3:46 Hansni Bu
  2020-09-10  6:18 ` [Bug 1895080] " Laurent Vivier
                   ` (5 more replies)
  0 siblings, 6 replies; 73+ messages in thread
From: Hansni Bu @ 2020-09-10  3:46 UTC (permalink / raw)
  To: qemu-devel

Public bug reported:

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.

** Affects: qemu
     Importance: Undecided
         Status: New

** Attachment added: "config script and test ELF file"
   https://bugs.launchpad.net/bugs/1895080/+attachment/5409254/+files/config_and_elf.tar.xz

-- 
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


^ permalink raw reply related	[flat|nested] 73+ messages in thread
* [RFC PATCH] linux-user: test, don't assert addr != test in pgb_reserved_va
@ 2020-09-11 14:56 ` Alex Bennée
  0 siblings, 0 replies; 73+ messages in thread
From: Alex Bennée @ 2020-09-11 14:56 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alex Bennée, Laurent Vivier, Bug 1895080

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 <1895080@bugs.launchpad.net>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 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



^ permalink raw reply related	[flat|nested] 73+ messages in thread
* [PATCH  v1 0/6] deprecation and linux-user tweaks (+test fix)
@ 2020-09-14 15:07 Alex Bennée
  2020-09-14 15:07   ` [Bug 1895080] " Alex Bennée
                   ` (5 more replies)
  0 siblings, 6 replies; 73+ messages in thread
From: Alex Bennée @ 2020-09-14 15:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alex Bennée

Hi,

This series contains the previously posted linux-user fix for dealing
with weird mmap semantics as well as some tweaks to configure as
suggested in a late review of my last PR. It includes tilegx in the
modified configure logic for handling deprecated fixes. There is also
a fix from Max for iotests although I suspect there will be a v2 of
the patch soon.

Most need review:
 - gitlab: create a build-deprecated target
 - configure: include tilegx-linux-user in the auto-exclude logic
 - configure: also skip deprecated targets with target-list-exclude
 - configure: use add_to for tweaking deprecated_features
 - linux-user: test, don't assert addr != test in pgb_reserved_va

Alex Bennée (5):
  linux-user: test, don't assert addr != test in pgb_reserved_va
  configure: use add_to for tweaking deprecated_features
  configure: also skip deprecated targets with target-list-exclude
  configure: include tilegx-linux-user in the auto-exclude logic
  gitlab: create a build-deprecated target

Max Reitz (1):
  iotests: Work around failing readlink -f

 configure                | 15 +++++++++++----
 linux-user/elfload.c     |  9 ++++-----
 .gitlab-ci.yml           | 10 ++++++++++
 .travis.yml              |  3 +--
 tests/qemu-iotests/check |  4 ++++
 5 files changed, 30 insertions(+), 11 deletions(-)

-- 
2.20.1



^ permalink raw reply	[flat|nested] 73+ messages in thread
* [PATCH  v2 0/8] configure deprecation, linux-user and iotest fixes
@ 2020-09-15 13:43 Alex Bennée
  2020-09-15 13:43   ` [Bug 1895080] " Alex Bennée
                   ` (7 more replies)
  0 siblings, 8 replies; 73+ messages in thread
From: Alex Bennée @ 2020-09-15 13:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alex Bennée

Hi,

This series contains the previously posted linux-user fix for dealing
with weird mmap semantics as well as some tweaks to configure. Since
last version I've included Max's latest iotest update as well as
re-factored the configure logic. I've also added a patch for to
deprecate lm32 and unicore32 from configure.

Most need review:
 - configure: add [lm32|unicore32]-softmmu to deprecation logic
 - configure: include tilegx-linux-user in the deprecation logic
 - configure: clean-up the target-list-exclude logic
 - configure: also skip deprecated targets with target-list-exclude
 - configure: move deprecated feature processing to supported_target
 - linux-user: test, don't assert addr != test in pgb_reserved_va

Alex Bennée (7):
  linux-user: test, don't assert addr != test in pgb_reserved_va
  configure: move deprecated feature processing to supported_target
  configure: also skip deprecated targets with target-list-exclude
  configure: clean-up the target-list-exclude logic
  configure: include tilegx-linux-user in the deprecation logic
  gitlab: create a build-deprecated target
  configure: add [lm32|unicore32]-softmmu to deprecation logic

Max Reitz (1):
  iotests: Drop readlink -f

 configure                | 33 ++++++++++++++++++---------------
 linux-user/elfload.c     |  9 ++++-----
 .gitlab-ci.yml           | 15 +++++++++++++--
 .shippable.yml           |  2 +-
 .travis.yml              |  3 +--
 tests/qemu-iotests/check |  2 +-
 6 files changed, 38 insertions(+), 26 deletions(-)

-- 
2.20.1



^ permalink raw reply	[flat|nested] 73+ messages in thread
* [PULL 0/8] configure deprecation, linux-user and test fix
@ 2020-09-16 12:26 Alex Bennée
  2020-09-16 12:26   ` [Bug 1895080] " Alex Bennée
                   ` (8 more replies)
  0 siblings, 9 replies; 73+ messages in thread
From: Alex Bennée @ 2020-09-16 12:26 UTC (permalink / raw)
  To: peter.maydell; +Cc: Alex Bennée, qemu-devel

The following changes since commit de39a045bd8d2b49e4f3d07976622c29d58e0bac:

  Merge remote-tracking branch 'remotes/kraxel/tags/vga-20200915-pull-request' into staging (2020-09-15 14:25:05 +0100)

are available in the Git repository at:

  https://github.com/stsquad/qemu.git tags/pull-configure-fixes-160920-1

for you to fetch changes up to 3ffc7f013763bf4fc50c3b403cbacca2bee68cfa:

  configure: add [lm32|unicore32]-softmmu to deprecation logic (2020-09-16 10:07:01 +0100)

----------------------------------------------------------------
configure tweaks for deprecation

  - iotest fix for readlink -f
  - linux-user, report rather than assert on mmap failure
  - clean-up and re-factor the logic
  - add tilegx-linux-user to deprecated_targets_list
  - add [lm32|unicore32]-softmmu deprecated_targets_list
  - add a gitlab deprecated builds test

----------------------------------------------------------------
Alex Bennée (7):
      linux-user: test, don't assert addr != test in pgb_reserved_va
      configure: move deprecated feature processing to supported_target
      configure: also skip deprecated targets with target-list-exclude
      configure: clean-up the target-list-exclude logic
      configure: include tilegx-linux-user in the deprecation logic
      gitlab: create a build-deprecated target
      configure: add [lm32|unicore32]-softmmu to deprecation logic

Max Reitz (1):
      iotests: Drop readlink -f

 configure                | 33 ++++++++++++++++++---------------
 linux-user/elfload.c     |  9 ++++-----
 .gitlab-ci.yml           | 15 +++++++++++++--
 .shippable.yml           |  2 +-
 .travis.yml              |  3 +--
 tests/qemu-iotests/check |  2 +-
 6 files changed, 38 insertions(+), 26 deletions(-)

-- 
2.20.1



^ permalink raw reply	[flat|nested] 73+ messages in thread

end of thread, other threads:[~2020-12-10  9:56 UTC | newest]

Thread overview: 73+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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-15  2:09 ` Hansni Bu
2020-11-08  9:43 ` Thomas Huth
2020-12-10  9:17 ` Thomas Huth
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-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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.