From nobody Thu Jul 17 23:34:02 2025 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 4bjq4q2zbmz62PHD; Thu, 17 Jul 2025 23:34:03 +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 4bjq4q0VC1z3hc1; Thu, 17 Jul 2025 23:34:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1752795243; 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=cqpkw14iUoSXKZFHvpNSRG7WAePAT1kTrPVBTiaAgR0=; b=bGlaYilPjkJ9O4q8WvvaBLjzcbE3qIPp5WIouO1kigVz+fP9s8SU4vEqJ6UE1Wmj4fADQT 0SDIURSo0InKQqtMtQG6PEeGFmSfCgBwmc6+0eIEXHN2gnFQTWa9PsRA1JsmQCvag4yHqI TnhLYuVKzGshKIuuUP0Je+7ksCLmQOtajucRahBy7JZADWhHiwdeb/IvQulRn3yfK5UNZc VfnwpbeuFAubaNiSWy0L96YkedA5D1NPImgynrcwxZL332mGv33Y6Qu9LprFE2oEy26J1u S1lfNFnYWsLU/Bwkogt1rqyLgbuMJ23WS1KW/TFIiv+qqRbv118MfimGFHzs8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1752795243; 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=cqpkw14iUoSXKZFHvpNSRG7WAePAT1kTrPVBTiaAgR0=; b=Ra99JRuEs6cUm2pv0myPacEZy3feIryNn+F08wMX3hzFdj2t1A/XXdDrYoBHgs+2igjvqM sNmewL7iMd30pCQKnkWu5ALE2MyQoJgO6cri3s0dD3+i2DykJdqiRsKrgMIILCYMOptlbj igigqs5I74m1XcBLicCLiyhX44AHilyPI+uRqLSVtE5CKMUiSgLwZrH0NPcKkQOMU223SQ So58W0sm1j9Y3dNrL4HJG3v7TXkGvtc1pe6P3uY7woSadhztHBkO/e4XsZY8adeswuFoUZ 6pc4zp4UrbyFzlSF3ntejNNSWzQTjpylQFqYjlzO9leDXVjXQBBLydmkhQOCtA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1752795243; a=rsa-sha256; cv=none; b=Hq5rWHOrCbJrb1YZAHjKWco8YP8MXOprCdRy4ZAn7ZvHimCtOTi08Sas3LN+DnsYJxt02m MYrnJfgIejD8NjIAwBWErlkoMHToDU8AmU+aSQXWtQyGczybl/ixAt5pyAfu6H+kiurZtI /67gl5ACSFPhg6/Trrf/tGGODJgu9A+oVDtZkbfk0oFBu7r2Y1ajUI9d/cR+2DrlYllpx4 VjzbfOwiW/d1BdWQpsVX8+7lKpfhhW+Dkj2Pp/N5SPdwib9GYPMGLnXaa8W+OKu7WRhPE+ lJugZlVbfNji3pPiwp0PyuPoDLQGViHInV/sKKphMljQRyBo3aCjJFkFsb18fg== 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 4bjq4p72Zdz1gZ; Thu, 17 Jul 2025 23:34:02 +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 56HNY2hB082870; Thu, 17 Jul 2025 23:34:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 56HNY2qW082867; Thu, 17 Jul 2025 23:34:02 GMT (envelope-from git) Date: Thu, 17 Jul 2025 23:34:02 GMT Message-Id: <202507172334.56HNY2qW082867@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alan Cox Subject: git: 5a846c48f209 - main - pmap_enter_{l2,pde}: correct the handling of an error case 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 5a846c48f209d04dad36aa35a9968f557c4516f7 Auto-Submitted: auto-generated The branch main has been updated by alc: URL: https://cgit.FreeBSD.org/src/commit/?id=5a846c48f209d04dad36aa35a9968f557c4516f7 commit 5a846c48f209d04dad36aa35a9968f557c4516f7 Author: Alan Cox AuthorDate: 2025-07-16 08:08:49 +0000 Commit: Alan Cox CommitDate: 2025-07-17 22:10:29 +0000 pmap_enter_{l2,pde}: correct the handling of an error case When pmap_enter_object()'s call to pmap_enter_{l2,pde}() fails to create a managed mapping within the kernel address space due to the inability to allocate a PV entry, it needs to remove the kernel page table page from the pmap's trie of idle page table pages. Previously, it did not. Reviewed by: andrew, kib, markj MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D51353 --- sys/amd64/amd64/pmap.c | 11 +++++++++++ sys/arm64/arm64/pmap.c | 12 ++++++++++++ 2 files changed, 23 insertions(+) diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index 2c7777e608b9..14f57ca94ba7 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -7561,6 +7561,9 @@ pmap_enter_pde(pmap_t pmap, vm_offset_t va, pd_entry_t newpde, u_int flags, PG_RW = pmap_rw_bit(pmap); KASSERT((newpde & (pmap_modified_bit(pmap) | PG_RW)) != PG_RW, ("pmap_enter_pde: newpde is missing PG_M")); + KASSERT((flags & (PMAP_ENTER_NOREPLACE | PMAP_ENTER_NORECLAIM)) != + PMAP_ENTER_NORECLAIM, + ("pmap_enter_pde: flags is missing PMAP_ENTER_NOREPLACE")); PG_V = pmap_valid_bit(pmap); PMAP_LOCK_ASSERT(pmap, MA_OWNED); @@ -7689,6 +7692,14 @@ pmap_enter_pde(pmap_t pmap, vm_offset_t va, pd_entry_t newpde, u_int flags, if (!pmap_pv_insert_pde(pmap, va, newpde, flags, lockp)) { if (pdpg != NULL) pmap_abort_ptp(pmap, va, pdpg); + else { + KASSERT(va >= VM_MAXUSER_ADDRESS && + (*pde & (PG_PS | PG_V)) == PG_V, + ("pmap_enter_pde: invalid kernel PDE")); + mt = pmap_remove_pt_page(pmap, va); + KASSERT(mt != NULL, + ("pmap_enter_pde: missing kernel PTP")); + } if (uwptpg != NULL) { mt = pmap_remove_pt_page(pmap, va); KASSERT(mt == uwptpg, diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c index a09da794e77d..459cc8ebe505 100644 --- a/sys/arm64/arm64/pmap.c +++ b/sys/arm64/arm64/pmap.c @@ -5709,6 +5709,9 @@ pmap_enter_l2(pmap_t pmap, vm_offset_t va, pd_entry_t new_l2, u_int flags, PMAP_LOCK_ASSERT(pmap, MA_OWNED); KASSERT(ADDR_IS_CANONICAL(va), ("%s: Address not in canonical form: %lx", __func__, va)); + KASSERT((flags & (PMAP_ENTER_NOREPLACE | PMAP_ENTER_NORECLAIM)) != + PMAP_ENTER_NORECLAIM, + ("pmap_enter_l2: flags is missing PMAP_ENTER_NOREPLACE")); if ((l2 = pmap_alloc_l2(pmap, va, &l2pg, (flags & PMAP_ENTER_NOSLEEP) != 0 ? NULL : lockp)) == NULL) { @@ -5828,6 +5831,15 @@ pmap_enter_l2(pmap_t pmap, vm_offset_t va, pd_entry_t new_l2, u_int flags, if (!pmap_pv_insert_l2(pmap, va, new_l2, flags, lockp)) { if (l2pg != NULL) pmap_abort_ptp(pmap, va, l2pg); + else { + KASSERT(ADDR_IS_KERNEL(va) && + (pmap_load(l2) & ATTR_DESCR_MASK) == + L2_TABLE, + ("pmap_enter_l2: invalid kernel L2E")); + mt = pmap_remove_pt_page(pmap, va); + KASSERT(mt != NULL, + ("pmap_enter_l2: missing kernel PTP")); + } if (uwptpg != NULL) { mt = pmap_remove_pt_page(pmap, va); KASSERT(mt == uwptpg,