git: f3e11927dc28 - main - vm: Allow MAP_32BIT for all architectures
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 14 Aug 2023 17:20:40 UTC
The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=f3e11927dc287ff686b5cc3618aba4e1e58a5dca commit f3e11927dc287ff686b5cc3618aba4e1e58a5dca Author: Dmitry Chagin <dchagin@FreeBSD.org> AuthorDate: 2023-08-14 17:20:20 +0000 Commit: Dmitry Chagin <dchagin@FreeBSD.org> CommitDate: 2023-08-14 17:20:20 +0000 vm: Allow MAP_32BIT for all architectures Reviewed by: alc, kib, markj Differential revision: https://reviews.freebsd.org/D41435 --- lib/libc/sys/mmap.2 | 3 +-- lib/libsysdecode/flags.c | 9 --------- lib/libsysdecode/mktables | 2 +- sys/kern/uipc_shm.c | 8 +------- sys/sys/mman.h | 2 -- sys/vm/vm_mmap.c | 17 ++--------------- tests/sys/vm/Makefile | 5 ----- tests/sys/vm/mmap_map_32bit_helper.c | 1 - 8 files changed, 5 insertions(+), 42 deletions(-) diff --git a/lib/libc/sys/mmap.2 b/lib/libc/sys/mmap.2 index 5a3c6eb5d06e..37006b0355a6 100644 --- a/lib/libc/sys/mmap.2 +++ b/lib/libc/sys/mmap.2 @@ -28,7 +28,7 @@ .\" @(#)mmap.2 8.4 (Berkeley) 5/11/95 .\" $FreeBSD$ .\" -.Dd December 24, 2020 +.Dd August 14, 2023 .Dt MMAP 2 .Os .Sh NAME @@ -145,7 +145,6 @@ Request a region in the first 2GB of the current process's address space. If a suitable region cannot be found, .Fn mmap will fail. -This flag is only available on 64-bit platforms. .It Dv MAP_ALIGNED Ns Pq Fa n Align the region on a requested boundary. If a suitable region cannot be found, diff --git a/lib/libsysdecode/flags.c b/lib/libsysdecode/flags.c index ac109cc454e0..31c125ad71af 100644 --- a/lib/libsysdecode/flags.c +++ b/lib/libsysdecode/flags.c @@ -913,20 +913,11 @@ sysdecode_mmap_flags(FILE *fp, int flags, int *rem) /* * MAP_ALIGNED can't be handled directly by print_mask_int(). - * MAP_32BIT is also problematic since it isn't defined for - * all platforms. */ printed = false; align = flags & MAP_ALIGNMENT_MASK; val = (unsigned)flags & ~MAP_ALIGNMENT_MASK; print_mask_part(fp, mmapflags, &val, &printed); -#ifdef MAP_32BIT - if (val & MAP_32BIT) { - fprintf(fp, "%sMAP_32BIT", printed ? "|" : ""); - printed = true; - val &= ~MAP_32BIT; - } -#endif if (align != 0) { if (printed) fputc('|', fp); diff --git a/lib/libsysdecode/mktables b/lib/libsysdecode/mktables index a0ff8ee8516c..68c3450a03f7 100644 --- a/lib/libsysdecode/mktables +++ b/lib/libsysdecode/mktables @@ -153,7 +153,7 @@ gen_table "vmresult" "KERN_[A-Z_]+[[:space:]]+[0-9]+" "vm/v gen_table "wait6opt" "W[A-Z]+[[:space:]]+[0-9]+" "sys/wait.h" gen_table "seekwhence" "SEEK_[A-Z]+[[:space:]]+[0-9]+" "sys/unistd.h" gen_table "fcntlcmd" "F_[A-Z0-9_]+[[:space:]]+[0-9]+[[:space:]]+" "sys/fcntl.h" "F_CANCEL|F_..LCK" -gen_table "mmapflags" "MAP_[A-Z_]+[[:space:]]+0x[0-9A-Fa-f]+" "sys/mman.h" +gen_table "mmapflags" "MAP_[2-3A-Z_]+[[:space:]]+0x[0-9A-Fa-f]+" "sys/mman.h" gen_table "rtpriofuncs" "RTP_[A-Z]+[[:space:]]+[0-9]+" "sys/rtprio.h" gen_table "msgflags" "MSG_[A-Z_]+[[:space:]]+0x[0-9]+" "sys/socket.h" "MSG_SOCALLBCK|MSG_MORETOCOME|MSG_TLSAPPDATA" gen_table "sigcode" "SI_[A-Z]+[[:space:]]+0(x[0-9abcdef]+)?" "sys/signal.h" diff --git a/sys/kern/uipc_shm.c b/sys/kern/uipc_shm.c index fb210248f9ac..be4a700c4944 100644 --- a/sys/kern/uipc_shm.c +++ b/sys/kern/uipc_shm.c @@ -1549,11 +1549,7 @@ shm_mmap_large(struct shmfd *shmfd, vm_map_t map, vm_offset_t *addr, /* MAP_PRIVATE is disabled */ if ((flags & ~(MAP_SHARED | MAP_FIXED | MAP_EXCL | - MAP_NOCORE | -#ifdef MAP_32BIT - MAP_32BIT | -#endif - MAP_ALIGNMENT_MASK)) != 0) + MAP_NOCORE | MAP_32BIT | MAP_ALIGNMENT_MASK)) != 0) return (EINVAL); vms = td->td_proc->p_vmspace; @@ -1573,10 +1569,8 @@ shm_mmap_large(struct shmfd *shmfd, vm_map_t map, vm_offset_t *addr, if ((foff & mask) != 0) return (EINVAL); maxaddr = vm_map_max(map); -#ifdef MAP_32BIT if ((flags & MAP_32BIT) != 0 && maxaddr > MAP_32BIT_MAX_ADDR) maxaddr = MAP_32BIT_MAX_ADDR; -#endif if (size == 0 || (size & mask) != 0 || (*addr != 0 && ((*addr & mask) != 0 || *addr + size < *addr || *addr + size > maxaddr))) diff --git a/sys/sys/mman.h b/sys/sys/mman.h index 0413249dee2c..29b00107792f 100644 --- a/sys/sys/mman.h +++ b/sys/sys/mman.h @@ -104,9 +104,7 @@ #define MAP_EXCL 0x00004000 /* for MAP_FIXED, fail if address is used */ #define MAP_NOCORE 0x00020000 /* dont include these pages in a coredump */ #define MAP_PREFAULT_READ 0x00040000 /* prefault mapping for reading */ -#ifdef __LP64__ #define MAP_32BIT 0x00080000 /* map in the low 2GB of address space */ -#endif /* * Request specific alignment (n == log2 of the desired alignment). diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c index 64287f096332..8f0b985da627 100644 --- a/sys/vm/vm_mmap.c +++ b/sys/vm/vm_mmap.c @@ -272,11 +272,7 @@ kern_mmap(struct thread *td, const struct mmap_req *mrp) } if ((flags & ~(MAP_SHARED | MAP_PRIVATE | MAP_FIXED | MAP_HASSEMAPHORE | MAP_STACK | MAP_NOSYNC | MAP_ANON | MAP_EXCL | MAP_NOCORE | - MAP_PREFAULT_READ | MAP_GUARD | -#ifdef MAP_32BIT - MAP_32BIT | -#endif - MAP_ALIGNMENT_MASK)) != 0) + MAP_PREFAULT_READ | MAP_GUARD | MAP_32BIT | MAP_ALIGNMENT_MASK)) != 0) return (EINVAL); if ((flags & (MAP_EXCL | MAP_FIXED)) == MAP_EXCL) return (EINVAL); @@ -287,10 +283,7 @@ kern_mmap(struct thread *td, const struct mmap_req *mrp) return (EINVAL); if ((flags & MAP_GUARD) != 0 && (prot != PROT_NONE || fd != -1 || pos != 0 || (flags & ~(MAP_FIXED | MAP_GUARD | MAP_EXCL | -#ifdef MAP_32BIT - MAP_32BIT | -#endif - MAP_ALIGNMENT_MASK)) != 0)) + MAP_32BIT | MAP_ALIGNMENT_MASK)) != 0)) return (EINVAL); /* @@ -331,7 +324,6 @@ kern_mmap(struct thread *td, const struct mmap_req *mrp) /* Address range must be all in user VM space. */ if (!vm_map_range_valid(&vms->vm_map, addr, addr + size)) return (EINVAL); -#ifdef MAP_32BIT if (flags & MAP_32BIT && addr + size > MAP_32BIT_MAX_ADDR) return (EINVAL); } else if (flags & MAP_32BIT) { @@ -342,7 +334,6 @@ kern_mmap(struct thread *td, const struct mmap_req *mrp) */ if (addr + size > MAP_32BIT_MAX_ADDR) addr = 0; -#endif } else { /* * XXX for non-fixed mappings where no hint is provided or @@ -1621,18 +1612,14 @@ vm_mmap_object(vm_map_t map, vm_offset_t *addr, vm_size_t size, vm_prot_t prot, else findspace = VMFS_OPTIMAL_SPACE; max_addr = 0; -#ifdef MAP_32BIT if ((flags & MAP_32BIT) != 0) max_addr = MAP_32BIT_MAX_ADDR; -#endif if (curmap) { default_addr = round_page((vm_offset_t)td->td_proc->p_vmspace-> vm_daddr + lim_max(td, RLIMIT_DATA)); -#ifdef MAP_32BIT if ((flags & MAP_32BIT) != 0) default_addr = 0; -#endif rv = vm_map_find_min(map, object, foff, addr, size, default_addr, max_addr, findspace, prot, maxprot, docow); diff --git a/tests/sys/vm/Makefile b/tests/sys/vm/Makefile index c460ba9d8db7..a3ea83a33cfd 100644 --- a/tests/sys/vm/Makefile +++ b/tests/sys/vm/Makefile @@ -9,14 +9,9 @@ ATF_TESTS_C+= mlock_test \ page_fault_signal \ shared_shadow_inval_test -.if ${MACHINE_ARCH} != "i386" && ${MACHINE} != "arm" && \ - (${MACHINE} != "powerpc" || (${MACHINE_ARCH} != "powerpc" && \ - ${MACHINE_ARCH} != "powerpcspe")) - # MAP_32BIT is only available on 64-bit platforms BINDIR= ${TESTSDIR} ATF_TESTS_SH+= mmap_map_32bit_test PROGS+= mmap_map_32bit_helper -.endif SUBDIR= soxstack TESTS_SUBDIRS+= stack diff --git a/tests/sys/vm/mmap_map_32bit_helper.c b/tests/sys/vm/mmap_map_32bit_helper.c index 47d4b2c53c20..763bba35d2b9 100644 --- a/tests/sys/vm/mmap_map_32bit_helper.c +++ b/tests/sys/vm/mmap_map_32bit_helper.c @@ -11,7 +11,6 @@ #include <stdlib.h> #include <unistd.h> -_Static_assert(sizeof(vm_offset_t) >= 8, "Test is not intended for ILP32"); #define MAP_32BIT_MAX_ADDR ((vm_offset_t)1 << 31) int