[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: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Tue, 13 Jun 2023 12:33:08 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.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=Xcr/+OpieiydOSz09MoTu/6UtJ5G0GtWOcbANOB2+JU=; b=C2G7it6Lkw1E1W0AvVEve11N5pI7iMoljEIB+xaBzT2+L8u8WkdZodUT+zjbtNiscWIAhFMIo8Fv1a7Nla4N+qHPPJ4UFMb0TNsXJgkc8pC7EBFnXdoOwS4a7Pei6eIUTkmIpn8D4VmHOrtoDptFnV6vsmXBF/+MMs0xcKpwmwJypwuQPWcALCdvUVao3ZQ7lneEVyyUBi3NxtovVDT+NPZO80F6hYC3VkFGjZcyPhNhctr1f9BrvZsKbYEhyE7kzgAzjIUnUavLr192R5E4SXd0vnl13/DDY8JHD6g37tD4TxzbbNO75mfxCzECKm6oQvqXAsTsuOjnwGBvJVfI4w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K330O3M9cvvR7UAVA7IypVJIDxuGBQeJNinMw2HrOtm5jX3xbWiwc5UjfuITO66bxcY66fE3cSCxYtSDM3402VYPtJsdeRytVPyOAC59tsvs2iRwLQL246tcev7DAVfywKQ0AQ+3MQJgCgbmrM4KbSNsk8pKLsLQuNjdwtbMHXJ1OyeAgNVea+QSOrNRgu4NAbznfpK8ok+1eHSLJP3/OTI2URht69LF6+v1xdMwvUHS5SCYvUQvkQ1qI9uYdJHrPkCIHiesUt346EBKdC0IH3ZYhawPOlhB/ROkd7j06Tolw0EgQxRHERr5bd53YhuIhQPFJZ8DajPST2QQw8HC0Q==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Tue, 13 Jun 2023 10:39:32 +0000
  • Ironport-data: A9a23:OBU4bquLAzbIg7bL2N8mp/i5pefnVEtfMUV32f8akzHdYApBsoF/q tZmKWzTbP2NNjb2etFxat+/9k4FsMWHzd41TlZuryAxFSwQ+JbJXdiXEBz9bniYRiHhoOCLz O1FM4Wdc5pkJpP4jk3wWlQ0hSAkjclkfpKlVKiffHg3HVQ+IMsYoUoLs/YjhYJ1isSODQqIu Nfjy+XSI1bg0DNvWo4uw/vrRChH4rKq4Fv0gnRkPaoQ5AGHzCFMZH4iDfrZw0XQE9E88tGSH 44v/JnhlkvF8hEkDM+Sk7qTWiXmlZaLYGBiIlIPM0STqkAqSh4ai87XB9JFAatjsB2bnsgZ9 Tl4ncfYpTHFnEH7sL91vxFwS0mSNEDdkVPNCSDXXce7lyUqf5ZwqhnH4Y5f0YAwo45K7W9yG fMwMjdWKSqvps6M3LeCRtt03cUNPs3sM9ZK0p1g5Wmx4fcOZ7nmGvyPzvgBmTA6i4ZJAOrUY NcfZXx3dhPcbhZTO1ARTpUjgOOvgXq5eDpdwL6XjfNvvy6Pk0osjv60b4C9lt+iHK25mm6Co W3L5SLhCwwyP92D0zuVtHmrg4cjmAuiAdhMTODjqKQCbFu7y2MRDCMRD0OC//y2gUmHR/xxc kcs0397xUQ13AnxJjXnZDW6qnOZuh8XW/JLDvY3rgqKz8L88wufQ2QJUDNFQNgnr9MtAywn0 EeTmNHkDiApt6eaIU9x7Z+RpDK2fCMSdGkLYHZdSRNfuoa55oYukhjIU9BvVravicH4Ei3xx DbMqzUig7IUjogA0KDTEU37vg9Ab6PhFmYdjjg7lEr7tmuVuKbNi1SU1GXm
  • Ironport-hdrordr: A9a23:Jtvk5apb24h+BSTLY68hnoEaV5oReYIsimQD101hICG9Ffb1qy nOppsmPHrP4wr5N0tPpTntAsi9qBHnhP1ICPgqXYtKNTOO0AHEEGgI1/qB/9SPIVyYysdtkY tmbqhiGJnRIDFB/KDHCdCDYrMdKQ+8gcSVuds=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Tue, Jun 13, 2023 at 12:23:37PM +0200, Jan Beulich wrote:
> 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 ..."?

"Xen cannot rely ..." doesn't modify the sentence too much and could
likely be adjusted at commit if you agree?

Otherwise your last suggestion would also be OK by me.

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

Wanted to avoid repeatedly setting `invalidate_all = false` if all the
IOMMUs on the system don't support Invalidate All.

I don't have a strong opinion, my first (local) version didn't have
the right hand side of the condition, but then I realized that setting
this for every IOMMU on the system could be wasteful.

Thanks, Roger.



 


Rackspace

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