Print this page
Reduce lint
OS-5462 lxbrand kernel should be lint clean
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
OS-5354 lx shebang argument handling is incorrect
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
OS-5189 lx dev enumeration can deadlock with zfs
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
OS-4937 lxbrand ptracer count updates can race
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Joshua M. Clulow <jmc@joyent.com>
OS-3742 lxbrand add support for signalfd
OS-4382 remove obsolete brand hooks added during lx development
OS-4306 lxbrand setsockopt(IP_MULTICAST_TTL) handles optlen poorly
OS-4303 lxbrand ltp ptrace05 fails
Reviewed by: Joshua M. Clulow <jmc@joyent.com>
OS-4188 NULL dereference in lwp_hash_in
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Joshua M. Clulow <jmc@joyent.com>
OS-4119 lxbrand panic when running native perl inside lx zone
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
OS-4151 setbrand hooks should be sane during fork
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Joshua M. Clulow <jmc@joyent.com>
OS-4129 lxbrand should not abuse p_brand_data for storing exit signal
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Joshua M. Clulow <jmc@joyent.com>
OS-3825 lxbrand rsyslogd abort on centos6
OS-4047 lxbrand vsyscall while SIGSEGV? on next trap we're handler-free!
Reviewed by: Bryan Cantrill <bryan@joyent.com>
OS-3926 lxbrand in-kernel fchownat(2), fchown(2), lchown(2), chown(2) and 16-bit ID counterparts
OS-3920 lxbrand use native *at(2) system calls for LX emulation
OS-3561 lxbrand emulation library should execute on alternate stack
OS-3558 lxbrand add support for full in-kernel syscall handling
OS-3545 lx_syscall_regs should not walk stack
OS-3868 many LTP testcases now hang
OS-3901 lxbrand lx_recvmsg fails to translate control messages when 64-bit
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Reviewed by: Bryan Cantrill <bryan@joyent.com>
OS-3712 lx brand: DTrace pid provider induces core dumps on 64-bit processes
OS-3594 lx brand: need support for MAP_32BIT
OS-3554 lx brand: node.js test test-fs-append-file.js hangs on 64-bit
OS-3517 lx brand: branded zones don't interpret .interp section
OS-2844 lx brand should support 64-bit user-land
OS-3280 need a way to specify the root of a native system in the lx brand
OS-3279 lx brand should allow delegated datasets
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
OS-3149 lx brand always sends SIGCHLD to parent processes, regardless of how clone was invoked
OS-2887 lxbrand add WALL, WCLONE, WNOTHREAD support to waitid
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
OS-2834 ship lx brand
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/uts/common/brand/solaris10/s10_brand.c
+++ new/usr/src/uts/common/brand/solaris10/s10_brand.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
↓ open down ↓ |
14 lines elided |
↑ open up ↑ |
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved.
24 24 * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
25 + * Copyright 2016, Joyent, Inc.
25 26 */
26 27
27 28 #include <sys/errno.h>
28 29 #include <sys/exec.h>
29 30 #include <sys/file.h>
30 31 #include <sys/kmem.h>
31 32 #include <sys/modctl.h>
32 33 #include <sys/model.h>
33 34 #include <sys/proc.h>
34 35 #include <sys/syscall.h>
35 36 #include <sys/systm.h>
36 37 #include <sys/thread.h>
37 38 #include <sys/cmn_err.h>
|
↓ open down ↓ |
3 lines elided |
↑ open up ↑ |
38 39 #include <sys/archsystm.h>
39 40 #include <sys/pathname.h>
40 41 #include <sys/sunddi.h>
41 42
42 43 #include <sys/machbrand.h>
43 44 #include <sys/brand.h>
44 45 #include "s10_brand.h"
45 46
46 47 char *s10_emulation_table = NULL;
47 48
48 -void s10_init_brand_data(zone_t *);
49 +void s10_init_brand_data(zone_t *, kmutex_t *);
49 50 void s10_free_brand_data(zone_t *);
50 51 void s10_setbrand(proc_t *);
51 52 int s10_getattr(zone_t *, int, void *, size_t *);
52 53 int s10_setattr(zone_t *, int, void *, size_t);
53 54 int s10_brandsys(int, int64_t *, uintptr_t, uintptr_t, uintptr_t,
54 - uintptr_t, uintptr_t, uintptr_t);
55 + uintptr_t);
55 56 void s10_copy_procdata(proc_t *, proc_t *);
56 -void s10_proc_exit(struct proc *, klwp_t *);
57 +void s10_proc_exit(struct proc *);
57 58 void s10_exec();
58 -int s10_initlwp(klwp_t *);
59 +void s10_initlwp(klwp_t *, void *);
59 60 void s10_forklwp(klwp_t *, klwp_t *);
60 61 void s10_freelwp(klwp_t *);
61 62 void s10_lwpexit(klwp_t *);
62 63 int s10_elfexec(vnode_t *, execa_t *, uarg_t *, intpdata_t *, int,
63 - long *, int, caddr_t, cred_t *, int);
64 + long *, int, caddr_t, cred_t *, int *);
64 65 void s10_sigset_native_to_s10(sigset_t *);
65 66 void s10_sigset_s10_to_native(sigset_t *);
66 67
67 68 /* s10 brand */
68 69 struct brand_ops s10_brops = {
69 - s10_init_brand_data,
70 - s10_free_brand_data,
71 - s10_brandsys,
72 - s10_setbrand,
73 - s10_getattr,
74 - s10_setattr,
75 - s10_copy_procdata,
76 - s10_proc_exit,
77 - s10_exec,
78 - lwp_setrval,
79 - s10_initlwp,
80 - s10_forklwp,
81 - s10_freelwp,
82 - s10_lwpexit,
83 - s10_elfexec,
84 - s10_sigset_native_to_s10,
85 - s10_sigset_s10_to_native,
86 - S10_NSIG,
70 + s10_init_brand_data, /* b_init_brand_data */
71 + s10_free_brand_data, /* b_free_brand_data */
72 + s10_brandsys, /* b_brandsys */
73 + s10_setbrand, /* b_setbrand */
74 + s10_getattr, /* b_getattr */
75 + s10_setattr, /* b_setattr */
76 + s10_copy_procdata, /* b_copy_procdata */
77 + s10_proc_exit, /* b_proc_exit */
78 + s10_exec, /* b_exec */
79 + lwp_setrval, /* b_lwp_setrval */
80 + NULL, /* b_lwpdata_alloc */
81 + NULL, /* b_lwpdata_free */
82 + s10_initlwp, /* b_initlwp */
83 + NULL, /* b_initlwp_post */
84 + s10_forklwp, /* b_forklwp */
85 + s10_freelwp, /* b_freelwp */
86 + s10_lwpexit, /* b_lwpexit */
87 + s10_elfexec, /* b_elfexec */
88 + s10_sigset_native_to_s10, /* b_sigset_native_to_brand */
89 + s10_sigset_s10_to_native, /* b_sigset_brand_to_native */
90 + NULL, /* b_sigfd_translate */
91 + S10_NSIG, /* b_nsig */
92 + NULL, /* b_exit_with_sig */
93 + NULL, /* b_wait_filter */
94 + NULL, /* b_native_exec */
95 + NULL, /* b_map32limit */
96 + NULL, /* b_stop_notify */
97 + NULL, /* b_waitid_helper */
98 + NULL, /* b_sigcld_repost */
99 + NULL, /* b_issig_stop */
100 + NULL, /* b_sig_ignorable */
101 + NULL, /* b_savecontext */
102 +#if defined(_SYSCALL32_IMPL)
103 + NULL, /* b_savecontext32 */
104 +#endif
105 + NULL, /* b_restorecontext */
106 + NULL, /* b_sendsig_stack */
107 + NULL, /* b_sendsig */
108 + NULL, /* b_setid_clear */
109 + NULL, /* b_pagefault */
110 + B_TRUE /* b_intp_parse_arg */
87 111 };
88 112
89 113 #ifdef sparc
90 114
91 115 struct brand_mach_ops s10_mops = {
92 116 s10_brand_syscall_callback,
93 117 s10_brand_syscall32_callback
94 118 };
95 119
96 120 #else /* sparc */
97 121
98 122 #ifdef __amd64
99 123
100 124 struct brand_mach_ops s10_mops = {
101 125 s10_brand_sysenter_callback,
126 + NULL,
102 127 s10_brand_int91_callback,
103 128 s10_brand_syscall_callback,
104 - s10_brand_syscall32_callback
129 + s10_brand_syscall32_callback,
130 + NULL,
131 + NULL
105 132 };
106 133
107 134 #else /* ! __amd64 */
108 135
109 136 struct brand_mach_ops s10_mops = {
110 137 s10_brand_sysenter_callback,
111 138 NULL,
139 + NULL,
112 140 s10_brand_syscall_callback,
141 + NULL,
142 + NULL,
113 143 NULL
114 144 };
115 145 #endif /* __amd64 */
116 146
117 147 #endif /* _sparc */
118 148
119 149 struct brand s10_brand = {
120 150 BRAND_VER_1,
121 151 "solaris10",
122 152 &s10_brops,
123 - &s10_mops
153 + &s10_mops,
154 + sizeof (brand_proc_data_t),
124 155 };
125 156
126 157 static struct modlbrand modlbrand = {
127 158 &mod_brandops, /* type of module */
128 159 "Solaris 10 Brand", /* description of module */
129 160 &s10_brand /* driver ops */
130 161 };
131 162
132 163 static struct modlinkage modlinkage = {
133 164 MODREV_1, (void *)&modlbrand, NULL
134 165 };
135 166
136 167 void
137 168 s10_setbrand(proc_t *p)
138 169 {
139 170 brand_solaris_setbrand(p, &s10_brand);
140 171 }
141 172
142 173 /*ARGSUSED*/
143 174 int
144 175 s10_getattr(zone_t *zone, int attr, void *buf, size_t *bufsize)
145 176 {
146 177 ASSERT(zone->zone_brand == &s10_brand);
147 178 if (attr == S10_EMUL_BITMAP) {
148 179 if (buf == NULL || *bufsize != sizeof (s10_emul_bitmap_t))
149 180 return (EINVAL);
150 181 if (copyout(((s10_zone_data_t *)zone->zone_brand_data)->
151 182 emul_bitmap, buf, sizeof (s10_emul_bitmap_t)) != 0)
152 183 return (EFAULT);
153 184 return (0);
154 185 }
155 186
156 187 return (EINVAL);
157 188 }
158 189
159 190 int
160 191 s10_setattr(zone_t *zone, int attr, void *buf, size_t bufsize)
161 192 {
162 193 ASSERT(zone->zone_brand == &s10_brand);
163 194 if (attr == S10_EMUL_BITMAP) {
164 195 if (buf == NULL || bufsize != sizeof (s10_emul_bitmap_t))
165 196 return (EINVAL);
166 197 if (copyin(buf, ((s10_zone_data_t *)zone->zone_brand_data)->
167 198 emul_bitmap, sizeof (s10_emul_bitmap_t)) != 0)
168 199 return (EFAULT);
169 200 return (0);
170 201 }
171 202
172 203 return (EINVAL);
173 204 }
174 205
175 206 #ifdef __amd64
176 207 /*
177 208 * The Nevada kernel clears %fs for threads in 64-bit x86 processes but S10's
178 209 * libc expects %fs to be nonzero. This causes some committed
179 210 * libc/libthread interfaces (e.g., thr_main()) to fail, which impacts several
180 211 * libraries, including libdoor. This function sets the specified LWP's %fs
181 212 * register to the legacy S10 selector value (LWPFS_SEL).
182 213 *
183 214 * The best solution to the aforementioned problem is backporting CRs
184 215 * 6467491 to Solaris 10 so that 64-bit x86 Solaris 10 processes
185 216 * would accept zero for %fs. Backporting the CRs is a requirement for running
186 217 * S10 Containers in PV domUs because 64-bit Xen clears %fsbase when %fs is
187 218 * nonzero. Such behavior breaks 64-bit processes because Xen has to fetch the
188 219 * FS segments' base addresses from the LWPs' GDTs, which are only capable of
189 220 * 32-bit addressing.
190 221 */
191 222 /*ARGSUSED*/
192 223 static void
193 224 s10_amd64_correct_fsreg(klwp_t *l)
194 225 {
195 226 if (lwp_getdatamodel(l) == DATAMODEL_NATIVE) {
196 227 kpreempt_disable();
197 228 l->lwp_pcb.pcb_fs = LWPFS_SEL;
198 229 l->lwp_pcb.pcb_rupdate = 1;
199 230 lwptot(l)->t_post_sys = 1; /* Guarantee update_sregs() */
200 231 kpreempt_enable();
201 232 }
202 233 }
203 234 #endif /* __amd64 */
204 235
205 236 /*
206 237 * Native processes are started with the native ld.so.1 as the command. This
207 238 * brand op is invoked by s10_npreload to fix up the command and arguments
208 239 * so that apps like pgrep or ps see the expected command strings.
209 240 */
210 241 int
211 242 s10_native(void *cmd, void *args)
212 243 {
213 244 struct user *up = PTOU(curproc);
214 245 char cmd_buf[MAXCOMLEN + 1];
215 246 char arg_buf[PSARGSZ];
216 247
217 248 if (copyin(cmd, &cmd_buf, sizeof (cmd_buf)) != 0)
218 249 return (EFAULT);
219 250 if (copyin(args, &arg_buf, sizeof (arg_buf)) != 0)
220 251 return (EFAULT);
221 252
222 253 /*
223 254 * Make sure that the process' interpreter is the native dynamic linker.
224 255 * Convention dictates that native processes executing within solaris10-
225 256 * branded zones are interpreted by the native dynamic linker (the
226 257 * process and its arguments are specified as arguments to the dynamic
227 258 * linker). If this convention is violated (i.e.,
228 259 * brandsys(B_S10_NATIVE, ...) is invoked by a process that shouldn't be
229 260 * native), then do nothing and silently indicate success.
230 261 */
231 262 if (strcmp(up->u_comm, S10_LINKER_NAME) != 0)
232 263 return (0);
233 264
234 265 /*
235 266 * The sizeof has an extra value for the trailing '\0' so this covers
236 267 * the appended " " in the following strcmps.
237 268 */
238 269 if (strncmp(up->u_psargs, BRAND_NATIVE_LINKER64 " ",
239 270 sizeof (BRAND_NATIVE_LINKER64)) != 0 &&
240 271 strncmp(up->u_psargs, BRAND_NATIVE_LINKER32 " ",
241 272 sizeof (BRAND_NATIVE_LINKER32)) != 0)
|
↓ open down ↓ |
108 lines elided |
↑ open up ↑ |
242 273 return (0);
243 274
244 275 mutex_enter(&curproc->p_lock);
245 276 (void) strlcpy(up->u_comm, cmd_buf, sizeof (up->u_comm));
246 277 (void) strlcpy(up->u_psargs, arg_buf, sizeof (up->u_psargs));
247 278 mutex_exit(&curproc->p_lock);
248 279
249 280 return (0);
250 281 }
251 282
252 -/*ARGSUSED*/
283 +/* ARGSUSED5 */
253 284 int
254 285 s10_brandsys(int cmd, int64_t *rval, uintptr_t arg1, uintptr_t arg2,
255 - uintptr_t arg3, uintptr_t arg4, uintptr_t arg5, uintptr_t arg6)
286 + uintptr_t arg3, uintptr_t arg4)
256 287 {
257 288 proc_t *p = curproc;
258 289 int res;
259 290
260 291 *rval = 0;
261 292
262 293 if (cmd == B_S10_NATIVE)
263 294 return (s10_native((void *)arg1, (void *)arg2));
264 295
265 296 res = brand_solaris_cmd(cmd, arg1, arg2, arg3, &s10_brand, S10_VERSION);
266 297 if (res >= 0)
267 298 return (res);
268 299
269 300 switch ((cmd)) {
270 301 case B_S10_PIDINFO:
271 302 /*
272 303 * The s10 brand needs to be able to get the pid of the
273 304 * current process and the pid of the zone's init, and it
274 305 * needs to do this on every process startup. Early in
275 306 * brand startup, we can't call getpid() because calls to
276 307 * getpid() represent a magical signal to some old-skool
277 308 * debuggers. By merging all of this into one call, we
278 309 * make this quite a bit cheaper and easier to handle in
279 310 * the brand module.
280 311 */
281 312 if (copyout(&p->p_pid, (void *)arg1, sizeof (pid_t)) != 0)
282 313 return (EFAULT);
283 314 if (copyout(&p->p_zone->zone_proc_initpid, (void *)arg2,
284 315 sizeof (pid_t)) != 0)
285 316 return (EFAULT);
286 317 return (0);
287 318
288 319 case B_S10_ISFDXATTRDIR: {
289 320 /*
290 321 * This subcommand enables the userland brand emulation library
291 322 * to determine whether a file descriptor refers to an extended
292 323 * file attributes directory. There is no standard syscall or
293 324 * libc function that can make such a determination.
294 325 */
295 326 file_t *dir_filep;
296 327
297 328 dir_filep = getf((int)arg1);
298 329 if (dir_filep == NULL)
299 330 return (EBADF);
300 331 ASSERT(dir_filep->f_vnode != NULL);
301 332 *rval = IS_XATTRDIR(dir_filep->f_vnode);
302 333 releasef((int)arg1);
303 334 return (0);
304 335 }
305 336
306 337 #ifdef __amd64
307 338 case B_S10_FSREGCORRECTION:
308 339 /*
309 340 * This subcommand exists so that the SYS_lwp_private and
310 341 * SYS_lwp_create syscalls can manually set the current thread's
311 342 * %fs register to the legacy S10 selector value for 64-bit x86
312 343 * processes.
313 344 */
314 345 s10_amd64_correct_fsreg(ttolwp(curthread));
315 346 return (0);
316 347 #endif /* __amd64 */
317 348 }
318 349
|
↓ open down ↓ |
53 lines elided |
↑ open up ↑ |
319 350 return (EINVAL);
320 351 }
321 352
322 353 void
323 354 s10_copy_procdata(proc_t *child, proc_t *parent)
324 355 {
325 356 brand_solaris_copy_procdata(child, parent, &s10_brand);
326 357 }
327 358
328 359 void
329 -s10_proc_exit(struct proc *p, klwp_t *l)
360 +s10_proc_exit(struct proc *p)
330 361 {
331 - brand_solaris_proc_exit(p, l, &s10_brand);
362 + brand_solaris_proc_exit(p, &s10_brand);
332 363 }
333 364
334 365 void
335 366 s10_exec()
336 367 {
337 368 brand_solaris_exec(&s10_brand);
338 369 }
339 370
340 -int
341 -s10_initlwp(klwp_t *l)
371 +/* ARGSUSED */
372 +void
373 +s10_initlwp(klwp_t *l, void *bd)
342 374 {
343 - return (brand_solaris_initlwp(l, &s10_brand));
375 + brand_solaris_initlwp(l, &s10_brand);
344 376 }
345 377
346 378 void
347 379 s10_forklwp(klwp_t *p, klwp_t *c)
348 380 {
349 381 brand_solaris_forklwp(p, c, &s10_brand);
350 382
351 383 #ifdef __amd64
352 384 /*
353 385 * Only correct the child's %fs register if the parent's %fs register
354 386 * is LWPFS_SEL. If the parent's %fs register is zero, then the Solaris
355 387 * 10 environment that we're emulating uses a version of libc that
356 388 * works when %fs is zero (i.e., it contains backports of CRs 6467491
357 389 * and 6501650).
358 390 */
359 391 if (p->lwp_pcb.pcb_fs == LWPFS_SEL)
360 392 s10_amd64_correct_fsreg(c);
361 393 #endif /* __amd64 */
362 394 }
363 395
364 396 void
365 397 s10_freelwp(klwp_t *l)
366 398 {
367 399 brand_solaris_freelwp(l, &s10_brand);
368 400 }
369 401
370 402 void
371 403 s10_lwpexit(klwp_t *l)
|
↓ open down ↓ |
18 lines elided |
↑ open up ↑ |
372 404 {
373 405 brand_solaris_lwpexit(l, &s10_brand);
374 406 }
375 407
376 408 void
377 409 s10_free_brand_data(zone_t *zone)
378 410 {
379 411 kmem_free(zone->zone_brand_data, sizeof (s10_zone_data_t));
380 412 }
381 413
414 +/* ARGSUSED */
382 415 void
383 -s10_init_brand_data(zone_t *zone)
416 +s10_init_brand_data(zone_t *zone, kmutex_t *zsl)
384 417 {
385 418 ASSERT(zone->zone_brand == &s10_brand);
386 419 ASSERT(zone->zone_brand_data == NULL);
387 420 zone->zone_brand_data = kmem_zalloc(sizeof (s10_zone_data_t), KM_SLEEP);
388 421 }
389 422
390 423 int
391 424 s10_elfexec(vnode_t *vp, execa_t *uap, uarg_t *args, intpdata_t *idatap,
392 - int level, long *execsz, int setid, caddr_t exec_file, cred_t *cred,
393 - int brand_action)
425 + int level, long *execsz, int setid, caddr_t exec_file, cred_t *cred,
426 + int *brand_action)
394 427 {
395 428 return (brand_solaris_elfexec(vp, uap, args, idatap, level, execsz,
396 429 setid, exec_file, cred, brand_action, &s10_brand, S10_BRANDNAME,
397 - S10_LIB, S10_LIB32, S10_LINKER, S10_LINKER32));
430 + S10_LIB, S10_LIB32));
398 431 }
399 432
400 433 void
401 434 s10_sigset_native_to_s10(sigset_t *set)
402 435 {
403 436 int nativesig;
404 437 int s10sig;
405 438 sigset_t s10set;
406 439
407 440 /*
408 441 * Shortcut: we know the first 32 signals are the same in both
409 442 * s10 and native Solaris. Just assign the first word.
410 443 */
411 444 s10set.__sigbits[0] = set->__sigbits[0];
412 445 s10set.__sigbits[1] = 0;
413 446 s10set.__sigbits[2] = 0;
414 447 s10set.__sigbits[3] = 0;
415 448
416 449 /*
417 450 * Copy the remainder of the initial set of common signals.
418 451 */
419 452 for (nativesig = 33; nativesig < S10_SIGRTMIN; nativesig++)
420 453 if (sigismember(set, nativesig))
421 454 sigaddset(&s10set, nativesig);
422 455
423 456 /*
424 457 * Convert any native RT signals to their S10 values.
425 458 */
426 459 for (nativesig = _SIGRTMIN, s10sig = S10_SIGRTMIN;
427 460 nativesig <= _SIGRTMAX && s10sig <= S10_SIGRTMAX;
428 461 nativesig++, s10sig++) {
429 462 if (sigismember(set, nativesig))
430 463 sigaddset(&s10set, s10sig);
431 464 }
432 465
433 466 *set = s10set;
434 467 }
435 468
436 469 void
437 470 s10_sigset_s10_to_native(sigset_t *set)
438 471 {
439 472 int s10sig;
440 473 int nativesig;
441 474 sigset_t nativeset;
442 475
443 476 /*
444 477 * Shortcut: we know the first 32 signals are the same in both
445 478 * s10 and native Solaris. Just assign the first word.
446 479 */
447 480 nativeset.__sigbits[0] = set->__sigbits[0];
448 481 nativeset.__sigbits[1] = 0;
449 482 nativeset.__sigbits[2] = 0;
450 483 nativeset.__sigbits[3] = 0;
451 484
452 485 /*
453 486 * Copy the remainder of the initial set of common signals.
454 487 */
455 488 for (s10sig = 33; s10sig < S10_SIGRTMIN; s10sig++)
456 489 if (sigismember(set, s10sig))
457 490 sigaddset(&nativeset, s10sig);
458 491
459 492 /*
460 493 * Convert any S10 RT signals to their native values.
461 494 */
462 495 for (s10sig = S10_SIGRTMIN, nativesig = _SIGRTMIN;
463 496 s10sig <= S10_SIGRTMAX && nativesig <= _SIGRTMAX;
464 497 s10sig++, nativesig++) {
465 498 if (sigismember(set, s10sig))
466 499 sigaddset(&nativeset, nativesig);
467 500 }
468 501
469 502 *set = nativeset;
470 503 }
471 504
472 505 int
473 506 _init(void)
474 507 {
475 508 int err;
476 509
477 510 /*
478 511 * Set up the table indicating which system calls we want to
479 512 * interpose on. We should probably build this automatically from
480 513 * a list of system calls that is shared with the user-space
481 514 * library.
482 515 */
483 516 s10_emulation_table = kmem_zalloc(NSYSCALL, KM_SLEEP);
484 517 s10_emulation_table[S10_SYS_forkall] = 1; /* 2 */
485 518 s10_emulation_table[S10_SYS_open] = 1; /* 5 */
486 519 s10_emulation_table[S10_SYS_wait] = 1; /* 7 */
487 520 s10_emulation_table[S10_SYS_creat] = 1; /* 8 */
488 521 s10_emulation_table[S10_SYS_link] = 1; /* 9 */
489 522 s10_emulation_table[S10_SYS_unlink] = 1; /* 10 */
490 523 s10_emulation_table[S10_SYS_exec] = 1; /* 11 */
491 524 s10_emulation_table[S10_SYS_mknod] = 1; /* 14 */
492 525 s10_emulation_table[S10_SYS_chmod] = 1; /* 15 */
493 526 s10_emulation_table[S10_SYS_chown] = 1; /* 16 */
494 527 s10_emulation_table[S10_SYS_stat] = 1; /* 18 */
495 528 s10_emulation_table[S10_SYS_umount] = 1; /* 22 */
496 529 s10_emulation_table[S10_SYS_fstat] = 1; /* 28 */
497 530 s10_emulation_table[S10_SYS_utime] = 1; /* 30 */
498 531 s10_emulation_table[S10_SYS_access] = 1; /* 33 */
499 532 s10_emulation_table[SYS_kill] = 1; /* 37 */
500 533 s10_emulation_table[S10_SYS_dup] = 1; /* 41 */
501 534 s10_emulation_table[S10_SYS_pipe] = 1; /* 42 */
502 535 s10_emulation_table[SYS_ioctl] = 1; /* 54 */
503 536 s10_emulation_table[SYS_execve] = 1; /* 59 */
504 537 s10_emulation_table[SYS_acctctl] = 1; /* 71 */
505 538 s10_emulation_table[S10_SYS_issetugid] = 1; /* 75 */
506 539 s10_emulation_table[S10_SYS_fsat] = 1; /* 76 */
507 540 s10_emulation_table[S10_SYS_rmdir] = 1; /* 79 */
508 541 s10_emulation_table[S10_SYS_mkdir] = 1; /* 80 */
509 542 s10_emulation_table[SYS_getdents] = 1; /* 81 */
510 543 s10_emulation_table[S10_SYS_poll] = 1; /* 87 */
511 544 s10_emulation_table[S10_SYS_lstat] = 1; /* 88 */
512 545 s10_emulation_table[S10_SYS_symlink] = 1; /* 89 */
513 546 s10_emulation_table[S10_SYS_readlink] = 1; /* 90 */
514 547 s10_emulation_table[S10_SYS_fchmod] = 1; /* 93 */
515 548 s10_emulation_table[S10_SYS_fchown] = 1; /* 94 */
516 549 s10_emulation_table[SYS_sigprocmask] = 1; /* 95 */
517 550 s10_emulation_table[SYS_sigsuspend] = 1; /* 96 */
518 551 s10_emulation_table[SYS_sigaction] = 1; /* 98 */
519 552 s10_emulation_table[SYS_sigpending] = 1; /* 99 */
520 553 s10_emulation_table[SYS_waitid] = 1; /* 107 */
521 554 s10_emulation_table[SYS_sigsendsys] = 1; /* 108 */
522 555 #if defined(__x86)
523 556 s10_emulation_table[S10_SYS_xstat] = 1; /* 123 */
524 557 s10_emulation_table[S10_SYS_lxstat] = 1; /* 124 */
525 558 s10_emulation_table[S10_SYS_fxstat] = 1; /* 125 */
526 559 s10_emulation_table[S10_SYS_xmknod] = 1; /* 126 */
527 560 #endif
528 561 s10_emulation_table[S10_SYS_lchown] = 1; /* 130 */
529 562 s10_emulation_table[S10_SYS_rename] = 1; /* 134 */
530 563 s10_emulation_table[SYS_uname] = 1; /* 135 */
531 564 s10_emulation_table[SYS_sysconfig] = 1; /* 137 */
532 565 s10_emulation_table[SYS_systeminfo] = 1; /* 139 */
533 566 s10_emulation_table[S10_SYS_fork1] = 1; /* 143 */
534 567 s10_emulation_table[SYS_sigtimedwait] = 1; /* 144 */
535 568 s10_emulation_table[S10_SYS_lwp_sema_wait] = 1; /* 147 */
536 569 s10_emulation_table[S10_SYS_utimes] = 1; /* 154 */
537 570 s10_emulation_table[SYS_lwp_create] = 1; /* 159 */
538 571 s10_emulation_table[SYS_lwp_kill] = 1; /* 163 */
539 572 s10_emulation_table[SYS_lwp_sigmask] = 1; /* 165 */
540 573 #if defined(__amd64)
541 574 s10_emulation_table[SYS_lwp_private] = 1; /* 166 */
542 575 #endif /* __amd64 */
543 576 s10_emulation_table[S10_SYS_lwp_mutex_lock] = 1; /* 169 */
544 577 s10_emulation_table[SYS_pwrite] = 1; /* 174 */
545 578 s10_emulation_table[SYS_acl] = 1; /* 185 */
546 579 s10_emulation_table[SYS_auditsys] = 1; /* 186 */
547 580 s10_emulation_table[SYS_sigqueue] = 1; /* 190 */
548 581 s10_emulation_table[SYS_facl] = 1; /* 200 */
549 582 s10_emulation_table[SYS_signotify] = 1; /* 205 */
550 583 s10_emulation_table[SYS_lwp_mutex_timedlock] = 1; /* 210 */
551 584 s10_emulation_table[SYS_getdents64] = 1; /* 213 */
552 585 s10_emulation_table[S10_SYS_stat64] = 1; /* 215 */
553 586 s10_emulation_table[S10_SYS_lstat64] = 1; /* 216 */
554 587 s10_emulation_table[S10_SYS_fstat64] = 1; /* 217 */
555 588 s10_emulation_table[SYS_pwrite64] = 1; /* 223 */
556 589 s10_emulation_table[S10_SYS_creat64] = 1; /* 224 */
557 590 s10_emulation_table[S10_SYS_open64] = 1; /* 225 */
558 591 s10_emulation_table[SYS_zone] = 1; /* 227 */
559 592 s10_emulation_table[S10_SYS_so_socket] = 1; /* 230 */
560 593 s10_emulation_table[S10_SYS_accept] = 1; /* 234 */
561 594 s10_emulation_table[SYS_lwp_mutex_trylock] = 1; /* 251 */
562 595
563 596 err = mod_install(&modlinkage);
564 597 if (err) {
565 598 cmn_err(CE_WARN, "Couldn't install brand module");
566 599 kmem_free(s10_emulation_table, NSYSCALL);
567 600 }
568 601
569 602 return (err);
570 603 }
571 604
572 605 int
573 606 _info(struct modinfo *modinfop)
574 607 {
575 608 return (mod_info(&modlinkage, modinfop));
576 609 }
577 610
578 611 int
579 612 _fini(void)
580 613 {
581 614 return (brand_solaris_fini(&s10_emulation_table, &modlinkage,
582 615 &s10_brand));
583 616 }
|
↓ open down ↓ |
176 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX