diff options
author | julian <julian@FreeBSD.org> | 1999-04-05 19:38:30 +0000 |
---|---|---|
committer | julian <julian@FreeBSD.org> | 1999-04-05 19:38:30 +0000 |
commit | 0ed09d2ad576c0a64797f8ca9bebd32873f770ae (patch) | |
tree | 6de1ee6b7f198b11b20d471fbc1a36de8329d82e /sys/i386 | |
parent | 9ac433dd352fdfe7f3038aa0e1a4333686bc07fc (diff) | |
download | FreeBSD-src-0ed09d2ad576c0a64797f8ca9bebd32873f770ae.zip FreeBSD-src-0ed09d2ad576c0a64797f8ca9bebd32873f770ae.tar.gz |
Catch a case spotted by Tor where files mmapped could leave garbage in the
unallocated parts of the last page when the file ended on a frag
but not a page boundary.
Delimitted by tags PRE_MATT_MMAP_EOF and POST_MATT_MMAP_EOF,
in files alpha/alpha/pmap.c i386/i386/pmap.c nfs/nfs_bio.c vm/pmap.h
vm/vm_page.c vm/vm_page.h vm/vnode_pager.c miscfs/specfs/spec_vnops.c
ufs/ufs/ufs_readwrite.c kern/vfs_bio.c
Submitted by: Matt Dillon <dillon@freebsd.org>
Reviewed by: Alan Cox <alc@freebsd.org>
Diffstat (limited to 'sys/i386')
-rw-r--r-- | sys/i386/i386/pmap.c | 60 |
1 files changed, 55 insertions, 5 deletions
diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c index ec6c00c..c630306 100644 --- a/sys/i386/i386/pmap.c +++ b/sys/i386/i386/pmap.c @@ -39,7 +39,7 @@ * SUCH DAMAGE. * * from: @(#)pmap.c 7.7 (Berkeley) 5/12/91 - * $Id: pmap.c,v 1.225 1999/03/13 07:31:29 alc Exp $ + * $Id: pmap.c,v 1.226 1999/04/02 17:59:38 alc Exp $ */ /* @@ -2818,10 +2818,8 @@ pmap_kernel() } /* - * pmap_zero_page zeros the specified (machine independent) - * page by mapping the page into virtual memory and using - * bzero to clear its contents, one machine dependent page - * at a time. + * pmap_zero_page zeros the specified hardware page by mapping + * the page into KVM and using bzero to clear its contents. */ void pmap_zero_page(phys) @@ -2868,6 +2866,58 @@ pmap_zero_page(phys) } /* + * pmap_zero_page_area zeros the specified hardware page by mapping + * the page into KVM and using bzero to clear its contents. + * + * off and size may not cover an area beyond a single hardware page. + */ +void +pmap_zero_page_area(phys, off, size) + vm_offset_t phys; + int off; + int size; +{ +#ifdef SMP +#if !defined(MAX_PERF) + if (*(int *) prv_CMAP3) + panic("pmap_zero_page: prv_CMAP3 busy"); +#endif + + *(int *) prv_CMAP3 = PG_V | PG_RW | (phys & PG_FRAME) | PG_A | PG_M; + cpu_invlpg(&prv_CPAGE3); + +#if defined(I686_CPU) + if (cpu_class == CPUCLASS_686 && off == 0 && size == PAGE_SIZE) + i686_pagezero(&prv_CPAGE3); + else +#endif + bzero((char *)&prv_CPAGE3 + off, size); + + *(int *) prv_CMAP3 = 0; +#else +#if !defined(MAX_PERF) + if (*(int *) CMAP2) + panic("pmap_zero_page: CMAP2 busy"); +#endif + + *(int *) CMAP2 = PG_V | PG_RW | (phys & PG_FRAME) | PG_A | PG_M; + if (cpu_class == CPUCLASS_386) { + invltlb(); + } else { + invlpg((u_int)CADDR2); + } + +#if defined(I686_CPU) + if (cpu_class == CPUCLASS_686 && off == 0 && size == PAGE_SIZE) + i686_pagezero(CADDR2); + else +#endif + bzero((char *)CADDR2 + off, size); + *(int *) CMAP2 = 0; +#endif +} + +/* * pmap_copy_page copies the specified (machine independent) * page by mapping the page into virtual memory and using * bcopy to copy the page, one machine dependent page at a |