* Allow machine-dependent code to specify hooks for ptrace(2)
(__HAVE_PTRACE_MACHDEP) and procfs (__HAVE_PROCFS_MACHDEP). These changes will allow platforms like x86 (XMM) and PowerPC (AltiVec) to export extended register sets in a sane manner. * Use __HAVE_PTRACE_MACHDEP to export x86 XMM registers (standard FP + SSE/SSE2) using PT_{GET,SET}XMMREGS (in the machdep ptrace request space). * Use __HAVE_PROCFS_MACHDEP to export x86 XMM registers via /proc/N/xmmregs in procfs.
This commit is contained in:
parent
fbfa7f8e61
commit
03efee5585
@ -1,11 +1,11 @@
|
||||
/* $NetBSD: process_machdep.c,v 1.39 2001/12/04 19:41:47 thorpej Exp $ */
|
||||
/* $NetBSD: process_machdep.c,v 1.40 2001/12/05 00:58:06 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
|
||||
* Copyright (c) 1998, 2000, 2001 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Charles M. Hannum.
|
||||
* by Charles M. Hannum; by Jason R. Thorpe of Wasabi Systems, Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -59,7 +59,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.39 2001/12/04 19:41:47 thorpej Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.40 2001/12/05 00:58:06 thorpej Exp $");
|
||||
|
||||
#include "opt_vm86.h"
|
||||
#include "npx.h"
|
||||
@ -75,6 +75,8 @@ __KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.39 2001/12/04 19:41:47 thorpej
|
||||
|
||||
#include <uvm/uvm_extern.h>
|
||||
|
||||
#include <miscfs/procfs/procfs.h>
|
||||
|
||||
#include <machine/psl.h>
|
||||
#include <machine/reg.h>
|
||||
#include <machine/segments.h>
|
||||
@ -366,3 +368,171 @@ process_set_pc(p, addr)
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
#ifdef __HAVE_PTRACE_MACHDEP
|
||||
int
|
||||
process_machdep_read_xmmregs(p, regs)
|
||||
struct proc *p;
|
||||
struct xmmregs *regs;
|
||||
{
|
||||
union savefpu *frame = process_fpframe(p);
|
||||
|
||||
if (i386_use_fxsave == 0)
|
||||
return (EINVAL);
|
||||
|
||||
if (p->p_md.md_flags & MDP_USEDFPU) {
|
||||
#if NNPX > 0
|
||||
extern struct proc *npxproc;
|
||||
|
||||
if (npxproc == p)
|
||||
npxsave();
|
||||
#endif
|
||||
} else {
|
||||
/*
|
||||
* Fake a FNINIT.
|
||||
* The initial control word was already set by setregs(),
|
||||
* so save it temporarily.
|
||||
*/
|
||||
uint32_t mxcsr = frame->sv_xmm.sv_env.en_mxcsr;
|
||||
uint16_t cw = frame->sv_xmm.sv_env.en_cw;
|
||||
|
||||
/* XXX Don't zero XMM regs? */
|
||||
memset(&frame->sv_xmm, 0, sizeof(frame->sv_xmm));
|
||||
frame->sv_xmm.sv_env.en_cw = cw;
|
||||
frame->sv_xmm.sv_env.en_mxcsr = mxcsr;
|
||||
frame->sv_xmm.sv_env.en_sw = 0x0000;
|
||||
frame->sv_xmm.sv_env.en_tw = 0x00;
|
||||
|
||||
p->p_md.md_flags |= MDP_USEDFPU;
|
||||
}
|
||||
|
||||
memcpy(regs, &frame->sv_xmm, sizeof(*regs));
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
process_machdep_write_xmmregs(p, regs)
|
||||
struct proc *p;
|
||||
struct xmmregs *regs;
|
||||
{
|
||||
union savefpu *frame = process_fpframe(p);
|
||||
|
||||
if (i386_use_fxsave == 0)
|
||||
return (EINVAL);
|
||||
|
||||
if (p->p_md.md_flags & MDP_USEDFPU) {
|
||||
#if NNPX > 0
|
||||
extern struct proc *npxproc;
|
||||
|
||||
if (npxproc == p)
|
||||
npxdrop();
|
||||
#endif
|
||||
} else {
|
||||
p->p_md.md_flags |= MDP_USEDFPU;
|
||||
}
|
||||
|
||||
memcpy(&frame->sv_xmm, regs, sizeof(*regs));
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
ptrace_machdep_dorequest(p, t, req, addr, data)
|
||||
struct proc *p, *t;
|
||||
int req;
|
||||
caddr_t addr;
|
||||
int data;
|
||||
{
|
||||
struct uio uio;
|
||||
struct iovec iov;
|
||||
int write = 0;
|
||||
|
||||
switch (req) {
|
||||
case PT_SETXMMREGS:
|
||||
write = 1;
|
||||
|
||||
case PT_GETXMMREGS:
|
||||
/* write = 0 done above. */
|
||||
if (!procfs_machdep_validxmmregs(t, NULL))
|
||||
return (EINVAL);
|
||||
else {
|
||||
iov.iov_base = addr;
|
||||
iov.iov_len = sizeof(struct xmmregs);
|
||||
uio.uio_iov = &iov;
|
||||
uio.uio_iovcnt = 1;
|
||||
uio.uio_offset = 0;
|
||||
uio.uio_resid = sizeof(struct xmmregs);
|
||||
uio.uio_segflg = UIO_USERSPACE;
|
||||
uio.uio_rw = write ? UIO_WRITE : UIO_READ;
|
||||
uio.uio_procp = p;
|
||||
return (procfs_machdep_doxmmregs(p, t, NULL, &uio));
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
panic("ptrace_machdep: impossible");
|
||||
#endif
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* The following functions have procfs-centric names, but are in
|
||||
* fact used by both ptrace(2) and procfs.
|
||||
*/
|
||||
|
||||
int
|
||||
procfs_machdep_doxmmregs(curp, p, pfs, uio)
|
||||
struct proc *curp; /* tracer */
|
||||
struct proc *p; /* traced */
|
||||
struct pfsnode *pfs;
|
||||
struct uio *uio;
|
||||
{
|
||||
int error;
|
||||
struct xmmregs r;
|
||||
char *kv;
|
||||
int kl;
|
||||
|
||||
if ((error = procfs_checkioperm(curp, p)) != 0)
|
||||
return (error);
|
||||
|
||||
kl = sizeof(r);
|
||||
kv = (char *) &r;
|
||||
|
||||
kv += uio->uio_offset;
|
||||
kl -= uio->uio_offset;
|
||||
if (kl > uio->uio_resid)
|
||||
kl = uio->uio_resid;
|
||||
|
||||
PHOLD(p);
|
||||
|
||||
if (kl < 0)
|
||||
error = EINVAL;
|
||||
else
|
||||
error = process_machdep_read_xmmregs(p, &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 = process_machdep_write_xmmregs(p, &r);
|
||||
}
|
||||
|
||||
PRELE(p);
|
||||
|
||||
uio->uio_offset = 0;
|
||||
return (error);
|
||||
}
|
||||
|
||||
int
|
||||
procfs_machdep_validxmmregs(p, mp)
|
||||
struct proc *p;
|
||||
struct mount *mp;
|
||||
{
|
||||
|
||||
if (p->p_flag & P_SYSTEM)
|
||||
return (0);
|
||||
|
||||
return (i386_use_fxsave);
|
||||
}
|
||||
#endif /* __HAVE_PTRACE_MACHDEP */
|
||||
|
@ -1,10 +1,11 @@
|
||||
/* $NetBSD: procfs_machdep.c,v 1.7 2001/11/15 07:03:31 lukem Exp $ */
|
||||
/* $NetBSD: procfs_machdep.c,v 1.8 2001/12/05 00:58:06 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001 Wasabi Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Written by Frank van der Linden for Wasabi Systems, Inc.
|
||||
* Written by Frank van der Linden and Jason R. Thorpe for
|
||||
* Wasabi Systems, Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -36,14 +37,18 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.7 2001/11/15 07:03:31 lukem Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.8 2001/12/05 00:58:06 thorpej Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/vnode.h>
|
||||
|
||||
#include <miscfs/procfs/procfs.h>
|
||||
|
||||
#include <machine/cpu.h>
|
||||
#include <machine/reg.h>
|
||||
#include <machine/specialreg.h>
|
||||
|
||||
extern int i386_fpu_present, i386_fpu_exception, i386_fpu_fdivbug;
|
||||
@ -152,3 +157,55 @@ procfs_getcpuinfstr(char *buf, int *len)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef __HAVE_PROCFS_MACHDEP
|
||||
void
|
||||
procfs_machdep_allocvp(struct vnode *vp)
|
||||
{
|
||||
struct pfsnode *pfs = vp->v_data;
|
||||
|
||||
switch (pfs->pfs_type) {
|
||||
case Pmachdep_xmmregs: /* /proc/N/xmmregs = -rw------- */
|
||||
pfs->pfs_mode = S_IRUSR|S_IWUSR;
|
||||
vp->v_type = VREG;
|
||||
break;
|
||||
|
||||
default:
|
||||
panic("procfs_machdep_allocvp");
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
procfs_machdep_rw(struct proc *curp, struct proc *p, struct pfsnode *pfs,
|
||||
struct uio *uio)
|
||||
{
|
||||
|
||||
switch (pfs->pfs_type) {
|
||||
case Pmachdep_xmmregs:
|
||||
return (procfs_machdep_doxmmregs(curp, p, pfs, uio));
|
||||
|
||||
default:
|
||||
panic("procfs_machdep_rw");
|
||||
}
|
||||
|
||||
/* NOTREACHED */
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
int
|
||||
procfs_machdep_getattr(struct vnode *vp, struct vattr *vap, struct proc *procp)
|
||||
{
|
||||
struct pfsnode *pfs = VTOPFS(vp);
|
||||
|
||||
switch (pfs->pfs_type) {
|
||||
case Pmachdep_xmmregs:
|
||||
vap->va_bytes = vap->va_size = sizeof(struct xmmregs);
|
||||
break;
|
||||
|
||||
default:
|
||||
panic("procfs_machdep_getattr");
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
|
@ -1,4 +1,39 @@
|
||||
/* $NetBSD: ptrace.h,v 1.6 1995/08/06 05:33:23 mycroft Exp $ */
|
||||
/* $NetBSD: ptrace.h,v 1.7 2001/12/05 00:58:06 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001 Wasabi Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Written by Jason R. Thorpe for Wasabi Systems, Inc.
|
||||
*
|
||||
* 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 for the NetBSD Project by
|
||||
* Wasabi Systems, Inc.
|
||||
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
|
||||
* or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993 Christopher G. Demetriou
|
||||
@ -30,6 +65,9 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _I386_PTRACE_H_
|
||||
#define _I386_PTRACE_H_
|
||||
|
||||
/*
|
||||
* i386-dependent ptrace definitions
|
||||
*/
|
||||
@ -38,3 +76,66 @@
|
||||
#define PT_SETREGS (PT_FIRSTMACH + 2)
|
||||
#define PT_GETFPREGS (PT_FIRSTMACH + 3)
|
||||
#define PT_SETFPREGS (PT_FIRSTMACH + 4)
|
||||
|
||||
/* We have machine-dependent process tracing needs. */
|
||||
#define __HAVE_PTRACE_MACHDEP
|
||||
|
||||
/* We have machine-dependent procfs nodes. */
|
||||
#define __HAVE_PROCFS_MACHDEP
|
||||
|
||||
/* The machine-dependent ptrace(2) requests. */
|
||||
#define PT_GETXMMREGS (PT_FIRSTMACH + 5)
|
||||
#define PT_SETXMMREGS (PT_FIRSTMACH + 6)
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
||||
/*
|
||||
* These are used in sys_ptrace() to find good ptrace(2) requests.
|
||||
*/
|
||||
#define PTRACE_MACHDEP_REQUEST_CASES \
|
||||
case PT_GETXMMREGS: \
|
||||
case PT_SETXMMREGS:
|
||||
|
||||
/*
|
||||
* These are used to define machine-dependent procfs node types.
|
||||
*/
|
||||
#define PROCFS_MACHDEP_NODE_TYPES \
|
||||
Pmachdep_xmmregs, /* extended FP register set */
|
||||
|
||||
/*
|
||||
* These are used in switch statements to catch machine-dependent
|
||||
* procfs node types.
|
||||
*/
|
||||
#define PROCFS_MACHDEP_NODETYPE_CASES \
|
||||
case Pmachdep_xmmregs:
|
||||
|
||||
/*
|
||||
* These are used to protect a privileged process's state.
|
||||
*/
|
||||
#define PROCFS_MACHDEP_PROTECT_CASES \
|
||||
case Pmachdep_xmmregs:
|
||||
|
||||
/*
|
||||
* These are used to define the machine-dependent procfs nodes.
|
||||
*/
|
||||
#define PROCFS_MACHDEP_NODETYPE_DEFNS \
|
||||
{ DT_REG, N("xmmregs"), Pmachdep_xmmregs, \
|
||||
procfs_machdep_validxmmregs },
|
||||
|
||||
struct xmmregs;
|
||||
|
||||
struct mount;
|
||||
struct pfsnode;
|
||||
|
||||
/* Functions used by both ptrace(2) and procfs. */
|
||||
int process_machdep_read_xmmregs(struct proc *, struct xmmregs *);
|
||||
int process_machdep_write_xmmregs(struct proc *, struct xmmregs *);
|
||||
|
||||
int procfs_machdep_validxmmregs(struct proc *, struct mount *);
|
||||
|
||||
int procfs_machdep_doxmmregs(struct proc *, struct proc *,
|
||||
struct pfsnode *, struct uio *);
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#endif /* _I386_PTRACE_H_ */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: reg.h,v 1.16 2001/07/17 08:13:06 fvdl Exp $ */
|
||||
/* $NetBSD: reg.h,v 1.17 2001/12/05 00:58:06 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
@ -103,4 +103,12 @@ struct fpreg {
|
||||
char __data[108];
|
||||
};
|
||||
|
||||
struct xmmregs {
|
||||
/*
|
||||
* XXX
|
||||
* Fill this in with real info.
|
||||
*/
|
||||
char __data[512];
|
||||
};
|
||||
|
||||
#endif /* !_I386_REG_H_ */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: sys_process.c,v 1.70 2001/11/12 15:25:25 lukem Exp $ */
|
||||
/* $NetBSD: sys_process.c,v 1.71 2001/12/05 00:58:05 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1994 Christopher G. Demetriou. All rights reserved.
|
||||
@ -53,7 +53,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: sys_process.c,v 1.70 2001/11/12 15:25:25 lukem Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: sys_process.c,v 1.71 2001/12/05 00:58:05 thorpej Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -181,6 +181,11 @@ sys_ptrace(p, v, retval)
|
||||
#ifdef PT_SETFPREGS
|
||||
case PT_SETFPREGS:
|
||||
#endif
|
||||
|
||||
#ifdef __HAVE_PTRACE_MACHDEP
|
||||
PTRACE_MACHDEP_REQUEST_CASES
|
||||
#endif
|
||||
|
||||
/*
|
||||
* You can't do what you want to the process if:
|
||||
* (1) It's not being traced at all,
|
||||
@ -394,6 +399,13 @@ sys_ptrace(p, v, retval)
|
||||
return (procfs_dofpregs(p, t, NULL, &uio));
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __HAVE_PTRACE_MACHDEP
|
||||
PTRACE_MACHDEP_REQUEST_CASES
|
||||
return (ptrace_machdep_dorequest(p, t,
|
||||
SCARG(uap, req), SCARG(uap, addr),
|
||||
SCARG(uap, data)));
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: procfs.h,v 1.35 2001/09/15 16:12:59 chs Exp $ */
|
||||
/* $NetBSD: procfs.h,v 1.36 2001/12/05 00:58:05 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993 Jan-Simon Pendry
|
||||
@ -39,6 +39,9 @@
|
||||
* @(#)procfs.h 8.9 (Berkeley) 5/14/95
|
||||
*/
|
||||
|
||||
/* This also pulls in __HAVE_PROCFS_MACHDEP */
|
||||
#include <sys/ptrace.h>
|
||||
|
||||
/*
|
||||
* The different types of node in a procfs filesystem
|
||||
*/
|
||||
@ -60,6 +63,9 @@ typedef enum {
|
||||
Pmeminfo, /* system memory info (if -o linux) */
|
||||
Pcpuinfo, /* CPU info (if -o linux) */
|
||||
Pmaps, /* memory map, Linux style (if -o linux) */
|
||||
#ifdef __HAVE_PROCFS_MACHDEP
|
||||
PROCFS_MACHDEP_NODE_TYPES
|
||||
#endif
|
||||
} pfstype;
|
||||
|
||||
/*
|
||||
@ -172,4 +178,13 @@ extern struct vfsops procfs_vfsops;
|
||||
|
||||
int procfs_root __P((struct mount *, struct vnode **));
|
||||
|
||||
#ifdef __HAVE_PROCFS_MACHDEP
|
||||
struct vattr;
|
||||
|
||||
void procfs_machdep_allocvp(struct vnode *);
|
||||
int procfs_machdep_rw(struct proc *, struct proc *, struct pfsnode *,
|
||||
struct uio *);
|
||||
int procfs_machdep_getattr(struct vnode *, struct vattr *, struct proc *);
|
||||
#endif
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: procfs_ctl.c,v 1.20 2001/11/10 13:33:43 lukem Exp $ */
|
||||
/* $NetBSD: procfs_ctl.c,v 1.21 2001/12/05 00:58:05 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993 Jan-Simon Pendry
|
||||
@ -40,7 +40,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: procfs_ctl.c,v 1.20 2001/11/10 13:33:43 lukem Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: procfs_ctl.c,v 1.21 2001/12/05 00:58:05 thorpej Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -53,7 +53,6 @@ __KERNEL_RCSID(0, "$NetBSD: procfs_ctl.c,v 1.20 2001/11/10 13:33:43 lukem Exp $"
|
||||
#include <sys/resource.h>
|
||||
#include <sys/resourcevar.h>
|
||||
#include <sys/signalvar.h>
|
||||
#include <sys/ptrace.h>
|
||||
#include <miscfs/procfs/procfs.h>
|
||||
|
||||
#define PROCFS_CTL_ATTACH 1
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: procfs_fpregs.c,v 1.8 2001/11/10 13:33:43 lukem Exp $ */
|
||||
/* $NetBSD: procfs_fpregs.c,v 1.9 2001/12/05 00:58:05 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993 Jan-Simon Pendry
|
||||
@ -40,7 +40,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: procfs_fpregs.c,v 1.8 2001/11/10 13:33:43 lukem Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: procfs_fpregs.c,v 1.9 2001/12/05 00:58:05 thorpej Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -48,7 +48,6 @@ __KERNEL_RCSID(0, "$NetBSD: procfs_fpregs.c,v 1.8 2001/11/10 13:33:43 lukem Exp
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/vnode.h>
|
||||
#include <sys/ptrace.h>
|
||||
#include <machine/reg.h>
|
||||
#include <miscfs/procfs/procfs.h>
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: procfs_regs.c,v 1.13 2001/11/10 13:33:44 lukem Exp $ */
|
||||
/* $NetBSD: procfs_regs.c,v 1.14 2001/12/05 00:58:05 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993 Jan-Simon Pendry
|
||||
@ -40,7 +40,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: procfs_regs.c,v 1.13 2001/11/10 13:33:44 lukem Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: procfs_regs.c,v 1.14 2001/12/05 00:58:05 thorpej Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -48,7 +48,6 @@ __KERNEL_RCSID(0, "$NetBSD: procfs_regs.c,v 1.13 2001/11/10 13:33:44 lukem Exp $
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/vnode.h>
|
||||
#include <sys/ptrace.h>
|
||||
#include <machine/reg.h>
|
||||
#include <miscfs/procfs/procfs.h>
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: procfs_subr.c,v 1.39 2001/11/10 13:33:44 lukem Exp $ */
|
||||
/* $NetBSD: procfs_subr.c,v 1.40 2001/12/05 00:58:05 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Christopher G. Demetriou. All rights reserved.
|
||||
@ -41,7 +41,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: procfs_subr.c,v 1.39 2001/11/10 13:33:44 lukem Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: procfs_subr.c,v 1.40 2001/12/05 00:58:05 thorpej Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -168,6 +168,12 @@ procfs_allocvp(mp, vpp, pid, pfs_type)
|
||||
vp->v_type = VREG;
|
||||
break;
|
||||
|
||||
#ifdef __HAVE_PROCFS_MACHDEP
|
||||
PROCFS_MACHDEP_NODETYPE_CASES
|
||||
procfs_machdep_allocvp(vp);
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
panic("procfs_allocvp");
|
||||
}
|
||||
@ -211,6 +217,9 @@ procfs_rw(v)
|
||||
case Pregs:
|
||||
case Pfpregs:
|
||||
case Pmem:
|
||||
#if defined(__HAVE_PROCFS_MACHDEP) && defined(PROCFS_MACHDEP_PROTECT_CASES)
|
||||
PROCFS_MACHDEP_PROTECT_CASES
|
||||
#endif
|
||||
/*
|
||||
* Do not allow init to be modified while in secure mode; it
|
||||
* could be duped into changing the security level.
|
||||
@ -255,9 +264,15 @@ procfs_rw(v)
|
||||
|
||||
case Pmeminfo:
|
||||
return (procfs_domeminfo(curp, p, pfs, uio));
|
||||
|
||||
case Pcpuinfo:
|
||||
return (procfs_docpuinfo(curp, p, pfs, uio));
|
||||
|
||||
#ifdef __HAVE_PROCFS_MACHDEP
|
||||
PROCFS_MACHDEP_NODETYPE_CASES
|
||||
return (procfs_machdep_rw(curp, p, pfs, uio));
|
||||
#endif
|
||||
|
||||
default:
|
||||
return (EOPNOTSUPP);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: procfs_vnops.c,v 1.85 2001/11/10 13:33:44 lukem Exp $ */
|
||||
/* $NetBSD: procfs_vnops.c,v 1.86 2001/12/05 00:58:06 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993 Jan-Simon Pendry
|
||||
@ -44,7 +44,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: procfs_vnops.c,v 1.85 2001/11/10 13:33:44 lukem Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: procfs_vnops.c,v 1.86 2001/12/05 00:58:06 thorpej Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -58,7 +58,6 @@ __KERNEL_RCSID(0, "$NetBSD: procfs_vnops.c,v 1.85 2001/11/10 13:33:44 lukem Exp
|
||||
#include <sys/mount.h>
|
||||
#include <sys/dirent.h>
|
||||
#include <sys/resourcevar.h>
|
||||
#include <sys/ptrace.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <uvm/uvm_extern.h> /* for PAGE_SIZE */
|
||||
@ -103,6 +102,9 @@ const struct proc_target {
|
||||
{ DT_REG, N("maps"), Pmaps, procfs_validmap },
|
||||
{ DT_REG, N("cmdline"), Pcmdline, NULL },
|
||||
{ DT_REG, N("exe"), Pfile, procfs_validfile_linux },
|
||||
#ifdef __HAVE_PROCFS_MACHDEP
|
||||
PROCFS_MACHDEP_NODETYPE_DEFNS
|
||||
#endif
|
||||
#undef N
|
||||
};
|
||||
static int nproc_targets = sizeof(proc_targets) / sizeof(proc_targets[0]);
|
||||
@ -509,6 +511,9 @@ procfs_getattr(v)
|
||||
case Pmem:
|
||||
case Pregs:
|
||||
case Pfpregs:
|
||||
#if defined(__HAVE_PROCFS_MACHDEP) && defined(PROCFS_MACHDEP_PROTECT_CASES)
|
||||
PROCFS_MACHDEP_PROTECT_CASES
|
||||
#endif
|
||||
/*
|
||||
* If the process has exercised some setuid or setgid
|
||||
* privilege, then rip away read/write permission so
|
||||
@ -625,6 +630,12 @@ procfs_getattr(v)
|
||||
vap->va_bytes = vap->va_size = 0;
|
||||
break;
|
||||
|
||||
#ifdef __HAVE_PROCFS_MACHDEP
|
||||
PROCFS_MACHDEP_NODETYPE_CASES
|
||||
error = procfs_machdep_getattr(ap->a_vp, vap, procp);
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
panic("procfs_getattr");
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ptrace.h,v 1.22 2001/06/13 16:06:27 nathanw Exp $ */
|
||||
/* $NetBSD: ptrace.h,v 1.23 2001/12/05 00:58:06 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1984, 1993
|
||||
@ -76,6 +76,11 @@ int process_write_fpregs __P((struct proc *p, struct fpreg *regs));
|
||||
int process_write_regs __P((struct proc *p, struct reg *regs));
|
||||
#endif
|
||||
|
||||
#ifdef __HAVE_PROCFS_MACHDEP
|
||||
int ptrace_machdep_dorequest(struct proc *, struct proc *, int,
|
||||
caddr_t, int);
|
||||
#endif
|
||||
|
||||
#ifndef FIX_SSTEP
|
||||
#define FIX_SSTEP(p)
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user