[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 33/40] linux-user/elfload: use MAP_FIXED_NOREPLACE in pgb_rese
From: |
Alex Bennée |
Subject: |
[PATCH v4 33/40] linux-user/elfload: use MAP_FIXED_NOREPLACE in pgb_reserved_va |
Date: |
Wed, 1 Jul 2020 14:56:45 +0100 |
Given we assert the requested address matches what we asked we should
also make that clear in the mmap flags. Otherwise we see failures in
the GitLab environment for some currently unknown but allowable
reason. We use MAP_FIXED_NOREPLACE if we can so we don't just clobber
an existing mapping. Also include the strerror string for a bit more
info on failure.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
v4
- use MAP_FIXED_NOREPLACE instead
- also dump strerror
---
linux-user/elfload.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index b5cb21384a1..7e7f642332d 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -2294,7 +2294,7 @@ static void pgb_dynamic(const char *image_name, long
align)
static void pgb_reserved_va(const char *image_name, abi_ulong guest_loaddr,
abi_ulong guest_hiaddr, long align)
{
- const int flags = MAP_ANONYMOUS | MAP_PRIVATE | MAP_NORESERVE;
+ int flags = MAP_ANONYMOUS | MAP_PRIVATE | MAP_NORESERVE;
void *addr, *test;
if (guest_hiaddr > reserved_va) {
@@ -2307,15 +2307,19 @@ static void pgb_reserved_va(const char *image_name,
abi_ulong guest_loaddr,
/* Widen the "image" to the entire reserved address space. */
pgb_static(image_name, 0, reserved_va, align);
+#ifdef MAP_FIXED_NOREPLACE
+ flags |= MAP_FIXED_NOREPLACE;
+#endif
+
/* Reserve the memory on the host. */
assert(guest_base != 0);
test = g2h(0);
addr = mmap(test, reserved_va, PROT_NONE, flags, -1, 0);
if (addr == MAP_FAILED) {
error_report("Unable to reserve 0x%lx bytes of virtual address "
- "space for use as guest address space (check your "
+ "space (%s) for use as guest address space (check your "
"virtual memory ulimit setting or reserve less "
- "using -R option)", reserved_va);
+ "using -R option)", reserved_va, strerror(errno));
exit(EXIT_FAILURE);
}
assert(addr == test);
--
2.20.1
- [PATCH v4 23/40] gitlab: build containers with buildkit and metadata, (continued)
- [PATCH v4 23/40] gitlab: build containers with buildkit and metadata, Alex Bennée, 2020/07/01
- [PATCH v4 37/40] gitlab: limit re-builds of the containers, Alex Bennée, 2020/07/01
- [PATCH v4 26/40] tests/acceptance: skip s390x_ccw_vrtio_tcg on GitLab, Alex Bennée, 2020/07/01
- [PATCH v4 34/40] gitlab: enable check-tcg for linux-user tests, Alex Bennée, 2020/07/01
- [PATCH v4 15/40] tests/vm: allow us to take advantage of MTTCG, Alex Bennée, 2020/07/01
- [PATCH v4 35/40] gitlab: add avocado asset caching, Alex Bennée, 2020/07/01
- [PATCH v4 16/40] tests/docker: check for an parameters not empty string, Alex Bennée, 2020/07/01
- [PATCH v4 27/40] tests/acceptance: fix dtb path for machine_rx_gdbsim, Alex Bennée, 2020/07/01
- [PATCH v4 14/40] tests/vm: switch from optsparse to argparse, Alex Bennée, 2020/07/01
- [PATCH v4 33/40] linux-user/elfload: use MAP_FIXED_NOREPLACE in pgb_reserved_va,
Alex Bennée <=
- [PATCH v4 31/40] tests/tcg: add more default compilers to configure.sh, Alex Bennée, 2020/07/01
- [PATCH v4 40/40] shippable: pull images from registry instead of building, Alex Bennée, 2020/07/01
- [PATCH v4 29/40] tests/acceptance: skip LinuxInitrd 2gib with v4.16 on GitLab, Alex Bennée, 2020/07/01
- [PATCH v4 38/40] containers.yml: build with docker.py tooling, Alex Bennée, 2020/07/01
- [PATCH v4 28/40] tests/acceptance: skip multicore mips_malta tests on GitLab, Alex Bennée, 2020/07/01