From nobody Mon Apr 24 11:52:12 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 4Q4k595mvrz46jyX; Mon, 24 Apr 2023 11:52:13 +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 4Q4k5936Bcz3jLs; Mon, 24 Apr 2023 11:52:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682337133; 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=MvKFHeWOSHgYmoR6dmeDrVWeYkPnszBuF5ib9pTHWCU=; b=mZ5kjn/HCMzscwCZCDppVwf3hCa7GcGkXspoRvmQ7UUorKHJhJr6rsooKl3ZVQMs9p8jJs f/ekDlXjpDxkS6QI9R02jQJj7lkg2pvA2uXZ4t+Ro6WBBR6kd1t1zkl3qS2bHur8awCkJ3 gKkKuKRaKjRsQl0PqRRH9vWx1JZetKXFvtPcepUdFABzvwKK36TaLE6JXDLtWieXJm6ZCR Ez3LU82F3PDN7uuVuorJQE26vEzluPtvaqB6uUQPK1+rQKjA+Mz4UOWg2s0VraBJxiyXQf XNM1PW8+ejF9i2QoTvpXR3F63AeORNBiuYYqd2jWxdD+N1Xffvwb7YJct/AfZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682337133; 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=MvKFHeWOSHgYmoR6dmeDrVWeYkPnszBuF5ib9pTHWCU=; b=w49X6h4Vn+MPquO5wfW+rSHHiGPw0nqr29sP2MLp1asUmLxOYUrI4X/6KfcHDZjaRar6z7 pTBZbnUwUNsZr26tVRqJu6XdAk6Q4BCKv4axXtku2PH+r2SN/xObroH1CsNwQUDs7AqYkV 5iLXGM2C3xqRqdrQ8NRJOeL5Ee4W40An9uzt1FqU1mqvVTqVHW3FhgY6a40DkKF+qzfMPZ 7P6qPG336XHXYMs8EjQ1ARnf7/WVbgO9TmDcTS7JFLak52n2EYwYuVECC73qqrlKmEFY08 FoUTVnvroQ6vmr6a3pOrA1q3gWef/ykBiX14VoLGL1knT0cWw+MHWYlyRyGIXw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1682337133; a=rsa-sha256; cv=none; b=mBfC49lFiXK9JrJvTEjgE0sGihuJbhUYCIPaf38MJyLrHQn3/AdrAzZaAAMGpgliwjoZdw j+1K3k6xEDwXu8TR0EwRU2acio9S44jMfCPObSNlhz2IXy1+k1VK8vZrlj+uZtLzL/D07D yn9k5eBDLXCzBwAsnx8TbAFq3HUSfhDqcjb+A0PKvEciY5VBGMxIlnBR+QNv62noTA0FuH GEe86MTzNP9WeO17udqSys6w3Sog4t+o4EtkWUvoixUn2BWnikh3mUy4stc2cvL+NOsrCO DwDEGB5LVS+nsnoi3nLNFtwA0gLx8+X5tizg4BYgCuT57MQnu0tboFdyfNxbnQ== 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 4Q4k586QTrzPh5; Mon, 24 Apr 2023 11:52:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 33OBqCsw003234; Mon, 24 Apr 2023 11:52:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 33OBqCCY003233; Mon, 24 Apr 2023 11:52:12 GMT (envelope-from git) Date: Mon, 24 Apr 2023 11:52:12 GMT Message-Id: <202304241152.33OBqCCY003233@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: cdd34e0038e5 - main - Remove virtual addresses from smmu_pmap_remove_pages 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: andrew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: cdd34e0038e5b22c23cc6e343c8e9ad83f497adf Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=cdd34e0038e5b22c23cc6e343c8e9ad83f497adf commit cdd34e0038e5b22c23cc6e343c8e9ad83f497adf Author: Andrew Turner AuthorDate: 2023-04-24 11:47:55 +0000 Commit: Andrew Turner CommitDate: 2023-04-24 11:47:55 +0000 Remove virtual addresses from smmu_pmap_remove_pages This function needs to unmap all memory in a given SMMU context. Have it iterate over all page table entries to find what has been mapped rather than looking at virtual addresses. While here use SMMU specific macros. Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D39185 --- sys/arm64/iommu/iommu_pmap.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/sys/arm64/iommu/iommu_pmap.c b/sys/arm64/iommu/iommu_pmap.c index c681f7827394..1c45579835c7 100644 --- a/sys/arm64/iommu/iommu_pmap.c +++ b/sys/arm64/iommu/iommu_pmap.c @@ -503,7 +503,7 @@ _pmap_alloc_l3(struct smmu_pmap *pmap, vm_pindex_t ptepindex) pd_entry_t *l0, *l1, *l2; pd_entry_t tl0, tl1; - l1index = ptepindex >> Ln_ENTRIES_SHIFT; + l1index = ptepindex >> IOMMU_Ln_ENTRIES_SHIFT; l0index = l1index >> IOMMU_L0_ENTRIES_SHIFT; l0 = &pmap->sp_l0[l0index]; @@ -792,7 +792,6 @@ smmu_pmap_remove_pages(struct smmu_pmap *pmap) pd_entry_t l0e, *l1, l1e, *l2, l2e; pt_entry_t *l3, l3e; vm_page_t m, m0, m1; - vm_offset_t sva; vm_paddr_t pa; vm_paddr_t pa0; vm_paddr_t pa1; @@ -800,48 +799,43 @@ smmu_pmap_remove_pages(struct smmu_pmap *pmap) SMMU_PMAP_LOCK(pmap); - for (sva = VM_MINUSER_ADDRESS, i = smmu_l0_index(sva); - (i < Ln_ENTRIES && sva < VM_MAXUSER_ADDRESS); i++) { + for (i = 0; i < IOMMU_L0_ENTRIES; i++) { l0e = pmap->sp_l0[i]; if ((l0e & ATTR_DESCR_VALID) == 0) { - sva += IOMMU_L0_SIZE; continue; } pa0 = l0e & ~ATTR_MASK; m0 = PHYS_TO_VM_PAGE(pa0); l1 = (pd_entry_t *)PHYS_TO_DMAP(pa0); - for (j = smmu_l1_index(sva); j < Ln_ENTRIES; j++) { + for (j = 0; j < IOMMU_Ln_ENTRIES; j++) { l1e = l1[j]; if ((l1e & ATTR_DESCR_VALID) == 0) { - sva += IOMMU_L1_SIZE; continue; } if ((l1e & ATTR_DESCR_MASK) == IOMMU_L1_BLOCK) { - sva += IOMMU_L1_SIZE; continue; } pa1 = l1e & ~ATTR_MASK; m1 = PHYS_TO_VM_PAGE(pa1); l2 = (pd_entry_t *)PHYS_TO_DMAP(pa1); - for (k = smmu_l2_index(sva); k < Ln_ENTRIES; k++) { + for (k = 0; k < IOMMU_Ln_ENTRIES; k++) { l2e = l2[k]; if ((l2e & ATTR_DESCR_VALID) == 0) { - sva += IOMMU_L2_SIZE; continue; } pa = l2e & ~ATTR_MASK; m = PHYS_TO_VM_PAGE(pa); l3 = (pt_entry_t *)PHYS_TO_DMAP(pa); - for (l = smmu_l3_index(sva); l < Ln_ENTRIES; - l++, sva += IOMMU_L3_SIZE) { + for (l = 0; l < IOMMU_Ln_ENTRIES; l++) { l3e = l3[l]; if ((l3e & ATTR_DESCR_VALID) == 0) continue; - panic("%s: l3e found for va %jx\n", - __func__, sva); + panic( + "%s: l3e found (indexes %d %d %d %d)", + __func__, i, j, k, l); } vm_page_unwire_noq(m1);