From nobody Mon Oct 9 00:47:14 2023 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 4S3gNL6R4bz4wRrN; Mon, 9 Oct 2023 00:47:14 +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 4S3gNL5wX7z3JQv; Mon, 9 Oct 2023 00:47:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1696812434; 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=sAeeBtGnGUjEt871NJmfqBEmboqYvb6UuHYByqU7dFM=; b=suK0f61yaRaXNEn4f2kZjxJ8vvA+UzlIP6dxhYI22Z9mYRla/uGrfwz2CZg3wKpjsqrD7H MVLl/KPBI+9hYZzuxL2A5Ej0sC+6jpj47rxZ4ujRVF8m3doqnhfftFRh7R6yXgRvw9SPbM vAo0zZtjrPZbNzoeukcd4LvPtzJ4qaVcC0AVTE7+AoegGJV3q6uCcfWxx3Uga0EhDuf8qq k794rcxeyBvqbevMcv2+n5y4Vlhvp/t43Q2yNIkQvYgsGbsq8cSg200CjGMZoOgZDCczUt YreXQKQrjXrdOoXqL+8KaJjgScjayMw0Qy7vsl25LvCVBND0XOPn2Nxf8IlAKQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1696812434; a=rsa-sha256; cv=none; b=LrJ5GgzFEGjLjx5o/YWOsvANxHUE+AYHFWi9glZSFtdn7GK90ZB6LhFhy3I2KNo6oZxdN+ cGhhfDaj2Vh68OgrpSPi9CAPfL7xi35uNA36zfbz6pPbwJEp5AbEi31k876SnY6lTzPI5s pcPsVLkALoTW0PJ1FGOhik7bJcS0rFNOAZ02twW9ZTkmjhCCkQYj8D+E4nmTPK8U7finm/ 4uPp/oflJM4k3K2n6rdaIsV3nLZ/3e0lDuP9T1T5k6738HQBmm35aulwo0lnL98Ys8vb1S exiubjOsFTk3xuQeDOa+pGDr7EI1TQOmhrsvaemZn61xBlvrnY7xZWQtMD1jpQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1696812434; 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=sAeeBtGnGUjEt871NJmfqBEmboqYvb6UuHYByqU7dFM=; b=PSILmEqP+fJilvB4E4ChtNfCYAxJ5QUFI/6kp3fyf9WyNlP+JuU78fucHl9P8cG6syuMxp ZCyTfgb3P00STaexT3aZFEldP6vPUkBw9W6NXgU2z1OIjU+sZfG6I+ide3sGRzkuIQMP5T YdiXsTu6DjplxkrA4JUEftkGdIetFHkT08DVBm0Ksw1BBX/pKKzOimF5nt8iKLSHD1KDXp yUDTSi5Ysymgg48sL3gnahMbLBAum24P5DX/aoPp8Xvk5crX5d9+gXm4KG8zy1H87QSvQU 5C8gJpkI+K0g9a/vQv/8dIOWL4vXdmQ7t87ukKC3M0aUZbD9rT9pOsciRMIhDQ== 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 4S3gNL4hNyzZpj; Mon, 9 Oct 2023 00:47:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3990lElB023861; Mon, 9 Oct 2023 00:47:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3990lEua023858; Mon, 9 Oct 2023 00:47:14 GMT (envelope-from git) Date: Mon, 9 Oct 2023 00:47:14 GMT Message-Id: <202310090047.3990lEua023858@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: 6c1d6d4c7ffd - main - i386: Add a leaf PTP when pmap_enter(psind=1) creates a wired mapping 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: 6c1d6d4c7ffd81d66acd4869cfe596398df301b7 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=6c1d6d4c7ffd81d66acd4869cfe596398df301b7 commit 6c1d6d4c7ffd81d66acd4869cfe596398df301b7 Author: Bojan Novković AuthorDate: 2023-10-09 00:32:35 +0000 Commit: Mark Johnston CommitDate: 2023-10-09 00:40:44 +0000 i386: Add a leaf PTP when pmap_enter(psind=1) creates a wired mapping Let pmap_enter_pde() create wired mappings. In particular, allocate a leaf PTP for use during demotion. This is a step towards reverting commit 64087fd7f372. Reviewed by: alc, kib, markj Sponsored by: Google, Inc. (GSoC 2023) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D41635 --- sys/i386/i386/pmap.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c index 2d19fc51dd53..6b839484e6c5 100644 --- a/sys/i386/i386/pmap.c +++ b/sys/i386/i386/pmap.c @@ -3973,12 +3973,11 @@ pmap_enter_pde(pmap_t pmap, vm_offset_t va, pd_entry_t newpde, u_int flags, struct spglist free; pd_entry_t oldpde, *pde; vm_page_t mt; + vm_page_t uwptpg; rw_assert(&pvh_global_lock, RA_WLOCKED); KASSERT((newpde & (PG_M | PG_RW)) != PG_RW, ("pmap_enter_pde: newpde is missing PG_M")); - KASSERT(pmap == kernel_pmap || (newpde & PG_W) == 0, - ("pmap_enter_pde: cannot create wired user mapping")); PMAP_LOCK_ASSERT(pmap, MA_OWNED); pde = pmap_pde(pmap, va); oldpde = *pde; @@ -4028,11 +4027,40 @@ pmap_enter_pde(pmap_t pmap, vm_offset_t va, pd_entry_t newpde, u_int flags, panic("pmap_enter_pde: trie insert failed"); } } + + /* + * Allocate a leaf ptpage for wired userspace pages. + */ + uwptpg = NULL; + if ((newpde & PG_W) != 0 && pmap != kernel_pmap) { + uwptpg = vm_page_alloc_noobj(VM_ALLOC_WIRED); + if (uwptpg == NULL) { + return (KERN_RESOURCE_SHORTAGE); + } + uwptpg->pindex = va >> PDRSHIFT; + if (pmap_insert_pt_page(pmap, uwptpg, true, false)) { + vm_page_unwire_noq(uwptpg); + vm_page_free(uwptpg); + return (KERN_RESOURCE_SHORTAGE); + } + pmap->pm_stats.resident_count++; + uwptpg->ref_count = NPTEPG; + } if ((newpde & PG_MANAGED) != 0) { /* * Abort this mapping if its PV entry could not be created. */ if (!pmap_pv_insert_pde(pmap, va, newpde, flags)) { + if (uwptpg != NULL) { + mt = pmap_remove_pt_page(pmap, va); + KASSERT(mt == uwptpg, + ("removed pt page %p, expected %p", mt, + uwptpg)); + pmap->pm_stats.resident_count--; + uwptpg->ref_count = 1; + vm_page_unwire_noq(uwptpg); + vm_page_free(uwptpg); + } CTR2(KTR_PMAP, "pmap_enter_pde: failure for va %#lx" " in pmap %p", va, pmap); return (KERN_RESOURCE_SHORTAGE);