diff options
author | Michael Corcoran <Michael.Corcoran@Sun.COM> | 2008-11-24 17:12:06 -0800 |
---|---|---|
committer | Michael Corcoran <Michael.Corcoran@Sun.COM> | 2008-11-24 17:12:06 -0800 |
commit | 0616c1c344750b61fbfd80b1185254b28a9fe60d (patch) | |
tree | b73bff6b61a4213c28a88a5fd6234764fda27fc6 /usr/src/uts/common/sys | |
parent | 394ab0cbe9de0b3be5bf232d9224a9d050999ae5 (diff) | |
download | illumos-joyent-0616c1c344750b61fbfd80b1185254b28a9fe60d.tar.gz |
PSARC/2008/226 mmapobj(2) - mmap object
6502792 Same dynamic libraries should be mapped at the same virtual addresses in different processes
Diffstat (limited to 'usr/src/uts/common/sys')
-rw-r--r-- | usr/src/uts/common/sys/Makefile | 1 | ||||
-rw-r--r-- | usr/src/uts/common/sys/mman.h | 70 | ||||
-rw-r--r-- | usr/src/uts/common/sys/mmapobj.h | 52 | ||||
-rw-r--r-- | usr/src/uts/common/sys/syscall.h | 3 | ||||
-rw-r--r-- | usr/src/uts/common/sys/vmem.h | 10 |
5 files changed, 129 insertions, 7 deletions
diff --git a/usr/src/uts/common/sys/Makefile b/usr/src/uts/common/sys/Makefile index d0d808d459..5fe7393f56 100644 --- a/usr/src/uts/common/sys/Makefile +++ b/usr/src/uts/common/sys/Makefile @@ -368,6 +368,7 @@ CHKHDRS= \ miiregs.h \ mixer.h \ mman.h \ + mmapobj.h \ mntent.h \ mntio.h \ mnttab.h \ diff --git a/usr/src/uts/common/sys/mman.h b/usr/src/uts/common/sys/mman.h index a155d8d68b..1c8da540d1 100644 --- a/usr/src/uts/common/sys/mman.h +++ b/usr/src/uts/common/sys/mman.h @@ -40,8 +40,6 @@ #ifndef _SYS_MMAN_H #define _SYS_MMAN_H -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/feature_tests.h> #ifdef __cplusplus @@ -121,6 +119,71 @@ extern "C" { #include <sys/types.h> +#endif /* !_ASM && !_KERNEL */ + +/* External flags for mmapobj syscall (Exclusive of MAP_* flags above) */ +#define MMOBJ_PADDING 0x10000 +#define MMOBJ_INTERPRET 0x20000 + +#define MMOBJ_ALL_FLAGS (MMOBJ_PADDING | MMOBJ_INTERPRET) + +/* + * Values for mr_flags field of mmapobj_result_t below. + * The bottom 16 bits are mutually exclusive and thus only one + * of them can be set at a time. Use MR_GET_TYPE below to check this value. + * The top 16 bits are used for flags which are not mutually exclusive and + * thus more than one of these flags can be set for a given mmapobj_result_t. + * + * MR_PADDING being set indicates that this memory range represents the user + * requested padding. + * + * MR_HDR_ELF being set indicates that the ELF header of the mapped object + * is mapped at mr_addr + mr_offset. + * + * MR_HDR_AOUT being set indicates that the AOUT (4.x) header of the mapped + * object is mapped at mr_addr + mr_offset. + */ + +/* + * External flags for mr_flags field below. + */ +#define MR_PADDING 0x1 +#define MR_HDR_ELF 0x2 +#define MR_HDR_AOUT 0x3 + +/* + * Internal flags for mr_flags field below. + */ +#ifdef _KERNEL +#define MR_RESV 0x80000000 /* overmapped /dev/null */ +#endif /* _KERNEL */ + +#define MR_TYPE_MASK 0x0000ffff +#define MR_GET_TYPE(val) ((val) & MR_TYPE_MASK) + +#if !defined(_ASM) +typedef struct mmapobj_result { + caddr_t mr_addr; /* mapping address */ + size_t mr_msize; /* mapping size */ + size_t mr_fsize; /* file size */ + size_t mr_offset; /* offset into file */ + uint_t mr_prot; /* the protections provided */ + uint_t mr_flags; /* info on the mapping */ +} mmapobj_result_t; + +#if defined(_KERNEL) || defined(_SYSCALL32) +typedef struct mmapobj_result32 { + caddr32_t mr_addr; /* mapping address */ + size32_t mr_msize; /* mapping size */ + size32_t mr_fsize; /* file size */ + size32_t mr_offset; /* offset into file */ + uint_t mr_prot; /* the protections provided */ + uint_t mr_flags; /* info on the mapping */ +} mmapobj_result32_t; +#endif /* defined(_KERNEL) || defined(_SYSCALL32) */ +#endif /* !defined(_ASM) */ + +#if !defined(_ASM) && !defined(_KERNEL) /* * large file compilation environment setup * @@ -157,6 +220,7 @@ extern "C" { #ifdef __STDC__ #if (_POSIX_C_SOURCE > 2) || defined(_XPG4_2) extern void *mmap(void *, size_t, int, int, int, off_t); +extern int mmapobj(int, uint_t, void *, uint_t *, void *); extern int munmap(void *, size_t); extern int mprotect(void *, size_t, int); extern int msync(void *, size_t, int); @@ -172,6 +236,7 @@ extern void *mmap64(void *, size_t, int, int, int, off64_t); #else /* (_POSIX_C_SOURCE > 2) || defined(_XPG4_2) */ extern caddr_t mmap(caddr_t, size_t, int, int, int, off_t); extern int munmap(caddr_t, size_t); +extern int mmapobj(int, uint_t, mmapobj_result_t *, uint_t *, void *); extern int mprotect(caddr_t, size_t, int); extern int msync(caddr_t, size_t, int); extern int mlock(caddr_t, size_t); @@ -211,6 +276,7 @@ extern int posix_madvise(void *, size_t, int); #else /* __STDC__ */ extern caddr_t mmap(); extern int munmap(); +extern int mmapobj(); extern int mprotect(); extern int mincore(); extern int memcntl(); diff --git a/usr/src/uts/common/sys/mmapobj.h b/usr/src/uts/common/sys/mmapobj.h new file mode 100644 index 0000000000..fd3f8f16f4 --- /dev/null +++ b/usr/src/uts/common/sys/mmapobj.h @@ -0,0 +1,52 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_MMAPOBJ_H +#define _SYS_MMAPOBJ_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Number of mmapobj_result_t structures created on stack for quick allocation. + * More will be manually kmem_alloc'ed if needed. + * Should be enough for most ELF objects. + */ +#define LIBVA_CACHED_SEGS 3 + +#ifdef _KERNEL +extern void lib_va_init(void); +extern void mmapobj_unmap(mmapobj_result_t *, int, int, ushort_t); +#endif + +extern int mmapobj(vnode_t *, uint_t, mmapobj_result_t *, uint_t *, size_t, + cred_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MMAPOBJ_H */ diff --git a/usr/src/uts/common/sys/syscall.h b/usr/src/uts/common/sys/syscall.h index 779672e7f5..5b186aaf06 100644 --- a/usr/src/uts/common/sys/syscall.h +++ b/usr/src/uts/common/sys/syscall.h @@ -30,8 +30,6 @@ #ifndef _SYS_SYSCALL_H #define _SYS_SYSCALL_H -#pragma ident "%Z%%M% %I% %E% SMI" - #ifdef __cplusplus extern "C" { #endif @@ -319,6 +317,7 @@ extern "C" { #define SYS_lxstat 124 #define SYS_fxstat 125 #define SYS_xmknod 126 +#define SYS_mmapobj 127 #define SYS_setrlimit 128 #define SYS_getrlimit 129 #define SYS_lchown 130 diff --git a/usr/src/uts/common/sys/vmem.h b/usr/src/uts/common/sys/vmem.h index abcc8b26bc..a76d0fbed7 100644 --- a/usr/src/uts/common/sys/vmem.h +++ b/usr/src/uts/common/sys/vmem.h @@ -19,15 +19,13 @@ * CDDL HEADER END */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #ifndef _SYS_VMEM_H #define _SYS_VMEM_H -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/types.h> #ifdef __cplusplus @@ -62,6 +60,12 @@ extern "C" { */ #define VM_ABORT 0x00002000 +/* + * VM_ENDALLOC requests that large addresses be preferred in allocations. + * Has no effect if VM_NEXTFIT is active. + */ +#define VM_ENDALLOC 0x00004000 + #define VM_FLAGS 0x0000FFFF /* |