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
This commit is contained in:
Mark Johnston 2021-11-15 12:41:24 -05:00
parent 42c2cd1ffb
commit 71e6e9da22
2 changed files with 20 additions and 8 deletions

View file

@ -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)

View file

@ -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 */