All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Tian, Kevin" <kevin.tian@intel.com>
To: Jan Beulich <jbeulich@suse.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: Paul Durrant <paul@xen.org>
Subject: RE: [PATCH] VT-d: fix caching mode IOTLB flushing
Date: Fri, 27 Aug 2021 03:43:34 +0000	[thread overview]
Message-ID: <BN9PR11MB54338B5C615A48CE313703578CC89@BN9PR11MB5433.namprd11.prod.outlook.com> (raw)
In-Reply-To: <8b873e30-c1d1-3174-9e67-506887deedcc@suse.com>

> From: Jan Beulich <jbeulich@suse.com>
> Sent: Thursday, August 19, 2021 4:06 PM
> 
> While for context cache entry flushing use of did 0 is indeed correct
> (after all upon reading the context entry the IOMMU wouldn't know any
> domain ID if the entry is not present, and hence a surrogate one needs
> to be used), for IOTLB entries the normal domain ID (from the [present]
> context entry) gets used. See sub-section "IOTLB" of section "Address
> Translation Caches" in the VT-d spec.
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Kevin Tian <kevin.tian@intel.com>

> ---
> Luckily this is supposed to be an issue only when running on emulated
> IOMMUs; hardware implementations are expected to have CAP.CM=0.
> 
> --- a/xen/drivers/passthrough/vtd/iommu.c
> +++ b/xen/drivers/passthrough/vtd/iommu.c
> @@ -474,17 +474,10 @@ int vtd_flush_iotlb_reg(struct vtd_iommu
> 
>      /*
>       * In the non-present entry flush case, if hardware doesn't cache
> -     * non-present entry we do nothing and if hardware cache non-present
> -     * entry, we flush entries of domain 0 (the domain id is used to cache
> -     * any non-present entries)
> +     * non-present entries we do nothing.
>       */
> -    if ( flush_non_present_entry )
> -    {
> -        if ( !cap_caching_mode(iommu->cap) )
> -            return 1;
> -        else
> -            did = 0;
> -    }
> +    if ( flush_non_present_entry && !cap_caching_mode(iommu->cap) )
> +        return 1;
> 
>      /* use register invalidation */
>      switch ( type )
> --- a/xen/drivers/passthrough/vtd/qinval.c
> +++ b/xen/drivers/passthrough/vtd/qinval.c
> @@ -362,17 +362,10 @@ static int __must_check flush_iotlb_qi(s
> 
>      /*
>       * In the non-present entry flush case, if hardware doesn't cache
> -     * non-present entry we do nothing and if hardware cache non-present
> -     * entry, we flush entries of domain 0 (the domain id is used to cache
> -     * any non-present entries)
> +     * non-present entries we do nothing.
>       */
> -    if ( flush_non_present_entry )
> -    {
> -        if ( !cap_caching_mode(iommu->cap) )
> -            return 1;
> -        else
> -            did = 0;
> -    }
> +    if ( flush_non_present_entry && !cap_caching_mode(iommu->cap) )
> +        return 1;
> 
>      /* use queued invalidation */
>      if (cap_write_drain(iommu->cap))


      parent reply	other threads:[~2021-08-27  3:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-19  8:05 [PATCH] VT-d: fix caching mode IOTLB flushing Jan Beulich
2021-08-19 18:52 ` Paul Durrant
2021-08-27  3:43 ` Tian, Kevin [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=BN9PR11MB54338B5C615A48CE313703578CC89@BN9PR11MB5433.namprd11.prod.outlook.com \
    --to=kevin.tian@intel.com \
    --cc=jbeulich@suse.com \
    --cc=paul@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /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.