3785 Implement MAP_32BIT flag to mmap()
Reviewed by: Albert Lee <
[email protected]>
Reviewed by: Dan McDonald <
[email protected]>
Reviewed by: Robert Mustacchi <
[email protected]>
Approved by: Dan McDonald <
[email protected]>
--- a/usr/src/cmd/truss/print.c Thu Aug 22 09:51:47 2013 -0800
+++ b/usr/src/cmd/truss/print.c Fri Aug 23 11:13:02 2013 -0400
@@ -734,7 +734,7 @@
arg &= ~(_MAP_NEW|MAP_TYPE);
if (arg & ~(MAP_FIXED|MAP_RENAME|MAP_NORESERVE|MAP_ANON|MAP_ALIGN|
- MAP_TEXT|MAP_INITDATA))
+ MAP_TEXT|MAP_INITDATA|MAP_32BIT))
(void) snprintf(str + used, sizeof (pri->code_buf) - used,
"|0x%lX", arg);
else {
@@ -752,6 +752,8 @@
(void) strlcat(str, "|MAP_TEXT", CBSIZE);
if (arg & MAP_INITDATA)
(void) strlcat(str, "|MAP_INITDATA", CBSIZE);
+ if (arg & MAP_32BIT)
+ (void) strlcat(str, "|MAP_32BIT", CBSIZE);
}
return ((const char *)str);
--- a/usr/src/man/man2/mmap.2 Thu Aug 22 09:51:47 2013 -0800
+++ b/usr/src/man/man2/mmap.2 Fri Aug 23 11:13:02 2013 -0400
@@ -1,4 +1,5 @@
'\" te
+.\" Copyright 2013 OmniTI Computer Consulting, Inc. All Rights Reserved.
.\" Copyright 1989 AT&T. Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved. Portions Copyright (c) 1992, X/Open Company Limited. All Rights Reserved.
.\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
.\" http://www.opengroup.org/bookstore/.
@@ -203,6 +204,15 @@
.RE
.sp
+.ne 2
+.na
+\fB\fBMAP_32BIT\fR\fR
+.ad
+.RS 17n
+Map to the lower 32 bits of address space.
+.RE
+
+.sp
.LP
The \fBMAP_SHARED\fR and \fBMAP_PRIVATE\fR options describe the disposition of
write references to the underlying object. If \fBMAP_SHARED\fR is specified,
@@ -288,6 +298,13 @@
dynamic linker for mapping initialized data of shared objects.
.sp
.LP
+The \fBMAP_32BIT\fR option informs the system that the search space for
+mapping assignment should be limited to the first 32 bits (4 Gbytes) of the
+caller's address space. This flag is accepted in both 32-bit and 64-bit
+process models, but does not alter the mapping strategy when used in a
+32-bit process model.
+.sp
+.LP
The \fIoff\fR argument is constrained to be aligned and sized according to the
value returned by \fBsysconf()\fR when passed \fB_SC_PAGESIZE\fR or
\fB_SC_PAGE_SIZE\fR. When \fBMAP_FIXED\fR is specified, the \fIaddr\fR argument
--- a/usr/src/uts/common/os/grow.c Thu Aug 22 09:51:47 2013 -0800
+++ b/usr/src/uts/common/os/grow.c Fri Aug 23 11:13:02 2013 -0400
@@ -19,6 +19,8 @@
* CDDL HEADER END
*/
+/* Copyright 2013 OmniTI Computer Consulting, Inc. All rights reserved. */
+
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
@@ -814,9 +816,7 @@
struct file *fp;
int error;
- if (flags & _MAP_LOW32)
- error = EINVAL;
- else if (fd == -1 && (flags & MAP_ANON) != 0)
+ if (fd == -1 && (flags & MAP_ANON) != 0)
error = smmap_common(&addr, len, prot, flags,
NULL, (offset_t)pos);
else if ((fp = getf(fd)) != NULL) {
--- a/usr/src/uts/common/sys/mman.h Thu Aug 22 09:51:47 2013 -0800
+++ b/usr/src/uts/common/sys/mman.h Fri Aug 23 11:13:02 2013 -0400
@@ -19,6 +19,7 @@
* CDDL HEADER END
*/
+/* Copyright 2013 OmniTI Computer Consulting, Inc. All rights reserved. */
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
@@ -104,8 +105,10 @@
#if (_POSIX_C_SOURCE <= 2) || defined(_XPG4_2)
#ifdef _KERNEL
#define PROT_EXCL 0x20
+#endif /* _KERNEL */
+
#define _MAP_LOW32 0x80 /* force mapping in lower 4G of address space */
-#endif /* _KERNEL */
+#define MAP_32BIT _MAP_LOW32
/*
* For the sake of backward object compatibility, we use the _MAP_NEW flag.