Source-Changes-HG archive

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

[src/trunk]: src/sys/arch On Xen, there is variable-sized Xen data after the ...



details:   https://anonhg.NetBSD.org/src/rev/3dd3fe04fc28
branches:  trunk
changeset: 777570:3dd3fe04fc28
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Thu Feb 23 18:59:21 2012 +0000

description:
On Xen, there is variable-sized Xen data after the kernel's text+data+bss
(this include the physical->machine table).
(vaddr_t)(KERNBASE + NKL2_KIMG_ENTRIES * NBPD_L2) is after text+data+bss but,
on a domU with lots of RAM (more than 4GB) (so large
xpmap_phys_to_machine_mapping table) this can point to some of Xen's data
setup at bootstrap (either the xpmap_phys_to_machine_mapping table,
some page shared with the hypervisor, or our kernel page table). Using it for
early_zerop will cause of these pages to be unmapped after bootstrap.
This will cause a kernel page fault for the domU, either immediatly or
eventually much later, depending on where early_zerop points to.
To fix this, account for early_zerop when building the bootstrap pages,
and its VA from here.

May fix PR port-xen/38699

diffstat:

 sys/arch/x86/x86/pmap.c      |  16 ++++++++++++----
 sys/arch/xen/x86/x86_xpmap.c |  10 ++++++++--
 2 files changed, 20 insertions(+), 6 deletions(-)

diffs (104 lines):

diff -r 57e7433caa2b -r 3dd3fe04fc28 sys/arch/x86/x86/pmap.c
--- a/sys/arch/x86/x86/pmap.c   Thu Feb 23 18:23:33 2012 +0000
+++ b/sys/arch/x86/x86/pmap.c   Thu Feb 23 18:59:21 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.169 2012/02/21 21:09:51 rmind Exp $ */
+/*     $NetBSD: pmap.c,v 1.170 2012/02/23 18:59:21 bouyer Exp $        */
 
 /*-
  * Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
@@ -171,7 +171,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.169 2012/02/21 21:09:51 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.170 2012/02/23 18:59:21 bouyer Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -513,7 +513,12 @@
  * special VAs and the PTEs that map them
  */
 static pt_entry_t *csrc_pte, *cdst_pte, *zero_pte, *ptp_pte, *early_zero_pte;
-static char *csrcp, *cdstp, *zerop, *ptpp, *early_zerop;
+static char *csrcp, *cdstp, *zerop, *ptpp;
+#ifdef XEN
+char *early_zerop; /* also referenced from xen_pmap_bootstrap() */
+#else
+static char *early_zerop;
+#endif
 
 #endif
 
@@ -1384,8 +1389,11 @@
                 * when it's called for the first time.
                 * XXXfvdl fix this for MULTIPROCESSOR later.
                 */
-
+#ifdef XEN
+               /* early_zerop initialized in xen_pmap_bootstrap() */
+#else
                early_zerop = (void *)(KERNBASE + NKL2_KIMG_ENTRIES * NBPD_L2);
+#endif
                early_zero_pte = PTE_BASE + pl1_i((vaddr_t)early_zerop);
        }
 
diff -r 57e7433caa2b -r 3dd3fe04fc28 sys/arch/xen/x86/x86_xpmap.c
--- a/sys/arch/xen/x86/x86_xpmap.c      Thu Feb 23 18:23:33 2012 +0000
+++ b/sys/arch/xen/x86/x86_xpmap.c      Thu Feb 23 18:59:21 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: x86_xpmap.c,v 1.39 2012/02/17 18:40:20 bouyer Exp $    */
+/*     $NetBSD: x86_xpmap.c,v 1.40 2012/02/23 18:59:21 bouyer Exp $    */
 
 /*
  * Copyright (c) 2006 Mathieu Ropert <mro%adviseo.fr@localhost>
@@ -69,7 +69,7 @@
 
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: x86_xpmap.c,v 1.39 2012/02/17 18:40:20 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: x86_xpmap.c,v 1.40 2012/02/23 18:59:21 bouyer Exp $");
 
 #include "opt_xen.h"
 #include "opt_ddb.h"
@@ -595,6 +595,7 @@
         *  - UAREA
         *  - dummy user PGD (x86_64)
         *  - HYPERVISOR_shared_info
+        *  - early_zerop
         *  - ISA I/O mem (if needed)
         */
        mapsize += UPAGES * NBPG;
@@ -602,6 +603,7 @@
        mapsize += NBPG;
 #endif
        mapsize += NBPG;
+       mapsize += NBPG;
 
 #ifdef DOM0OPS
        if (xendomain_is_dom0()) {
@@ -690,6 +692,7 @@
        vaddr_t page, avail, text_end, map_end;
        int i;
        extern char __data_start;
+       extern char *early_zerop; /* from pmap.c */
 
        __PRINTK(("xen_bootstrap_tables(%#" PRIxVADDR ", %#" PRIxVADDR ","
            " %d, %d)\n",
@@ -704,6 +707,7 @@
         *  UAREA
         *  dummy user PGD (x86_64 only)/gdt page (i386 only)
         *  HYPERVISOR_shared_info
+        *  early_zerop
         *  ISA I/O mem (if needed)
         */
        map_end = new_pgd + ((new_count + l2_4_count) * NBPG);
@@ -711,6 +715,8 @@
                map_end += (UPAGES + 1) * NBPG;
                HYPERVISOR_shared_info = (shared_info_t *)map_end;
                map_end += NBPG;
+               early_zerop = (char *)map_end;
+               map_end += NBPG;
        }
        /*
         * we always set atdevbase, as it's used by init386 to find the first



Home | Main Index | Thread Index | Old Index