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.
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.
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]
23 * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
35 #include <sys/modctl.h>
36 #include <sys/types.h>
39 * All Brands supported by this kernel must use BRAND_VER_1.
44 * sub-commands to brandsys.
45 * 1 - 128 are for common commands
46 * 128+ are available for brand-specific commands.
51 #define B_EXEC_NATIVE 4
52 #define B_EXEC_BRAND 5
53 #define B_TRUSS_POINT 6
56 * Structure used by zoneadmd to communicate the name of a brand and the
57 * supporting brand module into the kernel.
60 char ba_brandname
[MAXNAMELEN
];
61 char ba_modname
[MAXPATHLEN
];
64 /* What we call the native brand. */
65 #define NATIVE_BRAND_NAME "native"
68 * Aux vector containing lddata pointer of brand library linkmap.
69 * Used by common {brand}_librtld_db.
71 #define AT_SUN_BRAND_COMMON_LDDATA AT_SUN_BRAND_AUX1
74 * Information needed by the brand library to launch an executable.
76 typedef struct brand_elf_data
{
87 * Common structure used to register a branded processes
89 typedef struct brand_proc_reg
{
90 uint_t sbr_version
; /* version number */
91 caddr_t sbr_handler
; /* base address of handler */
98 struct brand_mach_ops
;
103 void (*b_init_brand_data
)(zone_t
*);
104 void (*b_free_brand_data
)(zone_t
*);
105 int (*b_brandsys
)(int, int64_t *, uintptr_t, uintptr_t, uintptr_t,
106 uintptr_t, uintptr_t, uintptr_t);
107 void (*b_setbrand
)(struct proc
*);
108 int (*b_getattr
)(zone_t
*, int, void *, size_t *);
109 int (*b_setattr
)(zone_t
*, int, void *, size_t);
110 void (*b_copy_procdata
)(struct proc
*, struct proc
*);
111 void (*b_proc_exit
)(struct proc
*, klwp_t
*);
113 void (*b_lwp_setrval
)(klwp_t
*, int, int);
114 int (*b_initlwp
)(klwp_t
*);
115 void (*b_forklwp
)(klwp_t
*, klwp_t
*);
116 void (*b_freelwp
)(klwp_t
*);
117 void (*b_lwpexit
)(klwp_t
*);
118 int (*b_elfexec
)(struct vnode
*vp
, struct execa
*uap
,
119 struct uarg
*args
, struct intpdata
*idata
, int level
,
120 long *execsz
, int setid
, caddr_t exec_file
,
121 struct cred
*cred
, int brand_action
);
122 void (*b_sigset_native_to_brand
)(sigset_t
*);
123 void (*b_sigset_brand_to_native
)(sigset_t
*);
128 * The b_version field must always be the first entry in this struct.
130 typedef struct brand
{
133 struct brand_ops
*b_ops
;
134 struct brand_mach_ops
*b_machops
;
137 extern brand_t native_brand
;
142 #define lwptolwpbrand(l) ((l)->lwp_brand)
143 #define ttolwpbrand(t) (lwptolwpbrand(ttolwp(t)))
144 #define PROC_IS_BRANDED(p) ((p)->p_brand != &native_brand)
145 #define ZONE_IS_BRANDED(z) ((z)->zone_brand != &native_brand)
146 #define BROP(p) ((p)->p_brand->b_ops)
147 #define ZBROP(z) ((z)->zone_brand->b_ops)
148 #define BRMOP(p) ((p)->p_brand->b_machops)
149 #define SIGSET_NATIVE_TO_BRAND(sigset) \
150 if (PROC_IS_BRANDED(curproc) && \
151 BROP(curproc)->b_sigset_native_to_brand) \
152 BROP(curproc)->b_sigset_native_to_brand(sigset)
153 #define SIGSET_BRAND_TO_NATIVE(sigset) \
154 if (PROC_IS_BRANDED(curproc) && \
155 BROP(curproc)->b_sigset_brand_to_native) \
156 BROP(curproc)->b_sigset_brand_to_native(sigset)
158 extern void brand_init();
159 extern int brand_register(brand_t
*);
160 extern int brand_unregister(brand_t
*);
161 extern brand_t
*brand_register_zone(struct brand_attr
*);
162 extern brand_t
*brand_find_name(char *);
163 extern void brand_unregister_zone(brand_t
*);
164 extern int brand_zone_count(brand_t
*);
165 extern void brand_setbrand(proc_t
*);
166 extern void brand_clearbrand(proc_t
*, boolean_t
);
169 * The following functions can be shared among kernel brand modules which
170 * implement Solaris-derived brands, all of which need to do similar tasks to
173 extern int brand_solaris_cmd(int, uintptr_t, uintptr_t, uintptr_t,
174 struct brand
*, int);
175 extern void brand_solaris_copy_procdata(proc_t
*, proc_t
*,
177 extern int brand_solaris_elfexec(vnode_t
*, execa_t
*, uarg_t
*,
178 intpdata_t
*, int, long *, int, caddr_t
, cred_t
*, int,
179 struct brand
*, char *, char *, char *, char *, char *);
180 extern void brand_solaris_exec(struct brand
*);
181 extern int brand_solaris_fini(char **, struct modlinkage
*,
183 extern void brand_solaris_forklwp(klwp_t
*, klwp_t
*, struct brand
*);
184 extern void brand_solaris_freelwp(klwp_t
*, struct brand
*);
185 extern int brand_solaris_initlwp(klwp_t
*, struct brand
*);
186 extern void brand_solaris_lwpexit(klwp_t
*, struct brand
*);
187 extern void brand_solaris_proc_exit(struct proc
*, klwp_t
*,
189 extern void brand_solaris_setbrand(proc_t
*, struct brand
*);
191 #if defined(_SYSCALL32)
192 typedef struct brand_elf_data32
{
198 uint32_t sed_ldentry
;
200 } brand_elf_data32_t
;
202 typedef struct brand_common_reg32
{
203 uint32_t sbr_version
; /* version number */
204 caddr32_t sbr_handler
; /* base address of handler */
205 } brand_common_reg32_t
;
206 #endif /* _SYSCALL32 */
209 * Common information associated with all branded processes
211 typedef struct brand_proc_data
{
212 caddr_t spd_handler
; /* address of user-space handler */
213 brand_elf_data_t spd_elf_data
; /* common ELF data for branded app. */
216 #define BRAND_NATIVE_DIR "/.SUNWnative/"
217 #define BRAND_NATIVE_LINKER32 BRAND_NATIVE_DIR "lib/ld.so.1"
218 #define BRAND_NATIVE_LINKER64 BRAND_NATIVE_DIR "lib/64/ld.so.1"
226 #endif /* _SYS_BRAND_H */