summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2005-11-04 21:48:08 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2005-11-04 21:48:08 +0000
commit3d8e26477d53466e9c6005eb82f67134364b9d3a (patch)
tree18755a263f25352a3bde8dfd07f44d234c312a78 /sys
parentdf3527a220a7b4406fb3685a06b8b52e7921b3f6 (diff)
Add an extra flags argument to uvm_io(), to specify whether we want to fix
the protection of the memory mapping we're doing I/O on, or if we want to leave them as they are. This should only be necessary for breakpoint insertion in code, so we'll only use it for ptrace requests. Initially from art@ after discussion with kettenis@ millert@ and I, tested by many.
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_sysctl.c8
-rw-r--r--sys/miscfs/procfs/procfs_cmdline.c8
-rw-r--r--sys/miscfs/procfs/procfs_mem.c5
-rw-r--r--sys/uvm/uvm_extern.h6
-rw-r--r--sys/uvm/uvm_io.c15
5 files changed, 23 insertions, 19 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c
index bf03966144c..7513ea171f3 100644
--- a/sys/kern/kern_sysctl.c
+++ b/sys/kern/kern_sysctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_sysctl.c,v 1.131 2005/09/25 20:48:23 miod Exp $ */
+/* $OpenBSD: kern_sysctl.c,v 1.132 2005/11/04 21:47:57 miod Exp $ */
/* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */
/*-
@@ -1468,7 +1468,7 @@ sysctl_proc_args(int *name, u_int namelen, void *oldp, size_t *oldlenp,
uio.uio_rw = UIO_READ;
uio.uio_procp = cp;
- if ((error = uvm_io(&vp->p_vmspace->vm_map, &uio)) != 0)
+ if ((error = uvm_io(&vp->p_vmspace->vm_map, &uio, 0)) != 0)
goto out;
if (op == KERN_PROC_NARGV) {
@@ -1525,7 +1525,7 @@ sysctl_proc_args(int *name, u_int namelen, void *oldp, size_t *oldlenp,
uio.uio_segflg = UIO_SYSSPACE;
uio.uio_rw = UIO_READ;
uio.uio_procp = cp;
- if ((error = uvm_io(&vp->p_vmspace->vm_map, &uio)) != 0)
+ if ((error = uvm_io(&vp->p_vmspace->vm_map, &uio, 0)) != 0)
goto out;
if (varg == NULL)
@@ -1547,7 +1547,7 @@ more:
uio.uio_segflg = UIO_SYSSPACE;
uio.uio_rw = UIO_READ;
uio.uio_procp = cp;
- if ((error = uvm_io(&vp->p_vmspace->vm_map, &uio)) != 0)
+ if ((error = uvm_io(&vp->p_vmspace->vm_map, &uio, 0)) != 0)
goto out;
for (vstrlen = 0; vstrlen < len; vstrlen++) {
diff --git a/sys/miscfs/procfs/procfs_cmdline.c b/sys/miscfs/procfs/procfs_cmdline.c
index c23a733045e..191130d5e1f 100644
--- a/sys/miscfs/procfs/procfs_cmdline.c
+++ b/sys/miscfs/procfs/procfs_cmdline.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: procfs_cmdline.c,v 1.4 2004/05/05 23:52:09 tedu Exp $ */
+/* $OpenBSD: procfs_cmdline.c,v 1.5 2005/11/04 21:48:07 miod Exp $ */
/* $NetBSD: procfs_cmdline.c,v 1.3 1999/03/13 22:26:48 thorpej Exp $ */
/*
@@ -121,7 +121,7 @@ procfs_docmdline(curp, p, pfs, uio)
auio.uio_segflg = UIO_SYSSPACE;
auio.uio_rw = UIO_READ;
auio.uio_procp = NULL;
- error = uvm_io(&p->p_vmspace->vm_map, &auio);
+ error = uvm_io(&p->p_vmspace->vm_map, &auio, 0);
if (error)
goto bad;
@@ -137,7 +137,7 @@ procfs_docmdline(curp, p, pfs, uio)
auio.uio_segflg = UIO_SYSSPACE;
auio.uio_rw = UIO_READ;
auio.uio_procp = NULL;
- error = uvm_io(&p->p_vmspace->vm_map, &auio);
+ error = uvm_io(&p->p_vmspace->vm_map, &auio, 0);
if (error)
goto bad;
@@ -160,7 +160,7 @@ procfs_docmdline(curp, p, pfs, uio)
auio.uio_segflg = UIO_SYSSPACE;
auio.uio_rw = UIO_READ;
auio.uio_procp = NULL;
- error = uvm_io(&p->p_vmspace->vm_map, &auio);
+ error = uvm_io(&p->p_vmspace->vm_map, &auio, 0);
if (error)
goto bad;
diff --git a/sys/miscfs/procfs/procfs_mem.c b/sys/miscfs/procfs/procfs_mem.c
index 95d617083ea..56b73a22c04 100644
--- a/sys/miscfs/procfs/procfs_mem.c
+++ b/sys/miscfs/procfs/procfs_mem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: procfs_mem.c,v 1.22 2004/05/20 09:20:41 kettenis Exp $ */
+/* $OpenBSD: procfs_mem.c,v 1.23 2005/11/04 21:48:07 miod Exp $ */
/* $NetBSD: procfs_mem.c,v 1.8 1996/02/09 22:40:50 christos Exp $ */
/*
@@ -81,7 +81,8 @@ procfs_domem(curp, p, pfs, uio)
return(EFAULT);
addr = uio->uio_offset;
p->p_vmspace->vm_refcnt++; /* XXX */
- error = uvm_io(&p->p_vmspace->vm_map, uio);
+ error = uvm_io(&p->p_vmspace->vm_map, uio,
+ uio->uio_rw == UIO_WRITE ? UVM_IO_FIXPROT : 0);
uvmspace_free(p->p_vmspace);
if (error == 0 && uio->uio_rw == UIO_WRITE)
diff --git a/sys/uvm/uvm_extern.h b/sys/uvm/uvm_extern.h
index f9f52056fee..b45f6380974 100644
--- a/sys/uvm/uvm_extern.h
+++ b/sys/uvm/uvm_extern.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_extern.h,v 1.58 2005/09/28 00:24:03 pedro Exp $ */
+/* $OpenBSD: uvm_extern.h,v 1.59 2005/11/04 21:48:07 miod Exp $ */
/* $NetBSD: uvm_extern.h,v 1.57 2001/03/09 01:02:12 chs Exp $ */
/*
@@ -491,7 +491,9 @@ void uvm_init(void);
/* init the uvm system */
/* uvm_io.c */
-int uvm_io(vm_map_t, struct uio *);
+int uvm_io(vm_map_t, struct uio *, int);
+
+#define UVM_IO_FIXPROT 0x01
/* uvm_km.c */
vaddr_t uvm_km_alloc1(vm_map_t, vsize_t, boolean_t);
diff --git a/sys/uvm/uvm_io.c b/sys/uvm/uvm_io.c
index 25702be8d4b..f9fb928f4bb 100644
--- a/sys/uvm/uvm_io.c
+++ b/sys/uvm/uvm_io.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_io.c,v 1.15 2005/05/24 21:11:47 tedu Exp $ */
+/* $OpenBSD: uvm_io.c,v 1.16 2005/11/04 21:48:07 miod Exp $ */
/* $NetBSD: uvm_io.c,v 1.12 2000/06/27 17:29:23 mrg Exp $ */
/*
@@ -60,14 +60,12 @@
*/
int
-uvm_io(map, uio)
- vm_map_t map;
- struct uio *uio;
+uvm_io(vm_map_t map, struct uio *uio, int flags)
{
vaddr_t baseva, endva, pageoffset, kva;
vsize_t chunksz, togo, sz;
vm_map_entry_t dead_entries;
- int error;
+ int error, extractflags;
/*
* step 0: sanity checks and set up for copy loop. start with a
@@ -95,6 +93,10 @@ uvm_io(map, uio)
chunksz = min(round_page(togo + pageoffset), MAXBSIZE);
error = 0;
+ extractflags = UVM_EXTRACT_QREF | UVM_EXTRACT_CONTIG;
+ if (flags & UVM_IO_FIXPROT)
+ extractflags |= UVM_EXTRACT_FIXPROT;
+
/*
* step 1: main loop... while we've got data to move
*/
@@ -106,8 +108,7 @@ uvm_io(map, uio)
*/
error = uvm_map_extract(map, baseva, chunksz, kernel_map, &kva,
- UVM_EXTRACT_QREF | UVM_EXTRACT_CONTIG |
- UVM_EXTRACT_FIXPROT);
+ extractflags);
if (error) {
/* retry with a smaller chunk... */