summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2001-11-28 13:47:41 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2001-11-28 13:47:41 +0000
commit4c46afe9f467831fba921bfa77a12903c4c39c7d (patch)
treeb755c95bf93b8cb384f911d3f70b96063188d78a /sys
parent8a3355695ffa23bba7a2cb69d229a81ba3485bf9 (diff)
Sync in more uvm changes from NetBSD.
This time we're getting rid of KERN_* and VM_PAGER_* error codes and use errnos instead.
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/alpha/alpha/machdep.c4
-rw-r--r--sys/arch/alpha/alpha/pmap.c26
-rw-r--r--sys/arch/alpha/alpha/trap.c12
-rw-r--r--sys/arch/amiga/amiga/machdep.c4
-rw-r--r--sys/arch/amiga/amiga/pmap.c16
-rw-r--r--sys/arch/amiga/amiga/trap.c29
-rw-r--r--sys/arch/amiga/dev/clock.c6
-rw-r--r--sys/arch/amiga/isa/cross.c4
-rw-r--r--sys/arch/hp300/dev/grf.c8
-rw-r--r--sys/arch/hp300/hp300/machdep.c9
-rw-r--r--sys/arch/hp300/hp300/pmap.c18
-rw-r--r--sys/arch/hp300/hp300/trap.c14
-rw-r--r--sys/arch/hppa/hppa/machdep.c4
-rw-r--r--sys/arch/hppa/hppa/mainbus.c4
-rw-r--r--sys/arch/hppa/hppa/pmap.c4
-rw-r--r--sys/arch/hppa/hppa/trap.c10
-rw-r--r--sys/arch/hppa/hppa/vm_machdep.c4
-rw-r--r--sys/arch/i386/i386/machdep.c4
-rw-r--r--sys/arch/i386/i386/pmap.c11
-rw-r--r--sys/arch/i386/i386/trap.c7
-rw-r--r--sys/arch/mac68k/dev/grf.c7
-rw-r--r--sys/arch/mac68k/mac68k/machdep.c4
-rw-r--r--sys/arch/mac68k/mac68k/pmap.c16
-rw-r--r--sys/arch/mac68k/mac68k/trap.c10
-rw-r--r--sys/arch/macppc/macppc/machdep.c4
-rw-r--r--sys/arch/mvme68k/mvme68k/machdep.c4
-rw-r--r--sys/arch/mvme68k/mvme68k/pmap.c21
-rw-r--r--sys/arch/mvme68k/mvme68k/trap.c14
-rw-r--r--sys/arch/mvme88k/mvme88k/machdep.c4
-rw-r--r--sys/arch/mvme88k/mvme88k/pmap.c4
-rw-r--r--sys/arch/mvme88k/mvme88k/trap.c36
-rw-r--r--sys/arch/mvmeppc/mvmeppc/machdep.c4
-rw-r--r--sys/arch/powerpc/powerpc/pmap.c6
-rw-r--r--sys/arch/powerpc/powerpc/trap.c12
-rw-r--r--sys/arch/sparc/sparc/machdep.c4
-rw-r--r--sys/arch/sparc/sparc/pmap.c34
-rw-r--r--sys/arch/sparc/sparc/trap.c24
-rw-r--r--sys/arch/sparc/sparc/vm_machdep.c4
-rw-r--r--sys/arch/sparc64/sparc64/trap.c18
-rw-r--r--sys/arch/sun3/sun3/machdep.c4
-rw-r--r--sys/arch/sun3/sun3/pmap.c4
-rw-r--r--sys/arch/sun3/sun3/trap.c10
-rw-r--r--sys/arch/vax/vax/machdep.c4
-rw-r--r--sys/arch/vax/vax/pmap.c10
-rw-r--r--sys/arch/vax/vax/trap.c6
-rw-r--r--sys/compat/svr4/svr4_misc.c18
-rw-r--r--sys/compat/vax1k/vax1k_subr.c8
-rw-r--r--sys/kern/exec_subr.c43
-rw-r--r--sys/kern/init_main.c5
-rw-r--r--sys/kern/kern_physio.c11
-rw-r--r--sys/kern/kern_sysctl.c12
-rw-r--r--sys/kern/sysv_shm.c15
-rw-r--r--sys/sys/param.h6
-rw-r--r--sys/uvm/uvm_anon.c14
-rw-r--r--sys/uvm/uvm_aobj.c22
-rw-r--r--sys/uvm/uvm_bio.c48
-rw-r--r--sys/uvm/uvm_device.c14
-rw-r--r--sys/uvm/uvm_extern.h8
-rw-r--r--sys/uvm/uvm_fault.c121
-rw-r--r--sys/uvm/uvm_glue.c20
-rw-r--r--sys/uvm/uvm_io.c7
-rw-r--r--sys/uvm/uvm_km.c23
-rw-r--r--sys/uvm/uvm_loan.c50
-rw-r--r--sys/uvm/uvm_map.c161
-rw-r--r--sys/uvm/uvm_map.h8
-rw-r--r--sys/uvm/uvm_map_i.h10
-rw-r--r--sys/uvm/uvm_mmap.c308
-rw-r--r--sys/uvm/uvm_page.c4
-rw-r--r--sys/uvm/uvm_pager.c62
-rw-r--r--sys/uvm/uvm_pager.h26
-rw-r--r--sys/uvm/uvm_param.h20
-rw-r--r--sys/uvm/uvm_pdaemon.c171
-rw-r--r--sys/uvm/uvm_swap.c30
-rw-r--r--sys/uvm/uvm_unix.c31
-rw-r--r--sys/uvm/uvm_user.c16
-rw-r--r--sys/uvm/uvm_vnode.c62
76 files changed, 704 insertions, 1116 deletions
diff --git a/sys/arch/alpha/alpha/machdep.c b/sys/arch/alpha/alpha/machdep.c
index 16b3514c6b5..39d8906520b 100644
--- a/sys/arch/alpha/alpha/machdep.c
+++ b/sys/arch/alpha/alpha/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.58 2001/11/24 17:53:39 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.59 2001/11/28 13:47:37 art Exp $ */
/* $NetBSD: machdep.c,v 1.210 2000/06/01 17:12:38 thorpej Exp $ */
/*-
@@ -914,7 +914,7 @@ cpu_startup()
if (uvm_map(kernel_map, (vaddr_t *) &buffers, round_page(size),
NULL, UVM_UNKNOWN_OFFSET, 0,
UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE,
- UVM_ADV_NORMAL, 0)) != KERN_SUCCESS)
+ UVM_ADV_NORMAL, 0)))
panic("startup: cannot allocate VM for buffers");
base = bufpages / nbuf;
residual = bufpages % nbuf;
diff --git a/sys/arch/alpha/alpha/pmap.c b/sys/arch/alpha/alpha/pmap.c
index 1d50a35d446..e8d2602cd60 100644
--- a/sys/arch/alpha/alpha/pmap.c
+++ b/sys/arch/alpha/alpha/pmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.c,v 1.24 2001/11/27 05:27:11 art Exp $ */
+/* $OpenBSD: pmap.c,v 1.25 2001/11/28 13:47:37 art Exp $ */
/* $NetBSD: pmap.c,v 1.154 2000/12/07 22:18:55 thorpej Exp $ */
/*-
@@ -804,7 +804,7 @@ pmap_bootstrap(paddr_t ptaddr, u_int maxasn, u_long ncpuids)
/*
* Figure out how many PTE's are necessary to map the kernel.
*/
- lev3mapsize = (VM_PHYS_SIZE + ubc_nwins * ubc_winsize +
+ lev3mapsize = (VM_PHYS_SIZE + (ubc_nwins << ubc_winshift) +
nbuf * MAXBSIZE + 16 * NCARGS + PAGER_MAP_SIZE) / NBPG +
(maxproc * UPAGES) + NKMEMCLUSTERS;
@@ -1687,7 +1687,7 @@ pmap_enter(pmap_t pmap, vaddr_t va, paddr_t pa, vm_prot_t prot, int flags)
boolean_t isactive;
boolean_t wired;
long cpu_id = cpu_number();
- int error = KERN_SUCCESS;
+ int error = 0;
#ifdef DEBUG
if (pmapdebug & (PDB_FOLLOW|PDB_ENTER))
@@ -1744,7 +1744,7 @@ pmap_enter(pmap_t pmap, vaddr_t va, paddr_t pa, vm_prot_t prot, int flags)
*/
if (pmap->pm_lev1map == kernel_lev1map) {
error = pmap_lev1map_create(pmap, cpu_id);
- if (error != KERN_SUCCESS) {
+ if (error) {
if (flags & PMAP_CANFAIL)
goto out;
panic("pmap_enter: unable to create lev1map");
@@ -1761,7 +1761,7 @@ pmap_enter(pmap_t pmap, vaddr_t va, paddr_t pa, vm_prot_t prot, int flags)
if (pmap_pte_v(l1pte) == 0) {
pmap_physpage_addref(l1pte);
error = pmap_ptpage_alloc(pmap, l1pte, PGU_L2PT);
- if (error != KERN_SUCCESS) {
+ if (error) {
pmap_l1pt_delref(pmap, l1pte, cpu_id);
if (flags & PMAP_CANFAIL)
goto out;
@@ -1786,7 +1786,7 @@ pmap_enter(pmap_t pmap, vaddr_t va, paddr_t pa, vm_prot_t prot, int flags)
if (pmap_pte_v(l2pte) == 0) {
pmap_physpage_addref(l2pte);
error = pmap_ptpage_alloc(pmap, l2pte, PGU_L3PT);
- if (error != KERN_SUCCESS) {
+ if (error) {
pmap_l2pt_delref(pmap, l1pte, l2pte, cpu_id);
if (flags & PMAP_CANFAIL)
goto out;
@@ -1892,7 +1892,7 @@ pmap_enter(pmap_t pmap, vaddr_t va, paddr_t pa, vm_prot_t prot, int flags)
*/
if (managed) {
error = pmap_pv_enter(pmap, pa, va, pte, TRUE);
- if (error != KERN_SUCCESS) {
+ if (error) {
pmap_l3pt_delref(pmap, va, pte, cpu_id, NULL);
if (flags & PMAP_CANFAIL)
goto out;
@@ -3052,7 +3052,7 @@ pmap_pv_enter(pmap_t pmap, paddr_t pa, vaddr_t va, pt_entry_t *pte,
*/
newpv = pmap_pv_alloc();
if (newpv == NULL)
- return (KERN_RESOURCE_SHORTAGE);
+ return (ENOMEM);
newpv->pv_va = va;
newpv->pv_pmap = pmap;
newpv->pv_pte = pte;
@@ -3085,7 +3085,7 @@ pmap_pv_enter(pmap_t pmap, paddr_t pa, vaddr_t va, pt_entry_t *pte,
if (dolock)
simple_unlock(&pvh->pvh_slock);
- return (KERN_SUCCESS);
+ return (0);
}
/*
@@ -3527,7 +3527,7 @@ pmap_lev1map_create(pmap_t pmap, long cpu_id)
l1pt = pool_cache_get(&pmap_l1pt_cache, PR_NOWAIT);
if (l1pt == NULL) {
simple_unlock(&pmap_growkernel_slock);
- return (KERN_RESOURCE_SHORTAGE);
+ return (ENOMEM);
}
pmap->pm_lev1map = l1pt;
@@ -3542,7 +3542,7 @@ pmap_lev1map_create(pmap_t pmap, long cpu_id)
pmap_asn_alloc(pmap, cpu_id);
PMAP_ACTIVATE(pmap, curproc, cpu_id);
}
- return (KERN_SUCCESS);
+ return (0);
}
/*
@@ -3689,7 +3689,7 @@ pmap_ptpage_alloc(pmap_t pmap, pt_entry_t *pte, int usage)
* another pmap!
*/
if (pmap_ptpage_steal(pmap, usage, &ptpa) == FALSE)
- return (KERN_RESOURCE_SHORTAGE);
+ return (ENOMEM);
}
/*
@@ -3699,7 +3699,7 @@ pmap_ptpage_alloc(pmap_t pmap, pt_entry_t *pte, int usage)
PG_V | PG_KRE | PG_KWE | PG_WIRED |
(pmap == pmap_kernel() ? PG_ASM : 0));
- return (KERN_SUCCESS);
+ return (0);
}
/*
diff --git a/sys/arch/alpha/alpha/trap.c b/sys/arch/alpha/alpha/trap.c
index 67317763768..4100a183fe1 100644
--- a/sys/arch/alpha/alpha/trap.c
+++ b/sys/arch/alpha/alpha/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.27 2001/11/06 19:53:13 miod Exp $ */
+/* $OpenBSD: trap.c,v 1.28 2001/11/28 13:47:37 art Exp $ */
/* $NetBSD: trap.c,v 1.52 2000/05/24 16:48:33 thorpej Exp $ */
/*-
@@ -501,17 +501,17 @@ trap(a0, a1, a2, entry, framep)
if (map != kernel_map &&
(caddr_t)va >= vm->vm_maxsaddr &&
va < USRSTACK) {
- if (rv == KERN_SUCCESS) {
+ if (rv == 0) {
unsigned nss;
nss = btoc(USRSTACK -
(unsigned long)va);
if (nss > vm->vm_ssize)
vm->vm_ssize = nss;
- } else if (rv == KERN_PROTECTION_FAILURE)
- rv = KERN_INVALID_ADDRESS;
+ } else if (rv == EACCES)
+ rv = EFAULT;
}
- if (rv == KERN_SUCCESS) {
+ if (rv == 0) {
goto out;
}
@@ -529,7 +529,7 @@ trap(a0, a1, a2, entry, framep)
ucode = ftype;
v = (caddr_t)a0;
typ = SEGV_MAPERR;
- if (rv == KERN_RESOURCE_SHORTAGE) {
+ if (rv == ENOMEM) {
printf("UVM: pid %d (%s), uid %d killed: "
"out of swap\n", p->p_pid, p->p_comm,
p->p_cred && p->p_ucred ?
diff --git a/sys/arch/amiga/amiga/machdep.c b/sys/arch/amiga/amiga/machdep.c
index 151fa9f18e6..f72b52e8698 100644
--- a/sys/arch/amiga/amiga/machdep.c
+++ b/sys/arch/amiga/amiga/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.58 2001/11/24 17:53:41 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.59 2001/11/28 13:47:37 art Exp $ */
/* $NetBSD: machdep.c,v 1.95 1997/08/27 18:31:17 is Exp $ */
/*
@@ -418,7 +418,7 @@ again:
if (uvm_map(kernel_map, (vaddr_t *)&buffers, round_page(size),
NULL, UVM_UNKNOWN_OFFSET, 0,
UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE,
- UVM_ADV_NORMAL, 0)) != KERN_SUCCESS)
+ UVM_ADV_NORMAL, 0)))
panic("startup: cannot allocate buffers");
minaddr = (vaddr_t) buffers;
if ((bufpages / nbuf) >= btoc(MAXBSIZE)) {
diff --git a/sys/arch/amiga/amiga/pmap.c b/sys/arch/amiga/amiga/pmap.c
index 27e16bee96d..2273f0bebb0 100644
--- a/sys/arch/amiga/amiga/pmap.c
+++ b/sys/arch/amiga/amiga/pmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.c,v 1.38 2001/11/07 01:18:00 art Exp $ */
+/* $OpenBSD: pmap.c,v 1.39 2001/11/28 13:47:37 art Exp $ */
/* $NetBSD: pmap.c,v 1.68 1999/06/19 19:44:09 is Exp $ */
/*-
@@ -504,14 +504,14 @@ pmap_init()
NULL, UVM_UNKNOWN_OFFSET, 0,
UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE,
UVM_INH_NONE, UVM_ADV_RANDOM,
- UVM_FLAG_FIXED)) != KERN_SUCCESS)
+ UVM_FLAG_FIXED)))
goto bogons;
addr = (vaddr_t) Sysmap;
if (uvm_map(kernel_map, &addr, AMIGA_KPTSIZE,
NULL, UVM_UNKNOWN_OFFSET, 0,
UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE,
UVM_INH_NONE, UVM_ADV_RANDOM,
- UVM_FLAG_FIXED)) != KERN_SUCCESS) {
+ UVM_FLAG_FIXED))) {
/*
* If this fails, it is probably because the static
* portion of the kernel page table isn't big enough
@@ -602,11 +602,9 @@ bogons:
rv = uvm_map(kernel_map, &addr, s, NULL, UVM_UNKNOWN_OFFSET, 0,
UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE,
UVM_ADV_RANDOM, UVM_FLAG_NOMERGE));
- if (rv != KERN_SUCCESS || (addr + s) >= (vaddr_t)Sysmap)
+ if (rv || (addr + s) >= (vaddr_t)Sysmap)
panic("pmap_init: kernel PT too small");
- rv = uvm_unmap(kernel_map, addr, addr + s);
- if (rv != KERN_SUCCESS)
- panic("pmap_init: uvm_unmap failed");
+ uvm_unmap(kernel_map, addr, addr + s);
/*
* Now allocate the space and link the pages together to
* form the KPT free list.
@@ -1375,7 +1373,7 @@ validate:
}
#endif
- return (KERN_SUCCESS);
+ return (0);
}
/*
@@ -2434,7 +2432,7 @@ pmap_enter_ptpage(pmap, va)
#endif
s = uvm_fault_wire(pt_map, va, va + PAGE_SIZE,
VM_PROT_READ|VM_PROT_WRITE);
- if (s != KERN_SUCCESS) {
+ if (s) {
printf("uvm_fault_wire(pt_map, 0x%lx, 0%lx, RW) "
"-> %d\n", va, va + PAGE_SIZE, s);
panic("pmap_enter: uvm_fault_wire failed");
diff --git a/sys/arch/amiga/amiga/trap.c b/sys/arch/amiga/amiga/trap.c
index e8961dc3501..3251e315940 100644
--- a/sys/arch/amiga/amiga/trap.c
+++ b/sys/arch/amiga/amiga/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.26 2001/11/25 17:21:32 miod Exp $ */
+/* $OpenBSD: trap.c,v 1.27 2001/11/28 13:47:37 art Exp $ */
/* $NetBSD: trap.c,v 1.56 1997/07/16 00:01:47 is Exp $ */
/*
@@ -380,7 +380,7 @@ trapmmufault(type, code, v, fp, p, sticks)
if (map != kernel_map && (caddr_t)va >= vm->vm_maxsaddr) {
nss = btoc(USRSTACK - (unsigned)va);
if (nss > btoc(p->p_rlimit[RLIMIT_STACK].rlim_cur)) {
- rv = KERN_FAILURE;
+ rv = EFAULT;
goto nogo;
}
}
@@ -403,7 +403,7 @@ trapmmufault(type, code, v, fp, p, sticks)
#else
if (mmutype == MMU_68040) {
#endif
- if(rv != KERN_SUCCESS) {
+ if (rv) {
goto nogo;
}
@@ -435,8 +435,7 @@ trapmmufault(type, code, v, fp, p, sticks)
if (fp->f_fmt7.f_wb2s & WBS_VALID &&
((fp->f_fmt7.f_wb2s & WBS_TTMASK)==WBS_TT_MOVE16) == 0) {
if (_write_back(2, fp->f_fmt7.f_wb2s,
- fp->f_fmt7.f_wb2d, fp->f_fmt7.f_wb2a, map)
- != KERN_SUCCESS)
+ fp->f_fmt7.f_wb2d, fp->f_fmt7.f_wb2a, map))
goto nogo;
if ((fp->f_fmt7.f_wb2s & WBS_TMMASK)
!= (code & SSW_TMMASK))
@@ -452,8 +451,7 @@ trapmmufault(type, code, v, fp, p, sticks)
else
wb3_map = &vm->vm_map;
if (_write_back(3, fp->f_fmt7.f_wb3s,
- fp->f_fmt7.f_wb3d, fp->f_fmt7.f_wb3a, wb3_map)
- != KERN_SUCCESS)
+ fp->f_fmt7.f_wb3d, fp->f_fmt7.f_wb3a, wb3_map))
goto nogo;
}
}
@@ -467,22 +465,22 @@ trapmmufault(type, code, v, fp, p, sticks)
* error.
*/
if (map != kernel_map && (caddr_t)va >= vm->vm_maxsaddr) {
- if (rv == KERN_SUCCESS) {
+ if (rv == 0) {
nss = btoc(USRSTACK-(unsigned)va);
if (nss > vm->vm_ssize)
vm->vm_ssize = nss;
- } else if (rv == KERN_PROTECTION_FAILURE)
- rv = KERN_INVALID_ADDRESS;
+ } else if (rv == EACCES)
+ rv = EFAULT;
}
- if (rv == KERN_SUCCESS) {
+ if (rv == 0) {
if (type == T_MMUFLT)
return;
userret(p, fp, sticks, 0, 0);
return;
}
#else /* use hacky 386bsd_code */
- if (rv == KERN_SUCCESS) {
+ if (rv == 0) {
/*
* XXX: continuation of rude stack hack
*/
@@ -994,7 +992,7 @@ _write_back (wb, wb_sts, wb_data, wb_addr, wb_map)
trunc_page((vm_offset_t)wb_addr),
0, VM_PROT_READ | VM_PROT_WRITE);
- if (wb_rc != KERN_SUCCESS)
+ if (wb_rc)
return (wb_rc);
#ifdef DEBUG
if (mmudebug)
@@ -1026,8 +1024,7 @@ _write_back (wb, wb_sts, wb_data, wb_addr, wb_map)
wb_rc = uvm_fault(wb_map,
trunc_page((vm_offset_t)wb_addr + wb_extra_page),
0, VM_PROT_READ | VM_PROT_WRITE);
-
- if (wb_rc != KERN_SUCCESS)
+ if (wb_rc)
return (wb_rc);
}
#ifdef DEBUG
@@ -1061,7 +1058,7 @@ _write_back (wb, wb_sts, wb_data, wb_addr, wb_map)
curpcb->pcb_onfault = NULL;
if ((wb_sts & WBS_TMMASK) != FC_USERD)
__asm volatile("movec %0,dfc\n" : : "d" (FC_USERD));
- return (KERN_SUCCESS);
+ return (0);
}
/*
diff --git a/sys/arch/amiga/dev/clock.c b/sys/arch/amiga/dev/clock.c
index 20849b8dcf9..213c3fa01e2 100644
--- a/sys/arch/amiga/dev/clock.c
+++ b/sys/arch/amiga/dev/clock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: clock.c,v 1.11 2001/11/06 19:53:14 miod Exp $ */
+/* $OpenBSD: clock.c,v 1.12 2001/11/28 13:47:38 art Exp $ */
/* $NetBSD: clock.c,v 1.25 1997/01/02 20:59:42 is Exp $ */
/*
@@ -521,8 +521,8 @@ clockunmmap(dev, addr, p)
if (addr == 0)
return(EINVAL); /* XXX: how do we deal with this? */
- rv = vm_deallocate(p->p_vmspace->vm_map, (vm_offset_t)addr, PAGE_SIZE);
- return(rv == KERN_SUCCESS ? 0 : EINVAL);
+ uvm_deallocate(p->p_vmspace->vm_map, (vm_offset_t)addr, PAGE_SIZE);
+ return (0);
}
startclock()
diff --git a/sys/arch/amiga/isa/cross.c b/sys/arch/amiga/isa/cross.c
index b01ddbb46e6..140b9941391 100644
--- a/sys/arch/amiga/isa/cross.c
+++ b/sys/arch/amiga/isa/cross.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cross.c,v 1.18 2001/11/06 19:53:14 miod Exp $ */
+/* $OpenBSD: cross.c,v 1.19 2001/11/28 13:47:38 art Exp $ */
/*
* Copyright (c) 1994, 1996 Niklas Hallqvist, Carsten Hammer
@@ -282,7 +282,7 @@ cross_mem_map(bst, addr, sz, cacheable, handle)
vm_map_lock(kernel_map);
error = vm_map_insert(kernel_map, object, 0, kva, kva + banked_size);
vm_map_unlock(kernel_map);
- if (error != KERN_SUCCESS)
+ if (error)
goto fail_insert;
/* Tell caller where to find his data. */
diff --git a/sys/arch/hp300/dev/grf.c b/sys/arch/hp300/dev/grf.c
index feb437cb0a7..3b1801f6a28 100644
--- a/sys/arch/hp300/dev/grf.c
+++ b/sys/arch/hp300/dev/grf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: grf.c,v 1.16 2001/11/06 19:53:14 miod Exp $ */
+/* $OpenBSD: grf.c,v 1.17 2001/11/28 13:47:38 art Exp $ */
/* $NetBSD: grf.c,v 1.30 1998/08/20 08:33:41 kleink Exp $ */
/*
@@ -654,7 +654,6 @@ grfunmap(dev, addr, p)
struct grf_softc *sc = grf_cd.cd_devs[GRFUNIT(dev)];
struct grf_data *gp = sc->sc_data;
vsize_t size;
- int rv;
#ifdef DEBUG
if (grfdebug & GDB_MMAP)
@@ -664,9 +663,8 @@ grfunmap(dev, addr, p)
return(EINVAL); /* XXX: how do we deal with this? */
(void) (*gp->g_sw->gd_mode)(gp, GM_UNMAP, 0);
size = round_page(gp->g_display.gd_regsize + gp->g_display.gd_fbsize);
- rv = uvm_unmap(&p->p_vmspace->vm_map, (vaddr_t)addr,
- (vaddr_t)addr + size);
- return(rv == KERN_SUCCESS ? 0 : EINVAL);
+ uvm_unmap(&p->p_vmspace->vm_map, (vaddr_t)addr, (vaddr_t)addr + size);
+ return (0);
}
#ifdef COMPAT_HPUX
diff --git a/sys/arch/hp300/hp300/machdep.c b/sys/arch/hp300/hp300/machdep.c
index ff538e8162b..b3d519e6285 100644
--- a/sys/arch/hp300/hp300/machdep.c
+++ b/sys/arch/hp300/hp300/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.68 2001/11/09 15:25:55 art Exp $ */
+/* $OpenBSD: machdep.c,v 1.69 2001/11/28 13:47:38 art Exp $ */
/* $NetBSD: machdep.c,v 1.121 1999/03/26 23:41:29 mycroft Exp $ */
/*
@@ -293,7 +293,7 @@ cpu_startup()
if (uvm_map(kernel_map, (vaddr_t *) &buffers, round_page(size),
NULL, UVM_UNKNOWN_OFFSET, 0,
UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE,
- UVM_ADV_NORMAL, 0)) != KERN_SUCCESS)
+ UVM_ADV_NORMAL, 0)))
panic("startup: cannot allocate VM for buffers");
minaddr = (vaddr_t)buffers;
base = bufpages / nbuf;
@@ -353,8 +353,7 @@ cpu_startup()
* XXX This is bogus; should just fix KERNBASE and
* XXX VM_MIN_KERNEL_ADDRESS, but not right now.
*/
- if (uvm_map_protect(kernel_map, 0, NBPG, UVM_PROT_NONE, TRUE)
- != KERN_SUCCESS)
+ if (uvm_map_protect(kernel_map, 0, NBPG, UVM_PROT_NONE, TRUE))
panic("can't mark page 0 off-limits");
/*
@@ -365,7 +364,7 @@ cpu_startup()
* XXX of NBPG.
*/
if (uvm_map_protect(kernel_map, NBPG, round_page((vaddr_t)&etext),
- UVM_PROT_READ|UVM_PROT_EXEC, TRUE) != KERN_SUCCESS)
+ UVM_PROT_READ|UVM_PROT_EXEC, TRUE))
panic("can't protect kernel text");
/*
diff --git a/sys/arch/hp300/hp300/pmap.c b/sys/arch/hp300/hp300/pmap.c
index 7677a088434..77f75eecac4 100644
--- a/sys/arch/hp300/hp300/pmap.c
+++ b/sys/arch/hp300/hp300/pmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.c,v 1.32 2001/11/27 22:05:29 miod Exp $ */
+/* $OpenBSD: pmap.c,v 1.33 2001/11/28 13:47:38 art Exp $ */
/* $NetBSD: pmap.c,v 1.80 1999/09/16 14:52:06 chs Exp $ */
/*-
@@ -383,14 +383,14 @@ pmap_init()
NULL, UVM_UNKNOWN_OFFSET, 0,
UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE,
UVM_INH_NONE, UVM_ADV_RANDOM,
- UVM_FLAG_FIXED)) != KERN_SUCCESS)
+ UVM_FLAG_FIXED)))
goto bogons;
addr = (vaddr_t) Sysmap;
if (uvm_map(kernel_map, &addr, HP_MAX_PTSIZE,
NULL, UVM_UNKNOWN_OFFSET, 0,
UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE,
UVM_INH_NONE, UVM_ADV_RANDOM,
- UVM_FLAG_FIXED)) != KERN_SUCCESS) {
+ UVM_FLAG_FIXED))) {
/*
* If this fails, it is probably because the static
* portion of the kernel page table isn't big enough
@@ -464,11 +464,9 @@ pmap_init()
rv = uvm_map(kernel_map, &addr, s, NULL, UVM_UNKNOWN_OFFSET, 0,
UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE,
UVM_ADV_RANDOM, UVM_FLAG_NOMERGE));
- if (rv != KERN_SUCCESS || (addr + s) >= (vaddr_t)Sysmap)
+ if (rv || (addr + s) >= (vaddr_t)Sysmap)
panic("pmap_init: kernel PT too small");
- rv = uvm_unmap(kernel_map, addr, addr + s);
- if (rv != KERN_SUCCESS)
- panic("pmap_init: uvm_unmap failed");
+ uvm_unmap(kernel_map, addr, addr + s);
/*
* Now allocate the space and link the pages together to
@@ -1399,7 +1397,7 @@ validate:
pmap_check_wiring("enter", trunc_page((vaddr_t)pte));
#endif
- return (KERN_SUCCESS);
+ return (0);
}
void
@@ -2124,9 +2122,9 @@ pmap_mapmulti(pmap, va)
if (*ste == SG_NV && (*bste & SG_V)) {
*ste = *bste;
TBIAU();
- return (KERN_SUCCESS);
+ return (0);
}
- return (KERN_INVALID_ADDRESS);
+ return (EFAULT);
}
#endif /* COMPAT_HPUX */
diff --git a/sys/arch/hp300/hp300/trap.c b/sys/arch/hp300/hp300/trap.c
index 591973cd303..6744ada3853 100644
--- a/sys/arch/hp300/hp300/trap.c
+++ b/sys/arch/hp300/hp300/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.32 2001/11/25 17:15:19 miod Exp $ */
+/* $OpenBSD: trap.c,v 1.33 2001/11/28 13:47:38 art Exp $ */
/* $NetBSD: trap.c,v 1.57 1998/02/16 20:58:31 thorpej Exp $ */
/*
@@ -646,10 +646,10 @@ dopanic:
vaddr_t bva;
rv = pmap_mapmulti(map->pmap, va);
- if (rv != KERN_SUCCESS) {
+ if (rv) {
bva = HPMMBASEADDR(va);
rv = uvm_fault(map, bva, 0, ftype);
- if (rv == KERN_SUCCESS)
+ if (rv == 0)
(void) pmap_mapmulti(map->pmap, va);
}
} else
@@ -669,16 +669,16 @@ dopanic:
*/
if ((vm != NULL && (caddr_t)va >= vm->vm_maxsaddr)
&& map != kernel_map) {
- if (rv == KERN_SUCCESS) {
+ if (rv == 0) {
unsigned nss;
nss = btoc(USRSTACK-(unsigned)va);
if (nss > vm->vm_ssize)
vm->vm_ssize = nss;
- } else if (rv == KERN_PROTECTION_FAILURE)
- rv = KERN_INVALID_ADDRESS;
+ } else if (rv == EACCES)
+ rv = EFAULT;
}
- if (rv == KERN_SUCCESS) {
+ if (rv == 0) {
if (type == T_MMUFLT) {
#ifdef M68040
if (cputype == CPU_68040)
diff --git a/sys/arch/hppa/hppa/machdep.c b/sys/arch/hppa/hppa/machdep.c
index 196d2ac85d1..bb2694b1198 100644
--- a/sys/arch/hppa/hppa/machdep.c
+++ b/sys/arch/hppa/hppa/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.44 2001/11/24 17:53:41 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.45 2001/11/28 13:47:38 art Exp $ */
/*
* Copyright (c) 1999-2000 Michael Shalayeff
@@ -608,7 +608,7 @@ cpu_startup()
size = MAXBSIZE * nbuf;
if (uvm_map(kernel_map, (vaddr_t *) &buffers, round_page(size),
NULL, UVM_UNKNOWN_OFFSET, 0, UVM_MAPFLAG(UVM_PROT_NONE,
- UVM_PROT_NONE, UVM_INH_NONE, UVM_ADV_NORMAL, 0)) != KERN_SUCCESS)
+ UVM_PROT_NONE, UVM_INH_NONE, UVM_ADV_NORMAL, 0)))
panic("cpu_startup: cannot allocate VM for buffers");
minaddr = (vaddr_t)buffers;
base = bufpages / nbuf;
diff --git a/sys/arch/hppa/hppa/mainbus.c b/sys/arch/hppa/hppa/mainbus.c
index a703a9b59e2..ef8df572df6 100644
--- a/sys/arch/hppa/hppa/mainbus.c
+++ b/sys/arch/hppa/hppa/mainbus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mainbus.c,v 1.16 2001/11/07 01:18:00 art Exp $ */
+/* $OpenBSD: mainbus.c,v 1.17 2001/11/28 13:47:38 art Exp $ */
/*
* Copyright (c) 1998-2000 Michael Shalayeff
@@ -727,7 +727,7 @@ mbus_dmamem_alloc(void *v, bus_size_t size, bus_size_t alignment,
if (uvm_map(kernel_map, &va, size, NULL, UVM_UNKNOWN_OFFSET, 0,
UVM_MAPFLAG(UVM_PROT_ALL, UVM_PROT_ALL, UVM_INH_NONE,
- UVM_ADV_RANDOM, 0)) != KERN_SUCCESS) {
+ UVM_ADV_RANDOM, 0))) {
uvm_pglistfree(&pglist);
return ENOMEM;
}
diff --git a/sys/arch/hppa/hppa/pmap.c b/sys/arch/hppa/hppa/pmap.c
index 797e4571a73..cfdb7994368 100644
--- a/sys/arch/hppa/hppa/pmap.c
+++ b/sys/arch/hppa/hppa/pmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.c,v 1.47 2001/11/06 20:57:21 mickey Exp $ */
+/* $OpenBSD: pmap.c,v 1.48 2001/11/28 13:47:38 art Exp $ */
/*
* Copyright (c) 1998-2001 Michael Shalayeff
@@ -1076,7 +1076,7 @@ pmap_enter(pmap, va, pa, prot, flags)
printf("pmap_enter: leaving\n");
#endif
- return (KERN_SUCCESS);
+ return (0);
}
/*
diff --git a/sys/arch/hppa/hppa/trap.c b/sys/arch/hppa/hppa/trap.c
index e24802c45bd..59edd5bcd7e 100644
--- a/sys/arch/hppa/hppa/trap.c
+++ b/sys/arch/hppa/hppa/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.32 2001/11/06 20:58:48 mickey Exp $ */
+/* $OpenBSD: trap.c,v 1.33 2001/11/28 13:47:38 art Exp $ */
/*
* Copyright (c) 1998-2001 Michael Shalayeff
@@ -335,15 +335,15 @@ trap(type, frame)
* error.
*/
if (va >= (vaddr_t)vm->vm_maxsaddr + vm->vm_ssize) {
- if (ret == KERN_SUCCESS) {
+ if (ret == 0) {
vsize_t nss = btoc(va - USRSTACK + NBPG);
if (nss > vm->vm_ssize)
vm->vm_ssize = nss;
- } else if (ret == KERN_PROTECTION_FAILURE)
- ret = KERN_INVALID_ADDRESS;
+ } else if (ret == EACCES)
+ ret = EFAULT;
}
- if (ret != KERN_SUCCESS) {
+ if (ret != 0) {
if (type & T_USER) {
printf("trapsignal: uvm_fault\n");
sv.sival_int = frame->tf_ior;
diff --git a/sys/arch/hppa/hppa/vm_machdep.c b/sys/arch/hppa/hppa/vm_machdep.c
index 306eb5271dc..3f70fa05e1b 100644
--- a/sys/arch/hppa/hppa/vm_machdep.c
+++ b/sys/arch/hppa/hppa/vm_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm_machdep.c,v 1.28 2001/11/07 01:18:00 art Exp $ */
+/* $OpenBSD: vm_machdep.c,v 1.29 2001/11/28 13:47:38 art Exp $ */
/*
* Copyright (c) 1999-2000 Michael Shalayeff
@@ -316,7 +316,7 @@ vmapbuf(bp, len)
kva = vm_map_min(phys_map);
if (uvm_map(phys_map, &kva, size, NULL, addr, 0,
UVM_MAPFLAG(UVM_PROT_ALL, UVM_PROT_ALL,
- UVM_INH_NONE, UVM_ADV_RANDOM, 0)) == KERN_SUCCESS)
+ UVM_INH_NONE, UVM_ADV_RANDOM, 0)) == 0)
break;
tsleep(phys_map, PVM, "vallocwait", 0);
}
diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c
index e4e9633ea1d..72894a35231 100644
--- a/sys/arch/i386/i386/machdep.c
+++ b/sys/arch/i386/i386/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.183 2001/11/24 17:53:41 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.184 2001/11/28 13:47:38 art Exp $ */
/* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */
/*-
@@ -532,7 +532,7 @@ setup_buffers(maxaddr)
if (uvm_map(kernel_map, (vaddr_t *) &buffers, round_page(size),
NULL, UVM_UNKNOWN_OFFSET, 0,
UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE,
- UVM_ADV_NORMAL, 0)) != KERN_SUCCESS)
+ UVM_ADV_NORMAL, 0)))
panic("cpu_startup: cannot allocate VM for buffers");
addr = (vaddr_t)buffers;
diff --git a/sys/arch/i386/i386/pmap.c b/sys/arch/i386/i386/pmap.c
index e7934581d50..b3da2c94d8e 100644
--- a/sys/arch/i386/i386/pmap.c
+++ b/sys/arch/i386/i386/pmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.c,v 1.47 2001/11/07 02:55:50 art Exp $ */
+/* $OpenBSD: pmap.c,v 1.48 2001/11/28 13:47:38 art Exp $ */
/* $NetBSD: pmap.c,v 1.91 2000/06/02 17:46:37 thorpej Exp $ */
/*
@@ -2744,9 +2744,6 @@ pmap_change_attrs(pg, setbits, clearbits)
for (pve = pvh->pvh_list; pve != NULL; pve = pve->pv_next) {
#ifdef DIAGNOSTIC
- if (pve->pv_va >= uvm.pager_sva && pve->pv_va < uvm.pager_eva) {
- printf("pmap_change_attrs: found pager VA on pv_list\n");
- }
if (!pmap_valid_entry(pve->pv_pmap->pm_pdir[pdei(pve->pv_va)]))
panic("pmap_change_attrs: mapping without PTP "
"detected");
@@ -3498,7 +3495,7 @@ pmap_enter(pmap, va, pa, prot, flags)
ptp = pmap_get_ptp(pmap, pdei(va), FALSE);
if (ptp == NULL) {
if (flags & PMAP_CANFAIL) {
- return (KERN_RESOURCE_SHORTAGE);
+ return (ENOMEM);
}
panic("pmap_enter: get ptp failed");
}
@@ -3598,7 +3595,7 @@ pmap_enter(pmap, va, pa, prot, flags)
pve = pmap_alloc_pv(pmap, ALLOCPV_NEED);
if (pve == NULL) {
if (flags & PMAP_CANFAIL) {
- error = KERN_RESOURCE_SHORTAGE;
+ error = ENOMEM;
goto out;
}
panic("pmap_enter: no pv entries available");
@@ -3636,7 +3633,7 @@ enter_now:
if ((opte & ~(PG_M|PG_U)) != npte && pmap_is_curpmap(pmap))
pmap_update_pg(va);
- error = KERN_SUCCESS;
+ error = 0;
out:
pmap_unmap_ptes(pmap);
diff --git a/sys/arch/i386/i386/trap.c b/sys/arch/i386/i386/trap.c
index 892ce2bb758..98580fd7259 100644
--- a/sys/arch/i386/i386/trap.c
+++ b/sys/arch/i386/i386/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.44 2001/11/06 18:41:09 art Exp $ */
+/* $OpenBSD: trap.c,v 1.45 2001/11/28 13:47:38 art Exp $ */
/* $NetBSD: trap.c,v 1.95 1996/05/05 06:50:02 mycroft Exp $ */
/*-
@@ -469,7 +469,7 @@ trap(frame)
p->p_addr->u_pcb.pcb_onfault = NULL;
rv = uvm_fault(map, va, 0, ftype);
p->p_addr->u_pcb.pcb_onfault = onfault;
- if (rv == KERN_SUCCESS) {
+ if (rv == 0) {
if (nss > vm->vm_ssize)
vm->vm_ssize = nss;
if (type == T_PAGEFLT)
@@ -565,8 +565,7 @@ trapwrite(addr)
nss = 0;
}
- if (uvm_fault(&vm->vm_map, va, 0, VM_PROT_READ | VM_PROT_WRITE)
- != KERN_SUCCESS)
+ if (uvm_fault(&vm->vm_map, va, 0, VM_PROT_READ | VM_PROT_WRITE))
return 1;
if (nss > vm->vm_ssize)
diff --git a/sys/arch/mac68k/dev/grf.c b/sys/arch/mac68k/dev/grf.c
index dd1f3434a1a..c11cbc5da35 100644
--- a/sys/arch/mac68k/dev/grf.c
+++ b/sys/arch/mac68k/dev/grf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: grf.c,v 1.18 2001/11/06 19:53:14 miod Exp $ */
+/* $OpenBSD: grf.c,v 1.19 2001/11/28 13:47:38 art Exp $ */
/* $NetBSD: grf.c,v 1.41 1997/02/24 06:20:04 scottr Exp $ */
/*
@@ -391,7 +391,6 @@ grfunmap(dev, addr, p)
{
struct grf_softc *gp;
vm_size_t size;
- int rv;
gp = grf_cd.cd_devs[GRFUNIT(dev)];
@@ -405,8 +404,8 @@ grfunmap(dev, addr, p)
size = round_page(gp->sc_grfmode->fbsize);
- rv = uvm_unmap(&p->p_vmspace->vm_map, (vm_offset_t)addr,
+ uvm_unmap(&p->p_vmspace->vm_map, (vm_offset_t)addr,
(vm_offset_t)addr + size);
- return (rv == KERN_SUCCESS ? 0 : EINVAL);
+ return (0);
}
diff --git a/sys/arch/mac68k/mac68k/machdep.c b/sys/arch/mac68k/mac68k/machdep.c
index 51db2e477b0..642712037c1 100644
--- a/sys/arch/mac68k/mac68k/machdep.c
+++ b/sys/arch/mac68k/mac68k/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.88 2001/11/24 17:53:41 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.89 2001/11/28 13:47:38 art Exp $ */
/* $NetBSD: machdep.c,v 1.207 1998/07/08 04:39:34 thorpej Exp $ */
/*
@@ -451,7 +451,7 @@ again:
size = MAXBSIZE * nbuf;
if (uvm_map(kernel_map, (vm_offset_t *) &buffers, round_page(size),
NULL, UVM_UNKNOWN_OFFSET, 0, UVM_MAPFLAG(UVM_PROT_NONE,
- UVM_PROT_NONE, UVM_INH_NONE, UVM_ADV_NORMAL, 0)) != KERN_SUCCESS)
+ UVM_PROT_NONE, UVM_INH_NONE, UVM_ADV_NORMAL, 0)))
panic("startup: cannot allocate VM for buffers");
minaddr = (vm_offset_t)buffers;
base = bufpages / nbuf;
diff --git a/sys/arch/mac68k/mac68k/pmap.c b/sys/arch/mac68k/mac68k/pmap.c
index 299f88522b1..9afba2e761c 100644
--- a/sys/arch/mac68k/mac68k/pmap.c
+++ b/sys/arch/mac68k/mac68k/pmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.c,v 1.31 2001/11/07 01:18:00 art Exp $ */
+/* $OpenBSD: pmap.c,v 1.32 2001/11/28 13:47:38 art Exp $ */
/* $NetBSD: pmap.c,v 1.55 1999/04/22 04:24:53 chs Exp $ */
/*
@@ -341,14 +341,14 @@ pmap_init()
NULL, UVM_UNKNOWN_OFFSET, 0,
UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE,
UVM_INH_NONE, UVM_ADV_RANDOM,
- UVM_FLAG_FIXED)) != KERN_SUCCESS)
+ UVM_FLAG_FIXED)))
goto bogons;
addr = (vaddr_t)Sysmap;
if (uvm_map(kernel_map, &addr, MAC_MAX_PTSIZE,
NULL, UVM_UNKNOWN_OFFSET, 0,
UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE,
UVM_INH_NONE, UVM_ADV_RANDOM,
- UVM_FLAG_FIXED)) != KERN_SUCCESS) {
+ UVM_FLAG_FIXED))) {
/*
* If this fails, it is probably because the static
* portion of the kernel page table isn't big enough
@@ -422,11 +422,9 @@ pmap_init()
rv = uvm_map(kernel_map, &addr, s, NULL, UVM_UNKNOWN_OFFSET, 0,
UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE,
UVM_ADV_RANDOM, UVM_FLAG_NOMERGE));
- if (rv != KERN_SUCCESS || (addr + s) >= (vaddr_t)Sysmap)
+ if (rv || (addr + s) >= (vaddr_t)Sysmap)
panic("pmap_init: kernel PT too small");
- rv = uvm_unmap(kernel_map, addr, addr + s);
- if (rv != KERN_SUCCESS)
- panic("pmap_init: uvm_unmap failed");
+ uvm_unmap(kernel_map, addr, addr + s);
/*
* Now allocate the space and link the pages together to
@@ -1259,7 +1257,7 @@ validate:
pmap_check_wiring("enter", trunc_page((vaddr_t)pmap_pte(pmap, va)));
#endif
- return (KERN_SUCCESS);
+ return (0);
}
/*
@@ -2210,7 +2208,7 @@ pmap_enter_ptpage(pmap, va)
PMAP_DPRINTF(PDB_ENTER|PDB_PTPAGE,
("enter: about to fault UPT pg at %lx\n", va));
s = uvm_fault(pt_map, va, 0, VM_PROT_READ|VM_PROT_WRITE);
- if (s != KERN_SUCCESS) {
+ if (s) {
printf("uvm_fault(pt_map, 0x%lx, 0, RW) -> %d\n",
va, s);
panic("pmap_enter: uvm_fault failed");
diff --git a/sys/arch/mac68k/mac68k/trap.c b/sys/arch/mac68k/mac68k/trap.c
index f9dc6019bbc..d2a1a125409 100644
--- a/sys/arch/mac68k/mac68k/trap.c
+++ b/sys/arch/mac68k/mac68k/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.31 2001/11/25 17:15:20 miod Exp $ */
+/* $OpenBSD: trap.c,v 1.32 2001/11/28 13:47:38 art Exp $ */
/* $NetBSD: trap.c,v 1.68 1998/12/22 08:47:07 scottr Exp $ */
/*
@@ -621,16 +621,16 @@ copyfault:
*/
if ((vm != NULL && (caddr_t)va >= vm->vm_maxsaddr)
&& map != kernel_map) {
- if (rv == KERN_SUCCESS) {
+ if (rv == 0) {
u_int nss;
nss = btoc(USRSTACK-(unsigned)va);
if (nss > vm->vm_ssize)
vm->vm_ssize = nss;
- } else if (rv == KERN_PROTECTION_FAILURE)
- rv = KERN_INVALID_ADDRESS;
+ } else if (rv == EACCES)
+ rv = EFAULT;
}
- if (rv == KERN_SUCCESS) {
+ if (rv == 0) {
if (type == T_MMUFLT) {
#if defined(M68040)
if (mmutype == MMU_68040)
diff --git a/sys/arch/macppc/macppc/machdep.c b/sys/arch/macppc/macppc/machdep.c
index 5783956e11c..a97eb2621f2 100644
--- a/sys/arch/macppc/macppc/machdep.c
+++ b/sys/arch/macppc/macppc/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.15 2001/11/19 00:48:01 drahn Exp $ */
+/* $OpenBSD: machdep.c,v 1.16 2001/11/28 13:47:38 art Exp $ */
/* $NetBSD: machdep.c,v 1.4 1996/10/16 19:33:11 ws Exp $ */
/*
@@ -553,7 +553,7 @@ cpu_startup()
if (uvm_map(kernel_map, (vaddr_t *) &buffers, round_page(sz),
NULL, UVM_UNKNOWN_OFFSET, 0,
UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE,
- UVM_ADV_NORMAL, 0)) != KERN_SUCCESS)
+ UVM_ADV_NORMAL, 0)))
panic("cpu_startup: cannot allocate VM for buffers");
/*
addr = (vaddr_t)buffers;
diff --git a/sys/arch/mvme68k/mvme68k/machdep.c b/sys/arch/mvme68k/mvme68k/machdep.c
index c8002d34884..cf3c51eebd0 100644
--- a/sys/arch/mvme68k/mvme68k/machdep.c
+++ b/sys/arch/mvme68k/mvme68k/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.56 2001/11/24 17:53:41 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.57 2001/11/28 13:47:38 art Exp $ */
/*
* Copyright (c) 1995 Theo de Raadt
@@ -343,7 +343,7 @@ again:
if (uvm_map(kernel_map, (vaddr_t *) &buffers, m68k_round_page(size),
NULL, UVM_UNKNOWN_OFFSET, 0,
UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE,
- UVM_ADV_NORMAL, 0)) != KERN_SUCCESS)
+ UVM_ADV_NORMAL, 0)))
panic("cpu_startup: cannot allocate VM for buffers");
minaddr = (vaddr_t)buffers;
diff --git a/sys/arch/mvme68k/mvme68k/pmap.c b/sys/arch/mvme68k/mvme68k/pmap.c
index ce7cd076711..690b73789b7 100644
--- a/sys/arch/mvme68k/mvme68k/pmap.c
+++ b/sys/arch/mvme68k/mvme68k/pmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.c,v 1.30 2001/11/07 01:18:00 art Exp $ */
+/* $OpenBSD: pmap.c,v 1.31 2001/11/28 13:47:38 art Exp $ */
/*
* Copyright (c) 1995 Theo de Raadt
@@ -349,14 +349,14 @@ pmap_init()
NULL, UVM_UNKNOWN_OFFSET, 0,
UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE,
UVM_INH_NONE, UVM_ADV_RANDOM,
- UVM_FLAG_FIXED)) != KERN_SUCCESS)
+ UVM_FLAG_FIXED)))
goto bogons;
addr = (vaddr_t) Sysmap;
if (uvm_map(kernel_map, &addr, M68K_MAX_PTSIZE,
NULL, UVM_UNKNOWN_OFFSET, 0,
UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE,
UVM_INH_NONE, UVM_ADV_RANDOM,
- UVM_FLAG_FIXED)) != KERN_SUCCESS) {
+ UVM_FLAG_FIXED))) {
/*
* If this fails, it is probably because the static
* portion of the kernel page table isn't big enough
@@ -446,11 +446,9 @@ pmap_init()
rv = uvm_map(kernel_map, &addr, s, NULL, UVM_UNKNOWN_OFFSET, 0,
UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE,
UVM_ADV_RANDOM, UVM_FLAG_NOMERGE));
- if (rv != KERN_SUCCESS || (addr + s) >= (vaddr_t)Sysmap)
+ if (rv || (addr + s) >= (vaddr_t)Sysmap)
panic("pmap_init: kernel PT too small");
- rv = uvm_unmap(kernel_map, addr, addr + s);
- if (rv != KERN_SUCCESS)
- panic("pmap_init: uvm_unmap failed");
+ uvm_unmap(kernel_map, addr, addr + s);
/*
* Now allocate the space and link the pages together to
@@ -1232,7 +1230,7 @@ validate:
pmap_check_wiring("enter", trunc_page(pmap_pte(pmap, va)));
#endif
- return (KERN_SUCCESS);
+ return (0);
}
/*
@@ -1689,9 +1687,9 @@ pmap_mapmulti(pmap, va)
if (*ste == SG_NV && (*bste & SG_V)) {
*ste = *bste;
TBIAU();
- return (KERN_SUCCESS);
+ return (0);
}
- return (KERN_INVALID_ADDRESS);
+ return (EFAULT);
}
#endif
@@ -2225,8 +2223,7 @@ pmap_enter_ptpage(pmap, va)
printf("enter: about to fault UPT pg at %x\n", va);
#endif
if (uvm_fault_wire(pt_map, va, va + PAGE_SIZE,
- VM_PROT_READ|VM_PROT_WRITE)
- != KERN_SUCCESS)
+ VM_PROT_READ|VM_PROT_WRITE))
panic("pmap_enter: uvm_fault failed");
pmap_extract(pmap_kernel(), va, &ptpa);
}
diff --git a/sys/arch/mvme68k/mvme68k/trap.c b/sys/arch/mvme68k/mvme68k/trap.c
index be45d95f887..456c7a83efb 100644
--- a/sys/arch/mvme68k/mvme68k/trap.c
+++ b/sys/arch/mvme68k/mvme68k/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.38 2001/11/25 17:15:20 miod Exp $ */
+/* $OpenBSD: trap.c,v 1.39 2001/11/28 13:47:38 art Exp $ */
/*
* Copyright (c) 1995 Theo de Raadt
@@ -580,10 +580,10 @@ copyfault:
vm_offset_t bva;
rv = pmap_mapmulti(map->pmap, va);
- if (rv != KERN_SUCCESS) {
+ if (rv) {
bva = HPMMBASEADDR(va);
rv = uvm_fault(map, bva, 0, ftype);
- if (rv == KERN_SUCCESS)
+ if (rv == 0)
(void) pmap_mapmulti(map->pmap, va);
}
} else
@@ -602,16 +602,16 @@ copyfault:
* error.
*/
if ((caddr_t)va >= vm->vm_maxsaddr && map != kernel_map) {
- if (rv == KERN_SUCCESS) {
+ if (rv == 0) {
unsigned nss;
nss = btoc(USRSTACK-(unsigned)va);
if (nss > vm->vm_ssize)
vm->vm_ssize = nss;
- } else if (rv == KERN_PROTECTION_FAILURE)
- rv = KERN_INVALID_ADDRESS;
+ } else if (rv == EACCES)
+ rv = EFAULT;
}
- if (rv == KERN_SUCCESS) {
+ if (rv == 0) {
if (type == T_MMUFLT) {
#if defined(M68040)
if (mmutype == MMU_68040)
diff --git a/sys/arch/mvme88k/mvme88k/machdep.c b/sys/arch/mvme88k/mvme88k/machdep.c
index ee7bd51bebf..1ae80a69a31 100644
--- a/sys/arch/mvme88k/mvme88k/machdep.c
+++ b/sys/arch/mvme88k/mvme88k/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.65 2001/11/27 05:26:36 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.66 2001/11/28 13:47:38 art Exp $ */
/*
* Copyright (c) 1998, 1999, 2000, 2001 Steve Murphree, Jr.
* Copyright (c) 1996 Nivas Madhur
@@ -597,7 +597,7 @@ cpu_startup()
if (uvm_map(kernel_map, (vaddr_t *) &buffers, round_page(size),
NULL, UVM_UNKNOWN_OFFSET, 0,
UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE,
- UVM_ADV_NORMAL, 0)) != KERN_SUCCESS)
+ UVM_ADV_NORMAL, 0)))
panic("cpu_startup: cannot allocate VM for buffers");
minaddr = (vaddr_t)buffers;
diff --git a/sys/arch/mvme88k/mvme88k/pmap.c b/sys/arch/mvme88k/mvme88k/pmap.c
index 535b9a854c1..43656667f40 100644
--- a/sys/arch/mvme88k/mvme88k/pmap.c
+++ b/sys/arch/mvme88k/mvme88k/pmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.c,v 1.45 2001/11/27 05:39:02 miod Exp $ */
+/* $OpenBSD: pmap.c,v 1.46 2001/11/28 13:47:38 art Exp $ */
/*
* Copyright (c) 1996 Nivas Madhur
* All rights reserved.
@@ -2769,7 +2769,7 @@ Retry:
if (pv_e != PV_ENTRY_NULL)
pool_put(&pvpool, pv_e);
- return (KERN_SUCCESS);
+ return (0);
} /* pmap_enter */
/*
diff --git a/sys/arch/mvme88k/mvme88k/trap.c b/sys/arch/mvme88k/mvme88k/trap.c
index 0cad1b68667..f91611face1 100644
--- a/sys/arch/mvme88k/mvme88k/trap.c
+++ b/sys/arch/mvme88k/mvme88k/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.25 2001/11/07 22:32:29 miod Exp $ */
+/* $OpenBSD: trap.c,v 1.26 2001/11/28 13:47:39 art Exp $ */
/*
* Copyright (c) 1998 Steve Murphree, Jr.
* Copyright (c) 1996 Nivas Madhur
@@ -404,7 +404,7 @@ trap18x(unsigned type, struct m88100_saved_state *frame)
if ((frame->dpfsr >> 16 & 0x7) == 0x4 /* seg fault */
|| (frame->dpfsr >> 16 & 0x7) == 0x5) { /* page fault */
result = uvm_fault(map, va, 0, ftype);
- if (result == KERN_SUCCESS) {
+ if (result == 0) {
/*
* We could resolve the fault. Call
* data_access_emulation to drain the data unit pipe
@@ -494,15 +494,15 @@ outtahere:
}
if ((caddr_t)va >= vm->vm_maxsaddr) {
- if (result == KERN_SUCCESS) {
+ if (result == 0) {
nss = btoc(USRSTACK - va);/* XXX check this */
if (nss > vm->vm_ssize)
vm->vm_ssize = nss;
- } else if (result == KERN_PROTECTION_FAILURE)
- result = KERN_INVALID_ADDRESS;
+ } else if (result == EACCES)
+ result = EFAULT;
}
- if (result == KERN_SUCCESS) {
+ if (result == 0) {
if (type == T_DATAFLT+T_USER) {
/*
* We could resolve the fault. Call
@@ -519,9 +519,9 @@ outtahere:
frame->snip = frame->sxip & ~NIP_E;
}
} else {
- sig = result == KERN_PROTECTION_FAILURE ?
+ sig = result == EACCES ?
SIGBUS : SIGSEGV;
- fault_type = result == KERN_PROTECTION_FAILURE ?
+ fault_type = result == EACCES ?
BUS_ADRERR : SEGV_MAPERR;
}
break;
@@ -965,7 +965,7 @@ trap197(unsigned type, struct m88100_saved_state *frame)
if ((frame->dsr & CMMU_DSR_SI) /* seg fault */
|| (frame->dsr & CMMU_DSR_PI)) { /* page fault */
result = uvm_fault(map, va, 0, ftype);
- if (result == KERN_SUCCESS) {
+ if (result == 0) {
return;
}
}
@@ -973,7 +973,7 @@ trap197(unsigned type, struct m88100_saved_state *frame)
if ((frame->isr & CMMU_ISR_SI) /* seg fault */
|| (frame->isr & CMMU_ISR_PI)) { /* page fault */
result = uvm_fault(map, va, 0, ftype);
- if (result == KERN_SUCCESS) {
+ if (result == 0) {
return;
}
}
@@ -1018,7 +1018,7 @@ trap197(unsigned type, struct m88100_saved_state *frame)
if ((frame->dsr & CMMU_DSR_SI) /* seg fault */
|| (frame->dsr & CMMU_DSR_PI)) { /* page fault */
result = uvm_fault(map, va, 0, ftype);
- if (result == KERN_SUCCESS) {
+ if (result == 0) {
return;
}
}
@@ -1026,24 +1026,24 @@ trap197(unsigned type, struct m88100_saved_state *frame)
if ((frame->isr & CMMU_ISR_SI) /* seg fault */
|| (frame->isr & CMMU_ISR_PI)) { /* page fault */
result = uvm_fault(map, va, 0, ftype);
- if (result == KERN_SUCCESS) {
+ if (result == 0) {
return;
}
}
}
if ((caddr_t)va >= vm->vm_maxsaddr) {
- if (result == KERN_SUCCESS) {
+ if (result == 0) {
nss = btoc(USRSTACK - va);/* XXX check this */
if (nss > vm->vm_ssize)
vm->vm_ssize = nss;
- } else if (result == KERN_PROTECTION_FAILURE)
- result = KERN_INVALID_ADDRESS;
+ } else if (result == EACCES)
+ result = EFAULT;
}
- if (result != KERN_SUCCESS) {
- sig = result == KERN_PROTECTION_FAILURE ? SIGBUS : SIGSEGV;
- fault_type = result == KERN_PROTECTION_FAILURE ? BUS_ADRERR
+ if (result != 0) {
+ sig = result == EACCES ? SIGBUS : SIGSEGV;
+ fault_type = result == EACCES ? BUS_ADRERR
: SEGV_MAPERR;
} else {
return;
diff --git a/sys/arch/mvmeppc/mvmeppc/machdep.c b/sys/arch/mvmeppc/mvmeppc/machdep.c
index 29c35532a62..893c9dcd0ff 100644
--- a/sys/arch/mvmeppc/mvmeppc/machdep.c
+++ b/sys/arch/mvmeppc/mvmeppc/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.14 2001/11/09 15:25:55 art Exp $ */
+/* $OpenBSD: machdep.c,v 1.15 2001/11/28 13:47:39 art Exp $ */
/* $NetBSD: machdep.c,v 1.4 1996/10/16 19:33:11 ws Exp $ */
/*
@@ -522,7 +522,7 @@ cpu_startup()
if (uvm_map(kernel_map, (vaddr_t *) &buffers, round_page(sz),
NULL, UVM_UNKNOWN_OFFSET, 0,
UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE,
- UVM_ADV_NORMAL, 0)) != KERN_SUCCESS)
+ UVM_ADV_NORMAL, 0)))
panic("cpu_startup: cannot allocate VM for buffers");
/*
addr = (vaddr_t)buffers;
diff --git a/sys/arch/powerpc/powerpc/pmap.c b/sys/arch/powerpc/powerpc/pmap.c
index 3075bc124c4..57e61abfe98 100644
--- a/sys/arch/powerpc/powerpc/pmap.c
+++ b/sys/arch/powerpc/powerpc/pmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.c,v 1.47 2001/11/06 19:53:16 miod Exp $ */
+/* $OpenBSD: pmap.c,v 1.48 2001/11/28 13:47:39 art Exp $ */
/* $NetBSD: pmap.c,v 1.1 1996/09/30 16:34:52 ws Exp $ */
/*
@@ -1275,7 +1275,7 @@ pmap_enter_c_pv(pm, va, pa, prot, flags, cacheable, pv)
*/
if (pte_insert(idx, &pte)) {
splx(s);
- return (KERN_SUCCESS);
+ return (0);
}
/*
@@ -1288,7 +1288,7 @@ pmap_enter_c_pv(pm, va, pa, prot, flags, cacheable, pv)
LIST_INSERT_HEAD(potable + idx, po, po_list);
splx(s);
- return (KERN_SUCCESS);
+ return (0);
}
#define KERN_MAP_PV TRUE
diff --git a/sys/arch/powerpc/powerpc/trap.c b/sys/arch/powerpc/powerpc/trap.c
index 59fad7edbca..51d8d951118 100644
--- a/sys/arch/powerpc/powerpc/trap.c
+++ b/sys/arch/powerpc/powerpc/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.38 2001/11/13 14:31:52 drahn Exp $ */
+/* $OpenBSD: trap.c,v 1.39 2001/11/28 13:47:39 art Exp $ */
/* $NetBSD: trap.c,v 1.3 1996/10/13 03:31:37 christos Exp $ */
/*
@@ -290,9 +290,7 @@ trap(frame)
ftype = VM_PROT_READ | VM_PROT_WRITE;
else
ftype = VM_PROT_READ;
- if (uvm_fault(map, trunc_page(va), 0, ftype)
- == KERN_SUCCESS)
- {
+ if (uvm_fault(map, trunc_page(va), 0, ftype) == 0) {
return;
}
if ((fb = p->p_addr->u_pcb.pcb_onfault)) {
@@ -318,8 +316,7 @@ printf("kern dsi on addr %x iar %x\n", frame->dar, frame->srr0);
} else
vftype = ftype = VM_PROT_READ;
if (uvm_fault(&p->p_vmspace->vm_map,
- trunc_page(frame->dar), 0, ftype)
- == KERN_SUCCESS) {
+ trunc_page(frame->dar), 0, ftype) == 0) {
break;
}
#if 0
@@ -338,8 +335,7 @@ printf("dsi on addr %x iar %x lr %x\n", frame->dar, frame->srr0,frame->lr);
ftype = VM_PROT_READ | VM_PROT_EXECUTE;
if (uvm_fault(&p->p_vmspace->vm_map,
- trunc_page(frame->srr0), 0, ftype)
- == KERN_SUCCESS) {
+ trunc_page(frame->srr0), 0, ftype)) {
break;
}
}
diff --git a/sys/arch/sparc/sparc/machdep.c b/sys/arch/sparc/sparc/machdep.c
index 26afa435d6d..8f1a7991c25 100644
--- a/sys/arch/sparc/sparc/machdep.c
+++ b/sys/arch/sparc/sparc/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.71 2001/11/24 17:53:41 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.72 2001/11/28 13:47:39 art Exp $ */
/* $NetBSD: machdep.c,v 1.85 1997/09/12 08:55:02 pk Exp $ */
/*
@@ -209,7 +209,7 @@ cpu_startup()
if (uvm_map(kernel_map, (vaddr_t *) &buffers, round_page(size),
NULL, UVM_UNKNOWN_OFFSET, 0,
UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE,
- UVM_ADV_NORMAL, 0)) != KERN_SUCCESS)
+ UVM_ADV_NORMAL, 0)))
panic("cpu_startup: cannot allocate VM for buffers");
minaddr = (vaddr_t) buffers;
diff --git a/sys/arch/sparc/sparc/pmap.c b/sys/arch/sparc/sparc/pmap.c
index 889f56b381a..ccd9ac4597c 100644
--- a/sys/arch/sparc/sparc/pmap.c
+++ b/sys/arch/sparc/sparc/pmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.c,v 1.97 2001/11/22 09:54:04 art Exp $ */
+/* $OpenBSD: pmap.c,v 1.98 2001/11/28 13:47:39 art Exp $ */
/* $NetBSD: pmap.c,v 1.118 1998/05/19 19:00:18 thorpej Exp $ */
/*
@@ -4883,7 +4883,7 @@ pmap_enter4_4c(pm, va, pa, prot, flags)
printf("pmap_enter: pm %p, va 0x%lx, pa 0x%lx: in MMU hole\n",
pm, va, pa);
#endif
- return (KERN_FAILURE);
+ return (EINVAL);
}
#ifdef DEBUG
@@ -4914,7 +4914,7 @@ pmap_enter4_4c(pm, va, pa, prot, flags)
else
ret = pmap_enu4_4c(pm, va, prot, flags, pv, pteproto);
#ifdef DIAGNOSTIC
- if ((flags & PMAP_CANFAIL) == 0 && ret != KERN_SUCCESS)
+ if ((flags & PMAP_CANFAIL) == 0 && ret)
panic("pmap_enter4_4c: can't fail, but did");
#endif
setcontext4(ctx);
@@ -4968,7 +4968,7 @@ pmap_enk4_4c(pm, va, prot, flags, pv, pteproto)
/* just changing protection and/or wiring */
splx(s);
pmap_changeprot4_4c(pm, va, prot, wired);
- return (KERN_SUCCESS);
+ return (0);
}
if ((tpte & PG_TYPE) == PG_OBMEM) {
@@ -5042,7 +5042,7 @@ pmap_enk4_4c(pm, va, prot, flags, pv, pteproto)
setpte4(va, pteproto);
splx(s);
- return (KERN_SUCCESS);
+ return (0);
}
/* enter new (or change existing) user mapping */
@@ -5092,7 +5092,7 @@ pmap_enu4_4c(pm, va, prot, flags, pv, pteproto)
sp = malloc((u_long)size, M_VMPMAP, M_NOWAIT);
if (sp == NULL)
- return (KERN_RESOURCE_SHORTAGE);
+ return (ENOMEM);
qzero((caddr_t)sp, size);
rp->rg_segmap = sp;
rp->rg_nsegmap = 0;
@@ -5107,7 +5107,7 @@ pmap_enu4_4c(pm, va, prot, flags, pv, pteproto)
pte = malloc((u_long)size, M_VMPMAP, M_NOWAIT);
if (pte == NULL)
- return (KERN_RESOURCE_SHORTAGE);
+ return (ENOMEM);
#ifdef DEBUG
if (sp->sg_pmeg != seginval)
panic("pmap_enter: new ptes, but not seginval");
@@ -5149,7 +5149,7 @@ pmap_enu4_4c(pm, va, prot, flags, pv, pteproto)
pm->pm_stats.wired_count++;
else
pm->pm_stats.wired_count--;
- return (KERN_SUCCESS);
+ return (0);
}
/*
* Switcheroo: changing pa for this va.
@@ -5203,7 +5203,7 @@ pmap_enu4_4c(pm, va, prot, flags, pv, pteproto)
splx(s);
- return (KERN_SUCCESS);
+ return (0);
}
void
@@ -5309,7 +5309,7 @@ pmap_enter4m(pm, va, pa, prot, flags)
else
ret = pmap_enu4m(pm, va, prot, flags, pv, pteproto);
#ifdef DIAGNOSTIC
- if ((flags & PMAP_CANFAIL) == 0 && ret != KERN_SUCCESS)
+ if ((flags & PMAP_CANFAIL) == 0 && ret != 0)
panic("pmap_enter4_4c: can't fail, but did");
#endif
if (pv) {
@@ -5362,7 +5362,7 @@ pmap_enk4m(pm, va, prot, flags, pv, pteproto)
/* just changing protection and/or wiring */
splx(s);
pmap_changeprot4m(pm, va, prot, wired);
- return (KERN_SUCCESS);
+ return (0);
}
if ((tpte & SRMMU_PGTYPE) == PG_SUN4M_OBMEM) {
@@ -5399,7 +5399,7 @@ pmap_enk4m(pm, va, prot, flags, pv, pteproto)
splx(s);
- return (KERN_SUCCESS);
+ return (0);
}
/* enter new (or change existing) user mapping */
@@ -5433,7 +5433,7 @@ pmap_enu4m(pm, va, prot, flags, pv, pteproto)
sp = malloc((u_long)size, M_VMPMAP, M_NOWAIT);
if (sp == NULL)
- return (KERN_RESOURCE_SHORTAGE);
+ return (ENOMEM);
qzero((caddr_t)sp, size);
rp->rg_segmap = sp;
rp->rg_nsegmap = 0;
@@ -5446,7 +5446,7 @@ pmap_enu4m(pm, va, prot, flags, pv, pteproto)
ptd = pool_get(&L23_pool, PR_NOWAIT);
if (ptd == NULL)
- return (KERN_RESOURCE_SHORTAGE);
+ return (ENOMEM);
rp->rg_seg_ptps = ptd;
for (i = 0; i < SRMMU_L2SIZE; i++)
@@ -5462,7 +5462,7 @@ pmap_enu4m(pm, va, prot, flags, pv, pteproto)
pte = pool_get(&L23_pool, PR_NOWAIT);
if (pte == NULL)
- return (KERN_RESOURCE_SHORTAGE);
+ return (ENOMEM);
sp->sg_pte = pte;
sp->sg_npte = 1;
@@ -5491,7 +5491,7 @@ pmap_enu4m(pm, va, prot, flags, pv, pteproto)
pm->pm_stats.wired_count++;
else
pm->pm_stats.wired_count--;
- return (KERN_SUCCESS);
+ return (0);
}
/*
* Switcheroo: changing pa for this va.
@@ -5533,7 +5533,7 @@ pmap_enu4m(pm, va, prot, flags, pv, pteproto)
splx(s);
- return (KERN_SUCCESS);
+ return (0);
}
void
diff --git a/sys/arch/sparc/sparc/trap.c b/sys/arch/sparc/sparc/trap.c
index 98a6ca5f0cb..22ed3032786 100644
--- a/sys/arch/sparc/sparc/trap.c
+++ b/sys/arch/sparc/sparc/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.34 2001/11/06 21:33:53 mickey Exp $ */
+/* $OpenBSD: trap.c,v 1.35 2001/11/28 13:47:39 art Exp $ */
/* $NetBSD: trap.c,v 1.58 1997/09/12 08:55:01 pk Exp $ */
/*
@@ -695,7 +695,7 @@ mem_access_fault(type, ser, v, pc, psr, tf)
if (cold)
goto kfault;
if (va >= KERNBASE) {
- if (uvm_fault(kernel_map, va, 0, ftype) == KERN_SUCCESS)
+ if (uvm_fault(kernel_map, va, 0, ftype) == 0)
return;
goto kfault;
}
@@ -726,14 +726,14 @@ mem_access_fault(type, ser, v, pc, psr, tf)
* error.
*/
if ((caddr_t)va >= vm->vm_maxsaddr) {
- if (rv == KERN_SUCCESS) {
+ if (rv == 0) {
unsigned nss = btoc(USRSTACK - va);
if (nss > vm->vm_ssize)
vm->vm_ssize = nss;
- } else if (rv == KERN_PROTECTION_FAILURE)
- rv = KERN_INVALID_ADDRESS;
+ } else if (rv == EACCES)
+ rv = EFAULT;
}
- if (rv == KERN_SUCCESS) {
+ if (rv == 0) {
/*
* pmap_enter() does not enter all requests made from
* vm_fault into the MMU (as that causes unnecessary
@@ -899,7 +899,7 @@ mem_access_fault4m(type, sfsr, sfva, tf)
*/
if (mmumod == SUN4M_MMU_HS) { /* On HS, we have va for both */
if (vm_fault(kernel_map, trunc_page(pc),
- VM_PROT_READ, 0) != KERN_SUCCESS)
+ VM_PROT_READ, 0))
#ifdef DEBUG
printf("mem_access_fault: "
"can't pagein 1st text fault.\n")
@@ -935,7 +935,7 @@ mem_access_fault4m(type, sfsr, sfva, tf)
if (cold)
goto kfault;
if (va >= KERNBASE) {
- if (uvm_fault(kernel_map, va, 0, ftype) == KERN_SUCCESS)
+ if (uvm_fault(kernel_map, va, 0, ftype) == 0)
return;
goto kfault;
}
@@ -954,14 +954,14 @@ mem_access_fault4m(type, sfsr, sfva, tf)
* error.
*/
if ((caddr_t)va >= vm->vm_maxsaddr) {
- if (rv == KERN_SUCCESS) {
+ if (rv == 0) {
unsigned nss = btoc(USRSTACK - va);
if (nss > vm->vm_ssize)
vm->vm_ssize = nss;
- } else if (rv == KERN_PROTECTION_FAILURE)
- rv = KERN_INVALID_ADDRESS;
+ } else if (rv == EACCES)
+ rv = EFAULT;
}
- if (rv != KERN_SUCCESS) {
+ if (rv != 0) {
/*
* Pagein failed. If doing copyin/out, return to onfault
* address. Any other page fault in kernel, die; if user
diff --git a/sys/arch/sparc/sparc/vm_machdep.c b/sys/arch/sparc/sparc/vm_machdep.c
index ba9db25a4cc..2856d3b0d60 100644
--- a/sys/arch/sparc/sparc/vm_machdep.c
+++ b/sys/arch/sparc/sparc/vm_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm_machdep.c,v 1.36 2001/11/22 09:49:43 art Exp $ */
+/* $OpenBSD: vm_machdep.c,v 1.37 2001/11/28 13:47:39 art Exp $ */
/* $NetBSD: vm_machdep.c,v 1.30 1997/03/10 23:55:40 pk Exp $ */
/*
@@ -314,7 +314,7 @@ vmapbuf(bp, sz)
kva = vm_map_min(kernel_map);
if (uvm_map(kernel_map, &kva, size, NULL, uva, 0,
UVM_MAPFLAG(UVM_PROT_ALL, UVM_PROT_ALL,
- UVM_INH_NONE, UVM_ADV_RANDOM, 0)) == KERN_SUCCESS)
+ UVM_INH_NONE, UVM_ADV_RANDOM, 0)) == 0)
break;
tsleep(kernel_map, PVM, "vallocwait", 0);
}
diff --git a/sys/arch/sparc64/sparc64/trap.c b/sys/arch/sparc64/sparc64/trap.c
index 79696d2a636..42ffab991e8 100644
--- a/sys/arch/sparc64/sparc64/trap.c
+++ b/sys/arch/sparc64/sparc64/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.13 2001/11/06 19:53:16 miod Exp $ */
+/* $OpenBSD: trap.c,v 1.14 2001/11/28 13:47:39 art Exp $ */
/* $NetBSD: trap.c,v 1.73 2001/08/09 01:03:01 eeh Exp $ */
/*
@@ -856,8 +856,8 @@ data_access_fault(tf, type, pc, addr, sfva, sfsr)
segsz_t nss = btoc(USRSTACK - va);
if (nss > vm->vm_ssize)
vm->vm_ssize = nss;
- } else if (rv == KERN_PROTECTION_FAILURE)
- rv = KERN_INVALID_ADDRESS;
+ } else if (rv == EACCES)
+ rv = EFAULT;
}
if (rv != 0) {
/*
@@ -882,7 +882,7 @@ kfault:
tf->tf_npc = onfault + 4;
return;
}
- if (rv == KERN_RESOURCE_SHORTAGE) {
+ if (rv == ENOMEM) {
printf("UVM: pid %d (%s), uid %d killed: out of swap\n",
p->p_pid, p->p_comm,
p->p_cred && p->p_ucred ?
@@ -1035,8 +1035,8 @@ text_access_fault(tf, type, pc, sfsr)
segsz_t nss = btoc(USRSTACK - va);
if (nss > vm->vm_ssize)
vm->vm_ssize = nss;
- } else if (rv == KERN_PROTECTION_FAILURE)
- rv = KERN_INVALID_ADDRESS;
+ } else if (rv == EACCES)
+ rv = EFAULT;
}
if (rv != 0) {
/*
@@ -1129,7 +1129,7 @@ text_access_error(tf, type, pc, sfsr, afva, afsr)
vm = p->p_vmspace;
/* alas! must call the horrible vm code */
- rv = uvm_fault(&vm->vm_map, (vaddr_t)va, 0, access_type);
+ rv = uvm_fault(&vm->vm_map, va, 0, access_type);
/*
* If this was a stack access we keep track of the maximum
@@ -1143,8 +1143,8 @@ text_access_error(tf, type, pc, sfsr, afva, afsr)
segsz_t nss = btoc(USRSTACK - va);
if (nss > vm->vm_ssize)
vm->vm_ssize = nss;
- } else if (rv == KERN_PROTECTION_FAILURE)
- rv = KERN_INVALID_ADDRESS;
+ } else if (rv == EACCES)
+ rv = EFAULT;
}
if (rv != 0) {
/*
diff --git a/sys/arch/sun3/sun3/machdep.c b/sys/arch/sun3/sun3/machdep.c
index c67efa1ab62..7979000eba5 100644
--- a/sys/arch/sun3/sun3/machdep.c
+++ b/sys/arch/sun3/sun3/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.44 2001/11/07 01:18:00 art Exp $ */
+/* $OpenBSD: machdep.c,v 1.45 2001/11/28 13:47:39 art Exp $ */
/* $NetBSD: machdep.c,v 1.77 1996/10/13 03:47:51 christos Exp $ */
/*
@@ -282,7 +282,7 @@ cpu_startup()
if (uvm_map(kernel_map, (vaddr_t *) &buffers, round_page(size),
NULL, UVM_UNKNOWN_OFFSET, 0,
UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE,
- UVM_ADV_NORMAL, 0)) != KERN_SUCCESS)
+ UVM_ADV_NORMAL, 0)))
panic("startup: cannot allocate buffers");
minaddr = (vm_offset_t)buffers;
if ((bufpages / nbuf) >= btoc(MAXBSIZE)) {
diff --git a/sys/arch/sun3/sun3/pmap.c b/sys/arch/sun3/sun3/pmap.c
index 999384d08b1..59261de8bac 100644
--- a/sys/arch/sun3/sun3/pmap.c
+++ b/sys/arch/sun3/sun3/pmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.c,v 1.31 2001/11/07 01:18:00 art Exp $ */
+/* $OpenBSD: pmap.c,v 1.32 2001/11/28 13:47:39 art Exp $ */
/* $NetBSD: pmap.c,v 1.64 1996/11/20 18:57:35 gwr Exp $ */
/*-
@@ -2507,7 +2507,7 @@ pmap_enter(pmap, va, pa, prot, flags)
}
PMAP_UNLOCK();
- return (KERN_SUCCESS);
+ return (0);
}
/*
diff --git a/sys/arch/sun3/sun3/trap.c b/sys/arch/sun3/sun3/trap.c
index 5b627ab8183..23b43ba8a6f 100644
--- a/sys/arch/sun3/sun3/trap.c
+++ b/sys/arch/sun3/sun3/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.29 2001/11/25 17:15:21 miod Exp $ */
+/* $OpenBSD: trap.c,v 1.30 2001/11/28 13:47:39 art Exp $ */
/* $NetBSD: trap.c,v 1.63-1.65ish 1997/01/16 15:41:40 gwr Exp $ */
/*
@@ -544,16 +544,16 @@ trap(type, code, v, frame)
* error.
*/
if ((map != kernel_map) && ((caddr_t)va >= vm->vm_maxsaddr)) {
- if (rv == KERN_SUCCESS) {
+ if (rv == 0) {
unsigned nss;
nss = btoc((u_int)(USRSTACK-va));
if (nss > vm->vm_ssize)
vm->vm_ssize = nss;
- } else if (rv == KERN_PROTECTION_FAILURE)
- rv = KERN_INVALID_ADDRESS;
+ } else if (rv == EACCES)
+ rv = EFAULT;
}
- if (rv == KERN_SUCCESS)
+ if (rv == 0)
goto finish;
if ((type & T_USER) == 0) {
diff --git a/sys/arch/vax/vax/machdep.c b/sys/arch/vax/vax/machdep.c
index e6d251700d9..f7ff70c87a6 100644
--- a/sys/arch/vax/vax/machdep.c
+++ b/sys/arch/vax/vax/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.45 2001/11/24 17:53:41 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.46 2001/11/28 13:47:39 art Exp $ */
/* $NetBSD: machdep.c,v 1.108 2000/09/13 15:00:23 thorpej Exp $ */
/*
@@ -213,7 +213,7 @@ cpu_startup()
if (uvm_map(kernel_map, (vm_offset_t *) &buffers, round_page(size),
NULL, UVM_UNKNOWN_OFFSET, 0,
UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE,
- UVM_ADV_NORMAL, 0)) != KERN_SUCCESS)
+ UVM_ADV_NORMAL, 0)))
panic("cpu_startup: cannot allocate VM for buffers");
minaddr = (vm_offset_t) buffers;
diff --git a/sys/arch/vax/vax/pmap.c b/sys/arch/vax/vax/pmap.c
index 0fc4b0947a3..2544cdbdbea 100644
--- a/sys/arch/vax/vax/pmap.c
+++ b/sys/arch/vax/vax/pmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.c,v 1.24 2001/11/17 05:07:55 hugh Exp $ */
+/* $OpenBSD: pmap.c,v 1.25 2001/11/28 13:47:39 art Exp $ */
/* $NetBSD: pmap.c,v 1.74 1999/11/13 21:32:25 matt Exp $ */
/*
* Copyright (c) 1994, 1998, 1999 Ludd, University of Lule}, Sweden.
@@ -722,7 +722,7 @@ if (startpmapdebug)
break;
if (flags & PMAP_CANFAIL) {
RECURSEEND;
- return (KERN_RESOURCE_SHORTAGE);
+ return (ENOMEM);
}
panic("pmap_enter: no free pages");
@@ -745,13 +745,13 @@ if (startpmapdebug)
if (newpte == (oldpte | PG_W)) {
patch[i] |= PG_W; /* Just wiring change */
RECURSEEND;
- return (KERN_SUCCESS);
+ return (0);
}
/* mapping unchanged? just return. */
if (newpte == oldpte) {
RECURSEEND;
- return (KERN_SUCCESS);
+ return (0);
}
/* Changing mapping? */
@@ -814,7 +814,7 @@ if (startpmapdebug)
more_pventries();
mtpr(0, PR_TBIA); /* Always; safety belt */
- return (KERN_SUCCESS);
+ return (0);
}
void *
diff --git a/sys/arch/vax/vax/trap.c b/sys/arch/vax/vax/trap.c
index 6046656fdbb..3de7399f7ee 100644
--- a/sys/arch/vax/vax/trap.c
+++ b/sys/arch/vax/vax/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.18 2001/11/06 23:57:54 miod Exp $ */
+/* $OpenBSD: trap.c,v 1.19 2001/11/28 13:47:39 art Exp $ */
/* $NetBSD: trap.c,v 1.47 1999/08/21 19:26:20 matt Exp $ */
/*
* Copyright (c) 1994 Ludd, University of Lule}, Sweden.
@@ -231,13 +231,13 @@ if(faultdebug)printf("trap accflt type %lx, code %lx, pc %lx, psl %lx\n",
ftype = VM_PROT_READ;
rv = uvm_fault(map, addr, 0, ftype);
- if (rv != KERN_SUCCESS) {
+ if (rv) {
if (umode == 0) {
FAULTCHK;
panic("Segv in kernel mode: pc %x addr %x",
(u_int)frame->pc, (u_int)frame->code);
}
- if (rv == KERN_RESOURCE_SHORTAGE) {
+ if (rv == ENOMEM) {
printf("UVM: pid %d (%s), uid %d killed: "
"out of swap\n",
p->p_pid, p->p_comm,
diff --git a/sys/compat/svr4/svr4_misc.c b/sys/compat/svr4/svr4_misc.c
index b47cae762f5..99d911bdcf1 100644
--- a/sys/compat/svr4/svr4_misc.c
+++ b/sys/compat/svr4/svr4_misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: svr4_misc.c,v 1.37 2001/11/07 01:18:01 art Exp $ */
+/* $OpenBSD: svr4_misc.c,v 1.38 2001/11/28 13:47:39 art Exp $ */
/* $NetBSD: svr4_misc.c,v 1.42 1996/12/06 03:22:34 christos Exp $ */
/*
@@ -654,7 +654,7 @@ svr4_sys_break(p, v, retval)
struct svr4_sys_break_args *uap = v;
register struct vmspace *vm = p->p_vmspace;
vaddr_t new, old;
- int rv;
+ int error;
register int diff;
old = (vaddr_t) vm->vm_daddr;
@@ -674,23 +674,19 @@ svr4_sys_break(p, v, retval)
DPRINTF(("break(3): old %lx new %lx diff %x\n", old, new, diff));
if (diff > 0) {
- rv = uvm_map(&vm->vm_map, &old, diff, NULL, UVM_UNKNOWN_OFFSET,
+ error = uvm_map(&vm->vm_map, &old, diff, NULL, UVM_UNKNOWN_OFFSET,
0, UVM_MAPFLAG(UVM_PROT_ALL, UVM_PROT_ALL, UVM_INH_COPY,
UVM_ADV_NORMAL,
UVM_FLAG_AMAPPAD|UVM_FLAG_FIXED|
UVM_FLAG_OVERLAY|UVM_FLAG_COPYONW));
- if (rv != KERN_SUCCESS) {
- uprintf("sbrk: grow failed, return = %d\n", rv);
- return ENOMEM;
+ if (error) {
+ uprintf("sbrk: grow failed, return = %d\n", error);
+ return error;
}
vm->vm_dsize += btoc(diff);
} else if (diff < 0) {
diff = -diff;
- rv = uvm_deallocate(&vm->vm_map, new, diff);
- if (rv != KERN_SUCCESS) {
- uprintf("sbrk: shrink failed, return = %d\n", rv);
- return ENOMEM;
- }
+ uvm_deallocate(&vm->vm_map, new, diff);
vm->vm_dsize -= btoc(diff);
}
return 0;
diff --git a/sys/compat/vax1k/vax1k_subr.c b/sys/compat/vax1k/vax1k_subr.c
index b272219cf7f..6164197cf6d 100644
--- a/sys/compat/vax1k/vax1k_subr.c
+++ b/sys/compat/vax1k/vax1k_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vax1k_subr.c,v 1.1 2001/11/14 14:37:22 hugh Exp $ */
+/* $OpenBSD: vax1k_subr.c,v 1.2 2001/11/28 13:47:39 art Exp $ */
/* $NetBSD: vax1k_subr.c,v 1.2 1999/03/24 05:51:20 mrg Exp $ */
/*
@@ -59,7 +59,7 @@ vax1k_map_readvn(p, cmd)
int error;
if (cmd->ev_len == 0)
- return(KERN_SUCCESS); /* XXXCDC: should it happen? */
+ return (0);
oaddr = cmd->ev_addr;
cmd->ev_addr = trunc_page(cmd->ev_addr); /* required by uvm_map */
@@ -90,7 +90,7 @@ vax1k_map_readvn(p, cmd)
trunc_page(cmd->ev_addr),
round_page(cmd->ev_addr + cmd->ev_len),
cmd->ev_prot, FALSE));
- } else {
- return(KERN_SUCCESS);
}
+
+ return (0);
}
diff --git a/sys/kern/exec_subr.c b/sys/kern/exec_subr.c
index e79db64dcae..1d816ded073 100644
--- a/sys/kern/exec_subr.c
+++ b/sys/kern/exec_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exec_subr.c,v 1.15 2001/11/27 05:27:11 art Exp $ */
+/* $OpenBSD: exec_subr.c,v 1.16 2001/11/28 13:47:39 art Exp $ */
/* $NetBSD: exec_subr.c,v 1.9 1994/12/04 03:10:42 mycroft Exp $ */
/*
@@ -138,14 +138,8 @@ vmcmd_map_pagedvn(p, cmd)
struct proc *p;
struct exec_vmcmd *cmd;
{
- /*
- * note that if you're going to map part of an process as being
- * paged from a vnode, that vnode had damn well better be marked as
- * VTEXT. that's handled in the routine which sets up the vmcmd to
- * call this routine.
- */
struct uvm_object *uobj;
- int retval;
+ int error;
/*
* map the vnode in using uvm_map.
@@ -173,24 +167,16 @@ vmcmd_map_pagedvn(p, cmd)
* do the map
*/
- retval = uvm_map(&p->p_vmspace->vm_map, &cmd->ev_addr, cmd->ev_len,
+ error = uvm_map(&p->p_vmspace->vm_map, &cmd->ev_addr, cmd->ev_len,
uobj, cmd->ev_offset, 0,
UVM_MAPFLAG(cmd->ev_prot, VM_PROT_ALL, UVM_INH_COPY,
UVM_ADV_NORMAL, UVM_FLAG_COPYONW|UVM_FLAG_FIXED));
- /*
- * check for error
- */
-
- if (retval == KERN_SUCCESS)
- return(0);
-
- /*
- * error: detach from object
- */
+ if (error) {
+ uobj->pgops->pgo_detach(uobj);
+ }
- uobj->pgops->pgo_detach(uobj);
- return(EINVAL);
+ return(error);
}
/*
@@ -207,7 +193,7 @@ vmcmd_map_readvn(p, cmd)
int error;
if (cmd->ev_len == 0)
- return(KERN_SUCCESS); /* XXXCDC: should it happen? */
+ return (0);
cmd->ev_addr = trunc_page(cmd->ev_addr); /* required by uvm_map */
error = uvm_map(&p->p_vmspace->vm_map, &cmd->ev_addr,
@@ -217,13 +203,13 @@ vmcmd_map_readvn(p, cmd)
UVM_FLAG_FIXED|UVM_FLAG_OVERLAY|UVM_FLAG_COPYONW));
if (error)
- return error;
+ return (error);
error = vn_rdwr(UIO_READ, cmd->ev_vp, (caddr_t)cmd->ev_addr,
cmd->ev_len, cmd->ev_offset, UIO_USERSPACE, IO_UNIT|IO_NODELOCKED,
p->p_ucred, NULL, p);
if (error)
- return error;
+ return (error);
if (cmd->ev_prot != (VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE)) {
/*
@@ -232,13 +218,12 @@ vmcmd_map_readvn(p, cmd)
* it mapped read-only, so now we are going to have to call
* uvm_map_protect() to fix up the protection. ICK.
*/
- return(uvm_map_protect(&p->p_vmspace->vm_map,
+ return (uvm_map_protect(&p->p_vmspace->vm_map,
trunc_page(cmd->ev_addr),
round_page(cmd->ev_addr + cmd->ev_len),
cmd->ev_prot, FALSE));
- } else {
- return(KERN_SUCCESS);
}
+ return (0);
}
/*
@@ -255,7 +240,7 @@ vmcmd_map_zero(p, cmd)
int error;
if (cmd->ev_len == 0)
- return(KERN_SUCCESS); /* XXXCDC: should it happen? */
+ return (0);
cmd->ev_addr = trunc_page(cmd->ev_addr); /* required by uvm_map */
error = uvm_map(&p->p_vmspace->vm_map, &cmd->ev_addr,
@@ -266,7 +251,7 @@ vmcmd_map_zero(p, cmd)
if (error)
return error;
- return(KERN_SUCCESS);
+ return (0);
}
/*
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c
index 800eb96aa08..4324fb9ece5 100644
--- a/sys/kern/init_main.c
+++ b/sys/kern/init_main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: init_main.c,v 1.86 2001/11/27 22:53:19 provos Exp $ */
+/* $OpenBSD: init_main.c,v 1.87 2001/11/28 13:47:39 art Exp $ */
/* $NetBSD: init_main.c,v 1.84.4.1 1996/06/02 09:08:06 mrg Exp $ */
/*
@@ -511,8 +511,7 @@ start_init(arg)
if (uvm_map(&p->p_vmspace->vm_map, &addr, PAGE_SIZE,
NULL, UVM_UNKNOWN_OFFSET, 0,
UVM_MAPFLAG(UVM_PROT_ALL, UVM_PROT_ALL, UVM_INH_COPY,
- UVM_ADV_NORMAL, UVM_FLAG_FIXED|UVM_FLAG_OVERLAY|UVM_FLAG_COPYONW))
- != KERN_SUCCESS)
+ UVM_ADV_NORMAL, UVM_FLAG_FIXED|UVM_FLAG_OVERLAY|UVM_FLAG_COPYONW)))
panic("init: couldn't allocate argument space");
#ifdef MACHINE_STACK_GROWS_UP
p->p_vmspace->vm_maxsaddr = (caddr_t)addr + PAGE_SIZE;
diff --git a/sys/kern/kern_physio.c b/sys/kern/kern_physio.c
index 6be92145c71..bd83546c9dd 100644
--- a/sys/kern/kern_physio.c
+++ b/sys/kern/kern_physio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_physio.c,v 1.16 2001/11/15 23:15:15 art Exp $ */
+/* $OpenBSD: kern_physio.c,v 1.17 2001/11/28 13:47:39 art Exp $ */
/* $NetBSD: kern_physio.c,v 1.28 1997/05/19 10:43:28 pk Exp $ */
/*-
@@ -173,11 +173,12 @@ physio(strategy, bp, dev, flags, minphys, uio)
* restores it.
*/
PHOLD(p);
- if (uvm_vslock(p, bp->b_data, todo, (flags & B_READ) ?
- VM_PROT_READ | VM_PROT_WRITE : VM_PROT_READ) !=
- KERN_SUCCESS) {
+ error = uvm_vslock(p, bp->b_data, todo,
+ (flags & B_READ) ?
+ VM_PROT_READ | VM_PROT_WRITE : VM_PROT_READ);
+ if (error) {
bp->b_flags |= B_ERROR;
- bp->b_error = EFAULT;
+ bp->b_error = error;
goto after_unlock;
}
vmapbuf(bp, todo);
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c
index 4c4a911d690..44eb2f9924c 100644
--- a/sys/kern/kern_sysctl.c
+++ b/sys/kern/kern_sysctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_sysctl.c,v 1.59 2001/11/06 19:53:20 miod Exp $ */
+/* $OpenBSD: kern_sysctl.c,v 1.60 2001/11/28 13:47:39 art Exp $ */
/* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */
/*-
@@ -187,12 +187,14 @@ sys___sysctl(p, v, retval)
if (SCARG(uap, old) != NULL) {
if ((error = lockmgr(&sysctl_lock, LK_EXCLUSIVE, NULL, p)) != 0)
return (error);
- if (dolock)
- if (uvm_vslock(p, SCARG(uap, old), oldlen,
- VM_PROT_READ|VM_PROT_WRITE) != KERN_SUCCESS) {
+ if (dolock) {
+ error = uvm_vslock(p, SCARG(uap, old), oldlen,
+ VM_PROT_READ|VM_PROT_WRITE);
+ if (error) {
lockmgr(&sysctl_lock, LK_RELEASE, NULL, p);
- return EFAULT;
+ return (error);
}
+ }
savelen = oldlen;
}
error = (*fn)(name + 1, SCARG(uap, namelen) - 1, SCARG(uap, old),
diff --git a/sys/kern/sysv_shm.c b/sys/kern/sysv_shm.c
index f7a233d632c..817d7512b6c 100644
--- a/sys/kern/sysv_shm.c
+++ b/sys/kern/sysv_shm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sysv_shm.c,v 1.22 2001/11/07 01:18:01 art Exp $ */
+/* $OpenBSD: sysv_shm.c,v 1.23 2001/11/28 13:47:39 art Exp $ */
/* $NetBSD: sysv_shm.c,v 1.50 1998/10/21 22:24:29 tron Exp $ */
/*
@@ -144,15 +144,13 @@ shm_delete_mapping(vm, shmmap_s)
struct shmmap_state *shmmap_s;
{
struct shmid_ds *shmseg;
- int segnum, result;
+ int segnum;
size_t size;
segnum = IPCID_TO_IX(shmmap_s->shmid);
shmseg = &shmsegs[segnum];
size = round_page(shmseg->shm_segsz);
- result = uvm_deallocate(&vm->vm_map, shmmap_s->va, size);
- if (result != KERN_SUCCESS)
- return EINVAL;
+ uvm_deallocate(&vm->vm_map, shmmap_s->va, size);
shmmap_s->shmid = -1;
shmseg->shm_dtime = time.tv_sec;
if ((--shmseg->shm_nattch <= 0) &&
@@ -207,7 +205,6 @@ sys_shmat(p, v, retval)
vaddr_t attach_va;
vm_prot_t prot;
vsize_t size;
- int rv;
shmmap_s = (struct shmmap_state *)p->p_vmspace->vm_shm;
if (shmmap_s == NULL) {
@@ -252,11 +249,11 @@ sys_shmat(p, v, retval)
}
shm_handle = shmseg->shm_internal;
uao_reference(shm_handle->shm_object);
- rv = uvm_map(&p->p_vmspace->vm_map, &attach_va, size,
+ error = uvm_map(&p->p_vmspace->vm_map, &attach_va, size,
shm_handle->shm_object, 0, 0, UVM_MAPFLAG(prot, prot,
UVM_INH_SHARE, UVM_ADV_RANDOM, 0));
- if (rv != KERN_SUCCESS) {
- return ENOMEM;
+ if (error) {
+ return error;
}
shmmap_s->va = attach_va;
diff --git a/sys/sys/param.h b/sys/sys/param.h
index 59fe3a01548..0ad1ce9422e 100644
--- a/sys/sys/param.h
+++ b/sys/sys/param.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: param.h,v 1.42 2001/11/27 05:27:12 art Exp $ */
+/* $OpenBSD: param.h,v 1.43 2001/11/28 13:47:39 art Exp $ */
/* $NetBSD: param.h,v 1.23 1996/03/17 01:02:29 thorpej Exp $ */
/*-
@@ -233,8 +233,8 @@
* Defaults for Unified Buffer Cache parameters.
*/
-#ifndef UBC_WINSIZE
-#define UBC_WINSIZE 8192
+#ifndef UBC_WINSHIFT
+#define UBC_WINSHIFT 13
#endif
#ifndef UBC_NWINS
#define UBC_NWINS 1024
diff --git a/sys/uvm/uvm_anon.c b/sys/uvm/uvm_anon.c
index 8478141a72c..4089ca48991 100644
--- a/sys/uvm/uvm_anon.c
+++ b/sys/uvm/uvm_anon.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: uvm_anon.c,v 1.16 2001/11/27 05:27:12 art Exp $ */
-/* $NetBSD: uvm_anon.c,v 1.15 2001/02/18 21:19:08 chs Exp $ */
+/* $OpenBSD: uvm_anon.c,v 1.17 2001/11/28 13:47:39 art Exp $ */
+/* $NetBSD: uvm_anon.c,v 1.16 2001/03/10 22:46:47 chs Exp $ */
/*
*
@@ -482,20 +482,20 @@ anon_pagein(anon)
rv = uvmfault_anonget(NULL, NULL, anon);
/*
- * if rv == VM_PAGER_OK, anon is still locked, else anon
+ * if rv == 0, anon is still locked, else anon
* is unlocked
*/
switch (rv) {
- case VM_PAGER_OK:
+ case 0:
break;
- case VM_PAGER_ERROR:
- case VM_PAGER_REFAULT:
+ case EIO:
+ case ERESTART:
/*
* nothing more to do on errors.
- * VM_PAGER_REFAULT can only mean that the anon was freed,
+ * ERESTART can only mean that the anon was freed,
* so again there's nothing to do.
*/
diff --git a/sys/uvm/uvm_aobj.c b/sys/uvm/uvm_aobj.c
index 0ebf53c3502..0d7d7c3aa3f 100644
--- a/sys/uvm/uvm_aobj.c
+++ b/sys/uvm/uvm_aobj.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: uvm_aobj.c,v 1.21 2001/11/27 05:27:12 art Exp $ */
-/* $NetBSD: uvm_aobj.c,v 1.39 2001/02/18 21:19:08 chs Exp $ */
+/* $OpenBSD: uvm_aobj.c,v 1.22 2001/11/28 13:47:39 art Exp $ */
+/* $NetBSD: uvm_aobj.c,v 1.40 2001/03/10 22:46:47 chs Exp $ */
/*
* Copyright (c) 1998 Chuck Silvers, Charles D. Cranor and
@@ -935,7 +935,7 @@ uao_flush(uobj, start, stop, flags)
*
* cases 1 and 2 can be handled with PGO_LOCKED, case 3 cannot.
* so, if the "center" page hits case 3 (or any page, with PGO_ALLPAGES),
- * then we will need to return VM_PAGER_UNLOCK.
+ * then we will need to return EBUSY.
*
* => prefer map unlocked (not required)
* => object must be locked! we will _unlock_ it before starting any I/O.
@@ -1040,10 +1040,10 @@ uao_get(uobj, offset, pps, npagesp, centeridx, access_type, advice, flags)
*npagesp = gotpages;
if (done)
/* bingo! */
- return(VM_PAGER_OK);
+ return(0);
else
/* EEK! Need to unlock and I/O */
- return(VM_PAGER_UNLOCK);
+ return(EBUSY);
}
/*
@@ -1177,7 +1177,7 @@ uao_get(uobj, offset, pps, npagesp, centeridx, access_type, advice, flags)
/*
* I/O done. check for errors.
*/
- if (rv != VM_PAGER_OK)
+ if (rv != 0)
{
UVMHIST_LOG(pdhist, "<- done (error=%d)",
rv,0,0,0);
@@ -1228,7 +1228,7 @@ uao_get(uobj, offset, pps, npagesp, centeridx, access_type, advice, flags)
simple_unlock(&uobj->vmobjlock);
UVMHIST_LOG(pdhist, "<- done (OK)",0,0,0,0);
- return(VM_PAGER_OK);
+ return(0);
}
/*
@@ -1488,14 +1488,14 @@ uao_pagein_page(aobj, pageidx)
simple_lock(&aobj->u_obj.vmobjlock);
switch (rv) {
- case VM_PAGER_OK:
+ case 0:
break;
- case VM_PAGER_ERROR:
- case VM_PAGER_REFAULT:
+ case EIO:
+ case ERESTART:
/*
* nothing more to do on errors.
- * VM_PAGER_REFAULT can only mean that the anon was freed,
+ * ERESTART can only mean that the anon was freed,
* so again there's nothing to do.
*/
return FALSE;
diff --git a/sys/uvm/uvm_bio.c b/sys/uvm/uvm_bio.c
index fccf51b8ece..9ba758f2680 100644
--- a/sys/uvm/uvm_bio.c
+++ b/sys/uvm/uvm_bio.c
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_bio.c,v 1.7 2001/02/02 01:55:52 enami Exp $ */
+/* $NetBSD: uvm_bio.c,v 1.11 2001/03/19 00:29:04 chs Exp $ */
/*
* Copyright (c) 1998 Chuck Silvers.
@@ -64,7 +64,7 @@ static struct ubc_map *ubc_find_mapping __P((struct uvm_object *, voff_t));
(((u_long)(offset)) >> PAGE_SHIFT)) & \
ubc_object.hashmask)
-#define UBC_QUEUE(offset) (&ubc_object.inactive[((offset) / ubc_winsize) & \
+#define UBC_QUEUE(offset) (&ubc_object.inactive[((offset) >> ubc_winshift) & \
(UBC_NQUEUES - 1)])
struct ubc_map
@@ -103,7 +103,8 @@ struct uvm_pagerops ubc_pager =
};
int ubc_nwins = UBC_NWINS;
-int ubc_winsize = UBC_WINSIZE;
+int ubc_winshift = UBC_WINSHIFT;
+int ubc_winsize;
#ifdef PMAP_PREFER
int ubc_nqueues;
boolean_t ubc_release_unmap = FALSE;
@@ -150,14 +151,15 @@ ubc_init(void)
va = (vaddr_t)1L;
#ifdef PMAP_PREFER
PMAP_PREFER(0, &va);
- if (va < ubc_winsize) {
- va = ubc_winsize;
+ ubc_nqueues = va >> ubc_winshift;
+ if (ubc_nqueues == 0) {
+ ubc_nqueues = 1;
}
- ubc_nqueues = va / ubc_winsize;
if (ubc_nqueues != 1) {
ubc_release_unmap = TRUE;
}
#endif
+ ubc_winsize = 1 << ubc_winshift;
ubc_object.inactive = malloc(UBC_NQUEUES *
sizeof(struct ubc_inactive_head),
M_TEMP, M_NOWAIT);
@@ -179,10 +181,9 @@ ubc_init(void)
}
if (uvm_map(kernel_map, (vaddr_t *)&ubc_object.kva,
- ubc_nwins * ubc_winsize, &ubc_object.uobj, 0, (vsize_t)va,
+ ubc_nwins << ubc_winshift, &ubc_object.uobj, 0, (vsize_t)va,
UVM_MAPFLAG(UVM_PROT_ALL, UVM_PROT_ALL, UVM_INH_NONE,
- UVM_ADV_RANDOM, UVM_FLAG_NOMERGE))
- != KERN_SUCCESS) {
+ UVM_ADV_RANDOM, UVM_FLAG_NOMERGE)) != 0) {
panic("ubc_init: failed to map ubc_object\n");
}
UVMHIST_INIT(ubchist, 300);
@@ -192,7 +193,7 @@ ubc_init(void)
/*
* ubc_fault: fault routine for ubc mapping
*/
-static int
+int
ubc_fault(ufi, ign1, ign2, ign3, ign4, fault_type, access_type, flags)
struct uvm_faultinfo *ufi;
vaddr_t ign1;
@@ -207,7 +208,7 @@ ubc_fault(ufi, ign1, ign2, ign3, ign4, fault_type, access_type, flags)
struct ubc_map *umap;
vaddr_t va, eva, ubc_offset, slot_offset;
int i, error, rv, npages;
- struct vm_page *pgs[ubc_winsize >> PAGE_SHIFT], *pg;
+ struct vm_page *pgs[(1 << ubc_winshift) >> PAGE_SHIFT], *pg;
UVMHIST_FUNC("ubc_fault"); UVMHIST_CALLED(ubchist);
/*
@@ -217,7 +218,7 @@ ubc_fault(ufi, ign1, ign2, ign3, ign4, fault_type, access_type, flags)
*/
if (flags & PGO_LOCKED) {
#if 0
- return VM_PAGER_UNLOCK;
+ return EBUSY;
#else
uvmfault_unlockall(ufi, NULL, &ubc_object.uobj, NULL);
flags &= ~PGO_LOCKED;
@@ -230,7 +231,7 @@ ubc_fault(ufi, ign1, ign2, ign3, ign4, fault_type, access_type, flags)
UVMHIST_LOG(ubchist, "va 0x%lx ubc_offset 0x%lx at %d",
va, ubc_offset, access_type,0);
- umap = &ubc_object.umap[ubc_offset / ubc_winsize];
+ umap = &ubc_object.umap[ubc_offset >> ubc_winshift];
KASSERT(umap->refcount != 0);
slot_offset = trunc_page(ubc_offset & (ubc_winsize - 1));
@@ -287,10 +288,10 @@ again:
goto again;
}
if (error) {
- return VM_PAGER_ERROR;
+ return error;
}
if (npages == 0) {
- return VM_PAGER_OK;
+ return 0;
}
va = ufi->orig_rvaddr;
@@ -328,14 +329,14 @@ again:
UVM_PAGE_OWN(pg, NULL);
}
simple_unlock(&uobj->vmobjlock);
- return VM_PAGER_OK;
+ return 0;
}
/*
* local functions
*/
-static struct ubc_map *
+struct ubc_map *
ubc_find_mapping(uobj, offset)
struct uvm_object *uobj;
voff_t offset;
@@ -411,7 +412,7 @@ again:
umap, hash);
va = (vaddr_t)(ubc_object.kva +
- (umap - ubc_object.umap) * ubc_winsize);
+ ((umap - ubc_object.umap) << ubc_winshift));
pmap_remove(pmap_kernel(), va, va + ubc_winsize);
}
@@ -435,10 +436,11 @@ again:
splx(s);
UVMHIST_LOG(ubchist, "umap %p refs %d va %p",
umap, umap->refcount,
- ubc_object.kva + (umap - ubc_object.umap) * ubc_winsize,0);
+ ubc_object.kva + ((umap - ubc_object.umap) << ubc_winshift),
+ 0);
return ubc_object.kva +
- (umap - ubc_object.umap) * ubc_winsize + slot_offset;
+ ((umap - ubc_object.umap) << ubc_winshift) + slot_offset;
}
@@ -457,7 +459,7 @@ ubc_release(va, wlen)
s = splbio();
simple_lock(&ubc_object.uobj.vmobjlock);
- umap = &ubc_object.umap[((char *)va - ubc_object.kva) / ubc_winsize];
+ umap = &ubc_object.umap[((char *)va - ubc_object.kva) >> ubc_winshift];
uobj = umap->uobj;
KASSERT(uobj != NULL);
@@ -481,7 +483,7 @@ ubc_release(va, wlen)
*/
va = (vaddr_t)(ubc_object.kva +
- (umap - ubc_object.umap) * ubc_winsize);
+ ((umap - ubc_object.umap) << ubc_winshift));
pmap_remove(pmap_kernel(), va, va + ubc_winsize);
LIST_REMOVE(umap, hash);
umap->uobj = NULL;
@@ -534,7 +536,7 @@ ubc_flush(uobj, start, end)
*/
va = (vaddr_t)(ubc_object.kva +
- (umap - ubc_object.umap) * ubc_winsize);
+ ((umap - ubc_object.umap) << ubc_winshift));
pmap_remove(pmap_kernel(), va, va + ubc_winsize);
LIST_REMOVE(umap, hash);
diff --git a/sys/uvm/uvm_device.c b/sys/uvm/uvm_device.c
index 932fdfd5ec3..2704d728c7d 100644
--- a/sys/uvm/uvm_device.c
+++ b/sys/uvm/uvm_device.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: uvm_device.c,v 1.17 2001/11/07 02:55:50 art Exp $ */
-/* $NetBSD: uvm_device.c,v 1.30 2000/11/25 06:27:59 chs Exp $ */
+/* $OpenBSD: uvm_device.c,v 1.18 2001/11/28 13:47:39 art Exp $ */
+/* $NetBSD: uvm_device.c,v 1.32 2001/03/15 06:10:56 chs Exp $ */
/*
*
@@ -401,7 +401,7 @@ udv_fault(ufi, vaddr, pps, npages, centeridx, fault_type, access_type, flags)
UVMHIST_LOG(maphist, "<- failed -- COW entry (etype=0x%x)",
entry->etype, 0,0,0);
uvmfault_unlockall(ufi, ufi->entry->aref.ar_amap, uobj, NULL);
- return(VM_PAGER_ERROR);
+ return(EIO);
}
/*
@@ -427,7 +427,7 @@ udv_fault(ufi, vaddr, pps, npages, centeridx, fault_type, access_type, flags)
* loop over the page range entering in as needed
*/
- retval = VM_PAGER_OK;
+ retval = 0;
for (lcv = 0 ; lcv < npages ; lcv++, curr_offset += PAGE_SIZE,
curr_va += PAGE_SIZE) {
if ((flags & PGO_ALLPAGES) == 0 && lcv != centeridx)
@@ -438,7 +438,7 @@ udv_fault(ufi, vaddr, pps, npages, centeridx, fault_type, access_type, flags)
mdpgno = (*mapfn)(device, curr_offset, access_type);
if (mdpgno == -1) {
- retval = VM_PAGER_ERROR;
+ retval = EIO;
break;
}
paddr = pmap_phys_address(mdpgno);
@@ -447,7 +447,7 @@ udv_fault(ufi, vaddr, pps, npages, centeridx, fault_type, access_type, flags)
" MAPPING: device: pm=0x%x, va=0x%x, pa=0x%lx, at=%d",
ufi->orig_map->pmap, curr_va, paddr, mapprot);
if (pmap_enter(ufi->orig_map->pmap, curr_va, paddr,
- mapprot, PMAP_CANFAIL | mapprot) != KERN_SUCCESS) {
+ mapprot, PMAP_CANFAIL | mapprot) != 0) {
/*
* pmap_enter() didn't have the resource to
* enter this mapping. Unlock everything,
@@ -461,7 +461,7 @@ udv_fault(ufi, vaddr, pps, npages, centeridx, fault_type, access_type, flags)
uvmfault_unlockall(ufi, ufi->entry->aref.ar_amap,
uobj, NULL);
uvm_wait("udv_fault");
- return (VM_PAGER_REFAULT);
+ return (ERESTART);
}
}
diff --git a/sys/uvm/uvm_extern.h b/sys/uvm/uvm_extern.h
index bb6b841f0ca..3e3d255a5a9 100644
--- a/sys/uvm/uvm_extern.h
+++ b/sys/uvm/uvm_extern.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: uvm_extern.h,v 1.34 2001/11/27 05:27:12 art Exp $ */
-/* $NetBSD: uvm_extern.h,v 1.57 2001/03/09 01:02:12 chs Exp $ */
+/* $OpenBSD: uvm_extern.h,v 1.35 2001/11/28 13:47:39 art Exp $ */
+/* $NetBSD: uvm_extern.h,v 1.58 2001/03/15 06:10:56 chs Exp $ */
/*
*
@@ -569,7 +569,7 @@ void uvm_total __P((struct vmtotal *));
/* uvm_mmap.c */
int uvm_mmap __P((vm_map_t, vaddr_t *, vsize_t,
vm_prot_t, vm_prot_t, int,
- caddr_t, voff_t, vsize_t));
+ void *, voff_t, vsize_t));
/* uvm_page.c */
struct vm_page *uvm_pagealloc_strat __P((struct uvm_object *,
@@ -610,7 +610,7 @@ int uvm_coredump __P((struct proc *, struct vnode *,
int uvm_grow __P((struct proc *, vaddr_t));
/* uvm_user.c */
-int uvm_deallocate __P((vm_map_t, vaddr_t, vsize_t));
+void uvm_deallocate __P((vm_map_t, vaddr_t, vsize_t));
/* uvm_vnode.c */
void uvm_vnp_setsize __P((struct vnode *, voff_t));
diff --git a/sys/uvm/uvm_fault.c b/sys/uvm/uvm_fault.c
index 0e4103fe49b..3be2966ea58 100644
--- a/sys/uvm/uvm_fault.c
+++ b/sys/uvm/uvm_fault.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: uvm_fault.c,v 1.25 2001/11/27 05:27:12 art Exp $ */
-/* $NetBSD: uvm_fault.c,v 1.56 2001/02/18 21:19:08 chs Exp $ */
+/* $OpenBSD: uvm_fault.c,v 1.26 2001/11/28 13:47:39 art Exp $ */
+/* $NetBSD: uvm_fault.c,v 1.60 2001/04/01 16:45:53 chs Exp $ */
/*
*
@@ -276,7 +276,7 @@ uvmfault_amapcopy(ufi)
* page in that anon.
*
* => maps, amap, and anon locked by caller.
- * => if we fail (result != VM_PAGER_OK) we unlock everything.
+ * => if we fail (result != 0) we unlock everything.
* => if we are successful, we return with everything still locked.
* => we don't move the page on the queues [gets moved later]
* => if we allocate a new page [we_own], it gets put on the queues.
@@ -296,12 +296,12 @@ uvmfault_anonget(ufi, amap, anon)
boolean_t we_own; /* we own anon's page? */
boolean_t locked; /* did we relock? */
struct vm_page *pg;
- int result;
+ int error;
UVMHIST_FUNC("uvmfault_anonget"); UVMHIST_CALLED(maphist);
LOCK_ASSERT(simple_lock_held(&anon->an_lock));
- result = 0; /* XXX shut up gcc */
+ error = 0;
uvmexp.fltanget++;
/* bump rusage counters */
if (anon->u.an_page)
@@ -342,7 +342,7 @@ uvmfault_anonget(ufi, amap, anon)
if ((pg->flags & (PG_BUSY|PG_RELEASED)) == 0) {
UVMHIST_LOG(maphist, "<- OK",0,0,0,0);
- return (VM_PAGER_OK);
+ return (0);
}
pg->flags |= PG_WANTED;
uvmexp.fltpgwait++;
@@ -398,7 +398,7 @@ uvmfault_anonget(ufi, amap, anon)
* we hold PG_BUSY on the page.
*/
uvmexp.pageins++;
- result = uvm_swap_get(pg, anon->an_swslot,
+ error = uvm_swap_get(pg, anon->an_swslot,
PGO_SYNCIO);
/*
@@ -455,12 +455,10 @@ uvmfault_anonget(ufi, amap, anon)
NULL);
uvmexp.fltpgrele++;
UVMHIST_LOG(maphist, "<- REFAULT", 0,0,0,0);
- return (VM_PAGER_REFAULT); /* refault! */
+ return (ERESTART); /* refault! */
}
- if (result != VM_PAGER_OK) {
- KASSERT(result != VM_PAGER_PEND);
-
+ if (error) {
/* remove page from anon */
anon->u.an_page = NULL;
@@ -488,7 +486,7 @@ uvmfault_anonget(ufi, amap, anon)
else
simple_unlock(&anon->an_lock);
UVMHIST_LOG(maphist, "<- ERROR", 0,0,0,0);
- return (VM_PAGER_ERROR);
+ return error;
}
/*
@@ -509,7 +507,7 @@ uvmfault_anonget(ufi, amap, anon)
if (!locked) {
UVMHIST_LOG(maphist, "<- REFAULT", 0,0,0,0);
- return (VM_PAGER_REFAULT);
+ return (ERESTART);
}
/*
@@ -522,7 +520,7 @@ uvmfault_anonget(ufi, amap, anon)
uvmfault_unlockall(ufi, amap, NULL, anon);
UVMHIST_LOG(maphist, "<- REFAULT", 0,0,0,0);
- return (VM_PAGER_REFAULT);
+ return (ERESTART);
}
/*
@@ -565,7 +563,7 @@ uvm_fault(orig_map, vaddr, fault_type, access_type)
struct uvm_faultinfo ufi;
vm_prot_t enter_prot;
boolean_t wired, narrow, promote, locked, shadowed;
- int npages, nback, nforw, centeridx, result, lcv, gotpages;
+ int npages, nback, nforw, centeridx, error, lcv, gotpages;
vaddr_t startva, objaddr, currva, offset, uoff;
paddr_t pa;
struct vm_amap *amap;
@@ -602,10 +600,11 @@ uvm_fault(orig_map, vaddr, fault_type, access_type)
* maps are never pageable, and this approach avoids an evil
* locking mess.
*/
+
if (orig_map == kernel_map && uvmfault_check_intrsafe(&ufi)) {
UVMHIST_LOG(maphist, "<- VA 0x%lx in intrsafe map %p",
ufi.orig_rvaddr, ufi.map, 0, 0);
- return (KERN_FAILURE);
+ return EFAULT;
}
/*
@@ -619,10 +618,12 @@ ReFault:
if (uvmfault_lookup(&ufi, FALSE) == FALSE) {
UVMHIST_LOG(maphist, "<- no mapping @ 0x%x", vaddr, 0,0,0);
- return (KERN_INVALID_ADDRESS);
+ return (EFAULT);
}
/* locked: maps(read) */
+ KASSERT(ufi.map->flags & VM_MAP_PAGEABLE);
+
/*
* check protection
*/
@@ -632,18 +633,7 @@ ReFault:
"<- protection failure (prot=0x%x, access=0x%x)",
ufi.entry->protection, access_type, 0, 0);
uvmfault_unlockmaps(&ufi, FALSE);
- return (KERN_PROTECTION_FAILURE);
- }
-
- /*
- * if the map is not a pageable map, a page fault always fails.
- */
-
- if ((ufi.map->flags & VM_MAP_PAGEABLE) == 0) {
- UVMHIST_LOG(maphist,
- "<- map %p not pageable", ufi.map, 0, 0, 0);
- uvmfault_unlockmaps(&ufi, FALSE);
- return (KERN_FAILURE);
+ return EACCES;
}
/*
@@ -702,7 +692,7 @@ ReFault:
if (amap == NULL && uobj == NULL) {
uvmfault_unlockmaps(&ufi, FALSE);
UVMHIST_LOG(maphist,"<- no backing store, no overlay",0,0,0,0);
- return (KERN_INVALID_ADDRESS);
+ return (EFAULT);
}
/*
@@ -887,18 +877,14 @@ ReFault:
simple_lock(&uobj->vmobjlock);
/* locked: maps(read), amap (if there), uobj */
- result = uobj->pgops->pgo_fault(&ufi, startva, pages, npages,
- centeridx, fault_type, access_type,
- PGO_LOCKED|PGO_SYNCIO);
+ error = uobj->pgops->pgo_fault(&ufi, startva, pages, npages,
+ centeridx, fault_type, access_type, PGO_LOCKED|PGO_SYNCIO);
/* locked: nothing, pgo_fault has unlocked everything */
- if (result == VM_PAGER_OK)
- return (KERN_SUCCESS); /* pgo_fault did pmap enter */
- else if (result == VM_PAGER_REFAULT)
+ if (error == ERESTART)
goto ReFault; /* try again! */
- else
- return (KERN_PROTECTION_FAILURE);
+ return error;
}
/*
@@ -1058,24 +1044,20 @@ ReFault:
* lock that object for us if it does not fail.
*/
- result = uvmfault_anonget(&ufi, amap, anon);
- switch (result) {
- case VM_PAGER_OK:
+ error = uvmfault_anonget(&ufi, amap, anon);
+ switch (error) {
+ case 0:
break;
- case VM_PAGER_REFAULT:
+ case ERESTART:
goto ReFault;
- case VM_PAGER_AGAIN:
+ case EAGAIN:
tsleep(&lbolt, PVM, "fltagain1", 0);
goto ReFault;
default:
-#ifdef DIAGNOSTIC
- panic("uvm_fault: uvmfault_anonget -> %d", result);
-#else
- return (KERN_PROTECTION_FAILURE);
-#endif
+ return error;
}
/*
@@ -1199,7 +1181,7 @@ ReFault:
UVMHIST_LOG(maphist,
"<- failed. out of VM",0,0,0,0);
uvmexp.fltnoanon++;
- return (KERN_RESOURCE_SHORTAGE);
+ return ENOMEM;
}
uvmexp.fltnoram++;
@@ -1247,7 +1229,7 @@ ReFault:
ufi.orig_map->pmap, ufi.orig_rvaddr, pg, 0);
if (pmap_enter(ufi.orig_map->pmap, ufi.orig_rvaddr, VM_PAGE_TO_PHYS(pg),
enter_prot, access_type | PMAP_CANFAIL | (wired ? PMAP_WIRED : 0))
- != KERN_SUCCESS) {
+ != 0) {
/*
* No need to undo what we did; we can simply think of
* this as the pmap throwing away the mapping information.
@@ -1263,7 +1245,7 @@ ReFault:
UVMHIST_LOG(maphist,
"<- failed. out of VM",0,0,0,0);
/* XXX instrumentation */
- return (KERN_RESOURCE_SHORTAGE);
+ return ENOMEM;
}
/* XXX instrumentation */
uvm_wait("flt_pmfail1");
@@ -1302,7 +1284,7 @@ ReFault:
if (anon != oanon)
simple_unlock(&anon->an_lock);
uvmfault_unlockall(&ufi, amap, uobj, oanon);
- return (KERN_SUCCESS);
+ return 0;
Case2:
@@ -1356,29 +1338,27 @@ Case2:
uvmexp.fltget++;
gotpages = 1;
uoff = (ufi.orig_rvaddr - ufi.entry->start) + ufi.entry->offset;
- result = uobj->pgops->pgo_get(uobj, uoff, &uobjpage, &gotpages,
+ error = uobj->pgops->pgo_get(uobj, uoff, &uobjpage, &gotpages,
0, access_type & MASK(ufi.entry), ufi.entry->advice,
PGO_SYNCIO);
- /* locked: uobjpage(if result OK) */
+ /* locked: uobjpage(if no error) */
/*
* recover from I/O
*/
- if (result != VM_PAGER_OK) {
- KASSERT(result != VM_PAGER_PEND);
-
- if (result == VM_PAGER_AGAIN) {
+ if (error) {
+ if (error == EAGAIN) {
UVMHIST_LOG(maphist,
" pgo_get says TRY AGAIN!",0,0,0,0);
- tsleep((caddr_t)&lbolt, PVM, "fltagain2", 0);
+ tsleep(&lbolt, PVM, "fltagain2", 0);
goto ReFault;
}
UVMHIST_LOG(maphist, "<- pgo_get failed (code %d)",
- result, 0,0,0);
- return (KERN_PROTECTION_FAILURE); /* XXX i/o error */
+ error, 0,0,0);
+ return error;
}
/* locked: uobjpage */
@@ -1629,7 +1609,7 @@ Case2:
UVMHIST_LOG(maphist, " promote: out of VM",
0,0,0,0);
uvmexp.fltnoanon++;
- return (KERN_RESOURCE_SHORTAGE);
+ return ENOMEM;
}
UVMHIST_LOG(maphist, " out of RAM, waiting for more",
@@ -1710,8 +1690,7 @@ Case2:
KASSERT(access_type == VM_PROT_READ || (pg->flags & PG_RDONLY) == 0);
if (pmap_enter(ufi.orig_map->pmap, ufi.orig_rvaddr, VM_PAGE_TO_PHYS(pg),
pg->flags & PG_RDONLY ? VM_PROT_READ : enter_prot,
- access_type | PMAP_CANFAIL | (wired ? PMAP_WIRED : 0))
- != KERN_SUCCESS) {
+ access_type | PMAP_CANFAIL | (wired ? PMAP_WIRED : 0)) != 0) {
/*
* No need to undo what we did; we can simply think of
@@ -1737,7 +1716,7 @@ Case2:
UVMHIST_LOG(maphist,
"<- failed. out of VM",0,0,0,0);
/* XXX instrumentation */
- return (KERN_RESOURCE_SHORTAGE);
+ return ENOMEM;
}
/* XXX instrumentation */
uvm_wait("flt_pmfail2");
@@ -1779,7 +1758,7 @@ Case2:
uvmfault_unlockall(&ufi, amap, uobj, anon);
UVMHIST_LOG(maphist, "<- done (SUCCESS!)",0,0,0,0);
- return (KERN_SUCCESS);
+ return 0;
}
@@ -1800,7 +1779,7 @@ uvm_fault_wire(map, start, end, access_type)
{
vaddr_t va;
pmap_t pmap;
- int rv;
+ int error;
pmap = vm_map_pmap(map);
@@ -1811,16 +1790,16 @@ uvm_fault_wire(map, start, end, access_type)
*/
for (va = start ; va < end ; va += PAGE_SIZE) {
- rv = uvm_fault(map, va, VM_FAULT_WIRE, access_type);
- if (rv) {
+ error = uvm_fault(map, va, VM_FAULT_WIRE, access_type);
+ if (error) {
if (va != start) {
uvm_fault_unwire(map, start, va);
}
- return (rv);
+ return error;
}
}
- return (KERN_SUCCESS);
+ return 0;
}
/*
diff --git a/sys/uvm/uvm_glue.c b/sys/uvm/uvm_glue.c
index 78e881bef6e..4eb6e146a83 100644
--- a/sys/uvm/uvm_glue.c
+++ b/sys/uvm/uvm_glue.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: uvm_glue.c,v 1.26 2001/11/10 19:20:39 art Exp $ */
-/* $NetBSD: uvm_glue.c,v 1.44 2001/02/06 19:54:44 eeh Exp $ */
+/* $OpenBSD: uvm_glue.c,v 1.27 2001/11/28 13:47:39 art Exp $ */
+/* $NetBSD: uvm_glue.c,v 1.45 2001/03/15 06:10:57 chs Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -218,15 +218,13 @@ uvm_vslock(p, addr, len, access_type)
{
vm_map_t map;
vaddr_t start, end;
- int rv;
+ int error;
map = &p->p_vmspace->vm_map;
start = trunc_page((vaddr_t)addr);
end = round_page((vaddr_t)addr + len);
-
- rv = uvm_fault_wire(map, start, end, access_type);
-
- return (rv);
+ error = uvm_fault_wire(map, start, end, access_type);
+ return error;
}
/*
@@ -271,7 +269,7 @@ uvm_fork(p1, p2, shared, stack, stacksize, func, arg)
void *arg;
{
struct user *up = p2->p_addr;
- int rv;
+ int error;
if (shared == TRUE) {
p2->p_vmspace = NULL;
@@ -288,10 +286,10 @@ uvm_fork(p1, p2, shared, stack, stacksize, func, arg)
* Note the kernel stack gets read/write accesses right off
* the bat.
*/
- rv = uvm_fault_wire(kernel_map, (vaddr_t)up,
+ error = uvm_fault_wire(kernel_map, (vaddr_t)up,
(vaddr_t)up + USPACE, VM_PROT_READ | VM_PROT_WRITE);
- if (rv != KERN_SUCCESS)
- panic("uvm_fork: uvm_fault_wire failed: %d", rv);
+ if (error)
+ panic("uvm_fork: uvm_fault_wire failed: %d", error);
/*
* p_stats currently points at a field in the user struct. Copy
diff --git a/sys/uvm/uvm_io.c b/sys/uvm/uvm_io.c
index 5cb29a07715..cd64da0ac95 100644
--- a/sys/uvm/uvm_io.c
+++ b/sys/uvm/uvm_io.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: uvm_io.c,v 1.10 2001/11/06 01:35:04 art Exp $ */
-/* $NetBSD: uvm_io.c,v 1.12 2000/06/27 17:29:23 mrg Exp $ */
+/* $OpenBSD: uvm_io.c,v 1.11 2001/11/28 13:47:39 art Exp $ */
+/* $NetBSD: uvm_io.c,v 1.13 2001/03/15 06:10:57 chs Exp $ */
/*
*
@@ -138,8 +138,7 @@ uvm_io(map, uio)
*/
vm_map_lock(kernel_map);
- (void)uvm_unmap_remove(kernel_map, kva, kva+chunksz,
- &dead_entries);
+ uvm_unmap_remove(kernel_map, kva, kva + chunksz, &dead_entries);
vm_map_unlock(kernel_map);
if (dead_entries != NULL)
diff --git a/sys/uvm/uvm_km.c b/sys/uvm/uvm_km.c
index b15ba7cdbef..43922f24541 100644
--- a/sys/uvm/uvm_km.c
+++ b/sys/uvm/uvm_km.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: uvm_km.c,v 1.22 2001/11/11 01:16:56 art Exp $ */
-/* $NetBSD: uvm_km.c,v 1.42 2001/01/14 02:10:01 thorpej Exp $ */
+/* $OpenBSD: uvm_km.c,v 1.23 2001/11/28 13:47:39 art Exp $ */
+/* $NetBSD: uvm_km.c,v 1.43 2001/03/15 06:10:57 chs Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -236,7 +236,7 @@ uvm_km_init(start, end)
kernel_map_store.pmap = pmap_kernel();
if (uvm_map(&kernel_map_store, &base, start - base, NULL,
UVM_UNKNOWN_OFFSET, 0, UVM_MAPFLAG(UVM_PROT_ALL, UVM_PROT_ALL,
- UVM_INH_NONE, UVM_ADV_RANDOM,UVM_FLAG_FIXED)) != KERN_SUCCESS)
+ UVM_INH_NONE, UVM_ADV_RANDOM,UVM_FLAG_FIXED)) != 0)
panic("uvm_km_init: could not reserve space for kernel");
/*
@@ -275,7 +275,7 @@ uvm_km_suballoc(map, min, max, size, flags, fixed, submap)
if (uvm_map(map, min, size, NULL, UVM_UNKNOWN_OFFSET, 0,
UVM_MAPFLAG(UVM_PROT_ALL, UVM_PROT_ALL, UVM_INH_NONE,
- UVM_ADV_RANDOM, mapflags)) != KERN_SUCCESS) {
+ UVM_ADV_RANDOM, mapflags)) != 0) {
panic("uvm_km_suballoc: unable to allocate space in parent map");
}
@@ -303,7 +303,7 @@ uvm_km_suballoc(map, min, max, size, flags, fixed, submap)
* now let uvm_map_submap plug in it...
*/
- if (uvm_map_submap(map, *min, *max, submap) != KERN_SUCCESS)
+ if (uvm_map_submap(map, *min, *max, submap) != 0)
panic("uvm_km_suballoc: submap allocation failed");
return(submap);
@@ -509,7 +509,7 @@ uvm_km_kmemalloc(map, obj, size, flags)
if (__predict_false(uvm_map(map, &kva, size, obj, UVM_UNKNOWN_OFFSET,
0, UVM_MAPFLAG(UVM_PROT_ALL, UVM_PROT_ALL, UVM_INH_NONE,
UVM_ADV_RANDOM, (flags & UVM_KMF_TRYLOCK)))
- != KERN_SUCCESS)) {
+ != 0)) {
UVMHIST_LOG(maphist, "<- done (no VM)",0,0,0,0);
return(0);
}
@@ -612,11 +612,10 @@ uvm_km_free_wakeup(map, addr, size)
vm_map_entry_t dead_entries;
vm_map_lock(map);
- (void)uvm_unmap_remove(map, trunc_page(addr), round_page(addr+size),
- &dead_entries);
+ uvm_unmap_remove(map, trunc_page(addr), round_page(addr + size),
+ &dead_entries);
wakeup(map);
vm_map_unlock(map);
-
if (dead_entries != NULL)
uvm_unmap_detach(dead_entries, 0);
}
@@ -650,7 +649,7 @@ uvm_km_alloc1(map, size, zeroit)
if (__predict_false(uvm_map(map, &kva, size, uvm.kernel_object,
UVM_UNKNOWN_OFFSET, 0, UVM_MAPFLAG(UVM_PROT_ALL, UVM_PROT_ALL,
UVM_INH_NONE, UVM_ADV_RANDOM,
- 0)) != KERN_SUCCESS)) {
+ 0)) != 0)) {
UVMHIST_LOG(maphist,"<- done (no VM)",0,0,0,0);
return(0);
}
@@ -756,7 +755,7 @@ uvm_km_valloc_align(map, size, align)
if (__predict_false(uvm_map(map, &kva, size, uvm.kernel_object,
UVM_UNKNOWN_OFFSET, align, UVM_MAPFLAG(UVM_PROT_ALL, UVM_PROT_ALL,
UVM_INH_NONE, UVM_ADV_RANDOM,
- 0)) != KERN_SUCCESS)) {
+ 0)) != 0)) {
UVMHIST_LOG(maphist, "<- done (no VM)", 0,0,0,0);
return(0);
}
@@ -800,7 +799,7 @@ uvm_km_valloc_prefer_wait(map, size, prefer)
if (__predict_true(uvm_map(map, &kva, size, uvm.kernel_object,
prefer, 0, UVM_MAPFLAG(UVM_PROT_ALL,
UVM_PROT_ALL, UVM_INH_NONE, UVM_ADV_RANDOM, 0))
- == KERN_SUCCESS)) {
+ == 0)) {
UVMHIST_LOG(maphist,"<- done (kva=0x%x)", kva,0,0,0);
return(kva);
}
diff --git a/sys/uvm/uvm_loan.c b/sys/uvm/uvm_loan.c
index 481c6bec810..1c0d926ae76 100644
--- a/sys/uvm/uvm_loan.c
+++ b/sys/uvm/uvm_loan.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: uvm_loan.c,v 1.12 2001/11/11 01:16:56 art Exp $ */
-/* $NetBSD: uvm_loan.c,v 1.23 2001/01/23 02:27:39 thorpej Exp $ */
+/* $OpenBSD: uvm_loan.c,v 1.13 2001/11/28 13:47:39 art Exp $ */
+/* $NetBSD: uvm_loan.c,v 1.27 2001/04/09 06:21:03 jdolecek Exp $ */
/*
*
@@ -220,21 +220,15 @@ uvm_loan(map, start, len, result, flags)
{
struct uvm_faultinfo ufi;
void **output;
- int rv;
-
-#ifdef DIAGNOSTIC
- if (map->flags & VM_MAP_INTRSAFE)
- panic("uvm_loan: intrsafe map");
-#endif
+ int rv, error;
/*
* ensure that one and only one of the flags is set
*/
- if ((flags & (UVM_LOAN_TOANON|UVM_LOAN_TOPAGE)) ==
- (UVM_LOAN_TOANON|UVM_LOAN_TOPAGE) ||
- (flags & (UVM_LOAN_TOANON|UVM_LOAN_TOPAGE)) == 0)
- return(KERN_FAILURE);
+ KASSERT(((flags & UVM_LOAN_TOANON) == 0) ^
+ ((flags & UVM_LOAN_TOPAGE) == 0));
+ KASSERT((map->flags & VM_MAP_INTRSAFE) == 0);
/*
* "output" is a pointer to the current place to put the loaned
@@ -262,15 +256,19 @@ uvm_loan(map, start, len, result, flags)
* an unmapped region (an error)
*/
- if (!uvmfault_lookup(&ufi, FALSE))
+ if (!uvmfault_lookup(&ufi, FALSE)) {
+ error = ENOENT;
goto fail;
+ }
/*
* now do the loanout
*/
rv = uvm_loanentry(&ufi, &output, flags);
- if (rv < 0)
+ if (rv < 0) {
+ error = EINVAL;
goto fail;
+ }
/*
* done! advance pointers and unlock.
@@ -285,7 +283,7 @@ uvm_loan(map, start, len, result, flags)
* got it! return success.
*/
- return(KERN_SUCCESS);
+ return 0;
fail:
/*
@@ -299,7 +297,7 @@ fail:
uvm_unloanpage((struct vm_page **)result,
output - result);
}
- return(KERN_FAILURE);
+ return (error);
}
/*
@@ -354,15 +352,15 @@ uvm_loananon(ufi, output, flags, anon)
* unlocked everything and returned an error code.
*/
- if (result != VM_PAGER_OK) {
+ if (result != 0) {
/* need to refault (i.e. refresh our lookup) ? */
- if (result == VM_PAGER_REFAULT)
+ if (result == ERESTART)
return(0);
/* "try again"? sleep a bit and retry ... */
- if (result == VM_PAGER_AGAIN) {
- tsleep((caddr_t)&lbolt, PVM, "loanagain", 0);
+ if (result == EAGAIN) {
+ tsleep(&lbolt, PVM, "loanagain", 0);
return(0);
}
@@ -427,7 +425,7 @@ uvm_loanuobj(ufi, output, flags, va)
result = uobj->pgops->pgo_get(uobj, va - ufi->entry->start,
&pg, &npages, 0, VM_PROT_READ, MADV_NORMAL, PGO_LOCKED);
} else {
- result = VM_PAGER_ERROR;
+ result = EIO;
}
/*
@@ -435,7 +433,7 @@ uvm_loanuobj(ufi, output, flags, va)
* then we fail the loan.
*/
- if (result != VM_PAGER_OK && result != VM_PAGER_UNLOCK) {
+ if (result != 0 && result != EBUSY) {
uvmfault_unlockall(ufi, amap, uobj, NULL);
return(-1);
}
@@ -444,7 +442,7 @@ uvm_loanuobj(ufi, output, flags, va)
* if we need to unlock for I/O, do so now.
*/
- if (result == VM_PAGER_UNLOCK) {
+ if (result == EBUSY) {
uvmfault_unlockall(ufi, amap, NULL, NULL);
npages = 1;
@@ -457,9 +455,9 @@ uvm_loanuobj(ufi, output, flags, va)
* check for errors
*/
- if (result != VM_PAGER_OK) {
- if (result == VM_PAGER_AGAIN) {
- tsleep((caddr_t)&lbolt, PVM, "fltagain2", 0);
+ if (result != 0) {
+ if (result == EAGAIN) {
+ tsleep(&lbolt, PVM, "fltagain2", 0);
return(0); /* redo the lookup and try again */
}
return(-1); /* total failure */
diff --git a/sys/uvm/uvm_map.c b/sys/uvm/uvm_map.c
index bcefa88942c..da4bdd44f9f 100644
--- a/sys/uvm/uvm_map.c
+++ b/sys/uvm/uvm_map.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: uvm_map.c,v 1.31 2001/11/12 01:26:09 art Exp $ */
-/* $NetBSD: uvm_map.c,v 1.93 2001/02/11 01:34:23 eeh Exp $ */
+/* $OpenBSD: uvm_map.c,v 1.32 2001/11/28 13:47:39 art Exp $ */
+/* $NetBSD: uvm_map.c,v 1.94 2001/03/15 06:10:57 chs Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -525,7 +525,7 @@ uvm_map(map, startp, size, uobj, uoffset, align, flags)
if ((prot & maxprot) != prot) {
UVMHIST_LOG(maphist, "<- prot. failure: prot=0x%x, max=0x%x",
prot, maxprot,0,0);
- return(KERN_PROTECTION_FAILURE);
+ return EACCES;
}
/*
@@ -534,14 +534,14 @@ uvm_map(map, startp, size, uobj, uoffset, align, flags)
if (vm_map_lock_try(map) == FALSE) {
if (flags & UVM_FLAG_TRYLOCK)
- return(KERN_FAILURE);
+ return EAGAIN;
vm_map_lock(map); /* could sleep here */
}
if ((prev_entry = uvm_map_findspace(map, *startp, size, startp,
uobj, uoffset, align, flags)) == NULL) {
UVMHIST_LOG(maphist,"<- uvm_map_findspace failed!",0,0,0,0);
vm_map_unlock(map);
- return (KERN_NO_SPACE);
+ return ENOMEM;
}
#ifdef PMAP_GROWKERNEL
@@ -644,7 +644,7 @@ uvm_map(map, startp, size, uobj, uoffset, align, flags)
UVMHIST_LOG(maphist,"<- done (via backmerge)!", 0, 0, 0, 0);
vm_map_unlock(map);
- return (KERN_SUCCESS);
+ return 0;
}
step3:
@@ -715,7 +715,7 @@ step3:
UVMHIST_LOG(maphist,"<- done!", 0, 0, 0, 0);
vm_map_unlock(map);
- return(KERN_SUCCESS);
+ return 0;
}
/*
@@ -954,7 +954,7 @@ uvm_map_findspace(map, hint, length, result, uobj, uoffset, align, flags)
* in "entry_list"
*/
-int
+void
uvm_unmap_remove(map, start, end, entry_list)
vm_map_t map;
vaddr_t start,end;
@@ -1122,7 +1122,6 @@ uvm_unmap_remove(map, start, end, entry_list)
*entry_list = first_entry;
UVMHIST_LOG(maphist,"<- done!", 0, 0, 0, 0);
- return(KERN_SUCCESS);
}
/*
@@ -1212,7 +1211,7 @@ uvm_map_reserve(map, size, offset, align, raddr)
if (uvm_map(map, raddr, size, NULL, offset, 0,
UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE,
- UVM_ADV_RANDOM, UVM_FLAG_NOMERGE)) != KERN_SUCCESS) {
+ UVM_ADV_RANDOM, UVM_FLAG_NOMERGE)) != 0) {
UVMHIST_LOG(maphist, "<- done (no VM)", 0,0,0,0);
return (FALSE);
}
@@ -1685,7 +1684,7 @@ uvm_map_submap(map, start, end, submap)
vaddr_t start, end;
{
vm_map_entry_t entry;
- int result;
+ int error;
vm_map_lock(map);
@@ -1706,12 +1705,12 @@ uvm_map_submap(map, start, end, submap)
entry->object.sub_map = submap;
entry->offset = 0;
uvm_map_reference(submap);
- result = KERN_SUCCESS;
+ error = 0;
} else {
- result = KERN_INVALID_ARGUMENT;
+ error = EINVAL;
}
vm_map_unlock(map);
- return(result);
+ return error;
}
@@ -1724,7 +1723,6 @@ uvm_map_submap(map, start, end, submap)
#define MASK(entry) (UVM_ET_ISCOPYONWRITE(entry) ? \
~VM_PROT_WRITE : VM_PROT_ALL)
-#define max(a,b) ((a) > (b) ? (a) : (b))
int
uvm_map_protect(map, start, end, new_prot, set_max)
@@ -1734,15 +1732,13 @@ uvm_map_protect(map, start, end, new_prot, set_max)
boolean_t set_max;
{
vm_map_entry_t current, entry;
- int rv = KERN_SUCCESS;
+ int error = 0;
UVMHIST_FUNC("uvm_map_protect"); UVMHIST_CALLED(maphist);
UVMHIST_LOG(maphist,"(map=0x%x,start=0x%x,end=0x%x,new_prot=0x%x)",
map, start, end, new_prot);
vm_map_lock(map);
-
VM_MAP_RANGE_CHECK(map, start, end);
-
if (uvm_map_lookup_entry(map, start, &entry)) {
UVM_MAP_CLIP_START(map, entry, start);
} else {
@@ -1756,11 +1752,11 @@ uvm_map_protect(map, start, end, new_prot, set_max)
current = entry;
while ((current != &map->header) && (current->start < end)) {
if (UVM_ET_ISSUBMAP(current)) {
- rv = KERN_INVALID_ARGUMENT;
+ error = EINVAL;
goto out;
}
if ((new_prot & current->max_protection) != new_prot) {
- rv = KERN_PROTECTION_FAILURE;
+ error = EACCES;
goto out;
}
current = current->next;
@@ -1769,12 +1765,10 @@ uvm_map_protect(map, start, end, new_prot, set_max)
/* go back and fix up protections (no need to clip this time). */
current = entry;
-
while ((current != &map->header) && (current->start < end)) {
vm_prot_t old_prot;
UVM_MAP_CLIP_END(map, current, end);
-
old_prot = current->protection;
if (set_max)
current->protection =
@@ -1805,13 +1799,13 @@ uvm_map_protect(map, start, end, new_prot, set_max)
new_prot != VM_PROT_NONE) {
if (uvm_map_pageable(map, entry->start,
entry->end, FALSE,
- UVM_LK_ENTER|UVM_LK_EXIT) != KERN_SUCCESS) {
+ UVM_LK_ENTER|UVM_LK_EXIT) != 0) {
/*
* If locking the entry fails, remember the
* error if it's the first one. Note we
* still continue setting the protection in
- * the map, but will return the resource
- * shortage condition regardless.
+ * the map, but will return the error
+ * condition regardless.
*
* XXX Ignore what the actual error is,
* XXX just call it a resource shortage
@@ -1819,7 +1813,7 @@ uvm_map_protect(map, start, end, new_prot, set_max)
* XXX what uvm_map_protect() itself would
* XXX normally return.
*/
- rv = KERN_RESOURCE_SHORTAGE;
+ error = ENOMEM;
}
}
@@ -1828,11 +1822,10 @@ uvm_map_protect(map, start, end, new_prot, set_max)
out:
vm_map_unlock(map);
- UVMHIST_LOG(maphist, "<- done, rv=%d",rv,0,0,0);
- return (rv);
+ UVMHIST_LOG(maphist, "<- done, error=%d",error,0,0,0);
+ return error;
}
-#undef max
#undef MASK
/*
@@ -1862,7 +1855,7 @@ uvm_map_inherit(map, start, end, new_inheritance)
break;
default:
UVMHIST_LOG(maphist,"<- done (INVALID ARG)",0,0,0,0);
- return (KERN_INVALID_ARGUMENT);
+ return EINVAL;
}
vm_map_lock(map);
@@ -1884,7 +1877,7 @@ uvm_map_inherit(map, start, end, new_inheritance)
vm_map_unlock(map);
UVMHIST_LOG(maphist,"<- done (OK)",0,0,0,0);
- return(KERN_SUCCESS);
+ return 0;
}
/*
@@ -1931,7 +1924,7 @@ uvm_map_advice(map, start, end, new_advice)
default:
vm_map_unlock(map);
UVMHIST_LOG(maphist,"<- done (INVALID ARG)",0,0,0,0);
- return (KERN_INVALID_ARGUMENT);
+ return EINVAL;
}
entry->advice = new_advice;
entry = entry->next;
@@ -1939,7 +1932,7 @@ uvm_map_advice(map, start, end, new_advice)
vm_map_unlock(map);
UVMHIST_LOG(maphist,"<- done (OK)",0,0,0,0);
- return (KERN_SUCCESS);
+ return 0;
}
/*
@@ -1975,7 +1968,6 @@ uvm_map_pageable(map, start, end, new_pageable, lockflags)
if ((lockflags & UVM_LK_ENTER) == 0)
vm_map_lock(map);
-
VM_MAP_RANGE_CHECK(map, start, end);
/*
@@ -1990,8 +1982,8 @@ uvm_map_pageable(map, start, end, new_pageable, lockflags)
if ((lockflags & UVM_LK_EXIT) == 0)
vm_map_unlock(map);
- UVMHIST_LOG(maphist,"<- done (INVALID ARG)",0,0,0,0);
- return (KERN_INVALID_ADDRESS);
+ UVMHIST_LOG(maphist,"<- done (fault)",0,0,0,0);
+ return EFAULT;
}
entry = start_entry;
@@ -2014,9 +2006,8 @@ uvm_map_pageable(map, start, end, new_pageable, lockflags)
entry->next->start > entry->end))) {
if ((lockflags & UVM_LK_EXIT) == 0)
vm_map_unlock(map);
- UVMHIST_LOG(maphist,
- "<- done (INVALID UNWIRE ARG)",0,0,0,0);
- return (KERN_INVALID_ARGUMENT);
+ UVMHIST_LOG(maphist, "<- done (INVAL)",0,0,0,0);
+ return EINVAL;
}
entry = entry->next;
}
@@ -2037,7 +2028,7 @@ uvm_map_pageable(map, start, end, new_pageable, lockflags)
if ((lockflags & UVM_LK_EXIT) == 0)
vm_map_unlock(map);
UVMHIST_LOG(maphist,"<- done (OK UNWIRE)",0,0,0,0);
- return(KERN_SUCCESS);
+ return 0;
}
/*
@@ -2107,7 +2098,7 @@ uvm_map_pageable(map, start, end, new_pageable, lockflags)
if ((lockflags & UVM_LK_EXIT) == 0)
vm_map_unlock(map);
UVMHIST_LOG(maphist,"<- done (INVALID WIRE)",0,0,0,0);
- return (KERN_INVALID_ARGUMENT);
+ return EINVAL;
}
entry = entry->next;
}
@@ -2129,11 +2120,13 @@ uvm_map_pageable(map, start, end, new_pageable, lockflags)
rv = uvm_fault_wire(map, entry->start, entry->end,
entry->protection);
if (rv) {
+
/*
* wiring failed. break out of the loop.
* we'll clean up the map below, once we
* have a write lock again.
*/
+
break;
}
}
@@ -2198,7 +2191,7 @@ uvm_map_pageable(map, start, end, new_pageable, lockflags)
}
UVMHIST_LOG(maphist,"<- done (OK WIRE)",0,0,0,0);
- return(KERN_SUCCESS);
+ return 0;
}
/*
@@ -2246,7 +2239,7 @@ uvm_map_pageable_all(map, flags, limit)
vm_map_modflags(map, 0, VM_MAP_WIREFUTURE);
vm_map_unlock(map);
UVMHIST_LOG(maphist,"<- done (OK UNWIRE)",0,0,0,0);
- return (KERN_SUCCESS);
+ return 0;
/*
* end of unwire case!
@@ -2266,7 +2259,7 @@ uvm_map_pageable_all(map, flags, limit)
*/
UVMHIST_LOG(maphist,"<- done (OK no wire)",0,0,0,0);
vm_map_unlock(map);
- return (KERN_SUCCESS);
+ return 0;
}
/*
@@ -2302,7 +2295,7 @@ uvm_map_pageable_all(map, flags, limit)
if (atop(size) + uvmexp.wired > uvmexp.wiredmax) {
vm_map_unlock(map);
- return (KERN_NO_SPACE); /* XXX overloaded */
+ return ENOMEM;
}
/* XXX non-pmap_wired_count case must be handled by caller */
@@ -2310,7 +2303,7 @@ uvm_map_pageable_all(map, flags, limit)
if (limit != 0 &&
(size + ptoa(pmap_wired_count(vm_map_pmap(map))) > limit)) {
vm_map_unlock(map);
- return (KERN_NO_SPACE); /* XXX overloaded */
+ return ENOMEM;
}
#endif
@@ -2353,7 +2346,7 @@ uvm_map_pageable_all(map, flags, limit)
vm_map_busy(map);
vm_map_downgrade(map);
- rv = KERN_SUCCESS;
+ rv = 0;
for (entry = map->header.next; entry != &map->header;
entry = entry->next) {
if (entry->wired_count == 1) {
@@ -2420,7 +2413,7 @@ uvm_map_pageable_all(map, flags, limit)
vm_map_unlock_read(map);
UVMHIST_LOG(maphist,"<- done (OK WIRE)",0,0,0,0);
- return (KERN_SUCCESS);
+ return 0;
}
/*
@@ -2464,7 +2457,7 @@ uvm_map_clean(map, start, end, flags)
VM_MAP_RANGE_CHECK(map, start, end);
if (uvm_map_lookup_entry(map, start, &entry) == FALSE) {
vm_map_unlock_read(map);
- return(KERN_INVALID_ADDRESS);
+ return EFAULT;
}
/*
@@ -2474,19 +2467,18 @@ uvm_map_clean(map, start, end, flags)
for (current = entry; current->start < end; current = current->next) {
if (UVM_ET_ISSUBMAP(current)) {
vm_map_unlock_read(map);
- return (KERN_INVALID_ARGUMENT);
+ return EINVAL;
}
if (end <= current->end) {
break;
}
if (current->end != current->next->start) {
vm_map_unlock_read(map);
- return (KERN_INVALID_ADDRESS);
+ return EFAULT;
}
}
- error = KERN_SUCCESS;
-
+ error = 0;
for (current = entry; start < end; current = current->next) {
amap = current->aref.ar_amap; /* top layer */
uobj = current->object.uvm_obj; /* bottom layer */
@@ -2605,7 +2597,7 @@ uvm_map_clean(map, start, end, flags)
simple_unlock(&uobj->vmobjlock);
if (rv == FALSE)
- error = KERN_FAILURE;
+ error = EIO;
}
start += size;
}
@@ -2627,40 +2619,40 @@ uvm_map_checkprot(map, start, end, protection)
vaddr_t start, end;
vm_prot_t protection;
{
- vm_map_entry_t entry;
- vm_map_entry_t tmp_entry;
-
- if (!uvm_map_lookup_entry(map, start, &tmp_entry)) {
- return(FALSE);
- }
- entry = tmp_entry;
- while (start < end) {
- if (entry == &map->header) {
- return(FALSE);
- }
+ vm_map_entry_t entry;
+ vm_map_entry_t tmp_entry;
+
+ if (!uvm_map_lookup_entry(map, start, &tmp_entry)) {
+ return(FALSE);
+ }
+ entry = tmp_entry;
+ while (start < end) {
+ if (entry == &map->header) {
+ return(FALSE);
+ }
/*
* no holes allowed
*/
- if (start < entry->start) {
- return(FALSE);
- }
+ if (start < entry->start) {
+ return(FALSE);
+ }
/*
* check protection associated with entry
*/
- if ((entry->protection & protection) != protection) {
- return(FALSE);
- }
+ if ((entry->protection & protection) != protection) {
+ return(FALSE);
+ }
- /* go to next entry */
+ /* go to next entry */
- start = entry->end;
- entry = entry->next;
- }
- return(TRUE);
+ start = entry->end;
+ entry = entry->next;
+ }
+ return(TRUE);
}
/*
@@ -2700,15 +2692,12 @@ uvmspace_init(vm, pmap, min, max, pageable)
UVMHIST_FUNC("uvmspace_init"); UVMHIST_CALLED(maphist);
memset(vm, 0, sizeof(*vm));
-
uvm_map_setup(&vm->vm_map, min, max, pageable ? VM_MAP_PAGEABLE : 0);
-
if (pmap)
pmap_reference(pmap);
else
pmap = pmap_create();
vm->vm_map.pmap = pmap;
-
vm->vm_refcnt = 1;
UVMHIST_LOG(maphist,"<- done",0,0,0,0);
}
@@ -2812,8 +2801,6 @@ uvmspace_exec(p, start, end)
map->min_offset = start;
map->max_offset = end;
vm_map_unlock(map);
-
-
} else {
/*
@@ -2863,7 +2850,7 @@ uvmspace_free(vm)
#endif
vm_map_lock(&vm->vm_map);
if (vm->vm_map.nentries) {
- (void)uvm_unmap_remove(&vm->vm_map,
+ uvm_unmap_remove(&vm->vm_map,
vm->vm_map.min_offset, vm->vm_map.max_offset,
&dead_entries);
if (dead_entries != NULL)
@@ -2919,13 +2906,9 @@ uvmspace_fork(vm1)
/*
* first, some sanity checks on the old entry
*/
- if (UVM_ET_ISSUBMAP(old_entry))
- panic("fork: encountered a submap during fork (illegal)");
-
- if (!UVM_ET_ISCOPYONWRITE(old_entry) &&
- UVM_ET_ISNEEDSCOPY(old_entry))
- panic("fork: non-copy_on_write map entry marked needs_copy (illegal)");
-
+ KASSERT(!UVM_ET_ISSUBMAP(old_entry));
+ KASSERT(UVM_ET_ISCOPYONWRITE(old_entry) ||
+ !UVM_ET_ISNEEDSCOPY(old_entry));
switch (old_entry->inheritance) {
case MAP_INHERIT_NONE:
diff --git a/sys/uvm/uvm_map.h b/sys/uvm/uvm_map.h
index 2c95aff1607..fa135af21d5 100644
--- a/sys/uvm/uvm_map.h
+++ b/sys/uvm/uvm_map.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: uvm_map.h,v 1.16 2001/11/27 05:27:12 art Exp $ */
-/* $NetBSD: uvm_map.h,v 1.24 2001/02/18 21:19:08 chs Exp $ */
+/* $OpenBSD: uvm_map.h,v 1.17 2001/11/28 13:47:40 art Exp $ */
+/* $NetBSD: uvm_map.h,v 1.25 2001/03/15 06:10:57 chs Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -343,9 +343,9 @@ int uvm_map_reserve __P((vm_map_t, vsize_t, vaddr_t, vsize_t,
void uvm_map_setup __P((vm_map_t, vaddr_t, vaddr_t, int));
int uvm_map_submap __P((vm_map_t, vaddr_t, vaddr_t, vm_map_t));
MAP_INLINE
-int uvm_unmap __P((vm_map_t, vaddr_t, vaddr_t));
+void uvm_unmap __P((vm_map_t, vaddr_t, vaddr_t));
void uvm_unmap_detach __P((vm_map_entry_t,int));
-int uvm_unmap_remove __P((vm_map_t, vaddr_t, vaddr_t,
+void uvm_unmap_remove __P((vm_map_t, vaddr_t, vaddr_t,
vm_map_entry_t *));
#endif /* _KERNEL */
diff --git a/sys/uvm/uvm_map_i.h b/sys/uvm/uvm_map_i.h
index c8f75e5f91a..2f4578f2a22 100644
--- a/sys/uvm/uvm_map_i.h
+++ b/sys/uvm/uvm_map_i.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: uvm_map_i.h,v 1.9 2001/11/09 03:32:23 art Exp $ */
-/* $NetBSD: uvm_map_i.h,v 1.18 2000/11/27 08:40:04 chs Exp $ */
+/* $OpenBSD: uvm_map_i.h,v 1.10 2001/11/28 13:47:40 art Exp $ */
+/* $NetBSD: uvm_map_i.h,v 1.19 2001/03/15 06:10:57 chs Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -159,12 +159,11 @@ uvm_map_setup(map, min, max, flags)
* => map must be unlocked (we will lock it)
*/
-MAP_INLINE int
+MAP_INLINE void
uvm_unmap(map, start, end)
vm_map_t map;
vaddr_t start,end;
{
- int result;
vm_map_entry_t dead_entries;
UVMHIST_FUNC("uvm_unmap"); UVMHIST_CALLED(maphist);
@@ -175,14 +174,13 @@ uvm_unmap(map, start, end)
* detach from the dead entries...
*/
vm_map_lock(map);
- result = uvm_unmap_remove(map, start, end, &dead_entries);
+ uvm_unmap_remove(map, start, end, &dead_entries);
vm_map_unlock(map);
if (dead_entries != NULL)
uvm_unmap_detach(dead_entries, 0);
UVMHIST_LOG(maphist, "<- done", 0,0,0,0);
- return(result);
}
diff --git a/sys/uvm/uvm_mmap.c b/sys/uvm/uvm_mmap.c
index 3c4c4bdf961..32203733178 100644
--- a/sys/uvm/uvm_mmap.c
+++ b/sys/uvm/uvm_mmap.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: uvm_mmap.c,v 1.28 2001/11/27 05:27:12 art Exp $ */
-/* $NetBSD: uvm_mmap.c,v 1.49 2001/02/18 21:19:08 chs Exp $ */
+/* $OpenBSD: uvm_mmap.c,v 1.29 2001/11/28 13:47:40 art Exp $ */
+/* $NetBSD: uvm_mmap.c,v 1.50 2001/03/15 06:10:57 chs Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -165,8 +165,8 @@ sys_mincore(p, v, retval)
* Lock down vec, so our returned status isn't outdated by
* storing the status byte for a page.
*/
- uvm_vslock(p, vec, npgs, VM_PROT_WRITE);
+ uvm_vslock(p, vec, npgs, VM_PROT_WRITE);
vm_map_lock_read(map);
if (uvm_map_lookup_entry(map, start, &entry) == FALSE) {
@@ -194,6 +194,7 @@ sys_mincore(p, v, retval)
* Special case for objects with no "real" pages. Those
* are always considered resident (mapped devices).
*/
+
if (UVM_ET_ISOBJ(entry)) {
KASSERT(!UVM_OBJ_IS_KERN_OBJECT(entry->object.uvm_obj));
if (entry->object.uvm_obj->pgops->pgo_releasepg
@@ -221,30 +222,31 @@ sys_mincore(p, v, retval)
start - entry->start);
/* Don't need to lock anon here. */
if (anon != NULL && anon->u.an_page != NULL) {
+
/*
* Anon has the page for this entry
* offset.
*/
+
pgi = 1;
}
}
-
if (uobj != NULL && pgi == 0) {
/* Check the bottom layer. */
m = uvm_pagelookup(uobj,
entry->offset + (start - entry->start));
if (m != NULL) {
+
/*
* Object has the page for this entry
* offset.
*/
+
pgi = 1;
}
}
-
(void) subyte(vec, pgi);
}
-
if (uobj != NULL)
simple_unlock(&uobj->vmobjlock);
if (amap != NULL)
@@ -291,15 +293,15 @@ sys_mmap(p, v, retval)
struct filedesc *fdp = p->p_fd;
struct file *fp;
struct vnode *vp;
- caddr_t handle;
+ void *handle;
int error;
/*
* first, extract syscall args from the uap.
*/
- addr = (vaddr_t) SCARG(uap, addr);
- size = (vsize_t) SCARG(uap, len);
+ addr = (vaddr_t)SCARG(uap, addr);
+ size = (vsize_t)SCARG(uap, len);
prot = SCARG(uap, prot) & VM_PROT_ALL;
flags = SCARG(uap, flags);
fd = SCARG(uap, fd);
@@ -321,7 +323,7 @@ sys_mmap(p, v, retval)
pageoff = (pos & PAGE_MASK);
pos -= pageoff;
size += pageoff; /* add offset */
- size = (vsize_t) round_page(size); /* round up */
+ size = (vsize_t)round_page(size); /* round up */
if ((ssize_t) size < 0)
return (EINVAL); /* don't allow wrap */
@@ -351,10 +353,8 @@ sys_mmap(p, v, retval)
* we will refine our guess later (e.g. to account for VAC, etc)
*/
- if (addr < round_page((vaddr_t)p->p_vmspace->vm_daddr +
- MAXDSIZ))
- addr = round_page((vaddr_t)p->p_vmspace->vm_daddr +
- MAXDSIZ);
+ addr = MAX(addr, round_page((vaddr_t)p->p_vmspace->vm_daddr +
+ MAXDSIZ));
}
/*
@@ -446,12 +446,7 @@ sys_mmap(p, v, retval)
/* MAP_PRIVATE mappings can always write to */
maxprot |= VM_PROT_WRITE;
}
-
- /*
- * set handle to vnode
- */
-
- handle = (caddr_t)vp;
+ handle = vp;
} else { /* MAP_ANON case */
/*
@@ -476,7 +471,8 @@ sys_mmap(p, v, retval)
if ((flags & MAP_ANON) != 0 ||
((flags & MAP_PRIVATE) != 0 && (prot & PROT_WRITE) != 0)) {
if (size >
- (p->p_rlimit[RLIMIT_DATA].rlim_cur - ctob(p->p_vmspace->vm_dsize))) {
+ (p->p_rlimit[RLIMIT_DATA].rlim_cur -
+ ctob(p->p_vmspace->vm_dsize))) {
return (ENOMEM);
}
}
@@ -513,7 +509,7 @@ sys_msync(p, v, retval)
vaddr_t addr;
vsize_t size, pageoff;
vm_map_t map;
- int rv, flags, uvmflags;
+ int error, rv, flags, uvmflags;
/*
* extract syscall args from the uap
@@ -532,13 +528,13 @@ sys_msync(p, v, retval)
flags |= MS_SYNC;
/*
- * align the address to a page boundary, and adjust the size accordingly
+ * align the address to a page boundary and adjust the size accordingly.
*/
pageoff = (addr & PAGE_MASK);
addr -= pageoff;
size += pageoff;
- size = (vsize_t) round_page(size);
+ size = (vsize_t)round_page(size);
/* disallow wrap-around. */
if (addr + size < addr)
@@ -560,6 +556,7 @@ sys_msync(p, v, retval)
* This can be incorrect if the region splits or is coalesced
* with a neighbor.
*/
+
if (size == 0) {
vm_map_entry_t entry;
@@ -577,6 +574,7 @@ sys_msync(p, v, retval)
/*
* translate MS_ flags into PGO_ flags
*/
+
uvmflags = PGO_CLEANIT;
if (flags & MS_INVALIDATE)
uvmflags |= PGO_FREE;
@@ -585,27 +583,8 @@ sys_msync(p, v, retval)
else
uvmflags |= PGO_SYNCIO; /* XXXCDC: force sync for now! */
- /*
- * doit!
- */
- rv = uvm_map_clean(map, addr, addr+size, uvmflags);
-
- /*
- * and return...
- */
- switch (rv) {
- case KERN_SUCCESS:
- return(0);
- case KERN_INVALID_ADDRESS:
- return (ENOMEM);
- case KERN_FAILURE:
- return (EIO);
- case KERN_PAGES_LOCKED: /* XXXCDC: uvm doesn't return this */
- return (EBUSY);
- default:
- return (EINVAL);
- }
- /*NOTREACHED*/
+ error = uvm_map_clean(map, addr, addr+size, uvmflags);
+ return error;
}
/*
@@ -629,20 +608,20 @@ sys_munmap(p, v, retval)
struct vm_map_entry *dead_entries;
/*
- * get syscall args...
+ * get syscall args.
*/
- addr = (vaddr_t) SCARG(uap, addr);
- size = (vsize_t) SCARG(uap, len);
+ addr = (vaddr_t)SCARG(uap, addr);
+ size = (vsize_t)SCARG(uap, len);
/*
- * align the address to a page boundary, and adjust the size accordingly
+ * align the address to a page boundary and adjust the size accordingly.
*/
pageoff = (addr & PAGE_MASK);
addr -= pageoff;
size += pageoff;
- size = (vsize_t) round_page(size);
+ size = (vsize_t)round_page(size);
if ((int)size < 0)
return (EINVAL);
@@ -661,29 +640,20 @@ sys_munmap(p, v, retval)
return (EINVAL);
map = &p->p_vmspace->vm_map;
-
- vm_map_lock(map); /* lock map so we can checkprot */
-
/*
* interesting system call semantic: make sure entire range is
* allocated before allowing an unmap.
*/
+ vm_map_lock(map);
if (!uvm_map_checkprot(map, addr, addr + size, VM_PROT_NONE)) {
vm_map_unlock(map);
return (EINVAL);
}
-
- /*
- * doit!
- */
- (void) uvm_unmap_remove(map, addr, addr + size, &dead_entries);
-
- vm_map_unlock(map); /* and unlock */
-
+ uvm_unmap_remove(map, addr, addr + size, &dead_entries);
+ vm_map_unlock(map);
if (dead_entries != NULL)
uvm_unmap_detach(dead_entries, 0);
-
return (0);
}
@@ -705,7 +675,7 @@ sys_mprotect(p, v, retval)
vaddr_t addr;
vsize_t size, pageoff;
vm_prot_t prot;
- int rv;
+ int error;
/*
* extract syscall args from uap
@@ -716,27 +686,19 @@ sys_mprotect(p, v, retval)
prot = SCARG(uap, prot) & VM_PROT_ALL;
/*
- * align the address to a page boundary, and adjust the size accordingly
+ * align the address to a page boundary and adjust the size accordingly.
*/
+
pageoff = (addr & PAGE_MASK);
addr -= pageoff;
size += pageoff;
- size = (vsize_t) round_page(size);
+ size = (vsize_t)round_page(size);
+
if ((int)size < 0)
return (EINVAL);
-
- /*
- * doit
- */
-
- rv = uvm_map_protect(&p->p_vmspace->vm_map,
- addr, addr+size, prot, FALSE);
-
- if (rv == KERN_SUCCESS)
- return (0);
- if (rv == KERN_PROTECTION_FAILURE)
- return (EACCES);
- return (EINVAL);
+ error = uvm_map_protect(&p->p_vmspace->vm_map, addr, addr + size, prot,
+ FALSE);
+ return error;
}
/*
@@ -757,30 +719,26 @@ sys_minherit(p, v, retval)
vaddr_t addr;
vsize_t size, pageoff;
vm_inherit_t inherit;
+ int error;
addr = (vaddr_t)SCARG(uap, addr);
size = (vsize_t)SCARG(uap, len);
inherit = SCARG(uap, inherit);
+
/*
- * align the address to a page boundary, and adjust the size accordingly
+ * align the address to a page boundary and adjust the size accordingly.
*/
pageoff = (addr & PAGE_MASK);
addr -= pageoff;
size += pageoff;
- size = (vsize_t) round_page(size);
+ size = (vsize_t)round_page(size);
if ((int)size < 0)
return (EINVAL);
-
- switch (uvm_map_inherit(&p->p_vmspace->vm_map, addr, addr+size,
- inherit)) {
- case KERN_SUCCESS:
- return (0);
- case KERN_PROTECTION_FAILURE:
- return (EACCES);
- }
- return (EINVAL);
+ error = uvm_map_inherit(&p->p_vmspace->vm_map, addr, addr + size,
+ inherit);
+ return error;
}
/*
@@ -801,7 +759,7 @@ sys_madvise(p, v, retval)
} */ *uap = v;
vaddr_t addr;
vsize_t size, pageoff;
- int advice, rv;;
+ int advice, error;
addr = (vaddr_t)SCARG(uap, addr);
size = (vsize_t)SCARG(uap, len);
@@ -810,10 +768,11 @@ sys_madvise(p, v, retval)
/*
* align the address to a page boundary, and adjust the size accordingly
*/
+
pageoff = (addr & PAGE_MASK);
addr -= pageoff;
size += pageoff;
- size = (vsize_t) round_page(size);
+ size = (vsize_t)round_page(size);
if ((ssize_t)size <= 0)
return (EINVAL);
@@ -822,11 +781,12 @@ sys_madvise(p, v, retval)
case MADV_NORMAL:
case MADV_RANDOM:
case MADV_SEQUENTIAL:
- rv = uvm_map_advice(&p->p_vmspace->vm_map, addr, addr + size,
+ error = uvm_map_advice(&p->p_vmspace->vm_map, addr, addr + size,
advice);
break;
case MADV_WILLNEED:
+
/*
* Activate all these pages, pre-faulting them in if
* necessary.
@@ -836,29 +796,35 @@ sys_madvise(p, v, retval)
* Should invent a "weak" mode for uvm_fault()
* which would only do the PGO_LOCKED pgo_get().
*/
+
return (0);
case MADV_DONTNEED:
+
/*
* Deactivate all these pages. We don't need them
* any more. We don't, however, toss the data in
* the pages.
*/
- rv = uvm_map_clean(&p->p_vmspace->vm_map, addr, addr + size,
+
+ error = uvm_map_clean(&p->p_vmspace->vm_map, addr, addr + size,
PGO_DEACTIVATE);
break;
case MADV_FREE:
+
/*
* These pages contain no valid data, and may be
* garbage-collected. Toss all resources, including
* any swap space in use.
*/
- rv = uvm_map_clean(&p->p_vmspace->vm_map, addr, addr + size,
+
+ error = uvm_map_clean(&p->p_vmspace->vm_map, addr, addr + size,
PGO_FREE);
break;
case MADV_SPACEAVAIL:
+
/*
* XXXMRG What is this? I think it's:
*
@@ -869,24 +835,14 @@ sys_madvise(p, v, retval)
* as it will free swap space allocated to pages in core.
* There's also what to do for device/file/anonymous memory.
*/
+
return (EINVAL);
default:
return (EINVAL);
}
- switch (rv) {
- case KERN_SUCCESS:
- return (0);
- case KERN_NO_SPACE:
- return (EAGAIN);
- case KERN_INVALID_ADDRESS:
- return (ENOMEM);
- case KERN_FAILURE:
- return (EIO);
- }
-
- return (EINVAL);
+ return error;
}
/*
@@ -910,19 +866,21 @@ sys_mlock(p, v, retval)
/*
* extract syscall args from uap
*/
+
addr = (vaddr_t)SCARG(uap, addr);
size = (vsize_t)SCARG(uap, len);
/*
* align the address to a page boundary and adjust the size accordingly
*/
+
pageoff = (addr & PAGE_MASK);
addr -= pageoff;
size += pageoff;
- size = (vsize_t) round_page(size);
+ size = (vsize_t)round_page(size);
/* disallow wrap-around. */
- if (addr + (int)size < addr)
+ if (addr + size < addr)
return (EINVAL);
if (atop(size) + uvmexp.wired > uvmexp.wiredmax)
@@ -939,7 +897,7 @@ sys_mlock(p, v, retval)
error = uvm_map_pageable(&p->p_vmspace->vm_map, addr, addr+size, FALSE,
0);
- return (error == KERN_SUCCESS ? 0 : ENOMEM);
+ return error;
}
/*
@@ -970,13 +928,14 @@ sys_munlock(p, v, retval)
/*
* align the address to a page boundary, and adjust the size accordingly
*/
+
pageoff = (addr & PAGE_MASK);
addr -= pageoff;
size += pageoff;
- size = (vsize_t) round_page(size);
+ size = (vsize_t)round_page(size);
/* disallow wrap-around. */
- if (addr + (int)size < addr)
+ if (addr + size < addr)
return (EINVAL);
#ifndef pmap_wired_count
@@ -986,7 +945,7 @@ sys_munlock(p, v, retval)
error = uvm_map_pageable(&p->p_vmspace->vm_map, addr, addr+size, TRUE,
0);
- return (error == KERN_SUCCESS ? 0 : ENOMEM);
+ return error;
}
/*
@@ -1017,23 +976,6 @@ sys_mlockall(p, v, retval)
error = uvm_map_pageable_all(&p->p_vmspace->vm_map, flags,
p->p_rlimit[RLIMIT_MEMLOCK].rlim_cur);
- switch (error) {
- case KERN_SUCCESS:
- error = 0;
- break;
-
- case KERN_NO_SPACE: /* XXX overloaded */
- error = ENOMEM;
- break;
-
- default:
- /*
- * "Some or all of the memory could not be locked when
- * the call was made."
- */
- error = EAGAIN;
- }
-
return (error);
}
@@ -1068,13 +1010,13 @@ uvm_mmap(map, addr, size, prot, maxprot, flags, handle, foff, locklimit)
vsize_t size;
vm_prot_t prot, maxprot;
int flags;
- caddr_t handle; /* XXX: VNODE? */
+ void *handle;
voff_t foff;
vsize_t locklimit;
{
struct uvm_object *uobj;
struct vnode *vp;
- int retval;
+ int error;
int advice = UVM_ADV_NORMAL;
uvm_flag_t uvmflag = 0;
@@ -1097,7 +1039,6 @@ uvm_mmap(map, addr, size, prot, maxprot, flags, handle, foff, locklimit)
if ((flags & MAP_FIXED) == 0) {
*addr = round_page(*addr); /* round */
} else {
-
if (*addr & PAGE_MASK)
return(EINVAL);
uvmflag |= UVM_FLAG_FIXED;
@@ -1120,10 +1061,9 @@ uvm_mmap(map, addr, size, prot, maxprot, flags, handle, foff, locklimit)
uvmflag |= UVM_FLAG_OVERLAY;
} else {
-
- vp = (struct vnode *) handle; /* get vnode */
+ vp = (struct vnode *)handle;
if (vp->v_type != VCHR) {
- uobj = uvn_attach((void *) vp, (flags & MAP_SHARED) ?
+ uobj = uvn_attach((void *)vp, (flags & MAP_SHARED) ?
maxprot : (maxprot & ~VM_PROT_WRITE));
/* XXX for now, attach doesn't gain a ref */
@@ -1139,97 +1079,67 @@ uvm_mmap(map, addr, size, prot, maxprot, flags, handle, foff, locklimit)
*/
if (uobj == NULL && (prot & PROT_EXEC) == 0) {
maxprot &= ~VM_PROT_EXECUTE;
- uobj = udv_attach((void *) &vp->v_rdev,
+ uobj = udv_attach((void *)&vp->v_rdev,
(flags & MAP_SHARED) ? maxprot :
(maxprot & ~VM_PROT_WRITE), foff, size);
}
advice = UVM_ADV_RANDOM;
}
-
if (uobj == NULL)
return((vp->v_type == VREG) ? ENOMEM : EINVAL);
-
if ((flags & MAP_SHARED) == 0)
uvmflag |= UVM_FLAG_COPYONW;
}
- /*
- * set up mapping flags
- */
-
uvmflag = UVM_MAPFLAG(prot, maxprot,
(flags & MAP_SHARED) ? UVM_INH_SHARE : UVM_INH_COPY,
advice, uvmflag);
+ error = uvm_map(map, addr, size, uobj, foff, 0, uvmflag);
+ if (error) {
+ if (uobj)
+ uobj->pgops->pgo_detach(uobj);
+ return error;
+ }
/*
- * do it!
+ * POSIX 1003.1b -- if our address space was configured
+ * to lock all future mappings, wire the one we just made.
*/
- retval = uvm_map(map, addr, size, uobj, foff, 0, uvmflag);
+ if (prot == VM_PROT_NONE) {
- if (retval == KERN_SUCCESS) {
/*
- * POSIX 1003.1b -- if our address space was configured
- * to lock all future mappings, wire the one we just made.
+ * No more work to do in this case.
*/
- if (prot == VM_PROT_NONE) {
- /*
- * No more work to do in this case.
- */
- return (0);
- }
-
- vm_map_lock(map);
- if (map->flags & VM_MAP_WIREFUTURE) {
- if ((atop(size) + uvmexp.wired) > uvmexp.wiredmax
+ return (0);
+ }
+ vm_map_lock(map);
+ if (map->flags & VM_MAP_WIREFUTURE) {
+ if ((atop(size) + uvmexp.wired) > uvmexp.wiredmax
#ifdef pmap_wired_count
- || (locklimit != 0 && (size +
- ptoa(pmap_wired_count(vm_map_pmap(map)))) >
- locklimit)
+ || (locklimit != 0 && (size +
+ ptoa(pmap_wired_count(vm_map_pmap(map)))) >
+ locklimit)
#endif
- ) {
- retval = KERN_RESOURCE_SHORTAGE;
- vm_map_unlock(map);
- /* unmap the region! */
- (void) uvm_unmap(map, *addr, *addr + size);
- goto bad;
- }
- /*
- * uvm_map_pageable() always returns the map
- * unlocked.
- */
- retval = uvm_map_pageable(map, *addr, *addr + size,
- FALSE, UVM_LK_ENTER);
- if (retval != KERN_SUCCESS) {
- /* unmap the region! */
- (void) uvm_unmap(map, *addr, *addr + size);
- goto bad;
- }
- return (0);
+ ) {
+ vm_map_unlock(map);
+ uvm_unmap(map, *addr, *addr + size);
+ return ENOMEM;
}
- vm_map_unlock(map);
+ /*
+ * uvm_map_pageable() always returns the map unlocked.
+ */
+ error = uvm_map_pageable(map, *addr, *addr + size,
+ FALSE, UVM_LK_ENTER);
+ if (error) {
+ uvm_unmap(map, *addr, *addr + size);
+ return error;
+ }
return (0);
}
-
- /*
- * errors: first detach from the uobj, if any.
- */
-
- if (uobj)
- uobj->pgops->pgo_detach(uobj);
-
- bad:
- switch (retval) {
- case KERN_INVALID_ADDRESS:
- case KERN_NO_SPACE:
- return(ENOMEM);
- case KERN_RESOURCE_SHORTAGE:
- return (EAGAIN);
- case KERN_PROTECTION_FAILURE:
- return(EACCES);
- }
- return(EINVAL);
+ vm_map_unlock(map);
+ return 0;
}
diff --git a/sys/uvm/uvm_page.c b/sys/uvm/uvm_page.c
index f7ebbd77f80..217ae468046 100644
--- a/sys/uvm/uvm_page.c
+++ b/sys/uvm/uvm_page.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_page.c,v 1.32 2001/11/27 05:27:12 art Exp $ */
+/* $OpenBSD: uvm_page.c,v 1.33 2001/11/28 13:47:40 art Exp $ */
/* $NetBSD: uvm_page.c,v 1.51 2001/03/09 01:02:12 chs Exp $ */
/*
@@ -1071,7 +1071,7 @@ uvm_pagealloc_contig(size, low, high, alignment)
addr = vm_map_min(kernel_map);
if (uvm_map(kernel_map, &addr, size, NULL, UVM_UNKNOWN_OFFSET, 0,
UVM_MAPFLAG(UVM_PROT_ALL, UVM_PROT_ALL, UVM_INH_NONE,
- UVM_ADV_RANDOM, 0)) != KERN_SUCCESS) {
+ UVM_ADV_RANDOM, 0))) {
uvm_pglistfree(&pglist);
return 0;
}
diff --git a/sys/uvm/uvm_pager.c b/sys/uvm/uvm_pager.c
index 2fded9caf08..2c7619d6c04 100644
--- a/sys/uvm/uvm_pager.c
+++ b/sys/uvm/uvm_pager.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: uvm_pager.c,v 1.23 2001/11/27 05:27:12 art Exp $ */
-/* $NetBSD: uvm_pager.c,v 1.41 2001/02/18 19:26:50 chs Exp $ */
+/* $OpenBSD: uvm_pager.c,v 1.24 2001/11/28 13:47:40 art Exp $ */
+/* $NetBSD: uvm_pager.c,v 1.43 2001/03/15 06:10:58 chs Exp $ */
/*
*
@@ -149,7 +149,7 @@ ReStart:
kva = 0; /* let system choose VA */
if (uvm_map(pager_map, &kva, size, NULL,
- UVM_UNKNOWN_OFFSET, 0, UVM_FLAG_NOMERGE) != KERN_SUCCESS) {
+ UVM_UNKNOWN_OFFSET, 0, UVM_FLAG_NOMERGE) != 0) {
if (curproc == uvm.pagedaemon_proc) {
simple_lock(&pager_map_wanted_lock);
if (emerginuse) {
@@ -223,7 +223,7 @@ uvm_pagermapout(kva, npages)
}
vm_map_lock(pager_map);
- (void) uvm_unmap_remove(pager_map, kva, kva + size, &entries);
+ uvm_unmap_remove(pager_map, kva, kva + size, &entries);
simple_lock(&pager_map_wanted_lock);
if (pager_map_wanted) {
pager_map_wanted = FALSE;
@@ -231,11 +231,11 @@ uvm_pagermapout(kva, npages)
}
simple_unlock(&pager_map_wanted_lock);
vm_map_unlock(pager_map);
+
remove:
pmap_remove(pmap_kernel(), kva, kva + (npages << PAGE_SHIFT));
if (entries)
uvm_unmap_detach(entries, 0);
-
UVMHIST_LOG(maphist,"<- done",0,0,0,0);
}
@@ -396,22 +396,22 @@ uvm_mk_pcluster(uobj, pps, npages, center, flags, mlo, mhi)
* => flags (first two for non-swap-backed pages)
* PGO_ALLPAGES: all pages in uobj are valid targets
* PGO_DOACTCLUST: include "PQ_ACTIVE" pages as valid targets
- * PGO_SYNCIO: do SYNC I/O (no async)
+ * PGO_SYNCIO: wait for i/o to complete
* PGO_PDFREECLUST: pagedaemon: drop cluster on successful I/O
* => start/stop: if (uobj && !PGO_ALLPAGES) limit targets to this range
* if (!uobj) start is the (daddr_t) of the starting swapblk
* => return state:
- * 1. we return the VM_PAGER status code of the pageout
+ * 1. we return the error code of the pageout
* 2. we return with the page queues unlocked
* 3. if (uobj != NULL) [!swap_backed] we return with
* uobj locked _only_ if PGO_PDFREECLUST is set
- * AND result != VM_PAGER_PEND. in all other cases
+ * AND result == 0 AND async. in all other cases
* we return with uobj unlocked. [this is a hack
* that allows the pagedaemon to save one lock/unlock
* pair in the !swap_backed case since we have to
* lock the uobj to drop the cluster anyway]
* 4. on errors we always drop the cluster. thus, if we return
- * !PEND, !OK, then the caller only has to worry about
+ * an error, then the caller only has to worry about
* un-busying the main page (not the cluster pages).
* 5. on success, if !PGO_PDFREECLUST, we return the cluster
* with all pages busy (caller must un-busy and check
@@ -428,6 +428,7 @@ uvm_pager_put(uobj, pg, ppsp_ptr, npages, flags, start, stop)
{
int result;
daddr_t swblk;
+ boolean_t async = (flags & PGO_SYNCIO) == 0;
struct vm_page **ppsp = *ppsp_ptr;
UVMHIST_FUNC("uvm_pager_put"); UVMHIST_CALLED(ubchist);
@@ -502,20 +503,21 @@ ReTry:
* i/o is done...]
*/
- if (result == VM_PAGER_PEND || result == VM_PAGER_OK) {
- if (result == VM_PAGER_OK && (flags & PGO_PDFREECLUST)) {
+ if (result == 0) {
+ if (flags & PGO_PDFREECLUST && !async) {
+
/*
- * drop cluster and relock object (only if I/O is
- * not pending)
+ * drop cluster and relock object for sync i/o.
*/
+
if (uobj)
/* required for dropcluster */
simple_lock(&uobj->vmobjlock);
if (*npages > 1 || pg == NULL)
uvm_pager_dropcluster(uobj, pg, ppsp, npages,
PGO_PDFREECLUST);
- /* if (uobj): object still locked, as per
- * return-state item #3 */
+
+ /* if (uobj): object still locked, as per #3 */
}
return (result);
}
@@ -540,7 +542,7 @@ ReTry:
*/
if (uobj == NULL && pg != NULL) {
- int nswblk = (result == VM_PAGER_AGAIN) ? swblk : 0;
+ int nswblk = (result == EAGAIN) ? swblk : 0;
if (pg->pqflags & PQ_ANON) {
simple_lock(&pg->uanon->an_lock);
pg->uanon->an_swslot = nswblk;
@@ -553,7 +555,7 @@ ReTry:
simple_unlock(&pg->uobject->vmobjlock);
}
}
- if (result == VM_PAGER_AGAIN) {
+ if (result == EAGAIN) {
/*
* for transient failures, free all the swslots that
@@ -878,29 +880,3 @@ freed:
pool_put(&bufpool, bp);
splx(s);
}
-
-/*
- * translate unix errno values to VM_PAGER_*.
- */
-
-int
-uvm_errno2vmerror(errno)
- int errno;
-{
- switch (errno) {
- case 0:
- return VM_PAGER_OK;
- case EINVAL:
- return VM_PAGER_BAD;
- case EINPROGRESS:
- return VM_PAGER_PEND;
- case EIO:
- return VM_PAGER_ERROR;
- case EAGAIN:
- return VM_PAGER_AGAIN;
- case EBUSY:
- return VM_PAGER_UNLOCK;
- default:
- return VM_PAGER_ERROR;
- }
-}
diff --git a/sys/uvm/uvm_pager.h b/sys/uvm/uvm_pager.h
index b246e815e04..a826ada04de 100644
--- a/sys/uvm/uvm_pager.h
+++ b/sys/uvm/uvm_pager.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: uvm_pager.h,v 1.14 2001/11/10 18:42:31 art Exp $ */
-/* $NetBSD: uvm_pager.h,v 1.20 2000/11/27 08:40:05 chs Exp $ */
+/* $OpenBSD: uvm_pager.h,v 1.15 2001/11/28 13:47:40 art Exp $ */
+/* $NetBSD: uvm_pager.h,v 1.21 2001/03/10 22:46:50 chs Exp $ */
/*
*
@@ -166,7 +166,6 @@ void uvm_pagermapout __P((vaddr_t, int));
struct vm_page **uvm_mk_pcluster __P((struct uvm_object *, struct vm_page **,
int *, struct vm_page *, int,
voff_t, voff_t));
-int uvm_errno2vmerror __P((int));
/* Flags to uvm_pagermapin() */
#define UVMPAGER_MAPIN_WAITOK 0x01 /* it's okay to wait */
@@ -174,27 +173,6 @@ int uvm_errno2vmerror __P((int));
#define UVMPAGER_MAPIN_WRITE 0x00 /* device -> host (pseudo flag) */
/*
- * get/put return values
- * OK operation was successful
- * BAD specified data was out of the accepted range
- * FAIL specified data was in range, but doesn't exist
- * PEND operations was initiated but not completed
- * ERROR error while accessing data that is in range and exists
- * AGAIN temporary resource shortage prevented operation from happening
- * UNLOCK unlock the map and try again
- * REFAULT [uvm_fault internal use only!] unable to relock data structures,
- * thus the mapping needs to be reverified before we can procede
- */
-#define VM_PAGER_OK 0
-#define VM_PAGER_BAD 1
-#define VM_PAGER_FAIL 2
-#define VM_PAGER_PEND 3
-#define VM_PAGER_ERROR 4
-#define VM_PAGER_AGAIN 5
-#define VM_PAGER_UNLOCK 6
-#define VM_PAGER_REFAULT 7
-
-/*
* XXX
* this is needed until the device strategy interface
* is changed to do physically-addressed i/o.
diff --git a/sys/uvm/uvm_param.h b/sys/uvm/uvm_param.h
index 78b3f1bc5ba..46b0b1a79e0 100644
--- a/sys/uvm/uvm_param.h
+++ b/sys/uvm/uvm_param.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: uvm_param.h,v 1.3 2001/11/27 05:27:12 art Exp $ */
-/* $NetBSD: uvm_param.h,v 1.5 2001/03/09 01:02:12 chs Exp $ */
+/* $OpenBSD: uvm_param.h,v 1.4 2001/11/28 13:47:40 art Exp $ */
+/* $NetBSD: uvm_param.h,v 1.7 2001/03/21 03:16:06 chs Exp $ */
/*
* Copyright (c) 1991, 1993
@@ -135,20 +135,6 @@ struct _ps_strings {
#define SWAPSKIPBYTES 8192 /* never use at the start of a swap space */
-/*
- * Return values from the VM routines.
- */
-#define KERN_SUCCESS 0
-#define KERN_INVALID_ADDRESS 1
-#define KERN_PROTECTION_FAILURE 2
-#define KERN_NO_SPACE 3
-#define KERN_INVALID_ARGUMENT 4
-#define KERN_FAILURE 5
-#define KERN_RESOURCE_SHORTAGE 6
-#define KERN_NOT_RECEIVER 7
-#define KERN_NO_ACCESS 8
-#define KERN_PAGES_LOCKED 9
-
#ifndef ASSEMBLER
/*
* Convert addresses to pages and vice versa.
@@ -167,7 +153,7 @@ struct _ps_strings {
extern psize_t mem_size; /* size of physical memory (bytes) */
extern int ubc_nwins; /* number of UBC mapping windows */
-extern int ubc_winsize; /* size of a UBC mapping window */
+extern int ubc_winshift; /* shift for a UBC mapping window */
#else
/* out-of-kernel versions of round_page and trunc_page */
diff --git a/sys/uvm/uvm_pdaemon.c b/sys/uvm/uvm_pdaemon.c
index 5708b89a507..d25cd2d6119 100644
--- a/sys/uvm/uvm_pdaemon.c
+++ b/sys/uvm/uvm_pdaemon.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: uvm_pdaemon.c,v 1.18 2001/11/12 01:26:10 art Exp $ */
-/* $NetBSD: uvm_pdaemon.c,v 1.30 2001/03/09 01:02:12 chs Exp $ */
+/* $OpenBSD: uvm_pdaemon.c,v 1.19 2001/11/28 13:47:40 art Exp $ */
+/* $NetBSD: uvm_pdaemon.c,v 1.31 2001/03/10 22:46:50 chs Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -767,18 +767,14 @@ uvmpd_scan_inactive(pglst)
*
* note locking semantics of uvm_pager_put with PGO_PDFREECLUST:
* IN: locked: uobj (if !swap_backed), page queues
- * OUT: locked: uobj (if !swap_backed && result !=VM_PAGER_PEND)
- * !locked: pageqs, uobj (if swap_backed || VM_PAGER_PEND)
- *
- * [the bit about VM_PAGER_PEND saves us one lock-unlock pair]
+ * OUT:!locked: pageqs, uobj
*/
/* locked: uobj (if !swap_backed), page queues */
uvmexp.pdpageouts++;
result = uvm_pager_put(swap_backed ? NULL : uobj, p,
&ppsp, &npages, PGO_ALLPAGES|PGO_PDFREECLUST, start, 0);
- /* locked: uobj (if !swap_backed && result != PEND) */
- /* unlocked: pageqs, object (if swap_backed ||result == PEND) */
+ /* unlocked: pageqs, uobj */
/*
* if we did i/o to swap, zero swslot to indicate that we are
@@ -789,35 +785,10 @@ uvmpd_scan_inactive(pglst)
swslot = 0; /* done with this cluster */
/*
- * first, we check for VM_PAGER_PEND which means that the
- * async I/O is in progress and the async I/O done routine
- * will clean up after us. in this case we move on to the
- * next page.
- *
- * there is a very remote chance that the pending async i/o can
- * finish _before_ we get here. if that happens, our page "p"
- * may no longer be on the inactive queue. so we verify this
- * when determining the next page (starting over at the head if
- * we've lost our inactive page).
+ * if the pageout failed, reactivate the page and continue.
*/
- if (result == VM_PAGER_PEND) {
- uvmexp.paging += npages;
- uvm_lock_pageq();
- uvmexp.pdpending++;
- if (p) {
- if (p->pqflags & PQ_INACTIVE)
- nextpg = TAILQ_NEXT(p, pageq);
- else
- nextpg = TAILQ_FIRST(pglst);
- } else {
- nextpg = NULL;
- }
- continue;
- }
-
- if (result == VM_PAGER_ERROR &&
- curproc == uvm.pagedaemon_proc) {
+ if (result == EIO && curproc == uvm.pagedaemon_proc) {
uvm_lock_pageq();
nextpg = TAILQ_NEXT(p, pageq);
uvm_pageactivate(p);
@@ -825,134 +796,20 @@ uvmpd_scan_inactive(pglst)
}
/*
- * clean up "p" if we have one
+ * the pageout is in progress. bump counters and set up
+ * for the next loop.
*/
+ uvm_lock_pageq();
+ uvmexp.paging += npages;
+ uvmexp.pdpending++;
if (p) {
- /*
- * the I/O request to "p" is done and uvm_pager_put
- * has freed any cluster pages it may have allocated
- * during I/O. all that is left for us to do is
- * clean up page "p" (which is still PG_BUSY).
- *
- * our result could be one of the following:
- * VM_PAGER_OK: successful pageout
- *
- * VM_PAGER_AGAIN: tmp resource shortage, we skip
- * to next page
- * VM_PAGER_{FAIL,ERROR,BAD}: an error. we
- * "reactivate" page to get it out of the way (it
- * will eventually drift back into the inactive
- * queue for a retry).
- * VM_PAGER_UNLOCK: should never see this as it is
- * only valid for "get" operations
- */
-
- /* relock p's object: page queues not lock yet, so
- * no need for "try" */
-
- /* !swap_backed case: already locked... */
- if (swap_backed) {
- if (anon)
- simple_lock(&anon->an_lock);
- else
- simple_lock(&uobj->vmobjlock);
- }
-
- /* handle PG_WANTED now */
- if (p->flags & PG_WANTED)
- /* still holding object lock */
- wakeup(p);
-
- p->flags &= ~(PG_BUSY|PG_WANTED);
- UVM_PAGE_OWN(p, NULL);
-
- /* released during I/O? */
- if (p->flags & PG_RELEASED) {
- if (anon) {
- /* remove page so we can get nextpg */
- anon->u.an_page = NULL;
-
- simple_unlock(&anon->an_lock);
- uvm_anfree(anon); /* kills anon */
- pmap_page_protect(p, VM_PROT_NONE);
- anon = NULL;
- uvm_lock_pageq();
- nextpg = TAILQ_NEXT(p, pageq);
- /* free released page */
- uvm_pagefree(p);
-
- } else {
-
- /*
- * pgo_releasepg nukes the page and
- * gets "nextpg" for us. it returns
- * with the page queues locked (when
- * given nextpg ptr).
- */
-
- if (!uobj->pgops->pgo_releasepg(p,
- &nextpg))
- /* uobj died after release */
- uobj = NULL;
-
- /*
- * lock page queues here so that they're
- * always locked at the end of the loop.
- */
-
- uvm_lock_pageq();
- }
- } else { /* page was not released during I/O */
- uvm_lock_pageq();
+ if (p->pqflags & PQ_INACTIVE)
nextpg = TAILQ_NEXT(p, pageq);
- if (result != VM_PAGER_OK) {
- /* pageout was a failure... */
- if (result != VM_PAGER_AGAIN)
- uvm_pageactivate(p);
- pmap_clear_reference(p);
- /* XXXCDC: if (swap_backed) FREE p's
- * swap block? */
- } else {
- /* pageout was a success... */
- pmap_clear_reference(p);
- pmap_clear_modify(p);
- p->flags |= PG_CLEAN;
- }
- }
-
- /*
- * drop object lock (if there is an object left). do
- * a safety check of nextpg to make sure it is on the
- * inactive queue (it should be since PG_BUSY pages on
- * the inactive queue can't be re-queued [note: not
- * true for active queue]).
- */
-
- if (anon)
- simple_unlock(&anon->an_lock);
- else if (uobj)
- simple_unlock(&uobj->vmobjlock);
-
+ else
+ nextpg = TAILQ_FIRST(pglst);
} else {
-
- /*
- * if p is null in this loop, make sure it stays null
- * in the next loop.
- */
-
nextpg = NULL;
-
- /*
- * lock page queues here just so they're always locked
- * at the end of the loop.
- */
-
- uvm_lock_pageq();
- }
-
- if (nextpg && (nextpg->pqflags & PQ_INACTIVE) == 0) {
- nextpg = TAILQ_FIRST(pglst); /* reload! */
}
}
return (retval);
diff --git a/sys/uvm/uvm_swap.c b/sys/uvm/uvm_swap.c
index c4298200688..fc1d6861de1 100644
--- a/sys/uvm/uvm_swap.c
+++ b/sys/uvm/uvm_swap.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: uvm_swap.c,v 1.42 2001/11/27 05:27:12 art Exp $ */
-/* $NetBSD: uvm_swap.c,v 1.46 2001/02/18 21:19:08 chs Exp $ */
+/* $OpenBSD: uvm_swap.c,v 1.43 2001/11/28 13:47:40 art Exp $ */
+/* $NetBSD: uvm_swap.c,v 1.47 2001/03/10 22:46:51 chs Exp $ */
/*
* Copyright (c) 1995, 1996, 1997 Matthew R. Green
@@ -1754,12 +1754,13 @@ uvm_swap_get(page, swslot, flags)
uvmexp.nswget++;
KASSERT(flags & PGO_SYNCIO);
if (swslot == SWSLOT_BAD) {
- return VM_PAGER_ERROR;
+ return EIO;
}
/*
* this page is (about to be) no longer only in swap.
*/
+
simple_lock(&uvm.swap_data_lock);
uvmexp.swpgonly--;
simple_unlock(&uvm.swap_data_lock);
@@ -1767,10 +1768,12 @@ uvm_swap_get(page, swslot, flags)
result = uvm_swap_io(&page, swslot, 1, B_READ |
((flags & PGO_SYNCIO) ? 0 : B_ASYNC));
- if (result != VM_PAGER_OK && result != VM_PAGER_PEND) {
+ if (result != 0) {
+
/*
* oops, the read failed so it really is still only in swap.
*/
+
simple_lock(&uvm.swap_data_lock);
uvmexp.swpgonly++;
simple_unlock(&uvm.swap_data_lock);
@@ -1791,7 +1794,7 @@ uvm_swap_io(pps, startslot, npages, flags)
daddr_t startblk;
struct buf *bp;
vaddr_t kva;
- int result, s, mapinflags, pflag;
+ int error, s, mapinflags, pflag;
boolean_t write, async;
#ifdef UVM_SWAP_ENCRYPT
vaddr_t dstkva;
@@ -1821,7 +1824,7 @@ uvm_swap_io(pps, startslot, npages, flags)
mapinflags |= UVMPAGER_MAPIN_WAITOK;
kva = uvm_pagermapin(pps, npages, mapinflags);
if (kva == 0)
- return (VM_PAGER_AGAIN);
+ return (EAGAIN);
#ifdef UVM_SWAP_ENCRYPT
if (write) {
@@ -1867,14 +1870,14 @@ uvm_swap_io(pps, startslot, npages, flags)
if (!uvm_swap_allocpages(tpps, npages)) {
uvm_pagermapout(kva, npages);
- return (VM_PAGER_AGAIN);
+ return (EAGAIN);
}
dstkva = uvm_pagermapin(tpps, npages, swmapflags);
if (dstkva == NULL) {
uvm_pagermapout(kva, npages);
uvm_swap_freepages(tpps, npages);
- return (VM_PAGER_AGAIN);
+ return (EAGAIN);
}
src = (caddr_t) kva;
@@ -1928,7 +1931,7 @@ uvm_swap_io(pps, startslot, npages, flags)
uvm_swap_freepages(tpps, npages);
}
#endif
- return (VM_PAGER_AGAIN);
+ return (EAGAIN);
}
#ifdef UVM_SWAP_ENCRYPT
@@ -1992,13 +1995,12 @@ uvm_swap_io(pps, startslot, npages, flags)
*/
VOP_STRATEGY(bp);
if (async)
- return (VM_PAGER_PEND);
+ return 0;
/*
* must be sync i/o. wait for it to finish
*/
- (void) biowait(bp);
- result = (bp->b_flags & B_ERROR) ? VM_PAGER_ERROR : VM_PAGER_OK;
+ error = biowait(bp);
#ifdef UVM_SWAP_ENCRYPT
/*
@@ -2050,8 +2052,8 @@ uvm_swap_io(pps, startslot, npages, flags)
/*
* finally return.
*/
- UVMHIST_LOG(pdhist, "<- done (sync) result=%d", result, 0, 0, 0);
- return (result);
+ UVMHIST_LOG(pdhist, "<- done (sync) error=%d", error, 0, 0, 0);
+ return (error);
}
static void
diff --git a/sys/uvm/uvm_unix.c b/sys/uvm/uvm_unix.c
index 44863db3e2d..a2fde83db35 100644
--- a/sys/uvm/uvm_unix.c
+++ b/sys/uvm/uvm_unix.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: uvm_unix.c,v 1.17 2001/11/07 02:55:51 art Exp $ */
-/* $NetBSD: uvm_unix.c,v 1.18 2000/09/13 15:00:25 thorpej Exp $ */
+/* $OpenBSD: uvm_unix.c,v 1.18 2001/11/28 13:47:40 art Exp $ */
+/* $NetBSD: uvm_unix.c,v 1.20 2001/03/19 02:25:33 simonb Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -78,7 +78,7 @@ sys_obreak(p, v, retval)
struct vmspace *vm = p->p_vmspace;
vaddr_t new, old;
ssize_t diff;
- int rv;
+ int error;
old = (vaddr_t)vm->vm_daddr;
new = round_page((vaddr_t)SCARG(uap, nsize));
@@ -95,26 +95,23 @@ sys_obreak(p, v, retval)
* grow or shrink?
*/
if (diff > 0) {
- rv = uvm_map(&vm->vm_map, &old, diff, NULL, UVM_UNKNOWN_OFFSET,
- 0, UVM_MAPFLAG(UVM_PROT_ALL, UVM_PROT_ALL, UVM_INH_COPY,
+ error = uvm_map(&vm->vm_map, &old, diff, NULL,
+ UVM_UNKNOWN_OFFSET, 0,
+ UVM_MAPFLAG(UVM_PROT_ALL, UVM_PROT_ALL, UVM_INH_COPY,
UVM_ADV_NORMAL, UVM_FLAG_AMAPPAD|UVM_FLAG_FIXED|
UVM_FLAG_OVERLAY|UVM_FLAG_COPYONW));
- if (rv == KERN_SUCCESS) {
- vm->vm_dsize += atop(diff);
- return (0);
+ if (error) {
+ uprintf("sbrk: grow %ld failed, error = %d\n",
+ (long)diff, error);
+ return error;
}
+ vm->vm_dsize += atop(diff);
} else {
- rv = uvm_deallocate(&vm->vm_map, new, -diff);
- if (rv == KERN_SUCCESS) {
- vm->vm_dsize -= atop(-diff);
- return (0);
- }
+ uvm_deallocate(&vm->vm_map, new, -diff);
+ vm->vm_dsize -= atop(-diff);
}
- uprintf("sbrk: %s %ld failed, return = %d\n",
- diff > 0 ? "grow" : "shrink",
- (long)(diff > 0 ? diff : -diff), rv);
- return (ENOMEM);
+ return (0);
}
/*
diff --git a/sys/uvm/uvm_user.c b/sys/uvm/uvm_user.c
index cd2cacbe837..e6a6ba1d738 100644
--- a/sys/uvm/uvm_user.c
+++ b/sys/uvm/uvm_user.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: uvm_user.c,v 1.6 2001/11/06 01:35:04 art Exp $ */
-/* $NetBSD: uvm_user.c,v 1.8 2000/06/27 17:29:37 mrg Exp $ */
+/* $OpenBSD: uvm_user.c,v 1.7 2001/11/28 13:47:40 art Exp $ */
+/* $NetBSD: uvm_user.c,v 1.9 2001/03/15 06:10:58 chs Exp $ */
/*
*
@@ -50,19 +50,15 @@
* uvm_deallocate: deallocate memory (unmap)
*/
-int
+void
uvm_deallocate(map, start, size)
vm_map_t map;
vaddr_t start;
vsize_t size;
{
- if (map == NULL)
- panic("uvm_deallocate with null map");
-
- if (size == (vaddr_t) 0)
- return (KERN_SUCCESS);
-
- return(uvm_unmap(map, trunc_page(start), round_page(start+size)));
+ if (size == 0)
+ return;
+ uvm_unmap(map, trunc_page(start), round_page(start + size));
}
diff --git a/sys/uvm/uvm_vnode.c b/sys/uvm/uvm_vnode.c
index 667cbc5b458..cef3499f281 100644
--- a/sys/uvm/uvm_vnode.c
+++ b/sys/uvm/uvm_vnode.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: uvm_vnode.c,v 1.25 2001/11/27 05:27:12 art Exp $ */
-/* $NetBSD: uvm_vnode.c,v 1.47 2001/03/09 01:02:13 chs Exp $ */
+/* $OpenBSD: uvm_vnode.c,v 1.26 2001/11/28 13:47:40 art Exp $ */
+/* $NetBSD: uvm_vnode.c,v 1.48 2001/03/10 22:46:51 chs Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -247,8 +247,6 @@ uvn_reference(uobj)
* remove a reference to a VM object.
*
* => caller must call with object unlocked and map locked.
- * => this starts the detach process, but doesn't have to finish it
- * (async i/o could still be pending).
*/
static void
uvn_detach(uobj)
@@ -300,7 +298,7 @@ uvn_releasepg(pg, nextpgp)
* there are two tailq's in the uvm. structure... one for pending async
* i/o and one for "done" async i/o. to do an async i/o one puts
* a buf on the "pending" list (protected by splbio()), starts the
- * i/o and returns VM_PAGER_PEND. when the i/o is done, we expect
+ * i/o and returns 0. when the i/o is done, we expect
* some sort of "i/o done" function to be called (at splbio(), interrupt
* time). this function should remove the buf from the pending list
* and place it on the "done" list and wakeup the daemon. the daemon
@@ -391,6 +389,7 @@ uvn_flush(uobj, start, stop, flags)
int s;
int npages, result, lcv;
boolean_t retval, need_iosync, by_list, needs_clean, all, wasclean;
+ boolean_t async = (flags & PGO_SYNCIO) == 0;
voff_t curoff;
u_short pp_version;
UVMHIST_FUNC("uvn_flush"); UVMHIST_CALLED(maphist);
@@ -522,7 +521,7 @@ uvn_flush(uobj, start, stop, flags)
if ((flags & PGO_CLEANIT) == 0 || (pp->flags & PG_BUSY) != 0) {
needs_clean = FALSE;
- if (flags & PGO_SYNCIO)
+ if (!async)
need_iosync = TRUE;
} else {
@@ -587,7 +586,6 @@ uvn_flush(uobj, start, stop, flags)
UVM_PAGE_OWN(pp, "uvn_flush");
pmap_page_protect(pp, VM_PROT_READ);
pp_version = pp->version;
-ReTry:
ppsp = pps;
npages = sizeof(pps) / sizeof(struct vm_page *);
@@ -609,34 +607,10 @@ ReTry:
uvm_lock_pageq();
/*
- * VM_PAGER_AGAIN: given the structure of this pager, this
- * can only happen when we are doing async I/O and can't
- * map the pages into kernel memory (pager_map) due to lack
- * of vm space. if this happens we drop back to sync I/O.
- */
-
- if (result == VM_PAGER_AGAIN) {
-
- /*
- * it is unlikely, but page could have been released
- * while we had the object lock dropped. we ignore
- * this now and retry the I/O. we will detect and
- * handle the released page after the syncio I/O
- * completes.
- */
-#ifdef DIAGNOSTIC
- if (flags & PGO_SYNCIO)
- panic("uvn_flush: PGO_SYNCIO return 'try again' error (impossible)");
-#endif
- flags |= PGO_SYNCIO;
- goto ReTry;
- }
-
- /*
- * the cleaning operation is now done. finish up. note that
- * on error (!OK, !PEND) uvm_pager_put drops the cluster for us.
- * if success (OK, PEND) then uvm_pager_put returns the cluster
- * to us in ppsp/npages.
+ * the cleaning operation is now done. finish up. note that
+ * on error uvm_pager_put drops the cluster for us.
+ * on success uvm_pager_put returns the cluster to us in
+ * ppsp/npages.
*/
/*
@@ -644,7 +618,7 @@ ReTry:
* we can move on to the next page.
*/
- if (result == VM_PAGER_PEND &&
+ if (result == 0 && async &&
(flags & (PGO_DEACTIVATE|PGO_FREE)) == 0) {
/*
@@ -701,17 +675,17 @@ ReTry:
* verify the page wasn't moved while obj was
* unlocked
*/
- if (result == VM_PAGER_PEND && ptmp->uobject != uobj)
+ if (result == 0 && async && ptmp->uobject != uobj)
continue;
/*
* unbusy the page if I/O is done. note that for
- * pending I/O it is possible that the I/O op
+ * async I/O it is possible that the I/O op
* finished before we relocked the object (in
* which case the page is no longer busy).
*/
- if (result != VM_PAGER_PEND) {
+ if (result != 0 || !async) {
if (ptmp->flags & PG_WANTED) {
/* still holding object lock */
wakeup(ptmp);
@@ -730,7 +704,7 @@ ReTry:
continue;
} else {
if ((flags & PGO_WEAK) == 0 &&
- !(result == VM_PAGER_ERROR &&
+ !(result == EIO &&
curproc == uvm.pagedaemon_proc)) {
ptmp->flags |=
(PG_CLEAN|PG_CLEANCHK);
@@ -753,12 +727,12 @@ ReTry:
uvm_pagedeactivate(ptmp);
}
} else if (flags & PGO_FREE) {
- if (result == VM_PAGER_PEND) {
+ if (result == 0 && async) {
if ((ptmp->flags & PG_BUSY) != 0)
/* signal for i/o done */
ptmp->flags |= PG_RELEASED;
} else {
- if (result != VM_PAGER_OK) {
+ if (result != 0) {
printf("uvn_flush: obj=%p, "
"offset=0x%llx. error %d\n",
pp->uobject,
@@ -852,7 +826,7 @@ uvn_put(uobj, pps, npages, flags)
int error;
error = VOP_PUTPAGES(vp, pps, npages, flags, NULL);
- return uvm_errno2vmerror(error);
+ return error;
}
@@ -884,7 +858,7 @@ uvn_get(uobj, offset, pps, npagesp, centeridx, access_type, advice, flags)
UVMHIST_LOG(ubchist, "vp %p off 0x%x", vp, (int)offset, 0,0);
error = VOP_GETPAGES(vp, offset, pps, npagesp, centeridx,
access_type, advice, flags);
- return uvm_errno2vmerror(error);
+ return error;
}