sys_machdep.c revision 1.7 1 /* $NetBSD: sys_machdep.c,v 1.7 2007/11/22 16:17:13 bouyer Exp $ */
2
3 /*-
4 * Copyright (c) 1998, 2007 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Charles M. Hannum, and by Andrew Doran.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 #include <sys/cdefs.h>
40 __KERNEL_RCSID(0, "$NetBSD: sys_machdep.c,v 1.7 2007/11/22 16:17:13 bouyer Exp $");
41
42 #include "opt_compat_netbsd.h"
43 #include "opt_mtrr.h"
44 #include "opt_perfctrs.h"
45 #include "opt_user_ldt.h"
46 #include "opt_vm86.h"
47 #include "opt_xen.h"
48
49 #include <sys/param.h>
50 #include <sys/systm.h>
51 #include <sys/ioctl.h>
52 #include <sys/file.h>
53 #include <sys/time.h>
54 #include <sys/proc.h>
55 #include <sys/user.h>
56 #include <sys/uio.h>
57 #include <sys/kernel.h>
58 #include <sys/buf.h>
59 #include <sys/signal.h>
60 #include <sys/malloc.h>
61 #include <sys/kauth.h>
62
63 #include <sys/mount.h>
64 #include <sys/syscallargs.h>
65
66 #include <uvm/uvm_extern.h>
67
68 #include <machine/cpu.h>
69 #include <machine/cpufunc.h>
70 #include <machine/gdt.h>
71 #include <machine/psl.h>
72 #include <machine/reg.h>
73 #include <machine/sysarch.h>
74 #include <machine/mtrr.h>
75
76 #ifdef __x86_64__
77 /* Need to be checked. */
78 #undef USER_LDT
79 #undef PERFCTRS
80 #undef VM86
81 #undef IOPERM
82 #else
83 #define IOPERM
84 #endif
85
86 #ifdef VM86
87 #include <machine/vm86.h>
88 #endif
89
90 #ifdef PERFCTRS
91 #include <machine/pmc.h>
92 #endif
93
94 /* XXX needs changes from vmlocking branch */
95 #define mutex_enter(x) /* nothing */
96 #define mutex_exit(x) /* nothing */
97
98 extern struct vm_map *kernel_map;
99
100 int x86_get_ioperm(struct lwp *, void *, register_t *);
101 int x86_set_ioperm(struct lwp *, void *, register_t *);
102 int x86_get_mtrr(struct lwp *, void *, register_t *);
103 int x86_set_mtrr(struct lwp *, void *, register_t *);
104 int x86_set_sdbase(void *arg, char which);
105 int x86_get_sdbase(void *arg, char which);
106
107 #ifdef LDT_DEBUG
108 static void x86_print_ldt(int, const struct segment_descriptor *);
109
110 static void
111 x86_print_ldt(int i, const struct segment_descriptor *d)
112 {
113 printf("[%d] lolimit=0x%x, lobase=0x%x, type=%u, dpl=%u, p=%u, "
114 "hilimit=0x%x, xx=%x, def32=%u, gran=%u, hibase=0x%x\n",
115 i, d->sd_lolimit, d->sd_lobase, d->sd_type, d->sd_dpl, d->sd_p,
116 d->sd_hilimit, d->sd_xx, d->sd_def32, d->sd_gran, d->sd_hibase);
117 }
118 #endif
119
120 int
121 x86_get_ldt_len(struct lwp *l)
122 {
123 #ifndef USER_LDT
124 return -1;
125 #else
126 pmap_t pmap = l->l_proc->p_vmspace->vm_map.pmap;
127 int nldt;
128
129 mutex_enter(&pmap->pm_lock);
130
131 if (pmap->pm_flags & PMF_USER_LDT) {
132 nldt = pmap->pm_ldt_len;
133 } else {
134 nldt = NLDT;
135 }
136 mutex_exit(&pmap->pm_lock);
137 return nldt;
138 #endif
139 }
140
141
142 int
143 x86_get_ldt(struct lwp *l, void *args, register_t *retval)
144 {
145 #ifndef USER_LDT
146 return EINVAL;
147 #else
148 struct x86_get_ldt_args ua;
149 union descriptor *cp;
150 int error;
151
152 if ((error = copyin(args, &ua, sizeof(ua))) != 0)
153 return error;
154
155 if (ua.num < 0 || ua.num > 8192)
156 return EINVAL;
157
158 cp = malloc(ua.num * sizeof(union descriptor), M_TEMP, M_WAITOK);
159 if (cp == NULL)
160 return ENOMEM;
161
162 error = x86_get_ldt1(l, &ua, cp);
163 *retval = ua.num;
164 if (error == 0)
165 error = copyout(cp, ua.desc, ua.num * sizeof(*cp));
166
167 free(cp, M_TEMP);
168 return error;
169 #endif
170 }
171
172 int
173 x86_get_ldt1(struct lwp *l, struct x86_get_ldt_args *ua, union descriptor *cp)
174 {
175 #ifndef USER_LDT
176 return EINVAL;
177 #else
178 int error;
179 struct proc *p = l->l_proc;
180 pmap_t pmap = p->p_vmspace->vm_map.pmap;
181 int nldt, num;
182 union descriptor *lp;
183
184 error = kauth_authorize_machdep(l->l_cred, KAUTH_MACHDEP_LDT_GET,
185 NULL, NULL, NULL, NULL);
186 if (error)
187 return (error);
188
189 #ifdef LDT_DEBUG
190 printf("x86_get_ldt: start=%d num=%d descs=%p\n", ua->start,
191 ua->num, ua->desc);
192 #endif
193
194 if (ua->start < 0 || ua->num < 0 || ua->start > 8192 || ua->num > 8192 ||
195 ua->start + ua->num > 8192)
196 return (EINVAL);
197
198 mutex_enter(&pmap->pm_lock);
199
200 if (pmap->pm_flags & PMF_USER_LDT) {
201 nldt = pmap->pm_ldt_len;
202 lp = pmap->pm_ldt;
203 } else {
204 nldt = NLDT;
205 lp = ldt;
206 }
207
208 if (ua->start > nldt) {
209 mutex_exit(&pmap->pm_lock);
210 return (EINVAL);
211 }
212
213 lp += ua->start;
214 num = min(ua->num, nldt - ua->start);
215 ua->num = num;
216 #ifdef LDT_DEBUG
217 {
218 int i;
219 for (i = 0; i < num; i++)
220 x86_print_ldt(i, &lp[i].sd);
221 }
222 #endif
223
224 memcpy(cp, lp, num * sizeof(union descriptor));
225 mutex_exit(&pmap->pm_lock);
226
227 return 0;
228 #endif
229 }
230
231 int
232 x86_set_ldt(struct lwp *l, void *args, register_t *retval)
233 {
234 #ifndef USER_LDT
235 return EINVAL;
236 #else
237 struct x86_set_ldt_args ua;
238 union descriptor *descv;
239 int error;
240
241 if ((error = copyin(args, &ua, sizeof(ua))) != 0)
242 return (error);
243
244 if (ua.num < 0 || ua.num > 8192)
245 return EINVAL;
246
247 descv = malloc(sizeof (*descv) * ua.num, M_TEMP, M_NOWAIT);
248 if (descv == NULL)
249 return ENOMEM;
250
251 error = copyin(ua.desc, descv, sizeof (*descv) * ua.num);
252 if (error == 0)
253 error = x86_set_ldt1(l, &ua, descv);
254 *retval = ua.start;
255
256 free(descv, M_TEMP);
257 return error;
258 #endif
259 }
260
261 int
262 x86_set_ldt1(struct lwp *l, struct x86_set_ldt_args *ua,
263 union descriptor *descv)
264 {
265 #ifndef USER_LDT
266 return EINVAL;
267 #else
268 int error, i, n, sel, free_sel;
269 struct proc *p = l->l_proc;
270 struct pcb *pcb = &l->l_addr->u_pcb;
271 pmap_t pmap = p->p_vmspace->vm_map.pmap;
272 size_t old_len, new_len, ldt_len, free_len;
273 union descriptor *old_ldt, *new_ldt, *free_ldt;
274
275 error = kauth_authorize_machdep(l->l_cred, KAUTH_MACHDEP_LDT_SET,
276 NULL, NULL, NULL, NULL);
277 if (error)
278 return (error);
279
280 if (ua->start < 0 || ua->num < 0 || ua->start > 8192 || ua->num > 8192 ||
281 ua->start + ua->num > 8192)
282 return (EINVAL);
283
284 /* Check descriptors for access violations. */
285 for (i = 0; i < ua->num; i++) {
286 union descriptor *desc = &descv[i];
287
288 switch (desc->sd.sd_type) {
289 case SDT_SYSNULL:
290 desc->sd.sd_p = 0;
291 break;
292 case SDT_SYS286CGT:
293 case SDT_SYS386CGT:
294 /*
295 * Only allow call gates targeting a segment
296 * in the LDT or a user segment in the fixed
297 * part of the gdt. Segments in the LDT are
298 * constrained (below) to be user segments.
299 */
300 if (desc->gd.gd_p != 0 &&
301 !ISLDT(desc->gd.gd_selector) &&
302 ((IDXSEL(desc->gd.gd_selector) >= NGDT) ||
303 (gdt[IDXSEL(desc->gd.gd_selector)].sd.sd_dpl !=
304 SEL_UPL))) {
305 return EACCES;
306 }
307 break;
308 case SDT_MEMEC:
309 case SDT_MEMEAC:
310 case SDT_MEMERC:
311 case SDT_MEMERAC:
312 /* Must be "present" if executable and conforming. */
313 if (desc->sd.sd_p == 0)
314 return EACCES;
315 break;
316 case SDT_MEMRO:
317 case SDT_MEMROA:
318 case SDT_MEMRW:
319 case SDT_MEMRWA:
320 case SDT_MEMROD:
321 case SDT_MEMRODA:
322 case SDT_MEMRWD:
323 case SDT_MEMRWDA:
324 case SDT_MEME:
325 case SDT_MEMEA:
326 case SDT_MEMER:
327 case SDT_MEMERA:
328 break;
329 default:
330 /*
331 * Make sure that unknown descriptor types are
332 * not marked present.
333 */
334 if (desc->sd.sd_p != 0)
335 return EACCES;
336 break;
337 }
338
339 if (desc->sd.sd_p != 0) {
340 /* Only user (ring-3) descriptors may be present. */
341 if (desc->sd.sd_dpl != SEL_UPL)
342 return EACCES;
343 }
344 }
345
346 /* allocate user ldt */
347 free_sel = -1;
348 new_ldt = NULL;
349 new_len = 0;
350 free_ldt = NULL;
351 free_len = 0;
352 mutex_enter(&pmap->pm_lock);
353 if (pmap->pm_ldt == 0 || (ua->start + ua->num) > pmap->pm_ldt_len) {
354 if (pmap->pm_flags & PMF_USER_LDT)
355 ldt_len = pmap->pm_ldt_len;
356 else
357 ldt_len = 512;
358 while ((ua->start + ua->num) > ldt_len)
359 ldt_len *= 2;
360 new_len = ldt_len * sizeof(union descriptor);
361
362 mutex_exit(&pmap->pm_lock);
363 new_ldt = (union descriptor *)uvm_km_alloc(kernel_map,
364 new_len, 0, UVM_KMF_WIRED);
365 memset(new_ldt, 0, new_len);
366 sel = ldt_alloc(new_ldt, new_len);
367 mutex_enter(&pmap->pm_lock);
368
369 if (pmap->pm_ldt != NULL && ldt_len <= pmap->pm_ldt_len) {
370 /*
371 * Another thread (re)allocated the LDT to
372 * sufficient size while we were blocked in
373 * uvm_km_alloc. Oh well. The new entries
374 * will quite probably not be right, but
375 * hey.. not our problem if user applications
376 * have race conditions like that.
377 */
378 goto copy;
379 }
380
381 old_ldt = pmap->pm_ldt;
382 free_ldt = old_ldt;
383 free_len = pmap->pm_ldt_len * sizeof(union descriptor);
384
385 if (old_ldt != NULL) {
386 old_len = pmap->pm_ldt_len * sizeof(union descriptor);
387 } else {
388 old_len = NLDT * sizeof(union descriptor);
389 old_ldt = ldt;
390 }
391
392 memcpy(new_ldt, old_ldt, old_len);
393 memset((char *)new_ldt + old_len, 0, new_len - old_len);
394
395 pmap->pm_ldt = new_ldt;
396 pmap->pm_ldt_len = ldt_len;
397
398 if (pmap->pm_flags & PMF_USER_LDT)
399 free_sel = pmap->pm_ldt_sel;
400 else {
401 pmap->pm_flags |= PMF_USER_LDT;
402 free_sel = -1;
403 }
404 pmap->pm_ldt_sel = sel;
405 pcb->pcb_ldt_sel = pmap->pm_ldt_sel;
406 if (pcb == curpcb)
407 lldt(pcb->pcb_ldt_sel);
408 new_ldt = NULL;
409 }
410 copy:
411 /* Now actually replace the descriptors. */
412 for (i = 0, n = ua->start; i < ua->num; i++, n++)
413 pmap->pm_ldt[n] = descv[i];
414
415 mutex_exit(&pmap->pm_lock);
416
417 if (new_ldt != NULL)
418 uvm_km_free(kernel_map, (vaddr_t)new_ldt, new_len,
419 UVM_KMF_WIRED);
420 if (free_sel != -1)
421 ldt_free(free_sel);
422 if (free_ldt != NULL)
423 uvm_km_free(kernel_map, (vaddr_t)free_ldt, free_len,
424 UVM_KMF_WIRED);
425
426 return (error);
427 #endif
428 }
429
430 int
431 x86_iopl(struct lwp *l, void *args, register_t *retval)
432 {
433 int error;
434 struct x86_iopl_args ua;
435 #ifdef XEN
436 struct pcb *pcb = &l->l_addr->u_pcb;
437 #ifdef __x86_64__
438 #define TSS_IO tss_iobase
439 #else
440 #define TSS_IO tss_ioopt
441 #endif /* __x86_64__ */
442 #else
443 struct trapframe *tf = l->l_md.md_regs;
444 #endif
445
446 error = kauth_authorize_machdep(l->l_cred, KAUTH_MACHDEP_IOPL,
447 NULL, NULL, NULL, NULL);
448 if (error)
449 return (error);
450
451 if ((error = copyin(args, &ua, sizeof(ua))) != 0)
452 return error;
453
454 #ifdef XEN
455 {
456 pcb->pcb_tss.TSS_IO &= ~SEL_RPL;
457 if (ua.iopl)
458 pcb->pcb_tss.TSS_IO |= SEL_UPL; /* i/o pl */
459 else
460 pcb->pcb_tss.TSS_IO |= SEL_KPL; /* i/o pl */
461 }
462 /* Force the change at ring 0. */
463 #ifdef XEN3
464 {
465 struct physdev_op physop;
466 physop.cmd = PHYSDEVOP_SET_IOPL;
467 physop.u.set_iopl.iopl = pcb->pcb_tss.TSS_IO & SEL_RPL;
468 HYPERVISOR_physdev_op(&physop);
469 }
470 #else /* XEN3 */
471 {
472 dom0_op_t op;
473 op.cmd = DOM0_IOPL;
474 op.u.iopl.domain = DOMID_SELF;
475 op.u.iopl.iopl = pcb->pcb_tss.TSS_IO & SEL_RPL; /* i/o pl */
476 HYPERVISOR_dom0_op(&op);
477 }
478 #endif /* XEN3 */
479 #undef TSS_IO
480 #elif defined(__x86_64__)
481 if (ua.iopl)
482 tf->tf_rflags |= PSL_IOPL;
483 else
484 tf->tf_rflags &= ~PSL_IOPL;
485 #else
486 if (ua.iopl)
487 tf->tf_eflags |= PSL_IOPL;
488 else
489 tf->tf_eflags &= ~PSL_IOPL;
490 #endif
491
492 return 0;
493 }
494
495 int
496 x86_get_ioperm(struct lwp *l, void *args, register_t *retval)
497 {
498 #ifdef IOPERM
499 int error;
500 struct pcb *pcb = &l->l_addr->u_pcb;
501 struct x86_get_ioperm_args ua;
502
503 error = kauth_authorize_machdep(l->l_cred, KAUTH_MACHDEP_IOPERM_GET,
504 NULL, NULL, NULL, NULL);
505 if (error)
506 return (error);
507
508 if ((error = copyin(args, &ua, sizeof(ua))) != 0)
509 return (error);
510
511 return copyout(pcb->pcb_iomap, ua.iomap, sizeof(pcb->pcb_iomap));
512 #else
513 return EINVAL;
514 #endif
515 }
516
517 int
518 x86_set_ioperm(struct lwp *l, void *args, register_t *retval)
519 {
520 #ifdef IOPERM
521 int error;
522 struct pcb *pcb = &l->l_addr->u_pcb;
523 struct x86_set_ioperm_args ua;
524
525 error = kauth_authorize_machdep(l->l_cred, KAUTH_MACHDEP_IOPERM_SET,
526 NULL, NULL, NULL, NULL);
527 if (error)
528 return (error);
529
530 if ((error = copyin(args, &ua, sizeof(ua))) != 0)
531 return (error);
532
533 return copyin(ua.iomap, pcb->pcb_iomap, sizeof(pcb->pcb_iomap));
534 #else
535 return EINVAL;
536 #endif
537 }
538
539 int
540 x86_get_mtrr(struct lwp *l, void *args, register_t *retval)
541 {
542 #ifdef MTRR
543 struct x86_get_mtrr_args ua;
544 int error, n;
545
546 if (mtrr_funcs == NULL)
547 return ENOSYS;
548
549 error = kauth_authorize_machdep(l->l_cred, KAUTH_MACHDEP_MTRR_GET,
550 NULL, NULL, NULL, NULL);
551 if (error)
552 return (error);
553
554 error = copyin(args, &ua, sizeof ua);
555 if (error != 0)
556 return error;
557
558 error = copyin(ua.n, &n, sizeof n);
559 if (error != 0)
560 return error;
561
562 error = mtrr_get(ua.mtrrp, &n, l->l_proc, MTRR_GETSET_USER);
563
564 copyout(&n, ua.n, sizeof (int));
565
566 return error;
567 #else
568 return EINVAL;
569 #endif
570 }
571
572 int
573 x86_set_mtrr(struct lwp *l, void *args, register_t *retval)
574 {
575 #ifdef MTRR
576 int error, n;
577 struct x86_set_mtrr_args ua;
578
579 if (mtrr_funcs == NULL)
580 return ENOSYS;
581
582 error = kauth_authorize_machdep(l->l_cred, KAUTH_MACHDEP_MTRR_SET,
583 NULL, NULL, NULL, NULL);
584 if (error)
585 return (error);
586
587 error = copyin(args, &ua, sizeof ua);
588 if (error != 0)
589 return error;
590
591 error = copyin(ua.n, &n, sizeof n);
592 if (error != 0)
593 return error;
594
595 error = mtrr_set(ua.mtrrp, &n, l->l_proc, MTRR_GETSET_USER);
596 if (n != 0)
597 mtrr_commit();
598
599 copyout(&n, ua.n, sizeof n);
600
601 return error;
602 #else
603 return EINVAL;
604 #endif
605 }
606
607 int
608 x86_set_sdbase(void *arg, char which)
609 {
610 #ifdef i386
611 struct segment_descriptor sd;
612 vaddr_t base;
613 int error;
614
615 error = copyin(arg, &base, sizeof(base));
616 if (error != 0)
617 return error;
618
619 sd.sd_lobase = base & 0xffffff;
620 sd.sd_hibase = (base >> 24) & 0xff;
621 sd.sd_lolimit = 0xffff;
622 sd.sd_hilimit = 0xf;
623 sd.sd_type = SDT_MEMRWA;
624 sd.sd_dpl = SEL_UPL;
625 sd.sd_p = 1;
626 sd.sd_xx = 0;
627 sd.sd_def32 = 1;
628 sd.sd_gran = 1;
629
630 crit_enter();
631 if (which == 'f') {
632 memcpy(&curpcb->pcb_fsd, &sd, sizeof(sd));
633 memcpy(&curcpu()->ci_gdt[GUFS_SEL], &sd, sizeof(sd));
634 } else /* which == 'g' */ {
635 memcpy(&curpcb->pcb_gsd, &sd, sizeof(sd));
636 memcpy(&curcpu()->ci_gdt[GUGS_SEL], &sd, sizeof(sd));
637 }
638 crit_exit();
639
640 return 0;
641 #else
642 return EINVAL;
643 #endif
644 }
645
646 int
647 x86_get_sdbase(void *arg, char which)
648 {
649 #ifdef i386
650 struct segment_descriptor *sd;
651 vaddr_t base;
652
653 switch (which) {
654 case 'f':
655 sd = (struct segment_descriptor *)&curpcb->pcb_fsd;
656 break;
657 case 'g':
658 sd = (struct segment_descriptor *)&curpcb->pcb_gsd;
659 break;
660 default:
661 panic("x86_get_sdbase");
662 }
663
664 base = sd->sd_hibase << 24 | sd->sd_lobase;
665 return copyout(&base, &arg, sizeof(base));
666 #else
667 return EINVAL;
668 #endif
669 }
670
671 int
672 sys_sysarch(struct lwp *l, void *v, register_t *retval)
673 {
674 struct sys_sysarch_args /* {
675 syscallarg(int) op;
676 syscallarg(void *) parms;
677 } */ *uap = v;
678 int error = 0;
679
680 switch(SCARG(uap, op)) {
681 case X86_IOPL:
682 error = x86_iopl(l, SCARG(uap, parms), retval);
683 break;
684
685 case X86_GET_LDT:
686 error = x86_get_ldt(l, SCARG(uap, parms), retval);
687 break;
688
689 case X86_SET_LDT:
690 error = x86_set_ldt(l, SCARG(uap, parms), retval);
691 break;
692
693 case X86_GET_IOPERM:
694 error = x86_get_ioperm(l, SCARG(uap, parms), retval);
695 break;
696
697 case X86_SET_IOPERM:
698 error = x86_set_ioperm(l, SCARG(uap, parms), retval);
699 break;
700
701 case X86_GET_MTRR:
702 error = x86_get_mtrr(l, SCARG(uap, parms), retval);
703 break;
704 case X86_SET_MTRR:
705 error = x86_set_mtrr(l, SCARG(uap, parms), retval);
706 break;
707
708 #ifdef VM86
709 case X86_VM86:
710 error = x86_vm86(l, SCARG(uap, parms), retval);
711 break;
712 #ifdef COMPAT_16
713 case X86_OLD_VM86:
714 error = compat_16_x86_vm86(l, SCARG(uap, parms), retval);
715 break;
716 #endif
717 #endif
718
719 #ifdef PERFCTRS
720 case X86_PMC_INFO:
721 error = pmc_info(l, SCARG(uap, parms), retval);
722 break;
723
724 case X86_PMC_STARTSTOP:
725 error = pmc_startstop(l, SCARG(uap, parms), retval);
726 break;
727
728 case X86_PMC_READ:
729 error = pmc_read(l, SCARG(uap, parms), retval);
730 break;
731 #endif
732
733 case X86_SET_FSBASE:
734 error = x86_set_sdbase(SCARG(uap, parms), 'f');
735 break;
736
737 case X86_SET_GSBASE:
738 error = x86_set_sdbase(SCARG(uap, parms), 'g');
739 break;
740
741 case X86_GET_FSBASE:
742 error = x86_get_sdbase(SCARG(uap, parms), 'f');
743 break;
744
745 case X86_GET_GSBASE:
746 error = x86_get_sdbase(SCARG(uap, parms), 'g');
747 break;
748
749 default:
750 error = EINVAL;
751 break;
752 }
753 return (error);
754 }
755