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

Re: [PATCH] iommu/amd-vi: fix checking for Invalidate All support in amd_iommu_resume()


  • To: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 13 Jun 2023 12:23:37 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=NxHuK9m1PXy+DzrZ6E/Pc2dbZl7g3QYj5vzJVPcFc6A=; b=aLYYFxAAWmEUCDPVljr1QKfHYfwwpdp88Inypr3KSTcnhnfBSdyzpSG+THBuDtTzk4Jy3p4mLCIZsoEWQK3QJu0FsCatPFnYZS5A0vhivT4tn5mVxmKHQdzHnleI812QLBzljMk9FwnrDQ7tAT8OItpXXWv03s4T+SbptE7Csn61we6aCN2aslEJLsz3jdXEXw/clvya8Urkc330bXT4186Oly/b+mj0MWORupsKx+bDi2R00OjxtBsYXLyDtPD97t+P3KgcVH4SRmQTiw6C2qPJnKN1LD7yKfoSSPA5uJt/4r8Ir25oNs77/Ejyc1yfRbTDkfjcIiV6IwoG6v/8MA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=azlsT+wX3oW3O2kvM0bcV5HeZeq3nfwgjDExtsM2hMAbVpEA60h9E+g4OzA6EdItzOXOnvMOd8zgS9i9VeyTp9cONV22JHJC1UEs+HSRYNfEd41NXRtd4md3G+yOszYFg4CBbO0Z886daw/Q1ftsHHa6foWEpI1F/13BWLL9BPM1htx11Qv9OYgnaZc74H5mK1ffZ5cKay1j9CCQJLzoUnizOquInuwZ02rL8xKq0wuMFSweQ7dzdhDrR6qrAn1zOBjkecbEMOtMXxHmBlmLH0C9TP1S/OpiY+Uy2yBCYMFHVredqWg2jwfkIK4m0xnP5IB8UlyNM0jCxmu9IAPhbQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Tue, 13 Jun 2023 10:23:54 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 13.06.2023 12:13, Roger Pau Monne wrote:
> Do not rely on iommu local variable pointing to a valid amd_iommu

"Do not rely" sounds like we might, but we choose not to. But we may
not rely on this, as the pointer simply isn't valid to deref past
the loop. Hence perhaps better "We cannot rely ..." or even "The
iommu local variable does not point to ..."?

> element after the call to for_each_amd_iommu().  Instead check whether
> any IOMMU on the system doesn't support Invalidate All in order to
> perform the per-domain and per-device flushes.
> 
> Fixes: 9c46139de889 ('amd iommu: Support INVALIDATE_IOMMU_ALL command.')
> Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> ---
> I don't have a way to test host suspend/resume, so the patch is only
> build tested.
> ---
>  xen/drivers/passthrough/amd/iommu_init.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/xen/drivers/passthrough/amd/iommu_init.c 
> b/xen/drivers/passthrough/amd/iommu_init.c
> index 9773ccfcb41f..4facff93d68b 100644
> --- a/xen/drivers/passthrough/amd/iommu_init.c
> +++ b/xen/drivers/passthrough/amd/iommu_init.c
> @@ -1580,6 +1580,7 @@ void cf_check amd_iommu_crash_shutdown(void)
>  void cf_check amd_iommu_resume(void)
>  {
>      struct amd_iommu *iommu;
> +    bool invalidate_all = true;
>  
>      for_each_amd_iommu ( iommu )
>      {
> @@ -1589,10 +1590,12 @@ void cf_check amd_iommu_resume(void)
>          */
>          disable_iommu(iommu);
>          enable_iommu(iommu);
> +        if ( !iommu->features.flds.ia_sup && invalidate_all )

You don't really need the right hand part of the condition, do you?

Preferably with the adjustments (which I'd be happy to do while
committing, as long as you agree)
Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>

Jan

> +            invalidate_all = false;
>      }
>  
>      /* flush all cache entries after iommu re-enabled */
> -    if ( !iommu->features.flds.ia_sup )
> +    if ( !invalidate_all )
>      {
>          invalidate_all_devices();
>          invalidate_all_domain_pages();




 


Rackspace

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