Received: by 2002:ac0:950e:0:0:0:0:0 with SMTP id f14csp1321747imc; Sun, 17 Mar 2019 10:27:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqx8+LGSYIXYIr6WwDPFY9I/EgcfShPWwn3q42L7ldv+0tylIqCKfKmKvQMavv3RAgAnqzi4 X-Received: by 2002:a17:902:403:: with SMTP id 3mr15638670ple.48.1552843622894; Sun, 17 Mar 2019 10:27:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552843622; cv=none; d=google.com; s=arc-20160816; b=H9bfaT5vouRxA+QCg2Hw6+QlHckkxZg/EnF+N23Fjkd9zTRS77ob21MFTE32LDZVDC 86w+H9ufVSBgfXP5X13r9czx+R8fbVqulS4O+dbzGszac51OD/t8W/CE0LCLK2Rp7TyG jAFhzbe9Se4l1/VKPX+cD2bFxp7pozSp9PUDW10P8N6lLxTVMa9C7CyAq2TqNJSF4eYy eaN8iMI6+ygYYFHHbWzuAyq2uMJ5VHsAwLw+dzjwnH1NRlzM8a3gnP408eyMoF3VF8IF Y7uE9mARd7wUnXv5RGwBL/plnNzpcgBNZ4G75TAgAjOL6lasqT9ElOu/2i0LhOwCgWKQ cdyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=nK+/CLKKTy/TajMHptJh++bSKDgCSa/RKpZKnZyCics=; b=qdEWjm6qJKJPSV+ZnwCnuMwI3C+hUrqDMDTk3eLmFoDDD4ioS+twtj4zaOkfU7dqvi gPbNr81RspOD56ehbLhkk2VrV0V1Dzixe9s7VKvyL2YRHrZX1oyWyHr60XgS8ZyhZsFV estAiVoJVZwXfIntE7+loQfuUW32FxMF7EN7z3YDkVYIqzSlbAtUcSUD/WDn+44sy1kT djEb3l87O2IjHKQRwx5ivwu0O8dD85A2iRK5jMXl/WbT0iow35+rAzaPGnHumZAoMRqX ztqvqXd6lpyTNx+sYGwYd+GN9La7wiKJ3zYUqyaDYZJEuQltz0qKRakqj3dBQGO94i1Z Io8w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w4si6750659pgp.171.2019.03.17.10.26.47; Sun, 17 Mar 2019 10:27:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727632AbfCQRYY (ORCPT + 99 others); Sun, 17 Mar 2019 13:24:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50402 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726938AbfCQRYX (ORCPT ); Sun, 17 Mar 2019 13:24:23 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E4224308FE62; Sun, 17 Mar 2019 17:24:22 +0000 (UTC) Received: from laptop.redhat.com (ovpn-116-102.ams2.redhat.com [10.36.116.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id E6F6719C71; Sun, 17 Mar 2019 17:24:13 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, joro@8bytes.org, alex.williamson@redhat.com, jacob.jun.pan@linux.intel.com, yi.l.liu@linux.intel.com, jean-philippe.brucker@arm.com, will.deacon@arm.com, robin.murphy@arm.com Cc: kevin.tian@intel.com, ashok.raj@intel.com, marc.zyngier@arm.com, christoffer.dall@arm.com, peter.maydell@linaro.org, vincent.stehle@arm.com Subject: [PATCH v6 16/22] iommu/smmuv3: Implement bind/unbind_guest_msi Date: Sun, 17 Mar 2019 18:22:26 +0100 Message-Id: <20190317172232.1068-17-eric.auger@redhat.com> In-Reply-To: <20190317172232.1068-1-eric.auger@redhat.com> References: <20190317172232.1068-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Sun, 17 Mar 2019 17:24:23 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The bind/unbind_guest_msi() callbacks check the domain is NESTED and redirect to the dma-iommu implementation. Signed-off-by: Eric Auger --- drivers/iommu/arm-smmu-v3.c | 44 +++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index 4a05dd66df74..a4b82c520647 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c @@ -2207,6 +2207,48 @@ static void arm_smmu_put_resv_regions(struct device *dev, kfree(entry); } +static int +arm_smmu_bind_guest_msi(struct iommu_domain *domain, struct device *dev, + dma_addr_t giova, phys_addr_t gpa, size_t size) +{ + struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain); + struct arm_smmu_device *smmu; + int ret = -EINVAL; + + mutex_lock(&smmu_domain->init_mutex); + smmu = smmu_domain->smmu; + if (!smmu) + goto out; + + if (smmu_domain->stage != ARM_SMMU_DOMAIN_NESTED) + goto out; + + ret = iommu_dma_bind_guest_msi(domain, dev, giova, gpa, size); +out: + mutex_unlock(&smmu_domain->init_mutex); + return ret; +} + +static void +arm_smmu_unbind_guest_msi(struct iommu_domain *domain, + struct device *dev, dma_addr_t giova) +{ + struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain); + struct arm_smmu_device *smmu; + + mutex_lock(&smmu_domain->init_mutex); + smmu = smmu_domain->smmu; + if (!smmu) + goto unlock; + + if (smmu_domain->stage != ARM_SMMU_DOMAIN_NESTED) + goto unlock; + + iommu_dma_unbind_guest_msi(domain, dev, giova); +unlock: + mutex_unlock(&smmu_domain->init_mutex); +} + static int arm_smmu_attach_pasid_table(struct iommu_domain *domain, struct iommu_pasid_table_config *cfg) { @@ -2396,6 +2438,8 @@ static struct iommu_ops arm_smmu_ops = { .attach_pasid_table = arm_smmu_attach_pasid_table, .detach_pasid_table = arm_smmu_detach_pasid_table, .cache_invalidate = arm_smmu_cache_invalidate, + .bind_guest_msi = arm_smmu_bind_guest_msi, + .unbind_guest_msi = arm_smmu_unbind_guest_msi, .pgsize_bitmap = -1UL, /* Restricted during device attach */ }; -- 2.20.1