Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/x86/x86 - re-factor code in pmap_map_ptes() slightl...
details: https://anonhg.NetBSD.org/src/rev/3ab6098e2ab1
branches: trunk
changeset: 752124:3ab6098e2ab1
user: jym <jym%NetBSD.org@localhost>
date: Tue Feb 16 00:48:17 2010 +0000
description:
- re-factor code in pmap_map_ptes() slightly, and make it PAE-ready for
native i386 by using PDP_SIZE
- introduce pmap_unmap_apdp(), used to clear the APDP entries in PD, and
replace the relevant code parts with this function.
Comes from Jeremy Morse's patch for i386 PAE support. Adjustments by me.
diffstat:
sys/arch/x86/x86/pmap.c | 55 ++++++++++++++++++++++++++----------------------
1 files changed, 30 insertions(+), 25 deletions(-)
diffs (125 lines):
diff -r afc3b57dec43 -r 3ab6098e2ab1 sys/arch/x86/x86/pmap.c
--- a/sys/arch/x86/x86/pmap.c Tue Feb 16 00:47:46 2010 +0000
+++ b/sys/arch/x86/x86/pmap.c Tue Feb 16 00:48:17 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.103 2010/02/12 01:55:45 jym Exp $ */
+/* $NetBSD: pmap.c,v 1.104 2010/02/16 00:48:17 jym Exp $ */
/*
* Copyright (c) 2007 Manuel Bouyer.
@@ -149,7 +149,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.103 2010/02/12 01:55:45 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.104 2010/02/16 00:48:17 jym Exp $");
#include "opt_user_ldt.h"
#include "opt_lockdebug.h"
@@ -590,6 +590,7 @@
struct pv_entry **);
static void pmap_unmap_ptes(struct pmap *, struct pmap *);
+static void pmap_unmap_apdp(void);
static bool pmap_get_physpage(vaddr_t, int, paddr_t *);
static int pmap_pdes_invalid(vaddr_t, pd_entry_t * const *,
pd_entry_t *);
@@ -746,6 +747,22 @@
}
/*
+ * Unmap the content of APDP PDEs
+ */
+static void
+pmap_unmap_apdp(void) {
+ int i;
+
+ for (i = 0; i < PDP_SIZE; i++) {
+ pmap_pte_set(APDP_PDE+i, 0);
+#if defined (XEN) && defined (PAE)
+ /* clear shadow entries too */
+ pmap_pte_set(APDP_PDE_SHADOW+i, 0);
+#endif
+ }
+}
+
+/*
* Add a reference to the specified pmap.
*/
@@ -833,9 +850,9 @@
/* need to load a new alternate pt space into curpmap? */
COUNT(apdp_pde_map);
opde = *APDP_PDE;
-#ifdef XEN
if (!pmap_valid_entry(opde) ||
pmap_pte2pa(opde) != pmap_pdirpa(pmap, 0)) {
+#ifdef XEN
int i;
s = splvm();
/* Make recursive entry usable in user PGD */
@@ -858,17 +875,18 @@
if (pmap_valid_entry(opde))
pmap_apte_flush(ourpmap);
splx(s);
- }
#else /* XEN */
- npde = pmap_pa2pte(pmap_pdirpa(pmap, 0)) | PG_RW | PG_V;
- if (!pmap_valid_entry(opde) ||
- pmap_pte2pa(opde) != pmap_pdirpa(pmap, 0)) {
- pmap_pte_set(APDP_PDE, npde);
+ int i;
+ for (i = 0; i < PDP_SIZE; i++) {
+ npde = pmap_pa2pte(
+ pmap_pdirpa(pmap, i * NPDPG)) | PG_RW | PG_V;
+ pmap_pte_set(APDP_PDE+i, npde);
+ }
pmap_pte_flush();
if (pmap_valid_entry(opde))
pmap_apte_flush(ourpmap);
+#endif /* XEN */
}
-#endif /* XEN */
*pmap2 = ourpmap;
*ptepp = APTE_BASE;
*pdeppp = alternate_pdes;
@@ -913,7 +931,7 @@
KASSERT(curcpu()->ci_pmap == pmap2);
#endif
#if defined(MULTIPROCESSOR)
- pmap_pte_set(APDP_PDE, 0);
+ pmap_unmap_apdp();
pmap_pte_flush();
pmap_apte_flush(pmap2);
#endif
@@ -2301,13 +2319,7 @@
*/
if (xpmap_ptom_masked(pmap_pdirpa(pmap, 0)) == (*APDP_PDE & PG_FRAME)) {
kpreempt_disable();
- for (i = 0; i < PDP_SIZE; i++) {
- pmap_pte_set(&APDP_PDE[i], 0);
-#ifdef PAE
- /* clear shadow entry too */
- pmap_pte_set(&APDP_PDE_SHADOW[i], 0);
-#endif
- }
+ pmap_unmap_apdp();
pmap_pte_flush();
pmap_apte_flush(pmap_kernel());
kpreempt_enable();
@@ -2752,14 +2764,7 @@
* been freed
*/
if (*APDP_PDE) {
- int i;
- for (i = 0; i < PDP_SIZE; i++) {
- pmap_pte_set(&APDP_PDE[i], 0);
-#ifdef PAE
- /* clear shadow entry too */
- pmap_pte_set(&APDP_PDE_SHADOW[i], 0);
-#endif
- }
+ pmap_unmap_apdp();
}
/* lldt() does pmap_pte_flush() */
#else /* XEN */
Home |
Main Index |
Thread Index |
Old Index