Module Name: src Committed By: rmind Date: Sat Jan 19 01:04:52 UTC 2013
Modified Files: src/sys/kern: subr_physmap.c src/sys/sys: physmap.h Log Message: - physmap_map, physmap_map_fini: pmap_update() must be performed before freeing the VA; otherwise there is a window when it can be re-used while stale TLB entries may be present. - physmap_fill: use MIN() instead of min(), since vsize_t is used. - Add RCS ID comment while here and prevent physmap.h inclusion in userland. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/kern/subr_physmap.c cvs rdiff -u -r1.1 -r1.2 src/sys/sys/physmap.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/subr_physmap.c diff -u src/sys/kern/subr_physmap.c:1.1 src/sys/kern/subr_physmap.c:1.2 --- src/sys/kern/subr_physmap.c:1.1 Fri Jan 18 06:42:16 2013 +++ src/sys/kern/subr_physmap.c Sat Jan 19 01:04:51 2013 @@ -1,3 +1,5 @@ +/* $NetBSD: subr_physmap.c,v 1.2 2013/01/19 01:04:51 rmind Exp $ */ + /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. * All rights reserved. @@ -28,8 +30,7 @@ */ #include <sys/cdefs.h> - -__KERNEL_RCSID(1, "$NetBSD: subr_physmap.c,v 1.1 2013/01/18 06:42:16 matt Exp $"); +__KERNEL_RCSID(1, "$NetBSD: subr_physmap.c,v 1.2 2013/01/19 01:04:51 rmind Exp $"); #include <sys/param.h> #include <sys/physmap.h> @@ -82,7 +83,7 @@ physmap_fill(physmap_t *map, pmap_t pmap if (!pmap_extract(pmap, va, &ps->ps_addr)) { return EFAULT; } - ps->ps_len = min(len, PAGE_SIZE - offset); + ps->ps_len = MIN(len, PAGE_SIZE - offset); if (ps->ps_len == len) { map->pm_nsegs = 1; return 0; @@ -266,9 +267,9 @@ physmap_map(void *cookie, vaddr_t *kvap) */ if (pc->pc_kva != 0 && !pc->pc_direct_mapped) { pmap_kremove(pc->pc_kva, pc->pc_klen); + pmap_update(pmap_kernel()); uvm_km_free(kernel_map, pc->pc_kva, pc->pc_klen, UVM_KMF_VAONLY); - pmap_update(pmap_kernel()); } /* @@ -350,9 +351,9 @@ physmap_map_fini(void *cookie) */ if (pc->pc_kva != 0 && !pc->pc_direct_mapped) { pmap_kremove(pc->pc_kva, pc->pc_klen); + pmap_update(pmap_kernel()); uvm_km_free(kernel_map, pc->pc_kva, pc->pc_klen, UVM_KMF_VAONLY); - pmap_update(pmap_kernel()); } /* Index: src/sys/sys/physmap.h diff -u src/sys/sys/physmap.h:1.1 src/sys/sys/physmap.h:1.2 --- src/sys/sys/physmap.h:1.1 Fri Jan 18 06:42:16 2013 +++ src/sys/sys/physmap.h Sat Jan 19 01:04:52 2013 @@ -1,3 +1,5 @@ +/* $NetBSD: physmap.h,v 1.2 2013/01/19 01:04:52 rmind Exp $ */ + /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. * All rights reserved. @@ -30,7 +32,13 @@ #ifndef _SYS_PHYSMAP_H_ #define _SYS_PHYSMAP_H_ +#if !defined(_KERNEL) +#error "not supposed to be exposed to userland" +#endif + #include <sys/types.h> +#include <sys/uio.h> +#include <uvm/uvm_extern.h> typedef struct { paddr_t ps_addr; @@ -44,10 +52,6 @@ struct physmap { physmap_segment_t pm_segs[0]; }; -#ifdef _KERNEL -#include <sys/uio.h> -#include <uvm/uvm_extern.h> - int physmap_create_iov(physmap_t **, const struct vmspace *, struct iovec *, size_t); int physmap_create_linear(physmap_t **, const struct vmspace *, @@ -62,6 +66,5 @@ size_t physmap_map(void *, vaddr_t *); void physmap_map_fini(void *); void physmap_zero(physmap_t *, size_t, size_t); -#endif /* _KERNEL */ #endif /* _SYS_PHYSMAP_H_ */