Message ID | 20230615071613.690639-1-yanfei.xu@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp459998vqr; Thu, 15 Jun 2023 00:51:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ75f22v/o864tm/KnXxP+B7U8An3iIhglmb5zt7n5+3G+cdPtac9g7bAr4+ViSWAENq1+CN X-Received: by 2002:a17:906:c151:b0:933:4d37:82b2 with SMTP id dp17-20020a170906c15100b009334d3782b2mr20133554ejc.57.1686815479255; Thu, 15 Jun 2023 00:51:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686815479; cv=none; d=google.com; s=arc-20160816; b=ctJEi/hJDW4X91jAN8k9+cKdk/kOtb/KuifZcBpEyPTqwAFISsRka9nDVAoegww8H5 FNWqVgxK+Hb8IiuI7ByZfMgcKKaoL7lDV6Zh7qkHXhZgO9PplIfDmUI6uWXFn/qntjcv CWnT0kmEl/1KlnwHbhhHzyiNpZFYHnwTAGcmCI2F1Zewtp2AHC4C3wzd4FPxn7zwZpCt PI+lzCDJEypsma8lxLohffR9CO/xFb5xPTUEKWBgbnVFoJDSKgBHp2P100DFxN0c4vF1 vwyJ8J85912srvUO7OsdD8qxNXDU67V6/uVjQVTYPDaEqdmzQ0q08VslQ4CDrNKJKDhK pfSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=pI9Kebwri7Wjwt5dIv+EfvKXtO/M52yhl/ynLaKFTh4=; b=pcCbCp4RpGDbpAoY79rDVqGbuP8DGf5mc10DFd+qK5S4oyt0FY+11gP/LZxj12yl1A KUAYBTj4ePcHtUuQQSdsDJUNVR1LdsBikn1ym+bIXKoE/MLpwkNv8hCb9+C1XU3nwgpj mTt2EC4Q8E/hMiwW2UdL1Wolr4CTRkFIytnpvA5jR2+IqlvGFonbBbaR6rX7AAp7fsab F9s3i3fmRFfMGmKPV9Vu/P4I0XAhHaQjN8oDOy1Ic7lZH5k3woIhNNFjjv6dTynffD68 Qvtfroj1E46jSgjHxO//+u+O+Q4Q2LyXbKN1k/Rkutc7EC1784B4AA5vAd91TUR7GX13 ikZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZjE8i8W5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j18-20020a170906051200b0097459846857si419563eja.296.2023.06.15.00.50.55; Thu, 15 Jun 2023 00:51:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZjE8i8W5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244147AbjFOHVI (ORCPT <rfc822;n2h9z4@gmail.com> + 99 others); Thu, 15 Jun 2023 03:21:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238246AbjFOHU3 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 15 Jun 2023 03:20:29 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 606D8270A for <linux-kernel@vger.kernel.org>; Thu, 15 Jun 2023 00:18:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686813532; x=1718349532; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=tv0xInhDNZvIGN29/qg5JZUQvfOAzDkVJk+y8zR9+Z0=; b=ZjE8i8W5fRSYFplo7odk277vLPw/NRW+H+Cg0bltmmU6YvIoa+B2nV6z HodB+9+nZRCpCSFkwTo7SyybDL1vvpbxXeD7ZDSRw88S5vJPJPGP5luyN Rbp8jjA/5EjQPHW0vCxkPd7E7PruPItMMao9OitTst5rjrSYbkNDK/7yp Xu6MQaczsHrg8YmR9MTmffUKsgLsWb4v1imMtyt5+r+Bb2YmkTOucMtGs guDVeococ+8h7VMb2jNsN5NmJ+XYZfbHpO1HwWJItf5XlO0grmoPALOGq Wl1EeJGAL0LFlHim7BxDEtybz+Ml4zTIQ4VonP4x7Yf2DkX6S7QG3mdmY w==; X-IronPort-AV: E=McAfee;i="6600,9927,10741"; a="339183070" X-IronPort-AV: E=Sophos;i="6.00,244,1681196400"; d="scan'208";a="339183070" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2023 00:18:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10741"; a="706544678" X-IronPort-AV: E=Sophos;i="6.00,244,1681196400"; d="scan'208";a="706544678" Received: from tower.bj.intel.com ([10.238.157.62]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2023 00:18:49 -0700 From: Yanfei Xu <yanfei.xu@intel.com> To: dwmw2@infradead.org, baolu.lu@linux.intel.com, joro@8bytes.org, will@kernel.org, robin.murphy@arm.com Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org, yanfei.xu@intel.com Subject: [PATCH] iommu/vt-d: Fix to flush cache of PASID directory table Date: Thu, 15 Jun 2023 15:16:13 +0800 Message-Id: <20230615071613.690639-1-yanfei.xu@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768754227771261515?= X-GMAIL-MSGID: =?utf-8?q?1768754227771261515?= |
Series |
iommu/vt-d: Fix to flush cache of PASID directory table
|
|
Commit Message
Yanfei Xu
June 15, 2023, 7:16 a.m. UTC
Even the PCI devices don't support pasid capability, PASID
table is mandatory for a PCI device in scalable mode. However
flushing cache of pasid directory table for these devices are
not taken after pasid table is allocated as the "size" of
table is zero. Fix to assign it with a page size.
Fixes: 194b3348bdbb ("iommu/vt-d: Fix PASID directory pointer coherency")
Signed-off-by: Yanfei Xu <yanfei.xu@intel.com>
---
drivers/iommu/intel/pasid.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
Comments
Hi, > -----Original Message----- > From: Yanfei Xu <yanfei.xu@intel.com> > Sent: Thursday, June 15, 2023 3:16 PM > To: dwmw2@infradead.org; baolu.lu@linux.intel.com; joro@8bytes.org; > will@kernel.org; robin.murphy@arm.com > Cc: iommu@lists.linux.dev; linux-kernel@vger.kernel.org; Xu, Yanfei > <yanfei.xu@intel.com> > Subject: [PATCH] iommu/vt-d: Fix to flush cache of PASID directory table > > Even the PCI devices don't support pasid capability, PASID table is mandatory > for a PCI device in scalable mode. However flushing cache of pasid directory > table for these devices are not taken after pasid table is allocated as the "size" > of table is zero. Fix to assign it with a page size. > > Fixes: 194b3348bdbb ("iommu/vt-d: Fix PASID directory pointer coherency") > Signed-off-by: Yanfei Xu <yanfei.xu@intel.com> > --- > drivers/iommu/intel/pasid.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c index > c5d479770e12..bde7df055865 100644 > --- a/drivers/iommu/intel/pasid.c > +++ b/drivers/iommu/intel/pasid.c > @@ -115,7 +115,9 @@ int intel_pasid_alloc_table(struct device *dev) > intel_pasid_max_id); > > size = max_pasid >> (PASID_PDE_SHIFT - 3); > - order = size ? get_order(size) : 0; > + if (!size) > + size = PAGE_SIZE; How about merging the logic of the above few lines into this one: size = info->pasid_supported ? max_pasid >> (PASID_PDE_SHIFT - 3) : PAGE_SIZE; Though the logic is about the same, the suggested one seems more intuitive. Regards, -Tina > + order = get_order(size); > pages = alloc_pages_node(info->iommu->node, > GFP_KERNEL | __GFP_ZERO, order); > if (!pages) { > -- > 2.34.1 >
On 6/16/2023 7:43 AM, Zhang, Tina wrote: > Hi, > >> -----Original Message----- >> From: Yanfei Xu <yanfei.xu@intel.com> >> Sent: Thursday, June 15, 2023 3:16 PM >> To: dwmw2@infradead.org; baolu.lu@linux.intel.com; joro@8bytes.org; >> will@kernel.org; robin.murphy@arm.com >> Cc: iommu@lists.linux.dev; linux-kernel@vger.kernel.org; Xu, Yanfei >> <yanfei.xu@intel.com> >> Subject: [PATCH] iommu/vt-d: Fix to flush cache of PASID directory table >> >> Even the PCI devices don't support pasid capability, PASID table is mandatory >> for a PCI device in scalable mode. However flushing cache of pasid directory >> table for these devices are not taken after pasid table is allocated as the "size" >> of table is zero. Fix to assign it with a page size. >> >> Fixes: 194b3348bdbb ("iommu/vt-d: Fix PASID directory pointer coherency") >> Signed-off-by: Yanfei Xu <yanfei.xu@intel.com> >> --- >> drivers/iommu/intel/pasid.c | 4 +++- >> 1 file changed, 3 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c index >> c5d479770e12..bde7df055865 100644 >> --- a/drivers/iommu/intel/pasid.c >> +++ b/drivers/iommu/intel/pasid.c >> @@ -115,7 +115,9 @@ int intel_pasid_alloc_table(struct device *dev) >> intel_pasid_max_id); >> >> size = max_pasid >> (PASID_PDE_SHIFT - 3); >> - order = size ? get_order(size) : 0; >> + if (!size) >> + size = PAGE_SIZE; > How about merging the logic of the above few lines into this one: > size = info->pasid_supported ? max_pasid >> (PASID_PDE_SHIFT - 3) : PAGE_SIZE; Yes, it would be more intuitive. But the prerequisite is if we can make sure that the value of max_pasid shifted is still greater than 0. I roughly went through the PCIE spec and didn't find out where defines the smallest PASID value for the PCIE device. Thanks, Yanfei > Though the logic is about the same, the suggested one seems more intuitive. > > Regards, > -Tina > >> + order = get_order(size); >> pages = alloc_pages_node(info->iommu->node, >> GFP_KERNEL | __GFP_ZERO, order); >> if (!pages) { >> -- >> 2.34.1 >>
On 6/15/23 3:16 PM, Yanfei Xu wrote: > Even the PCI devices don't support pasid capability, PASID > table is mandatory for a PCI device in scalable mode. However > flushing cache of pasid directory table for these devices are > not taken after pasid table is allocated as the "size" of > table is zero. Fix to assign it with a page size. Documentation/process/submitting-patches.rst Please add more information about - Describe your problem. - Any background of the problem? - How your change fixes the problem. ... > > Fixes: 194b3348bdbb ("iommu/vt-d: Fix PASID directory pointer coherency") Do you need a Cc stable? > Signed-off-by: Yanfei Xu <yanfei.xu@intel.com> > --- > drivers/iommu/intel/pasid.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c > index c5d479770e12..bde7df055865 100644 > --- a/drivers/iommu/intel/pasid.c > +++ b/drivers/iommu/intel/pasid.c > @@ -115,7 +115,9 @@ int intel_pasid_alloc_table(struct device *dev) > intel_pasid_max_id); > > size = max_pasid >> (PASID_PDE_SHIFT - 3); > - order = size ? get_order(size) : 0; > + if (!size) > + size = PAGE_SIZE; > + order = get_order(size); > pages = alloc_pages_node(info->iommu->node, > GFP_KERNEL | __GFP_ZERO, order); > if (!pages) { Is it similar to diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c index c5d479770e12..49fc5a038a14 100644 --- a/drivers/iommu/intel/pasid.c +++ b/drivers/iommu/intel/pasid.c @@ -129,7 +129,7 @@ int intel_pasid_alloc_table(struct device *dev) info->pasid_table = pasid_table; if (!ecap_coherent(info->iommu->ecap)) - clflush_cache_range(pasid_table->table, size); + clflush_cache_range(pasid_table->table, (1 << order) * PAGE_SIZE); return 0; } ? Best regards, baolu
On 6/16/2023 10:01 AM, Baolu Lu wrote: > On 6/15/23 3:16 PM, Yanfei Xu wrote: >> Even the PCI devices don't support pasid capability, PASID >> table is mandatory for a PCI device in scalable mode. However >> flushing cache of pasid directory table for these devices are >> not taken after pasid table is allocated as the "size" of >> table is zero. Fix to assign it with a page size. > > Documentation/process/submitting-patches.rst > > Please add more information about > > - Describe your problem. > - Any background of the problem? > - How your change fixes the problem. > ... > Got it! Will improve these in commit message. Just noticed this when reading the iommu code, no actual problem encountered. >> >> Fixes: 194b3348bdbb ("iommu/vt-d: Fix PASID directory pointer >> coherency") > > Do you need a Cc stable? Yes, will add Cc: <stable@vger.kernel.org> > >> Signed-off-by: Yanfei Xu <yanfei.xu@intel.com> >> --- >> drivers/iommu/intel/pasid.c | 4 +++- >> 1 file changed, 3 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c >> index c5d479770e12..bde7df055865 100644 >> --- a/drivers/iommu/intel/pasid.c >> +++ b/drivers/iommu/intel/pasid.c >> @@ -115,7 +115,9 @@ int intel_pasid_alloc_table(struct device *dev) >> intel_pasid_max_id); >> size = max_pasid >> (PASID_PDE_SHIFT - 3); >> - order = size ? get_order(size) : 0; >> + if (!size) >> + size = PAGE_SIZE; >> + order = get_order(size); >> pages = alloc_pages_node(info->iommu->node, >> GFP_KERNEL | __GFP_ZERO, order); >> if (!pages) { > > Is it similar to A little difference that real size may less than memory size calculated by order. But it is no effect. I think this is simpler. Thanks, Yanfei > > diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c > index c5d479770e12..49fc5a038a14 100644 > --- a/drivers/iommu/intel/pasid.c > +++ b/drivers/iommu/intel/pasid.c > @@ -129,7 +129,7 @@ int intel_pasid_alloc_table(struct device *dev) > info->pasid_table = pasid_table; > > if (!ecap_coherent(info->iommu->ecap)) > - clflush_cache_range(pasid_table->table, size); > + clflush_cache_range(pasid_table->table, (1 << order) * > PAGE_SIZE); > > return 0; > } > > ? > > Best regards, > baolu
On 6/16/23 11:06 AM, Yanfei Xu wrote: >>> >>> Fixes: 194b3348bdbb ("iommu/vt-d: Fix PASID directory pointer >>> coherency") >> >> Do you need a Cc stable? > > Yes, will add Cc: <stable@vger.kernel.org> I was not asking you to Cc stable, just reminded you to consider whether your change fixes any real problem and that problem could also happen with stable kernels. Best regards, baolu
diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c index c5d479770e12..bde7df055865 100644 --- a/drivers/iommu/intel/pasid.c +++ b/drivers/iommu/intel/pasid.c @@ -115,7 +115,9 @@ int intel_pasid_alloc_table(struct device *dev) intel_pasid_max_id); size = max_pasid >> (PASID_PDE_SHIFT - 3); - order = size ? get_order(size) : 0; + if (!size) + size = PAGE_SIZE; + order = get_order(size); pages = alloc_pages_node(info->iommu->node, GFP_KERNEL | __GFP_ZERO, order); if (!pages) {