Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/xen/x86 In bootstrap, after switching to a new page...



details:   https://anonhg.NetBSD.org/src/rev/689a7362252f
branches:  trunk
changeset: 366045:689a7362252f
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Wed May 11 16:22:46 2022 +0000

description:
In bootstrap, after switching to a new page table make sure that
now-unused memory is unmapped.

diffstat:

 sys/arch/xen/x86/x86_xpmap.c |  12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diffs (40 lines):

diff -r 267edcd5ec88 -r 689a7362252f sys/arch/xen/x86/x86_xpmap.c
--- a/sys/arch/xen/x86/x86_xpmap.c      Wed May 11 15:46:25 2022 +0000
+++ b/sys/arch/xen/x86/x86_xpmap.c      Wed May 11 16:22:46 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: x86_xpmap.c,v 1.90 2020/09/06 02:18:53 riastradh Exp $ */
+/*     $NetBSD: x86_xpmap.c,v 1.91 2022/05/11 16:22:46 bouyer Exp $    */
 
 /*
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -95,7 +95,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: x86_xpmap.c,v 1.90 2020/09/06 02:18:53 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: x86_xpmap.c,v 1.91 2022/05/11 16:22:46 bouyer Exp $");
 
 #include "opt_xen.h"
 #include "opt_ddb.h"
@@ -911,7 +911,7 @@
        /* Unpin old PGD */
        xpq_queue_unpin_table(xpmap_ptom_masked(old_pgd - KERNBASE));
 
-       /* Mark old tables RW */
+       /* Mark old tables RW if used, unmap otherwise */
        page = old_pgd;
        addr = xpmap_mtop((paddr_t)L2[pl2_pi(page)] & PTE_4KFRAME);
        pte = (pd_entry_t *)((u_long)addr + KERNBASE);
@@ -925,6 +925,12 @@
                 */
                pte++;
        }
+       while (page < old_pgd + (old_count * PAGE_SIZE)) {
+               addr = xpmap_ptom(((u_long)pte) - KERNBASE);
+               xpq_queue_pte_update(addr, 0);
+               page += PAGE_SIZE;
+               pte++;
+       }
        xpq_flush_queue();
 }
 



Home | Main Index | Thread Index | Old Index