From nobody Wed Nov 08 12:31:48 2023 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 4SQPbT1tp2z50KBY; Wed, 8 Nov 2023 12:31:49 +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 4SQPbT1K61z3Xt0; Wed, 8 Nov 2023 12:31:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699446709; 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=ceNK342Qdf1sOkEGsAQHWsNpErENK+Y5xqdJGBJcCsU=; b=L7vEelTqXh4bk9v0R8t6NOpN4YohBBATFxohVBqy131KS9FjZOr2ngqJcVmR3NLUNtcFrZ SF0A3+aIAuqm6CSJcMgpkzsvD1AGmsjR+2UxlQheAPxZ2xT6qcid49moswA8xvB4L7BYon oyhcS5LP+nYF8RpOZp+a5cuSODQyQ9WJGuhoWpofoDwDWTl1+aP7g9xTcrhC9CGwyQpxH/ pqdHkR+PZyvRo7IIoBaBxQEytDUkW8b4/FFs+D83mYc9pj2cEwR955BHko+8TK8YPZN5wG O/3dGZlR9uyg1YYXRcG8p/IWd3DDEeP2fgq+4S8AQV0X5rtxOLmML/SoK6jNYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699446709; 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=ceNK342Qdf1sOkEGsAQHWsNpErENK+Y5xqdJGBJcCsU=; b=e6xLLKdiwQIX84CWWa2uKlCo3sHlhUSCq9ccaEZ4BoVAOuMUhic2ZLgejb6N1qdi154qUX 8Rx5LrTgEby2pwEC8Gm2HFb1yZ0SsXu4Ky/l8XeT1my/sO0LLmAeewSlpBOWJlyhKss06D oT2cMdImNb+BU17RaJkq4o8NaMDBJcic7UVRqFr2QIPjqDICJwbxWNjL99jpX0Rx8fptCn ozKGb9UvZ63JWV1ol6DLNerNB3zUi5P3BWzK/ATWGNMuPIwrgjQAqrg4d7kCYZumouDzeU c6m7ONYyW9QnLJ4Js8jBoi3O4r45NNtM842+cyIDGMlV8TjzNQfH/0VG2RKHew== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1699446709; a=rsa-sha256; cv=none; b=lqQnhyfkA6TbmaziF17sMkah1gslyZNhBmPP6xdt729zX02mGSG6Pl3PwLeCKgE1SIragH 9OzErnn22878J76GWNzZ7Bu0SwMZstcP3cUv1/IDeTNSMWeUp3ascTWT1XbjdkFSbrRR4x y5zJteURm9DAH/d+ksm21ijT5kHK8FkJTbJRCgcoxkeNndFmtK5p+oVgcbJru5Y98VkHFB Yfv3YfYsgaHjxmmz3ym/f1KuFwfnaB9NBQ/DNeUC9JttGdqWLJqw/qmphEI3MMkT+AHasw OZqWDFABpT3J3Klp7SFZXzS8Te5bqru/Jg1tEInrzEqxHLmBPu7z11IKFe9n5g== 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 4SQPbT0HZkzYPC; Wed, 8 Nov 2023 12:31:49 +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 3A8CVm6W056885; Wed, 8 Nov 2023 12:31:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3A8CVmkK056882; Wed, 8 Nov 2023 12:31:48 GMT (envelope-from git) Date: Wed, 8 Nov 2023 12:31:48 GMT Message-Id: <202311081231.3A8CVmkK056882@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: d0941ed9b5c3 - main - riscv: Add a leaf PTP when pmap_enter(psind=1) creates a wired mapping 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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: d0941ed9b5c39d92d0aa75bc253506cb59a2e9a1 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=d0941ed9b5c39d92d0aa75bc253506cb59a2e9a1 commit d0941ed9b5c39d92d0aa75bc253506cb59a2e9a1 Author: Bojan Novković AuthorDate: 2023-11-08 10:20:06 +0000 Commit: Mark Johnston CommitDate: 2023-11-08 12:19:15 +0000 riscv: Add a leaf PTP when pmap_enter(psind=1) creates a wired mapping Let pmap_enter_l2() create wired mappings. In particular, allocate a leaf PTP for use during demotion. This is the last pmap which requires such a change ahead of reverting commit 64087fd7f372. Reviewed by: markj Sponsored by: Google, Inc. (GSoC 2023) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D41633 --- sys/riscv/riscv/pmap.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/sys/riscv/riscv/pmap.c b/sys/riscv/riscv/pmap.c index f6923363c484..223bf0243964 100644 --- a/sys/riscv/riscv/pmap.c +++ b/sys/riscv/riscv/pmap.c @@ -2685,6 +2685,8 @@ pmap_demote_l2_locked(pmap_t pmap, pd_entry_t *l2, vm_offset_t va, ("pmap_demote_l2_locked: oldl2 is not a leaf entry")); if ((oldl2 & PTE_A) == 0 || (mpte = pmap_remove_pt_page(pmap, va)) == NULL) { + KASSERT((oldl2 & PTE_SW_WIRED) == 0, + ("pmap_demote_l2_locked: page table page for a wired mapping is missing")); if ((oldl2 & PTE_A) == 0 || (mpte = vm_page_alloc_noobj( (VIRT_IN_DMAP(va) ? VM_ALLOC_INTERRUPT : 0) | VM_ALLOC_WIRED)) == NULL) { @@ -3217,6 +3219,7 @@ pmap_enter_l2(pmap_t pmap, vm_offset_t va, pd_entry_t new_l2, u_int flags, pd_entry_t *l2, *l3, oldl2; vm_offset_t sva; vm_page_t l2pg, mt; + vm_page_t uwptpg; PMAP_LOCK_ASSERT(pmap, MA_OWNED); @@ -3274,6 +3277,24 @@ pmap_enter_l2(pmap_t pmap, vm_offset_t va, pd_entry_t new_l2, u_int flags, ("pmap_enter_l2: non-zero L2 entry %p", l2)); } + /* + * Allocate leaf ptpage for wired userspace pages. + */ + uwptpg = NULL; + if ((new_l2 & PTE_SW_WIRED) != 0 && pmap != kernel_pmap) { + uwptpg = vm_page_alloc_noobj(VM_ALLOC_WIRED); + if (uwptpg == NULL) { + return (KERN_RESOURCE_SHORTAGE); + } + uwptpg->pindex = pmap_l2_pindex(va); + if (pmap_insert_pt_page(pmap, uwptpg, true, false)) { + vm_page_unwire_noq(uwptpg); + vm_page_free(uwptpg); + return (KERN_RESOURCE_SHORTAGE); + } + pmap_resident_count_inc(pmap, 1); + uwptpg->ref_count = Ln_ENTRIES; + } if ((new_l2 & PTE_SW_MANAGED) != 0) { /* * Abort this mapping if its PV entry could not be created. @@ -3290,6 +3311,16 @@ pmap_enter_l2(pmap_t pmap, vm_offset_t va, pd_entry_t new_l2, u_int flags, pmap_invalidate_page(pmap, va); vm_page_free_pages_toq(&free, true); } + if (uwptpg != NULL) { + mt = pmap_remove_pt_page(pmap, va); + KASSERT(mt == uwptpg, + ("removed pt page %p, expected %p", mt, + uwptpg)); + pmap_resident_count_dec(pmap, 1); + uwptpg->ref_count = 1; + vm_page_unwire_noq(uwptpg); + vm_page_free(uwptpg); + } CTR2(KTR_PMAP, "pmap_enter_l2: failed to create PV entry" " for va %#lx in pmap %p", va, pmap);