PERFORCE change 77438 for review
Peter Wemm
peter at FreeBSD.org
Wed May 25 03:13:37 GMT 2005
http://perforce.freebsd.org/chv.cgi?CH=77438
Change 77438 by peter at peter_melody on 2005/05/25 03:12:50
Inflict more evil
Affected files ...
.. //depot/projects/hammer/sys/fs/procfs/procfs_dbregs.c#6 edit
.. //depot/projects/hammer/sys/fs/procfs/procfs_fpregs.c#6 edit
.. //depot/projects/hammer/sys/fs/procfs/procfs_ioctl.c#7 edit
.. //depot/projects/hammer/sys/fs/procfs/procfs_map.c#8 edit
.. //depot/projects/hammer/sys/fs/procfs/procfs_regs.c#6 edit
Differences ...
==== //depot/projects/hammer/sys/fs/procfs/procfs_dbregs.c#6 (text+ko) ====
@@ -43,6 +43,8 @@
* $FreeBSD: src/sys/fs/procfs/procfs_dbregs.c,v 1.25 2004/10/01 05:01:17 das Exp $
*/
+#include "opt_compat.h"
+
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/lock.h>
@@ -56,11 +58,29 @@
#include <fs/pseudofs/pseudofs.h>
#include <fs/procfs/procfs.h>
+#ifdef COMPAT_IA32
+#include <sys/procfs.h>
+#include <machine/fpu.h>
+#include <compat/ia32/ia32_reg.h>
+
+extern struct sysentvec ia32_freebsd_sysvec;
+#define PROC(d, w, t, r) wrap32 ? proc_ ## d ## _ ## w ## 32(t, r ## 32) : proc_ ## d ## _ ## w(t, r)
+#define UIOMOVE_FROMBUF(k, u) wrap32 ? uiomove_frombuf(& k ## 32, sizeof(k ## 32), u) : uiomove_frombuf(& k, sizeof(k), u)
+#else
+#define PROC(d, w, t, r) proc_ ## d ## _ ## w(t, r)
+#define UIOMOVE_FROMBUF(k, u) uiomove_frombuf(& k, sizeof(k), u)
+#endif
+
int
procfs_doprocdbregs(PFS_FILL_ARGS)
{
int error;
struct dbreg r;
+ struct thread *td2;
+#ifdef COMPAT_IA32
+ struct dbreg32 r32;
+ int wrap32 = 0;
+#endif
PROC_LOCK(p);
KASSERT(p->p_lock > 0, ("proc not held"));
@@ -70,10 +90,20 @@
}
/* XXXKSE: */
- error = proc_read_dbregs(FIRST_THREAD_IN_PROC(p), &r);
+ td2 = FIRST_THREAD_IN_PROC(p);
+#ifdef COMPAT_IA32
+ if (td->td_proc->p_sysent == &ia32_freebsd_sysvec) {
+ if (td2->td_proc->p_sysent != &ia32_freebsd_sysvec) {
+ PROC_UNLOCK(p);
+ return (EINVAL);
+ }
+ wrap32 = 1;
+ }
+#endif
+ error = PROC(read, dbregs, td2, &r);
if (error == 0) {
PROC_UNLOCK(p);
- error = uiomove_frombuf(&r, sizeof(r), uio);
+ error = UIOMOVE_FROMBUF(r, uio);
PROC_LOCK(p);
}
if (error == 0 && uio->uio_rw == UIO_WRITE) {
@@ -81,7 +111,7 @@
error = EBUSY;
else
/* XXXKSE: */
- error = proc_write_dbregs(FIRST_THREAD_IN_PROC(p), &r);
+ error = PROC(write, dbregs, td2, &r);
}
PROC_UNLOCK(p);
==== //depot/projects/hammer/sys/fs/procfs/procfs_fpregs.c#6 (text+ko) ====
@@ -37,6 +37,8 @@
* $FreeBSD: src/sys/fs/procfs/procfs_fpregs.c,v 1.31 2004/10/01 05:01:17 das Exp $
*/
+#include "opt_compat.h"
+
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/lock.h>
@@ -50,11 +52,29 @@
#include <fs/pseudofs/pseudofs.h>
#include <fs/procfs/procfs.h>
+#ifdef COMPAT_IA32
+#include <sys/procfs.h>
+#include <machine/fpu.h>
+#include <compat/ia32/ia32_reg.h>
+
+extern struct sysentvec ia32_freebsd_sysvec;
+#define PROC(d, w, t, r) wrap32 ? proc_ ## d ## _ ## w ## 32(t, r ## 32) : proc_ ## d ## _ ## w(t, r)
+#define UIOMOVE_FROMBUF(k, u) wrap32 ? uiomove_frombuf(& k ## 32, sizeof(k ## 32), u) : uiomove_frombuf(& k, sizeof(k), u)
+#else
+#define PROC(d, w, t, r) proc_ ## d ## _ ## w(t, r)
+#define UIOMOVE_FROMBUF(k, u) uiomove_frombuf(& k, sizeof(k), u)
+#endif
+
int
procfs_doprocfpregs(PFS_FILL_ARGS)
{
int error;
struct fpreg r;
+ struct thread *td2;
+#ifdef COMPAT_IA32
+ struct fpreg32 r32;
+ int wrap32 = 0;
+#endif
PROC_LOCK(p);
KASSERT(p->p_lock > 0, ("proc not held"));
@@ -64,10 +84,20 @@
}
/* XXXKSE: */
- error = proc_read_fpregs(FIRST_THREAD_IN_PROC(p), &r);
+ td2 = FIRST_THREAD_IN_PROC(p);
+#ifdef COMPAT_IA32
+ if (td->td_proc->p_sysent == &ia32_freebsd_sysvec) {
+ if (td2->td_proc->p_sysent != &ia32_freebsd_sysvec) {
+ PROC_UNLOCK(p);
+ return (EINVAL);
+ }
+ wrap32 = 1;
+ }
+#endif
+ error = PROC(read, fpregs, td2, &r);
if (error == 0) {
PROC_UNLOCK(p);
- error = uiomove_frombuf(&r, sizeof(r), uio);
+ error = UIOMOVE_FROMBUF(r, uio);
PROC_LOCK(p);
}
if (error == 0 && uio->uio_rw == UIO_WRITE) {
@@ -75,7 +105,7 @@
error = EBUSY;
else
/* XXXKSE: */
- error = proc_write_fpregs(FIRST_THREAD_IN_PROC(p), &r);
+ error = PROC(write, fpregs, td2, &r);
}
PROC_UNLOCK(p);
==== //depot/projects/hammer/sys/fs/procfs/procfs_ioctl.c#7 (text+ko) ====
@@ -42,6 +42,19 @@
#include <fs/pseudofs/pseudofs.h>
#include <fs/procfs/procfs.h>
+#ifdef COMPAT_IA32
+struct procfs_status32 {
+ int state; /* Running, stopped, something else? */
+ int flags; /* Any flags */
+ unsigned int events; /* Events to stop on */
+ int why; /* What event, if any, proc stopped on */
+ unsigned int val; /* Any extra data */
+};
+
+#define PIOCWAIT32 _IOR('p', 4, struct procfs_status32)
+#define PIOCSTATUS32 _IOR('p', 6, struct procfs_status32)
+#endif
+
/*
* Process ioctls
*/
@@ -49,6 +62,9 @@
procfs_ioctl(PFS_IOCTL_ARGS)
{
struct procfs_status *ps;
+#ifdef COMPAT_IA32
+ struct procfs_status32 *ps32;
+#endif
int error, flags, sig;
int l;
@@ -100,6 +116,25 @@
ps->why = p->p_step ? p->p_stype : 0;
ps->val = p->p_step ? p->p_xstat : 0;
break;
+#ifdef COMPAT_IA32
+ case PIOCWAIT32:
+ while (p->p_step == 0) {
+ /* sleep until p stops */
+ error = msleep(&p->p_stype, &p->p_mtx,
+ PWAIT|PCATCH, "pioctl", 0);
+ if (error != 0)
+ break;
+ }
+ /* fall through to PIOCSTATUS32 */
+ case PIOCSTATUS32:
+ ps32 = (struct procfs_status32 *)data;
+ ps32->state = (p->p_step == 0);
+ ps32->flags = 0; /* nope */
+ ps32->events = p->p_stops;
+ ps32->why = p->p_step ? p->p_stype : 0;
+ ps32->val = p->p_step ? p->p_xstat : 0;
+ break;
+#endif
#if defined(COMPAT_FREEBSD5) || defined(COMPAT_FREEBSD4)
case _IOC(IOC_IN, 'p', 5, 0):
#endif
==== //depot/projects/hammer/sys/fs/procfs/procfs_map.c#8 (text+ko) ====
@@ -35,6 +35,8 @@
* $FreeBSD: src/sys/fs/procfs/procfs_map.c,v 1.37 2005/01/06 18:10:40 imp Exp $
*/
+#include "opt_compat.h"
+
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/lock.h>
@@ -54,7 +56,15 @@
#include <vm/vm_page.h>
#include <vm/vm_object.h>
+#ifdef COMPAT_IA32
+#include <sys/procfs.h>
+#include <machine/fpu.h>
+#include <compat/ia32/ia32_reg.h>
+
+extern struct sysentvec ia32_freebsd_sysvec;
+#endif
+
#define MEBUFFERSIZE 256
/*
@@ -77,6 +87,9 @@
vm_map_entry_t entry;
char mebuffer[MEBUFFERSIZE];
char *fullpath, *freepath;
+#ifdef COMPAT_IA32
+ int wrap32 = 0;
+#endif
GIANT_REQUIRED;
@@ -92,6 +105,13 @@
if (uio->uio_offset != 0)
return (0);
+#ifdef COMPAT_IA32
+ if (curthread->td_proc->p_sysent == &ia32_freebsd_sysvec) {
+ if (p->p_sysent != &ia32_freebsd_sysvec)
+ return (EOPNOTSUPP);
+ wrap32 = 1;
+ }
+#endif
error = 0;
if (map != &curthread->td_proc->p_vmspace->vm_map)
vm_map_lock_read(map);
@@ -164,7 +184,12 @@
snprintf(mebuffer, sizeof mebuffer,
"0x%lx 0x%lx %d %d %p %s%s%s %d %d 0x%x %s %s %s %s\n",
(u_long)entry->start, (u_long)entry->end,
- resident, privateresident, obj,
+ resident, privateresident,
+#ifdef COMPAT_IA32
+ wrap32 ? NULL : obj,
+#else
+ obj,
+#endif
(entry->protection & VM_PROT_READ)?"r":"-",
(entry->protection & VM_PROT_WRITE)?"w":"-",
(entry->protection & VM_PROT_EXECUTE)?"x":"-",
==== //depot/projects/hammer/sys/fs/procfs/procfs_regs.c#6 (text+ko) ====
@@ -37,6 +37,8 @@
* $FreeBSD: src/sys/fs/procfs/procfs_regs.c,v 1.30 2004/10/01 05:01:17 das Exp $
*/
+#include "opt_compat.h"
+
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/lock.h>
@@ -50,11 +52,29 @@
#include <fs/pseudofs/pseudofs.h>
#include <fs/procfs/procfs.h>
+#ifdef COMPAT_IA32
+#include <sys/procfs.h>
+#include <machine/fpu.h>
+#include <compat/ia32/ia32_reg.h>
+
+extern struct sysentvec ia32_freebsd_sysvec;
+#define PROC(d, w, t, r) wrap32 ? proc_ ## d ## _ ## w ## 32(t, r ## 32) : proc_ ## d ## _ ## w(t, r)
+#define UIOMOVE_FROMBUF(k, u) wrap32 ? uiomove_frombuf(& k ## 32, sizeof(k ## 32), u) : uiomove_frombuf(& k, sizeof(k), u)
+#else
+#define PROC(d, w, t, r) proc_ ## d ## _ ## w(t, r)
+#define UIOMOVE_FROMBUF(k, u) uiomove_frombuf(& k, sizeof(k), u)
+#endif
+
int
procfs_doprocregs(PFS_FILL_ARGS)
{
int error;
struct reg r;
+ struct thread *td2;
+#ifdef COMPAT_IA32
+ struct reg32 r32;
+ int wrap32 = 0;
+#endif
PROC_LOCK(p);
KASSERT(p->p_lock > 0, ("proc not held"));
@@ -64,10 +84,20 @@
}
/* XXXKSE: */
- error = proc_read_regs(FIRST_THREAD_IN_PROC(p), &r);
+ td2 = FIRST_THREAD_IN_PROC(p);
+#ifdef COMPAT_IA32
+ if (td->td_proc->p_sysent == &ia32_freebsd_sysvec) {
+ if (td2->td_proc->p_sysent != &ia32_freebsd_sysvec) {
+ PROC_UNLOCK(p);
+ return (EINVAL);
+ }
+ wrap32 = 1;
+ }
+#endif
+ error = PROC(read, regs, td2, &r);
if (error == 0) {
PROC_UNLOCK(p);
- error = uiomove_frombuf(&r, sizeof(r), uio);
+ error = UIOMOVE_FROMBUF(r, uio);
PROC_LOCK(p);
}
if (error == 0 && uio->uio_rw == UIO_WRITE) {
@@ -75,7 +105,7 @@
error = EBUSY;
else
/* XXXKSE: */
- error = proc_write_regs(FIRST_THREAD_IN_PROC(p), &r);
+ error = PROC(write, regs, td2, &r);
}
PROC_UNLOCK(p);
More information about the p4-projects
mailing list