Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1235398pxk; Thu, 10 Sep 2020 10:13:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwK5lY4n+JE6xGRkf1CDmfOxGJ4QwgVY8Kiu7h++RwoHhnIUouE3IOtMyjMjAcVGMHKuokx X-Received: by 2002:a05:6402:70f:: with SMTP id w15mr10634234edx.202.1599758012225; Thu, 10 Sep 2020 10:13:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599758012; cv=none; d=google.com; s=arc-20160816; b=WiUZSYNTPaZbUsSwFRIyOWiqFiDGbtL0hFw8sStF3cwZuPBWenT57aFqtEnWv46Xuu RjPjQlfyHBBw/+8yRmIpqvgs5lUAkSnwVt3K4ctNGVGq8FQp3lVfbICi5+Yb4DnIVMk/ 6ed8VRKk09EIdd0dSWjgiAyZebOJz0jnFxu5Xr9EcdF/FgPfL4GMNPe817sqz9lZOry0 ygXxMsLQcfMrLEnTWDviaObeN+zc2g4pgfkoUVZ8RTRqrftDaCi6fbZu5twpJwodi66+ 3L0p2d4vG2bx42FVkhufGLWEw4522WzBLJMiiehj8O4J4Ih55pAW7Hm1NOI+uVdqvveK qaHw== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date:ironport-sdr:ironport-sdr; bh=TxB7kjGhkrke762M3VGN+6pVWakC9vzF4Y1AZgz1Tio=; b=devxY6SrFgKjAr95fnKqntjwOo/WeWCJJoizH0TGtA88eXa0vWl0YafQmxjSqsdx19 8gzvEUVu7x0c4iy1pIEEEbq5dcVEZv9OrA0BHpdQgx4fKWvN/S5GVv80neqV146s73RZ XeY0OhaKDmqum7z5iAkHqPGMB8vXjoxjXq7eoJjziVAwmLsF9DIlwPDLd46ByKTCO6sd BCJn66NBIjHu29tB29zXTe+w8K8gevduph7RwpvRlK0cPAAq5dhaoc1hXG68RaJVPOcZ kCnPILv7+5BeYQeRO5DYFNIJ0XArRSoIHXC2dMjP4NXgXObytWq6n54q2XRuHXiQFhkI BT7Q== 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 ci4si4136046ejb.290.2020.09.10.10.13.09; Thu, 10 Sep 2020 10:13: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 S1726890AbgIJRMg (ORCPT + 99 others); Thu, 10 Sep 2020 13:12:36 -0400 Received: from mga14.intel.com ([192.55.52.115]:55321 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726167AbgIJRKw (ORCPT ); Thu, 10 Sep 2020 13:10:52 -0400 IronPort-SDR: O87W02/8X/3D2CO5mblc81Zdm2GR6AeytnTGW5Rhy5bYThU7DtHNasdy7tw2E2l33T22zmeRkw XZF314VI5cDw== X-IronPort-AV: E=McAfee;i="6000,8403,9740"; a="157869318" X-IronPort-AV: E=Sophos;i="5.76,413,1592895600"; d="scan'208";a="157869318" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Sep 2020 10:10:51 -0700 IronPort-SDR: y3sx8lMTfOuw2CWmGsmU5NWTdrMQUu/FoHHbxM6PaW6Bm+XOz1mC1rsaSguMbPKBBWT+a28ipy /9w6SGhO5lXA== X-IronPort-AV: E=Sophos;i="5.76,413,1592895600"; d="scan'208";a="300623572" Received: from jacob-builder.jf.intel.com (HELO jacob-builder) ([10.7.199.155]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Sep 2020 10:10:50 -0700 Date: Thu, 10 Sep 2020 10:12:48 -0700 From: Jacob Pan To: Auger Eric Cc: Jacob Pan , iommu@lists.linux-foundation.org, LKML , Jean-Philippe Brucker , Lu Baolu , Joerg Roedel , David Woodhouse , "Tian, Kevin" , Raj Ashok , Wu Hao , jacob.jun.pan@linux.intel.com Subject: Re: [PATCH v2 9/9] iommu/vt-d: Store guest PASID during bind Message-ID: <20200910101248.19460882@jacob-builder> In-Reply-To: <60feda75-5862-c898-97b1-1f5eafdb8d8c@redhat.com> References: <1598070918-21321-1-git-send-email-jacob.jun.pan@linux.intel.com> <1598070918-21321-10-git-send-email-jacob.jun.pan@linux.intel.com> <60feda75-5862-c898-97b1-1f5eafdb8d8c@redhat.com> Organization: OTC X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 1 Sep 2020 19:08:44 +0200 Auger Eric wrote: > Hi Jacob, > On 8/22/20 6:35 AM, Jacob Pan wrote: > > IOASID core maintains the guest-host mapping in the form of SPID and > > IOASID. This patch assigns the guest PASID (if valid) as SPID while > > binding guest page table with a host PASID. This mapping will be > > used for lookup and notifications. > > > > Signed-off-by: Jacob Pan > > --- > > drivers/iommu/intel/svm.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c > > index d8a5efa75095..4c958b1aec4c 100644 > > --- a/drivers/iommu/intel/svm.c > > +++ b/drivers/iommu/intel/svm.c > > @@ -406,6 +406,7 @@ int intel_svm_bind_gpasid(struct iommu_domain > > *domain, struct device *dev, if (data->flags & > > IOMMU_SVA_GPASID_VAL) { svm->gpasid = data->gpasid; > > svm->flags |= SVM_FLAG_GUEST_PASID; > > + ioasid_attach_spid(data->hpasid, > > data->gpasid); > don't you want to handle the returned value? Yes, I also need to add a check for duplicated SPID within a set. > > } > > svm->iommu = iommu; > > /* > > @@ -517,6 +518,7 @@ int intel_svm_unbind_gpasid(struct device *dev, > > int pasid) ioasid_attach_data(pasid, NULL); > > ioasid_notify(pasid, IOASID_UNBIND, > > IOASID_NOTIFY_SET); > > + ioasid_attach_spid(pasid, > > INVALID_IOASID); > So this answers my previous question ;-) but won't it enter the if > (!ioasid_data) path and fail to reset the spid? > Sorry, i am not following. If there is no ioasid_data then there is no SPID to be stored. BTW, I plan to separate the APIs into two. ioasid_attach_spid ioasid_detach_spid Only ioasid_detach_spid will be calling synchronize RCU, then ioasid_attach_spid can be called under spinlock. Thanks, > Eric > > kfree(svm); > > } > > } > > > > _______________________________________________ > iommu mailing list > iommu@lists.linux-foundation.org > https://lists.linuxfoundation.org/mailman/listinfo/iommu [Jacob Pan]