mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-14 20:37:06 +00:00
vm: Allow MAP_32BIT for all architectures
Reviewed by: alc, kib, markj Differential revision: https://reviews.freebsd.org/D41435
This commit is contained in:
parent
0ddd32b617
commit
f3e11927dc
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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)))
|
||||
|
|
|
@ -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).
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue