[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [PATCH] VT-d: fix caching mode IOTLB flushing


  • To: Jan Beulich <jbeulich@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: "Tian, Kevin" <kevin.tian@xxxxxxxxx>
  • Date: Fri, 27 Aug 2021 03:43:34 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RWI/QdwE5y2BWGEZA+m3vE+TpcRJXyO2GWgwPbk9AjE=; b=JqgI65Z4zvaBAJDt1uroIioqMH9X3u64Fwd1ZnXSEKbpgyETKryuwlJR+pajOQs9Tw5m6Z+JY6OoM6V0axs9841Ctuz7y9DetFPJIg708x2Q+YfCV+GPBoqRDOa9m8eeUul4Jgvdjjx+/QFen1sMHpPrERbIUzqb3Im24u6HMWWWEirivFMc8DG1AHrBOonjnzwpel0VQjC8M3nJ7B/eaao7r1RHlxtweAX60Y8+D3b9AQuzhK5waAYsxr+hzy4ViCnVVADPTA5uSow0PI8g9HDVnVczdhMl/cUlgkmWnBz7QJORAr5e42g7aPmsNzCAYJa3V9KkgL2Ig7gIwOGXWw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mtSjf9HYm/czsHQdGjly55DMiBDS/Mub3k4ma1UC8G4JxOhz4of2/VhD1ZcybBgakCJHoxew8OE9S7j7x6TYtFoM5iPdXnZ/b4Gh9fqJddLLL/xpr52Wz4YYCHJmFRCg10zbWz7U49DHObzgC4H2tMP519jDH6VWcKEuWGtQYaScX9vpzlJHSlrurquqBb8yuhQ/LbC1ouyLk3jFjcOXHlrJqhMQHf/4tjahWVVxdFAQZit3xT0cJHvGfkj/JEzHtjz/oX8vV/+Fi/NYpU/iWvTZ2ka0ikG/dwXOdFlnSVAvPIb8aToLNhkQm0S4l2A1Qs4K/DUzD1orMzbLUNf/Vw==
  • Authentication-results: suse.com; dkim=none (message not signed) header.d=none;suse.com; dmarc=none action=none header.from=intel.com;
  • Cc: Paul Durrant <paul@xxxxxxx>
  • Delivery-date: Fri, 27 Aug 2021 03:43:59 +0000
  • Dlp-product: dlpe-windows
  • Dlp-reaction: no-action
  • Dlp-version: 11.5.1.3
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHXlNEMfoGT1txCikWyu5KsojfNr6uGwaQA
  • Thread-topic: [PATCH] VT-d: fix caching mode IOTLB flushing

> From: Jan Beulich <jbeulich@xxxxxxxx>
> 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@xxxxxxxx>

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

> ---
> 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))


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.