[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH for-8.1 v2] linux-user: Define real MAP_FIXED_NOREPLACE value
From: |
Akihiko Odaki |
Subject: |
[PATCH for-8.1 v2] linux-user: Define real MAP_FIXED_NOREPLACE value |
Date: |
Wed, 9 Aug 2023 00:06:35 +0900 |
do_brk() assumes target_mmap() emulates MAP_FIXED_NOREPLACE even when
the host does not support it. However, such emulation is not possible
if MAP_FIXED_NOREPLACE is defined as zero.
Define MAP_FIXED_NOREPLACE with the real value instead of zero if it is
not defined.
Fixes: e69e032d1a ("linux-user: Use MAP_FIXED_NOREPLACE for do_brk()")
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
include/qemu/osdep.h | 8 ++++++--
linux-user/elfload.c | 1 -
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index cc61b00ba9..6c1050afcd 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -289,8 +289,12 @@ void QEMU_ERROR("code path is reachable")
#ifndef MAP_ANONYMOUS
#define MAP_ANONYMOUS MAP_ANON
#endif
-#ifndef MAP_FIXED_NOREPLACE
-#define MAP_FIXED_NOREPLACE 0
+#if defined(__linux__) && !defined(MAP_FIXED_NOREPLACE)
+#if MAP_HUGETLB == 0x100000
+#define MAP_FIXED_NOREPLACE 0x200000
+#else
+#define MAP_FIXED_NOREPLACE 0x100000
+#endif
#endif
#ifndef MAP_NORESERVE
#define MAP_NORESERVE 0
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 36e4026f05..9d9c79a653 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -2807,7 +2807,6 @@ 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);
- /* osdep.h defines this as 0 if it's missing */
flags |= MAP_FIXED_NOREPLACE;
/* Reserve the memory on the host. */
--
2.41.0
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH for-8.1 v2] linux-user: Define real MAP_FIXED_NOREPLACE value,
Akihiko Odaki <=