From nobody Wed Nov 03 17:54:04 2021 X-Original-To: dev-commits-src-branches@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 A4D9118241DA; Wed, 3 Nov 2021 17:54:05 +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 4HkvXY06RPz3qMB; Wed, 3 Nov 2021 17:54:04 +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 BA5921D19D; Wed, 3 Nov 2021 17:54: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 1A3Hs4UM029395; Wed, 3 Nov 2021 17:54:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A3Hs4Wk029394; Wed, 3 Nov 2021 17:54:04 GMT (envelope-from git) Date: Wed, 3 Nov 2021 17:54:04 GMT Message-Id: <202111031754.1A3Hs4Wk029394@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 0fcf472fd583 - stable/13 - amd64: Add comments to pmap_pinit_type() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/13 X-Git-Reftype: branch X-Git-Commit: 0fcf472fd583c51d5d583305c10ba1430a378ba1 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=0fcf472fd583c51d5d583305c10ba1430a378ba1 commit 0fcf472fd583c51d5d583305c10ba1430a378ba1 Author: Mark Johnston AuthorDate: 2021-10-20 00:29:18 +0000 Commit: Mark Johnston CommitDate: 2021-11-03 17:41:55 +0000 amd64: Add comments to pmap_pinit_type() ... explaining why we don't pass the pmap pointer to pmap_alloc_pt_page(). Reported by: alc Reviewed by: alc, kib Sponsored by: The FreeBSD Foundation (cherry picked from commit 34fac29e98313fb0bfba0503e2e19e352b452516) --- sys/amd64/amd64/pmap.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index 19219e4676cc..d7954b9444b5 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -4293,7 +4293,9 @@ pmap_pinit_type(pmap_t pmap, enum pmap_type pm_type, int flags) int i; /* - * allocate the page directory page + * Allocate the page directory page. Pass NULL instead of a pointer to + * the pmap here to avoid recording this page in the resident count, as + * optimizations in pmap_remove() depend on this. */ pmltop_pg = pmap_alloc_pt_page(NULL, 0, VM_ALLOC_WIRED | VM_ALLOC_ZERO | VM_ALLOC_WAITOK); @@ -4325,6 +4327,10 @@ pmap_pinit_type(pmap_t pmap, enum pmap_type pm_type, int flags) else pmap_pinit_pml4(pmltop_pg); if ((curproc->p_md.md_flags & P_MD_KPTI) != 0) { + /* + * As with pmltop_pg, pass NULL instead of a pointer to + * the pmap to ensure that the PTI page isn't counted. + */ pmltop_pgu = pmap_alloc_pt_page(NULL, 0, VM_ALLOC_WIRED | VM_ALLOC_WAITOK); pmap->pm_pmltopu = (pml4_entry_t *)PHYS_TO_DMAP(