From nobody Mon Nov 15 18:03:03 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 2695F188A346; Mon, 15 Nov 2021 18:03:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HtH9P1bJTz3HgX; Mon, 15 Nov 2021 18:03:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 02FB81E4D0; Mon, 15 Nov 2021 18:03:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1AFI331Q027405; Mon, 15 Nov 2021 18:03:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1AFI33Mj027404; Mon, 15 Nov 2021 18:03:03 GMT (envelope-from git) Date: Mon, 15 Nov 2021 18:03:03 GMT Message-Id: <202111151803.1AFI33Mj027404@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 71e6e9da225a - main - amd64: Initialize kernel_pmap's active CPU set to all_cpus List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 71e6e9da225aede95f6813a0fcf886538d0da9fe Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=71e6e9da225aede95f6813a0fcf886538d0da9fe commit 71e6e9da225aede95f6813a0fcf886538d0da9fe Author: Mark Johnston AuthorDate: 2021-11-15 17:41:24 +0000 Commit: Mark Johnston 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 */