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 - Rather use pmap_pte_set() when modifying ...



details:   https://anonhg.NetBSD.org/src/rev/55e36aaaf405
branches:  trunk
changeset: 764713:55e36aaaf405
user:      jym <jym%NetBSD.org@localhost>
date:      Sun May 01 18:52:29 2011 +0000

description:
- Rather use pmap_pte_set() when modifying a PTE.

- Call pmap_pte_flush() when issuing PTE modifications. While it is a NOOP
for native x86, it is not for Xen. It will flush all operations that are
possibly waiting in the queue, like xpq_queue_pte_update(). Do it for
each level, this function is only called at boot time and is not
performance critical.

While here:
- No need to cast early_zerop to void with memset().
- Move common variables out of the #ifdef's.
- KNF

diffstat:

 sys/arch/x86/x86/pmap.c |  20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diffs (70 lines):

diff -r e75be36eaefd -r 55e36aaaf405 sys/arch/x86/x86/pmap.c
--- a/sys/arch/x86/x86/pmap.c   Sun May 01 18:14:01 2011 +0000
+++ b/sys/arch/x86/x86/pmap.c   Sun May 01 18:52:29 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.120 2011/04/27 07:42:11 plunky Exp $        */
+/*     $NetBSD: pmap.c,v 1.121 2011/05/01 18:52:29 jym Exp $   */
 
 /*
  * Copyright (c) 2007 Manuel Bouyer.
@@ -142,7 +142,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.120 2011/04/27 07:42:11 plunky Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.121 2011/05/01 18:52:29 jym Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -1594,9 +1594,9 @@
 void
 pmap_prealloc_lowmem_ptps(void)
 {
-#ifdef XEN
        int level;
        paddr_t newp;
+#ifdef XEN
        paddr_t pdes_pa;
 
        pdes_pa = pmap_pdirpa(pmap_kernel(), 0);
@@ -1606,7 +1606,7 @@
                avail_start += PAGE_SIZE;
                HYPERVISOR_update_va_mapping ((vaddr_t)early_zerop,
                    xpmap_ptom_masked(newp) | PG_u | PG_V | PG_RW, UVMF_INVLPG);
-               memset((void *)early_zerop, 0, PAGE_SIZE);
+               memset(early_zerop, 0, PAGE_SIZE);
                /* Mark R/O before installing */
                HYPERVISOR_update_va_mapping ((vaddr_t)early_zerop,
                    xpmap_ptom_masked(newp) | PG_u | PG_V, UVMF_INVLPG);
@@ -1614,9 +1614,10 @@
                        HYPERVISOR_update_va_mapping (newp + KERNBASE,
                            xpmap_ptom_masked(newp) | PG_u | PG_V, UVMF_INVLPG);
                xpq_queue_pte_update (
-                       xpmap_ptom_masked(pdes_pa)
-                       + (pl_i(0, level) * sizeof (pd_entry_t)),
-                       xpmap_ptom_masked(newp) | PG_RW | PG_u | PG_V);
+                   xpmap_ptom_masked(pdes_pa)
+                   + (pl_i(0, level) * sizeof (pd_entry_t)),
+                   xpmap_ptom_masked(newp) | PG_RW | PG_u | PG_V);
+               pmap_pte_flush();
                level--;
                if (level <= 1)
                        break;
@@ -1624,15 +1625,14 @@
        }
 #else /* XEN */
        pd_entry_t *pdes;
-       int level;
-       paddr_t newp;
 
        pdes = pmap_kernel()->pm_pdir;
        level = PTP_LEVELS;
        for (;;) {
                newp = avail_start;
                avail_start += PAGE_SIZE;
-               *early_zero_pte = (newp & PG_FRAME) | PG_V | PG_RW;
+               pmap_pte_set(early_zero_pte, (newp & PG_FRAME) | PG_V | PG_RW);
+               pmap_pte_flush();
                pmap_update_pg((vaddr_t)early_zerop);
                memset(early_zerop, 0, PAGE_SIZE);
                pdes[pl_i(0, level)] = (newp & PG_FRAME) | PG_V | PG_RW;



Home | Main Index | Thread Index | Old Index