Source-Changes-HG archive

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

[src/trunk]: src/sys Rip out the code that might once have supported the free...



details:   https://anonhg.NetBSD.org/src/rev/69a91e440d17
branches:  trunk
changeset: 326122:69a91e440d17
user:      dsl <dsl%NetBSD.org@localhost>
date:      Sun Jan 19 13:35:58 2014 +0000

description:
Rip out the code that might once have supported the freebsd ptrace
  system calls.
Removes some very dodgy conversions of FP register layouts.
Most of it has been disabled since 2007 when I removed the stackgap.

diffstat:

 sys/arch/i386/i386/freebsd_machdep.c    |  154 +-------------------------------
 sys/arch/i386/include/freebsd_machdep.h |   70 +--------------
 sys/compat/freebsd/freebsd_ptrace.c     |  110 +----------------------
 3 files changed, 6 insertions(+), 328 deletions(-)

diffs (truncated from 399 to 300 lines):

diff -r 0139ee79024d -r 69a91e440d17 sys/arch/i386/i386/freebsd_machdep.c
--- a/sys/arch/i386/i386/freebsd_machdep.c      Sun Jan 19 11:36:45 2014 +0000
+++ b/sys/arch/i386/i386/freebsd_machdep.c      Sun Jan 19 13:35:58 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: freebsd_machdep.c,v 1.56 2013/12/08 20:45:30 dsl Exp $ */
+/*     $NetBSD: freebsd_machdep.c,v 1.57 2014/01/19 13:35:58 dsl Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: freebsd_machdep.c,v 1.56 2013/12/08 20:45:30 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: freebsd_machdep.c,v 1.57 2014/01/19 13:35:58 dsl Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_vm86.h"
@@ -56,7 +56,6 @@
 #include <compat/freebsd/freebsd_syscallargs.h>
 #include <compat/freebsd/freebsd_exec.h>
 #include <compat/freebsd/freebsd_signal.h>
-#include <compat/freebsd/freebsd_ptrace.h>
 
 void
 freebsd_setregs(struct lwp *l, struct exec_package *epp, vaddr_t stack)
@@ -255,152 +254,3 @@
        return (EJUSTRETURN);
 }
 
-
-/*
- * freebsd_ptrace(2) support
- */
-
-void
-netbsd_to_freebsd_ptrace_regs(struct reg *nregs, struct fpreg *nfpregs, struct freebsd_ptrace_reg *fregs)
-{
-       struct save87 *nframe = (struct save87 *)nfpregs;
-
-       fregs->freebsd_ptrace_regs.tf_es = nregs->r_es;
-       fregs->freebsd_ptrace_regs.tf_ds = nregs->r_ds;
-       fregs->freebsd_ptrace_regs.tf_edi = nregs->r_edi;
-       fregs->freebsd_ptrace_regs.tf_esi = nregs->r_esi;
-       fregs->freebsd_ptrace_regs.tf_ebp = nregs->r_ebp;
-       fregs->freebsd_ptrace_regs.tf_isp = 0;
-       fregs->freebsd_ptrace_regs.tf_ebx = nregs->r_ebx;
-       fregs->freebsd_ptrace_regs.tf_edx = nregs->r_edx;
-       fregs->freebsd_ptrace_regs.tf_ecx = nregs->r_ecx;
-       fregs->freebsd_ptrace_regs.tf_eax = nregs->r_eax;
-       fregs->freebsd_ptrace_regs.tf_trapno = 0;
-
-       fregs->freebsd_ptrace_regs.tf_err = 0;
-       fregs->freebsd_ptrace_regs.tf_eip = nregs->r_eip;
-       fregs->freebsd_ptrace_regs.tf_cs = nregs->r_cs;
-       fregs->freebsd_ptrace_regs.tf_eflags = nregs->r_eflags;
-
-       fregs->freebsd_ptrace_regs.tf_esp = nregs->r_esp;
-       fregs->freebsd_ptrace_regs.tf_ss = nregs->r_ss;
-
-       fregs->freebsd_ptrace_fpregs.sv_env = nframe->sv_env;
-       memcpy(fregs->freebsd_ptrace_fpregs.sv_ac, nframe->sv_ac,
-             sizeof(fregs->freebsd_ptrace_fpregs.sv_ac));
-       fregs->freebsd_ptrace_fpregs.sv_ex_sw = 
-               nframe->sv_ex_sw;
-       /*
-        * fortunately, sizeof(freebsd_save87) >= sizeof(save87)
-        */
-#ifdef DIAGNOSTIC
-       if (sizeof(fregs->freebsd_ptrace_fpregs.sv_pad) <
-           sizeof(nframe->sv_ex_tw) + sizeof(nframe->sv_pad)) {
-               panic("netbsd_to_freebsd_ptrace_regs: %s",
-                     "sizeof(freebsd_save87) >= sizeof(save87)");
-       }
-#endif
-       memcpy(fregs->freebsd_ptrace_fpregs.sv_pad, &nframe->sv_ex_tw,
-             sizeof(nframe->sv_ex_tw));
-       memcpy((char *)fregs->freebsd_ptrace_fpregs.sv_pad +
-             sizeof(nframe->sv_ex_tw),
-             nframe->sv_pad,
-             sizeof(nframe->sv_pad));
-       memset((char *)fregs->freebsd_ptrace_fpregs.sv_pad +
-             sizeof(nframe->sv_ex_tw) + sizeof(nframe->sv_pad),
-             0,
-             sizeof(fregs->freebsd_ptrace_fpregs.sv_pad) -
-             sizeof(nframe->sv_ex_tw) - sizeof(nframe->sv_pad));
-}
-
-void
-freebsd_to_netbsd_ptrace_regs(struct freebsd_ptrace_reg *fregs, struct reg *nregs, struct fpreg *nfpregs)
-{
-       struct save87 *nframe = (struct save87 *)nfpregs;
-
-       nregs->r_es = fregs->freebsd_ptrace_regs.tf_es;
-       nregs->r_ds = fregs->freebsd_ptrace_regs.tf_ds;
-       nregs->r_edi = fregs->freebsd_ptrace_regs.tf_edi;
-       nregs->r_esi = fregs->freebsd_ptrace_regs.tf_esi;
-       nregs->r_ebp = fregs->freebsd_ptrace_regs.tf_ebp;
-       nregs->r_ebx = fregs->freebsd_ptrace_regs.tf_ebx;
-       nregs->r_edx = fregs->freebsd_ptrace_regs.tf_edx;
-       nregs->r_ecx = fregs->freebsd_ptrace_regs.tf_ecx;
-       nregs->r_eax = fregs->freebsd_ptrace_regs.tf_eax;
-
-       nregs->r_eip = fregs->freebsd_ptrace_regs.tf_eip;
-       nregs->r_cs = fregs->freebsd_ptrace_regs.tf_cs;
-       nregs->r_eflags = fregs->freebsd_ptrace_regs.tf_eflags;
-
-       nregs->r_esp = fregs->freebsd_ptrace_regs.tf_esp;
-       nregs->r_ss = fregs->freebsd_ptrace_regs.tf_ss;
-
-       nframe->sv_env = fregs->freebsd_ptrace_fpregs.sv_env;
-       memcpy(nframe->sv_ac, fregs->freebsd_ptrace_fpregs.sv_ac,
-             sizeof(nframe->sv_ac));
-       nframe->sv_ex_sw =
-               fregs->freebsd_ptrace_fpregs.sv_ex_sw;
-       /*
-        * fortunately, sizeof(freebsd_save87) >= sizeof(save87)
-        */
-       memcpy(&nframe->sv_ex_tw, fregs->freebsd_ptrace_fpregs.sv_pad,
-             sizeof(nframe->sv_ex_tw));
-       memcpy(nframe->sv_pad,
-             (char *)fregs->freebsd_ptrace_fpregs.sv_pad +
-             sizeof(nframe->sv_ex_tw),
-             sizeof(nframe->sv_pad));
-}
-
-/* random value, except FREEBSD_U_AR0_OFFSET..., FREEBSD_U_SAVEFP_OFFSET... */
-#define        FREEBSD_REGS_OFFSET 0x2000
-
-int
-freebsd_ptrace_getregs(struct freebsd_ptrace_reg *fregs, void *addr, register_t *datap)
-{
-       vaddr_t offset = (vaddr_t)addr;
-
-       if (offset == FREEBSD_U_AR0_OFFSET) {
-               *datap = FREEBSD_REGS_OFFSET + FREEBSD_USRSTACK;
-               return 0;
-       } else if (offset >= FREEBSD_REGS_OFFSET &&
-                  offset <= FREEBSD_REGS_OFFSET + 
-                     sizeof(fregs->freebsd_ptrace_regs)-sizeof(register_t)) {
-               *datap = *(register_t *)&((char *)&fregs->freebsd_ptrace_regs)
-                       [(vaddr_t) addr - FREEBSD_REGS_OFFSET];
-               return 0;
-       } else if (offset >= FREEBSD_U_SAVEFP_OFFSET &&
-                  offset <= FREEBSD_U_SAVEFP_OFFSET + 
-                     sizeof(fregs->freebsd_ptrace_fpregs)-sizeof(register_t)){
-               *datap= *(register_t *)&((char *)&fregs->freebsd_ptrace_fpregs)
-                       [offset - FREEBSD_U_SAVEFP_OFFSET];
-               return 0;
-       }
-#ifdef DIAGNOSTIC
-       printf("freebsd_ptrace_getregs: *(0x%08lx)\n", offset);
-#endif
-       return EFAULT;
-}
-
-int
-freebsd_ptrace_setregs(struct freebsd_ptrace_reg *fregs, void *addr, int data)
-{
-       vaddr_t offset = (vaddr_t)addr;
-
-       if (offset >= FREEBSD_REGS_OFFSET &&
-           offset <= FREEBSD_REGS_OFFSET +
-                       sizeof(fregs->freebsd_ptrace_regs) - sizeof(int)) {
-               *(int *)&((char *)&fregs->freebsd_ptrace_regs)
-                       [offset - FREEBSD_REGS_OFFSET] = data;
-               return 0;
-       } else if (offset >= FREEBSD_U_SAVEFP_OFFSET &&
-                  offset <= FREEBSD_U_SAVEFP_OFFSET + 
-                       sizeof(fregs->freebsd_ptrace_fpregs) - sizeof(int)) {
-               *(int *)&((char *)&fregs->freebsd_ptrace_fpregs)
-                       [offset - FREEBSD_U_SAVEFP_OFFSET] = data;
-               return 0;
-       }
-#ifdef DIAGNOSTIC
-       printf("freebsd_ptrace_setregs: *(0x%08lx) = 0x%08x\n", offset, data);
-#endif
-       return EFAULT;
-}
diff -r 0139ee79024d -r 69a91e440d17 sys/arch/i386/include/freebsd_machdep.h
--- a/sys/arch/i386/include/freebsd_machdep.h   Sun Jan 19 11:36:45 2014 +0000
+++ b/sys/arch/i386/include/freebsd_machdep.h   Sun Jan 19 13:35:58 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: freebsd_machdep.h,v 1.11 2013/12/09 17:39:53 dsl Exp $ */
+/*     $NetBSD: freebsd_machdep.h,v 1.12 2014/01/19 13:35:58 dsl Exp $ */
 
 /*
  * Copyright (c) 1986, 1989, 1991, 1993
@@ -111,74 +111,6 @@
        struct  freebsd_sigcontext sf_sc;
 };
 
-/*
- * freebsd_ptrace(2) support
- */
-
-#define        FREEBSD_USRSTACK        0xefbfe000 /* USRSTACK */
-#define        FREEBSD_U_AR0_OFFSET    0x0000045c /* offsetof(struct user, u_ar0) */
-#define        FREEBSD_U_SAVEFP_OFFSET 0x00000070
-       /* offsetof(struct user, u_pcb) + offsetof(struct pcb, pcb_savefpu) */
-
-/* Exception/Trap Stack Frame */
-struct freebsd_trapframe {
-       int     tf_es;
-       int     tf_ds;
-       int     tf_edi;
-       int     tf_esi;
-       int     tf_ebp;
-       int     tf_isp;
-       int     tf_ebx;
-       int     tf_edx;
-       int     tf_ecx;
-       int     tf_eax;
-       int     tf_trapno;
-       /* below portion defined in 386 hardware */
-       int     tf_err;
-       int     tf_eip;
-       int     tf_cs;
-       int     tf_eflags;
-       /* below only when transitting rings (e.g. user to kernel) */
-       int     tf_esp;
-       int     tf_ss;
-};
-
-/* Environment information of floating point unit */
-#define freebsd_env87 env87
-
-/* Contents of each floating point accumulator */
-struct freebsd_fpacc87 {
-#ifdef dontdef /* too unportable */
-       u_long  fp_mantlo;      /* mantissa low (31:0) */
-       u_long  fp_manthi;      /* mantissa high (63:32) */
-       int     fp_exp:15;      /* exponent */
-       int     fp_sgn:1;       /* mantissa sign */
-#else
-       u_char  fp_bytes[10];
-#endif
-};
-
-/* Floating point context */
-struct freebsd_save87 {
-       struct freebsd_env87 sv_env;    /* floating point control/status */
-       struct freebsd_fpacc87 sv_ac[8];        /* accumulator contents, 0-7 */
-       u_long  sv_ex_sw;               /* status word for last exception */
-       /*
-        * Bogus padding for emulators.  Emulators should use their own
-        * struct and arrange to store into this struct (ending here)
-        * before it is inspected for ptracing or for core dumps.  Some
-        * emulators overwrite the whole struct.  We have no good way of
-        * knowing how much padding to leave.  Leave just enough for the
-        * GPL emulator's i387_union (176 bytes total).
-        */
-       u_char  sv_pad[64];     /* padding; used by emulators */
-};
-
-struct freebsd_ptrace_reg {
-       struct freebsd_trapframe freebsd_ptrace_regs;
-       struct freebsd_save87 freebsd_ptrace_fpregs;
-};
-
 /* sys/i386/include/exec.h */
 #define FREEBSD___LDPGSZ       4096
 
diff -r 0139ee79024d -r 69a91e440d17 sys/compat/freebsd/freebsd_ptrace.c
--- a/sys/compat/freebsd/freebsd_ptrace.c       Sun Jan 19 11:36:45 2014 +0000
+++ b/sys/compat/freebsd/freebsd_ptrace.c       Sun Jan 19 13:35:58 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: freebsd_ptrace.c,v 1.19 2009/11/23 00:46:06 rmind Exp $        */
+/*     $NetBSD: freebsd_ptrace.c,v 1.20 2014/01/19 13:35:58 dsl Exp $  */
 
 /*-
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -71,7 +71,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: freebsd_ptrace.c,v 1.19 2009/11/23 00:46:06 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: freebsd_ptrace.c,v 1.20 2014/01/19 13:35:58 dsl Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -91,7 +91,6 @@
 
 #include <compat/common/compat_util.h>
 #include <compat/freebsd/freebsd_syscallargs.h>
-#include <compat/freebsd/freebsd_ptrace.h>
 
 /*
  * Process debugging system call.
@@ -99,108 +98,5 @@
 int
 freebsd_sys_ptrace(struct lwp *l, const struct freebsd_sys_ptrace_args *uap, register_t *retval)
 {
-       /* {
-               syscallarg(int) req;
-               syscallarg(pid_t) pid;
-               syscallarg(void *) addr;
-               syscallarg(int) data;
-       } */
-       struct sys_ptrace_args npa;



Home | Main Index | Thread Index | Old Index