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 dedup pmap_pdirpa() KASSERT() in pmap_react...
details: https://anonhg.NetBSD.org/src/rev/5d006df83b09
branches: trunk
changeset: 320893:5d006df83b09
user: jdolecek <jdolecek%NetBSD.org@localhost>
date: Sun Mar 04 10:40:01 2018 +0000
description:
dedup pmap_pdirpa() KASSERT() in pmap_reactive(), pmap_load(), and
pmap_deactivate()
diffstat:
sys/arch/x86/x86/pmap.c | 43 +++++++++++++++++++------------------------
1 files changed, 19 insertions(+), 24 deletions(-)
diffs (85 lines):
diff -r acb6011f1e00 -r 5d006df83b09 sys/arch/x86/x86/pmap.c
--- a/sys/arch/x86/x86/pmap.c Sun Mar 04 10:26:10 2018 +0000
+++ b/sys/arch/x86/x86/pmap.c Sun Mar 04 10:40:01 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.284 2018/03/04 10:26:10 jdolecek Exp $ */
+/* $NetBSD: pmap.c,v 1.285 2018/03/04 10:40:01 jdolecek Exp $ */
/*
* Copyright (c) 2008, 2010, 2016, 2017 The NetBSD Foundation, Inc.
@@ -170,7 +170,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.284 2018/03/04 10:26:10 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.285 2018/03/04 10:40:01 jdolecek Exp $");
#include "opt_user_ldt.h"
#include "opt_lockdebug.h"
@@ -2867,6 +2867,20 @@
}
}
+#if defined(XEN) && defined(__x86_64__)
+#define KASSERT_PDIRPA(pmap) \
+ KASSERT(pmap_pdirpa(pmap, 0) == ci->ci_xen_current_user_pgd || \
+ pmap == pmap_kernel())
+#elif defined(PAE)
+#define KASSERT_PDIRPA(pmap) \
+ KASSERT(pmap_pdirpa(pmap, 0) == pmap_pte2pa(ci->ci_pae_l3_pdir[0]))
+#elif !defined(XEN)
+#define KASSERT_PDIRPA(pmap) \
+ KASSERT(pmap_pdirpa(pmap, 0) == pmap_pte2pa(rcr3()))
+#else
+#define KASSERT_PDIRPA(pmap) KASSERT(true) /* nothing to do */
+#endif
+
/*
* pmap_reactivate: try to regain reference to the pmap.
*
@@ -2880,13 +2894,7 @@
const cpuid_t cid = cpu_index(ci);
KASSERT(kpreempt_disabled());
-#if defined(XEN) && defined(__x86_64__)
- KASSERT(pmap_pdirpa(pmap, 0) == ci->ci_xen_current_user_pgd);
-#elif defined(PAE)
- KASSERT(pmap_pdirpa(pmap, 0) == pmap_pte2pa(ci->ci_pae_l3_pdir[0]));
-#elif !defined(XEN)
- KASSERT(pmap_pdirpa(pmap, 0) == pmap_pte2pa(rcr3()));
-#endif
+ KASSERT_PDIRPA(pmap);
/*
* If we still have a lazy reference to this pmap, we can assume
@@ -2979,14 +2987,7 @@
kcpuset_atomic_clear(oldpmap->pm_cpus, cid);
kcpuset_atomic_clear(oldpmap->pm_kernel_cpus, cid);
-#if defined(XEN) && defined(__x86_64__)
- KASSERT(pmap_pdirpa(oldpmap, 0) == ci->ci_xen_current_user_pgd ||
- oldpmap == pmap_kernel());
-#elif defined(PAE)
- KASSERT(pmap_pdirpa(oldpmap, 0) == pmap_pte2pa(ci->ci_pae_l3_pdir[0]));
-#elif !defined(XEN)
- KASSERT(pmap_pdirpa(oldpmap, 0) == pmap_pte2pa(rcr3()));
-#endif
+ KASSERT_PDIRPA(oldpmap);
KASSERT(!kcpuset_isset(pmap->pm_cpus, cid));
KASSERT(!kcpuset_isset(pmap->pm_kernel_cpus, cid));
@@ -3091,13 +3092,7 @@
return;
}
-#if defined(XEN) && defined(__x86_64__)
- KASSERT(pmap_pdirpa(pmap, 0) == ci->ci_xen_current_user_pgd);
-#elif defined(PAE)
- KASSERT(pmap_pdirpa(pmap, 0) == pmap_pte2pa(ci->ci_pae_l3_pdir[0]));
-#elif !defined(XEN)
- KASSERT(pmap_pdirpa(pmap, 0) == pmap_pte2pa(rcr3()));
-#endif
+ KASSERT_PDIRPA(pmap);
KASSERT(ci->ci_pmap == pmap);
/*
Home |
Main Index |
Thread Index |
Old Index