Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys - physmap_map, physmap_map_fini: pmap_update() must be p...



details:   https://anonhg.NetBSD.org/src/rev/9a1479be16f3
branches:  trunk
changeset: 784123:9a1479be16f3
user:      rmind <rmind%NetBSD.org@localhost>
date:      Sat Jan 19 01:04:51 2013 +0000

description:
- 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.

diffstat:

 sys/kern/subr_physmap.c |  11 ++++++-----
 sys/sys/physmap.h       |  13 ++++++++-----
 2 files changed, 14 insertions(+), 10 deletions(-)

diffs (91 lines):

diff -r 163646c3dff1 -r 9a1479be16f3 sys/kern/subr_physmap.c
--- a/sys/kern/subr_physmap.c   Sat Jan 19 00:51:52 2013 +0000
+++ b/sys/kern/subr_physmap.c   Sat Jan 19 01:04:51 2013 +0000
@@ -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 @@
                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 @@
         */
        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 @@
         */
        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());
        }
 
        /*
diff -r 163646c3dff1 -r 9a1479be16f3 sys/sys/physmap.h
--- a/sys/sys/physmap.h Sat Jan 19 00:51:52 2013 +0000
+++ b/sys/sys/physmap.h Sat Jan 19 01:04:51 2013 +0000
@@ -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 @@
        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 @@
 void   physmap_map_fini(void *);
 
 void   physmap_zero(physmap_t *, size_t, size_t);
-#endif /* _KERNEL */
 
 #endif /* _SYS_PHYSMAP_H_ */



Home | Main Index | Thread Index | Old Index