Bug Summary

File:obj-scan-build/i386/i386/mach_i386.server.c
Location:line 101, column 2
Description:Value stored to 'msgh_simple' is never read

Annotated Source Code

1/* Module mach_i386 */
2
3#ifndef _GNU_SOURCE1
4#define _GNU_SOURCE1 1
5#endif
6
7#define EXPORT_BOOLEAN
8#include <mach/boolean.h>
9#include <mach/kern_return.h>
10#include <mach/message.h>
11#include <mach/mig_errors.h>
12#include <mach/mig_support.h>
13#include <ipc/ipc_port.h>
14
15#ifndef mig_internalstatic
16#define mig_internalstatic static
17#endif
18
19#ifndef mig_external
20#define mig_external
21#endif
22
23#ifndef mig_unlikely
24#define mig_unlikely(X)__builtin_expect (!! (X), 0) __builtin_expect (!! (X), 0)
25#endif
26
27#ifndef TypeCheck1
28#define TypeCheck1 1
29#endif
30
31#ifndef UseExternRCSId1
32#define UseExternRCSId1 1
33#endif
34
35#define BAD_TYPECHECK(type, check)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t
w; } _t, _c; _t.t = *(type); _c.t = *(check);_t.w != _c.w; }
)), 0)
mig_unlikely (({\__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t
w; } _t, _c; _t.t = *(type); _c.t = *(check);_t.w != _c.w; }
)), 0)
36 union { mach_msg_type_t t; unsigned32_t w; } _t, _c;\__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t
w; } _t, _c; _t.t = *(type); _c.t = *(check);_t.w != _c.w; }
)), 0)
37 _t.t = *(type); _c.t = *(check);_t.w != _c.w; }))__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t
w; } _t, _c; _t.t = *(type); _c.t = *(check);_t.w != _c.w; }
)), 0)
38#define msgh_request_portmsgh_remote_port msgh_remote_port
39#define MACH_MSGH_BITS_REQUEST(bits)((bits) & 0x000000ff) MACH_MSGH_BITS_REMOTE(bits)((bits) & 0x000000ff)
40#define msgh_reply_portmsgh_local_port msgh_local_port
41#define MACH_MSGH_BITS_REPLY(bits)(((bits) & 0x0000ff00) >> 8) MACH_MSGH_BITS_LOCAL(bits)(((bits) & 0x0000ff00) >> 8)
42
43#include <mach/std_types.h>
44#include <kern/ipc_kobject.h>
45#include <kern/ipc_tt.h>
46#include <kern/ipc_host.h>
47#include <kern/task.h>
48#include <kern/thread.h>
49#include <kern/host.h>
50#include <kern/processor.h>
51#include <vm/vm_object.h>
52#include <vm/vm_map.h>
53#include <ipc/ipc_space.h>
54#include <mach/mach_types.h>
55#include <mach/machine/mach_i386_types.h>
56#include <machine/io_perm.h>
57
58/* Routine i386_set_ldt */
59mig_internalstatic void _Xi386_set_ldt
60 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
61{
62 typedef struct {
63 mach_msg_header_t Head;
64 mach_msg_type_t first_selectorType;
65 int first_selector;
66 mach_msg_type_long_t desc_listType;
67 descriptor_t desc_list[256];
68 } Request;
69
70 typedef struct {
71 mach_msg_header_t Head;
72 mach_msg_type_t RetCodeType;
73 kern_return_t RetCode;
74 } Reply;
75
76 Request *In0P = (Request *) InHeadP;
77 Reply *OutP = (Reply *) OutHeadP;
78 mig_external kern_return_t i386_set_ldt
79 (thread_t target_thread, int first_selector, descriptor_list_t desc_list, mach_msg_type_number_t desc_listCnt, boolean_t desc_listSCopy);
80
81#if TypeCheck1
82 boolean_t msgh_simple = msgh_simple;
83#endif /* TypeCheck */
84
85 unsigned int msgh_size;
86
87 const mach_msg_type_t first_selectorCheck = {
88 /* msgt_name = */ 2,
89 /* msgt_size = */ 32,
90 /* msgt_number = */ 1,
91 /* msgt_inline = */ TRUE((boolean_t) 1),
92 /* msgt_longform = */ FALSE((boolean_t) 0),
93 /* msgt_deallocate = */ FALSE((boolean_t) 0),
94 /* msgt_unused = */ 0
95 };
96
97 thread_t target_thread;
98
99#if TypeCheck1
100 msgh_size = In0P->Head.msgh_size;
101 msgh_simple = !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX0x80000000U);
Value stored to 'msgh_simple' is never read
102 if (mig_unlikely ((msgh_size < 44))__builtin_expect (!! ((msgh_size < 44)), 0))
103 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
104#endif /* TypeCheck */
105
106#if TypeCheck1
107 if (BAD_TYPECHECK(&In0P->first_selectorType, &first_selectorCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t
w; } _t, _c; _t.t = *(&In0P->first_selectorType); _c.
t = *(&first_selectorCheck);_t.w != _c.w; })), 0)
)
108 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
109#endif /* TypeCheck */
110
111#if TypeCheck1
112 if (mig_unlikely ((In0P->desc_listType.msgtl_header.msgt_longform != TRUE) ||__builtin_expect (!! ((In0P->desc_listType.msgtl_header.msgt_longform
!= ((boolean_t) 1)) || (In0P->desc_listType.msgtl_name !=
2) || (In0P->desc_listType.msgtl_size != 32)), 0)
113 (In0P->desc_listType.msgtl_name != 2) ||__builtin_expect (!! ((In0P->desc_listType.msgtl_header.msgt_longform
!= ((boolean_t) 1)) || (In0P->desc_listType.msgtl_name !=
2) || (In0P->desc_listType.msgtl_size != 32)), 0)
114 (In0P->desc_listType.msgtl_size != 32))__builtin_expect (!! ((In0P->desc_listType.msgtl_header.msgt_longform
!= ((boolean_t) 1)) || (In0P->desc_listType.msgtl_name !=
2) || (In0P->desc_listType.msgtl_size != 32)), 0)
)
115 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
116#endif /* TypeCheck */
117
118#if TypeCheck1
119 if (mig_unlikely (msgh_size != 44 + ((In0P->desc_listType.msgtl_header.msgt_inline) ? 4 * In0P->desc_listType.msgtl_number : sizeof(descriptor_t *)))__builtin_expect (!! (msgh_size != 44 + ((In0P->desc_listType
.msgtl_header.msgt_inline) ? 4 * In0P->desc_listType.msgtl_number
: sizeof(descriptor_t *))), 0)
)
120 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
121#endif /* TypeCheck */
122
123 target_thread = convert_port_to_thread((ipc_port_t) In0P->Head.msgh_request_portmsgh_remote_port);
124
125 OutP->RetCode = i386_set_ldt(target_thread, In0P->first_selector, (In0P->desc_listType.msgtl_header.msgt_inline) ? In0P->desc_list : *((descriptor_t **)In0P->desc_list), In0P->desc_listType.msgtl_number / 2, In0P->desc_listType.msgtl_header.msgt_inline);
126 thread_deallocate(target_thread);
127}
128
129/* Default implementation of i386_set_ldt */
130#ifdef MIG_EOPNOTSUPP
131kern_return_t __attribute__ ((weak))
132i386_set_ldt
133(
134 thread_t target_thread,
135 int first_selector,
136 descriptor_list_t desc_list,
137 mach_msg_type_number_t desc_listCnt,
138 boolean_t desc_listSCopy
139) { return MIG_EOPNOTSUPP; }
140#endif /* MIG_EOPNOTSUPP */
141
142/* Routine i386_get_ldt */
143mig_internalstatic void _Xi386_get_ldt
144 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
145{
146 typedef struct {
147 mach_msg_header_t Head;
148 mach_msg_type_t first_selectorType;
149 int first_selector;
150 mach_msg_type_t selector_countType;
151 int selector_count;
152 } Request;
153
154 typedef struct {
155 mach_msg_header_t Head;
156 mach_msg_type_t RetCodeType;
157 kern_return_t RetCode;
158 mach_msg_type_long_t desc_listType;
159 descriptor_t desc_list[256];
160 } Reply;
161
162 Request *In0P = (Request *) InHeadP;
163 Reply *OutP = (Reply *) OutHeadP;
164 mig_external kern_return_t i386_get_ldt
165 (thread_t target_thread, int first_selector, int selector_count, descriptor_list_t *desc_list, mach_msg_type_number_t *desc_listCnt);
166
167 boolean_t msgh_simple = msgh_simple;
168 const mach_msg_type_t first_selectorCheck = {
169 /* msgt_name = */ 2,
170 /* msgt_size = */ 32,
171 /* msgt_number = */ 1,
172 /* msgt_inline = */ TRUE((boolean_t) 1),
173 /* msgt_longform = */ FALSE((boolean_t) 0),
174 /* msgt_deallocate = */ FALSE((boolean_t) 0),
175 /* msgt_unused = */ 0
176 };
177
178 const mach_msg_type_t selector_countCheck = {
179 /* msgt_name = */ 2,
180 /* msgt_size = */ 32,
181 /* msgt_number = */ 1,
182 /* msgt_inline = */ TRUE((boolean_t) 1),
183 /* msgt_longform = */ FALSE((boolean_t) 0),
184 /* msgt_deallocate = */ FALSE((boolean_t) 0),
185 /* msgt_unused = */ 0
186 };
187
188 const mach_msg_type_long_t desc_listType = {
189 {
190 /* msgt_name = */ 0,
191 /* msgt_size = */ 0,
192 /* msgt_number = */ 0,
193 /* msgt_inline = */ TRUE((boolean_t) 1),
194 /* msgt_longform = */ TRUE((boolean_t) 1),
195 /* msgt_deallocate = */ FALSE((boolean_t) 0),
196 /* msgt_unused = */ 0
197 },
198 /* msgtl_name = */ 2,
199 /* msgtl_size = */ 32,
200 /* msgtl_number = */ 512,
201 };
202
203 thread_t target_thread;
204 mach_msg_type_number_t desc_listCnt;
205
206 descriptor_t *desc_listP;
207
208#if TypeCheck1
209 if (mig_unlikely ((In0P->Head.msgh_size != 40) ||__builtin_expect (!! ((In0P->Head.msgh_size != 40) || (In0P
->Head.msgh_bits & 0x80000000U)), 0)
210 (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 40) || (In0P
->Head.msgh_bits & 0x80000000U)), 0)
)
211 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
212#endif /* TypeCheck */
213
214#if TypeCheck1
215 if (BAD_TYPECHECK(&In0P->first_selectorType, &first_selectorCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t
w; } _t, _c; _t.t = *(&In0P->first_selectorType); _c.
t = *(&first_selectorCheck);_t.w != _c.w; })), 0)
)
216 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
217#endif /* TypeCheck */
218
219#if TypeCheck1
220 if (BAD_TYPECHECK(&In0P->selector_countType, &selector_countCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t
w; } _t, _c; _t.t = *(&In0P->selector_countType); _c.
t = *(&selector_countCheck);_t.w != _c.w; })), 0)
)
221 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
222#endif /* TypeCheck */
223
224 target_thread = convert_port_to_thread((ipc_port_t) In0P->Head.msgh_request_portmsgh_remote_port);
225
226 desc_listP = OutP->desc_list;
227 desc_listCnt = 256;
228
229 OutP->RetCode = i386_get_ldt(target_thread, In0P->first_selector, In0P->selector_count, &desc_listP, &desc_listCnt);
230 thread_deallocate(target_thread);
231 if (OutP->RetCode != KERN_SUCCESS0)
232 return;
233
234 msgh_simple = TRUE((boolean_t) 1);
235
236 OutP->desc_listType = desc_listType;
237 if (desc_listP != OutP->desc_list) {
238 OutP->desc_listType.msgtl_header.msgt_inline = FALSE((boolean_t) 0);
239 *((descriptor_t **)OutP->desc_list) = desc_listP;
240 msgh_simple = FALSE((boolean_t) 0);
241 }
242
243 OutP->desc_listType.msgtl_number = 2 * desc_listCnt;
244 OutP->Head.msgh_size = 44 + ((OutP->desc_listType.msgtl_header.msgt_inline) ? 8 * desc_listCnt : sizeof(descriptor_t *));
245
246 if (!msgh_simple)
247 OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX0x80000000U;
248}
249
250/* Default implementation of i386_get_ldt */
251#ifdef MIG_EOPNOTSUPP
252kern_return_t __attribute__ ((weak))
253i386_get_ldt
254(
255 thread_t target_thread,
256 int first_selector,
257 int selector_count,
258 descriptor_list_t *desc_list,
259 mach_msg_type_number_t *desc_listCnt
260) { return MIG_EOPNOTSUPP; }
261#endif /* MIG_EOPNOTSUPP */
262
263/* Routine i386_io_perm_create */
264mig_internalstatic void _Xi386_io_perm_create
265 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
266{
267 typedef struct {
268 mach_msg_header_t Head;
269 mach_msg_type_t fromType;
270 io_port_t from;
271 char fromPad[2];
272 mach_msg_type_t toType;
273 io_port_t to;
274 char toPad[2];
275 } Request;
276
277 typedef struct {
278 mach_msg_header_t Head;
279 mach_msg_type_t RetCodeType;
280 kern_return_t RetCode;
281 mach_msg_type_t io_permType;
282 ipc_port_t io_perm;
283 } Reply;
284
285 Request *In0P = (Request *) InHeadP;
286 Reply *OutP = (Reply *) OutHeadP;
287 mig_external kern_return_t i386_io_perm_create
288 (ipc_port_t master_port, io_port_t from, io_port_t to, io_perm_t *io_perm);
289
290 const mach_msg_type_t fromCheck = {
291 /* msgt_name = */ 1,
292 /* msgt_size = */ 16,
293 /* msgt_number = */ 1,
294 /* msgt_inline = */ TRUE((boolean_t) 1),
295 /* msgt_longform = */ FALSE((boolean_t) 0),
296 /* msgt_deallocate = */ FALSE((boolean_t) 0),
297 /* msgt_unused = */ 0
298 };
299
300 const mach_msg_type_t toCheck = {
301 /* msgt_name = */ 1,
302 /* msgt_size = */ 16,
303 /* msgt_number = */ 1,
304 /* msgt_inline = */ TRUE((boolean_t) 1),
305 /* msgt_longform = */ FALSE((boolean_t) 0),
306 /* msgt_deallocate = */ FALSE((boolean_t) 0),
307 /* msgt_unused = */ 0
308 };
309
310 const mach_msg_type_t io_permType = {
311 /* msgt_name = */ 17,
312 /* msgt_size = */ 32,
313 /* msgt_number = */ 1,
314 /* msgt_inline = */ TRUE((boolean_t) 1),
315 /* msgt_longform = */ FALSE((boolean_t) 0),
316 /* msgt_deallocate = */ FALSE((boolean_t) 0),
317 /* msgt_unused = */ 0
318 };
319
320 io_perm_t io_perm;
321
322#if TypeCheck1
323 if (mig_unlikely ((In0P->Head.msgh_size != 40) ||__builtin_expect (!! ((In0P->Head.msgh_size != 40) || (In0P
->Head.msgh_bits & 0x80000000U)), 0)
324 (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 40) || (In0P
->Head.msgh_bits & 0x80000000U)), 0)
)
325 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
326#endif /* TypeCheck */
327
328#if TypeCheck1
329 if (BAD_TYPECHECK(&In0P->fromType, &fromCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t
w; } _t, _c; _t.t = *(&In0P->fromType); _c.t = *(&
fromCheck);_t.w != _c.w; })), 0)
)
330 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
331#endif /* TypeCheck */
332
333#if TypeCheck1
334 if (BAD_TYPECHECK(&In0P->toType, &toCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t
w; } _t, _c; _t.t = *(&In0P->toType); _c.t = *(&toCheck
);_t.w != _c.w; })), 0)
)
335 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
336#endif /* TypeCheck */
337
338 OutP->RetCode = i386_io_perm_create((ipc_port_t) In0P->Head.msgh_request_portmsgh_remote_port, In0P->from, In0P->to, &io_perm);
339 if (OutP->RetCode != KERN_SUCCESS0)
340 return;
341
342 OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX0x80000000U;
343 OutP->Head.msgh_size = 40;
344
345 OutP->io_permType = io_permType;
346
347 OutP->io_perm = convert_io_perm_to_port(io_perm);
348}
349
350/* Default implementation of i386_io_perm_create */
351#ifdef MIG_EOPNOTSUPP
352kern_return_t __attribute__ ((weak))
353i386_io_perm_create
354(
355 ipc_port_t master_port,
356 io_port_t from,
357 io_port_t to,
358 io_perm_t *io_perm
359) { return MIG_EOPNOTSUPP; }
360#endif /* MIG_EOPNOTSUPP */
361
362/* Routine i386_io_perm_modify */
363mig_internalstatic void _Xi386_io_perm_modify
364 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
365{
366 typedef struct {
367 mach_msg_header_t Head;
368 mach_msg_type_t io_permType;
369 ipc_port_t io_perm;
370 mach_msg_type_t enableType;
371 boolean_t enable;
372 } Request;
373
374 typedef struct {
375 mach_msg_header_t Head;
376 mach_msg_type_t RetCodeType;
377 kern_return_t RetCode;
378 } Reply;
379
380 Request *In0P = (Request *) InHeadP;
381 Reply *OutP = (Reply *) OutHeadP;
382 mig_external kern_return_t i386_io_perm_modify
383 (task_t target_task, io_perm_t io_perm, boolean_t enable);
384
385 const mach_msg_type_t enableCheck = {
386 /* msgt_name = */ 0,
387 /* msgt_size = */ 32,
388 /* msgt_number = */ 1,
389 /* msgt_inline = */ TRUE((boolean_t) 1),
390 /* msgt_longform = */ FALSE((boolean_t) 0),
391 /* msgt_deallocate = */ FALSE((boolean_t) 0),
392 /* msgt_unused = */ 0
393 };
394
395 task_t target_task;
396
397#if TypeCheck1
398 if (mig_unlikely ((In0P->Head.msgh_size != 40) ||__builtin_expect (!! ((In0P->Head.msgh_size != 40) || !(In0P
->Head.msgh_bits & 0x80000000U)), 0)
399 !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 40) || !(In0P
->Head.msgh_bits & 0x80000000U)), 0)
)
400 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
401#endif /* TypeCheck */
402
403#if TypeCheck1
404 if (mig_unlikely ((In0P->io_permType.msgt_inline != TRUE) ||__builtin_expect (!! ((In0P->io_permType.msgt_inline != ((
boolean_t) 1)) || (In0P->io_permType.msgt_longform != ((boolean_t
) 0)) || (In0P->io_permType.msgt_name != 17) || (In0P->
io_permType.msgt_number != 1) || (In0P->io_permType.msgt_size
!= 32)), 0)
405 (In0P->io_permType.msgt_longform != FALSE) ||__builtin_expect (!! ((In0P->io_permType.msgt_inline != ((
boolean_t) 1)) || (In0P->io_permType.msgt_longform != ((boolean_t
) 0)) || (In0P->io_permType.msgt_name != 17) || (In0P->
io_permType.msgt_number != 1) || (In0P->io_permType.msgt_size
!= 32)), 0)
406 (In0P->io_permType.msgt_name != 17) ||__builtin_expect (!! ((In0P->io_permType.msgt_inline != ((
boolean_t) 1)) || (In0P->io_permType.msgt_longform != ((boolean_t
) 0)) || (In0P->io_permType.msgt_name != 17) || (In0P->
io_permType.msgt_number != 1) || (In0P->io_permType.msgt_size
!= 32)), 0)
407 (In0P->io_permType.msgt_number != 1) ||__builtin_expect (!! ((In0P->io_permType.msgt_inline != ((
boolean_t) 1)) || (In0P->io_permType.msgt_longform != ((boolean_t
) 0)) || (In0P->io_permType.msgt_name != 17) || (In0P->
io_permType.msgt_number != 1) || (In0P->io_permType.msgt_size
!= 32)), 0)
408 (In0P->io_permType.msgt_size != 32))__builtin_expect (!! ((In0P->io_permType.msgt_inline != ((
boolean_t) 1)) || (In0P->io_permType.msgt_longform != ((boolean_t
) 0)) || (In0P->io_permType.msgt_name != 17) || (In0P->
io_permType.msgt_number != 1) || (In0P->io_permType.msgt_size
!= 32)), 0)
)
409 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
410#endif /* TypeCheck */
411
412#if TypeCheck1
413 if (BAD_TYPECHECK(&In0P->enableType, &enableCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t
w; } _t, _c; _t.t = *(&In0P->enableType); _c.t = *(&
enableCheck);_t.w != _c.w; })), 0)
)
414 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
415#endif /* TypeCheck */
416
417 target_task = convert_port_to_task((ipc_port_t) In0P->Head.msgh_request_portmsgh_remote_port);
418
419 OutP->RetCode = i386_io_perm_modify(target_task, convert_port_to_io_perm(In0P->io_perm), In0P->enable);
420 task_deallocate(target_task);
421 if (OutP->RetCode != KERN_SUCCESS0)
422 return;
423
424 if (IP_VALID(In0P->io_perm)(((&(In0P->io_perm)->ip_target.ipt_object) != ((ipc_object_t
) 0)) && ((&(In0P->io_perm)->ip_target.ipt_object
) != ((ipc_object_t) -1)))
)
425 ipc_port_release_send(In0P->io_perm);
426}
427
428/* Default implementation of i386_io_perm_modify */
429#ifdef MIG_EOPNOTSUPP
430kern_return_t __attribute__ ((weak))
431i386_io_perm_modify
432(
433 task_t target_task,
434 io_perm_t io_perm,
435 boolean_t enable
436) { return MIG_EOPNOTSUPP; }
437#endif /* MIG_EOPNOTSUPP */
438
439/* Routine i386_set_gdt */
440mig_internalstatic void _Xi386_set_gdt
441 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
442{
443 typedef struct {
444 mach_msg_header_t Head;
445 mach_msg_type_t selectorType;
446 int selector;
447 mach_msg_type_t descType;
448 descriptor_t desc;
449 } Request;
450
451 typedef struct {
452 mach_msg_header_t Head;
453 mach_msg_type_t RetCodeType;
454 kern_return_t RetCode;
455 mach_msg_type_t selectorType;
456 int selector;
457 } Reply;
458
459 Request *In0P = (Request *) InHeadP;
460 Reply *OutP = (Reply *) OutHeadP;
461 mig_external kern_return_t i386_set_gdt
462 (thread_t target_thread, int *selector, descriptor_t desc);
463
464 const mach_msg_type_t selectorCheck = {
465 /* msgt_name = */ 2,
466 /* msgt_size = */ 32,
467 /* msgt_number = */ 1,
468 /* msgt_inline = */ TRUE((boolean_t) 1),
469 /* msgt_longform = */ FALSE((boolean_t) 0),
470 /* msgt_deallocate = */ FALSE((boolean_t) 0),
471 /* msgt_unused = */ 0
472 };
473
474 const mach_msg_type_t descCheck = {
475 /* msgt_name = */ 2,
476 /* msgt_size = */ 32,
477 /* msgt_number = */ 2,
478 /* msgt_inline = */ TRUE((boolean_t) 1),
479 /* msgt_longform = */ FALSE((boolean_t) 0),
480 /* msgt_deallocate = */ FALSE((boolean_t) 0),
481 /* msgt_unused = */ 0
482 };
483
484 const mach_msg_type_t selectorType = {
485 /* msgt_name = */ 2,
486 /* msgt_size = */ 32,
487 /* msgt_number = */ 1,
488 /* msgt_inline = */ TRUE((boolean_t) 1),
489 /* msgt_longform = */ FALSE((boolean_t) 0),
490 /* msgt_deallocate = */ FALSE((boolean_t) 0),
491 /* msgt_unused = */ 0
492 };
493
494 thread_t target_thread;
495
496#if TypeCheck1
497 if (mig_unlikely ((In0P->Head.msgh_size != 44) ||__builtin_expect (!! ((In0P->Head.msgh_size != 44) || (In0P
->Head.msgh_bits & 0x80000000U)), 0)
498 (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 44) || (In0P
->Head.msgh_bits & 0x80000000U)), 0)
)
499 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
500#endif /* TypeCheck */
501
502#if TypeCheck1
503 if (BAD_TYPECHECK(&In0P->selectorType, &selectorCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t
w; } _t, _c; _t.t = *(&In0P->selectorType); _c.t = *(
&selectorCheck);_t.w != _c.w; })), 0)
)
504 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
505#endif /* TypeCheck */
506
507#if TypeCheck1
508 if (BAD_TYPECHECK(&In0P->descType, &descCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t
w; } _t, _c; _t.t = *(&In0P->descType); _c.t = *(&
descCheck);_t.w != _c.w; })), 0)
)
509 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
510#endif /* TypeCheck */
511
512 target_thread = convert_port_to_thread((ipc_port_t) In0P->Head.msgh_request_portmsgh_remote_port);
513
514 OutP->RetCode = i386_set_gdt(target_thread, &In0P->selector, In0P->desc);
515 thread_deallocate(target_thread);
516 if (OutP->RetCode != KERN_SUCCESS0)
517 return;
518
519 OutP->Head.msgh_size = 40;
520
521 OutP->selectorType = selectorType;
522
523 OutP->selector = In0P->selector;
524}
525
526/* Default implementation of i386_set_gdt */
527#ifdef MIG_EOPNOTSUPP
528kern_return_t __attribute__ ((weak))
529i386_set_gdt
530(
531 thread_t target_thread,
532 int *selector,
533 descriptor_t desc
534) { return MIG_EOPNOTSUPP; }
535#endif /* MIG_EOPNOTSUPP */
536
537/* Routine i386_get_gdt */
538mig_internalstatic void _Xi386_get_gdt
539 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
540{
541 typedef struct {
542 mach_msg_header_t Head;
543 mach_msg_type_t selectorType;
544 int selector;
545 } Request;
546
547 typedef struct {
548 mach_msg_header_t Head;
549 mach_msg_type_t RetCodeType;
550 kern_return_t RetCode;
551 mach_msg_type_t descType;
552 descriptor_t desc;
553 } Reply;
554
555 Request *In0P = (Request *) InHeadP;
556 Reply *OutP = (Reply *) OutHeadP;
557 mig_external kern_return_t i386_get_gdt
558 (thread_t target_thread, int selector, descriptor_t *desc);
559
560 const mach_msg_type_t selectorCheck = {
561 /* msgt_name = */ 2,
562 /* msgt_size = */ 32,
563 /* msgt_number = */ 1,
564 /* msgt_inline = */ TRUE((boolean_t) 1),
565 /* msgt_longform = */ FALSE((boolean_t) 0),
566 /* msgt_deallocate = */ FALSE((boolean_t) 0),
567 /* msgt_unused = */ 0
568 };
569
570 const mach_msg_type_t descType = {
571 /* msgt_name = */ 2,
572 /* msgt_size = */ 32,
573 /* msgt_number = */ 2,
574 /* msgt_inline = */ TRUE((boolean_t) 1),
575 /* msgt_longform = */ FALSE((boolean_t) 0),
576 /* msgt_deallocate = */ FALSE((boolean_t) 0),
577 /* msgt_unused = */ 0
578 };
579
580 thread_t target_thread;
581
582#if TypeCheck1
583 if (mig_unlikely ((In0P->Head.msgh_size != 32) ||__builtin_expect (!! ((In0P->Head.msgh_size != 32) || (In0P
->Head.msgh_bits & 0x80000000U)), 0)
584 (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 32) || (In0P
->Head.msgh_bits & 0x80000000U)), 0)
)
585 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
586#endif /* TypeCheck */
587
588#if TypeCheck1
589 if (BAD_TYPECHECK(&In0P->selectorType, &selectorCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t
w; } _t, _c; _t.t = *(&In0P->selectorType); _c.t = *(
&selectorCheck);_t.w != _c.w; })), 0)
)
590 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
591#endif /* TypeCheck */
592
593 target_thread = convert_port_to_thread((ipc_port_t) In0P->Head.msgh_request_portmsgh_remote_port);
594
595 OutP->RetCode = i386_get_gdt(target_thread, In0P->selector, &OutP->desc);
596 thread_deallocate(target_thread);
597 if (OutP->RetCode != KERN_SUCCESS0)
598 return;
599
600 OutP->Head.msgh_size = 44;
601
602 OutP->descType = descType;
603}
604
605/* Default implementation of i386_get_gdt */
606#ifdef MIG_EOPNOTSUPP
607kern_return_t __attribute__ ((weak))
608i386_get_gdt
609(
610 thread_t target_thread,
611 int selector,
612 descriptor_t *desc
613) { return MIG_EOPNOTSUPP; }
614#endif /* MIG_EOPNOTSUPP */
615
616mig_routine_t mach_i386_server_routines[] = {
617 0,
618 0,
619 0,
620 _Xi386_set_ldt,
621 _Xi386_get_ldt,
622 _Xi386_io_perm_create,
623 _Xi386_io_perm_modify,
624 _Xi386_set_gdt,
625 _Xi386_get_gdt,
626};
627
628mig_external boolean_t mach_i386_server
629 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
630{
631 mach_msg_header_t *InP = InHeadP;
632 mig_reply_header_t *OutP = (mig_reply_header_t *) OutHeadP;
633
634 const mach_msg_type_t RetCodeType = {
635 /* msgt_name = */ MACH_MSG_TYPE_INTEGER_322,
636 /* msgt_size = */ 32,
637 /* msgt_number = */ 1,
638 /* msgt_inline = */ TRUE((boolean_t) 1),
639 /* msgt_longform = */ FALSE((boolean_t) 0),
640 /* msgt_deallocate = */ FALSE((boolean_t) 0),
641 /* msgt_unused = */ 0
642 };
643
644 mig_routine_t routine;
645
646 OutP->Head.msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REPLY(InP->msgh_bits), 0)(((((InP->msgh_bits) & 0x0000ff00) >> 8)) | ((0)
<< 8))
;
647 OutP->Head.msgh_size = sizeof *OutP;
648 OutP->Head.msgh_remote_port = InP->msgh_reply_portmsgh_local_port;
649 OutP->Head.msgh_local_port = MACH_PORT_NULL((mach_port_t) 0);
650 OutP->Head.msgh_seqno = 0;
651 OutP->Head.msgh_id = InP->msgh_id + 100;
652
653 OutP->RetCodeType = RetCodeType;
654
655 if ((InP->msgh_id > 3808) || (InP->msgh_id < 3800) ||
656 ((routine = mach_i386_server_routines[InP->msgh_id - 3800]) == 0)) {
657 OutP->RetCode = MIG_BAD_ID-303;
658 return FALSE((boolean_t) 0);
659 }
660 (*routine) (InP, &OutP->Head);
661 return TRUE((boolean_t) 1);
662}
663
664mig_external mig_routine_t mach_i386_server_routine
665 (const mach_msg_header_t *InHeadP)
666{
667 int msgh_id;
668
669 msgh_id = InHeadP->msgh_id - 3800;
670
671 if ((msgh_id > 8) || (msgh_id < 0))
672 return 0;
673
674 return mach_i386_server_routines[msgh_id];
675}
676