Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/cherry-xenmp]: src/sys/arch PAE MP support (preliminary), amd64 per-cpu ...
details: https://anonhg.NetBSD.org/src/rev/67a8e9cd5f3b
branches: cherry-xenmp
changeset: 765629:67a8e9cd5f3b
user: cherry <cherry%NetBSD.org@localhost>
date: Sat Aug 20 19:22:46 2011 +0000
description:
PAE MP support (preliminary), amd64 per-cpu L4 model redesigned, i386 pmap_pa_start/end fixup
diffstat:
sys/arch/amd64/amd64/machdep.c | 8 +-
sys/arch/amd64/include/pmap.h | 5 +-
sys/arch/i386/i386/machdep.c | 6 +-
sys/arch/i386/include/pmap.h | 11 +--
sys/arch/x86/include/cpu.h | 17 ++--
sys/arch/x86/x86/pmap.c | 77 ++++++++-------------
sys/arch/xen/include/hypervisor.h | 3 +-
sys/arch/xen/x86/cpu.c | 130 ++++++++++++++++++++++++++++++++++---
sys/arch/xen/x86/x86_xpmap.c | 14 ++-
sys/arch/xen/x86/xen_pmap.c | 34 ++++-----
10 files changed, 190 insertions(+), 115 deletions(-)
diffs (truncated from 625 to 300 lines):
diff -r a07ba7c15858 -r 67a8e9cd5f3b sys/arch/amd64/amd64/machdep.c
--- a/sys/arch/amd64/amd64/machdep.c Wed Aug 17 09:40:39 2011 +0000
+++ b/sys/arch/amd64/amd64/machdep.c Sat Aug 20 19:22:46 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.160.2.2 2011/06/23 14:18:56 cherry Exp $ */
+/* $NetBSD: machdep.c,v 1.160.2.3 2011/08/20 19:22:46 cherry Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008
@@ -107,7 +107,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.160.2.2 2011/06/23 14:18:56 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.160.2.3 2011/08/20 19:22:46 cherry Exp $");
/* #define XENDEBUG_LOW */
@@ -1320,8 +1320,8 @@
/* Determine physical address space */
avail_start = first_avail;
avail_end = ctob(xen_start_info.nr_pages);
- pmap_pa_start = (KERNTEXTOFF - KERNBASE);
- pmap_pa_end = avail_end;
+ pmap_pa_start = XPMAP_OFFSET;
+ pmap_pa_end = pmap_pa_start + ctob(xen_start_info.nr_pages);
__PRINTK(("pmap_pa_start 0x%lx avail_start 0x%lx avail_end 0x%lx\n",
pmap_pa_start, avail_start, avail_end));
#endif /* !XEN */
diff -r a07ba7c15858 -r 67a8e9cd5f3b sys/arch/amd64/include/pmap.h
--- a/sys/arch/amd64/include/pmap.h Wed Aug 17 09:40:39 2011 +0000
+++ b/sys/arch/amd64/include/pmap.h Sat Aug 20 19:22:46 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.h,v 1.24.2.1 2011/06/03 13:27:38 cherry Exp $ */
+/* $NetBSD: pmap.h,v 1.24.2.2 2011/08/20 19:22:46 cherry Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -191,7 +191,8 @@
#define AL4_BASE ((pd_entry_t *)((char *)AL3_BASE + L4_SLOT_PTE * NBPD_L1))
#define PDP_PDE (L4_BASE + PDIR_SLOT_PTE)
-#define APDP_PDE (L4_BASE + PDIR_SLOT_APTE)
+#define APDP_PDE (&curcpu()->ci_kpm_pdir[PDIR_SLOT_APTE])
+#define APDP_PDE_SHADOW (L4_BASE + PDIR_SLOT_APTE)
#define PDP_BASE L4_BASE
#define APDP_BASE AL4_BASE
diff -r a07ba7c15858 -r 67a8e9cd5f3b sys/arch/i386/i386/machdep.c
--- a/sys/arch/i386/i386/machdep.c Wed Aug 17 09:40:39 2011 +0000
+++ b/sys/arch/i386/i386/machdep.c Sat Aug 20 19:22:46 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.702.2.4 2011/08/07 19:48:07 cherry Exp $ */
+/* $NetBSD: machdep.c,v 1.702.2.5 2011/08/20 19:22:46 cherry Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009
@@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.702.2.4 2011/08/07 19:48:07 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.702.2.5 2011/08/20 19:22:46 cherry Exp $");
#include "opt_beep.h"
#include "opt_compat_ibcs2.h"
@@ -1437,7 +1437,7 @@
avail_start = first_avail;
avail_end = ctob(xen_start_info.nr_pages) + XPMAP_OFFSET;
pmap_pa_start = (KERNTEXTOFF - KERNBASE);
- pmap_pa_end = avail_end;
+ pmap_pa_end = pmap_pa_start + ctob(xen_start_info.nr_pages);
mem_clusters[0].start = avail_start;
mem_clusters[0].size = avail_end - avail_start;
mem_cluster_cnt++;
diff -r a07ba7c15858 -r 67a8e9cd5f3b sys/arch/i386/include/pmap.h
--- a/sys/arch/i386/include/pmap.h Wed Aug 17 09:40:39 2011 +0000
+++ b/sys/arch/i386/include/pmap.h Sat Aug 20 19:22:46 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.h,v 1.109.2.1 2011/07/31 20:49:11 cherry Exp $ */
+/* $NetBSD: pmap.h,v 1.109.2.2 2011/08/20 19:22:46 cherry Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -277,7 +277,7 @@
* mapping, because it points to the shadow PD. Use the kernel PD instead,
* which is static
*/
-#define APDP_PDE (&pmap_kl2pd[l2tol2(PDIR_SLOT_APTE)])
+#define APDP_PDE (&curcpu()->ci_kpm_pdir[l2tol2(PDIR_SLOT_APTE)])
#define APDP_PDE_SHADOW (L2_BASE + PDIR_SLOT_APTE)
#else /* PAE && XEN */
#define APDP_PDE (L2_BASE + PDIR_SLOT_APTE)
@@ -440,13 +440,6 @@
#endif
-#ifdef PAE
-/* Address of the static kernel's L2 page */
-pd_entry_t *pmap_kl2pd;
-paddr_t pmap_kl2paddr;
-#endif
-
-
struct trapframe;
int pmap_exec_fixup(struct vm_map *, struct trapframe *, struct pcb *);
diff -r a07ba7c15858 -r 67a8e9cd5f3b sys/arch/x86/include/cpu.h
--- a/sys/arch/x86/include/cpu.h Wed Aug 17 09:40:39 2011 +0000
+++ b/sys/arch/x86/include/cpu.h Sat Aug 20 19:22:46 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.34.2.4 2011/08/17 09:40:39 cherry Exp $ */
+/* $NetBSD: cpu.h,v 1.34.2.5 2011/08/20 19:22:47 cherry Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -180,12 +180,14 @@
pd_entry_t * ci_pae_l3_pdir; /* VA pointer to L3 PD */
#endif
-#if defined(XEN) && defined(__x86_64__)
+#if defined(XEN) && (defined(PAE) || defined(__x86_64__))
/* Currently active user PGD (can't use rcr3() with Xen) */
- pd_entry_t * ci_kpm_pdir; /* per-cpu L4 PD (va) */
- paddr_t ci_kpm_pdirpa; /* per-cpu L4 PD (pa) */
+ pd_entry_t * ci_kpm_pdir; /* per-cpu PMD (va) */
+ paddr_t ci_kpm_pdirpa; /* per-cpu PMD (pa) */
+#if defined(__x86_64__)
paddr_t ci_xen_current_user_pgd;
-#endif
+#endif /* __x86_64__ */
+#endif /* XEN et.al */
char *ci_doubleflt_stack;
char *ci_ddbipi_stack;
@@ -232,11 +234,6 @@
int ci_padout __aligned(64);
};
-#ifdef __x86_64__
-#define ci_pdirpa(ci, index) \
- ((ci)->ci_kpm_pdirpa + (index) * sizeof(pd_entry_t))
-#endif /* __x86_64__ */
-
/*
* Macros to handle (some) trapframe registers for common x86 code.
*/
diff -r a07ba7c15858 -r 67a8e9cd5f3b sys/arch/x86/x86/pmap.c
--- a/sys/arch/x86/x86/pmap.c Wed Aug 17 09:40:39 2011 +0000
+++ b/sys/arch/x86/x86/pmap.c Sat Aug 20 19:22:46 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.121.2.5 2011/08/17 09:40:39 cherry Exp $ */
+/* $NetBSD: pmap.c,v 1.121.2.6 2011/08/20 19:22:47 cherry 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.121.2.5 2011/08/17 09:40:39 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.121.2.6 2011/08/20 19:22:47 cherry Exp $");
#include "opt_user_ldt.h"
#include "opt_lockdebug.h"
@@ -1503,10 +1503,18 @@
HYPERVISOR_update_va_mapping (newp + KERNBASE,
xpmap_ptom_masked(newp) | PG_u | PG_V, UVMF_INVLPG);
xpq_queue_lock();
+ /* Update the pmap_kernel() L4 shadow */
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);
+
+ /* sync to per-cpu PD */
+ xpq_queue_pte_update(
+ xpmap_ptom_masked(cpu_info_primary.ci_kpm_pdirpa +
+ pl_i(0, PTP_LEVELS) *
+ sizeof(pd_entry_t)),
+ pmap_kernel()->pm_pdir[pl_i(0, PTP_LEVELS)]);
xpq_queue_unlock();
pmap_pte_flush();
@@ -1515,15 +1523,6 @@
break;
pdes_pa = newp;
}
-
- /* sync to per-cpu PD */
- xpq_queue_lock();
- xpq_queue_pte_update(
- xpmap_ptom_masked(ci_pdirpa(&cpu_info_primary,
- pl_i(0, PTP_LEVELS))),
- pmap_kernel()->pm_pdir[pl_i(0, PTP_LEVELS)]);
- xpq_queue_unlock();
- pmap_pte_flush();
#else /* XEN */
pd_entry_t *pdes;
@@ -1580,7 +1579,7 @@
/*
* pmap_cpu_init_late: perform late per-CPU initialization.
*/
-
+#ifndef XEN
void
pmap_cpu_init_late(struct cpu_info *ci)
{
@@ -1620,31 +1619,8 @@
pmap_update(pmap_kernel());
#endif
-#if defined(XEN) && defined (__x86_64)
- KASSERT(ci != NULL);
-
- ci->ci_kpm_pdir = (pd_entry_t *)uvm_km_alloc(kernel_map,
- PAGE_SIZE, 0, UVM_KMF_WIRED | UVM_KMF_ZERO | UVM_KMF_NOWAIT);
- if (ci->ci_kpm_pdir == NULL) {
- panic("%s: failed to allocate L4 per-cpu PD for CPU %d\n",
- __func__, cpu_index(ci));
- }
- ci->ci_kpm_pdirpa = vtophys((vaddr_t) ci->ci_kpm_pdir);
- KASSERT(ci->ci_kpm_pdirpa != 0);
-
- cpu_load_pmap(pmap_kernel());
-
- pmap_kenter_pa((vaddr_t)ci->ci_kpm_pdir, ci->ci_kpm_pdirpa,
- VM_PROT_READ, 0);
-
- pmap_update(pmap_kernel());
-
- xpq_queue_lock();
- xpq_queue_pin_l4_table(xpmap_ptom_masked(ci->ci_kpm_pdirpa));
- xpq_queue_unlock();
-
-#endif /* defined(XEN) && defined (__x86_64__) */
}
+#endif
/*
* p v _ e n t r y f u n c t i o n s
@@ -4163,7 +4139,6 @@
#ifdef XEN
int s = splvm(); /* protect xpq_* */
#endif
-
for (level = lvl; level > 1; level--) {
if (level == PTP_LEVELS){
pdep = pmap_kernel()->pm_pdir;
@@ -4179,6 +4154,7 @@
for (i = index; i <= endindex; i++) {
pt_entry_t pte;
+
KASSERT(!pmap_valid_entry(pdep[i]));
pmap_get_physpage(va, &pa);
pte = pmap_pa2pte(pa) | PG_k | PG_V | PG_RW;
@@ -4186,18 +4162,25 @@
xpq_queue_lock();
switch (level) {
case PTP_LEVELS:
-#ifdef __x86_64__
- /* update the per-cpu L4 */
- xpq_queue_pte_update(
- xpmap_ptom(ci_pdirpa(&cpu_info_primary, i)), pte);
-#endif /* __x86_64__ */
+#if defined(PAE) || defined(__x86_64__)
+ if (i >= PDIR_SLOT_KERN) {
+ /* update per-cpu PMDs on all cpus */
+ CPU_INFO_ITERATOR cii;
+ struct cpu_info *ci;
+ for (CPU_INFO_FOREACH(cii, ci)) {
+ if (ci == NULL) {
+ continue;
+ }
#ifdef PAE
- if (i > L2_SLOT_KERN) {
- /* update real kernel PD too */
- xpq_queue_pte_update(
- xpmap_ptetomach(&pmap_kl2pd[l2tol2(i)]), pte);
+ xpq_queue_pte_update(
+ xpmap_ptetomach(&ci->ci_kpm_pdir[l2tol2(i)]), pte);
+#elif defined(__x86_64__)
+ xpq_queue_pte_update(
+ xpmap_ptetomach(&ci->ci_kpm_pdir[i]), pte);
+#endif /* PAE */
+ }
}
-#endif
+#endif /* PAE || __x86_64__ */
/* FALLTHROUGH */
default: /* All other levels */
diff -r a07ba7c15858 -r 67a8e9cd5f3b sys/arch/xen/include/hypervisor.h
--- a/sys/arch/xen/include/hypervisor.h Wed Aug 17 09:40:39 2011 +0000
+++ b/sys/arch/xen/include/hypervisor.h Sat Aug 20 19:22:46 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hypervisor.h,v 1.31.10.1 2011/08/04 09:07:46 cherry Exp $ */
+/* $NetBSD: hypervisor.h,v 1.31.10.2 2011/08/20 19:22:47 cherry Exp $ */
Home |
Main Index |
Thread Index |
Old Index