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.
26 #include <sys/errno.h>
29 #include <sys/modctl.h>
30 #include <sys/model.h>
32 #include <sys/syscall.h>
33 #include <sys/systm.h>
34 #include <sys/thread.h>
35 #include <sys/cmn_err.h>
36 #include <sys/archsystm.h>
37 #include <sys/pathname.h>
39 #include <sys/machbrand.h>
40 #include <sys/brand.h>
41 #include "sn1_brand.h"
43 char *sn1_emulation_table
= NULL
;
45 void sn1_init_brand_data(zone_t
*);
46 void sn1_free_brand_data(zone_t
*);
47 void sn1_setbrand(proc_t
*);
48 int sn1_getattr(zone_t
*, int, void *, size_t *);
49 int sn1_setattr(zone_t
*, int, void *, size_t);
50 int sn1_brandsys(int, int64_t *, uintptr_t, uintptr_t, uintptr_t,
51 uintptr_t, uintptr_t, uintptr_t);
52 void sn1_copy_procdata(proc_t
*, proc_t
*);
53 void sn1_proc_exit(struct proc
*, klwp_t
*);
55 int sn1_initlwp(klwp_t
*);
56 void sn1_forklwp(klwp_t
*, klwp_t
*);
57 void sn1_freelwp(klwp_t
*);
58 void sn1_lwpexit(klwp_t
*);
59 int sn1_elfexec(vnode_t
*, execa_t
*, uarg_t
*, intpdata_t
*, int,
60 long *, int, caddr_t
, cred_t
*, int);
63 struct brand_ops sn1_brops
= {
86 struct brand_mach_ops sn1_mops
= {
87 sn1_brand_syscall_callback
,
88 sn1_brand_syscall32_callback
95 struct brand_mach_ops sn1_mops
= {
96 sn1_brand_sysenter_callback
,
97 sn1_brand_int91_callback
,
98 sn1_brand_syscall_callback
,
99 sn1_brand_syscall32_callback
102 #else /* ! __amd64 */
104 struct brand_mach_ops sn1_mops
= {
105 sn1_brand_sysenter_callback
,
107 sn1_brand_syscall_callback
,
114 struct brand sn1_brand
= {
121 static struct modlbrand modlbrand
= {
122 &mod_brandops
, /* type of module */
123 "Solaris N-1 Brand", /* description of module */
124 &sn1_brand
/* driver ops */
127 static struct modlinkage modlinkage
= {
128 MODREV_1
, (void *)&modlbrand
, NULL
132 sn1_setbrand(proc_t
*p
)
134 brand_solaris_setbrand(p
, &sn1_brand
);
139 sn1_getattr(zone_t
*zone
, int attr
, void *buf
, size_t *bufsize
)
146 sn1_setattr(zone_t
*zone
, int attr
, void *buf
, size_t bufsize
)
153 sn1_brandsys(int cmd
, int64_t *rval
, uintptr_t arg1
, uintptr_t arg2
,
154 uintptr_t arg3
, uintptr_t arg4
, uintptr_t arg5
, uintptr_t arg6
)
160 res
= brand_solaris_cmd(cmd
, arg1
, arg2
, arg3
, &sn1_brand
, SN1_VERSION
);
168 sn1_copy_procdata(proc_t
*child
, proc_t
*parent
)
170 brand_solaris_copy_procdata(child
, parent
, &sn1_brand
);
174 sn1_proc_exit(struct proc
*p
, klwp_t
*l
)
176 brand_solaris_proc_exit(p
, l
, &sn1_brand
);
182 brand_solaris_exec(&sn1_brand
);
186 sn1_initlwp(klwp_t
*l
)
188 return (brand_solaris_initlwp(l
, &sn1_brand
));
192 sn1_forklwp(klwp_t
*p
, klwp_t
*c
)
194 brand_solaris_forklwp(p
, c
, &sn1_brand
);
198 sn1_freelwp(klwp_t
*l
)
200 brand_solaris_freelwp(l
, &sn1_brand
);
204 sn1_lwpexit(klwp_t
*l
)
206 brand_solaris_lwpexit(l
, &sn1_brand
);
211 sn1_free_brand_data(zone_t
*zone
)
217 sn1_init_brand_data(zone_t
*zone
)
222 sn1_elfexec(vnode_t
*vp
, execa_t
*uap
, uarg_t
*args
, intpdata_t
*idatap
,
223 int level
, long *execsz
, int setid
, caddr_t exec_file
, cred_t
*cred
,
226 return (brand_solaris_elfexec(vp
, uap
, args
, idatap
, level
, execsz
,
227 setid
, exec_file
, cred
, brand_action
, &sn1_brand
, SN1_BRANDNAME
,
228 SN1_LIB
, SN1_LIB32
, SN1_LINKER
, SN1_LINKER32
));
237 * Set up the table indicating which system calls we want to
238 * interpose on. We should probably build this automatically from
239 * a list of system calls that is shared with the user-space
242 sn1_emulation_table
= kmem_zalloc(NSYSCALL
, KM_SLEEP
);
243 sn1_emulation_table
[SYS_read
] = 1; /* 3 */
244 sn1_emulation_table
[SYS_write
] = 1; /* 4 */
245 sn1_emulation_table
[SYS_time
] = 1; /* 13 */
246 sn1_emulation_table
[SYS_getpid
] = 1; /* 20 */
247 sn1_emulation_table
[SYS_mount
] = 1; /* 21 */
248 sn1_emulation_table
[SYS_getuid
] = 1; /* 24 */
249 sn1_emulation_table
[SYS_times
] = 1; /* 43 */
250 sn1_emulation_table
[SYS_getgid
] = 1; /* 47 */
251 sn1_emulation_table
[SYS_utssys
] = 1; /* 57 */
252 sn1_emulation_table
[SYS_waitid
] = 1; /* 107 */
253 sn1_emulation_table
[SYS_uname
] = 1; /* 135 */
255 err
= mod_install(&modlinkage
);
257 cmn_err(CE_WARN
, "Couldn't install brand module");
258 kmem_free(sn1_emulation_table
, NSYSCALL
);
265 _info(struct modinfo
*modinfop
)
267 return (mod_info(&modlinkage
, modinfop
));
273 return (brand_solaris_fini(&sn1_emulation_table
, &modlinkage
,