Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/x86/x86 Reduce the minefield: zero out the pdir onl...



details:   https://anonhg.NetBSD.org/src/rev/f224b8a9f219
branches:  trunk
changeset: 365325:f224b8a9f219
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sun Aug 12 11:51:42 2018 +0000

description:
Reduce the minefield: zero out the pdir only once, at the beginning of
the function. This eliminates one assumption on the order of the VM
areas.

diffstat:

 sys/arch/x86/x86/pmap.c |  16 ++++------------
 1 files changed, 4 insertions(+), 12 deletions(-)

diffs (58 lines):

diff -r 6a7a3cbb258a -r f224b8a9f219 sys/arch/x86/x86/pmap.c
--- a/sys/arch/x86/x86/pmap.c   Sun Aug 12 11:50:51 2018 +0000
+++ b/sys/arch/x86/x86/pmap.c   Sun Aug 12 11:51:42 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.298 2018/08/12 10:50:35 maxv Exp $  */
+/*     $NetBSD: pmap.c,v 1.299 2018/08/12 11:51:42 maxv Exp $  */
 
 /*
  * Copyright (c) 2008, 2010, 2016, 2017 The NetBSD Foundation, Inc.
@@ -157,7 +157,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.298 2018/08/12 10:50:35 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.299 2018/08/12 11:51:42 maxv Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -2318,6 +2318,8 @@
        int s;
 #endif
 
+       memset(pdir, 0, PDP_SIZE * PAGE_SIZE);
+
        /*
         * NOTE: The `pmaps_lock' is held when the PDP is allocated.
         */
@@ -2326,9 +2328,6 @@
        /* Fetch the physical address of the page directory */
        (void)pmap_extract(pmap_kernel(), (vaddr_t)pdir, &pdirpa);
 
-       /* Zero the area */
-       memset(pdir, 0, PAGE_SIZE); /* Xen wants a clean page */
-
        /*
         * This pdir will NEVER be active in kernel mode, so mark
         * recursive entry invalid.
@@ -2345,9 +2344,6 @@
        pdir[PDIR_SLOT_KERN + nkptp[PTP_LEVELS - 1] - 1] =
             (pd_entry_t)-1 & PG_FRAME;
 #else /* XEN && __x86_64__*/
-       /* Zero the area */
-       memset(pdir, 0, PDIR_SLOT_PTE * sizeof(pd_entry_t));
-
        object = (vaddr_t)v;
        for (i = 0; i < PDP_SIZE; i++, object += PAGE_SIZE) {
                /* Fetch the physical address of the page directory */
@@ -2367,10 +2363,6 @@
        memcpy(&pdir[PDIR_SLOT_KERN], &PDP_BASE[PDIR_SLOT_KERN],
            npde * sizeof(pd_entry_t));
 
-       /* Zero the rest */
-       memset(&pdir[PDIR_SLOT_KERN + npde], 0, (PAGE_SIZE * PDP_SIZE) -
-           (PDIR_SLOT_KERN + npde) * sizeof(pd_entry_t));
-
        if (VM_MIN_KERNEL_ADDRESS != KERNBASE) {
                int idx = pl_i(KERNBASE, PTP_LEVELS);
                pdir[idx] = PDP_BASE[idx];



Home | Main Index | Thread Index | Old Index