Module Name: src Committed By: bouyer Date: Thu Feb 23 18:59:22 UTC 2012
Modified Files: src/sys/arch/x86/x86: pmap.c src/sys/arch/xen/x86: x86_xpmap.c Log Message: 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 To generate a diff of this commit: cvs rdiff -u -r1.169 -r1.170 src/sys/arch/x86/x86/pmap.c cvs rdiff -u -r1.39 -r1.40 src/sys/arch/xen/x86/x86_xpmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/x86/x86/pmap.c diff -u src/sys/arch/x86/x86/pmap.c:1.169 src/sys/arch/x86/x86/pmap.c:1.170 --- src/sys/arch/x86/x86/pmap.c:1.169 Tue Feb 21 21:09:51 2012 +++ src/sys/arch/x86/x86/pmap.c Thu Feb 23 18:59:21 2012 @@ -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 @@ extern int mem_cluster_cnt; * 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 @@ pmap_bootstrap(vaddr_t kva_start) * 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); } Index: src/sys/arch/xen/x86/x86_xpmap.c diff -u src/sys/arch/xen/x86/x86_xpmap.c:1.39 src/sys/arch/xen/x86/x86_xpmap.c:1.40 --- src/sys/arch/xen/x86/x86_xpmap.c:1.39 Fri Feb 17 18:40:20 2012 +++ src/sys/arch/xen/x86/x86_xpmap.c Thu Feb 23 18:59:21 2012 @@ -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 <m...@adviseo.fr> @@ -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 @@ xen_pmap_bootstrap(void) * - UAREA * - dummy user PGD (x86_64) * - HYPERVISOR_shared_info + * - early_zerop * - ISA I/O mem (if needed) */ mapsize += UPAGES * NBPG; @@ -602,6 +603,7 @@ xen_pmap_bootstrap(void) mapsize += NBPG; #endif mapsize += NBPG; + mapsize += NBPG; #ifdef DOM0OPS if (xendomain_is_dom0()) { @@ -690,6 +692,7 @@ xen_bootstrap_tables (vaddr_t old_pgd, v 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 @@ xen_bootstrap_tables (vaddr_t old_pgd, v * 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 @@ xen_bootstrap_tables (vaddr_t old_pgd, v 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