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

RE: [PATCH v4 06/14] iommu: flush I/O TLB if iommu_map() or iommu_unmap() fail


  • To: Paul Durrant <paul@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: "Tian, Kevin" <kevin.tian@xxxxxxxxx>
  • Date: Fri, 14 Aug 2020 06:53:17 +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=a+ZcEKlkpcOMXAdDc396a0Ya/lxaK1zvCllHDme5R38=; b=oPHkmrI67juO8Z54ys55tsM9kV15c0uYUE9RQ1x4t6cosR/rBHIuDpVnFOTv0hMAwNbxHhqjDyuWh78qHyklSxpEQKTfGpksgPsQs57/m4dEHwJ6Lpqn1pA6Zgwi8KKjuxErdZWSFlWTHVBJzvuxiOCEZqROXt8DvSu14GW+R8+6xGtmpePjPtLzme2cNM2Wr3ko+imaSJ11tnlr2eO0OEfBH5GjrqXwmq9zhUAbq8lEqxkqFzsCHSKbzTtn6GXfkbuW4KDF+CD3cwcM7WdXTctxc5Ve9/I85tI6UB79xg0eCEhaAqAL6Y3koAOViSuJnqF5W2SlAd97qMlz9Px3cg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FBIbrwe3f6NU8wkQ4y1FSXxm8OOPjA2RO50VR3AgmEgsghPULlyHKSu2U+2QXRgUdLmKfCIppPjzcI9AYUzAeHfByeoWtmEpQaBvPsEbHj9skIMAdUgaxtV4K2CoOE0kVCO8HQfmMOO2hL9UQChqzA1sY4tZF+zVyIInF3zAiaDjUp9m6fA7D262Db3cw3JPFwjewuynVA805gpc8D/J6nBhqgfB+K3vGQvGnvVLEcME1y2rRph71v6ri8b968ot5YUVqon6NiAuSxKvInA/M/djkXEq2ZISAJHlvQVk3HktfzsgJfujIKiuY1kcdncI3oJTfL/hiyUmHNlLqnShQA==
  • Authentication-results: xen.org; dkim=none (message not signed) header.d=none;xen.org; dmarc=none action=none header.from=intel.com;
  • Cc: Paul Durrant <pdurrant@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>
  • Delivery-date: Fri, 14 Aug 2020 06:53:45 +0000
  • Dlp-product: dlpe-windows
  • Dlp-reaction: no-action
  • Dlp-version: 11.5.1.3
  • Ironport-sdr: hlvBPD06qQysWA7KuNw2RvOt+BoKWfoHujxIHOjgpcpB2JD9rxywM7kKXJqVYDmDb0icxgzQC0 Ny0aFg/AJvRQ==
  • Ironport-sdr: s58PoHpXjyri0UiTejB8O15k17+vRihYb+QQohiYI/yl7w2QRzoObJTQlkrUHlDeyCEKisdjhx 5pa05DLeXdJQ==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHWamVUYpnePGqDjU6QqOHETpTIJqk3Oeew
  • Thread-topic: [PATCH v4 06/14] iommu: flush I/O TLB if iommu_map() or iommu_unmap() fail

> From: Paul Durrant
> Sent: Tuesday, August 4, 2020 9:42 PM
> 
> From: Paul Durrant <pdurrant@xxxxxxxxxx>
> 
> This patch adds a full I/O TLB flush to the error paths of iommu_map() and
> iommu_unmap().
> 
> Without this change callers need constructs such as:
> 
> rc = iommu_map/unmap(...)
> err = iommu_flush(...)
> if ( !rc )
>   rc = err;
> 
> With this change, it can be simplified to:
> 
> rc = iommu_map/unmap(...)
> if ( !rc )
>   rc = iommu_flush(...)
> 
> because, if the map or unmap fails the flush will be unnecessary. This saves

this statement is different from change in iommu_map...

> a stack variable and generally makes the call sites tidier.
> 
> Signed-off-by: Paul Durrant <pdurrant@xxxxxxxxxx>
> ---
> Cc: Jan Beulich <jbeulich@xxxxxxxx>
> 
> v2:
>  - New in v2
> ---
>  xen/drivers/passthrough/iommu.c | 28 ++++++++++++----------------
>  1 file changed, 12 insertions(+), 16 deletions(-)
> 
> diff --git a/xen/drivers/passthrough/iommu.c
> b/xen/drivers/passthrough/iommu.c
> index 660dc5deb2..e2c0193a09 100644
> --- a/xen/drivers/passthrough/iommu.c
> +++ b/xen/drivers/passthrough/iommu.c
> @@ -274,6 +274,10 @@ int iommu_map(struct domain *d, dfn_t dfn, mfn_t
> mfn,
>          break;
>      }
> 
> +    /* Something went wrong so flush everything and clear flush flags */
> +    if ( unlikely(rc) && iommu_iotlb_flush_all(d, *flush_flags) )
> +        flush_flags = 0;
> +

... earlier you said flush is unnecessary if map fails. But here actually you
still need to flush everything so it's just sort of moving error-path flush
within the map function?

Thanks
Kevin

>      return rc;
>  }
> 
> @@ -283,14 +287,8 @@ int iommu_legacy_map(struct domain *d, dfn_t dfn,
> mfn_t mfn,
>      unsigned int flush_flags = 0;
>      int rc = iommu_map(d, dfn, mfn, page_order, flags, &flush_flags);
> 
> -    if ( !this_cpu(iommu_dont_flush_iotlb) )
> -    {
> -        int err = iommu_iotlb_flush(d, dfn, (1u << page_order),
> -                                    flush_flags);
> -
> -        if ( !rc )
> -            rc = err;
> -    }
> +    if ( !this_cpu(iommu_dont_flush_iotlb) && !rc )
> +        rc = iommu_iotlb_flush(d, dfn, (1u << page_order), flush_flags);
> 
>      return rc;
>  }
> @@ -330,6 +328,10 @@ int iommu_unmap(struct domain *d, dfn_t dfn,
> unsigned int page_order,
>          }
>      }
> 
> +    /* Something went wrong so flush everything and clear flush flags */
> +    if ( unlikely(rc) && iommu_iotlb_flush_all(d, *flush_flags) )
> +        flush_flags = 0;
> +
>      return rc;
>  }
> 
> @@ -338,14 +340,8 @@ int iommu_legacy_unmap(struct domain *d, dfn_t
> dfn, unsigned int page_order)
>      unsigned int flush_flags = 0;
>      int rc = iommu_unmap(d, dfn, page_order, &flush_flags);
> 
> -    if ( !this_cpu(iommu_dont_flush_iotlb) )
> -    {
> -        int err = iommu_iotlb_flush(d, dfn, (1u << page_order),
> -                                    flush_flags);
> -
> -        if ( !rc )
> -            rc = err;
> -    }
> +    if ( !this_cpu(iommu_dont_flush_iotlb) && ! rc )
> +        rc = iommu_iotlb_flush(d, dfn, (1u << page_order), flush_flags);
> 
>      return rc;
>  }
> --
> 2.20.1
> 




 


Rackspace

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