Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp221081ybh; Sun, 12 Jul 2020 04:15:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygh8sZESQBAwyjvogL1VV9s2RbXCDtXG834Pa7RJ+yrNlOUHuIZNmLuSwOLT0MV9zL0mBh X-Received: by 2002:a17:906:3945:: with SMTP id g5mr73644365eje.549.1594552532684; Sun, 12 Jul 2020 04:15:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594552532; cv=none; d=google.com; s=arc-20160816; b=FINiJ3VWypNznRa+OAMTfXsjWjU+ydKi6HzRl1anuRYB+9DE0YRdkapT6XlUdEcSgL f05iPAtchw/Eu1mVAw/k3vtGuqSM3/wqi+1/CGkUKDkqDYIzOSh6hS5sBYxMzH2SAVuP OVKpWKLJRD+h7r1orZC5JL0VLATRwBI5m/xZgGW2W9ZDiqiT5SxsExrh33XEzDml7B1C oPe5zJwTMdpmyJKHGHlDByBSucd25SnmNie5GZwgNa7F3FKGMwFyZjBO62ZbVLAwB6l9 RyuLyb5l/+fctNbxmSe8tA90d2tw/AjBPvepWBQpXESZqpCStNpOYOfzFWYxhn/q/EVd 9AOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:ironport-sdr:ironport-sdr; bh=uFz/V7/r3ufUtA+yQ2GYE3+dJfLvu+aKd16v6jaXb/I=; b=GrAAnekwpO5E06E8mCXsrJAxykSZJQIdo5ZV5Vv7o4s5lOZvisbyQRDifcY/nOXl8t Xb3fEXcDjWi+aWWCLPE4Y2JOh11jV8p8MyU4tt6olNdj7MpZSYt78jpz2CQ/31s4Aom9 W9n9jlP2rmkQOumcp9AHt3HeAquIg0TeAamp7l+cQH5k7/oPRD8wvzGe77YlRXdHt/XR y1OpvIQzhs+7UfABWYbDiQynJLxrcNWcFutK+thVz3Zv8Mwmk8YGt9K9otyIfqHM6zxa heNIU9lRy8d0Pu64XbtqVUMhKAd+oed9+BUNaXQHE9xVu1LMK62aG20Czc856elxjuBf lTpA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c13si7285015edw.351.2020.07.12.04.15.09; Sun, 12 Jul 2020 04:15:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728882AbgGLLOq (ORCPT + 99 others); Sun, 12 Jul 2020 07:14:46 -0400 Received: from mga09.intel.com ([134.134.136.24]:45842 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728841AbgGLLOi (ORCPT ); Sun, 12 Jul 2020 07:14:38 -0400 IronPort-SDR: wsR7g4+7jJII1LHBDnWl1//h3N+d6+TBk3VTpphjLz2zbtmsJbi65+hCtuXLqmgwHW6xR3IZhj QfBDI0/hXhPA== X-IronPort-AV: E=McAfee;i="6000,8403,9679"; a="149952697" X-IronPort-AV: E=Sophos;i="5.75,343,1589266800"; d="scan'208";a="149952697" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jul 2020 04:14:30 -0700 IronPort-SDR: Umq7MJShKRqhhn0Bck9xEkoGtVeaWrnFSyUsEeKXVLQfwxry9is8TA6hZ3HKDMjKlbYbFnBOrV TLrfGzMuMYQg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,343,1589266800"; d="scan'208";a="315788575" Received: from jacob-builder.jf.intel.com ([10.7.199.155]) by orsmga008.jf.intel.com with ESMTP; 12 Jul 2020 04:14:30 -0700 From: Liu Yi L To: alex.williamson@redhat.com, eric.auger@redhat.com, baolu.lu@linux.intel.com, joro@8bytes.org Cc: kevin.tian@intel.com, jacob.jun.pan@linux.intel.com, ashok.raj@intel.com, yi.l.liu@intel.com, jun.j.tian@intel.com, yi.y.sun@intel.com, jean-philippe@linaro.org, peterx@redhat.com, hao.wu@intel.com, stefanha@gmail.com, iommu@lists.linux-foundation.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 08/15] iommu: Pass domain to sva_unbind_gpasid() Date: Sun, 12 Jul 2020 04:21:03 -0700 Message-Id: <1594552870-55687-9-git-send-email-yi.l.liu@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1594552870-55687-1-git-send-email-yi.l.liu@intel.com> References: <1594552870-55687-1-git-send-email-yi.l.liu@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yi Sun Current interface is good enough for SVA virtualization on an assigned physical PCI device, but when it comes to mediated devices, a physical device may attached with multiple aux-domains. Also, for guest unbind, the PASID to be unbind should be allocated to the VM. This check requires to know the ioasid_set which is associated with the domain. So this interface needs to pass in domain info. Then the iommu driver is able to know which domain will be used for the 2nd stage translation of the nesting mode and also be able to do PASID ownership check. This patch passes @domain per the above reason. Cc: Kevin Tian CC: Jacob Pan Cc: Alex Williamson Cc: Eric Auger Cc: Jean-Philippe Brucker Cc: Joerg Roedel Cc: Lu Baolu Signed-off-by: Yi Sun Signed-off-by: Liu Yi L --- v2 -> v3: *) pass in domain info only *) use ioasid_t for pasid instead of int type v1 -> v2: *) added in v2. --- drivers/iommu/intel/svm.c | 3 ++- drivers/iommu/iommu.c | 2 +- include/linux/intel-iommu.h | 3 ++- include/linux/iommu.h | 3 ++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c index b9a9c55..d2c0e1a 100644 --- a/drivers/iommu/intel/svm.c +++ b/drivers/iommu/intel/svm.c @@ -432,7 +432,8 @@ int intel_svm_bind_gpasid(struct iommu_domain *domain, struct device *dev, return ret; } -int intel_svm_unbind_gpasid(struct device *dev, int pasid) +int intel_svm_unbind_gpasid(struct iommu_domain *domain, + struct device *dev, ioasid_t pasid) { struct intel_iommu *iommu = intel_svm_device_to_iommu(dev); struct intel_svm_dev *sdev; diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 7910249..d3e554c 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -2151,7 +2151,7 @@ int __iommu_sva_unbind_gpasid(struct iommu_domain *domain, struct device *dev, if (unlikely(!domain->ops->sva_unbind_gpasid)) return -ENODEV; - return domain->ops->sva_unbind_gpasid(dev, data->hpasid); + return domain->ops->sva_unbind_gpasid(domain, dev, data->hpasid); } EXPORT_SYMBOL_GPL(__iommu_sva_unbind_gpasid); diff --git a/include/linux/intel-iommu.h b/include/linux/intel-iommu.h index 0d0ab32..18f292e 100644 --- a/include/linux/intel-iommu.h +++ b/include/linux/intel-iommu.h @@ -738,7 +738,8 @@ extern int intel_svm_enable_prq(struct intel_iommu *iommu); extern int intel_svm_finish_prq(struct intel_iommu *iommu); int intel_svm_bind_gpasid(struct iommu_domain *domain, struct device *dev, struct iommu_gpasid_bind_data *data); -int intel_svm_unbind_gpasid(struct device *dev, int pasid); +int intel_svm_unbind_gpasid(struct iommu_domain *domain, + struct device *dev, ioasid_t pasid); struct iommu_sva *intel_svm_bind(struct device *dev, struct mm_struct *mm, void *drvdata); void intel_svm_unbind(struct iommu_sva *handle); diff --git a/include/linux/iommu.h b/include/linux/iommu.h index e84a1d5..ca5edd8 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -303,7 +303,8 @@ struct iommu_ops { int (*sva_bind_gpasid)(struct iommu_domain *domain, struct device *dev, struct iommu_gpasid_bind_data *data); - int (*sva_unbind_gpasid)(struct device *dev, int pasid); + int (*sva_unbind_gpasid)(struct iommu_domain *domain, + struct device *dev, ioasid_t pasid); int (*def_domain_type)(struct device *dev); -- 2.7.4