git: e0cee46f5800 - stable/13 - amd64: Initialize kernel_pmap's active CPU set to all_cpus
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 29 Nov 2021 14:21:05 UTC
The branch stable/13 has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=e0cee46f5800071c105955c530ae91afa2cca002
commit e0cee46f5800071c105955c530ae91afa2cca002
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2021-11-15 17:41:24 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2021-11-29 14:17:08 +0000
amd64: Initialize kernel_pmap's active CPU set to all_cpus
This is in preference to simply filling the cpuset, and allows the
conditional in pmap_invalidate_cpu_mask() to be elided.
Also export pmap_invalidate_cpu_mask() outside of pmap.c for use in a
subsequent commit.
Suggested by: kib
Reviewed by: alc, kib
Tested by: pho
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 71e6e9da225aede95f6813a0fcf886538d0da9fe)
---
sys/amd64/amd64/pmap.c | 22 ++++++++++++++--------
sys/amd64/include/pmap.h | 6 ++++++
2 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c
index 524b40ed2fee..986a1b670d60 100644
--- a/sys/amd64/amd64/pmap.c
+++ b/sys/amd64/amd64/pmap.c
@@ -1924,11 +1924,16 @@ pmap_bootstrap(vm_paddr_t *firstaddr)
kernel_pmap->pm_pmltop = kernel_pml4;
kernel_pmap->pm_cr3 = KPML4phys;
kernel_pmap->pm_ucr3 = PMAP_NO_CR3;
- CPU_FILL(&kernel_pmap->pm_active); /* don't allow deactivation */
TAILQ_INIT(&kernel_pmap->pm_pvchunk);
kernel_pmap->pm_stats.resident_count = res;
kernel_pmap->pm_flags = pmap_flags;
+ /*
+ * The kernel pmap is always active on all CPUs. Once CPUs are
+ * enumerated, the mask will be set equal to all_cpus.
+ */
+ CPU_FILL(&kernel_pmap->pm_active);
+
/*
* Initialize the TLB invalidations generation number lock.
*/
@@ -2968,12 +2973,6 @@ pmap_invalidate_ept(pmap_t pmap)
smr_wait(pmap->pm_eptsmr, goal);
}
-static cpuset_t
-pmap_invalidate_cpu_mask(pmap_t pmap)
-{
- return (pmap == kernel_pmap ? all_cpus : pmap->pm_active);
-}
-
static inline void
pmap_invalidate_preipi_pcid(pmap_t pmap)
{
@@ -10808,7 +10807,14 @@ pmap_pti_init(void)
pti_finalized = true;
VM_OBJECT_WUNLOCK(pti_obj);
}
-SYSINIT(pmap_pti, SI_SUB_CPU + 1, SI_ORDER_ANY, pmap_pti_init, NULL);
+
+static void
+pmap_cpu_init(void *arg __unused)
+{
+ CPU_COPY(&all_cpus, &kernel_pmap->pm_active);
+ pmap_pti_init();
+}
+SYSINIT(pmap_cpu, SI_SUB_CPU + 1, SI_ORDER_ANY, pmap_cpu_init, NULL);
static pdp_entry_t *
pmap_pti_pdpe(vm_offset_t va)
diff --git a/sys/amd64/include/pmap.h b/sys/amd64/include/pmap.h
index bd6a8c006813..14ff4cf3cde9 100644
--- a/sys/amd64/include/pmap.h
+++ b/sys/amd64/include/pmap.h
@@ -535,6 +535,12 @@ void pmap_kasan_enter(vm_offset_t);
void pmap_kmsan_enter(vm_offset_t);
#endif
+static __inline cpuset_t
+pmap_invalidate_cpu_mask(pmap_t pmap)
+{
+ return (pmap->pm_active);
+}
+
#endif /* _KERNEL */
/* Return various clipped indexes for a given VA */