Module Name: src
Committed By: cherry
Date: Thu Sep 1 08:04:46 UTC 2011
Modified Files:
src/sys/arch/x86/include [cherry-xenmp]: cpu.h
src/sys/arch/xen/x86 [cherry-xenmp]: cpu.c
Log Message:
fix %cr3 init. from mhitch@, tested by riz@ & mhitch@
To generate a diff of this commit:
cvs rdiff -u -r1.34.2.5 -r1.34.2.6 src/sys/arch/x86/include/cpu.h
cvs rdiff -u -r1.56.2.9 -r1.56.2.10 src/sys/arch/xen/x86/cpu.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/include/cpu.h
diff -u src/sys/arch/x86/include/cpu.h:1.34.2.5 src/sys/arch/x86/include/cpu.h:1.34.2.6
--- src/sys/arch/x86/include/cpu.h:1.34.2.5 Sat Aug 20 19:22:47 2011
+++ src/sys/arch/x86/include/cpu.h Thu Sep 1 08:04:46 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.34.2.5 2011/08/20 19:22:47 cherry Exp $ */
+/* $NetBSD: cpu.h,v 1.34.2.6 2011/09/01 08:04:46 cherry Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -176,7 +176,7 @@
#endif
#ifdef PAE
- uint32_t ci_pae_l3_pdirpa; /* PA of L3 PD */
+ paddr_t ci_pae_l3_pdirpa; /* PA of L3 PD */
pd_entry_t * ci_pae_l3_pdir; /* VA pointer to L3 PD */
#endif
Index: src/sys/arch/xen/x86/cpu.c
diff -u src/sys/arch/xen/x86/cpu.c:1.56.2.9 src/sys/arch/xen/x86/cpu.c:1.56.2.10
--- src/sys/arch/xen/x86/cpu.c:1.56.2.9 Tue Aug 30 12:53:46 2011
+++ src/sys/arch/xen/x86/cpu.c Thu Sep 1 08:04:46 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.56.2.9 2011/08/30 12:53:46 cherry Exp $ */
+/* $NetBSD: cpu.c,v 1.56.2.10 2011/09/01 08:04:46 cherry Exp $ */
/* NetBSD: cpu.c,v 1.18 2004/02/20 17:35:01 yamt Exp */
/*-
@@ -66,7 +66,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.56.2.9 2011/08/30 12:53:46 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.56.2.10 2011/09/01 08:04:46 cherry Exp $");
#include "opt_ddb.h"
#include "opt_multiprocessor.h"
@@ -1023,9 +1023,9 @@
* per-cpu L4 PD in pmap_cpu_init_late()
*/
#ifdef PAE
- initctx->ctrlreg[3] = xpmap_ptom(ci->ci_pae_l3_pdirpa);
+ initctx->ctrlreg[3] = xen_pfn_to_cr3(x86_btop(xpmap_ptom(ci->ci_pae_l3_pdirpa)));
#else /* PAE */
- initctx->ctrlreg[3] = xpmap_ptom(pcb->pcb_cr3);
+ initctx->ctrlreg[3] = xen_pfn_to_cr3(x86_btop(xpmap_ptom(pcb->pcb_cr3)));
#endif /* PAE */
initctx->ctrlreg[4] = /* CR4_PAE | */CR4_OSFXSR | CR4_OSXMMEXCPT;
@@ -1316,35 +1316,16 @@
KASSERT(ci != NULL);
#ifdef PAE
- {
- int ret;
- struct pglist pg;
- struct vm_page *vmap;
-
- /*
- * Allocate a page for the per-CPU L3 PD. cr3 being 32 bits, PA musts
- * resides below the 4GB boundary.
- */
- ret = uvm_pglistalloc(PAGE_SIZE, 0,
- 0x100000000ULL, 32, 0, &pg, 1, 0);
-
- vmap = TAILQ_FIRST(&pg);
-
- if (ret != 0 || vmap == NULL)
- panic("%s: failed to allocate L3 pglist for CPU %d (ret %d)\n",
- __func__, cpu_index(ci), ret);
-
- ci->ci_pae_l3_pdirpa = vmap->phys_addr;
-
- ci->ci_pae_l3_pdir = (paddr_t *)uvm_km_alloc(kernel_map, PAGE_SIZE, 0,
- UVM_KMF_VAONLY | UVM_KMF_NOWAIT);
+ ci->ci_pae_l3_pdir = (paddr_t *)uvm_km_alloc(kernel_map, PAGE_SIZE, 0,
+ UVM_KMF_WIRED | UVM_KMF_ZERO | UVM_KMF_NOWAIT);
- if (ci->ci_pae_l3_pdir == NULL)
- panic("%s: failed to allocate L3 PD for CPU %d\n",
- __func__, cpu_index(ci));
- pmap_kenter_pa((vaddr_t)ci->ci_pae_l3_pdir, ci->ci_pae_l3_pdirpa,
- VM_PROT_READ | VM_PROT_WRITE, 0);
+ if (ci->ci_pae_l3_pdir == NULL) {
+ panic("%s: failed to allocate L3 per-cpu PD for CPU %d\n",
+ __func__, cpu_index(ci));
}
+ ci->ci_pae_l3_pdirpa = vtophys((vaddr_t) ci->ci_pae_l3_pdir);
+ KASSERT(ci->ci_pae_l3_pdirpa != 0);
+
/* Initialise L2 entries 0 - 2: Point them to pmap_kernel() */
ci->ci_pae_l3_pdir[0] =
xpmap_ptom_masked(pmap_kernel()->pm_pdirpa[0]) | PG_V;