From nobody Sat Oct 05 07:11:33 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 4XLGmj48Yhz5Xrjp; Sat, 05 Oct 2024 07:11:33 +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 4XLGmj2Xgwz4NWn; Sat, 5 Oct 2024 07:11:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728112293; 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=QzFgqae46VxOIBJpNV3k3xycuEuj3rbfubgFIIlRk3k=; b=mnks2xRWlZ08jI26O5pXbomsI+fgiM6WPz3icrC4DAvny50JsFRU1Dh2KmhKe9v+5Xb8qa L2VbAFvdJFH5PLsDNRTO/yv8QhE5U+ojodu6E4gx5M8NC7fKLGNVJZJKClr3Lsauvcn+ye K1ch89ZyT8VPJ2Pfo/aULna0rZ5EifPaHNep78Mxg753XgvrZa/FpNNOXZbskHb5CyVXN1 b9bNUlSmqrvcRes32jdgRkm/3MN8gQwt4osZQTlQAUpGNxOLHkcLoXuzMOXiFilFDQTVSF u0XKcT40EbOkwn9VNm1Gh5YILmzoXXe3921rV6W1hZtJl3NlvY6jOKSzbYfl4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728112293; 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=QzFgqae46VxOIBJpNV3k3xycuEuj3rbfubgFIIlRk3k=; b=vUvTJic8HQCwMhvJA+DffMc7sizLgbIXuegLWEodtNaLgxk0tTwQhqmIjItxImfNBC6hAb TfxzUEq3X2nAyeQADHvlxSE8upj25388oJHotTmiVGmvKBRbKgQC7U1omGIB0F5U2ob1Cc 5+UNWgPMDwBiXte3tn/Kpyxg7jFpq0KYV7GftJQiTnMjK50WEmmQg5mvNXf27UlJ4lrOHS vrYb0RwTqcBbyFzLk88f8LWuIzMcRtue6VBfrjcFMVHo5TJ1YhJa646eod0JRfX8ohMMen g728rT66CVjOPk6/6PN0B5wkP96UcbvSfQ8uICZAd8IRACJjBg5h113jF0ySIA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1728112293; a=rsa-sha256; cv=none; b=lIbLrw+YO87XjjGXrhLShFemYkVHDYYsENLhtN91IEl9qOsAvdCAmwWjtHwQVx2Kdv4f2z rO6hgxTgvu2uduGmw0JaZCoDbFxYeJFm+iou0yPX3RaTHZN/EqtpxK8bibz1Nvy8wKxlwl 5WHtOgKWstnULsNyZFy6QpC6/k+gF2VATW9xkrTzrkbr7BzXJCVtGb1tycFwoj65pw/E9d LTtxpvafKk+/qefd3kz/qJpAqXnsEgx4UDJ5kZuoot6I0rPWWZd8DbR8gQEs1Q6RpTPNPd Rw3hDD599W7H0lhQTO7JIIsPhqt4WwE1i/AyMYIfBlwbEJ9+Z6EH2IUPcVdKAw== 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 4XLGmj1Twcz183p; Sat, 5 Oct 2024 07:11:33 +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 4957BX5S001804; Sat, 5 Oct 2024 07:11:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4957BXDP001801; Sat, 5 Oct 2024 07:11:33 GMT (envelope-from git) Date: Sat, 5 Oct 2024 07:11:33 GMT Message-Id: <202410050711.4957BXDP001801@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: a5943b6e503d - stable/14 - iommu: change iommu_domain_map_ops to take iommu_map_entry 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: a5943b6e503df1b75436f85ca7efa7e94c631a24 Auto-Submitted: auto-generated The branch stable/14 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=a5943b6e503df1b75436f85ca7efa7e94c631a24 commit a5943b6e503df1b75436f85ca7efa7e94c631a24 Author: Konstantin Belousov AuthorDate: 2024-09-25 01:47:54 +0000 Commit: Konstantin Belousov CommitDate: 2024-10-05 07:08:56 +0000 iommu: change iommu_domain_map_ops to take iommu_map_entry (cherry picked from commit bdd5eb33cacdbf174980b999c77847d0903fc12e) --- sys/arm64/iommu/iommu.c | 25 +++++++++++-------------- sys/dev/iommu/iommu.h | 8 ++++---- sys/dev/iommu/iommu_gas.c | 12 +++++------- sys/x86/iommu/intel_ctx.c | 4 ++-- sys/x86/iommu/intel_idpgtbl.c | 15 ++++++++++----- 5 files changed, 32 insertions(+), 32 deletions(-) diff --git a/sys/arm64/iommu/iommu.c b/sys/arm64/iommu/iommu.c index cdff7cdf4ae2..eb682a4a623f 100644 --- a/sys/arm64/iommu/iommu.c +++ b/sys/arm64/iommu/iommu.c @@ -81,22 +81,21 @@ struct iommu_entry { static LIST_HEAD(, iommu_entry) iommu_list = LIST_HEAD_INITIALIZER(iommu_list); static int -iommu_domain_unmap_buf(struct iommu_domain *iodom, iommu_gaddr_t base, - iommu_gaddr_t size, int flags) +iommu_domain_unmap_buf(struct iommu_domain *iodom, + struct iommu_map_entry *entry, int flags) { struct iommu_unit *iommu; int error; iommu = iodom->iommu; - - error = IOMMU_UNMAP(iommu->dev, iodom, base, size); - + error = IOMMU_UNMAP(iommu->dev, iodom, entry->start, entry->end - + entry->start); return (error); } static int -iommu_domain_map_buf(struct iommu_domain *iodom, iommu_gaddr_t base, - iommu_gaddr_t size, vm_page_t *ma, uint64_t eflags, int flags) +iommu_domain_map_buf(struct iommu_domain *iodom, struct iommu_map_entry *entry, + vm_page_t *ma, uint64_t eflags, int flags) { struct iommu_unit *iommu; vm_prot_t prot; @@ -111,12 +110,10 @@ iommu_domain_map_buf(struct iommu_domain *iodom, iommu_gaddr_t base, if (eflags & IOMMU_MAP_ENTRY_WRITE) prot |= VM_PROT_WRITE; - va = base; - + va = entry->start; iommu = iodom->iommu; - - error = IOMMU_MAP(iommu->dev, iodom, va, ma, size, prot); - + error = IOMMU_MAP(iommu->dev, iodom, va, ma, entry->end - + entry->start, prot); return (error); } @@ -429,8 +426,8 @@ iommu_domain_unload(struct iommu_domain *iodom, TAILQ_FOREACH_SAFE(entry, entries, dmamap_link, entry1) { KASSERT((entry->flags & IOMMU_MAP_ENTRY_MAP) != 0, ("not mapped entry %p %p", iodom, entry)); - error = iodom->ops->unmap(iodom, entry->start, entry->end - - entry->start, cansleep ? IOMMU_PGF_WAITOK : 0); + error = iodom->ops->unmap(iodom, entry, + cansleep ? IOMMU_PGF_WAITOK : 0); KASSERT(error == 0, ("unmap %p error %d", iodom, error)); TAILQ_REMOVE(entries, entry, dmamap_link); iommu_domain_free_entry(entry, true); diff --git a/sys/dev/iommu/iommu.h b/sys/dev/iommu/iommu.h index 957d4e14e8e2..84d8c3680b71 100644 --- a/sys/dev/iommu/iommu.h +++ b/sys/dev/iommu/iommu.h @@ -86,10 +86,10 @@ struct iommu_unit { }; struct iommu_domain_map_ops { - int (*map)(struct iommu_domain *domain, iommu_gaddr_t base, - iommu_gaddr_t size, vm_page_t *ma, uint64_t pflags, int flags); - int (*unmap)(struct iommu_domain *domain, iommu_gaddr_t base, - iommu_gaddr_t size, int flags); + int (*map)(struct iommu_domain *domain, struct iommu_map_entry *entry, + vm_page_t *ma, uint64_t pflags, int flags); + int (*unmap)(struct iommu_domain *domain, struct iommu_map_entry *entry, + int flags); }; /* diff --git a/sys/dev/iommu/iommu_gas.c b/sys/dev/iommu/iommu_gas.c index 4b6141b981da..26ac38da3c4f 100644 --- a/sys/dev/iommu/iommu_gas.c +++ b/sys/dev/iommu/iommu_gas.c @@ -826,8 +826,7 @@ iommu_gas_map(struct iommu_domain *domain, entry->flags |= eflags; IOMMU_DOMAIN_UNLOCK(domain); - error = domain->ops->map(domain, entry->start, - entry->end - entry->start, ma, eflags, + error = domain->ops->map(domain, entry, ma, eflags, ((flags & IOMMU_MF_CANWAIT) != 0 ? IOMMU_PGF_WAITOK : 0)); if (error == ENOMEM) { iommu_domain_unload_entry(entry, true, @@ -868,9 +867,9 @@ iommu_gas_map_region(struct iommu_domain *domain, struct iommu_map_entry *entry, if (entry->end == entry->start) return (0); - error = domain->ops->map(domain, entry->start, - entry->end - entry->start, ma + OFF_TO_IDX(start - entry->start), - eflags, ((flags & IOMMU_MF_CANWAIT) != 0 ? IOMMU_PGF_WAITOK : 0)); + error = domain->ops->map(domain, entry, + ma + OFF_TO_IDX(start - entry->start), eflags, + ((flags & IOMMU_MF_CANWAIT) != 0 ? IOMMU_PGF_WAITOK : 0)); if (error == ENOMEM) { iommu_domain_unload_entry(entry, false, (flags & IOMMU_MF_CANWAIT) != 0); @@ -979,8 +978,7 @@ iommu_unmap_msi(struct iommu_ctx *ctx) if (entry == NULL) return; - domain->ops->unmap(domain, entry->start, entry->end - - entry->start, IOMMU_PGF_WAITOK); + domain->ops->unmap(domain, entry, IOMMU_PGF_WAITOK); iommu_gas_free_space(entry); diff --git a/sys/x86/iommu/intel_ctx.c b/sys/x86/iommu/intel_ctx.c index ade3f61328d7..bdb5f8740bf2 100644 --- a/sys/x86/iommu/intel_ctx.c +++ b/sys/x86/iommu/intel_ctx.c @@ -896,8 +896,8 @@ dmar_domain_unload(struct iommu_domain *iodom, TAILQ_FOREACH_SAFE(entry, entries, dmamap_link, entry1) { KASSERT((entry->flags & IOMMU_MAP_ENTRY_MAP) != 0, ("not mapped entry %p %p", domain, entry)); - error = iodom->ops->unmap(iodom, entry->start, entry->end - - entry->start, cansleep ? IOMMU_PGF_WAITOK : 0); + error = iodom->ops->unmap(iodom, entry, + cansleep ? IOMMU_PGF_WAITOK : 0); KASSERT(error == 0, ("unmap %p error %d", domain, error)); if (!unit->qi_enabled) { dmar_flush_iotlb_sync(domain, entry->start, diff --git a/sys/x86/iommu/intel_idpgtbl.c b/sys/x86/iommu/intel_idpgtbl.c index 538d09649377..a949e38cc9b1 100644 --- a/sys/x86/iommu/intel_idpgtbl.c +++ b/sys/x86/iommu/intel_idpgtbl.c @@ -463,14 +463,18 @@ dmar_map_buf_locked(struct dmar_domain *domain, iommu_gaddr_t base, } static int -dmar_map_buf(struct iommu_domain *iodom, iommu_gaddr_t base, - iommu_gaddr_t size, vm_page_t *ma, uint64_t eflags, int flags) +dmar_map_buf(struct iommu_domain *iodom, struct iommu_map_entry *entry, + vm_page_t *ma, uint64_t eflags, int flags) { struct dmar_domain *domain; struct dmar_unit *unit; + iommu_gaddr_t base, size; uint64_t pflags; int error; + base = entry->start; + size = entry->end - entry->start; + pflags = ((eflags & IOMMU_MAP_ENTRY_READ) != 0 ? DMAR_PTE_R : 0) | ((eflags & IOMMU_MAP_ENTRY_WRITE) != 0 ? DMAR_PTE_W : 0) | ((eflags & IOMMU_MAP_ENTRY_SNOOP) != 0 ? DMAR_PTE_SNP : 0) | @@ -648,8 +652,8 @@ dmar_unmap_buf_locked(struct dmar_domain *domain, iommu_gaddr_t base, } static int -dmar_unmap_buf(struct iommu_domain *iodom, iommu_gaddr_t base, - iommu_gaddr_t size, int flags) +dmar_unmap_buf(struct iommu_domain *iodom, struct iommu_map_entry *entry, + int flags) { struct dmar_domain *domain; int error; @@ -657,7 +661,8 @@ dmar_unmap_buf(struct iommu_domain *iodom, iommu_gaddr_t base, domain = IODOM2DOM(iodom); DMAR_DOMAIN_PGLOCK(domain); - error = dmar_unmap_buf_locked(domain, base, size, flags); + error = dmar_unmap_buf_locked(domain, entry->start, entry->end - + entry->start, flags); DMAR_DOMAIN_PGUNLOCK(domain); return (error); }