Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Make uvm_vslock() return the error code from uvm_fault_w...
details: https://anonhg.NetBSD.org/src/rev/a43379caae31
branches: trunk
changeset: 473735:a43379caae31
user: thorpej <thorpej%NetBSD.org@localhost>
date: Thu Jun 17 15:47:22 1999 +0000
description:
Make uvm_vslock() return the error code from uvm_fault_wire(). All places
which use uvm_vslock() should now test the return value. If it's not
KERN_SUCCESS, wiring the pages failed, so the operation which is using
uvm_vslock() should error out.
XXX We currently just EFAULT a failed uvm_vslock(). We may want to do
more about translating error codes in the future.
diffstat:
sys/compat/netbsd32/netbsd32_netbsd.c | 14 ++++++++++++--
sys/dev/ic/rrunner.c | 27 +++++++++++++++++++++++----
sys/kern/kern_physio.c | 12 +++++++++---
sys/kern/kern_sysctl.c | 12 ++++++++++--
sys/uvm/uvm_extern.h | 4 ++--
sys/uvm/uvm_glue.c | 16 ++++++++++++----
6 files changed, 68 insertions(+), 17 deletions(-)
diffs (190 lines):
diff -r 4bc6e3042970 -r a43379caae31 sys/compat/netbsd32/netbsd32_netbsd.c
--- a/sys/compat/netbsd32/netbsd32_netbsd.c Thu Jun 17 07:59:16 1999 +0000
+++ b/sys/compat/netbsd32/netbsd32_netbsd.c Thu Jun 17 15:47:22 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_netbsd.c,v 1.14 1999/06/09 04:50:10 christos Exp $ */
+/* $NetBSD: netbsd32_netbsd.c,v 1.15 1999/06/17 15:47:23 thorpej Exp $ */
/*
* Copyright (c) 1998 Matthew R. Green
@@ -3786,7 +3786,17 @@
* XXX Um, this is kind of evil. What should
* XXX we be passing here?
*/
- uvm_vslock(p, SCARG(uap, old), savelen, VM_PROT_NONE);
+ if (uvm_vslock(p, SCARG(uap, old), savelen,
+ VM_PROT_NONE) != KERN_SUCCESS) {
+#if 0 /* XXXXXXXX */
+ memlock.sl_lock = 0;
+ if (memlock.sl_want) {
+ memlock.sl_want = 0;
+ wakeup((caddr_t)&memlock);
+ }
+#endif /* XXXXXXXX */
+ return (EFAULT);
+ }
}
oldlen = savelen;
}
diff -r 4bc6e3042970 -r a43379caae31 sys/dev/ic/rrunner.c
--- a/sys/dev/ic/rrunner.c Thu Jun 17 07:59:16 1999 +0000
+++ b/sys/dev/ic/rrunner.c Thu Jun 17 15:47:22 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rrunner.c,v 1.11 1999/05/26 01:09:02 thorpej Exp $ */
+/* $NetBSD: rrunner.c,v 1.12 1999/06/17 15:47:24 thorpej Exp $ */
/*
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -1062,8 +1062,17 @@
for (i = 0; i < uio->uio_iovcnt; i++) {
iovp = &uio->uio_iov[i];
- uvm_vslock(p, iovp->iov_base, iovp->iov_len,
- VM_PROT_READ | VM_PROT_WRITE);
+ if (uvm_vslock(p, iovp->iov_base, iovp->iov_len,
+ VM_PROT_READ | VM_PROT_WRITE) != KERN_SUCCESS) {
+ /* Unlock what we've locked so far. */
+ for (--i; i >= 0; i--) {
+ iovp = &uio->uio_iov[i];
+ uvm_vsunlock(p, ivop->iov_base,
+ iovp->iov_len);
+ }
+ error = EFAULT;
+ goto fpread_done;
+ }
}
/*
@@ -1226,7 +1235,17 @@
for (i = 0; i < uio->uio_iovcnt; i++) {
iovp = &uio->uio_iov[i];
- uvm_vslock(p, iovp->iov_base, iovp->iov_len, VM_PROT_READ);
+ if (uvm_vslock(p, iovp->iov_base, iovp->iov_len,
+ VM_PROT_READ) != KERN_SUCCESS) {
+ /* Unlock what we've locked so far. */
+ for (--i; i >= 0; i--) {
+ iovp = &uio->uio_iov[i];
+ uvm_vsunlock(p, ivop->iov_base,
+ iovp->iov_len);
+ }
+ error = EFAULT;
+ goto fpwrite_done;
+ }
}
/*
diff -r 4bc6e3042970 -r a43379caae31 sys/kern/kern_physio.c
--- a/sys/kern/kern_physio.c Thu Jun 17 07:59:16 1999 +0000
+++ b/sys/kern/kern_physio.c Thu Jun 17 15:47:22 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_physio.c,v 1.36 1999/05/26 01:08:03 thorpej Exp $ */
+/* $NetBSD: kern_physio.c,v 1.37 1999/06/17 15:47:23 thorpej Exp $ */
/*-
* Copyright (c) 1994 Christopher G. Demetriou
@@ -180,8 +180,13 @@
* restores it.
*/
PHOLD(p);
- uvm_vslock(p, bp->b_data, todo, (flags & B_READ) ?
- VM_PROT_READ | VM_PROT_WRITE : VM_PROT_READ);
+ if (uvm_vslock(p, bp->b_data, todo, (flags & B_READ) ?
+ VM_PROT_READ | VM_PROT_WRITE : VM_PROT_READ)
+ != KERN_SUCCESS) {
+ bp->b_flags |= B_ERROR;
+ bp->b_error = EFAULT;
+ goto after_vsunlock;
+ }
vmapbuf(bp, todo);
/* [call strategy to start the transfer] */
@@ -213,6 +218,7 @@
*/
vunmapbuf(bp, todo);
uvm_vsunlock(p, bp->b_data, todo);
+ after_vsunlock:
PRELE(p);
/* remember error value (save a splbio/splx pair) */
diff -r 4bc6e3042970 -r a43379caae31 sys/kern/kern_sysctl.c
--- a/sys/kern/kern_sysctl.c Thu Jun 17 07:59:16 1999 +0000
+++ b/sys/kern/kern_sysctl.c Thu Jun 17 15:47:22 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_sysctl.c,v 1.45 1999/05/26 01:07:06 thorpej Exp $ */
+/* $NetBSD: kern_sysctl.c,v 1.46 1999/06/17 15:47:23 thorpej Exp $ */
/*-
* Copyright (c) 1982, 1986, 1989, 1993
@@ -167,7 +167,15 @@
* XXX Um, this is kind of evil. What should we
* XXX be passing here?
*/
- uvm_vslock(p, SCARG(uap, old), oldlen, VM_PROT_NONE);
+ if (uvm_vslock(p, SCARG(uap, old), oldlen,
+ VM_PROT_NONE) != KERN_SUCCESS) {
+ memlock.sl_lock = 0;
+ if (memlock.sl_want) {
+ memlock.sl_want = 0;
+ wakeup((caddr_t)&memlock);
+ return (EFAULT);
+ }
+ }
}
savelen = oldlen;
}
diff -r 4bc6e3042970 -r a43379caae31 sys/uvm/uvm_extern.h
--- a/sys/uvm/uvm_extern.h Thu Jun 17 07:59:16 1999 +0000
+++ b/sys/uvm/uvm_extern.h Thu Jun 17 15:47:22 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_extern.h,v 1.28 1999/06/15 23:27:47 thorpej Exp $ */
+/* $NetBSD: uvm_extern.h,v 1.29 1999/06/17 15:47:22 thorpej Exp $ */
/*
*
@@ -282,7 +282,7 @@
__dead void uvm_scheduler __P((void)) __attribute__((noreturn));
void uvm_swapin __P((struct proc *));
boolean_t uvm_useracc __P((caddr_t, size_t, int));
-void uvm_vslock __P((struct proc *, caddr_t, size_t,
+int uvm_vslock __P((struct proc *, caddr_t, size_t,
vm_prot_t));
void uvm_vsunlock __P((struct proc *, caddr_t, size_t));
diff -r 4bc6e3042970 -r a43379caae31 sys/uvm/uvm_glue.c
--- a/sys/uvm/uvm_glue.c Thu Jun 17 07:59:16 1999 +0000
+++ b/sys/uvm/uvm_glue.c Thu Jun 17 15:47:22 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_glue.c,v 1.25 1999/06/17 05:57:33 thorpej Exp $ */
+/* $NetBSD: uvm_glue.c,v 1.26 1999/06/17 15:47:22 thorpej Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -219,16 +219,24 @@
* - XXXCDC: consider nuking this (or making it a macro?)
*/
-void
+int
uvm_vslock(p, addr, len, access_type)
struct proc *p;
caddr_t addr;
size_t len;
vm_prot_t access_type;
{
+ vm_map_t map;
+ vaddr_t start, end;
+ int rv;
- uvm_fault_wire(&p->p_vmspace->vm_map, trunc_page(addr),
- round_page(addr+len), access_type);
+ map = &p->p_vmspace->vm_map;
+ start = trunc_page(addr);
+ end = round_page(addr + len);
+
+ rv = uvm_fault_wire(map, start, end, access_type);
+
+ return (rv);
}
/*
Home |
Main Index |
Thread Index |
Old Index