Skip to contentSkip to conversation

qemu/osdep: Remove fallback for MAP_FIXED_NOREPLACE

PATCH In review Richard Henderson 4 participants 5 messages Aug 8, 2023 – Aug 9, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qemu/osdep: Remove fallback for MAP_FIXED_NOREPLACE

In order for our emulation of MAP_FIXED_NOREPLACE to succeed within linux-user target_mmap, we require a non-zero value. This does not require host kernel support, merely the bit being defined.

MAP_FIXED_NOREPLACE was added with glibc 2.28. From repology.org:

                  Fedora 36: 2.35
          CentOS 8 (RHEL-8): 2.28
                  Debian 11: 2.31
         OpenSUSE Leap 15.4: 2.31
           Ubuntu LTS 20.04: 2.31
---
 include/qemu/osdep.h | 3 ---
 linux-user/elfload.c | 1 -
 2 files changed, 4 deletions(-)
include/qemu/osdep.h +0 -3
index cc61b00ba9..21ef8f1699 100644
@@ -289,9 +289,6 @@ 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
-#endif
 #ifndef MAP_NORESERVE
 #define MAP_NORESERVE 0
 #endif
linux-user/elfload.c +0 -1
index 36e4026f05..9d9c79a653 100644
@@ -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. */
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Richard Henderson

In order for our emulation of MAP_FIXED_NOREPLACE to succeed within linux-user target_mmap, we require a non-zero value. This does not require host kernel support, merely the bit being defined.

MAP_FIXED_NOREPLACE was added with glibc 2.28. From repology.org:

Quoted 8 lines
                  Fedora 36: 2.35
          CentOS 8 (RHEL-8): 2.28
                  Debian 11: 2.31
         OpenSUSE Leap 15.4: 2.31
           Ubuntu LTS 20.04: 2.31
Signature · 2 lines
Alex Bennée
Virtualisation Tech Lead @ Linaro
Reviewed-by on v1 1/1
#2 lore raw
In reply to Richard Henderson
Quoted 6 lines · Richard Henderson

In order for our emulation of MAP_FIXED_NOREPLACE to succeed within linux-user target_mmap, we require a non-zero value. This does not require host kernel support, merely the bit being defined.

MAP_FIXED_NOREPLACE was added with glibc 2.28. From repology.org:

Quoted 8 lines
                   Fedora 36: 2.35
           CentOS 8 (RHEL-8): 2.28
                   Debian 11: 2.31
          OpenSUSE Leap 15.4: 2.31
            Ubuntu LTS 20.04: 2.31
#3 lore raw
In reply to Richard Henderson

08.08.2023 19:44, Richard Henderson пишет:

Quoted 3 lines

In order for our emulation of MAP_FIXED_NOREPLACE to succeed within linux-user target_mmap, we require a non-zero value. This does not require host kernel support, merely the bit being defined.

Hm. Should we add something like

assert(MAP_FIXED_NOREPLACE != 0)

somewhere?

/mjt

#4 lore raw
Quoted 10 lines · Michael Tokarev

08.08.2023 19:44, Richard Henderson пишет:

Quoted 3 lines

In order for our emulation of MAP_FIXED_NOREPLACE to succeed within linux-user target_mmap, we require a non-zero value.  This does not require host kernel support, merely the bit being defined.

Hm. Should we add something like

 assert(MAP_FIXED_NOREPLACE != 0)

somewhere?

I wouldn't think so. Where would a zero come from?

r~