Home | History | Annotate | Line # | Download | only in powerpc
linux_machdep.c revision 1.39.2.2
      1  1.39.2.2  wrstuden /*	$NetBSD: linux_machdep.c,v 1.39.2.2 2008/05/14 01:35:04 wrstuden Exp $ */
      2       1.1      manu 
      3       1.1      manu /*-
      4       1.1      manu  * Copyright (c) 1995, 2000, 2001 The NetBSD Foundation, Inc.
      5       1.1      manu  * All rights reserved.
      6       1.1      manu  *
      7       1.1      manu  * This code is derived from software contributed to The NetBSD Foundation
      8       1.1      manu  * by Frank van der Linden and Emmanuel Dreyfus.
      9       1.1      manu  *
     10       1.1      manu  * Redistribution and use in source and binary forms, with or without
     11       1.1      manu  * modification, are permitted provided that the following conditions
     12       1.1      manu  * are met:
     13       1.1      manu  * 1. Redistributions of source code must retain the above copyright
     14       1.1      manu  *    notice, this list of conditions and the following disclaimer.
     15       1.1      manu  * 2. Redistributions in binary form must reproduce the above copyright
     16       1.1      manu  *    notice, this list of conditions and the following disclaimer in the
     17       1.1      manu  *    documentation and/or other materials provided with the distribution.
     18       1.1      manu  *
     19       1.1      manu  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20       1.1      manu  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21       1.1      manu  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22       1.1      manu  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23       1.1      manu  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24       1.1      manu  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25       1.1      manu  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26       1.1      manu  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27       1.1      manu  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28       1.1      manu  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29       1.1      manu  * POSSIBILITY OF SUCH DAMAGE.
     30       1.1      manu  */
     31      1.12     lukem 
     32      1.12     lukem #include <sys/cdefs.h>
     33  1.39.2.2  wrstuden __KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.39.2.2 2008/05/14 01:35:04 wrstuden Exp $");
     34       1.1      manu 
     35       1.1      manu #include <sys/param.h>
     36       1.1      manu #include <sys/systm.h>
     37       1.1      manu #include <sys/signalvar.h>
     38       1.1      manu #include <sys/kernel.h>
     39       1.1      manu #include <sys/proc.h>
     40       1.1      manu #include <sys/user.h>
     41       1.1      manu #include <sys/buf.h>
     42       1.1      manu #include <sys/reboot.h>
     43       1.1      manu #include <sys/conf.h>
     44       1.1      manu #include <sys/exec.h>
     45       1.1      manu #include <sys/file.h>
     46       1.1      manu #include <sys/callout.h>
     47       1.1      manu #include <sys/malloc.h>
     48       1.1      manu #include <sys/mbuf.h>
     49       1.1      manu #include <sys/msgbuf.h>
     50       1.1      manu #include <sys/mount.h>
     51       1.1      manu #include <sys/vnode.h>
     52       1.1      manu #include <sys/device.h>
     53       1.1      manu #include <sys/syscallargs.h>
     54       1.1      manu #include <sys/filedesc.h>
     55       1.1      manu #include <sys/exec_elf.h>
     56       1.1      manu #include <sys/disklabel.h>
     57       1.3      manu #include <sys/ioctl.h>
     58       1.1      manu #include <miscfs/specfs/specdev.h>
     59       1.1      manu 
     60       1.1      manu #include <compat/linux/common/linux_types.h>
     61       1.1      manu #include <compat/linux/common/linux_signal.h>
     62       1.1      manu #include <compat/linux/common/linux_util.h>
     63       1.1      manu #include <compat/linux/common/linux_ioctl.h>
     64       1.1      manu #include <compat/linux/common/linux_hdio.h>
     65       1.1      manu #include <compat/linux/common/linux_exec.h>
     66       1.1      manu #include <compat/linux/common/linux_machdep.h>
     67       1.1      manu 
     68       1.1      manu #include <compat/linux/linux_syscallargs.h>
     69       1.1      manu 
     70      1.35        ad #include <sys/cpu.h>
     71      1.11       wiz #include <machine/fpu.h>
     72       1.1      manu #include <machine/psl.h>
     73       1.1      manu #include <machine/reg.h>
     74       1.1      manu #include <machine/vmparam.h>
     75       1.1      manu 
     76       1.1      manu /*
     77       1.1      manu  * To see whether wscons is configured (for virtual console ioctl calls).
     78       1.1      manu  */
     79      1.10       mrg #if defined(_KERNEL_OPT)
     80       1.1      manu #include "wsdisplay.h"
     81       1.1      manu #endif
     82       1.1      manu #if (NWSDISPLAY > 0)
     83       1.1      manu #include <dev/wscons/wsconsio.h>
     84       1.1      manu #include <dev/wscons/wsdisplay_usl_io.h>
     85       1.1      manu #endif
     86       1.1      manu 
     87      1.29     perry /*
     88       1.1      manu  * Set set up registers on exec.
     89       1.1      manu  * XXX not used at the moment since in sys/kern/exec_conf, LINUX_COMPAT
     90       1.1      manu  * entry uses NetBSD's native setregs instead of linux_setregs
     91       1.1      manu  */
     92       1.1      manu void
     93      1.36       dsl linux_setregs(struct lwp *l, struct exec_package *pack, u_long stack)
     94      1.29     perry {
     95      1.20   thorpej 	setregs(l, pack, stack);
     96       1.1      manu }
     97       1.1      manu 
     98       1.1      manu /*
     99       1.1      manu  * Send an interrupt to process.
    100       1.1      manu  *
    101       1.1      manu  * Adapted from arch/powerpc/powerpc/sig_machdep.c:sendsig and
    102       1.1      manu  * compat/linux/arch/i386/linux_machdep.c:linux_sendsig
    103       1.1      manu  *
    104       1.6      manu  * XXX Does not work well yet with RT signals
    105       1.1      manu  *
    106       1.1      manu  */
    107       1.1      manu 
    108      1.23      matt void
    109      1.24  christos linux_sendsig(const ksiginfo_t *ksi, const sigset_t *mask)
    110       1.1      manu {
    111      1.26   thorpej 	const int sig = ksi->ksi_signo;
    112      1.20   thorpej 	struct lwp *l = curlwp;
    113      1.20   thorpej 	struct proc *p = l->l_proc;
    114       1.1      manu 	struct trapframe *tf;
    115      1.16   thorpej 	sig_t catcher = SIGACTION(p, sig).sa_handler;
    116       1.8      manu 	struct linux_sigregs frame;
    117       1.4  christos 	struct linux_pt_regs linux_regs;
    118       1.1      manu 	struct linux_sigcontext sc;
    119       1.8      manu 	register_t fp;
    120      1.32        ad 	int onstack, error;
    121       1.1      manu 	int i;
    122       1.1      manu 
    123      1.20   thorpej 	tf = trapframe(l);
    124      1.29     perry 
    125      1.29     perry 	/*
    126      1.29     perry 	 * Do we need to jump onto the signal stack?
    127       1.1      manu 	 */
    128       1.1      manu 	onstack =
    129  1.39.2.1  wrstuden 	    (l->l_sigstk->ss_flags & (SS_DISABLE | SS_ONSTACK)) == 0 &&
    130       1.1      manu 	    (SIGACTION(p, sig).sa_flags & SA_ONSTACK) != 0;
    131       1.1      manu 
    132       1.1      manu 	/*
    133       1.1      manu 	 * Signal stack is broken (see at the end of linux_sigreturn), so we do
    134       1.1      manu 	 * not use it yet. XXX fix this.
    135       1.1      manu 	 */
    136       1.1      manu 	onstack=0;
    137       1.1      manu 
    138      1.29     perry 	/*
    139      1.29     perry 	 * Allocate space for the signal handler context.
    140       1.1      manu 	 */
    141       1.4  christos 	if (onstack) {
    142       1.8      manu 		fp = (register_t)
    143  1.39.2.1  wrstuden 		    ((char *)l->l_sigstk->ss_sp +
    144  1.39.2.1  wrstuden 		    l->l_sigstk->ss_size);
    145       1.4  christos 	} else {
    146       1.8      manu 		fp = tf->fixreg[1];
    147       1.4  christos 	}
    148       1.8      manu #ifdef DEBUG_LINUX
    149       1.8      manu 	printf("fp at start of linux_sendsig = %x\n", fp);
    150       1.8      manu #endif
    151       1.8      manu 	fp -= sizeof(struct linux_sigregs);
    152       1.8      manu 	fp &= ~0xf;
    153       1.1      manu 
    154      1.29     perry 	/*
    155       1.1      manu 	 * Prepare a sigcontext for later.
    156       1.1      manu 	 */
    157       1.8      manu 	memset(&sc, 0, sizeof sc);
    158      1.14  christos 	sc.lsignal = (int)native_to_linux_signo[sig];
    159       1.1      manu 	sc.lhandler = (unsigned long)catcher;
    160      1.13  christos 	native_to_linux_old_extra_sigset(&sc.lmask, &sc._unused[3], mask);
    161       1.1      manu 	sc.lregs = (struct linux_pt_regs*)fp;
    162       1.1      manu 
    163       1.1      manu 	/*
    164      1.29     perry 	 * Setup the signal stack frame as Linux does it in
    165       1.1      manu 	 * arch/ppc/kernel/signal.c:setup_frame()
    166       1.1      manu 	 *
    167      1.29     perry 	 * Save register context.
    168       1.1      manu 	 */
    169      1.29     perry 	for (i = 0; i < 32; i++)
    170       1.1      manu 		linux_regs.lgpr[i] = tf->fixreg[i];
    171      1.29     perry 	linux_regs.lnip = tf->srr0;
    172      1.28      matt 	linux_regs.lmsr = tf->srr1 & PSL_USERSRR1;
    173       1.1      manu 	linux_regs.lorig_gpr3 = tf->fixreg[3]; /* XXX Is that right? */
    174       1.1      manu 	linux_regs.lctr = tf->ctr;
    175       1.1      manu 	linux_regs.llink = tf->lr;
    176       1.1      manu 	linux_regs.lxer = tf->xer;
    177      1.29     perry 	linux_regs.lccr = tf->cr;
    178       1.1      manu 	linux_regs.lmq = 0;  			/* Unused, 601 only */
    179       1.8      manu 	linux_regs.ltrap = tf->exc;
    180      1.29     perry 	linux_regs.ldar = tf->dar;
    181       1.8      manu 	linux_regs.ldsisr = tf->dsisr;
    182       1.8      manu 	linux_regs.lresult = 0;
    183       1.8      manu 
    184       1.8      manu 	memset(&frame, 0, sizeof(frame));
    185       1.8      manu 	memcpy(&frame.lgp_regs, &linux_regs, sizeof(linux_regs));
    186       1.1      manu 
    187      1.28      matt 	save_fpu_lwp(curlwp, FPU_SAVE);
    188      1.28      matt 	memcpy(&frame.lfp_regs, curpcb->pcb_fpu.fpreg, sizeof(frame.lfp_regs));
    189       1.1      manu 
    190       1.1      manu 	/*
    191       1.4  christos 	 * Copy Linux's signal trampoline on the user stack It should not
    192       1.6      manu 	 * be used, but Linux binaries might expect it to be there.
    193       1.1      manu 	 */
    194       1.4  christos 	frame.ltramp[0] = 0x38997777; /* li r0, 0x7777 */
    195       1.4  christos 	frame.ltramp[1] = 0x44000002; /* sc */
    196      1.29     perry 
    197       1.1      manu 	/*
    198       1.1      manu 	 * Move it to the user stack
    199      1.29     perry 	 * There is a little trick here, about the LINUX_ABIGAP: the
    200       1.1      manu 	 * linux_sigreg structure has a 56 int gap to support rs6000/xcoff
    201       1.1      manu 	 * binaries. But the Linux kernel seems to do without it, and it
    202       1.1      manu 	 * just skip it when building the stack frame. Hence the LINUX_ABIGAP.
    203       1.1      manu 	 */
    204      1.32        ad 	sendsig_reset(l, sig);
    205      1.38        ad 	mutex_exit(p->p_lock);
    206      1.33  christos 	error = copyout(&frame, (void *)fp, sizeof (frame) - LINUX_ABIGAP);
    207      1.32        ad 
    208      1.32        ad 	if (error != 0) {
    209       1.1      manu 		/*
    210       1.1      manu 		 * Process has trashed its stack; give it an illegal
    211       1.9      manu 		 * instruction to halt it in its tracks.
    212       1.1      manu 		 */
    213      1.38        ad 		mutex_enter(p->p_lock);
    214      1.20   thorpej 		sigexit(l, SIGILL);
    215       1.1      manu 		/* NOTREACHED */
    216       1.1      manu 	}
    217       1.1      manu 
    218       1.1      manu 	/*
    219       1.1      manu 	 * Add a sigcontext on the stack
    220       1.1      manu 	 */
    221       1.8      manu 	fp -= sizeof(struct linux_sigcontext);
    222      1.33  christos 	error = copyout(&sc, (void *)fp, sizeof (struct linux_sigcontext));
    223      1.38        ad 	mutex_enter(p->p_lock);
    224      1.32        ad 
    225      1.32        ad 	if (error != 0) {
    226       1.1      manu 		/*
    227       1.1      manu 		 * Process has trashed its stack; give it an illegal
    228       1.9      manu 		 * instruction to halt it in its tracks.
    229       1.1      manu 		 */
    230      1.20   thorpej 		sigexit(l, SIGILL);
    231       1.1      manu 		/* NOTREACHED */
    232       1.1      manu 	}
    233       1.1      manu 
    234       1.1      manu 	/*
    235       1.8      manu 	 * Set the registers according to how the Linux process expects them.
    236       1.8      manu 	 * "Mind the gap" Linux expects a gap here.
    237       1.1      manu 	 */
    238       1.8      manu 	tf->fixreg[1] = fp - LINUX__SIGNAL_FRAMESIZE;
    239       1.1      manu 	tf->lr = (int)catcher;
    240      1.14  christos 	tf->fixreg[3] = (int)native_to_linux_signo[sig];
    241       1.8      manu 	tf->fixreg[4] = fp;
    242       1.1      manu 	tf->srr0 = (int)p->p_sigctx.ps_sigcode;
    243       1.1      manu 
    244       1.8      manu #ifdef DEBUG_LINUX
    245       1.8      manu 	printf("fp at end of linux_sendsig = %x\n", fp);
    246       1.8      manu #endif
    247      1.29     perry 	/*
    248      1.29     perry 	 * Remember that we're now on the signal stack.
    249       1.1      manu 	 */
    250       1.1      manu 	if (onstack)
    251  1.39.2.1  wrstuden 		l->l_sigstk->ss_flags |= SS_ONSTACK;
    252       1.1      manu #ifdef DEBUG_LINUX
    253       1.1      manu 	printf("linux_sendsig: exitting. fp=0x%lx\n",(long)fp);
    254       1.1      manu #endif
    255       1.1      manu }
    256       1.1      manu 
    257       1.1      manu /*
    258       1.1      manu  * System call to cleanup state after a signal
    259       1.1      manu  * has been taken.  Reset signal mask and
    260       1.1      manu  * stack state from context left by sendsig (above).
    261       1.1      manu  * Return to previous pc and psl as specified by
    262       1.1      manu  * context left by sendsig. Check carefully to
    263       1.1      manu  * make sure that the user has not modified the
    264       1.1      manu  * psl to gain improper privileges or to cause
    265       1.1      manu  * a machine fault.
    266       1.1      manu  *
    267       1.1      manu  * XXX not tested
    268       1.1      manu  */
    269       1.1      manu int
    270      1.37       dsl linux_sys_rt_sigreturn(struct lwp *l, const struct linux_sys_rt_sigreturn_args *uap, register_t *retval)
    271       1.1      manu {
    272      1.37       dsl 	/* {
    273       1.1      manu 		syscallarg(struct linux_rt_sigframe *) sfp;
    274      1.37       dsl 	} */
    275      1.20   thorpej 	struct proc *p = l->l_proc;
    276       1.1      manu 	struct linux_rt_sigframe *scp, sigframe;
    277       1.8      manu 	struct linux_sigregs sregs;
    278       1.8      manu 	struct linux_pt_regs *lregs;
    279       1.1      manu 	struct trapframe *tf;
    280       1.1      manu 	sigset_t mask;
    281       1.1      manu 	int i;
    282       1.1      manu 
    283       1.1      manu 	/*
    284       1.1      manu 	 * The trampoline code hands us the context.
    285       1.1      manu 	 * It is unsafe to keep track of it ourselves, in the event that a
    286       1.1      manu 	 * program jumps out of a signal handler.
    287       1.1      manu 	 */
    288       1.1      manu 	scp = SCARG(uap, sfp);
    289       1.1      manu 
    290       1.1      manu 	/*
    291       1.1      manu 	 * Get the context from user stack
    292       1.1      manu 	 */
    293      1.33  christos 	if (copyin((void *)scp, &sigframe, sizeof(*scp)))
    294       1.1      manu 		return (EFAULT);
    295       1.1      manu 
    296       1.1      manu 	/*
    297       1.8      manu 	 *  Restore register context.
    298       1.1      manu 	 */
    299      1.33  christos 	if (copyin((void *)sigframe.luc.luc_context.lregs,
    300       1.8      manu 		   &sregs, sizeof(sregs)))
    301       1.8      manu 		return (EFAULT);
    302       1.8      manu 	lregs = (struct linux_pt_regs *)&sregs.lgp_regs;
    303       1.8      manu 
    304      1.20   thorpej 	tf = trapframe(l);
    305       1.1      manu #ifdef DEBUG_LINUX
    306       1.1      manu 	    (unsigned long)tf, (unsigned long)scp);
    307       1.1      manu #endif
    308       1.1      manu 
    309      1.28      matt 	if (!PSL_USEROK_P(lregs->lmsr))
    310      1.29     perry 		return (EINVAL);
    311       1.1      manu 
    312      1.29     perry 	for (i = 0; i < 32; i++)
    313       1.8      manu 		tf->fixreg[i] = lregs->lgpr[i];
    314       1.8      manu 	tf->lr = lregs->llink;
    315       1.8      manu 	tf->cr = lregs->lccr;
    316       1.8      manu 	tf->xer = lregs->lxer;
    317       1.8      manu 	tf->ctr = lregs->lctr;
    318       1.8      manu 	tf->srr0 = lregs->lnip;
    319       1.8      manu 	tf->srr1 = lregs->lmsr;
    320       1.8      manu 
    321      1.28      matt 	/*
    322      1.28      matt 	 * Make sure the fpu state is discarded
    323      1.28      matt 	 */
    324      1.28      matt 	save_fpu_lwp(curlwp, FPU_DISCARD);
    325      1.28      matt 
    326      1.33  christos 	memcpy(curpcb->pcb_fpu.fpreg, (void *)&sregs.lfp_regs,
    327      1.28      matt 	       sizeof(curpcb->pcb_fpu.fpreg));
    328       1.1      manu 
    329      1.38        ad 	mutex_enter(p->p_lock);
    330      1.32        ad 
    331      1.29     perry 	/*
    332      1.29     perry 	 * Restore signal stack.
    333      1.29     perry 	 *
    334      1.29     perry 	 * XXX cannot find the onstack information in Linux sig context.
    335       1.1      manu 	 * Is signal stack really supported on Linux?
    336      1.29     perry 	 *
    337       1.1      manu 	 * It seems to be supported in libc6...
    338       1.1      manu 	 */
    339      1.29     perry 	/* if (sc.sc_onstack & SS_ONSTACK)
    340  1.39.2.1  wrstuden 		l->l_sigstk->ss_flags |= SS_ONSTACK;
    341       1.1      manu 	else */
    342  1.39.2.1  wrstuden 		l->l_sigstk->ss_flags &= ~SS_ONSTACK;
    343       1.1      manu 
    344       1.8      manu 	/*
    345       1.8      manu 	 * Grab the signal mask
    346       1.8      manu 	 */
    347      1.13  christos 	linux_to_native_sigset(&mask, &sigframe.luc.luc_sigmask);
    348      1.32        ad 	(void) sigprocmask1(l, SIG_SETMASK, &mask, 0);
    349      1.32        ad 
    350      1.38        ad 	mutex_exit(p->p_lock);
    351       1.8      manu 
    352       1.1      manu 	return (EJUSTRETURN);
    353       1.1      manu }
    354       1.1      manu 
    355       1.1      manu 
    356       1.1      manu /*
    357       1.1      manu  * The following needs code review for potential security issues
    358       1.1      manu  */
    359       1.1      manu int
    360      1.37       dsl linux_sys_sigreturn(struct lwp *l, const struct linux_sys_sigreturn_args *uap, register_t *retval)
    361       1.1      manu {
    362      1.37       dsl 	/* {
    363       1.1      manu 		syscallarg(struct linux_sigcontext *) scp;
    364      1.37       dsl 	} */
    365      1.20   thorpej 	struct proc *p = l->l_proc;
    366       1.1      manu 	struct linux_sigcontext *scp, context;
    367       1.8      manu 	struct linux_sigregs sregs;
    368       1.8      manu 	struct linux_pt_regs *lregs;
    369       1.1      manu 	struct trapframe *tf;
    370       1.1      manu 	sigset_t mask;
    371       1.1      manu 	int i;
    372       1.1      manu 
    373       1.1      manu 	/*
    374       1.1      manu 	 * The trampoline code hands us the context.
    375       1.1      manu 	 * It is unsafe to keep track of it ourselves, in the event that a
    376       1.1      manu 	 * program jumps out of a signal handler.
    377       1.1      manu 	 */
    378       1.1      manu 	scp = SCARG(uap, scp);
    379       1.1      manu 
    380       1.1      manu 	/*
    381       1.8      manu 	 * Get the context from user stack
    382       1.1      manu 	 */
    383       1.8      manu 	if (copyin(scp, &context, sizeof(*scp)))
    384       1.8      manu 		return (EFAULT);
    385       1.1      manu 
    386       1.1      manu 	/*
    387       1.8      manu 	 *  Restore register context.
    388       1.1      manu 	 */
    389      1.33  christos 	if (copyin((void *)context.lregs, &sregs, sizeof(sregs)))
    390       1.8      manu 		return (EFAULT);
    391       1.8      manu 	lregs = (struct linux_pt_regs *)&sregs.lgp_regs;
    392       1.8      manu 
    393      1.20   thorpej 	tf = trapframe(l);
    394       1.1      manu #ifdef DEBUG_LINUX
    395       1.1      manu 	printf("linux_sys_sigreturn: trapframe=0x%lx scp=0x%lx\n",
    396       1.1      manu 	    (unsigned long)tf, (unsigned long)scp);
    397       1.1      manu #endif
    398       1.1      manu 
    399      1.28      matt 	if (!PSL_USEROK_P(lregs->lmsr))
    400      1.29     perry 		return (EINVAL);
    401       1.1      manu 
    402      1.29     perry 	for (i = 0; i < 32; i++)
    403       1.8      manu 		tf->fixreg[i] = lregs->lgpr[i];
    404       1.8      manu 	tf->lr = lregs->llink;
    405       1.8      manu 	tf->cr = lregs->lccr;
    406       1.8      manu 	tf->xer = lregs->lxer;
    407       1.8      manu 	tf->ctr = lregs->lctr;
    408       1.8      manu 	tf->srr0 = lregs->lnip;
    409       1.8      manu 	tf->srr1 = lregs->lmsr;
    410       1.8      manu 
    411      1.28      matt 	/*
    412      1.28      matt 	 * Make sure the fpu state is discarded
    413      1.28      matt 	 */
    414      1.28      matt 	save_fpu_lwp(curlwp, FPU_DISCARD);
    415      1.28      matt 
    416      1.33  christos 	memcpy(curpcb->pcb_fpu.fpreg, (void *)&sregs.lfp_regs,
    417      1.28      matt 	       sizeof(curpcb->pcb_fpu.fpreg));
    418       1.1      manu 
    419      1.38        ad 	mutex_enter(p->p_lock);
    420      1.32        ad 
    421      1.29     perry 	/*
    422      1.29     perry 	 * Restore signal stack.
    423      1.29     perry 	 *
    424      1.29     perry 	 * XXX cannot find the onstack information in Linux sig context.
    425       1.1      manu 	 * Is signal stack really supported on Linux?
    426       1.1      manu 	 */
    427       1.4  christos #if 0
    428      1.29     perry 	if (sc.sc_onstack & SS_ONSTACK)
    429  1.39.2.1  wrstuden 		l->l_sigstk->ss_flags |= SS_ONSTACK;
    430       1.4  christos 	else
    431       1.4  christos #endif
    432  1.39.2.1  wrstuden 		l->l_sigstk->ss_flags &= ~SS_ONSTACK;
    433       1.1      manu 
    434       1.1      manu 	/* Restore signal mask. */
    435      1.13  christos 	linux_old_extra_to_native_sigset(&mask, &context.lmask,
    436      1.13  christos 	    &context._unused[3]);
    437      1.32        ad 	(void) sigprocmask1(l, SIG_SETMASK, &mask, 0);
    438      1.32        ad 
    439      1.38        ad 	mutex_exit(p->p_lock);
    440       1.1      manu 
    441       1.1      manu 	return (EJUSTRETURN);
    442       1.1      manu }
    443       1.1      manu 
    444       1.1      manu 
    445      1.11       wiz #if 0
    446       1.1      manu int
    447      1.36       dsl linux_sys_modify_ldt(struct proc *p, void *v, register_t *retval)
    448       1.1      manu {
    449      1.29     perry 	/*
    450       1.4  christos 	 * This syscall is not implemented in Linux/PowerPC: we should not
    451       1.4  christos 	 * be here
    452       1.1      manu 	 */
    453       1.1      manu #ifdef DEBUG_LINUX
    454      1.29     perry 	printf("linux_sys_modify_ldt: should not be here.\n");
    455       1.1      manu #endif
    456       1.1      manu   return 0;
    457       1.1      manu }
    458      1.11       wiz #endif
    459       1.1      manu 
    460      1.29     perry /*
    461       1.6      manu  * major device numbers remapping
    462       1.6      manu  */
    463       1.1      manu dev_t
    464      1.36       dsl linux_fakedev(dev_t dev, int raw)
    465       1.1      manu {
    466      1.15  jdolecek 	/* XXX write me */
    467      1.15  jdolecek 	return dev;
    468       1.1      manu }
    469       1.1      manu 
    470       1.1      manu /*
    471       1.1      manu  * We come here in a last attempt to satisfy a Linux ioctl() call
    472       1.1      manu  */
    473       1.1      manu int
    474      1.37       dsl linux_machdepioctl(struct lwp *l, const struct linux_sys_ioctl_args *uap, register_t *retval)
    475      1.29     perry {
    476      1.37       dsl 	/* {
    477       1.1      manu 		syscallarg(int) fd;
    478       1.1      manu 		syscallarg(u_long) com;
    479      1.33  christos 		syscallarg(void *) data;
    480      1.37       dsl 	} */
    481       1.1      manu 	struct sys_ioctl_args bia;
    482       1.1      manu 	u_long com;
    483      1.29     perry 
    484       1.1      manu 	SCARG(&bia, fd) = SCARG(uap, fd);
    485       1.1      manu 	SCARG(&bia, data) = SCARG(uap, data);
    486       1.1      manu 	com = SCARG(uap, com);
    487      1.29     perry 
    488       1.1      manu 	switch (com) {
    489       1.1      manu 	default:
    490       1.1      manu 		printf("linux_machdepioctl: invalid ioctl %08lx\n", com);
    491       1.1      manu 		return EINVAL;
    492       1.1      manu 	}
    493       1.1      manu 	SCARG(&bia, com) = com;
    494      1.20   thorpej 	/* XXX NJWLWP */
    495      1.22      fvdl 	return sys_ioctl(curlwp, &bia, retval);
    496       1.1      manu }
    497      1.11       wiz #if 0
    498       1.1      manu /*
    499       1.1      manu  * Set I/O permissions for a process. Just set the maximum level
    500       1.1      manu  * right away (ignoring the argument), otherwise we would have
    501       1.1      manu  * to rely on I/O permission maps, which are not implemented.
    502       1.1      manu  */
    503       1.1      manu int
    504      1.37       dsl linux_sys_iopl(struct lwp *l, const void *v, register_t *retval)
    505       1.1      manu {
    506      1.29     perry 	/*
    507       1.1      manu 	 * This syscall is not implemented in Linux/PowerPC: we should not be here
    508       1.1      manu 	 */
    509       1.1      manu #ifdef DEBUG_LINUX
    510       1.1      manu 	printf("linux_sys_iopl: should not be here.\n");
    511       1.1      manu #endif
    512       1.1      manu 	return 0;
    513       1.1      manu }
    514      1.11       wiz #endif
    515       1.1      manu 
    516       1.1      manu /*
    517       1.1      manu  * See above. If a root process tries to set access to an I/O port,
    518       1.1      manu  * just let it have the whole range.
    519       1.1      manu  */
    520       1.1      manu int
    521      1.37       dsl linux_sys_ioperm(struct lwp *l, const struct linux_sys_ioperm_args *uap, register_t *retval)
    522       1.1      manu {
    523      1.29     perry 	/*
    524       1.1      manu 	 * This syscall is not implemented in Linux/PowerPC: we should not be here
    525       1.1      manu 	 */
    526       1.1      manu #ifdef DEBUG_LINUX
    527      1.29     perry 	printf("linux_sys_ioperm: should not be here.\n");
    528       1.1      manu #endif
    529       1.1      manu 	return 0;
    530       1.1      manu }
    531       1.1      manu 
    532       1.1      manu /*
    533      1.29     perry  * wrapper linux_sys_new_uname() -> linux_sys_uname()
    534       1.1      manu  */
    535      1.29     perry int
    536      1.37       dsl linux_sys_new_uname(struct lwp *l, const struct linux_sys_new_uname_args *uap, register_t *retval)
    537       1.1      manu {
    538      1.37       dsl 	return linux_sys_uname(l, (const void *)uap, retval);
    539       1.1      manu }
    540       1.1      manu 
    541       1.1      manu /*
    542      1.29     perry  * wrapper linux_sys_new_select() -> linux_sys_select()
    543       1.1      manu  */
    544      1.29     perry int
    545      1.37       dsl linux_sys_new_select(struct lwp *l, const struct linux_sys_new_select_args *uap, register_t *retval)
    546       1.1      manu {
    547      1.37       dsl 	return linux_sys_select(l, (const void *)uap, retval);
    548       1.1      manu }
    549      1.30      fvdl 
    550      1.30      fvdl int
    551      1.30      fvdl linux_usertrap(struct lwp *l, vaddr_t trapaddr, void *arg)
    552      1.30      fvdl {
    553      1.30      fvdl 	return 0;
    554      1.30      fvdl }
    555