Print this page
OS-4470 lxbrand unblocking signals in new threads must be atomic
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/brand/lx/lx_brand/sys/lx_misc.h
+++ new/usr/src/lib/brand/lx/lx_brand/sys/lx_misc.h
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.
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 2009 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 */
26 26
27 27 /*
28 28 * Copyright 2015 Joyent, Inc. All rights reserved.
29 29 */
30 30
31 31 #ifndef _SYS_LX_H
32 32 #define _SYS_LX_H
33 33
34 34 #include <stdio.h>
35 35 #include <alloca.h>
36 36 #include <dirent.h>
37 37 #include <sys/types.h>
38 38 #include <sys/param.h>
39 39 #include <sys/lwp.h>
40 40
41 41 #include <sys/lx_brand.h>
42 42 #include <sys/lx_thread.h>
43 43
44 44 #include <lx_errno.h>
45 45
46 46 #ifdef __cplusplus
47 47 extern "C" {
48 48 #endif
49 49
50 50 extern char lx_release[LX_VERS_MAX];
51 51 extern char lx_cmd_name[MAXNAMLEN];
52 52 extern pid_t zoneinit_pid;
53 53
54 54 /*
55 55 * Values Linux expects for init
56 56 */
57 57 #define LX_INIT_PGID 1
58 58 #define LX_INIT_SID 1
59 59 #define LX_INIT_PID 1
60 60
61 61 /*
62 62 * Codes to reboot(2).
63 63 */
64 64 #define LINUX_REBOOT_MAGIC1 0xfee1dead
65 65 #define LINUX_REBOOT_MAGIC2 672274793
66 66 #define LINUX_REBOOT_MAGIC2A 85072278
67 67 #define LINUX_REBOOT_MAGIC2B 369367448
68 68 #define LINUX_REBOOT_MAGIC2C 537993216
69 69
70 70 /*
71 71 * This was observed as coming from Red Hat's init process, but it's not in
72 72 * their reboot(2) man page.
73 73 */
74 74 #define LINUX_REBOOT_MAGIC2D 0x28121969
75 75
76 76 #define LINUX_REBOOT_CMD_RESTART 0x1234567
77 77 #define LINUX_REBOOT_CMD_HALT 0xcdef0123
78 78 #define LINUX_REBOOT_CMD_POWER_OFF 0x4321fedc
79 79 #define LINUX_REBOOT_CMD_RESTART2 0xa1b2c3d4
80 80 #define LINUX_REBOOT_CMD_CAD_ON 0x89abcdef
81 81 #define LINUX_REBOOT_CMD_CAD_OFF 0
82 82
83 83 /*
84 84 * the maximum length of messages to be output with lx_msg(), lx_err(),
85 85 * lx_debug(), or lx_unsupported().
86 86 */
87 87 #define LX_MSG_MAXLEN (128 + MAXPATHLEN)
88 88
89 89 /*
90 90 * Linux scheduler priority ranges.
91 91 */
92 92 #define LX_SCHED_PRIORITY_MIN_OTHER 0
93 93 #define LX_SCHED_PRIORITY_MAX_OTHER 0
94 94 #define LX_SCHED_PRIORITY_MIN_RRFIFO 1
95 95 #define LX_SCHED_PRIORITY_MAX_RRFIFO 99
96 96
97 97 /*
98 98 * Constants to indicate who getrusage() should return information about.
99 99 */
100 100 #define LX_RUSAGE_SELF 0
101 101 #define LX_RUSAGE_CHILDREN (-1)
102 102 #define LX_RUSAGE_BOTH (-2)
103 103 #define LX_RUSAGE_THREAD 1
104 104
105 105 /*
106 106 * Based on code from brand_misc.h, but use of that is incompatible with the
107 107 * lx brand.
108 108 *
109 109 * These macros invoke a brandsys subcommand, B_TRUSS_POINT, which makes it
110 110 * easy to debug with DTrace.
111 111 */
112 112 #define B_TRUSS_POINT 6
113 113
114 114 #define B_TRACE_POINT_5(a0, a1, a2, a3, a4) \
115 115 (void) syscall(SYS_brand, B_TRUSS_POINT, (a0), (a1), (a2), (a3), (a4))
116 116
117 117 #define B_TRACE_POINT_4(a0, a1, a2, a3) \
118 118 B_TRACE_POINT_5((a0), (a1), (a2), (a3), 0)
119 119
120 120 #define B_TRACE_POINT_3(a0, a1, a2) \
121 121 B_TRACE_POINT_5((a0), (a1), (a2), 0, 0)
122 122
123 123 #define B_TRACE_POINT_2(a0, a1) \
124 124 B_TRACE_POINT_5((a0), (a1), 0, 0, 0)
125 125
126 126 #define B_TRACE_POINT_1(a0) \
127 127 B_TRACE_POINT_5((a0), 0, 0, 0, 0)
128 128
129 129 #define B_TRACE_POINT_0() \
130 130 B_TRACE_POINT_5(0, 0, 0, 0, 0)
131 131
132 132 /*
133 133 * Macros to access register state within a ucontext_t:
134 134 */
135 135 #define LX_REG(ucp, r) ((ucp)->uc_mcontext.gregs[(r)])
136 136
137 137 /*
138 138 * normally we never want to write to stderr or stdout because it's unsafe
139 139 * to make assumptions about the underlying file descriptors. to protect
140 140 * against writes to these file descriptors we go ahead and close them
141 141 * our brand process initalization code. but there are still occasions
142 142 * where we are willing to make assumptions about our file descriptors
143 143 * and write to them. at thes times we should use one lx_msg() or
144 144 * lx_msg_error()
145 145 */
146 146 extern void lx_msg(char *, ...);
↓ open down ↓ |
146 lines elided |
↑ open up ↑ |
147 147 extern void lx_err(char *, ...);
148 148 extern void lx_err_fatal(char *, ...);
149 149 extern void lx_unsupported(char *, ...);
150 150
151 151 struct ucontext;
152 152
153 153 extern ucontext_t *lx_syscall_regs(void);
154 154 extern uintptr_t lx_find_brand_sp(void);
155 155 extern const ucontext_t *lx_find_brand_uc(void);
156 156
157 +extern void lx_jump_to_linux(ucontext_t *) __NORETURN;
158 +
157 159 extern char *lx_fd_to_path(int fd, char *buf, int buf_size);
158 160 extern int lx_lpid_to_spair(pid_t, pid_t *, lwpid_t *);
159 161 extern int lx_lpid_to_spid(pid_t, pid_t *);
160 162
161 163 extern void lx_ptrace_init();
162 164 extern int lx_ptrace_wait(siginfo_t *);
163 165 extern void lx_ptrace_fork(void);
164 166 extern void lx_ptrace_stop_if_option(int, boolean_t, ulong_t msg, ucontext_t *);
165 167 extern void lx_ptrace_clone_begin(int, boolean_t);
166 168
167 169 extern int lx_check_alloca(size_t);
168 170 #define SAFE_ALLOCA(sz) (lx_check_alloca(sz) ? alloca(sz) : NULL)
169 171
170 172 extern int ltos_at_flag(int lflag, int allow, boolean_t enforce);
171 173
172 174 extern void lx_init_tsd(lx_tsd_t *);
173 175 extern int lx_alloc_stack(void **, size_t *);
174 176 extern void lx_install_stack(void *, size_t, lx_tsd_t *);
175 177 extern void lx_free_stack(void);
176 178 extern void lx_free_other_stacks(void);
177 179 extern void lx_stack_prefork(void);
178 180 extern void lx_stack_postfork(void);
179 181
180 182 /*
181 183 * NO_UUCOPY disables calls to the uucopy* system calls to help with
182 184 * debugging brand library accesses to linux application memory.
183 185 */
184 186 #ifdef NO_UUCOPY
185 187
186 188 int uucopy_unsafe(const void *src, void *dst, size_t n);
187 189 int uucopystr_unsafe(const void *src, void *dst, size_t n);
188 190
189 191 #define uucopy(src, dst, n) uucopy_unsafe((src), (dst), (n))
190 192 #define uucopystr(src, dst, n) uucopystr_unsafe((src), (dst), (n))
191 193
192 194 #endif /* NO_UUCOPY */
193 195
194 196 /*
195 197 * We use these Private libc interfaces to defer signals during critical
196 198 * sections.
197 199 */
198 200 extern void _sigon(void);
199 201 extern void _sigoff(void);
200 202
201 203 #ifdef __cplusplus
202 204 }
203 205 #endif
204 206
205 207 #endif /* _SYS_LX_H */
↓ open down ↓ |
39 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX