aboutsummaryrefslogtreecommitdiff
path: root/linux-user
diff options
context:
space:
mode:
authorAlex Bennée <alex.bennee@linaro.org>2020-07-01 14:56:45 +0100
committerAlex Bennée <alex.bennee@linaro.org>2020-07-11 15:53:00 +0100
commitc1f6ad798c7bb328a6f387f2509bf86305383d37 (patch)
tree915d6b186fa9a09aa201553faae7bb814e9ad183 /linux-user
parent27ebeda0c07dcc2e9eec98ed1f70115ffa1e3797 (diff)
linux-user/elfload: use MAP_FIXED_NOREPLACE in pgb_reserved_va
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> Message-Id: <20200701135652.1366-34-alex.bennee@linaro.org>
Diffstat (limited to 'linux-user')
-rw-r--r--linux-user/elfload.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index b5cb21384a..7e7f642332 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);