2 * Copyright (c) 2000 Marcel Moolenaar
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer
10 * in this position and unchanged.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #include <sys/cdefs.h>
30 __FBSDID("$FreeBSD$");
32 #include <sys/param.h>
33 #include <sys/systm.h>
34 #include <sys/capsicum.h>
36 #include <sys/fcntl.h>
37 #include <sys/imgact.h>
39 #include <sys/malloc.h>
41 #include <sys/mutex.h>
45 #include <sys/queue.h>
46 #include <sys/resource.h>
47 #include <sys/resourcevar.h>
48 #include <sys/signalvar.h>
49 #include <sys/syscallsubr.h>
50 #include <sys/sysproto.h>
51 #include <sys/unistd.h>
53 #include <sys/sched.h>
55 #include <machine/frame.h>
56 #include <machine/psl.h>
57 #include <machine/segments.h>
58 #include <machine/sysarch.h>
62 #include <vm/vm_map.h>
64 #include <i386/linux/linux.h>
65 #include <i386/linux/linux_proto.h>
66 #include <compat/linux/linux_ipc.h>
67 #include <compat/linux/linux_misc.h>
68 #include <compat/linux/linux_signal.h>
69 #include <compat/linux/linux_util.h>
70 #include <compat/linux/linux_emul.h>
72 #include <i386/include/pcb.h> /* needed for pcb definition in linux_set_thread_area */
74 #include "opt_posix.h"
76 extern struct sysentvec elf32_freebsd_sysvec; /* defined in i386/i386/elf_machdep.c */
84 l_uint read_exec_only:1;
85 l_uint limit_in_pages:1;
86 l_uint seg_not_present:1;
90 struct l_old_select_argv {
95 struct l_timeval *timeout;
98 static int linux_mmap_common(struct thread *td, l_uintptr_t addr,
99 l_size_t len, l_int prot, l_int flags, l_int fd,
104 linux_execve(struct thread *td, struct linux_execve_args *args)
106 struct image_args eargs;
110 LCONVPATHEXIST(td, args->path, &newpath);
114 printf(ARGS(execve, "%s"), newpath);
117 error = exec_copyin_args(&eargs, newpath, UIO_SYSSPACE,
118 args->argp, args->envp);
119 free(newpath, M_TEMP);
121 error = linux_common_execve(td, &eargs);
125 struct l_ipc_kludge {
126 struct l_msgbuf *msgp;
131 linux_ipc(struct thread *td, struct linux_ipc_args *args)
134 switch (args->what & 0xFFFF) {
136 struct linux_semop_args a;
138 a.semid = args->arg1;
140 a.nsops = args->arg2;
141 return (linux_semop(td, &a));
144 struct linux_semget_args a;
147 a.nsems = args->arg2;
148 a.semflg = args->arg3;
149 return (linux_semget(td, &a));
152 struct linux_semctl_args a;
155 a.semid = args->arg1;
156 a.semnum = args->arg2;
158 error = copyin(args->ptr, &a.arg, sizeof(a.arg));
161 return (linux_semctl(td, &a));
164 struct linux_msgsnd_args a;
166 a.msqid = args->arg1;
168 a.msgsz = args->arg2;
169 a.msgflg = args->arg3;
170 return (linux_msgsnd(td, &a));
173 struct linux_msgrcv_args a;
175 a.msqid = args->arg1;
176 a.msgsz = args->arg2;
177 a.msgflg = args->arg3;
178 if ((args->what >> 16) == 0) {
179 struct l_ipc_kludge tmp;
182 if (args->ptr == NULL)
184 error = copyin(args->ptr, &tmp, sizeof(tmp));
188 a.msgtyp = tmp.msgtyp;
191 a.msgtyp = args->arg5;
193 return (linux_msgrcv(td, &a));
196 struct linux_msgget_args a;
199 a.msgflg = args->arg2;
200 return (linux_msgget(td, &a));
203 struct linux_msgctl_args a;
205 a.msqid = args->arg1;
208 return (linux_msgctl(td, &a));
211 struct linux_shmat_args a;
213 a.shmid = args->arg1;
214 a.shmaddr = args->ptr;
215 a.shmflg = args->arg2;
216 a.raddr = (l_ulong *)args->arg3;
217 return (linux_shmat(td, &a));
220 struct linux_shmdt_args a;
222 a.shmaddr = args->ptr;
223 return (linux_shmdt(td, &a));
226 struct linux_shmget_args a;
230 a.shmflg = args->arg3;
231 return (linux_shmget(td, &a));
234 struct linux_shmctl_args a;
236 a.shmid = args->arg1;
239 return (linux_shmctl(td, &a));
249 linux_old_select(struct thread *td, struct linux_old_select_args *args)
251 struct l_old_select_argv linux_args;
252 struct linux_select_args newsel;
256 if (ldebug(old_select))
257 printf(ARGS(old_select, "%p"), args->ptr);
260 error = copyin(args->ptr, &linux_args, sizeof(linux_args));
264 newsel.nfds = linux_args.nfds;
265 newsel.readfds = linux_args.readfds;
266 newsel.writefds = linux_args.writefds;
267 newsel.exceptfds = linux_args.exceptfds;
268 newsel.timeout = linux_args.timeout;
269 return (linux_select(td, &newsel));
273 linux_set_cloned_tls(struct thread *td, void *desc)
275 struct segment_descriptor sd;
276 struct l_user_desc info;
280 error = copyin(desc, &info, sizeof(struct l_user_desc));
282 printf(LMSG("copyin failed!"));
284 idx = info.entry_number;
287 * looks like we're getting the idx we returned
288 * in the set_thread_area() syscall
290 if (idx != 6 && idx != 3) {
291 printf(LMSG("resetting idx!"));
295 /* this doesnt happen in practice */
297 /* we might copy out the entry_number as 3 */
298 info.entry_number = 3;
299 error = copyout(&info, desc, sizeof(struct l_user_desc));
301 printf(LMSG("copyout failed!"));
304 a[0] = LINUX_LDT_entry_a(&info);
305 a[1] = LINUX_LDT_entry_b(&info);
307 memcpy(&sd, &a, sizeof(a));
310 printf("Segment created in clone with "
311 "CLONE_SETTLS: lobase: %x, hibase: %x, "
312 "lolimit: %x, hilimit: %x, type: %i, "
313 "dpl: %i, p: %i, xx: %i, def32: %i, "
314 "gran: %i\n", sd.sd_lobase, sd.sd_hibase,
315 sd.sd_lolimit, sd.sd_hilimit, sd.sd_type,
316 sd.sd_dpl, sd.sd_p, sd.sd_xx,
317 sd.sd_def32, sd.sd_gran);
321 td->td_pcb->pcb_gsd = sd;
322 td->td_pcb->pcb_gs = GSEL(GUGS_SEL, SEL_UPL);
329 linux_set_upcall_kse(struct thread *td, register_t stack)
333 td->td_frame->tf_esp = stack;
336 * The newly created Linux thread returns
337 * to the user space by the same path that a parent do.
339 td->td_frame->tf_eax = 0;
343 #define STACK_SIZE (2 * 1024 * 1024)
344 #define GUARD_SIZE (4 * PAGE_SIZE)
347 linux_mmap2(struct thread *td, struct linux_mmap2_args *args)
352 printf(ARGS(mmap2, "%p, %d, %d, 0x%08x, %d, %d"),
353 (void *)args->addr, args->len, args->prot,
354 args->flags, args->fd, args->pgoff);
357 return (linux_mmap_common(td, args->addr, args->len, args->prot,
358 args->flags, args->fd, (uint64_t)(uint32_t)args->pgoff *
363 linux_mmap(struct thread *td, struct linux_mmap_args *args)
366 struct l_mmap_argv linux_args;
368 error = copyin(args->ptr, &linux_args, sizeof(linux_args));
374 printf(ARGS(mmap, "%p, %d, %d, 0x%08x, %d, %d"),
375 (void *)linux_args.addr, linux_args.len, linux_args.prot,
376 linux_args.flags, linux_args.fd, linux_args.pgoff);
379 return (linux_mmap_common(td, linux_args.addr, linux_args.len,
380 linux_args.prot, linux_args.flags, linux_args.fd,
381 (uint32_t)linux_args.pgoff));
385 linux_mmap_common(struct thread *td, l_uintptr_t addr, l_size_t len, l_int prot,
386 l_int flags, l_int fd, l_loff_t pos)
388 struct proc *p = td->td_proc;
389 struct mmap_args /* {
408 * You must specify exactly one of MAP_SHARED and MAP_PRIVATE
410 if (!((flags & LINUX_MAP_SHARED) ^ (flags & LINUX_MAP_PRIVATE)))
413 if (flags & LINUX_MAP_SHARED)
414 bsd_args.flags |= MAP_SHARED;
415 if (flags & LINUX_MAP_PRIVATE)
416 bsd_args.flags |= MAP_PRIVATE;
417 if (flags & LINUX_MAP_FIXED)
418 bsd_args.flags |= MAP_FIXED;
419 if (flags & LINUX_MAP_ANON) {
420 /* Enforce pos to be on page boundary, then ignore. */
421 if ((pos & PAGE_MASK) != 0)
424 bsd_args.flags |= MAP_ANON;
426 bsd_args.flags |= MAP_NOSYNC;
427 if (flags & LINUX_MAP_GROWSDOWN)
428 bsd_args.flags |= MAP_STACK;
431 * PROT_READ, PROT_WRITE, or PROT_EXEC implies PROT_READ and PROT_EXEC
432 * on Linux/i386. We do this to ensure maximum compatibility.
433 * Linux/ia64 does the same in i386 emulation mode.
435 bsd_args.prot = prot;
436 if (bsd_args.prot & (PROT_READ | PROT_WRITE | PROT_EXEC))
437 bsd_args.prot |= PROT_READ | PROT_EXEC;
439 /* Linux does not check file descriptor when MAP_ANONYMOUS is set. */
440 bsd_args.fd = (bsd_args.flags & MAP_ANON) ? -1 : fd;
441 if (bsd_args.fd != -1) {
443 * Linux follows Solaris mmap(2) description:
444 * The file descriptor fildes is opened with
445 * read permission, regardless of the
446 * protection options specified.
448 * Checking just CAP_MMAP is fine here, since the real work
449 * is done in the FreeBSD mmap().
452 error = fget(td, bsd_args.fd,
453 cap_rights_init(&rights, CAP_MMAP), &fp);
456 if (fp->f_type != DTYPE_VNODE) {
461 /* Linux mmap() just fails for O_WRONLY files */
462 if (!(fp->f_flag & FREAD)) {
470 if (flags & LINUX_MAP_GROWSDOWN) {
472 * The Linux MAP_GROWSDOWN option does not limit auto
473 * growth of the region. Linux mmap with this option
474 * takes as addr the inital BOS, and as len, the initial
475 * region size. It can then grow down from addr without
476 * limit. However, linux threads has an implicit internal
477 * limit to stack size of STACK_SIZE. Its just not
478 * enforced explicitly in linux. But, here we impose
479 * a limit of (STACK_SIZE - GUARD_SIZE) on the stack
480 * region, since we can do this with our mmap.
482 * Our mmap with MAP_STACK takes addr as the maximum
483 * downsize limit on BOS, and as len the max size of
484 * the region. It them maps the top SGROWSIZ bytes,
485 * and auto grows the region down, up to the limit
488 * If we don't use the MAP_STACK option, the effect
489 * of this code is to allocate a stack region of a
490 * fixed size of (STACK_SIZE - GUARD_SIZE).
493 if ((caddr_t)PTRIN(addr) + len > p->p_vmspace->vm_maxsaddr) {
495 * Some linux apps will attempt to mmap
496 * thread stacks near the top of their
497 * address space. If their TOS is greater
498 * than vm_maxsaddr, vm_map_growstack()
499 * will confuse the thread stack with the
500 * process stack and deliver a SEGV if they
501 * attempt to grow the thread stack past their
502 * current stacksize rlimit. To avoid this,
503 * adjust vm_maxsaddr upwards to reflect
504 * the current stacksize rlimit rather
505 * than the maximum possible stacksize.
506 * It would be better to adjust the
507 * mmap'ed region, but some apps do not check
508 * mmap's return value.
511 p->p_vmspace->vm_maxsaddr = (char *)USRSTACK -
512 lim_cur(p, RLIMIT_STACK);
517 * This gives us our maximum stack size and a new BOS.
518 * If we're using VM_STACK, then mmap will just map
519 * the top SGROWSIZ bytes, and let the stack grow down
520 * to the limit at BOS. If we're not using VM_STACK
521 * we map the full stack, since we don't have a way
524 if (len > STACK_SIZE - GUARD_SIZE) {
525 bsd_args.addr = (caddr_t)PTRIN(addr);
528 bsd_args.addr = (caddr_t)PTRIN(addr) -
529 (STACK_SIZE - GUARD_SIZE - len);
530 bsd_args.len = STACK_SIZE - GUARD_SIZE;
533 bsd_args.addr = (caddr_t)PTRIN(addr);
540 printf("-> %s(%p, %d, %d, 0x%08x, %d, 0x%x)\n",
542 (void *)bsd_args.addr, bsd_args.len, bsd_args.prot,
543 bsd_args.flags, bsd_args.fd, (int)bsd_args.pos);
545 error = sys_mmap(td, &bsd_args);
548 printf("-> %s() return: 0x%x (0x%08x)\n",
549 __func__, error, (u_int)td->td_retval[0]);
555 linux_mprotect(struct thread *td, struct linux_mprotect_args *uap)
557 struct mprotect_args bsd_args;
559 bsd_args.addr = uap->addr;
560 bsd_args.len = uap->len;
561 bsd_args.prot = uap->prot;
562 if (bsd_args.prot & (PROT_READ | PROT_WRITE | PROT_EXEC))
563 bsd_args.prot |= PROT_READ | PROT_EXEC;
564 return (sys_mprotect(td, &bsd_args));
568 linux_ioperm(struct thread *td, struct linux_ioperm_args *args)
571 struct i386_ioperm_args iia;
573 iia.start = args->start;
574 iia.length = args->length;
575 iia.enable = args->enable;
576 error = i386_set_ioperm(td, &iia);
581 linux_iopl(struct thread *td, struct linux_iopl_args *args)
585 if (args->level < 0 || args->level > 3)
587 if ((error = priv_check(td, PRIV_IO)) != 0)
589 if ((error = securelevel_gt(td->td_ucred, 0)) != 0)
591 td->td_frame->tf_eflags = (td->td_frame->tf_eflags & ~PSL_IOPL) |
592 (args->level * (PSL_IOPL / 3));
597 linux_modify_ldt(struct thread *td, struct linux_modify_ldt_args *uap)
600 struct i386_ldt_args ldt;
601 struct l_descriptor ld;
602 union descriptor desc;
606 case 0x00: /* read_ldt */
608 ldt.descs = uap->ptr;
609 ldt.num = uap->bytecount / sizeof(union descriptor);
610 error = i386_get_ldt(td, &ldt);
611 td->td_retval[0] *= sizeof(union descriptor);
613 case 0x02: /* read_default_ldt = 0 */
614 size = 5*sizeof(struct l_desc_struct);
615 if (size > uap->bytecount)
616 size = uap->bytecount;
617 for (written = error = 0; written < size && error == 0; written++)
618 error = subyte((char *)uap->ptr + written, 0);
619 td->td_retval[0] = written;
621 case 0x01: /* write_ldt */
622 case 0x11: /* write_ldt */
623 if (uap->bytecount != sizeof(ld))
626 error = copyin(uap->ptr, &ld, sizeof(ld));
630 ldt.start = ld.entry_number;
633 desc.sd.sd_lolimit = (ld.limit & 0x0000ffff);
634 desc.sd.sd_hilimit = (ld.limit & 0x000f0000) >> 16;
635 desc.sd.sd_lobase = (ld.base_addr & 0x00ffffff);
636 desc.sd.sd_hibase = (ld.base_addr & 0xff000000) >> 24;
637 desc.sd.sd_type = SDT_MEMRO | ((ld.read_exec_only ^ 1) << 1) |
640 desc.sd.sd_p = (ld.seg_not_present ^ 1);
642 desc.sd.sd_def32 = ld.seg_32bit;
643 desc.sd.sd_gran = ld.limit_in_pages;
644 error = i386_set_ldt(td, &ldt, &desc);
651 if (error == EOPNOTSUPP) {
652 printf("linux: modify_ldt needs kernel option USER_LDT\n");
660 linux_sigaction(struct thread *td, struct linux_sigaction_args *args)
663 l_sigaction_t act, oact;
667 if (ldebug(sigaction))
668 printf(ARGS(sigaction, "%d, %p, %p"),
669 args->sig, (void *)args->nsa, (void *)args->osa);
672 if (args->nsa != NULL) {
673 error = copyin(args->nsa, &osa, sizeof(l_osigaction_t));
676 act.lsa_handler = osa.lsa_handler;
677 act.lsa_flags = osa.lsa_flags;
678 act.lsa_restorer = osa.lsa_restorer;
679 LINUX_SIGEMPTYSET(act.lsa_mask);
680 act.lsa_mask.__mask = osa.lsa_mask;
683 error = linux_do_sigaction(td, args->sig, args->nsa ? &act : NULL,
684 args->osa ? &oact : NULL);
686 if (args->osa != NULL && !error) {
687 osa.lsa_handler = oact.lsa_handler;
688 osa.lsa_flags = oact.lsa_flags;
689 osa.lsa_restorer = oact.lsa_restorer;
690 osa.lsa_mask = oact.lsa_mask.__mask;
691 error = copyout(&osa, args->osa, sizeof(l_osigaction_t));
698 * Linux has two extra args, restart and oldmask. We dont use these,
699 * but it seems that "restart" is actually a context pointer that
700 * enables the signal to happen with a different register set.
703 linux_sigsuspend(struct thread *td, struct linux_sigsuspend_args *args)
709 if (ldebug(sigsuspend))
710 printf(ARGS(sigsuspend, "%08lx"), (unsigned long)args->mask);
713 LINUX_SIGEMPTYSET(mask);
714 mask.__mask = args->mask;
715 linux_to_bsd_sigset(&mask, &sigmask);
716 return (kern_sigsuspend(td, sigmask));
720 linux_rt_sigsuspend(struct thread *td, struct linux_rt_sigsuspend_args *uap)
727 if (ldebug(rt_sigsuspend))
728 printf(ARGS(rt_sigsuspend, "%p, %d"),
729 (void *)uap->newset, uap->sigsetsize);
732 if (uap->sigsetsize != sizeof(l_sigset_t))
735 error = copyin(uap->newset, &lmask, sizeof(l_sigset_t));
739 linux_to_bsd_sigset(&lmask, &sigmask);
740 return (kern_sigsuspend(td, sigmask));
744 linux_pause(struct thread *td, struct linux_pause_args *args)
746 struct proc *p = td->td_proc;
751 printf(ARGS(pause, ""));
755 sigmask = td->td_sigmask;
757 return (kern_sigsuspend(td, sigmask));
761 linux_sigaltstack(struct thread *td, struct linux_sigaltstack_args *uap)
768 if (ldebug(sigaltstack))
769 printf(ARGS(sigaltstack, "%p, %p"), uap->uss, uap->uoss);
772 if (uap->uss != NULL) {
773 error = copyin(uap->uss, &lss, sizeof(l_stack_t));
777 ss.ss_sp = lss.ss_sp;
778 ss.ss_size = lss.ss_size;
779 ss.ss_flags = linux_to_bsd_sigaltstack(lss.ss_flags);
781 error = kern_sigaltstack(td, (uap->uss != NULL) ? &ss : NULL,
782 (uap->uoss != NULL) ? &oss : NULL);
783 if (!error && uap->uoss != NULL) {
784 lss.ss_sp = oss.ss_sp;
785 lss.ss_size = oss.ss_size;
786 lss.ss_flags = bsd_to_linux_sigaltstack(oss.ss_flags);
787 error = copyout(&lss, uap->uoss, sizeof(l_stack_t));
794 linux_ftruncate64(struct thread *td, struct linux_ftruncate64_args *args)
796 struct ftruncate_args sa;
799 if (ldebug(ftruncate64))
800 printf(ARGS(ftruncate64, "%u, %jd"), args->fd,
801 (intmax_t)args->length);
805 sa.length = args->length;
806 return sys_ftruncate(td, &sa);
810 linux_set_thread_area(struct thread *td, struct linux_set_thread_area_args *args)
812 struct l_user_desc info;
816 struct segment_descriptor sd;
818 error = copyin(args->desc, &info, sizeof(struct l_user_desc));
823 if (ldebug(set_thread_area))
824 printf(ARGS(set_thread_area, "%i, %x, %x, %i, %i, %i, %i, %i, %i\n"),
832 info.seg_not_present,
836 idx = info.entry_number;
838 * Semantics of linux version: every thread in the system has array of
839 * 3 tls descriptors. 1st is GLIBC TLS, 2nd is WINE, 3rd unknown. This
840 * syscall loads one of the selected tls decriptors with a value and
841 * also loads GDT descriptors 6, 7 and 8 with the content of the
842 * per-thread descriptors.
844 * Semantics of fbsd version: I think we can ignore that linux has 3
845 * per-thread descriptors and use just the 1st one. The tls_array[]
846 * is used only in set/get-thread_area() syscalls and for loading the
847 * GDT descriptors. In fbsd we use just one GDT descriptor for TLS so
848 * we will load just one.
850 * XXX: this doesn't work when a user space process tries to use more
851 * than 1 TLS segment. Comment in the linux sources says wine might do
856 * we support just GLIBC TLS now
857 * we should let 3 proceed as well because we use this segment so
858 * if code does two subsequent calls it should succeed
860 if (idx != 6 && idx != -1 && idx != 3)
864 * we have to copy out the GDT entry we use
865 * FreeBSD uses GDT entry #3 for storing %gs so load that
867 * XXX: what if a user space program doesn't check this value and tries
870 idx = info.entry_number = 3;
871 error = copyout(&info, args->desc, sizeof(struct l_user_desc));
875 if (LINUX_LDT_empty(&info)) {
879 a[0] = LINUX_LDT_entry_a(&info);
880 a[1] = LINUX_LDT_entry_b(&info);
883 memcpy(&sd, &a, sizeof(a));
885 if (ldebug(set_thread_area))
886 printf("Segment created in set_thread_area: lobase: %x, hibase: %x, lolimit: %x, hilimit: %x, type: %i, dpl: %i, p: %i, xx: %i, def32: %i, gran: %i\n", sd.sd_lobase,
898 /* this is taken from i386 version of cpu_set_user_tls() */
901 td->td_pcb->pcb_gsd = sd;
902 PCPU_GET(fsgs_gdt)[1] = sd;
903 load_gs(GSEL(GUGS_SEL, SEL_UPL));
910 linux_get_thread_area(struct thread *td, struct linux_get_thread_area_args *args)
913 struct l_user_desc info;
916 struct l_desc_struct desc;
917 struct segment_descriptor sd;
920 if (ldebug(get_thread_area))
921 printf(ARGS(get_thread_area, "%p"), args->desc);
924 error = copyin(args->desc, &info, sizeof(struct l_user_desc));
928 idx = info.entry_number;
929 /* XXX: I am not sure if we want 3 to be allowed too. */
930 if (idx != 6 && idx != 3)
935 memset(&info, 0, sizeof(info));
937 sd = PCPU_GET(fsgs_gdt)[1];
939 memcpy(&desc, &sd, sizeof(desc));
941 info.entry_number = idx;
942 info.base_addr = LINUX_GET_BASE(&desc);
943 info.limit = LINUX_GET_LIMIT(&desc);
944 info.seg_32bit = LINUX_GET_32BIT(&desc);
945 info.contents = LINUX_GET_CONTENTS(&desc);
946 info.read_exec_only = !LINUX_GET_WRITABLE(&desc);
947 info.limit_in_pages = LINUX_GET_LIMIT_PAGES(&desc);
948 info.seg_not_present = !LINUX_GET_PRESENT(&desc);
949 info.useable = LINUX_GET_USEABLE(&desc);
951 error = copyout(&info, args->desc, sizeof(struct l_user_desc));
958 /* XXX: this wont work with module - convert it */
960 linux_mq_open(struct thread *td, struct linux_mq_open_args *args)
962 #ifdef P1003_1B_MQUEUE
963 return sys_kmq_open(td, (struct kmq_open_args *) args);
970 linux_mq_unlink(struct thread *td, struct linux_mq_unlink_args *args)
972 #ifdef P1003_1B_MQUEUE
973 return sys_kmq_unlink(td, (struct kmq_unlink_args *) args);
980 linux_mq_timedsend(struct thread *td, struct linux_mq_timedsend_args *args)
982 #ifdef P1003_1B_MQUEUE
983 return sys_kmq_timedsend(td, (struct kmq_timedsend_args *) args);
990 linux_mq_timedreceive(struct thread *td, struct linux_mq_timedreceive_args *args)
992 #ifdef P1003_1B_MQUEUE
993 return sys_kmq_timedreceive(td, (struct kmq_timedreceive_args *) args);
1000 linux_mq_notify(struct thread *td, struct linux_mq_notify_args *args)
1002 #ifdef P1003_1B_MQUEUE
1003 return sys_kmq_notify(td, (struct kmq_notify_args *) args);
1010 linux_mq_getsetattr(struct thread *td, struct linux_mq_getsetattr_args *args)
1012 #ifdef P1003_1B_MQUEUE
1013 return sys_kmq_setattr(td, (struct kmq_setattr_args *) args);