From nobody Mon Aug 14 17:20:40 2023 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4RPh4T4z1Fz4Tkks; Mon, 14 Aug 2023 17:20:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RPh4S5K9Sz3d15; Mon, 14 Aug 2023 17:20:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1692033640; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=BSbkH9398RcrAe1SRFRChkk7MeWFTcwyYKWnMzr+f04=; b=ZVreJ4TpGx1mgkEzPE8jmYvpRbI2KtsKWydynpm9HtoeNXqi2eOk4x5/w27ZIAGSsASyLY uFWJm36a+/uMLd2ZhBFtOkGPhx6c4cCuX/I79jHdSX1sC0crLJFjnXKyWnmw+AU3XPghCH 3ccDQV2rhHf6ipZXzQtoTXaD8WSkTr0bXryP8HJjQxfb/e/2xYgABpuWz8aNPxrXjX+Yg/ rZhR/d4VFCH9bjA4PSsq8lE9g+H/UBYjRw6S5D9N2BQl5GugzVTqtK2gW2yDhgz8XkEHou BkoTXiGwXB8h2jz/O4QXMaawWTwcSmw9z6dJPlo/Zn8SpLxZWzEQ7BmDbmYlpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1692033640; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=BSbkH9398RcrAe1SRFRChkk7MeWFTcwyYKWnMzr+f04=; b=lYbvI+KPsjd0L7Ag5ix9HJWSuYSD1ANrQuOlJxPBbCdjEIe6hkstUqTT7fBivh1OOOs9Xu 9dt94LtPe5ShC8UJ5uApbDoORYdaemtIPs5Eq/ZKZgJpUFs2m0DrW57819YnrhBMxRravz duruRNmqaNo2bRWDWJBXLiVGVcdZTvmORAWr9g55IHhAToo/YnUpvSDhIM63EUpRrvc7Wx nId7OcsFYG+M3mweixM9MocdpyYzQos8nSS4Wkpg9msGS5N8ltHxAAuTYd4kIyOntNx1s3 3raM9nf5uD125FXTP5fskw/kd+ht//dF0mXw+M83gMcaw+AOjVrsCVDI9HLN3w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1692033640; a=rsa-sha256; cv=none; b=btti1+08tUQNQYNefkhf+fDeF7qYkTA6D0W2rBugyulGSx22sFHn3APQn1F47n1v05ETvo jC39sSVGt5e4zyEdzdz7LLhK9kR1F2gOuHWIarjcGjNTBQCy6gB8I33rFWsI/OTkN20djE 5LcnINmotZMXvCF2pVbUcSnxtM4aXa8Z8HbFhtW++CgyOJv1Ruw2XDfMwZv5PVUpbrjeRe s90sPq2pkJDHzz7MLDYa18qUD/d3KYtlLVcyhSGq7kH1/KxHn0xa/IKpDMXrWi2JsxHToe RW3U3FinnRpF44rZj2iiKQRvSZHZk9fQEdNJVqe+TWvrCsEphil0Vh6A74+new== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4RPh4S4BCLzclr; Mon, 14 Aug 2023 17:20:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 37EHKe2N004502; Mon, 14 Aug 2023 17:20:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 37EHKeoB004500; Mon, 14 Aug 2023 17:20:40 GMT (envelope-from git) Date: Mon, 14 Aug 2023 17:20:40 GMT Message-Id: <202308141720.37EHKeoB004500@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: f3e11927dc28 - main - vm: Allow MAP_32BIT for all architectures List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f3e11927dc287ff686b5cc3618aba4e1e58a5dca Auto-Submitted: auto-generated The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=f3e11927dc287ff686b5cc3618aba4e1e58a5dca commit f3e11927dc287ff686b5cc3618aba4e1e58a5dca Author: Dmitry Chagin AuthorDate: 2023-08-14 17:20:20 +0000 Commit: Dmitry Chagin 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 #include -_Static_assert(sizeof(vm_offset_t) >= 8, "Test is not intended for ILP32"); #define MAP_32BIT_MAX_ADDR ((vm_offset_t)1 << 31) int