Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/compat/linux/arch/i386/linux_machdep.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/compat/linux/arch/i386/linux_machdep.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.110.2.8 retrieving revision 1.111 diff -u -p -r1.110.2.8 -r1.111 --- src/sys/compat/linux/arch/i386/linux_machdep.c 2008/03/24 09:38:41 1.110.2.8 +++ src/sys/compat/linux/arch/i386/linux_machdep.c 2005/08/21 13:13:50 1.111 @@ -1,7 +1,7 @@ -/* $NetBSD: linux_machdep.c,v 1.110.2.8 2008/03/24 09:38:41 yamt Exp $ */ +/* $NetBSD: linux_machdep.c,v 1.111 2005/08/21 13:13:50 yamt Exp $ */ /*- - * Copyright (c) 1995, 2000, 2008 The NetBSD Foundation, Inc. + * Copyright (c) 1995, 2000 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.110.2.8 2008/03/24 09:38:41 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.111 2005/08/21 13:13:50 yamt Exp $"); #if defined(_KERNEL_OPT) #include "opt_vm86.h" @@ -62,14 +62,13 @@ __KERNEL_RCSID(0, "$NetBSD: linux_machde #include #include #include +#include #include #include #include #include #include #include -#include - #include #include @@ -83,7 +82,7 @@ __KERNEL_RCSID(0, "$NetBSD: linux_machde #include -#include +#include #include #include #include @@ -107,22 +106,30 @@ __KERNEL_RCSID(0, "$NetBSD: linux_machde #endif #endif +#ifdef USER_LDT +#include +int linux_read_ldt __P((struct lwp *, struct linux_sys_modify_ldt_args *, + register_t *)); +int linux_write_ldt __P((struct lwp *, struct linux_sys_modify_ldt_args *, + register_t *)); +#endif + #ifdef DEBUG_LINUX #define DPRINTF(a) uprintf a #else #define DPRINTF(a) #endif -static struct biosdisk_info *fd2biosinfo(struct proc *, struct file *); +static struct biosdisk_info *fd2biosinfo __P((struct proc *, struct file *)); extern struct disklist *x86_alldisks; -static void linux_save_ucontext(struct lwp *, struct trapframe *, - const sigset_t *, struct sigaltstack *, struct linux_ucontext *); -static void linux_save_sigcontext(struct lwp *, struct trapframe *, - const sigset_t *, struct linux_sigcontext *); -static int linux_restore_sigcontext(struct lwp *, - struct linux_sigcontext *, register_t *); -static void linux_rt_sendsig(const ksiginfo_t *, const sigset_t *); -static void linux_old_sendsig(const ksiginfo_t *, const sigset_t *); +static void linux_save_ucontext __P((struct lwp *, struct trapframe *, + const sigset_t *, struct sigaltstack *, struct linux_ucontext *)); +static void linux_save_sigcontext __P((struct lwp *, struct trapframe *, + const sigset_t *, struct linux_sigcontext *)); +static int linux_restore_sigcontext __P((struct lwp *, + struct linux_sigcontext *, register_t *)); +static void linux_rt_sendsig __P((const ksiginfo_t *, const sigset_t *)); +static void linux_old_sendsig __P((const ksiginfo_t *, const sigset_t *)); extern char linux_sigcode[], linux_rt_sigcode[]; /* @@ -130,7 +137,10 @@ extern char linux_sigcode[], linux_rt_si */ void -linux_setregs(struct lwp *l, struct exec_package *epp, u_long stack) +linux_setregs(l, epp, stack) + struct lwp *l; + struct exec_package *epp; + u_long stack; { struct pcb *pcb = &l->l_addr->u_pcb; struct trapframe *tf; @@ -194,7 +204,12 @@ linux_sendsig(const ksiginfo_t *ksi, con static void -linux_save_ucontext(struct lwp *l, struct trapframe *tf, const sigset_t *mask, struct sigaltstack *sas, struct linux_ucontext *uc) +linux_save_ucontext(l, tf, mask, sas, uc) + struct lwp *l; + struct trapframe *tf; + const sigset_t *mask; + struct sigaltstack *sas; + struct linux_ucontext *uc; { uc->uc_flags = 0; uc->uc_link = NULL; @@ -205,7 +220,11 @@ linux_save_ucontext(struct lwp *l, struc } static void -linux_save_sigcontext(struct lwp *l, struct trapframe *tf, const sigset_t *mask, struct linux_sigcontext *sc) +linux_save_sigcontext(l, tf, mask, sc) + struct lwp *l; + struct trapframe *tf; + const sigset_t *mask; + struct linux_sigcontext *sc; { /* Save register context. */ #ifdef VM86 @@ -255,11 +274,11 @@ linux_rt_sendsig(const ksiginfo_t *ksi, struct proc *p = l->l_proc; struct trapframe *tf; struct linux_rt_sigframe *fp, frame; - int onstack, error; + int onstack; linux_siginfo_t *lsi; int sig = ksi->ksi_signo; sig_t catcher = SIGACTION(p, sig).sa_handler; - struct sigaltstack *sas = &l->l_sigstk; + struct sigaltstack *sas = &p->p_sigctx.ps_sigstk; tf = l->l_md.md_regs; /* Do we need to jump onto the signal stack? */ @@ -269,7 +288,7 @@ linux_rt_sendsig(const ksiginfo_t *ksi, /* Allocate space for the signal handler context. */ if (onstack) - fp = (struct linux_rt_sigframe *)((char *)sas->ss_sp + + fp = (struct linux_rt_sigframe *)((caddr_t)sas->ss_sp + sas->ss_size); else fp = (struct linux_rt_sigframe *)tf->tf_esp; @@ -319,19 +338,14 @@ linux_rt_sendsig(const ksiginfo_t *ksi, lsi->lsi_pid = ksi->ksi_pid; if (lsi->lsi_signo == LINUX_SIGALRM || lsi->lsi_signo >= LINUX_SIGRTMIN) - lsi->lsi_value.sival_ptr = ksi->ksi_value.sival_ptr; + lsi->lsi_value.sival_ptr = ksi->ksi_sigval.sival_ptr; break; } /* Save register context. */ linux_save_ucontext(l, tf, mask, sas, &frame.sf_uc); - sendsig_reset(l, sig); - - mutex_exit(&p->p_smutex); - error = copyout(&frame, fp, sizeof(frame)); - mutex_enter(&p->p_smutex); - if (error != 0) { + if (copyout(&frame, fp, sizeof(frame)) != 0) { /* * Process has trashed its stack; give it an illegal * instruction to halt it in its tracks. @@ -366,10 +380,10 @@ linux_old_sendsig(const ksiginfo_t *ksi, struct proc *p = l->l_proc; struct trapframe *tf; struct linux_sigframe *fp, frame; - int onstack, error; + int onstack; int sig = ksi->ksi_signo; sig_t catcher = SIGACTION(p, sig).sa_handler; - struct sigaltstack *sas = &l->l_sigstk; + struct sigaltstack *sas = &p->p_sigctx.ps_sigstk; tf = l->l_md.md_regs; @@ -379,7 +393,7 @@ linux_old_sendsig(const ksiginfo_t *ksi, /* Allocate space for the signal handler context. */ if (onstack) - fp = (struct linux_sigframe *) ((char *)sas->ss_sp + + fp = (struct linux_sigframe *) ((caddr_t)sas->ss_sp + sas->ss_size); else fp = (struct linux_sigframe *)tf->tf_esp; @@ -393,13 +407,8 @@ linux_old_sendsig(const ksiginfo_t *ksi, frame.sf_sig = native_to_linux_signo[sig]; linux_save_sigcontext(l, tf, mask, &frame.sf_sc); - sendsig_reset(l, sig); - mutex_exit(&p->p_smutex); - error = copyout(&frame, fp, sizeof(frame)); - mutex_enter(&p->p_smutex); - - if (error != 0) { + if (copyout(&frame, fp, sizeof(frame)) != 0) { /* * Process has trashed its stack; give it an illegal * instruction to halt it in its tracks. @@ -437,11 +446,14 @@ linux_old_sendsig(const ksiginfo_t *ksi, * a machine fault. */ int -linux_sys_rt_sigreturn(struct lwp *l, const struct linux_sys_rt_sigreturn_args *uap, register_t *retval) +linux_sys_rt_sigreturn(l, v, retval) + struct lwp *l; + void *v; + register_t *retval; { - /* { + struct linux_sys_rt_sigreturn_args /* { syscallarg(struct linux_ucontext *) ucp; - } */ + } */ *uap = v; struct linux_ucontext context, *ucp = SCARG(uap, ucp); int error; @@ -458,11 +470,14 @@ linux_sys_rt_sigreturn(struct lwp *l, co } int -linux_sys_sigreturn(struct lwp *l, const struct linux_sys_sigreturn_args *uap, register_t *retval) +linux_sys_sigreturn(l, v, retval) + struct lwp *l; + void *v; + register_t *retval; { - /* { + struct linux_sys_sigreturn_args /* { syscallarg(struct linux_sigcontext *) scp; - } */ + } */ *uap = v; struct linux_sigcontext context, *scp = SCARG(uap, scp); int error; @@ -471,17 +486,19 @@ linux_sys_sigreturn(struct lwp *l, const * It is unsafe to keep track of it ourselves, in the event that a * program jumps out of a signal handler. */ - if ((error = copyin((void *)scp, &context, sizeof(*scp))) != 0) + if ((error = copyin((caddr_t)scp, &context, sizeof(*scp))) != 0) return error; return linux_restore_sigcontext(l, &context, retval); } static int -linux_restore_sigcontext(struct lwp *l, struct linux_sigcontext *scp, - register_t *retval) +linux_restore_sigcontext(l, scp, retval) + struct lwp *l; + struct linux_sigcontext *scp; + register_t *retval; { struct proc *p = l->l_proc; - struct sigaltstack *sas = &l->l_sigstk; + struct sigaltstack *sas = &p->p_sigctx.ps_sigstk; struct trapframe *tf; sigset_t mask; ssize_t ss_gap; @@ -491,7 +508,7 @@ linux_restore_sigcontext(struct lwp *l, DPRINTF(("sigreturn enter esp=%x eip=%x\n", tf->tf_esp, tf->tf_eip)); #ifdef VM86 if (scp->sc_eflags & PSL_VM) { - void syscall_vm86(struct trapframe *); + void syscall_vm86 __P((struct trapframe *)); tf->tf_vm86_gs = scp->sc_gs; tf->tf_vm86_fs = scp->sc_fs; @@ -539,8 +556,8 @@ linux_restore_sigcontext(struct lwp *l, * Linux really does it this way; it doesn't have space in sigframe * to save the onstack flag. */ - mutex_enter(&p->p_smutex); - ss_gap = (ssize_t)((char *)scp->sc_esp_at_signal - (char *)sas->ss_sp); + ss_gap = (ssize_t) + ((caddr_t) scp->sc_esp_at_signal - (caddr_t) sas->ss_sp); if (ss_gap >= 0 && ss_gap < sas->ss_size) sas->ss_flags |= SS_ONSTACK; else @@ -548,55 +565,46 @@ linux_restore_sigcontext(struct lwp *l, /* Restore signal mask. */ linux_old_to_native_sigset(&mask, &scp->sc_mask); - (void) sigprocmask1(l, SIG_SETMASK, &mask, 0); - mutex_exit(&p->p_smutex); - + (void) sigprocmask1(p, SIG_SETMASK, &mask, 0); DPRINTF(("sigreturn exit esp=%x eip=%x\n", tf->tf_esp, tf->tf_eip)); return EJUSTRETURN; } #ifdef USER_LDT -static int -linux_read_ldt(struct lwp *l, const struct linux_sys_modify_ldt_args *uap, - register_t *retval) +int +linux_read_ldt(l, uap, retval) + struct lwp *l; + struct linux_sys_modify_ldt_args /* { + syscallarg(int) func; + syscallarg(void *) ptr; + syscallarg(size_t) bytecount; + } */ *uap; + register_t *retval; { - struct x86_get_ldt_args gl; + struct proc *p = l->l_proc; + struct i386_get_ldt_args gl; int error; - int num_ldt; - union descriptor *ldt_buf; - - /* - * I've checked the linux code - this function is asymetric with - * linux_write_ldt, and returns raw ldt entries. - * NB, the code I saw zerod the spare parts of the user buffer. - */ + caddr_t sg; + char *parms; DPRINTF(("linux_read_ldt!")); - - num_ldt = x86_get_ldt_len(l); - if (num_ldt <= 0) - return EINVAL; + sg = stackgap_init(p, 0); gl.start = 0; - gl.desc = NULL; + gl.desc = SCARG(uap, ptr); gl.num = SCARG(uap, bytecount) / sizeof(union descriptor); - if (gl.num > num_ldt) - gl.num = num_ldt; + parms = stackgap_alloc(p, &sg, sizeof(gl)); - ldt_buf = malloc(gl.num * sizeof *ldt, M_TEMP, M_WAITOK); + if ((error = copyout(&gl, parms, sizeof(gl))) != 0) + return (error); - error = x86_get_ldt1(l, &gl, ldt_buf); - /* NB gl.num might have changed */ - if (error == 0) { - *retval = gl.num * sizeof *ldt; - error = copyout(ldt_buf, SCARG(uap, ptr), - gl.num * sizeof *ldt_buf); - } - free(ldt, M_TEMP); + if ((error = i386_get_ldt(l, parms, retval)) != 0) + return (error); - return error; + *retval *= sizeof(union descriptor); + return (0); } struct linux_ldt_info { @@ -611,14 +619,24 @@ struct linux_ldt_info { u_int useable:1; }; -static int -linux_write_ldt(struct lwp *l, const struct linux_sys_modify_ldt_args *uap, - int oldmode) +int +linux_write_ldt(l, uap, retval) + struct lwp *l; + struct linux_sys_modify_ldt_args /* { + syscallarg(int) func; + syscallarg(void *) ptr; + syscallarg(size_t) bytecount; + } */ *uap; + register_t *retval; { + struct proc *p = l->l_proc; struct linux_ldt_info ldt_info; - union descriptor d; - struct x86_set_ldt_args sl; + struct segment_descriptor sd; + struct i386_set_ldt_args sl; int error; + caddr_t sg; + char *parms; + int oldmode = (int)retval[0]; DPRINTF(("linux_write_ldt %d\n", oldmode)); if (SCARG(uap, bytecount) != sizeof(ldt_info)) @@ -640,58 +658,75 @@ linux_write_ldt(struct lwp *l, const str ldt_info.limit_in_pages == 0 && ldt_info.seg_not_present == 1 && ldt_info.useable == 0))) { /* this means you should zero the ldt */ - (void)memset(&d, 0, sizeof(d)); + (void)memset(&sd, 0, sizeof(sd)); } else { - d.sd.sd_lobase = ldt_info.base_addr & 0xffffff; - d.sd.sd_hibase = (ldt_info.base_addr >> 24) & 0xff; - d.sd.sd_lolimit = ldt_info.limit & 0xffff; - d.sd.sd_hilimit = (ldt_info.limit >> 16) & 0xf; - d.sd.sd_type = 16 | (ldt_info.contents << 2) | + sd.sd_lobase = ldt_info.base_addr & 0xffffff; + sd.sd_hibase = (ldt_info.base_addr >> 24) & 0xff; + sd.sd_lolimit = ldt_info.limit & 0xffff; + sd.sd_hilimit = (ldt_info.limit >> 16) & 0xf; + sd.sd_type = 16 | (ldt_info.contents << 2) | (!ldt_info.read_exec_only << 1); - d.sd.sd_dpl = SEL_UPL; - d.sd.sd_p = !ldt_info.seg_not_present; - d.sd.sd_def32 = ldt_info.seg_32bit; - d.sd.sd_gran = ldt_info.limit_in_pages; + sd.sd_dpl = SEL_UPL; + sd.sd_p = !ldt_info.seg_not_present; + sd.sd_def32 = ldt_info.seg_32bit; + sd.sd_gran = ldt_info.limit_in_pages; if (!oldmode) - d.sd.sd_xx = ldt_info.useable; + sd.sd_xx = ldt_info.useable; else - d.sd.sd_xx = 0; + sd.sd_xx = 0; } + sg = stackgap_init(p, 0); sl.start = ldt_info.entry_number; - sl.desc = NULL;; + sl.desc = stackgap_alloc(p, &sg, sizeof(sd)); sl.num = 1; DPRINTF(("linux_write_ldt: idx=%d, base=0x%lx, limit=0x%x\n", ldt_info.entry_number, ldt_info.base_addr, ldt_info.limit)); - return x86_set_ldt1(l, &sl, &d); + parms = stackgap_alloc(p, &sg, sizeof(sl)); + + if ((error = copyout(&sd, sl.desc, sizeof(sd))) != 0) + return (error); + if ((error = copyout(&sl, parms, sizeof(sl))) != 0) + return (error); + + if ((error = i386_set_ldt(l, parms, retval)) != 0) + return (error); + + *retval = 0; + return (0); } #endif /* USER_LDT */ int -linux_sys_modify_ldt(struct lwp *l, const struct linux_sys_modify_ldt_args *uap, register_t *retval) +linux_sys_modify_ldt(l, v, retval) + struct lwp *l; + void *v; + register_t *retval; { - /* { + struct linux_sys_modify_ldt_args /* { syscallarg(int) func; syscallarg(void *) ptr; syscallarg(size_t) bytecount; - } */ + } */ *uap = v; switch (SCARG(uap, func)) { #ifdef USER_LDT case 0: - return linux_read_ldt(l, (const void *)uap, retval); + return linux_read_ldt(l, uap, retval); case 1: - return linux_write_ldt(l, (const void *)uap, 1); + retval[0] = 1; + return linux_write_ldt(l, uap, retval); case 2: #ifdef notyet - return (linux_read_default_ldt(l, (const void *)uap, retval); + return (linux_read_default_ldt(l, uap, retval); #else return (ENOSYS); #endif case 0x11: - return linux_write_ldt(l, (const void *)uap, 0); + retval[0] = 0; + return linux_write_ldt(l, uap, retval); #endif /* USER_LDT */ default: @@ -706,7 +741,9 @@ linux_sys_modify_ldt(struct lwp *l, cons * array for all major device numbers, and map linux_mknod too. */ dev_t -linux_fakedev(dev_t dev, int raw) +linux_fakedev(dev, raw) + dev_t dev; + int raw; { extern const struct cdevsw ptc_cdevsw, pts_cdevsw; const struct cdevsw *cd = cdevsw_lookup(dev); @@ -808,7 +845,9 @@ const u_short * const linux_keytabs[] = #endif static struct biosdisk_info * -fd2biosinfo(struct proc *p, struct file *fp) +fd2biosinfo(p, fp) + struct proc *p; + struct file *fp; { struct vnode *vp; const char *blkname; @@ -844,28 +883,33 @@ fd2biosinfo(struct proc *p, struct file * We come here in a last attempt to satisfy a Linux ioctl() call */ int -linux_machdepioctl(struct lwp *l, const struct linux_sys_ioctl_args *uap, register_t *retval) +linux_machdepioctl(p, v, retval) + struct proc *p; + void *v; + register_t *retval; { - /* { + struct linux_sys_ioctl_args /* { syscallarg(int) fd; syscallarg(u_long) com; - syscallarg(void *) data; - } */ + syscallarg(caddr_t) data; + } */ *uap = v; struct sys_ioctl_args bia; u_long com; int error, error1; #if (NWSDISPLAY > 0) struct vt_mode lvt; + caddr_t bvtp, sg; struct kbentry kbe; #endif struct linux_hd_geometry hdg; struct linux_hd_big_geometry hdg_big; struct biosdisk_info *bip; - file_t *fp; + struct filedesc *fdp; + struct file *fp; int fd; struct disklabel label, *labp; struct partinfo partp; - int (*ioctlf)(struct file *, u_long, void *); + int (*ioctlf)(struct file *, u_long, void *, struct proc *); u_long start, biostotal, realtotal; u_char heads, sectors; u_int cylinders; @@ -876,9 +920,13 @@ linux_machdepioctl(struct lwp *l, const SCARG(&bia, data) = SCARG(uap, data); com = SCARG(uap, com); - if ((fp = fd_getfile(fd)) == NULL) + fdp = p->p_fd; + + if ((fp = fd_getfile(fdp, fd)) == NULL) return (EBADF); + FILE_USE(fp); + switch (com) { #if (NWSDISPLAY > 0) case LINUX_KDGKBMODE: @@ -887,11 +935,11 @@ linux_machdepioctl(struct lwp *l, const case LINUX_KDSKBMODE: com = KDSKBMODE; if ((unsigned)SCARG(uap, data) == LINUX_K_MEDIUMRAW) - SCARG(&bia, data) = (void *)K_RAW; + SCARG(&bia, data) = (caddr_t)K_RAW; break; case LINUX_KIOCSOUND: SCARG(&bia, data) = - (void *)(((unsigned long)SCARG(&bia, data)) & 0xffff); + (caddr_t)(((unsigned long)SCARG(&bia, data)) & 0xffff); /* fall through */ case LINUX_KDMKTONE: com = KDMKTONE; @@ -919,23 +967,33 @@ linux_machdepioctl(struct lwp *l, const com = VT_OPENQRY; break; case LINUX_VT_GETMODE: - error = fp->f_ops->fo_ioctl(fp, VT_GETMODE, &lvt); - if (error != 0) + SCARG(&bia, com) = VT_GETMODE; + /* XXX NJWLWP */ + if ((error = sys_ioctl(curlwp, &bia, retval))) + goto out; + if ((error = copyin(SCARG(uap, data), (caddr_t)&lvt, + sizeof (struct vt_mode)))) goto out; lvt.relsig = native_to_linux_signo[lvt.relsig]; lvt.acqsig = native_to_linux_signo[lvt.acqsig]; lvt.frsig = native_to_linux_signo[lvt.frsig]; - error = copyout(&lvt, SCARG(uap, data), sizeof (lvt)); + error = copyout((caddr_t)&lvt, SCARG(uap, data), + sizeof (struct vt_mode)); goto out; case LINUX_VT_SETMODE: - error = copyin(SCARG(uap, data), &lvt, sizeof (lvt)); - if (error != 0) + com = VT_SETMODE; + if ((error = copyin(SCARG(uap, data), (caddr_t)&lvt, + sizeof (struct vt_mode)))) goto out; lvt.relsig = linux_to_native_signo[lvt.relsig]; lvt.acqsig = linux_to_native_signo[lvt.acqsig]; lvt.frsig = linux_to_native_signo[lvt.frsig]; - error = fp->f_ops->fo_ioctl(fp, VT_SETMODE, &lvt); - goto out; + sg = stackgap_init(p, 0); + bvtp = stackgap_alloc(p, &sg, sizeof (struct vt_mode)); + if ((error = copyout(&lvt, bvtp, sizeof (struct vt_mode)))) + goto out; + SCARG(&bia, data) = bvtp; + break; case LINUX_VT_DISALLOCATE: /* XXX should use WSDISPLAYIO_DELSCREEN */ error = 0; @@ -989,10 +1047,10 @@ linux_machdepioctl(struct lwp *l, const * the real geometry) if not found, by returning an * error. See common/linux_hdio.c */ - bip = fd2biosinfo(curproc, fp); + bip = fd2biosinfo(p, fp); ioctlf = fp->f_ops->fo_ioctl; - error = ioctlf(fp, DIOCGDEFLABEL, (void *)&label); - error1 = ioctlf(fp, DIOCGPART, (void *)&partp); + error = ioctlf(fp, DIOCGDEFLABEL, (caddr_t)&label, p); + error1 = ioctlf(fp, DIOCGPART, (caddr_t)&partp, p); if (error != 0 && error1 != 0) { error = error1; goto out; @@ -1042,22 +1100,22 @@ linux_machdepioctl(struct lwp *l, const ioctlf = fp->f_ops->fo_ioctl; pt.com = SCARG(uap, com); pt.data = SCARG(uap, data); - error = ioctlf(fp, PTIOCLINUX, &pt); + error = ioctlf(fp, PTIOCLINUX, (caddr_t)&pt, p); if (error == EJUSTRETURN) { retval[0] = (register_t)pt.data; error = 0; } - if (error == ENOTTY) { + if (error == ENOTTY) DPRINTF(("linux_machdepioctl: invalid ioctl %08lx\n", com)); - } goto out; } SCARG(&bia, com) = com; + /* XXX NJWLWP */ error = sys_ioctl(curlwp, &bia, retval); out: - fd_putfile(fd); + FILE_UNUSE(fp ,p); return error; } @@ -1067,15 +1125,20 @@ out: * to rely on I/O permission maps, which are not implemented. */ int -linux_sys_iopl(struct lwp *l, const struct linux_sys_iopl_args *uap, register_t *retval) +linux_sys_iopl(l, v, retval) + struct lwp *l; + void *v; + register_t *retval; { - /* { +#if 0 + struct linux_sys_iopl_args /* { syscallarg(int) level; - } */ + } */ *uap = v; +#endif + struct proc *p = l->l_proc; struct trapframe *fp = l->l_md.md_regs; - if (kauth_authorize_machdep(l->l_cred, KAUTH_MACHDEP_IOPL, - NULL, NULL, NULL, NULL) != 0) + if (suser(p->p_ucred, &p->p_acflag) != 0) return EPERM; fp->tf_eflags |= PSL_IOPL; *retval = 0; @@ -1087,18 +1150,20 @@ linux_sys_iopl(struct lwp *l, const stru * just let it have the whole range. */ int -linux_sys_ioperm(struct lwp *l, const struct linux_sys_ioperm_args *uap, register_t *retval) +linux_sys_ioperm(l, v, retval) + struct lwp *l; + void *v; + register_t *retval; { - /* { + struct linux_sys_ioperm_args /* { syscallarg(unsigned int) lo; syscallarg(unsigned int) hi; syscallarg(int) val; - } */ + } */ *uap = v; + struct proc *p = l->l_proc; struct trapframe *fp = l->l_md.md_regs; - if (kauth_authorize_machdep(l->l_cred, SCARG(uap, val) ? - KAUTH_MACHDEP_IOPERM_SET : KAUTH_MACHDEP_IOPERM_GET, NULL, NULL, - NULL, NULL) != 0) + if (suser(p->p_ucred, &p->p_acflag) != 0) return EPERM; if (SCARG(uap, val)) fp->tf_eflags |= PSL_IOPL; @@ -1107,36 +1172,7 @@ linux_sys_ioperm(struct lwp *l, const st } int -linux_usertrap(struct lwp *l, vaddr_t trapaddr, - void *arg) -{ - return 0; -} - -const char * -linux_get_uname_arch(void) -{ - static char uname_arch[5] = "i386"; - - if (uname_arch[1] == '3') - uname_arch[1] += cpu_class; - return uname_arch; -} - -#ifdef LINUX_NPTL -void * -linux_get_newtls(struct lwp *l) -{ - struct trapframe *tf = l->l_md.md_regs; - - /* XXX: Implement me */ - return NULL; -} - -int -linux_set_newtls(struct lwp *l, void *tls) +linux_usertrap(struct lwp *l, vaddr_t trapaddr, void *arg) { - /* XXX: Implement me */ return 0; } -#endif