From nobody Mon Apr 22 00:59:19 2024 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 4VN6Mq3Vw3z5HxK0; Mon, 22 Apr 2024 00:59:19 +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 4VN6Mq2zRwz4SyQ; Mon, 22 Apr 2024 00:59:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713747559; 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=/p6JTinFCKpnBTw0vm0KThzeOj9uzxeuQoCpspyInAQ=; b=dQMJxp3U5I0VYteOagfBVEL7CFcfJ3VBLcNAB2OP1a2TSbrwrMp+S19rhdoI6dZAbx9orA iodc5L3hOpZ/Z0wZkOoYyRWVHaT1m1GLJax9cF6/gP7mcJ/2plYP3QU71F1T+h6ls9Hpqt 6nIGGq6BGFCdQMvesdX3P10x7y275MEqkTtro7tJALKXZr9qdL3n7MTmtrabIy6BMYmE1L IsdSeW2e7G2FSa4ruuhy/KqjPdZRkUAZfXa7pRqdYHiKEBN9ks8smUCMTkCnajOlImfSW4 pni4LKYkE6Ua5OFwCi8adptUKTXMZ/4SZFtISEIJIzWKqDc8sx+hlzZKNEpWVw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1713747559; a=rsa-sha256; cv=none; b=CL+bLGKE9aNzp9bao38SHCjkPvW51Xwv0kp0T0TZWDe04DoHhYHZWNj9iflFHiudMY7zKd Zf6oGDyUYqtWWqJWDRrztTVX7gzxBs/kYUP7lUysI6XtSQXWHB5uYJOeRytsAN0xknrWGy VT1hxvMFkXyaPgQ2NnlBgVYCvbDrEwnJ+kUa0OZJt/5/fJ2Tdp3OT74px0u1+T6jyB2761 pBinMVEClVnnSwQe6gXxehVwDKJ4zQ8P+ZvrGYSRYsuUQBGZP4x4PlmtBf7fdLDkZQMwbx Y2FPNklCHfedf1VJFn1L4xEyMmMjF1DZIIPBGPikCH/xIgBGLqdFicT3cY6/gw== 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=1713747559; 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=/p6JTinFCKpnBTw0vm0KThzeOj9uzxeuQoCpspyInAQ=; b=PXIzVJHSwhy4G9mk92zu/SlGh0PRydzkYxF6XIXXcCEDhxECyE0dYDe6chRyXslA0MjOLY nCkMscFs9/6lOfypO+ke3DZ452d3rNqHJLh375jMckNX5aot8BYwM0Ba3loT+aXga01zPs 2rO8UMl8JM/hvTZ8GHM07FXwWHxyU+6HjXNGePK5i7P86yn46h9svnog4cdijHfNRor2uK dIL1pHqJi+4uOSH6/ka228lmDWykcf0inphcTYpr743AfTJNnRPA0gY5QCiBr5RBQBIqK9 cb/V/PEjPF/MNwHI8quM0Pxs/0HgjZtrNwktiG3mDmcGwfLGlqlHCtKlYtnoPg== 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 4VN6Mq2GwczRvp; Mon, 22 Apr 2024 00:59:19 +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 43M0xJux020334; Mon, 22 Apr 2024 00:59:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43M0xJeI020330; Mon, 22 Apr 2024 00:59:19 GMT (envelope-from git) Date: Mon, 22 Apr 2024 00:59:19 GMT Message-Id: <202404220059.43M0xJeI020330@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Doug Moore Subject: git: dd03eafacba9 - main - riscv: create a convenience composite macro 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: dougm X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: dd03eafacba962c9dcec929c3ed9d63e7c43da3a Auto-Submitted: auto-generated The branch main has been updated by dougm: URL: https://cgit.FreeBSD.org/src/commit/?id=dd03eafacba962c9dcec929c3ed9d63e7c43da3a commit dd03eafacba962c9dcec929c3ed9d63e7c43da3a Author: Doug Moore AuthorDate: 2024-04-21 22:24:29 +0000 Commit: Doug Moore CommitDate: 2024-04-21 23:36:00 +0000 riscv: create a convenience composite macro Define PTE_TO_VM_PAGE to compose the PHYS_TO_VM_PAGE and PTE_TO_PHYS macros. Use it where appropriate, and drop some variables that it makes unnecessary. Reviewed by: jhb (previous version) Differential Revision: https://reviews.freebsd.org/D44700 --- sys/riscv/riscv/pmap.c | 50 ++++++++++++++++++-------------------------------- 1 file changed, 18 insertions(+), 32 deletions(-) diff --git a/sys/riscv/riscv/pmap.c b/sys/riscv/riscv/pmap.c index 118efa3a4f55..b92cb816f44a 100644 --- a/sys/riscv/riscv/pmap.c +++ b/sys/riscv/riscv/pmap.c @@ -362,6 +362,7 @@ pagezero(void *p) ((((pte) & ~PTE_HI_MASK) >> PTE_PPN0_S) * PAGE_SIZE) #define L2PTE_TO_PHYS(l2) \ ((((l2) & ~PTE_HI_MASK) >> PTE_PPN1_S) << L2_SHIFT) +#define PTE_TO_VM_PAGE(pte) PHYS_TO_VM_PAGE(PTE_TO_PHYS(pte)) static __inline pd_entry_t * pmap_l0(pmap_t pmap, vm_offset_t va) @@ -940,7 +941,6 @@ vm_page_t pmap_extract_and_hold(pmap_t pmap, vm_offset_t va, vm_prot_t prot) { pt_entry_t *l3p, l3; - vm_paddr_t phys; vm_page_t m; m = NULL; @@ -948,8 +948,7 @@ pmap_extract_and_hold(pmap_t pmap, vm_offset_t va, vm_prot_t prot) l3p = pmap_l3(pmap, va); if (l3p != NULL && (l3 = pmap_load(l3p)) != 0) { if ((l3 & PTE_W) != 0 || (prot & VM_PROT_WRITE) == 0) { - phys = PTE_TO_PHYS(l3); - m = PHYS_TO_VM_PAGE(phys); + m = PTE_TO_VM_PAGE(l3); if (!vm_page_wire_mapped(m)) m = NULL; } @@ -1252,7 +1251,6 @@ pmap_unwire_ptp(pmap_t pmap, vm_offset_t va, vm_page_t m, struct spglist *free) static void _pmap_unwire_ptp(pmap_t pmap, vm_offset_t va, vm_page_t m, struct spglist *free) { - vm_paddr_t phys; PMAP_LOCK_ASSERT(pmap, MA_OWNED); if (m->pindex >= NUL2E + NUL1E) { @@ -1275,8 +1273,7 @@ _pmap_unwire_ptp(pmap_t pmap, vm_offset_t va, vm_page_t m, struct spglist *free) vm_page_t pdpg; l1 = pmap_l1(pmap, va); - phys = PTE_TO_PHYS(pmap_load(l1)); - pdpg = PHYS_TO_VM_PAGE(phys); + pdpg = PTE_TO_VM_PAGE(pmap_load(l1)); pmap_unwire_ptp(pmap, va, pdpg, free); } else if (m->pindex < NUL2E + NUL1E && pmap_mode != PMAP_MODE_SV39) { pd_entry_t *l0; @@ -1284,8 +1281,7 @@ _pmap_unwire_ptp(pmap_t pmap, vm_offset_t va, vm_page_t m, struct spglist *free) MPASS(pmap_mode != PMAP_MODE_SV39); l0 = pmap_l0(pmap, va); - phys = PTE_TO_PHYS(pmap_load(l0)); - pdpg = PHYS_TO_VM_PAGE(phys); + pdpg = PTE_TO_VM_PAGE(pmap_load(l0)); pmap_unwire_ptp(pmap, va, pdpg, free); } pmap_invalidate_page(pmap, va); @@ -1312,7 +1308,7 @@ pmap_unuse_pt(pmap_t pmap, vm_offset_t va, pd_entry_t ptepde, if (va >= VM_MAXUSER_ADDRESS) return (0); KASSERT(ptepde != 0, ("pmap_unuse_pt: ptepde != 0")); - mpte = PHYS_TO_VM_PAGE(PTE_TO_PHYS(ptepde)); + mpte = PTE_TO_VM_PAGE(ptepde); return (pmap_unwire_ptp(pmap, va, mpte, free)); } @@ -1487,8 +1483,7 @@ _pmap_alloc_l3(pmap_t pmap, vm_pindex_t ptepindex, struct rwlock **lockp) lockp) == NULL) goto fail; } else { - phys = PTE_TO_PHYS(pmap_load(l1)); - pdpg = PHYS_TO_VM_PAGE(phys); + pdpg = PTE_TO_VM_PAGE(pmap_load(l1)); pdpg->ref_count++; } } else { @@ -1512,8 +1507,7 @@ _pmap_alloc_l3(pmap_t pmap, vm_pindex_t ptepindex, struct rwlock **lockp) NUL2E + l1index, lockp) == NULL) goto fail; } else { - phys = PTE_TO_PHYS(pmap_load(l1)); - pdpg = PHYS_TO_VM_PAGE(phys); + pdpg = PTE_TO_VM_PAGE(pmap_load(l1)); pdpg->ref_count++; } } @@ -1553,7 +1547,7 @@ retry: ("%s: L1 entry %#lx for VA %#lx is a leaf", __func__, pmap_load(l1), va)); /* Add a reference to the L2 page. */ - l2pg = PHYS_TO_VM_PAGE(PTE_TO_PHYS(pmap_load(l1))); + l2pg = PTE_TO_VM_PAGE(pmap_load(l1)); l2pg->ref_count++; } else { /* Allocate a L2 page. */ @@ -1570,7 +1564,6 @@ pmap_alloc_l3(pmap_t pmap, vm_offset_t va, struct rwlock **lockp) { vm_pindex_t ptepindex; pd_entry_t *l2; - vm_paddr_t phys; vm_page_t m; /* @@ -1588,8 +1581,7 @@ retry: * hold count, and activate it. */ if (l2 != NULL && pmap_load(l2) != 0) { - phys = PTE_TO_PHYS(pmap_load(l2)); - m = PHYS_TO_VM_PAGE(phys); + m = PTE_TO_VM_PAGE(pmap_load(l2)); m->ref_count++; } else { /* @@ -2223,7 +2215,7 @@ pmap_remove_l2(pmap_t pmap, pt_entry_t *l2, vm_offset_t sva, pvh = pa_to_pvh(PTE_TO_PHYS(oldl2)); pmap_pvh_free(pvh, pmap, sva); eva = sva + L2_SIZE; - for (va = sva, m = PHYS_TO_VM_PAGE(PTE_TO_PHYS(oldl2)); + for (va = sva, m = PTE_TO_VM_PAGE(oldl2); va < eva; va += PAGE_SIZE, m++) { if ((oldl2 & PTE_D) != 0) vm_page_dirty(m); @@ -2261,7 +2253,6 @@ pmap_remove_l3(pmap_t pmap, pt_entry_t *l3, vm_offset_t va, { struct md_page *pvh; pt_entry_t old_l3; - vm_paddr_t phys; vm_page_t m; PMAP_LOCK_ASSERT(pmap, MA_OWNED); @@ -2271,8 +2262,7 @@ pmap_remove_l3(pmap_t pmap, pt_entry_t *l3, vm_offset_t va, pmap->pm_stats.wired_count -= 1; pmap_resident_count_dec(pmap, 1); if (old_l3 & PTE_SW_MANAGED) { - phys = PTE_TO_PHYS(old_l3); - m = PHYS_TO_VM_PAGE(phys); + m = PTE_TO_VM_PAGE(old_l3); if ((old_l3 & PTE_D) != 0) vm_page_dirty(m); if (old_l3 & PTE_A) @@ -2487,7 +2477,6 @@ pmap_protect(pmap_t pmap, vm_offset_t sva, vm_offset_t eva, vm_prot_t prot) pd_entry_t *l0, *l1, *l2, l2e; pt_entry_t *l3, l3e, mask; vm_page_t m, mt; - vm_paddr_t pa; vm_offset_t va_next; bool anychanged, pv_lists_locked; @@ -2543,8 +2532,7 @@ retryl2: if ((prot & VM_PROT_WRITE) == 0 && (l2e & (PTE_SW_MANAGED | PTE_D)) == (PTE_SW_MANAGED | PTE_D)) { - pa = PTE_TO_PHYS(l2e); - m = PHYS_TO_VM_PAGE(pa); + m = PTE_TO_VM_PAGE(l2e); for (mt = m; mt < &m[Ln_ENTRIES]; mt++) vm_page_dirty(mt); } @@ -2585,7 +2573,7 @@ retryl3: if ((prot & VM_PROT_WRITE) == 0 && (l3e & (PTE_SW_MANAGED | PTE_D)) == (PTE_SW_MANAGED | PTE_D)) { - m = PHYS_TO_VM_PAGE(PTE_TO_PHYS(l3e)); + m = PTE_TO_VM_PAGE(l3e); vm_page_dirty(m); } if (!atomic_fcmpset_long(l3, &l3e, l3e & ~mask)) @@ -2851,7 +2839,7 @@ pmap_promote_l2(pmap_t pmap, pd_entry_t *l2, vm_offset_t va, vm_page_t ml3, * destroyed by pmap_remove_l3(). */ if (ml3 == NULL) - ml3 = PHYS_TO_VM_PAGE(PTE_TO_PHYS(pmap_load(l2))); + ml3 = PTE_TO_VM_PAGE(pmap_load(l2)); KASSERT(ml3->pindex == pmap_l2_pindex(va), ("pmap_promote_l2: page table page's pindex is wrong")); if (pmap_insert_pt_page(pmap, ml3, true, all_l3e_PTE_A != 0)) { @@ -2953,7 +2941,7 @@ pmap_enter(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot, va, &lock))) { l3 = pmap_l2_to_l3(l2, va); if (va < VM_MAXUSER_ADDRESS) { - mpte = PHYS_TO_VM_PAGE(PTE_TO_PHYS(pmap_load(l2))); + mpte = PTE_TO_VM_PAGE(pmap_load(l2)); mpte->ref_count++; } } else if (va < VM_MAXUSER_ADDRESS) { @@ -3266,7 +3254,7 @@ pmap_enter_l2(pmap_t pmap, vm_offset_t va, pd_entry_t new_l2, u_int flags, * Both pmap_remove_l2() and pmap_remove_l3() will * leave the kernel page table page zero filled. */ - mt = PHYS_TO_VM_PAGE(PTE_TO_PHYS(pmap_load(l2))); + mt = PTE_TO_VM_PAGE(pmap_load(l2)); if (pmap_insert_pt_page(pmap, mt, false, false)) panic("pmap_enter_l2: trie insert failed"); } else @@ -3424,7 +3412,6 @@ pmap_enter_quick_locked(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot, vm_page_t mpte, struct rwlock **lockp) { struct spglist free; - vm_paddr_t phys; pd_entry_t *l2; pt_entry_t *l3, newl3; @@ -3464,8 +3451,7 @@ pmap_enter_quick_locked(pmap_t pmap, vm_offset_t va, vm_page_t m, if (l2 != NULL && pmap_load(l2) != 0) { if ((pmap_load(l2) & PTE_RWX) != 0) return (NULL); - phys = PTE_TO_PHYS(pmap_load(l2)); - mpte = PHYS_TO_VM_PAGE(phys); + mpte = PTE_TO_VM_PAGE(pmap_load(l2)); mpte->ref_count++; } else { /* @@ -4023,7 +4009,7 @@ pmap_remove_pages(pmap_t pmap) continue; } - m = PHYS_TO_VM_PAGE(PTE_TO_PHYS(tpte)); + m = PTE_TO_VM_PAGE(tpte); KASSERT((m->flags & PG_FICTITIOUS) != 0 || m < &vm_page_array[vm_page_array_size], ("pmap_remove_pages: bad pte %#jx",