From nobody Sat Oct 05 07:11:36 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 4XLGmn1bztz5XrS5; Sat, 05 Oct 2024 07:11:37 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XLGmm4X4Nz4Nt3; Sat, 5 Oct 2024 07:11:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728112296; 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=+RRFM/B68ZU+XPKWnunKb3C27XnPyU02IK0D8fY67HI=; b=peg9ZqnuB7gwBLtNtQl4oBcS64LI5vqOGIp7FWtX2NgEP5ulzNHcVpZ2lnhAolgGOV96Jl 0juhK8tICanouQ++a5fT0WFBk4MlJKm/fqcNH905p0HVU9lJjGC+vL444Gsq0LwFvcUZ+K EjFqPqQDiUNI5Sk/Z6xyXVgI6qoTKFf10+Lc98vnzPdAPOjwWxLuWms4ocMFHaFWKLpgY8 EAwow7J80d0WuyxTb15TW0mNPxUzcsCTHu6S6Rymk9MGWyOjV2eOiVN/yab/FZKBCqBZZ6 DZSebChdgwY+ALWWgGBjX/92mDHqo+7PsIHTPrwPuUS6XDabom5n8ixD1wxaEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728112296; 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=+RRFM/B68ZU+XPKWnunKb3C27XnPyU02IK0D8fY67HI=; b=Quu9fAASF93Z23oTqrm+SJaeSqdulLKhGCeNU45pcNoXSQap+f7olv4iTojtIQ5H0kKYDt LZNgyywYcXShI9vS9JNlnbvubTbKUpNvaNHxaWauhXDf5nrxvDc5fPlWMhHSFTVNSWux+W JMCEyOvNATorKm0GdhiD/eJTUhaiSs4v1T/78H0tX2TNuPciTM4as5tLuEslrGZqyu+XaW 5xvalAEtk5cbsU3PQsay29ME5MJU1SfyUsvsZMySjtGoRuLG8Q6C56jTxYr2BPJVMO0/L1 g6WwpVkOSn37WNM5z+WvBFWAbCRamDTg/SrlP/NvUy7BCzwS5uOtFkg0mJTLGQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1728112296; a=rsa-sha256; cv=none; b=c2t4imW6a8XdmS2M6ZMKGZZQwQ+oTkGWXRKdPaEHES3/e+wElert5pcdYd3+FgEyqwbwid Es9yttg8JGPdL1VQywvpDjHCv7pTShVg2hgtDSocnnRMiwBtkWqhc4m5LUmhgQlKXJqzz+ JY+rR5yTudw8/3jipWQERyWDZZHYrJTxEishefakPXe2wbysx63ikdktnbX1uOi3PMpCv3 AmQv57QKfOBvW1i61pGm33OkFl8xgi2j7F57mY97uibezf6SV60rC9R6D5G6JV6hr4GHGz PLxJafWU/bxLfQ43EzF7wz5JfLclW5+TNGWOmZoOe4Xib62CX80nJ93ig+bofA== 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 4XLGmm482qz17pR; Sat, 5 Oct 2024 07:11:36 +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 4957BaEf002001; Sat, 5 Oct 2024 07:11:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4957BaWr001998; Sat, 5 Oct 2024 07:11:36 GMT (envelope-from git) Date: Sat, 5 Oct 2024 07:11:36 GMT Message-Id: <202410050711.4957BaWr001998@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 938cac4bdf17 - stable/14 - dmar: on unmap, postpone freeing page table pages after the invalidation is done 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: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 938cac4bdf17188644512d5bbaba6768940fc423 Auto-Submitted: auto-generated The branch stable/14 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=938cac4bdf17188644512d5bbaba6768940fc423 commit 938cac4bdf17188644512d5bbaba6768940fc423 Author: Konstantin Belousov AuthorDate: 2024-09-25 03:54:44 +0000 Commit: Konstantin Belousov CommitDate: 2024-10-05 07:08:56 +0000 dmar: on unmap, postpone freeing page table pages after the invalidation is done (cherry picked from commit 3848dc4fe6f37cbcfaea29eb94fa560a503f60ab) --- sys/x86/iommu/intel_idpgtbl.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/sys/x86/iommu/intel_idpgtbl.c b/sys/x86/iommu/intel_idpgtbl.c index 9dc7a2d58b3f..e1b89571971b 100644 --- a/sys/x86/iommu/intel_idpgtbl.c +++ b/sys/x86/iommu/intel_idpgtbl.c @@ -69,7 +69,8 @@ #include static int dmar_unmap_buf_locked(struct dmar_domain *domain, - iommu_gaddr_t base, iommu_gaddr_t size, int flags); + iommu_gaddr_t base, iommu_gaddr_t size, int flags, + struct iommu_map_entry *entry); /* * The cache of the identity mapping page tables for the DMARs. Using @@ -387,7 +388,8 @@ retry: static int dmar_map_buf_locked(struct dmar_domain *domain, iommu_gaddr_t base, - iommu_gaddr_t size, vm_page_t *ma, uint64_t pflags, int flags) + iommu_gaddr_t size, vm_page_t *ma, uint64_t pflags, int flags, + struct iommu_map_entry *entry) { iommu_pte_t *pte; struct sf_buf *sf; @@ -447,7 +449,7 @@ dmar_map_buf_locked(struct dmar_domain *domain, iommu_gaddr_t base, if (sf != NULL) iommu_unmap_pgtbl(sf); dmar_unmap_buf_locked(domain, base1, base - base1, - flags); + flags, entry); TD_PINNED_ASSERT; return (ENOMEM); } @@ -518,7 +520,8 @@ dmar_map_buf(struct iommu_domain *iodom, struct iommu_map_entry *entry, KASSERT((flags & ~IOMMU_PGF_WAITOK) == 0, ("invalid flags %x", flags)); DMAR_DOMAIN_PGLOCK(domain); - error = dmar_map_buf_locked(domain, base, size, ma, pflags, flags); + error = dmar_map_buf_locked(domain, base, size, ma, pflags, flags, + entry); DMAR_DOMAIN_PGUNLOCK(domain); if (error != 0) return (error); @@ -536,11 +539,11 @@ dmar_map_buf(struct iommu_domain *iodom, struct iommu_map_entry *entry, static void dmar_unmap_clear_pte(struct dmar_domain *domain, iommu_gaddr_t base, int lvl, int flags, iommu_pte_t *pte, - struct sf_buf **sf, bool free_fs); + struct sf_buf **sf, struct iommu_map_entry *entry, bool free_fs); static void dmar_free_pgtbl_pde(struct dmar_domain *domain, iommu_gaddr_t base, - int lvl, int flags) + int lvl, int flags, struct iommu_map_entry *entry) { struct sf_buf *sf; iommu_pte_t *pde; @@ -548,12 +551,14 @@ dmar_free_pgtbl_pde(struct dmar_domain *domain, iommu_gaddr_t base, sf = NULL; pde = dmar_pgtbl_map_pte(domain, base, lvl, flags, &idx, &sf); - dmar_unmap_clear_pte(domain, base, lvl, flags, pde, &sf, true); + dmar_unmap_clear_pte(domain, base, lvl, flags, pde, &sf, + entry, true); } static void dmar_unmap_clear_pte(struct dmar_domain *domain, iommu_gaddr_t base, int lvl, - int flags, iommu_pte_t *pte, struct sf_buf **sf, bool free_sf) + int flags, iommu_pte_t *pte, struct sf_buf **sf, + struct iommu_map_entry *entry, bool free_sf) { vm_page_t m; @@ -572,8 +577,8 @@ dmar_unmap_clear_pte(struct dmar_domain *domain, iommu_gaddr_t base, int lvl, KASSERT(m->pindex != 0, ("lost reference (idx) on root pg domain %p base %jx lvl %d", domain, (uintmax_t)base, lvl)); - iommu_pgfree(domain->pgtbl_obj, m->pindex, flags, NULL); - dmar_free_pgtbl_pde(domain, base, lvl - 1, flags); + iommu_pgfree(domain->pgtbl_obj, m->pindex, flags, entry); + dmar_free_pgtbl_pde(domain, base, lvl - 1, flags, entry); } /* @@ -581,7 +586,7 @@ dmar_unmap_clear_pte(struct dmar_domain *domain, iommu_gaddr_t base, int lvl, */ static int dmar_unmap_buf_locked(struct dmar_domain *domain, iommu_gaddr_t base, - iommu_gaddr_t size, int flags) + iommu_gaddr_t size, int flags, struct iommu_map_entry *entry) { iommu_pte_t *pte; struct sf_buf *sf; @@ -632,7 +637,7 @@ dmar_unmap_buf_locked(struct dmar_domain *domain, iommu_gaddr_t base, if ((pte->pte & DMAR_PTE_SP) != 0 || lvl == domain->pglvl - 1) { dmar_unmap_clear_pte(domain, base, lvl, - flags, pte, &sf, false); + flags, pte, &sf, entry, false); break; } } @@ -662,7 +667,7 @@ dmar_unmap_buf(struct iommu_domain *iodom, struct iommu_map_entry *entry, DMAR_DOMAIN_PGLOCK(domain); error = dmar_unmap_buf_locked(domain, entry->start, entry->end - - entry->start, flags); + entry->start, flags, entry); DMAR_DOMAIN_PGUNLOCK(domain); return (error); }