From 7886fa77b7f089a120d84c0225e84e2e889957ae Mon Sep 17 00:00:00 2001 From: tholo Date: Tue, 7 Jan 1997 05:37:32 +0000 Subject: [PATCH] Fix for final ptdi panic on i386 --- sys/arch/i386/i386/pmap.c | 19 ++++++++++++++++++- sys/arch/i386/i386/pmap.old.c | 19 ++++++++++++++++++- sys/arch/i386/include/pmap.h | 3 ++- sys/arch/i386/include/pmap.old.h | 3 ++- sys/miscfs/procfs/procfs_mem.c | 8 ++++++-- sys/vm/vm_extern.h | 6 +++--- sys/vm/vm_glue.c | 17 ++++++++++------- sys/vm/vm_mmap.c | 6 +++--- 8 files changed, 62 insertions(+), 19 deletions(-) diff --git a/sys/arch/i386/i386/pmap.c b/sys/arch/i386/i386/pmap.c index cf4c5717c1f..3e7d0d0db44 100644 --- a/sys/arch/i386/i386/pmap.c +++ b/sys/arch/i386/i386/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.15 1996/10/25 11:14:13 deraadt Exp $ */ +/* $OpenBSD: pmap.c,v 1.16 1997/01/07 05:37:32 tholo Exp $ */ /* $NetBSD: pmap.c,v 1.36 1996/05/03 19:42:22 christos Exp $ */ /* @@ -1726,6 +1726,23 @@ pmap_changebit(pa, setbits, maskbits) splx(s); } +void +pmap_prefault(map, v, l) + vm_map_t map; + vm_offset_t v; + vm_size_t l; +{ + vm_offset_t pv, pv2; + + for (pv = v; pv < v + l ; pv += ~PD_MASK + 1) { + if (!pmap_pde_v(pmap_pde(map->pmap, pv))) { + pv2 = trunc_page(vtopte(pv)); + vm_fault(map, pv2, VM_PROT_READ, FALSE); + } + pv &= PD_MASK; + } +} + #ifdef DEBUG void pmap_pvdump(pa) diff --git a/sys/arch/i386/i386/pmap.old.c b/sys/arch/i386/i386/pmap.old.c index 57ae1e13313..0aa7a5d478f 100644 --- a/sys/arch/i386/i386/pmap.old.c +++ b/sys/arch/i386/i386/pmap.old.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.old.c,v 1.15 1996/10/25 11:14:13 deraadt Exp $ */ +/* $OpenBSD: pmap.old.c,v 1.16 1997/01/07 05:37:32 tholo Exp $ */ /* $NetBSD: pmap.c,v 1.36 1996/05/03 19:42:22 christos Exp $ */ /* @@ -1726,6 +1726,23 @@ pmap_changebit(pa, setbits, maskbits) splx(s); } +void +pmap_prefault(map, v, l) + vm_map_t map; + vm_offset_t v; + vm_size_t l; +{ + vm_offset_t pv, pv2; + + for (pv = v; pv < v + l ; pv += ~PD_MASK + 1) { + if (!pmap_pde_v(pmap_pde(map->pmap, pv))) { + pv2 = trunc_page(vtopte(pv)); + vm_fault(map, pv2, VM_PROT_READ, FALSE); + } + pv &= PD_MASK; + } +} + #ifdef DEBUG void pmap_pvdump(pa) diff --git a/sys/arch/i386/include/pmap.h b/sys/arch/i386/include/pmap.h index 4d43e526f80..67415f52349 100644 --- a/sys/arch/i386/include/pmap.h +++ b/sys/arch/i386/include/pmap.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.h,v 1.7 1996/10/25 11:14:16 deraadt Exp $ */ +/* $OpenBSD: pmap.h,v 1.8 1997/01/07 05:37:34 tholo Exp $ */ /* $NetBSD: pmap.h,v 1.23 1996/05/03 19:26:30 christos Exp $ */ /* @@ -86,6 +86,7 @@ extern int PTDpaddr; /* physical address of kernel PTD */ void pmap_bootstrap __P((vm_offset_t start)); boolean_t pmap_testbit __P((vm_offset_t, int)); void pmap_changebit __P((vm_offset_t, int, int)); +void pmap_prefault __P((vm_map_t, vm_offset_t, vm_size_t)); #endif /* diff --git a/sys/arch/i386/include/pmap.old.h b/sys/arch/i386/include/pmap.old.h index 3fbeaf58fdd..bbe198f994f 100644 --- a/sys/arch/i386/include/pmap.old.h +++ b/sys/arch/i386/include/pmap.old.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.old.h,v 1.7 1996/10/25 11:14:16 deraadt Exp $ */ +/* $OpenBSD: pmap.old.h,v 1.8 1997/01/07 05:37:34 tholo Exp $ */ /* $NetBSD: pmap.h,v 1.23 1996/05/03 19:26:30 christos Exp $ */ /* @@ -86,6 +86,7 @@ extern int PTDpaddr; /* physical address of kernel PTD */ void pmap_bootstrap __P((vm_offset_t start)); boolean_t pmap_testbit __P((vm_offset_t, int)); void pmap_changebit __P((vm_offset_t, int, int)); +void pmap_prefault __P((vm_map_t, vm_offset_t, vm_size_t)); #endif /* diff --git a/sys/miscfs/procfs/procfs_mem.c b/sys/miscfs/procfs/procfs_mem.c index 901f13c5e07..dd443a9ab57 100644 --- a/sys/miscfs/procfs/procfs_mem.c +++ b/sys/miscfs/procfs/procfs_mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: procfs_mem.c,v 1.2 1996/02/27 08:03:36 niklas Exp $ */ +/* $OpenBSD: procfs_mem.c,v 1.3 1997/01/07 05:37:35 tholo Exp $ */ /* $NetBSD: procfs_mem.c,v 1.8 1996/02/09 22:40:50 christos Exp $ */ /* @@ -149,7 +149,11 @@ procfs_rwmem(p, uio) */ if (!error) vm_map_lookup_done(tmap, out_entry); - + +#ifdef __i386__ + pmap_prefault(map, pageno, PAGE_SIZE); +#endif + /* * Fault the page in... */ diff --git a/sys/vm/vm_extern.h b/sys/vm/vm_extern.h index cf93f186b1b..14346cb8a05 100644 --- a/sys/vm/vm_extern.h +++ b/sys/vm/vm_extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_extern.h,v 1.8 1996/08/02 00:05:58 niklas Exp $ */ +/* $OpenBSD: vm_extern.h,v 1.9 1997/01/07 05:37:35 tholo Exp $ */ /* $NetBSD: vm_extern.h,v 1.20 1996/04/23 12:25:23 christos Exp $ */ /*- @@ -139,8 +139,8 @@ void vmtotal __P((struct vmtotal *)); void vnode_pager_setsize __P((struct vnode *, u_long)); void vnode_pager_umount __P((struct mount *)); boolean_t vnode_pager_uncache __P((struct vnode *)); -void vslock __P((caddr_t, u_int)); -void vsunlock __P((caddr_t, u_int)); +int vslock __P((caddr_t, u_int)); +int vsunlock __P((caddr_t, u_int)); /* Machine dependent portion */ void vmapbuf __P((struct buf *, vm_size_t)); diff --git a/sys/vm/vm_glue.c b/sys/vm/vm_glue.c index 764435ddc34..2851697956f 100644 --- a/sys/vm/vm_glue.c +++ b/sys/vm/vm_glue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_glue.c,v 1.21 1996/11/23 23:19:54 kstailey Exp $ */ +/* $OpenBSD: vm_glue.c,v 1.22 1997/01/07 05:37:36 tholo Exp $ */ /* $NetBSD: vm_glue.c,v 1.55.4.1 1996/06/13 17:25:45 cgd Exp $ */ /* @@ -173,22 +173,25 @@ chgkprot(addr, len, rw) } #endif -void +int vslock(addr, len) caddr_t addr; u_int len; { - vm_map_pageable(&curproc->p_vmspace->vm_map, trunc_page(addr), - round_page(addr+len), FALSE); +#ifdef __i386__ + pmap_prefault(&curproc->p_vmspace->vm_map, (vm_offset_t)addr, len); +#endif + return vm_map_pageable(&curproc->p_vmspace->vm_map, trunc_page(addr), + round_page(addr+len), FALSE); } -void +int vsunlock(addr, len) caddr_t addr; u_int len; { - vm_map_pageable(&curproc->p_vmspace->vm_map, trunc_page(addr), - round_page(addr+len), TRUE); + return vm_map_pageable(&curproc->p_vmspace->vm_map, trunc_page(addr), + round_page(addr+len), TRUE); } /* diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c index 5008feb1277..0e614e86493 100644 --- a/sys/vm/vm_mmap.c +++ b/sys/vm/vm_mmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_mmap.c,v 1.6 1996/04/21 22:33:13 deraadt Exp $ */ +/* $OpenBSD: vm_mmap.c,v 1.7 1997/01/07 05:37:37 tholo Exp $ */ /* $NetBSD: vm_mmap.c,v 1.47 1996/03/16 23:15:23 christos Exp $ */ /* @@ -599,7 +599,7 @@ sys_mlock(p, v, retval) return (error); #endif - error = vm_map_pageable(&p->p_vmspace->vm_map, addr, addr+size, FALSE); + error = vslock((caddr_t)addr, size); return (error == KERN_SUCCESS ? 0 : ENOMEM); } @@ -642,7 +642,7 @@ sys_munlock(p, v, retval) return (error); #endif - error = vm_map_pageable(&p->p_vmspace->vm_map, addr, addr+size, TRUE); + error = vsunlock((caddr_t)addr, size); return (error == KERN_SUCCESS ? 0 : ENOMEM); } -- 2.20.1