All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jacob Pan <jacob.jun.pan@linux.intel.com>
To: Baolu Lu <baolu.lu@linux.intel.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	iommu@lists.linux.dev, Joerg Roedel <joro@8bytes.org>,
	David Woodhouse <dwmw2@infradead.org>,
	Raj Ashok <ashok.raj@intel.com>,
	"Tian, Kevin" <kevin.tian@intel.com>, Yi Liu <yi.l.liu@intel.com>,
	stable@vger.kernel.org, Sukumar Ghorai <sukumar.ghorai@intel.com>,
	jacob.jun.pan@linux.intel.com
Subject: Re: [PATCH] iommu/vt-d: Fix PASID directory pointer coherency
Date: Tue, 7 Feb 2023 10:08:35 -0800	[thread overview]
Message-ID: <20230207100835.2dd3cb3b@jacob-builder> (raw)
In-Reply-To: <4a22577b-2bbc-d731-95e1-aee95d4a8c8e@linux.intel.com>

Hi Baolu,

On Tue, 7 Feb 2023 15:10:48 +0800, Baolu Lu <baolu.lu@linux.intel.com>
wrote:

> On 2023/2/7 1:25, Jacob Pan wrote:
> >>> ---
> >>>    drivers/iommu/intel/iommu.c | 6 ++++++
> >>>    1 file changed, 6 insertions(+)
> >>>
> >>> diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
> >>> index 59df7e42fd53..b4878c7ac008 100644
> >>> --- a/drivers/iommu/intel/iommu.c
> >>> +++ b/drivers/iommu/intel/iommu.c
> >>> @@ -1976,6 +1976,12 @@ static int domain_context_mapping_one(struct
> >>> dmar_domain *domain, pds = context_get_sm_pds(table);
> >>>    		context->lo = (u64)virt_to_phys(table->table) |
> >>>    				context_pdts(pds);
> >>> +		/*
> >>> +		 * Scalable-mode PASID directory pointer is not
> >>> snooped if the
> >>> +		 * coherent bit is not set.
> >>> +		 */
> >>> +		if (!ecap_coherent(iommu->ecap))
> >>> +			clflush_cache_range(table->table, sizeof(void
> >>> *));  
> >> This isn't comprehensive. The clflush should be called whenever the
> >> pasid directory table is allocated or updated.
> >>  
> > allocate a pasid table does not mean it gets used by iommu hw, not
> > until it is programmed into context entry.  
> 
> Hi Jacob,
> 
> This page is used by the device, and the device's access to this memory
> is not coherent. So after the page is allocated, any changes made by the
> CPU to this page must be written back to the real memory.
> 
> This patch only flushes the first 8 bytes of the table. That's not
> enough.
> 
make sense, thanks for the explanation.
> Be aware that page allocation also requires a clflush, because at least
> __GFP_ ZERO implies modification to page.
> 
Yes, zeroing dir page does change it but I think if we intercept every
update to the directory entry, it should be sufficient?

will send an updated version.


Thanks,

Jacob

      reply	other threads:[~2023-02-07 18:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-03 22:07 [PATCH] iommu/vt-d: Fix PASID directory pointer coherency Jacob Pan
2023-02-04  3:43 ` Baolu Lu
2023-02-06 17:25   ` Jacob Pan
2023-02-07  0:41     ` Tian, Kevin
2023-02-07 18:09       ` Jacob Pan
2023-02-07  7:10     ` Baolu Lu
2023-02-07 18:08       ` Jacob Pan [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230207100835.2dd3cb3b@jacob-builder \
    --to=jacob.jun.pan@linux.intel.com \
    --cc=ashok.raj@intel.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=dwmw2@infradead.org \
    --cc=iommu@lists.linux.dev \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=sukumar.ghorai@intel.com \
    --cc=yi.l.liu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.