Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/compat Use lwp_getpcb() in compat code, clean from struc...



details:   https://anonhg.NetBSD.org/src/rev/fe6ed7f548d1
branches:  trunk
changeset: 749249:fe6ed7f548d1
user:      rmind <rmind%NetBSD.org@localhost>
date:      Mon Nov 23 00:46:06 2009 +0000

description:
Use lwp_getpcb() in compat code, clean from struct user.

diffstat:

 sys/compat/common/kern_sig_43.c                 |   6 +-
 sys/compat/freebsd/freebsd_ptrace.c             |   5 +-
 sys/compat/irix/irix_signal.c                   |  62 ++++++++++++------------
 sys/compat/linux/arch/alpha/linux_machdep.c     |  21 ++++---
 sys/compat/linux/arch/amd64/linux_machdep.c     |  17 +++---
 sys/compat/linux/arch/arm/linux_machdep.c       |   5 +-
 sys/compat/linux/arch/i386/linux_exec_machdep.c |  10 ++--
 sys/compat/linux/arch/i386/linux_machdep.c      |  20 ++++---
 sys/compat/linux/arch/mips/linux_machdep.c      |   5 +-
 sys/compat/linux/arch/powerpc/linux_machdep.c   |   5 +-
 sys/compat/linux32/arch/amd64/linux32_machdep.c |  23 +++++---
 sys/compat/osf1/osf1_misc.c                     |   5 +-
 sys/compat/svr4/svr4_lwp.c                      |   5 +-
 sys/compat/svr4_32/svr4_32_lwp.c                |   5 +-
 14 files changed, 100 insertions(+), 94 deletions(-)

diffs (truncated from 725 to 300 lines):

diff -r 2d20081f6abd -r fe6ed7f548d1 sys/compat/common/kern_sig_43.c
--- a/sys/compat/common/kern_sig_43.c   Mon Nov 23 00:18:37 2009 +0000
+++ b/sys/compat/common/kern_sig_43.c   Mon Nov 23 00:46:06 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_sig_43.c,v 1.32 2008/04/28 20:23:41 martin Exp $  */
+/*     $NetBSD: kern_sig_43.c,v 1.33 2009/11/23 00:46:06 rmind Exp $   */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_sig_43.c,v 1.32 2008/04/28 20:23:41 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sig_43.c,v 1.33 2009/11/23 00:46:06 rmind Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -61,8 +61,6 @@
 
 #include <sys/cpu.h>
 
-#include <sys/user.h>          /* for coredump */
-
 #include <compat/sys/signal.h>
 
 void compat_43_sigmask_to_sigset(const int *, sigset_t *);
diff -r 2d20081f6abd -r fe6ed7f548d1 sys/compat/freebsd/freebsd_ptrace.c
--- a/sys/compat/freebsd/freebsd_ptrace.c       Mon Nov 23 00:18:37 2009 +0000
+++ b/sys/compat/freebsd/freebsd_ptrace.c       Mon Nov 23 00:46:06 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: freebsd_ptrace.c,v 1.18 2008/11/12 12:36:10 ad Exp $   */
+/*     $NetBSD: freebsd_ptrace.c,v 1.19 2009/11/23 00:46:06 rmind Exp $        */
 
 /*-
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -71,7 +71,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: freebsd_ptrace.c,v 1.18 2008/11/12 12:36:10 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: freebsd_ptrace.c,v 1.19 2009/11/23 00:46:06 rmind Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -79,7 +79,6 @@
 #include <sys/errno.h>
 #include <sys/ptrace.h>
 #include <sys/uio.h>
-#include <sys/user.h>
 #include <sys/mount.h>
 #include <sys/syscall.h>
 #include <sys/syscallargs.h>
diff -r 2d20081f6abd -r fe6ed7f548d1 sys/compat/irix/irix_signal.c
--- a/sys/compat/irix/irix_signal.c     Mon Nov 23 00:18:37 2009 +0000
+++ b/sys/compat/irix/irix_signal.c     Mon Nov 23 00:46:06 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: irix_signal.c,v 1.51 2009/11/04 21:23:02 rmind Exp $ */
+/*     $NetBSD: irix_signal.c,v 1.52 2009/11/23 00:46:06 rmind Exp $ */
 
 /*-
  * Copyright (c) 1994, 2001-2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: irix_signal.c,v 1.51 2009/11/04 21:23:02 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: irix_signal.c,v 1.52 2009/11/23 00:46:06 rmind Exp $");
 
 #include <sys/types.h>
 #include <sys/signal.h>
@@ -43,7 +43,6 @@
 #include <sys/systm.h>
 #include <sys/vnode.h>
 #include <sys/wait.h>
-#include <sys/user.h>
 
 #include <machine/regnum.h>
 #include <machine/trap.h>
@@ -370,10 +369,12 @@
 }
 
 static void
-irix_set_sigcontext (struct irix_sigcontext *scp, const sigset_t *mask, int code, struct lwp *l)
+irix_set_sigcontext (struct irix_sigcontext *scp, const sigset_t *mask,
+    int code, struct lwp *l)
 {
+       struct frame *f;
+       struct pcb *pcb;
        int i;
-       struct frame *f;
 
        KASSERT(mutex_owned(l->l_proc->p_lock));
 
@@ -400,19 +401,19 @@
        /*
         * Save the floating-pointstate, if necessary, then copy it.
         */
+       pcb = lwp_getpcb(l);
 #ifndef SOFTFLOAT
        scp->isc_ownedfp = l->l_md.md_flags & MDP_FPUSED;
        if (scp->isc_ownedfp) {
                /* if FPU has current state, save it first */
                if (l == fpcurlwp)
                        savefpregs(l);
-               (void)memcpy(&scp->isc_fpregs, &l->l_addr->u_pcb.pcb_fpregs,
+               memcpy(&scp->isc_fpregs, &pcb->pcb_fpregs,
                    sizeof(scp->isc_fpregs));
-               scp->isc_fpc_csr = l->l_addr->u_pcb.pcb_fpregs.r_regs[32];
+               scp->isc_fpc_csr = pcb->pcb_fpregs.r_regs[32];
        }
 #else
-       (void)memcpy(&scp->isc_fpregs, &l->l_addr->u_pcb.pcb_fpregs,
-           sizeof(scp->isc_fpregs));
+       memcpy(&scp->isc_fpregs, &pcb->pcb_fpregs, sizeof(scp->isc_fpregs));
 #endif
        /*
         * Save signal stack
@@ -424,9 +425,11 @@
 }
 
 void
-irix_set_ucontext(struct irix_ucontext *ucp, const sigset_t *mask, int code, struct lwp *l)
+irix_set_ucontext(struct irix_ucontext *ucp, const sigset_t *mask,
+    int code, struct lwp *l)
 {
        struct frame *f;
+       struct pcb *pcb;
 
        KASSERT(mutex_owned(l->l_proc->p_lock));
 
@@ -450,21 +453,20 @@
        /*
         * Save the floating-pointstate, if necessary, then copy it.
         */
+       pcb = lwp_getpcb(l);
 #ifndef SOFTFLOAT
        if (l->l_md.md_flags & MDP_FPUSED) {
                /* if FPU has current state, save it first */
                if (l == fpcurlwp)
                        savefpregs(l);
-               (void)memcpy(&ucp->iuc_mcontext.svr4___fpregs,
-                   &l->l_addr->u_pcb.pcb_fpregs,
-                   sizeof(ucp->iuc_mcontext.svr4___fpregs));
+               memcpy(&ucp->iuc_mcontext.svr4___fpregs,
+                   &pcb->pcb_fpregs, sizeof(ucp->iuc_mcontext.svr4___fpregs));
                ucp->iuc_mcontext.svr4___fpregs.svr4___fp_csr =
-                   l->l_addr->u_pcb.pcb_fpregs.r_regs[32];
+                   pcb->pcb_fpregs.r_regs[32];
        }
 #else
-       (void)memcpy(&ucp->iuc_mcontext.svr4___fpregs,
-           &l->l_addr->u_pcb.pcb_fpregs,
-           sizeof(ucp->iuc_mcontext.svr4___fpregs));
+       memcpy(&ucp->iuc_mcontext.svr4___fpregs,
+           &pcb->pcb_fpregs, sizeof(ucp->iuc_mcontext.svr4___fpregs));
 #endif
        /*
         * Save signal stack
@@ -570,20 +572,19 @@
        }
 
        if (ucp->iuc_flags & IRIX_UC_MAU) {
+               struct pcb *pcb = lwp_getpcb(l);
 #ifndef SOFTFLOAT
                /* Disable the FPU to fault in FP registers. */
                f->f_regs[_R_SR] &= ~MIPS_SR_COP_1_BIT;
                if (l == fpcurlwp)
                        fpcurlwp = NULL;
-               (void)memcpy(&l->l_addr->u_pcb.pcb_fpregs,
-                   &ucp->iuc_mcontext.svr4___fpregs,
-                   sizeof(l->l_addr->u_pcb.pcb_fpregs));
-               l->l_addr->u_pcb.pcb_fpregs.r_regs[32] =
+               memcpy(&pcb->pcb_fpregs, &ucp->iuc_mcontext.svr4___fpregs,
+                   sizeof(pcb->pcb_fpregs));
+               pcb->pcb_fpregs.r_regs[32] =
                     ucp->iuc_mcontext.svr4___fpregs.svr4___fp_csr;
 #else
-               (void)memcpy(&l->l_addr->u_pcb.pcb_fpregs,
-                   &ucp->iuc_mcontext.svr4___fpregs,
-                   sizeof(l->l_addr->u_pcb.pcb_fpregs));
+               memcpy(&pcb->pcb_fpregs, &ucp->iuc_mcontext.svr4___fpregs,
+                   sizeof(pcb->pcb_fpregs));
 #endif
        }
 
@@ -620,9 +621,10 @@
 static void
 irix_get_sigcontext(struct irix_sigcontext *scp, struct lwp *l)
 {
+       struct frame *f;
+       struct pcb *pcb;
+       sigset_t mask;
        int i;
-       struct frame *f;
-       sigset_t mask;
 
        KASSERT(mutex_owned(l->l_proc->p_lock));
 
@@ -635,19 +637,19 @@
        f->f_regs[_R_MULHI] = scp->isc_mdhi;
        f->f_regs[_R_PC] = scp->isc_pc;
 
+       pcb = lwp_getpcb(l);
 #ifndef SOFTFLOAT
        if (scp->isc_ownedfp) {
                /* Disable the FPU to fault in FP registers. */
                f->f_regs[_R_SR] &= ~MIPS_SR_COP_1_BIT;
                if (l == fpcurlwp)
                        fpcurlwp = NULL;
-               (void)memcpy(&l->l_addr->u_pcb.pcb_fpregs, &scp->isc_fpregs,
+               memcpy(&pcb->pcb_fpregs, &scp->isc_fpregs,
                    sizeof(scp->isc_fpregs));
-               l->l_addr->u_pcb.pcb_fpregs.r_regs[32] = scp->isc_fpc_csr;
+               pcb->pcb_fpregs.r_regs[32] = scp->isc_fpc_csr;
        }
 #else
-       (void)memcpy(&l->l_addr->u_pcb.pcb_fpregs, &scp->isc_fpregs,
-           sizeof(l->l_addr->u_pcb.pcb_fpregs));
+       memcpy(&pcb->pcb_fpregs, &scp->isc_fpregs, sizeof(pcb->pcb_fpregs));
 #endif
 
        /* Restore signal stack. */
diff -r 2d20081f6abd -r fe6ed7f548d1 sys/compat/linux/arch/alpha/linux_machdep.c
--- a/sys/compat/linux/arch/alpha/linux_machdep.c       Mon Nov 23 00:18:37 2009 +0000
+++ b/sys/compat/linux/arch/alpha/linux_machdep.c       Mon Nov 23 00:46:06 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_machdep.c,v 1.44 2009/03/18 17:06:48 cegger Exp $        */
+/*     $NetBSD: linux_machdep.c,v 1.45 2009/11/23 00:46:06 rmind Exp $ */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -35,14 +35,13 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.44 2009/03/18 17:06:48 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.45 2009/11/23 00:46:06 rmind Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/signalvar.h>
 #include <sys/kernel.h>
 #include <sys/proc.h>
-#include <sys/user.h>
 #include <sys/buf.h>
 #include <sys/reboot.h>
 #include <sys/conf.h>
@@ -256,11 +255,13 @@
        sigframe.sf_sc.sc_regs[R_SP] = alpha_pal_rdusp();
 
        if (l == fpcurlwp) {
-           alpha_pal_wrfen(1);
-           savefpstate(&l->l_addr->u_pcb.pcb_fp);
-           alpha_pal_wrfen(0);
-           sigframe.sf_sc.sc_fpcr = l->l_addr->u_pcb.pcb_fp.fpr_cr;
-           fpcurlwp = NULL;
+               struct pcb *pcb = lwp_getpcb(l);
+
+               alpha_pal_wrfen(1);
+               savefpstate(&pcb->pcb_fp);
+               alpha_pal_wrfen(0);
+               sigframe.sf_sc.sc_fpcr = pcb->pcb_fp.fpr_cr;
+               fpcurlwp = NULL;
        }
        /* XXX ownedfp ? etc...? */
 
@@ -374,6 +375,7 @@
                         sigset_t *mask)
 {
        struct proc *p = l->l_proc;
+       struct pcb *pcb;
 
        /*
         * Linux doesn't (yet) have alternate signal stacks.
@@ -407,7 +409,8 @@
            fpcurlwp = NULL;
 
        /* Restore fp regs and fpr_cr */
-       memcpy( &l->l_addr->u_pcb.pcb_fp, (struct fpreg *)context.sc_fpregs,
+       pcb = lwp_getpcb(l);
+       memcpy(&pcb->pcb_fp, (struct fpreg *)context.sc_fpregs,
            sizeof(struct fpreg));
        /* XXX sc_ownedfp ? */
        /* XXX sc_fp_control ? */
diff -r 2d20081f6abd -r fe6ed7f548d1 sys/compat/linux/arch/amd64/linux_machdep.c
--- a/sys/compat/linux/arch/amd64/linux_machdep.c       Mon Nov 23 00:18:37 2009 +0000
+++ b/sys/compat/linux/arch/amd64/linux_machdep.c       Mon Nov 23 00:46:06 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_machdep.c,v 1.36 2009/05/29 14:19:12 njoly Exp $ */
+/*     $NetBSD: linux_machdep.c,v 1.37 2009/11/23 00:46:06 rmind Exp $ */
 
 /*-
  * Copyright (c) 2005 Emmanuel Dreyfus, all rights reserved.
@@ -33,7 +33,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.36 2009/05/29 14:19:12 njoly Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.37 2009/11/23 00:46:06 rmind Exp $");



Home | Main Index | Thread Index | Old Index