diff --git a/sys/alpha/alpha/procfs_machdep.c b/sys/alpha/alpha/procfs_machdep.c deleted file mode 100644 index 0c141ebf4a4d..000000000000 --- a/sys/alpha/alpha/procfs_machdep.c +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * Copyright (c) 1993 Jan-Simon Pendry - * - * This code is derived from software contributed to Berkeley by - * Jan-Simon Pendry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)procfs_machdep.c 8.3 (Berkeley) 1/27/94 - * - * From: - * $FreeBSD$ - */ - -/* - * Functions to be implemented here are: - * - * procfs_read_regs(proc, regs) - * Get the current user-visible register set from the process - * and copy it into the regs structure (). - * The process is stopped at the time read_regs is called. - * - * procfs_write_regs(proc, regs) - * Update the current register set from the passed in regs - * structure. Take care to avoid clobbering special CPU - * registers or privileged bits in the PSL. - * Depending on the architecture this may have fix-up work to do, - * especially if the IAR or PCW are modified. - * The process is stopped at the time write_regs is called. - * - * procfs_read_fpregs, procfs_write_fpregs - * deal with the floating point register set, otherwise as above. - * - * procfs_sstep(proc) - * Arrange for the process to trap after executing a single instruction. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -#define PROCFS_ACTION(action) do { \ - int error; \ - \ - mtx_lock_spin(&sched_lock); \ - if ((td->td_proc->p_sflag & PS_INMEM) == 0) \ - error = EIO; \ - else \ - error = (action); \ - mtx_unlock_spin(&sched_lock); \ - return (error); \ -} while(0) - -int -procfs_read_regs(td, regs) - struct thread *td; - struct reg *regs; -{ - - PROCFS_ACTION(fill_regs(td, regs)); -} - -int -procfs_write_regs(td, regs) - struct thread *td; - struct reg *regs; -{ - - PROCFS_ACTION(set_regs(td, regs)); -} - -/* - * Ptrace doesn't support fpregs at all, and there are no security holes - * or translations for fpregs, so we can just copy them. - */ - -int -procfs_read_fpregs(td, fpregs) - struct thread *td; - struct fpreg *fpregs; -{ - - PROCFS_ACTION(fill_fpregs(td, fpregs)); -} - -int -procfs_write_fpregs(td, fpregs) - struct thread *td; - struct fpreg *fpregs; -{ - - PROCFS_ACTION(set_fpregs(td, fpregs)); -} - -int -procfs_sstep(td) - struct thread *td; -{ - return (EINVAL); -} - -/* - * Placeholders - */ -int -procfs_read_dbregs(td, dbregs) - struct thread *td; - struct dbreg *dbregs; -{ - return (EIO); -} - -int -procfs_write_dbregs(td, dbregs) - struct thread *td; - struct dbreg *dbregs; -{ - return (EIO); -} diff --git a/sys/conf/files.alpha b/sys/conf/files.alpha index 8f298ccefead..dad4b5028beb 100644 --- a/sys/conf/files.alpha +++ b/sys/conf/files.alpha @@ -72,7 +72,6 @@ alpha/alpha/pal.s standard alpha/alpha/perfmon.c optional perfmon profiling-routine alpha/alpha/perfmon.c optional perfmon alpha/alpha/pmap.c standard -alpha/alpha/procfs_machdep.c standard alpha/alpha/mp_machdep.c optional smp alpha/alpha/prom.c standard alpha/alpha/promcons.c standard diff --git a/sys/conf/files.i386 b/sys/conf/files.i386 index 458dd1982205..27797e91b6d3 100644 --- a/sys/conf/files.i386 +++ b/sys/conf/files.i386 @@ -202,7 +202,6 @@ i386/i386/nexus.c standard i386/i386/perfmon.c optional perfmon i386/i386/perfmon.c optional perfmon profiling-routine i386/i386/pmap.c standard -i386/i386/procfs_machdep.c standard i386/i386/support.s standard i386/i386/swtch.s standard i386/i386/sys_machdep.c standard diff --git a/sys/conf/files.ia64 b/sys/conf/files.ia64 index e6ddb23cf9ad..52e4eec58a6b 100644 --- a/sys/conf/files.ia64 +++ b/sys/conf/files.ia64 @@ -48,7 +48,6 @@ ia64/ia64/pal_stub.s optional ski ia64/ia64/perfmon.c optional perfmon profiling-routine ia64/ia64/perfmon.c optional perfmon ia64/ia64/pmap.c standard -ia64/ia64/procfs_machdep.c standard ia64/ia64/sal.c standard ia64/ia64/sapic.c standard ia64/ia64/setjmp.s standard diff --git a/sys/conf/files.pc98 b/sys/conf/files.pc98 index 1f01dfd83b27..ba9b63cdb7e7 100644 --- a/sys/conf/files.pc98 +++ b/sys/conf/files.pc98 @@ -196,7 +196,6 @@ i386/i386/nexus.c standard i386/i386/perfmon.c optional perfmon i386/i386/perfmon.c optional perfmon profiling-routine i386/i386/pmap.c standard -i386/i386/procfs_machdep.c standard i386/i386/support.s standard i386/i386/swtch.s standard i386/i386/sys_machdep.c standard diff --git a/sys/conf/files.powerpc b/sys/conf/files.powerpc index 225fb95d21f1..6c09692db4b1 100644 --- a/sys/conf/files.powerpc +++ b/sys/conf/files.powerpc @@ -25,7 +25,6 @@ powerpc/powerpc/machdep.c standard powerpc/powerpc/ofwmagic.s standard powerpc/powerpc/ofw_machdep.c standard powerpc/powerpc/pmap.c standard -powerpc/powerpc/procfs_machdep.c standard powerpc/powerpc/subyte.c standard powerpc/powerpc/suswintr.c standard powerpc/powerpc/suword.c standard diff --git a/sys/conf/files.sparc64 b/sys/conf/files.sparc64 index 758e94e209f6..b7f17e250231 100644 --- a/sys/conf/files.sparc64 +++ b/sys/conf/files.sparc64 @@ -26,7 +26,6 @@ sparc64/sparc64/identcpu.c standard sparc64/sparc64/intr_machdep.c standard sparc64/sparc64/machdep.c standard sparc64/sparc64/pmap.c standard -sparc64/sparc64/procfs_machdep.c standard sparc64/sparc64/pv.c standard sparc64/sparc64/rwindow.c standard sparc64/sparc64/support.s standard diff --git a/sys/fs/procfs/procfs_ctl.c b/sys/fs/procfs/procfs_ctl.c index 14e3d0a7ba55..2dcae24071bc 100644 --- a/sys/fs/procfs/procfs_ctl.c +++ b/sys/fs/procfs/procfs_ctl.c @@ -242,7 +242,7 @@ procfs_control(curp, p, op) case PROCFS_CTL_STEP: _PHOLD(p); PROC_UNLOCK(p); - error = procfs_sstep(&p->p_thread); /* XXXKSE */ + error = proc_sstep(&p->p_thread); /* XXXKSE */ PRELE(p); if (error) return (error); diff --git a/sys/fs/procfs/procfs_dbregs.c b/sys/fs/procfs/procfs_dbregs.c index 1327f279281a..dad4025cca0b 100644 --- a/sys/fs/procfs/procfs_dbregs.c +++ b/sys/fs/procfs/procfs_dbregs.c @@ -84,14 +84,14 @@ procfs_dodbregs(curp, p, pfs, uio) if (kl < 0) error = EINVAL; else - error = procfs_read_dbregs(&p->p_thread, &r); /* XXXKSE */ + error = proc_read_dbregs(&p->p_thread, &r); /* XXXKSE */ if (error == 0) error = uiomove(kv, kl, uio); if (error == 0 && uio->uio_rw == UIO_WRITE) { if (p->p_stat != SSTOP) error = EBUSY; else - error = procfs_write_dbregs(&p->p_thread, &r); /* XXXKSE */ + error = proc_write_dbregs(&p->p_thread, &r); /* XXXKSE */ } PRELE(p); diff --git a/sys/fs/procfs/procfs_fpregs.c b/sys/fs/procfs/procfs_fpregs.c index b01509b22327..99ed221dac23 100644 --- a/sys/fs/procfs/procfs_fpregs.c +++ b/sys/fs/procfs/procfs_fpregs.c @@ -81,14 +81,14 @@ procfs_dofpregs(curp, p, pfs, uio) if (kl < 0) error = EINVAL; else - error = procfs_read_fpregs(&p->p_thread, &r); + error = proc_read_fpregs(&p->p_thread, &r); if (error == 0) error = uiomove(kv, kl, uio); if (error == 0 && uio->uio_rw == UIO_WRITE) { if (p->p_stat != SSTOP) error = EBUSY; else - error = procfs_write_fpregs(&p->p_thread, &r); + error = proc_write_fpregs(&p->p_thread, &r); } PRELE(p); diff --git a/sys/fs/procfs/procfs_regs.c b/sys/fs/procfs/procfs_regs.c index 27e950d79880..8488f13ccd66 100644 --- a/sys/fs/procfs/procfs_regs.c +++ b/sys/fs/procfs/procfs_regs.c @@ -82,14 +82,14 @@ procfs_doregs(curp, p, pfs, uio) if (kl < 0) error = EINVAL; else - error = procfs_read_regs(&p->p_thread, &r); /* XXXKSE */ + error = proc_read_regs(&p->p_thread, &r); /* XXXKSE */ if (error == 0) error = uiomove(kv, kl, uio); if (error == 0 && uio->uio_rw == UIO_WRITE) { if (p->p_stat != SSTOP) error = EBUSY; else - error = procfs_write_regs(&p->p_thread, &r); /* XXXKSE */ + error = proc_write_regs(&p->p_thread, &r); /* XXXKSE */ } PRELE(p); diff --git a/sys/i386/i386/procfs_machdep.c b/sys/i386/i386/procfs_machdep.c deleted file mode 100644 index 7913dab01bd3..000000000000 --- a/sys/i386/i386/procfs_machdep.c +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * Copyright (c) 1993 Jan-Simon Pendry - * - * This code is derived from software contributed to Berkeley by - * Jan-Simon Pendry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)procfs_machdep.c 8.3 (Berkeley) 1/27/94 - * - * From: - * $FreeBSD$ - */ - -/* - * Functions to be implemented here are: - * - * procfs_read_regs(proc, regs) - * Get the current user-visible register set from the process - * and copy it into the regs structure (). - * The process is stopped at the time read_regs is called. - * - * procfs_write_regs(proc, regs) - * Update the current register set from the passed in regs - * structure. Take care to avoid clobbering special CPU - * registers or privileged bits in the PSL. - * Depending on the architecture this may have fix-up work to do, - * especially if the IAR or PCW are modified. - * The process is stopped at the time write_regs is called. - * - * procfs_read_fpregs, procfs_write_fpregs - * deal with the floating point register set, otherwise as above. - * - * procfs_read_dbregs, procfs_write_dbregs - * deal with the processor debug register set, otherwise as above. - * - * procfs_sstep(proc) - * Arrange for the process to trap after executing a single instruction. - * - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -#define PROCFS_ACTION(action) do { \ - int error; \ - \ - mtx_lock_spin(&sched_lock); \ - if ((td->td_proc->p_sflag & PS_INMEM) == 0) \ - error = EIO; \ - else \ - error = (action); \ - mtx_unlock_spin(&sched_lock); \ - return (error); \ -} while(0) - -int -procfs_read_regs(td, regs) - struct thread *td; - struct reg *regs; -{ - - PROCFS_ACTION(fill_regs(td, regs)); -} - -int -procfs_write_regs(td, regs) - struct thread *td; - struct reg *regs; -{ - - PROCFS_ACTION(set_regs(td, regs)); -} - -int -procfs_read_dbregs(td, dbregs) - struct thread *td; - struct dbreg *dbregs; -{ - - PROCFS_ACTION(fill_dbregs(td, dbregs)); -} - -int -procfs_write_dbregs(td, dbregs) - struct thread *td; - struct dbreg *dbregs; -{ - - PROCFS_ACTION(set_dbregs(td, dbregs)); -} - -/* - * Ptrace doesn't support fpregs at all, and there are no security holes - * or translations for fpregs, so we can just copy them. - */ - -int -procfs_read_fpregs(td, fpregs) - struct thread *td; - struct fpreg *fpregs; -{ - - PROCFS_ACTION(fill_fpregs(td, fpregs)); -} - -int -procfs_write_fpregs(td, fpregs) - struct thread *td; - struct fpreg *fpregs; -{ - - PROCFS_ACTION(set_fpregs(td, fpregs)); -} - -int -procfs_sstep(td) - struct thread *td; -{ - - PROCFS_ACTION(ptrace_single_step(td)); -} diff --git a/sys/ia64/ia64/procfs_machdep.c b/sys/ia64/ia64/procfs_machdep.c deleted file mode 100644 index 27a1198020b8..000000000000 --- a/sys/ia64/ia64/procfs_machdep.c +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * Copyright (c) 1993 Jan-Simon Pendry - * - * This code is derived from software contributed to Berkeley by - * Jan-Simon Pendry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)procfs_machdep.c 8.3 (Berkeley) 1/27/94 - * - * From: - * $FreeBSD$ - */ - -/* - * Functions to be implemented here are: - * - * procfs_read_regs(proc, regs) - * Get the current user-visible register set from the process - * and copy it into the regs structure (). - * The process is stopped at the time read_regs is called. - * - * procfs_write_regs(proc, regs) - * Update the current register set from the passed in regs - * structure. Take care to avoid clobbering special CPU - * registers or privileged bits in the PSL. - * Depending on the architecture this may have fix-up work to do, - * especially if the IAR or PCW are modified. - * The process is stopped at the time write_regs is called. - * - * procfs_read_fpregs, procfs_write_fpregs - * deal with the floating point register set, otherwise as above. - * - * procfs_sstep(proc) - * Arrange for the process to trap after executing a single instruction. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -#define PROCFS_ACTION(action) do { \ - int error; \ - \ - mtx_lock_spin(&sched_lock); \ - if ((td->td_proc->p_sflag & PS_INMEM) == 0) \ - error = EIO; \ - else \ - error = (action); \ - mtx_unlock_spin(&sched_lock); \ - return (error); \ -} while(0) - -int -procfs_read_regs(td, regs) - struct thread *td; - struct reg *regs; -{ - - PROCFS_ACTION(fill_regs(td, regs)); -} - -int -procfs_write_regs(td, regs) - struct thread *td; - struct reg *regs; -{ - - PROCFS_ACTION(set_regs(td, regs)); -} - -/* - * Ptrace doesn't support fpregs at all, and there are no security holes - * or translations for fpregs, so we can just copy them. - */ - -int -procfs_read_fpregs(td, fpregs) - struct thread *td; - struct fpreg *fpregs; -{ - - PROCFS_ACTION(fill_fpregs(td, fpregs)); -} - -int -procfs_write_fpregs(td, fpregs) - struct thread *td; - struct fpreg *fpregs; -{ - - PROCFS_ACTION(set_fpregs(td, fpregs)); -} - -int -procfs_sstep(td) - struct thread *td; -{ - return (EINVAL); -} - -/* - * Placeholders - */ -int -procfs_read_dbregs(td, dbregs) - struct thread *td; - struct dbreg *dbregs; -{ - return (EIO); -} - -int -procfs_write_dbregs(td, dbregs) - struct thread *td; - struct dbreg *dbregs; -{ - return (EIO); -} diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c index 7408c6cbd77c..a1ef385ad0d1 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -53,6 +53,36 @@ #include #include +#define PROC_REG_ACTION(name, action, type) \ +int \ +proc_##name##_##type##s(struct thread *td, struct type *regs) \ +{ \ + int error; \ + \ + mtx_lock_spin(&sched_lock); \ + error = (action##_##type##s(td, regs)); \ + mtx_unlock_spin(&sched_lock); \ + return (error); \ +} + +PROC_REG_ACTION(read, fill, reg); +PROC_REG_ACTION(write, set, reg); +PROC_REG_ACTION(read, fill, dbreg); +PROC_REG_ACTION(write, set, dbreg); +PROC_REG_ACTION(read, fill, fpreg); +PROC_REG_ACTION(write, set, fpreg); + +int +proc_sstep(struct thread *td) +{ + int error; + + mtx_lock_spin(&sched_lock); + error = ptrace_single_step(td); + mtx_unlock_spin(&sched_lock); + return (error); +} + int proc_rwmem(struct proc *p, struct uio *uio) { @@ -495,7 +525,7 @@ ptrace(struct thread *td, struct ptrace_args *uap) error = copyin(uap->addr, &r.reg, sizeof r.reg); if (error == 0) { PHOLD(p); - error = procfs_write_regs(&p->p_thread, &r.reg); + error = proc_write_regs(&p->p_thread, &r.reg); PRELE(p); } return (error); @@ -504,7 +534,7 @@ ptrace(struct thread *td, struct ptrace_args *uap) #ifdef PT_GETREGS case PT_GETREGS: PHOLD(p); - error = procfs_read_regs(&p->p_thread, &r.reg); + error = proc_read_regs(&p->p_thread, &r.reg); PRELE(p); if (error == 0) error = copyout(&r.reg, uap->addr, sizeof r.reg); @@ -516,7 +546,7 @@ ptrace(struct thread *td, struct ptrace_args *uap) error = copyin(uap->addr, &r.fpreg, sizeof r.fpreg); if (error == 0) { PHOLD(p); - error = procfs_write_fpregs(&p->p_thread, &r.fpreg); + error = proc_write_fpregs(&p->p_thread, &r.fpreg); PRELE(p); } return (error); @@ -525,7 +555,7 @@ ptrace(struct thread *td, struct ptrace_args *uap) #ifdef PT_GETFPREGS case PT_GETFPREGS: PHOLD(p); - error = procfs_read_fpregs(&p->p_thread, &r.fpreg); + error = proc_read_fpregs(&p->p_thread, &r.fpreg); PRELE(p); if (error == 0) error = copyout(&r.fpreg, uap->addr, sizeof r.fpreg); @@ -537,7 +567,7 @@ ptrace(struct thread *td, struct ptrace_args *uap) error = copyin(uap->addr, &r.dbreg, sizeof r.dbreg); if (error == 0) { PHOLD(p); - error = procfs_write_dbregs(&p->p_thread, &r.dbreg); + error = proc_write_dbregs(&p->p_thread, &r.dbreg); PRELE(p); } return (error); @@ -546,7 +576,7 @@ ptrace(struct thread *td, struct ptrace_args *uap) #ifdef PT_GETDBREGS case PT_GETDBREGS: PHOLD(p); - error = procfs_read_dbregs(&p->p_thread, &r.dbreg); + error = proc_read_dbregs(&p->p_thread, &r.dbreg); PRELE(p); if (error == 0) error = copyout(&r.dbreg, uap->addr, sizeof r.dbreg); diff --git a/sys/powerpc/powerpc/procfs_machdep.c b/sys/powerpc/powerpc/procfs_machdep.c deleted file mode 100644 index 83e89264e15d..000000000000 --- a/sys/powerpc/powerpc/procfs_machdep.c +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * Copyright (c) 1993 Jan-Simon Pendry - * - * This code is derived from software contributed to Berkeley by - * Jan-Simon Pendry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)procfs_machdep.c 8.3 (Berkeley) 1/27/94 - * - * $FreeBSD$ - */ - -/* - * Functions to be implemented here are: - * - * procfs_read_regs(proc, regs) - * Get the current user-visible register set from the process - * and copy it into the regs structure (). - * The process is stopped at the time read_regs is called. - * - * procfs_write_regs(proc, regs) - * Update the current register set from the passed in regs - * structure. Take care to avoid clobbering special CPU - * registers or privileged bits in the PSL. - * Depending on the architecture this may have fix-up work to do, - * especially if the IAR or PCW are modified. - * The process is stopped at the time write_regs is called. - * - * procfs_read_fpregs, procfs_write_fpregs - * deal with the floating point register set, otherwise as above. - * - * procfs_sstep(proc) - * Arrange for the process to trap after executing a single instruction. - * - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -#include - -#define PROCFS_ACTION(action) do { \ - int error; \ - \ - mtx_lock_spin(&sched_lock); \ - if ((td->td_proc->p_sflag & PS_INMEM) == 0) \ - error = EIO; \ - else \ - error = (action); \ - mtx_unlock_spin(&sched_lock); \ - return (error); \ -} while(0) - -int -procfs_read_regs(td, regs) - struct thread *td; - struct reg *regs; -{ - PROCFS_ACTION(fill_regs(td, regs)); -} - -int -procfs_write_regs(td, regs) - struct thread *td; - struct reg *regs; -{ - PROCFS_ACTION(set_regs(td, regs)); -} - -/* - * Ptrace doesn't support fpregs at all, and there are no security holes - * or translations for fpregs, so we can just copy them. - */ - -int -procfs_read_fpregs(td, fpregs) - struct thread *td; - struct fpreg *fpregs; -{ - PROCFS_ACTION(fill_fpregs(td, fpregs)); -} - -int -procfs_write_fpregs(td, fpregs) - struct thread *td; - struct fpreg *fpregs; -{ - PROCFS_ACTION(set_fpregs(td, fpregs)); -} - -int -procfs_sstep(td) - struct thread *td; -{ - return (EINVAL); -} - -/* - * Placeholders - */ -int -procfs_read_dbregs(td, dbregs) - struct thread *td; - struct dbreg *dbregs; -{ - return (EIO); -} - -int -procfs_write_dbregs(td, dbregs) - struct thread *td; - struct dbreg *dbregs; -{ - return (EIO); -} diff --git a/sys/sparc64/sparc64/procfs_machdep.c b/sys/sparc64/sparc64/procfs_machdep.c deleted file mode 100644 index 109c7b63fa11..000000000000 --- a/sys/sparc64/sparc64/procfs_machdep.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * Copyright (c) 1993 Jan-Simon Pendry - * - * This code is derived from software contributed to Berkeley by - * Jan-Simon Pendry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)procfs_machdep.c 8.3 (Berkeley) 1/27/94 - * $FreeBSD$ - */ - -/* - * Functions to be implemented here are: - * - * procfs_read_regs(proc, regs) - * Get the current user-visible register set from the process - * and copy it into the regs structure (). - * The process is stopped at the time read_regs is called. - * - * procfs_write_regs(proc, regs) - * Update the current register set from the passed in regs - * structure. Take care to avoid clobbering special CPU - * registers or privileged bits in the PSL. - * Depending on the architecture this may have fix-up work to do, - * especially if the IAR or PCW are modified. - * The process is stopped at the time write_regs is called. - * - * procfs_read_fpregs, procfs_write_fpregs - * deal with the floating point register set, otherwise as above. - * - * procfs_read_dbregs, procfs_write_dbregs - * deal with the processor debug register set, otherwise as above. - * - * procfs_sstep(proc) - * Arrange for the process to trap after executing a single instruction. - * - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -#define PROCFS_ACTION(action) do { \ - int error; \ - \ - mtx_lock_spin(&sched_lock); \ - if ((td->td_proc->p_sflag & PS_INMEM) == 0) \ - error = EIO; \ - else \ - error = (action); \ - mtx_unlock_spin(&sched_lock); \ - return (error); \ -} while(0) - -int -procfs_read_regs(struct thread *td, struct reg *regs) -{ - - PROCFS_ACTION(fill_regs(td, regs)); -} - -int -procfs_write_regs(struct thread *td, struct reg *regs) -{ - - PROCFS_ACTION(set_regs(td, regs)); -} - -int -procfs_read_dbregs(struct thread *td, struct dbreg *dbregs) -{ - - return (EIO); -} - -int -procfs_write_dbregs(struct thread *td, struct dbreg *dbregs) -{ - - return (EIO); -} - -/* - * Ptrace doesn't support fpregs at all, and there are no security holes - * or translations for fpregs, so we can just copy them. - */ - -int -procfs_read_fpregs(struct thread *td, struct fpreg *fpregs) -{ - - PROCFS_ACTION(fill_fpregs(td, fpregs)); -} - -int -procfs_write_fpregs(struct thread *td, struct fpreg *fpregs) -{ - - PROCFS_ACTION(set_fpregs(td, fpregs)); -} - -int -procfs_sstep(struct thread *td) -{ - - PROCFS_ACTION(ptrace_single_step(td)); -} diff --git a/sys/sys/ptrace.h b/sys/sys/ptrace.h index c290e38efef8..c530093b4a7a 100644 --- a/sys/sys/ptrace.h +++ b/sys/sys/ptrace.h @@ -67,13 +67,13 @@ int ptrace_single_step(struct thread *_td); struct reg; struct fpreg; struct dbreg; -int procfs_read_regs(struct thread *_td, struct reg *_reg); -int procfs_write_regs(struct thread *_td, struct reg *_reg); -int procfs_read_fpregs(struct thread *_td, struct fpreg *_fpreg); -int procfs_write_fpregs(struct thread *_td, struct fpreg *_fpreg); -int procfs_read_dbregs(struct thread *_td, struct dbreg *_dbreg); -int procfs_write_dbregs(struct thread *_td, struct dbreg *_dbreg); -int procfs_sstep(struct thread *_td); +int proc_read_regs(struct thread *_td, struct reg *_reg); +int proc_write_regs(struct thread *_td, struct reg *_reg); +int proc_read_fpregs(struct thread *_td, struct fpreg *_fpreg); +int proc_write_fpregs(struct thread *_td, struct fpreg *_fpreg); +int proc_read_dbregs(struct thread *_td, struct dbreg *_dbreg); +int proc_write_dbregs(struct thread *_td, struct dbreg *_dbreg); +int proc_sstep(struct thread *_td); int proc_rwmem(struct proc *_p, struct uio *_uio); #else /* !_KERNEL */