Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch Move the per-cpu l3 page allocation code to a separ...
details: https://anonhg.NetBSD.org/src/rev/7e867cc2e285
branches: trunk
changeset: 772349:7e867cc2e285
user: cherry <cherry%NetBSD.org@localhost>
date: Fri Dec 30 17:57:49 2011 +0000
description:
Move the per-cpu l3 page allocation code to a separate MD function. Avoids code duplication for xen PAE
diffstat:
sys/arch/i386/i386/machdep.c | 39 +++++++++++++++++++++++++++++++++++++--
sys/arch/i386/include/cpu.h | 6 +++++-
sys/arch/x86/include/cpu.h | 4 ++--
sys/arch/x86/x86/pmap.c | 32 +++-----------------------------
4 files changed, 47 insertions(+), 34 deletions(-)
diffs (148 lines):
diff -r 6afcd7092fe9 -r 7e867cc2e285 sys/arch/i386/i386/machdep.c
--- a/sys/arch/i386/i386/machdep.c Fri Dec 30 16:55:21 2011 +0000
+++ b/sys/arch/i386/i386/machdep.c Fri Dec 30 17:57:49 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.714 2011/11/29 11:12:26 martin Exp $ */
+/* $NetBSD: machdep.c,v 1.715 2011/12/30 17:57:49 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.714 2011/11/29 11:12:26 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.715 2011/12/30 17:57:49 cherry Exp $");
#include "opt_beep.h"
#include "opt_compat_ibcs2.h"
@@ -1917,3 +1917,38 @@
}
return 0;
}
+
+#ifdef PAE
+void
+cpu_alloc_l3_page(struct cpu_info *ci)
+{
+ int ret;
+ struct pglist pg;
+ struct vm_page *vmap;
+
+ KASSERT(ci != NULL);
+ /*
+ * 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);
+ 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);
+
+ pmap_update(pmap_kernel());
+}
+#endif /* PAE */
diff -r 6afcd7092fe9 -r 7e867cc2e285 sys/arch/i386/include/cpu.h
--- a/sys/arch/i386/include/cpu.h Fri Dec 30 16:55:21 2011 +0000
+++ b/sys/arch/i386/include/cpu.h Fri Dec 30 17:57:49 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.177 2011/07/26 12:56:39 yamt Exp $ */
+/* $NetBSD: cpu.h,v 1.178 2011/12/30 17:57:49 cherry Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -86,6 +86,10 @@
#define CLKF_INTR(frame) (curcpu()->ci_idepth > 0)
#define LWP_PC(l) ((l)->l_md.md_regs->tf_eip)
+#ifdef PAE
+void cpu_alloc_l3_page(struct cpu_info *);
+#endif /* PAE */
+
#endif /* _KERNEL */
#endif /* !_I386_CPU_H_ */
diff -r 6afcd7092fe9 -r 7e867cc2e285 sys/arch/x86/include/cpu.h
--- a/sys/arch/x86/include/cpu.h Fri Dec 30 16:55:21 2011 +0000
+++ b/sys/arch/x86/include/cpu.h Fri Dec 30 17:57:49 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.44 2011/12/07 15:47:42 cegger Exp $ */
+/* $NetBSD: cpu.h,v 1.45 2011/12/30 17:57:49 cherry Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -177,7 +177,7 @@
#endif
#ifdef PAE
- paddr_t ci_pae_l3_pdirpa; /* PA of L3 PD */
+ uint32_t ci_pae_l3_pdirpa; /* PA of L3 PD */
pd_entry_t * ci_pae_l3_pdir; /* VA pointer to L3 PD */
#endif
diff -r 6afcd7092fe9 -r 7e867cc2e285 sys/arch/x86/x86/pmap.c
--- a/sys/arch/x86/x86/pmap.c Fri Dec 30 16:55:21 2011 +0000
+++ b/sys/arch/x86/x86/pmap.c Fri Dec 30 17:57:49 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.148 2011/12/30 16:55:21 cherry Exp $ */
+/* $NetBSD: pmap.c,v 1.149 2011/12/30 17:57:49 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.148 2011/12/30 16:55:21 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.149 2011/12/30 17:57:49 cherry Exp $");
#include "opt_user_ldt.h"
#include "opt_lockdebug.h"
@@ -1663,33 +1663,7 @@
return;
#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);
- 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);
-
- pmap_update(pmap_kernel());
+ cpu_alloc_l3_page(ci);
#endif
}
#endif
Home |
Main Index |
Thread Index |
Old Index