Date: Mon, 15 Nov 2021 18:03:03 GMT From: Mark Johnston <markj@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 71e6e9da225a - main - amd64: Initialize kernel_pmap's active CPU set to all_cpus Message-ID: <202111151803.1AFI33Mj027404@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=71e6e9da225aede95f6813a0fcf886538d0da9fe commit 71e6e9da225aede95f6813a0fcf886538d0da9fe Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2021-11-15 17:41:24 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2021-11-15 18:01:30 +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 MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32792 --- 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 3f1125cfc79f..f369ec360c83 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -1958,11 +1958,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. */ @@ -3010,12 +3015,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) { @@ -10925,7 +10924,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 1e63ffb68099..b327d04c8261 100644 --- a/sys/amd64/include/pmap.h +++ b/sys/amd64/include/pmap.h @@ -532,6 +532,12 @@ vm_page_t pmap_page_alloc_below_4g(bool zeroed); void pmap_san_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 */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202111151803.1AFI33Mj027404>