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;
107 struct vmspace *oldvmspace;
111 LCONVPATHEXIST(td, args->path, &newpath);
115 printf(ARGS(execve, "%s"), newpath);
118 error = pre_execve(td, &oldvmspace);
120 free(newpath, M_TEMP);
123 error = exec_copyin_args(&eargs, newpath, UIO_SYSSPACE,
124 args->argp, args->envp);
125 free(newpath, M_TEMP);
127 error = kern_execve(td, &eargs, NULL);
129 error = linux_common_execve(td, &eargs);
130 post_execve(td, error, oldvmspace);
134 struct l_ipc_kludge {
135 struct l_msgbuf *msgp;
140 linux_ipc(struct thread *td, struct linux_ipc_args *args)
143 switch (args->what & 0xFFFF) {
145 struct linux_semop_args a;
147 a.semid = args->arg1;
149 a.nsops = args->arg2;
150 return (linux_semop(td, &a));
153 struct linux_semget_args a;
156 a.nsems = args->arg2;
157 a.semflg = args->arg3;
158 return (linux_semget(td, &a));
161 struct linux_semctl_args a;
164 a.semid = args->arg1;
165 a.semnum = args->arg2;
167 error = copyin(args->ptr, &a.arg, sizeof(a.arg));
170 return (linux_semctl(td, &a));
173 struct linux_msgsnd_args a;
175 a.msqid = args->arg1;
177 a.msgsz = args->arg2;
178 a.msgflg = args->arg3;
179 return (linux_msgsnd(td, &a));
182 struct linux_msgrcv_args a;
184 a.msqid = args->arg1;
185 a.msgsz = args->arg2;
186 a.msgflg = args->arg3;
187 if ((args->what >> 16) == 0) {
188 struct l_ipc_kludge tmp;
191 if (args->ptr == NULL)
193 error = copyin(args->ptr, &tmp, sizeof(tmp));
197 a.msgtyp = tmp.msgtyp;
200 a.msgtyp = args->arg5;
202 return (linux_msgrcv(td, &a));
205 struct linux_msgget_args a;
208 a.msgflg = args->arg2;
209 return (linux_msgget(td, &a));
212 struct linux_msgctl_args a;
214 a.msqid = args->arg1;
217 return (linux_msgctl(td, &a));
220 struct linux_shmat_args a;
222 a.shmid = args->arg1;
223 a.shmaddr = args->ptr;
224 a.shmflg = args->arg2;
225 a.raddr = (l_ulong *)args->arg3;
226 return (linux_shmat(td, &a));
229 struct linux_shmdt_args a;
231 a.shmaddr = args->ptr;
232 return (linux_shmdt(td, &a));
235 struct linux_shmget_args a;
239 a.shmflg = args->arg3;
240 return (linux_shmget(td, &a));
243 struct linux_shmctl_args a;
245 a.shmid = args->arg1;
248 return (linux_shmctl(td, &a));
258 linux_old_select(struct thread *td, struct linux_old_select_args *args)
260 struct l_old_select_argv linux_args;
261 struct linux_select_args newsel;
265 if (ldebug(old_select))
266 printf(ARGS(old_select, "%p"), args->ptr);
269 error = copyin(args->ptr, &linux_args, sizeof(linux_args));
273 newsel.nfds = linux_args.nfds;
274 newsel.readfds = linux_args.readfds;
275 newsel.writefds = linux_args.writefds;
276 newsel.exceptfds = linux_args.exceptfds;
277 newsel.timeout = linux_args.timeout;
278 return (linux_select(td, &newsel));
282 linux_set_cloned_tls(struct thread *td, void *desc)
284 struct segment_descriptor sd;
285 struct l_user_desc info;
289 error = copyin(desc, &info, sizeof(struct l_user_desc));
291 printf(LMSG("copyin failed!"));
293 idx = info.entry_number;
296 * looks like we're getting the idx we returned
297 * in the set_thread_area() syscall
299 if (idx != 6 && idx != 3) {
300 printf(LMSG("resetting idx!"));
304 /* this doesnt happen in practice */
306 /* we might copy out the entry_number as 3 */
307 info.entry_number = 3;
308 error = copyout(&info, desc, sizeof(struct l_user_desc));
310 printf(LMSG("copyout failed!"));
313 a[0] = LINUX_LDT_entry_a(&info);
314 a[1] = LINUX_LDT_entry_b(&info);
316 memcpy(&sd, &a, sizeof(a));
319 printf("Segment created in clone with "
320 "CLONE_SETTLS: lobase: %x, hibase: %x, "
321 "lolimit: %x, hilimit: %x, type: %i, "
322 "dpl: %i, p: %i, xx: %i, def32: %i, "
323 "gran: %i\n", sd.sd_lobase, sd.sd_hibase,
324 sd.sd_lolimit, sd.sd_hilimit, sd.sd_type,
325 sd.sd_dpl, sd.sd_p, sd.sd_xx,
326 sd.sd_def32, sd.sd_gran);
330 td->td_pcb->pcb_gsd = sd;
331 td->td_pcb->pcb_gs = GSEL(GUGS_SEL, SEL_UPL);
338 linux_set_upcall_kse(struct thread *td, register_t stack)
342 td->td_frame->tf_esp = stack;
345 * The newly created Linux thread returns
346 * to the user space by the same path that a parent do.
348 td->td_frame->tf_eax = 0;
352 #define STACK_SIZE (2 * 1024 * 1024)
353 #define GUARD_SIZE (4 * PAGE_SIZE)
356 linux_mmap2(struct thread *td, struct linux_mmap2_args *args)
361 printf(ARGS(mmap2, "%p, %d, %d, 0x%08x, %d, %d"),
362 (void *)args->addr, args->len, args->prot,
363 args->flags, args->fd, args->pgoff);
366 return (linux_mmap_common(td, args->addr, args->len, args->prot,
367 args->flags, args->fd, (uint64_t)(uint32_t)args->pgoff *
372 linux_mmap(struct thread *td, struct linux_mmap_args *args)
375 struct l_mmap_argv linux_args;
377 error = copyin(args->ptr, &linux_args, sizeof(linux_args));
383 printf(ARGS(mmap, "%p, %d, %d, 0x%08x, %d, %d"),
384 (void *)linux_args.addr, linux_args.len, linux_args.prot,
385 linux_args.flags, linux_args.fd, linux_args.pgoff);
388 return (linux_mmap_common(td, linux_args.addr, linux_args.len,
389 linux_args.prot, linux_args.flags, linux_args.fd,
390 (uint32_t)linux_args.pgoff));
394 linux_mmap_common(struct thread *td, l_uintptr_t addr, l_size_t len, l_int prot,
395 l_int flags, l_int fd, l_loff_t pos)
397 struct proc *p = td->td_proc;
398 struct mmap_args /* {
417 * You must specify exactly one of MAP_SHARED and MAP_PRIVATE
419 if (!((flags & LINUX_MAP_SHARED) ^ (flags & LINUX_MAP_PRIVATE)))
422 if (flags & LINUX_MAP_SHARED)
423 bsd_args.flags |= MAP_SHARED;
424 if (flags & LINUX_MAP_PRIVATE)
425 bsd_args.flags |= MAP_PRIVATE;
426 if (flags & LINUX_MAP_FIXED)
427 bsd_args.flags |= MAP_FIXED;
428 if (flags & LINUX_MAP_ANON) {
429 /* Enforce pos to be on page boundary, then ignore. */
430 if ((pos & PAGE_MASK) != 0)
433 bsd_args.flags |= MAP_ANON;
435 bsd_args.flags |= MAP_NOSYNC;
436 if (flags & LINUX_MAP_GROWSDOWN)
437 bsd_args.flags |= MAP_STACK;
440 * PROT_READ, PROT_WRITE, or PROT_EXEC implies PROT_READ and PROT_EXEC
441 * on Linux/i386. We do this to ensure maximum compatibility.
442 * Linux/ia64 does the same in i386 emulation mode.
444 bsd_args.prot = prot;
445 if (bsd_args.prot & (PROT_READ | PROT_WRITE | PROT_EXEC))
446 bsd_args.prot |= PROT_READ | PROT_EXEC;
448 /* Linux does not check file descriptor when MAP_ANONYMOUS is set. */
449 bsd_args.fd = (bsd_args.flags & MAP_ANON) ? -1 : fd;
450 if (bsd_args.fd != -1) {
452 * Linux follows Solaris mmap(2) description:
453 * The file descriptor fildes is opened with
454 * read permission, regardless of the
455 * protection options specified.
457 * Checking just CAP_MMAP is fine here, since the real work
458 * is done in the FreeBSD mmap().
461 error = fget(td, bsd_args.fd,
462 cap_rights_init(&rights, CAP_MMAP), &fp);
465 if (fp->f_type != DTYPE_VNODE) {
470 /* Linux mmap() just fails for O_WRONLY files */
471 if (!(fp->f_flag & FREAD)) {
479 if (flags & LINUX_MAP_GROWSDOWN) {
481 * The Linux MAP_GROWSDOWN option does not limit auto
482 * growth of the region. Linux mmap with this option
483 * takes as addr the inital BOS, and as len, the initial
484 * region size. It can then grow down from addr without
485 * limit. However, linux threads has an implicit internal
486 * limit to stack size of STACK_SIZE. Its just not
487 * enforced explicitly in linux. But, here we impose
488 * a limit of (STACK_SIZE - GUARD_SIZE) on the stack
489 * region, since we can do this with our mmap.
491 * Our mmap with MAP_STACK takes addr as the maximum
492 * downsize limit on BOS, and as len the max size of
493 * the region. It them maps the top SGROWSIZ bytes,
494 * and auto grows the region down, up to the limit
497 * If we don't use the MAP_STACK option, the effect
498 * of this code is to allocate a stack region of a
499 * fixed size of (STACK_SIZE - GUARD_SIZE).
502 if ((caddr_t)PTRIN(addr) + len > p->p_vmspace->vm_maxsaddr) {
504 * Some linux apps will attempt to mmap
505 * thread stacks near the top of their
506 * address space. If their TOS is greater
507 * than vm_maxsaddr, vm_map_growstack()
508 * will confuse the thread stack with the
509 * process stack and deliver a SEGV if they
510 * attempt to grow the thread stack past their
511 * current stacksize rlimit. To avoid this,
512 * adjust vm_maxsaddr upwards to reflect
513 * the current stacksize rlimit rather
514 * than the maximum possible stacksize.
515 * It would be better to adjust the
516 * mmap'ed region, but some apps do not check
517 * mmap's return value.
520 p->p_vmspace->vm_maxsaddr = (char *)USRSTACK -
521 lim_cur(p, RLIMIT_STACK);
526 * This gives us our maximum stack size and a new BOS.
527 * If we're using VM_STACK, then mmap will just map
528 * the top SGROWSIZ bytes, and let the stack grow down
529 * to the limit at BOS. If we're not using VM_STACK
530 * we map the full stack, since we don't have a way
533 if (len > STACK_SIZE - GUARD_SIZE) {
534 bsd_args.addr = (caddr_t)PTRIN(addr);
537 bsd_args.addr = (caddr_t)PTRIN(addr) -
538 (STACK_SIZE - GUARD_SIZE - len);
539 bsd_args.len = STACK_SIZE - GUARD_SIZE;
542 bsd_args.addr = (caddr_t)PTRIN(addr);
549 printf("-> %s(%p, %d, %d, 0x%08x, %d, 0x%x)\n",
551 (void *)bsd_args.addr, bsd_args.len, bsd_args.prot,
552 bsd_args.flags, bsd_args.fd, (int)bsd_args.pos);
554 error = sys_mmap(td, &bsd_args);
557 printf("-> %s() return: 0x%x (0x%08x)\n",
558 __func__, error, (u_int)td->td_retval[0]);
564 linux_mprotect(struct thread *td, struct linux_mprotect_args *uap)
566 struct mprotect_args bsd_args;
568 bsd_args.addr = uap->addr;
569 bsd_args.len = uap->len;
570 bsd_args.prot = uap->prot;
571 if (bsd_args.prot & (PROT_READ | PROT_WRITE | PROT_EXEC))
572 bsd_args.prot |= PROT_READ | PROT_EXEC;
573 return (sys_mprotect(td, &bsd_args));
577 linux_ioperm(struct thread *td, struct linux_ioperm_args *args)
580 struct i386_ioperm_args iia;
582 iia.start = args->start;
583 iia.length = args->length;
584 iia.enable = args->enable;
585 error = i386_set_ioperm(td, &iia);
590 linux_iopl(struct thread *td, struct linux_iopl_args *args)
594 if (args->level < 0 || args->level > 3)
596 if ((error = priv_check(td, PRIV_IO)) != 0)
598 if ((error = securelevel_gt(td->td_ucred, 0)) != 0)
600 td->td_frame->tf_eflags = (td->td_frame->tf_eflags & ~PSL_IOPL) |
601 (args->level * (PSL_IOPL / 3));
606 linux_modify_ldt(struct thread *td, struct linux_modify_ldt_args *uap)
609 struct i386_ldt_args ldt;
610 struct l_descriptor ld;
611 union descriptor desc;
615 case 0x00: /* read_ldt */
617 ldt.descs = uap->ptr;
618 ldt.num = uap->bytecount / sizeof(union descriptor);
619 error = i386_get_ldt(td, &ldt);
620 td->td_retval[0] *= sizeof(union descriptor);
622 case 0x02: /* read_default_ldt = 0 */
623 size = 5*sizeof(struct l_desc_struct);
624 if (size > uap->bytecount)
625 size = uap->bytecount;
626 for (written = error = 0; written < size && error == 0; written++)
627 error = subyte((char *)uap->ptr + written, 0);
628 td->td_retval[0] = written;
630 case 0x01: /* write_ldt */
631 case 0x11: /* write_ldt */
632 if (uap->bytecount != sizeof(ld))
635 error = copyin(uap->ptr, &ld, sizeof(ld));
639 ldt.start = ld.entry_number;
642 desc.sd.sd_lolimit = (ld.limit & 0x0000ffff);
643 desc.sd.sd_hilimit = (ld.limit & 0x000f0000) >> 16;
644 desc.sd.sd_lobase = (ld.base_addr & 0x00ffffff);
645 desc.sd.sd_hibase = (ld.base_addr & 0xff000000) >> 24;
646 desc.sd.sd_type = SDT_MEMRO | ((ld.read_exec_only ^ 1) << 1) |
649 desc.sd.sd_p = (ld.seg_not_present ^ 1);
651 desc.sd.sd_def32 = ld.seg_32bit;
652 desc.sd.sd_gran = ld.limit_in_pages;
653 error = i386_set_ldt(td, &ldt, &desc);
660 if (error == EOPNOTSUPP) {
661 printf("linux: modify_ldt needs kernel option USER_LDT\n");
669 linux_sigaction(struct thread *td, struct linux_sigaction_args *args)
672 l_sigaction_t act, oact;
676 if (ldebug(sigaction))
677 printf(ARGS(sigaction, "%d, %p, %p"),
678 args->sig, (void *)args->nsa, (void *)args->osa);
681 if (args->nsa != NULL) {
682 error = copyin(args->nsa, &osa, sizeof(l_osigaction_t));
685 act.lsa_handler = osa.lsa_handler;
686 act.lsa_flags = osa.lsa_flags;
687 act.lsa_restorer = osa.lsa_restorer;
688 LINUX_SIGEMPTYSET(act.lsa_mask);
689 act.lsa_mask.__bits[0] = osa.lsa_mask;
692 error = linux_do_sigaction(td, args->sig, args->nsa ? &act : NULL,
693 args->osa ? &oact : NULL);
695 if (args->osa != NULL && !error) {
696 osa.lsa_handler = oact.lsa_handler;
697 osa.lsa_flags = oact.lsa_flags;
698 osa.lsa_restorer = oact.lsa_restorer;
699 osa.lsa_mask = oact.lsa_mask.__bits[0];
700 error = copyout(&osa, args->osa, sizeof(l_osigaction_t));
707 * Linux has two extra args, restart and oldmask. We dont use these,
708 * but it seems that "restart" is actually a context pointer that
709 * enables the signal to happen with a different register set.
712 linux_sigsuspend(struct thread *td, struct linux_sigsuspend_args *args)
718 if (ldebug(sigsuspend))
719 printf(ARGS(sigsuspend, "%08lx"), (unsigned long)args->mask);
722 LINUX_SIGEMPTYSET(mask);
723 mask.__bits[0] = args->mask;
724 linux_to_bsd_sigset(&mask, &sigmask);
725 return (kern_sigsuspend(td, sigmask));
729 linux_rt_sigsuspend(struct thread *td, struct linux_rt_sigsuspend_args *uap)
736 if (ldebug(rt_sigsuspend))
737 printf(ARGS(rt_sigsuspend, "%p, %d"),
738 (void *)uap->newset, uap->sigsetsize);
741 if (uap->sigsetsize != sizeof(l_sigset_t))
744 error = copyin(uap->newset, &lmask, sizeof(l_sigset_t));
748 linux_to_bsd_sigset(&lmask, &sigmask);
749 return (kern_sigsuspend(td, sigmask));
753 linux_pause(struct thread *td, struct linux_pause_args *args)
755 struct proc *p = td->td_proc;
760 printf(ARGS(pause, ""));
764 sigmask = td->td_sigmask;
766 return (kern_sigsuspend(td, sigmask));
770 linux_sigaltstack(struct thread *td, struct linux_sigaltstack_args *uap)
777 if (ldebug(sigaltstack))
778 printf(ARGS(sigaltstack, "%p, %p"), uap->uss, uap->uoss);
781 if (uap->uss != NULL) {
782 error = copyin(uap->uss, &lss, sizeof(l_stack_t));
786 ss.ss_sp = lss.ss_sp;
787 ss.ss_size = lss.ss_size;
788 ss.ss_flags = linux_to_bsd_sigaltstack(lss.ss_flags);
790 error = kern_sigaltstack(td, (uap->uss != NULL) ? &ss : NULL,
791 (uap->uoss != NULL) ? &oss : NULL);
792 if (!error && uap->uoss != NULL) {
793 lss.ss_sp = oss.ss_sp;
794 lss.ss_size = oss.ss_size;
795 lss.ss_flags = bsd_to_linux_sigaltstack(oss.ss_flags);
796 error = copyout(&lss, uap->uoss, sizeof(l_stack_t));
803 linux_ftruncate64(struct thread *td, struct linux_ftruncate64_args *args)
805 struct ftruncate_args sa;
808 if (ldebug(ftruncate64))
809 printf(ARGS(ftruncate64, "%u, %jd"), args->fd,
810 (intmax_t)args->length);
814 sa.length = args->length;
815 return sys_ftruncate(td, &sa);
819 linux_set_thread_area(struct thread *td, struct linux_set_thread_area_args *args)
821 struct l_user_desc info;
825 struct segment_descriptor sd;
827 error = copyin(args->desc, &info, sizeof(struct l_user_desc));
832 if (ldebug(set_thread_area))
833 printf(ARGS(set_thread_area, "%i, %x, %x, %i, %i, %i, %i, %i, %i\n"),
841 info.seg_not_present,
845 idx = info.entry_number;
847 * Semantics of linux version: every thread in the system has array of
848 * 3 tls descriptors. 1st is GLIBC TLS, 2nd is WINE, 3rd unknown. This
849 * syscall loads one of the selected tls decriptors with a value and
850 * also loads GDT descriptors 6, 7 and 8 with the content of the
851 * per-thread descriptors.
853 * Semantics of fbsd version: I think we can ignore that linux has 3
854 * per-thread descriptors and use just the 1st one. The tls_array[]
855 * is used only in set/get-thread_area() syscalls and for loading the
856 * GDT descriptors. In fbsd we use just one GDT descriptor for TLS so
857 * we will load just one.
859 * XXX: this doesn't work when a user space process tries to use more
860 * than 1 TLS segment. Comment in the linux sources says wine might do
865 * we support just GLIBC TLS now
866 * we should let 3 proceed as well because we use this segment so
867 * if code does two subsequent calls it should succeed
869 if (idx != 6 && idx != -1 && idx != 3)
873 * we have to copy out the GDT entry we use
874 * FreeBSD uses GDT entry #3 for storing %gs so load that
876 * XXX: what if a user space program doesn't check this value and tries
879 idx = info.entry_number = 3;
880 error = copyout(&info, args->desc, sizeof(struct l_user_desc));
884 if (LINUX_LDT_empty(&info)) {
888 a[0] = LINUX_LDT_entry_a(&info);
889 a[1] = LINUX_LDT_entry_b(&info);
892 memcpy(&sd, &a, sizeof(a));
894 if (ldebug(set_thread_area))
895 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,
907 /* this is taken from i386 version of cpu_set_user_tls() */
910 td->td_pcb->pcb_gsd = sd;
911 PCPU_GET(fsgs_gdt)[1] = sd;
912 load_gs(GSEL(GUGS_SEL, SEL_UPL));
919 linux_get_thread_area(struct thread *td, struct linux_get_thread_area_args *args)
922 struct l_user_desc info;
925 struct l_desc_struct desc;
926 struct segment_descriptor sd;
929 if (ldebug(get_thread_area))
930 printf(ARGS(get_thread_area, "%p"), args->desc);
933 error = copyin(args->desc, &info, sizeof(struct l_user_desc));
937 idx = info.entry_number;
938 /* XXX: I am not sure if we want 3 to be allowed too. */
939 if (idx != 6 && idx != 3)
944 memset(&info, 0, sizeof(info));
946 sd = PCPU_GET(fsgs_gdt)[1];
948 memcpy(&desc, &sd, sizeof(desc));
950 info.entry_number = idx;
951 info.base_addr = LINUX_GET_BASE(&desc);
952 info.limit = LINUX_GET_LIMIT(&desc);
953 info.seg_32bit = LINUX_GET_32BIT(&desc);
954 info.contents = LINUX_GET_CONTENTS(&desc);
955 info.read_exec_only = !LINUX_GET_WRITABLE(&desc);
956 info.limit_in_pages = LINUX_GET_LIMIT_PAGES(&desc);
957 info.seg_not_present = !LINUX_GET_PRESENT(&desc);
958 info.useable = LINUX_GET_USEABLE(&desc);
960 error = copyout(&info, args->desc, sizeof(struct l_user_desc));
967 /* XXX: this wont work with module - convert it */
969 linux_mq_open(struct thread *td, struct linux_mq_open_args *args)
971 #ifdef P1003_1B_MQUEUE
972 return sys_kmq_open(td, (struct kmq_open_args *) args);
979 linux_mq_unlink(struct thread *td, struct linux_mq_unlink_args *args)
981 #ifdef P1003_1B_MQUEUE
982 return sys_kmq_unlink(td, (struct kmq_unlink_args *) args);
989 linux_mq_timedsend(struct thread *td, struct linux_mq_timedsend_args *args)
991 #ifdef P1003_1B_MQUEUE
992 return sys_kmq_timedsend(td, (struct kmq_timedsend_args *) args);
999 linux_mq_timedreceive(struct thread *td, struct linux_mq_timedreceive_args *args)
1001 #ifdef P1003_1B_MQUEUE
1002 return sys_kmq_timedreceive(td, (struct kmq_timedreceive_args *) args);
1009 linux_mq_notify(struct thread *td, struct linux_mq_notify_args *args)
1011 #ifdef P1003_1B_MQUEUE
1012 return sys_kmq_notify(td, (struct kmq_notify_args *) args);
1019 linux_mq_getsetattr(struct thread *td, struct linux_mq_getsetattr_args *args)
1021 #ifdef P1003_1B_MQUEUE
1022 return sys_kmq_setattr(td, (struct kmq_setattr_args *) args);