From nobody Sun Aug 10 23:23:42 2025 X-Original-To: dev-commits-src-all@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 4c0Yjq4r2Jz63XQq; Sun, 10 Aug 2025 23:23:43 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4c0Yjq1cq1z3fwB; Sun, 10 Aug 2025 23:23:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1754868223; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=On+vzg6nakLZXpAOAiBgfiFU906aI1eKFN7IP3Zb/9Y=; b=VXgszX9uZp4yY9j+9P3ak1ywE7ndQitJpexpxbMV8n66gbqkGTfaz6O+AzI4QNV4ixCl2L StGPcviUV7KjPlPGwk0gCyBMBJ6JkvXcb2qHUtunehJxCCAtKMU+p/ekm/G6RdoaXMoVSN ESASnSEvmBcCaFw/FQSZ8GHWxU3/HDG4Q7PZ2YoI6QVE2IezCC3jwAKaT+YRRkXmrjEiTo 0Nclt/M4uRBVW4zGwx/YEcS3SwTIEs5+p0y8jN6l8sO/CdDro0S+0YFqJDgwI601uN+Tqg Q2A9WhWrf2ceUxsBh3sm8qLizgW3GalFLhk67ZTyi9AGituDuG1gQm32N015Aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1754868223; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=On+vzg6nakLZXpAOAiBgfiFU906aI1eKFN7IP3Zb/9Y=; b=lQuc7jfPlfAlPBFn/TfYSmrB5T0IhRk1ZNhNBITPe0yHXdlG6BSVr8ETdxzWjEanW0IUrd MlOQeb6n2zF8G9g4MHK/IvXHxCxpMQwi5eeRCfNFhNIdHIJNQPLGd6idL2tYTBMJveUxYt VQUz9d7vKMtEf30S+Grvbmit0C/B/B4IO3b7Jom5lWh6t32lnVU4vE0Qj6JzBOIJogv6IZ Csj4C8vrS6awmyyuGkLBN97myZVhiKsdHwaCFx+Sf7+Hzqfg6X9+vA7A6VdeMjN5xI9xkB +R91SE/hOWmUmypH08mOQsBtMg00YhIq8LAdLKh2uX4CXz7Re4Cy6TdApfTTMg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1754868223; a=rsa-sha256; cv=none; b=x4o79KHnSdJjIkTITEwMgjiHZsFgqJaItCsD7n1NLtDX09q23M/sdWhc7kjAAfwagN4k6Y R7Y/IBtpxsEhaL9xGEOuKp5g+6lWymGaHvec9LpOqPhCtOvrZZXLwPuoGvQQjKnN5XUVLS lIJ6DioluoYvYIXa9atl8vGRscLF4+xWPAgVRAGU1Ct5LXii8pFLTQKT4groora+jQnBvU wbIcjI7LcVmw8hHk560z+WViH4ysB1Dw8AMG7bjCC8LCFUKz6XUD+XvehiYHBHpiu/kolJ s964IiMkTjU91dLYVmF6rz2WnDhppnMDvnJuy+l4VnttXaPI2utZ40fbVtX05g== 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 4c0Yjp71HzzBnq; Sun, 10 Aug 2025 23:23:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 57ANNg41054139; Sun, 10 Aug 2025 23:23:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 57ANNgf8054136; Sun, 10 Aug 2025 23:23:42 GMT (envelope-from git) Date: Sun, 10 Aug 2025 23:23:42 GMT Message-Id: <202508102323.57ANNgf8054136@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alan Cox Subject: git: d88f8a306cfe - stable/14 - pmap_demote_{l2,pde}: never invalidate wired mappings List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: alc X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: d88f8a306cfe7ba0a629108102ed2be0b090a876 Auto-Submitted: auto-generated The branch stable/14 has been updated by alc: URL: https://cgit.FreeBSD.org/src/commit/?id=d88f8a306cfe7ba0a629108102ed2be0b090a876 commit d88f8a306cfe7ba0a629108102ed2be0b090a876 Author: Alan Cox AuthorDate: 2025-07-19 20:18:04 +0000 Commit: Alan Cox CommitDate: 2025-08-10 21:02:57 +0000 pmap_demote_{l2,pde}: never invalidate wired mappings Rather than demoting a superpage mapping that hasn't been accessed, we ordinarily invalidate it. However, if the mapping is wired, invalidation is problematic because the page fault to reinstantiate the mapping could sleep. Instead, demote the wired mapping with the accessed flag cleared in the PTEs. (cherry picked from commit 7502c1f270827434bb9661cbb4b9652fdb836521) --- sys/amd64/amd64/pmap.c | 21 +++++++++++---------- sys/arm64/arm64/pmap.c | 24 +++++++++++++----------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index 8aea7ad6d622..9fd6c4091c95 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -6043,17 +6043,18 @@ pmap_demote_pde_mpte(pmap_t pmap, pd_entry_t *pde, vm_offset_t va, if (mpte == NULL) { /* * Invalidate the 2MB page mapping and return "failure" if the - * mapping was never accessed. + * mapping was never accessed and not wired. */ if ((oldpde & PG_A) == 0) { - KASSERT((oldpde & PG_W) == 0, - ("pmap_demote_pde: a wired mapping is missing PG_A")); - pmap_demote_pde_abort(pmap, va, pde, oldpde, lockp); - return (FALSE); - } - - mpte = pmap_remove_pt_page(pmap, va); - if (mpte == NULL) { + if ((oldpde & PG_W) == 0) { + pmap_demote_pde_abort(pmap, va, pde, oldpde, + lockp); + return (false); + } + mpte = pmap_remove_pt_page(pmap, va); + /* Fill the PTP with PTEs that have PG_A cleared. */ + mpte->valid = 0; + } else if ((mpte = pmap_remove_pt_page(pmap, va)) == NULL) { KASSERT((oldpde & PG_W) == 0, ("pmap_demote_pde: page table page for a wired mapping is missing")); @@ -6105,7 +6106,7 @@ pmap_demote_pde_mpte(pmap_t pmap, pd_entry_t *pde, vm_offset_t va, /* * If the PTP is not leftover from an earlier promotion or it does not * have PG_A set in every PTE, then fill it. The new PTEs will all - * have PG_A set. + * have PG_A set, unless this is a wired mapping with PG_A clear. */ if (!vm_page_all_valid(mpte)) pmap_fill_ptp(firstpte, newpte); diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c index 05cb0df4a1ae..a3014fd5cee3 100644 --- a/sys/arm64/arm64/pmap.c +++ b/sys/arm64/arm64/pmap.c @@ -7093,18 +7093,20 @@ pmap_demote_l2_locked(pmap_t pmap, pt_entry_t *l2, vm_offset_t va, /* * Invalidate the 2MB page mapping and return "failure" if the - * mapping was never accessed. + * mapping was never accessed and not wired. */ if ((oldl2 & ATTR_AF) == 0) { - KASSERT((oldl2 & ATTR_SW_WIRED) == 0, - ("pmap_demote_l2: a wired mapping is missing ATTR_AF")); - pmap_demote_l2_abort(pmap, va, l2, lockp); - CTR2(KTR_PMAP, "pmap_demote_l2: failure for va %#lx in pmap %p", - va, pmap); - goto fail; - } - - if ((ml3 = pmap_remove_pt_page(pmap, va)) == NULL) { + if ((oldl2 & ATTR_SW_WIRED) == 0) { + pmap_demote_l2_abort(pmap, va, l2, lockp); + CTR2(KTR_PMAP, + "pmap_demote_l2: failure for va %#lx in pmap %p", + va, pmap); + goto fail; + } + ml3 = pmap_remove_pt_page(pmap, va); + /* Fill the PTP with L3Es that have ATTR_AF cleared. */ + ml3->valid = 0; + } else if ((ml3 = pmap_remove_pt_page(pmap, va)) == NULL) { KASSERT((oldl2 & ATTR_SW_WIRED) == 0, ("pmap_demote_l2: page table page for a wired mapping" " is missing")); @@ -7160,7 +7162,7 @@ pmap_demote_l2_locked(pmap_t pmap, pt_entry_t *l2, vm_offset_t va, /* * If the PTP is not leftover from an earlier promotion or it does not * have ATTR_AF set in every L3E, then fill it. The new L3Es will all - * have ATTR_AF set. + * have ATTR_AF set, unless this is a wired mapping with ATTR_AF clear. * * When pmap_update_entry() clears the old L2 mapping, it (indirectly) * performs a dsb(). That dsb() ensures that the stores for filling