1*41aa5859Sriastradh /* $NetBSD: linux_machdep.c,v 1.51 2021/09/07 11:43:04 riastradh Exp $ */
254724278Smanu
354724278Smanu /*-
454724278Smanu * Copyright (c) 1995, 2000, 2001 The NetBSD Foundation, Inc.
554724278Smanu * All rights reserved.
654724278Smanu *
754724278Smanu * This code is derived from software contributed to The NetBSD Foundation
854724278Smanu * by Frank van der Linden and Emmanuel Dreyfus.
954724278Smanu *
1054724278Smanu * Redistribution and use in source and binary forms, with or without
1154724278Smanu * modification, are permitted provided that the following conditions
1254724278Smanu * are met:
1354724278Smanu * 1. Redistributions of source code must retain the above copyright
1454724278Smanu * notice, this list of conditions and the following disclaimer.
1554724278Smanu * 2. Redistributions in binary form must reproduce the above copyright
1654724278Smanu * notice, this list of conditions and the following disclaimer in the
1754724278Smanu * documentation and/or other materials provided with the distribution.
1854724278Smanu *
1954724278Smanu * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
2054724278Smanu * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2154724278Smanu * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2254724278Smanu * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2354724278Smanu * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2454724278Smanu * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2554724278Smanu * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2654724278Smanu * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2754724278Smanu * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2854724278Smanu * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2954724278Smanu * POSSIBILITY OF SUCH DAMAGE.
3054724278Smanu */
3154724278Smanu
32dab6ef8bSlukem #include <sys/cdefs.h>
33*41aa5859Sriastradh __KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.51 2021/09/07 11:43:04 riastradh Exp $");
34dab6ef8bSlukem
3554724278Smanu #include <sys/param.h>
3654724278Smanu #include <sys/systm.h>
3754724278Smanu #include <sys/signalvar.h>
3854724278Smanu #include <sys/kernel.h>
3954724278Smanu #include <sys/proc.h>
4054724278Smanu #include <sys/buf.h>
4154724278Smanu #include <sys/reboot.h>
4254724278Smanu #include <sys/conf.h>
4354724278Smanu #include <sys/exec.h>
4454724278Smanu #include <sys/file.h>
4554724278Smanu #include <sys/callout.h>
4654724278Smanu #include <sys/mbuf.h>
4754724278Smanu #include <sys/msgbuf.h>
4854724278Smanu #include <sys/mount.h>
4954724278Smanu #include <sys/vnode.h>
5054724278Smanu #include <sys/device.h>
5154724278Smanu #include <sys/syscallargs.h>
5254724278Smanu #include <sys/filedesc.h>
5354724278Smanu #include <sys/exec_elf.h>
5454724278Smanu #include <sys/disklabel.h>
55de8918d9Smanu #include <sys/ioctl.h>
5654724278Smanu #include <miscfs/specfs/specdev.h>
5754724278Smanu
5854724278Smanu #include <compat/linux/common/linux_types.h>
5954724278Smanu #include <compat/linux/common/linux_signal.h>
6054724278Smanu #include <compat/linux/common/linux_util.h>
6154724278Smanu #include <compat/linux/common/linux_ioctl.h>
6254724278Smanu #include <compat/linux/common/linux_hdio.h>
6354724278Smanu #include <compat/linux/common/linux_exec.h>
6454724278Smanu #include <compat/linux/common/linux_machdep.h>
6554724278Smanu
6654724278Smanu #include <compat/linux/linux_syscallargs.h>
6754724278Smanu
68a2a38285Sad #include <sys/cpu.h>
693d343db0Swiz #include <machine/fpu.h>
7054724278Smanu #include <machine/psl.h>
717146b2f6Srmind #include <machine/pcb.h>
7254724278Smanu #include <machine/vmparam.h>
7354724278Smanu
7454724278Smanu /*
7554724278Smanu * To see whether wscons is configured (for virtual console ioctl calls).
7654724278Smanu */
776a89288aSmrg #if defined(_KERNEL_OPT)
7854724278Smanu #include "wsdisplay.h"
7954724278Smanu #endif
8054724278Smanu #if (NWSDISPLAY > 0)
8154724278Smanu #include <dev/wscons/wsconsio.h>
8254724278Smanu #include <dev/wscons/wsdisplay_usl_io.h>
8354724278Smanu #endif
8454724278Smanu
8554724278Smanu /*
8654724278Smanu * Set set up registers on exec.
8754724278Smanu */
8854724278Smanu void
linux_setregs(struct lwp * l,struct exec_package * pack,vaddr_t stack)8933fa5ccbSchs linux_setregs(struct lwp *l, struct exec_package *pack, vaddr_t stack)
9054724278Smanu {
9146141a31Sthorpej setregs(l, pack, stack);
9254724278Smanu }
9354724278Smanu
9454724278Smanu /*
9554724278Smanu * Send an interrupt to process.
9654724278Smanu *
9754724278Smanu * Adapted from arch/powerpc/powerpc/sig_machdep.c:sendsig and
9854724278Smanu * compat/linux/arch/i386/linux_machdep.c:linux_sendsig
9954724278Smanu *
100bfaa81d0Smanu * XXX Does not work well yet with RT signals
10154724278Smanu *
10254724278Smanu */
10354724278Smanu
10485a5f306Smatt void
linux_sendsig(const ksiginfo_t * ksi,const sigset_t * mask)105cfba45c8Schristos linux_sendsig(const ksiginfo_t *ksi, const sigset_t *mask)
10654724278Smanu {
1078321b255Sthorpej const int sig = ksi->ksi_signo;
10846141a31Sthorpej struct lwp *l = curlwp;
10946141a31Sthorpej struct proc *p = l->l_proc;
11054724278Smanu struct trapframe *tf;
111011d4d5fSthorpej sig_t catcher = SIGACTION(p, sig).sa_handler;
112bb1594b2Smanu struct linux_sigregs frame;
11354724278Smanu struct linux_pt_regs linux_regs;
11454724278Smanu struct linux_sigcontext sc;
115bb1594b2Smanu register_t fp;
116b07ec3fcSad int onstack, error;
11754724278Smanu int i;
11854724278Smanu
11946141a31Sthorpej tf = trapframe(l);
12054724278Smanu
12154724278Smanu /*
12254724278Smanu * Do we need to jump onto the signal stack?
12354724278Smanu */
12454724278Smanu onstack =
125b07ec3fcSad (l->l_sigstk.ss_flags & (SS_DISABLE | SS_ONSTACK)) == 0 &&
12654724278Smanu (SIGACTION(p, sig).sa_flags & SA_ONSTACK) != 0;
12754724278Smanu
12854724278Smanu /*
12954724278Smanu * Signal stack is broken (see at the end of linux_sigreturn), so we do
13054724278Smanu * not use it yet. XXX fix this.
13154724278Smanu */
13254724278Smanu onstack=0;
13354724278Smanu
13454724278Smanu /*
13554724278Smanu * Allocate space for the signal handler context.
13654724278Smanu */
137ff4eeac9Schristos if (onstack) {
138bb1594b2Smanu fp = (register_t)
13948174a79Stsutsui ((char *)l->l_sigstk.ss_sp +
140b07ec3fcSad l->l_sigstk.ss_size);
141ff4eeac9Schristos } else {
142773e544eSmatt fp = tf->tf_fixreg[1];
143ff4eeac9Schristos }
144bb1594b2Smanu #ifdef DEBUG_LINUX
145bb1594b2Smanu printf("fp at start of linux_sendsig = %x\n", fp);
146bb1594b2Smanu #endif
147bb1594b2Smanu fp -= sizeof(struct linux_sigregs);
148bb1594b2Smanu fp &= ~0xf;
14954724278Smanu
15054724278Smanu /*
15154724278Smanu * Prepare a sigcontext for later.
15254724278Smanu */
153bb1594b2Smanu memset(&sc, 0, sizeof sc);
154ac29fb37Schristos sc.lsignal = (int)native_to_linux_signo[sig];
15554724278Smanu sc.lhandler = (unsigned long)catcher;
15628debea3Schristos native_to_linux_old_extra_sigset(&sc.lmask, &sc._unused[3], mask);
15754724278Smanu sc.lregs = (struct linux_pt_regs*)fp;
15854724278Smanu
15954724278Smanu /*
16054724278Smanu * Setup the signal stack frame as Linux does it in
16154724278Smanu * arch/ppc/kernel/signal.c:setup_frame()
16254724278Smanu *
16354724278Smanu * Save register context.
16454724278Smanu */
165*41aa5859Sriastradh memset(&linux_regs, 0, sizeof(linux_regs));
166ff4eeac9Schristos for (i = 0; i < 32; i++)
167773e544eSmatt linux_regs.lgpr[i] = tf->tf_fixreg[i];
168773e544eSmatt linux_regs.lnip = tf->tf_srr0;
169773e544eSmatt linux_regs.lmsr = tf->tf_srr1 & PSL_USERSRR1;
170773e544eSmatt linux_regs.lorig_gpr3 = tf->tf_fixreg[3]; /* XXX Is that right? */
171773e544eSmatt linux_regs.lctr = tf->tf_ctr;
172773e544eSmatt linux_regs.llink = tf->tf_lr;
173773e544eSmatt linux_regs.lxer = tf->tf_xer;
174773e544eSmatt linux_regs.lccr = tf->tf_cr;
17554724278Smanu linux_regs.lmq = 0; /* Unused, 601 only */
176773e544eSmatt linux_regs.ltrap = tf->tf_exc;
177773e544eSmatt linux_regs.ldar = tf->tf_dar;
178773e544eSmatt linux_regs.ldsisr = tf->tf_dsisr;
179bb1594b2Smanu linux_regs.lresult = 0;
18054724278Smanu
181bb1594b2Smanu memset(&frame, 0, sizeof(frame));
182bb1594b2Smanu memcpy(&frame.lgp_regs, &linux_regs, sizeof(linux_regs));
183bb1594b2Smanu
184cf77a76bSmatt #ifdef PPC_HAVE_FPU
185877a3ccfSchs fpu_save(l);
186cf77a76bSmatt #endif
187a6b639c3Smatt memcpy(&frame.lfp_regs, curpcb->pcb_fpu.fpreg, sizeof(frame.lfp_regs));
18854724278Smanu
18954724278Smanu /*
190ff4eeac9Schristos * Copy Linux's signal trampoline on the user stack It should not
191bfaa81d0Smanu * be used, but Linux binaries might expect it to be there.
19254724278Smanu */
19354724278Smanu frame.ltramp[0] = 0x38997777; /* li r0, 0x7777 */
19454724278Smanu frame.ltramp[1] = 0x44000002; /* sc */
19554724278Smanu
19654724278Smanu /*
19754724278Smanu * Move it to the user stack
19854724278Smanu * There is a little trick here, about the LINUX_ABIGAP: the
19954724278Smanu * linux_sigreg structure has a 56 int gap to support rs6000/xcoff
20054724278Smanu * binaries. But the Linux kernel seems to do without it, and it
20154724278Smanu * just skip it when building the stack frame. Hence the LINUX_ABIGAP.
20254724278Smanu */
203b07ec3fcSad sendsig_reset(l, sig);
204284c2b9aSad mutex_exit(p->p_lock);
20553524e44Schristos error = copyout(&frame, (void *)fp, sizeof (frame) - LINUX_ABIGAP);
206b07ec3fcSad
207b07ec3fcSad if (error != 0) {
20854724278Smanu /*
20954724278Smanu * Process has trashed its stack; give it an illegal
210383c1b63Smanu * instruction to halt it in its tracks.
21154724278Smanu */
212284c2b9aSad mutex_enter(p->p_lock);
21346141a31Sthorpej sigexit(l, SIGILL);
21454724278Smanu /* NOTREACHED */
21554724278Smanu }
21654724278Smanu
21754724278Smanu /*
21854724278Smanu * Add a sigcontext on the stack
21954724278Smanu */
220bb1594b2Smanu fp -= sizeof(struct linux_sigcontext);
22153524e44Schristos error = copyout(&sc, (void *)fp, sizeof (struct linux_sigcontext));
222284c2b9aSad mutex_enter(p->p_lock);
223b07ec3fcSad
224b07ec3fcSad if (error != 0) {
22554724278Smanu /*
22654724278Smanu * Process has trashed its stack; give it an illegal
227383c1b63Smanu * instruction to halt it in its tracks.
22854724278Smanu */
22946141a31Sthorpej sigexit(l, SIGILL);
23054724278Smanu /* NOTREACHED */
23154724278Smanu }
23254724278Smanu
23354724278Smanu /*
234bb1594b2Smanu * Set the registers according to how the Linux process expects them.
235bb1594b2Smanu * "Mind the gap" Linux expects a gap here.
23654724278Smanu */
237773e544eSmatt tf->tf_fixreg[1] = fp - LINUX__SIGNAL_FRAMESIZE;
238773e544eSmatt tf->tf_lr = (int)catcher;
239773e544eSmatt tf->tf_fixreg[3] = (int)native_to_linux_signo[sig];
240773e544eSmatt tf->tf_fixreg[4] = fp;
241773e544eSmatt tf->tf_srr0 = (int)p->p_sigctx.ps_sigcode;
24254724278Smanu
243bb1594b2Smanu #ifdef DEBUG_LINUX
244bb1594b2Smanu printf("fp at end of linux_sendsig = %x\n", fp);
245bb1594b2Smanu #endif
24654724278Smanu /*
24754724278Smanu * Remember that we're now on the signal stack.
24854724278Smanu */
24954724278Smanu if (onstack)
250b07ec3fcSad l->l_sigstk.ss_flags |= SS_ONSTACK;
25154724278Smanu #ifdef DEBUG_LINUX
252c826b564Smbalmer printf("linux_sendsig: exiting. fp=0x%lx\n",(long)fp);
25354724278Smanu #endif
25454724278Smanu }
25554724278Smanu
25654724278Smanu /*
25754724278Smanu * System call to cleanup state after a signal
25854724278Smanu * has been taken. Reset signal mask and
25954724278Smanu * stack state from context left by sendsig (above).
26054724278Smanu * Return to previous pc and psl as specified by
26154724278Smanu * context left by sendsig. Check carefully to
26254724278Smanu * make sure that the user has not modified the
26354724278Smanu * psl to gain improper privileges or to cause
26454724278Smanu * a machine fault.
26554724278Smanu *
26654724278Smanu * XXX not tested
26754724278Smanu */
26854724278Smanu int
linux_sys_rt_sigreturn(struct lwp * l,const struct linux_sys_rt_sigreturn_args * uap,register_t * retval)2697e2790cfSdsl linux_sys_rt_sigreturn(struct lwp *l, const struct linux_sys_rt_sigreturn_args *uap, register_t *retval)
27054724278Smanu {
2717e2790cfSdsl /* {
27254724278Smanu syscallarg(struct linux_rt_sigframe *) sfp;
2737e2790cfSdsl } */
27446141a31Sthorpej struct proc *p = l->l_proc;
27554724278Smanu struct linux_rt_sigframe *scp, sigframe;
276bb1594b2Smanu struct linux_sigregs sregs;
277bb1594b2Smanu struct linux_pt_regs *lregs;
27854724278Smanu struct trapframe *tf;
27954724278Smanu sigset_t mask;
28054724278Smanu int i;
28154724278Smanu
28254724278Smanu /*
28354724278Smanu * The trampoline code hands us the context.
28454724278Smanu * It is unsafe to keep track of it ourselves, in the event that a
28554724278Smanu * program jumps out of a signal handler.
28654724278Smanu */
28754724278Smanu scp = SCARG(uap, sfp);
28854724278Smanu
28954724278Smanu /*
29054724278Smanu * Get the context from user stack
29154724278Smanu */
29253524e44Schristos if (copyin((void *)scp, &sigframe, sizeof(*scp)))
29354724278Smanu return (EFAULT);
29454724278Smanu
29554724278Smanu /*
296bb1594b2Smanu * Restore register context.
29754724278Smanu */
29853524e44Schristos if (copyin((void *)sigframe.luc.luc_context.lregs,
299bb1594b2Smanu &sregs, sizeof(sregs)))
300bb1594b2Smanu return (EFAULT);
301bb1594b2Smanu lregs = (struct linux_pt_regs *)&sregs.lgp_regs;
302bb1594b2Smanu
30346141a31Sthorpej tf = trapframe(l);
30454724278Smanu #ifdef DEBUG_LINUX
30511b7e600Swiz printf("linux_sys_rt_sigreturn: trapframe=0x%lx scp=0x%lx\n",
30654724278Smanu (unsigned long)tf, (unsigned long)scp);
30754724278Smanu #endif
30854724278Smanu
309a6b639c3Smatt if (!PSL_USEROK_P(lregs->lmsr))
31054724278Smanu return (EINVAL);
31154724278Smanu
312ff4eeac9Schristos for (i = 0; i < 32; i++)
313773e544eSmatt tf->tf_fixreg[i] = lregs->lgpr[i];
314773e544eSmatt tf->tf_lr = lregs->llink;
315773e544eSmatt tf->tf_cr = lregs->lccr;
316773e544eSmatt tf->tf_xer = lregs->lxer;
317773e544eSmatt tf->tf_ctr = lregs->lctr;
318773e544eSmatt tf->tf_srr0 = lregs->lnip;
319773e544eSmatt tf->tf_srr1 = lregs->lmsr;
320bb1594b2Smanu
321a6b639c3Smatt /*
322a6b639c3Smatt * Make sure the fpu state is discarded
323a6b639c3Smatt */
324cf77a76bSmatt #ifdef PPC_HAVE_FPU
325875fe973Schs fpu_discard(l);
326cf77a76bSmatt #endif
327a6b639c3Smatt
32853524e44Schristos memcpy(curpcb->pcb_fpu.fpreg, (void *)&sregs.lfp_regs,
329a6b639c3Smatt sizeof(curpcb->pcb_fpu.fpreg));
33054724278Smanu
331875fe973Schs fpu_mark_used(l);
332cf77a76bSmatt
333284c2b9aSad mutex_enter(p->p_lock);
334b07ec3fcSad
33554724278Smanu /*
33654724278Smanu * Restore signal stack.
33754724278Smanu *
33854724278Smanu * XXX cannot find the onstack information in Linux sig context.
33954724278Smanu * Is signal stack really supported on Linux?
34054724278Smanu *
34154724278Smanu * It seems to be supported in libc6...
34254724278Smanu */
34354724278Smanu /* if (sc.sc_onstack & SS_ONSTACK)
344b07ec3fcSad l->l_sigstk.ss_flags |= SS_ONSTACK;
34554724278Smanu else */
346b07ec3fcSad l->l_sigstk.ss_flags &= ~SS_ONSTACK;
34754724278Smanu
348bb1594b2Smanu /*
349bb1594b2Smanu * Grab the signal mask
350bb1594b2Smanu */
35128debea3Schristos linux_to_native_sigset(&mask, &sigframe.luc.luc_sigmask);
352b07ec3fcSad (void) sigprocmask1(l, SIG_SETMASK, &mask, 0);
353b07ec3fcSad
354284c2b9aSad mutex_exit(p->p_lock);
355bb1594b2Smanu
35654724278Smanu return (EJUSTRETURN);
35754724278Smanu }
35854724278Smanu
35954724278Smanu
36054724278Smanu /*
36154724278Smanu * The following needs code review for potential security issues
36254724278Smanu */
36354724278Smanu int
linux_sys_sigreturn(struct lwp * l,const struct linux_sys_sigreturn_args * uap,register_t * retval)3647e2790cfSdsl linux_sys_sigreturn(struct lwp *l, const struct linux_sys_sigreturn_args *uap, register_t *retval)
36554724278Smanu {
3667e2790cfSdsl /* {
36754724278Smanu syscallarg(struct linux_sigcontext *) scp;
3687e2790cfSdsl } */
36946141a31Sthorpej struct proc *p = l->l_proc;
37054724278Smanu struct linux_sigcontext *scp, context;
371bb1594b2Smanu struct linux_sigregs sregs;
372bb1594b2Smanu struct linux_pt_regs *lregs;
37354724278Smanu struct trapframe *tf;
37454724278Smanu sigset_t mask;
37554724278Smanu int i;
37654724278Smanu
37754724278Smanu /*
37854724278Smanu * The trampoline code hands us the context.
37954724278Smanu * It is unsafe to keep track of it ourselves, in the event that a
38054724278Smanu * program jumps out of a signal handler.
38154724278Smanu */
38254724278Smanu scp = SCARG(uap, scp);
38354724278Smanu
38454724278Smanu /*
38554724278Smanu * Get the context from user stack
38654724278Smanu */
387bb1594b2Smanu if (copyin(scp, &context, sizeof(*scp)))
38854724278Smanu return (EFAULT);
38954724278Smanu
39054724278Smanu /*
391bb1594b2Smanu * Restore register context.
392bb1594b2Smanu */
39353524e44Schristos if (copyin((void *)context.lregs, &sregs, sizeof(sregs)))
394bb1594b2Smanu return (EFAULT);
395bb1594b2Smanu lregs = (struct linux_pt_regs *)&sregs.lgp_regs;
396bb1594b2Smanu
39746141a31Sthorpej tf = trapframe(l);
39854724278Smanu #ifdef DEBUG_LINUX
39954724278Smanu printf("linux_sys_sigreturn: trapframe=0x%lx scp=0x%lx\n",
40054724278Smanu (unsigned long)tf, (unsigned long)scp);
40154724278Smanu #endif
40254724278Smanu
403a6b639c3Smatt if (!PSL_USEROK_P(lregs->lmsr))
40454724278Smanu return (EINVAL);
40554724278Smanu
406ff4eeac9Schristos for (i = 0; i < 32; i++)
407773e544eSmatt tf->tf_fixreg[i] = lregs->lgpr[i];
408773e544eSmatt tf->tf_lr = lregs->llink;
409773e544eSmatt tf->tf_cr = lregs->lccr;
410773e544eSmatt tf->tf_xer = lregs->lxer;
411773e544eSmatt tf->tf_ctr = lregs->lctr;
412773e544eSmatt tf->tf_srr0 = lregs->lnip;
413773e544eSmatt tf->tf_srr1 = lregs->lmsr;
414bb1594b2Smanu
415a6b639c3Smatt /*
416a6b639c3Smatt * Make sure the fpu state is discarded
417a6b639c3Smatt */
418cf77a76bSmatt #ifdef PPC_HAVE_FPU
419875fe973Schs fpu_discard(l);
420cf77a76bSmatt #endif
421a6b639c3Smatt
42253524e44Schristos memcpy(curpcb->pcb_fpu.fpreg, (void *)&sregs.lfp_regs,
423a6b639c3Smatt sizeof(curpcb->pcb_fpu.fpreg));
42454724278Smanu
425875fe973Schs fpu_mark_used(l);
426cf77a76bSmatt
427284c2b9aSad mutex_enter(p->p_lock);
428b07ec3fcSad
42954724278Smanu /*
43054724278Smanu * Restore signal stack.
43154724278Smanu *
43254724278Smanu * XXX cannot find the onstack information in Linux sig context.
43354724278Smanu * Is signal stack really supported on Linux?
43454724278Smanu */
435ff4eeac9Schristos #if 0
436ff4eeac9Schristos if (sc.sc_onstack & SS_ONSTACK)
437b07ec3fcSad l->l_sigstk.ss_flags |= SS_ONSTACK;
438ff4eeac9Schristos else
439ff4eeac9Schristos #endif
440b07ec3fcSad l->l_sigstk.ss_flags &= ~SS_ONSTACK;
44154724278Smanu
44254724278Smanu /* Restore signal mask. */
44328debea3Schristos linux_old_extra_to_native_sigset(&mask, &context.lmask,
44428debea3Schristos &context._unused[3]);
445b07ec3fcSad (void) sigprocmask1(l, SIG_SETMASK, &mask, 0);
446b07ec3fcSad
447284c2b9aSad mutex_exit(p->p_lock);
44854724278Smanu
44954724278Smanu return (EJUSTRETURN);
45054724278Smanu }
45154724278Smanu
452bfaa81d0Smanu /*
453bfaa81d0Smanu * major device numbers remapping
454bfaa81d0Smanu */
45554724278Smanu dev_t
linux_fakedev(dev_t dev,int raw)45628bae79bSdsl linux_fakedev(dev_t dev, int raw)
45754724278Smanu {
45854724278Smanu /* XXX write me */
45954724278Smanu return dev;
46054724278Smanu }
46154724278Smanu
46254724278Smanu /*
46354724278Smanu * We come here in a last attempt to satisfy a Linux ioctl() call
46454724278Smanu */
46554724278Smanu int
linux_machdepioctl(struct lwp * l,const struct linux_sys_ioctl_args * uap,register_t * retval)4667e2790cfSdsl linux_machdepioctl(struct lwp *l, const struct linux_sys_ioctl_args *uap, register_t *retval)
46754724278Smanu {
4687e2790cfSdsl /* {
46954724278Smanu syscallarg(int) fd;
47054724278Smanu syscallarg(u_long) com;
47153524e44Schristos syscallarg(void *) data;
4727e2790cfSdsl } */
47354724278Smanu struct sys_ioctl_args bia;
47454724278Smanu u_long com;
47554724278Smanu
47654724278Smanu SCARG(&bia, fd) = SCARG(uap, fd);
47754724278Smanu SCARG(&bia, data) = SCARG(uap, data);
47854724278Smanu com = SCARG(uap, com);
47954724278Smanu
48054724278Smanu switch (com) {
48154724278Smanu default:
48254724278Smanu printf("linux_machdepioctl: invalid ioctl %08lx\n", com);
48354724278Smanu return EINVAL;
48454724278Smanu }
48554724278Smanu SCARG(&bia, com) = com;
48646141a31Sthorpej /* XXX NJWLWP */
487d5aece61Sfvdl return sys_ioctl(curlwp, &bia, retval);
48854724278Smanu }
48954724278Smanu
49054724278Smanu /*
49154724278Smanu * wrapper linux_sys_new_uname() -> linux_sys_uname()
49254724278Smanu */
49354724278Smanu int
linux_sys_new_uname(struct lwp * l,const struct linux_sys_new_uname_args * uap,register_t * retval)4947e2790cfSdsl linux_sys_new_uname(struct lwp *l, const struct linux_sys_new_uname_args *uap, register_t *retval)
49554724278Smanu {
4967e2790cfSdsl return linux_sys_uname(l, (const void *)uap, retval);
49754724278Smanu }
49854724278Smanu
49954724278Smanu /*
50054724278Smanu * wrapper linux_sys_new_select() -> linux_sys_select()
50154724278Smanu */
50254724278Smanu int
linux_sys_new_select(struct lwp * l,const struct linux_sys_new_select_args * uap,register_t * retval)5037e2790cfSdsl linux_sys_new_select(struct lwp *l, const struct linux_sys_new_select_args *uap, register_t *retval)
50454724278Smanu {
5057e2790cfSdsl return linux_sys_select(l, (const void *)uap, retval);
50654724278Smanu }
50733e2d79fSfvdl
50833e2d79fSfvdl int
linux_usertrap(struct lwp * l,vaddr_t trapaddr,void * arg)50933e2d79fSfvdl linux_usertrap(struct lwp *l, vaddr_t trapaddr, void *arg)
51033e2d79fSfvdl {
51133e2d79fSfvdl return 0;
51233e2d79fSfvdl }
513