1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _S10_BRAND_H 27 #define _S10_BRAND_H 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif 32 33 #include <sys/types.h> 34 35 #define S10_BRANDNAME "solaris10" 36 37 #define S10_VERSION_1 1 38 #define S10_VERSION S10_VERSION_1 39 40 #define S10_NATIVE_DIR "/.SUNWnative/" 41 #define S10_LIB_NAME "s10_brand.so.1" 42 #define S10_LINKER_NAME "ld.so.1" 43 44 #define S10_LIB32 S10_NATIVE_DIR "usr/lib/" S10_LIB_NAME 45 #define S10_LINKER32 "/lib/" S10_LINKER_NAME 46 #define S10_NATIVE_LINKER32 S10_NATIVE_DIR "lib/" S10_LINKER_NAME 47 48 #define S10_LIB64 S10_NATIVE_DIR "usr/lib/64/" S10_LIB_NAME 49 #define S10_LINKER64 "/lib/64/" S10_LINKER_NAME 50 #define S10_NATIVE_LINKER64 S10_NATIVE_DIR "lib/64/" S10_LINKER_NAME 51 52 #if defined(_LP64) 53 #define S10_LIB S10_LIB64 54 #define S10_LINKER S10_LINKER64 55 #else /* !_LP64 */ 56 #define S10_LIB S10_LIB32 57 #define S10_LINKER S10_LINKER32 58 #endif /* !_LP64 */ 59 60 /* 61 * Brand system call subcodes. 0-127 are reserved for generic subcodes. 62 */ 63 #define B_S10_PIDINFO 128 64 #define B_S10_TRUSS_POINT 129 65 #define B_S10_NATIVE 130 66 #define B_S10_FSREGCORRECTION 131 67 #define B_S10_ISFDXATTRDIR 132 68 69 /* 70 * Versioning flags 71 * 72 * The first enum value must be zero. Place new enum values at the end of the 73 * list but before S10_NUM_EMUL_FEATURES, which must always come last. 74 * Enum values should start with "S10_FEATURE_" and be named after the 75 * fixes/backports that they represent. For example, an enum value representing 76 * a backport that changes a MNTFS ioctl could be named 77 * "S10_FEATURE_ALTERED_MNTFS_IOCTL". 78 */ 79 enum s10_emulated_features { 80 S10_FEATURE_ALTERED_MNTFS_IOCTL, 81 S10_NUM_EMUL_FEATURES /* This must be the last entry! */ 82 }; 83 84 /* 85 * This string constant represents the path of the Solaris 10 directory 86 * containing emulation feature files. 87 */ 88 #define S10_REQ_EMULATION_DIR "/usr/lib/brand/solaris10" 89 90 /* 91 * s10_brand_syscall_callback_common() needs to save 4 local registers so it 92 * can free them up for its own use. 93 */ 94 #define S10_CPU_REG_SAVE_SIZE (sizeof (ulong_t) * 4) 95 96 /* 97 * Aux vector containing lddata pointer of brand library linkmap. 98 * Used by s10_librtld_db. 99 */ 100 #define AT_SUN_BRAND_S10_LDDATA AT_SUN_BRAND_AUX1 101 102 /* 103 * S10 system call codes for S10 traps that have been removed or reassigned, 104 * or that are to be removed or reassigned after the dtrace syscall provider 105 * has been reengineered to deal properly with syscall::open (for example). 106 */ 107 #define S10_SYS_forkall 2 108 #define S10_SYS_open 5 109 #define S10_SYS_wait 7 110 #define S10_SYS_creat 8 111 #define S10_SYS_unlink 10 112 #define S10_SYS_exec 11 113 #define S10_SYS_chown 16 114 #define S10_SYS_stat 18 115 #define S10_SYS_umount 22 116 #define S10_SYS_fstat 28 117 #define S10_SYS_utime 30 118 #define S10_SYS_access 33 119 #define S10_SYS_dup 41 120 #define S10_SYS_issetugid 75 121 #define S10_SYS_fsat 76 122 #define S10_SYS_rmdir 79 123 #define S10_SYS_poll 87 124 #define S10_SYS_lstat 88 125 #define S10_SYS_fchown 94 126 #define S10_SYS_xstat 123 127 #define S10_SYS_lxstat 124 128 #define S10_SYS_fxstat 125 129 #define S10_SYS_xmknod 126 130 #define S10_SYS_lchown 130 131 #define S10_SYS_rename 134 132 #define S10_SYS_fork1 143 133 #define S10_SYS_lwp_sema_wait 147 134 #define S10_SYS_utimes 154 135 #define S10_SYS_lwp_mutex_lock 169 136 #define S10_SYS_stat64 215 137 #define S10_SYS_lstat64 216 138 #define S10_SYS_fstat64 217 139 #define S10_SYS_creat64 224 140 #define S10_SYS_open64 225 141 142 /* 143 * solaris10-brand-specific attributes 144 * These must start at ZONE_ATTR_BRAND_ATTRS. 145 */ 146 #define S10_EMUL_BITMAP ZONE_ATTR_BRAND_ATTRS 147 148 /* 149 * Information needed by the s10 library to launch an executable. 150 */ 151 typedef struct s10_elf_data { 152 ulong_t sed_phdr; 153 ulong_t sed_phent; 154 ulong_t sed_phnum; 155 ulong_t sed_entry; 156 ulong_t sed_base; 157 ulong_t sed_ldentry; 158 ulong_t sed_lddata; 159 } s10_elf_data_t; 160 161 /* 162 * Structure used to register a branded processes 163 */ 164 typedef struct s10_brand_reg { 165 uint_t sbr_version; /* version number */ 166 caddr_t sbr_handler; /* base address of handler */ 167 } s10_brand_reg_t; 168 169 /* 170 * s10_emul_bitmap represents an emulation feature bitmap. Each constant 171 * in s10_emulated_features defines a bit index in this bitmap. If a bit is 172 * set, then the feature associated with the s10_emulated_features constant 173 * whose value is the bit's index is present in the associated zone's hosted 174 * Solaris 10 environment. 175 * 176 * NOTE: There must be at least one byte in the bitmap. 177 * 178 * We don't use the bitmap macros provided by usr/src/uts/common/sys/bitmap.h 179 * because they operate on ulong_t arrays. The size of a ulong_t depends on 180 * the data model in which the code that declares the ulong_t is compiled: 181 * four bytes on 32-bit architectures and eight bytes 64-bit architectures. 182 * If the kernel is 64-bit and a 32-bit process executes in a solaris10- 183 * branded zone, then if the process' emulation library, which is 32-bit, 184 * queries the kernel for the zone's emulation bitmap, then the kernel will 185 * refuse because the library will request a bitmap that's half as big 186 * as the bitmap the kernel provides. The 32-bit emulation library would need 187 * its own macros to define and operate on bitmaps with 64-bit array elements. 188 * Thus using the sys/bitmap.h macros is probably more troublesome than 189 * defining and using our own constants and macros for bitmap manipulations. 190 */ 191 typedef uint8_t s10_emul_bitmap_t[(S10_NUM_EMUL_FEATURES >> 3) + 1]; 192 193 #if defined(_KERNEL) 194 #if defined(_SYSCALL32) 195 typedef struct s10_elf_data32 { 196 uint32_t sed_phdr; 197 uint32_t sed_phent; 198 uint32_t sed_phnum; 199 uint32_t sed_entry; 200 uint32_t sed_base; 201 uint32_t sed_ldentry; 202 uint32_t sed_lddata; 203 } s10_elf_data32_t; 204 205 typedef struct s10_brand_reg32 { 206 uint32_t sbr_version; /* version number */ 207 caddr32_t sbr_handler; /* base address of handler */ 208 } s10_brand_reg32_t; 209 #endif /* _SYSCALL32 */ 210 211 /* 212 * Information associated with all s10 branded processes 213 */ 214 typedef struct s10_proc_data { 215 caddr_t spd_handler; /* address of user-space handler */ 216 s10_elf_data_t spd_elf_data; /* ELF data for s10 application */ 217 } s10_proc_data_t; 218 219 /* brand specific data */ 220 typedef struct s10_zone_data { 221 /* 222 * emul_bitmap specifies the features that are present in the 223 * associated zone. 224 */ 225 s10_emul_bitmap_t emul_bitmap; 226 } s10_zone_data_t; 227 228 void s10_brand_syscall_callback(void); 229 void s10_brand_syscall32_callback(void); 230 231 #if !defined(sparc) 232 void s10_brand_sysenter_callback(void); 233 #endif /* !sparc */ 234 235 #if defined(__amd64) 236 void s10_brand_int91_callback(void); 237 #endif /* __amd64 */ 238 #endif /* _KERNEL */ 239 240 #ifdef __cplusplus 241 } 242 #endif 243 244 #endif /* _S10_BRAND_H */ 245