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

Re: [PATCH] iommu/vtd: fix address translation for superpages


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Wed, 10 May 2023 10:27:12 +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=Q/Hp7+SOjMITpVc8Q+NNKeJqENwNVZysazit8HgCusU=; b=CWLTxMA+9h9tfobPRq7TCroVOh8V1k3w8HITimZl1lLw7+F9R9vAL+YAPNXLv2qWmgFbLs6MGU9T6kzWjvuJSRxUpZspWOw1oTi40GzvhlqKJqTTOuhVf3M4pUii+lX93P7N7USwhf4dbhFqy84jsI7epaMp6mXAtImiW2MzB0K1BRl5t0u8hzcVhshElQRC/Sj/aOFEe5Q/8ReAoTFWbvUS2O35JC4fovyK+38Z8P0xK6w1BiZa8m8Iwj+6g28arIlexdQEyJBd5rbuCkqqK1rHHtPXHZLArs5WPEaU2QQx9gWdQWp+jQiCoLM39MxHho5jf0q/f3wLO2d/wuqTGA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MveKHGzMySexfteJRyWnsUa161pRPSg+CbSoAoEUHZQVLTJoToqisJeH2sDTWK7z7ciOu8VHSs9iL7JEoKeT2CsmkgBn2f5bqJO0AdJrJFlJpnTltXcPlvEFripe+/VPHYCnC9Cfr5fBY79rYCSQsoaPO3rM4WKFP2Ih5Bf/M5BRukv/KobgSWaZbkcQwlUHBR2vmRNwPmYiHTCMXu6cAOQmzLvEJFM2rx3ahGygA38kor0hm8V2J5JQWHeNo6eQuPF0BcQbKiQ+oamakKwWS+hdY7qKTwoQGPY+6aU4YisBaDsLjogGAk3ee56dQOgcPT2rIH408wyAKV3Kej95Fg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Kevin Tian <kevin.tian@xxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Wed, 10 May 2023 08:27:51 +0000
  • Ironport-data: A9a23:wHpRN6N8UWIAGOHvrR2OlsFynXyQoLVcMsEvi/4bfWQNrUpzhjdWy WUeDW+BOvncMTH3Ktl0bNu/9RsPvMLdz9M3QQto+SlhQUwRpJueD7x1DKtS0wC6dZSfER09v 63yTvGacajYm1eF/k/F3oDJ9CU6jufQAOKnUoYoAwgpLSd8UiAtlBl/rOAwh49skLCRDhiE/ Nj/uKUzAnf8s9JPGj9SuvPrRC9H5qyo42tF5wRmPJingXeF/5UrJMNHTU2OByOQrrl8RoaSW +vFxbelyWLVlz9F5gSNy+uTnuUiG9Y+DCDW4pZkc/HKbitq/0Te5p0TJvsEAXq7vh3S9zxHJ HehgrTrIeshFvWkdO3wyHC0GQkmVUFN0OevzXRSLaV/ZqAJGpfh66wGMa04AWEX0qVIOWwe6 9dbESIAYh6umejo/riXasA506zPLOGzVG8ekldJ6GmFSNMZG9XESaiM4sJE1jAtgMwIBezZe 8cSdTtoalLHfgFLPVAUTpk5mY9EhFGmK2Ee9A3T+vFxujeJpOBy+OGF3N79YNuFSN8Thk+Fj mnH4374ElcRM9n3JT+tqyrz3LKTzX+kMG4UPLaI5vdgu3KW/XwwWTM7SGSVu/q2q0HrDrqzL GRRoELCt5Ma9kamU938VB2Qu2Ofs1gXXN84O+439gCLjLbV6gCxB24YQzoHY9sj3OcmSDpv2 lKXktfBAT10rKbTWX+b7q2Trz65JW4SN2BqWMMfZQ4M4t2mpZ5piBvKFopnCPTs0YezHizsy TeXqiR4n68Ukc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NKbxIFXFbWEnf0haCsnPUvdZfinhlH8XCWyOJv2AbiXB+n1LMSr1MgLkuTbfI=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Tue, May 09, 2023 at 06:06:45PM +0200, Jan Beulich wrote:
> On 09.05.2023 12:41, Roger Pau Monne wrote:
> > When translating an address that falls inside of a superpage in the
> > IOMMU page tables the fetching of the PTE physical address field
> > wasn't using dma_pte_addr(), which caused the returned data to be
> > corrupt as it would contain bits not related to the address field.
> 
> I'm afraid I don't understand:
> 
> > --- a/xen/drivers/passthrough/vtd/iommu.c
> > +++ b/xen/drivers/passthrough/vtd/iommu.c
> > @@ -359,16 +359,18 @@ static uint64_t addr_to_dma_page_maddr(struct domain 
> > *domain, daddr_t addr,
> >  
> >              if ( !alloc )
> >              {
> > -                pte_maddr = 0;
> >                  if ( !dma_pte_present(*pte) )
> > +                {
> > +                    pte_maddr = 0;
> >                      break;
> > +                }
> >  
> >                  /*
> >                   * When the leaf entry was requested, pass back the full 
> > PTE,
> >                   * with the address adjusted to account for the residual of
> >                   * the walk.
> >                   */
> > -                pte_maddr = pte->val +
> > +                pte_maddr +=
> >                      (addr & ((1UL << level_to_offset_bits(level)) - 1) &
> >                       PAGE_MASK);
> 
> With this change you're now violating what the comment says (plus what
> the comment ahead of the function says). And it says what it says for
> a reason - see intel_iommu_lookup_page(), which I think your change is
> breaking.

Hm, but the code in intel_iommu_lookup_page() is now wrong as it takes
the bits in DMA_PTE_CONTIG_MASK as part of the physical address when
doing the conversion to mfn?  maddr_to_mfn() doesn't perform a any
masking to remove the bits above PADDR_BITS.

Thanks, Roger.



 


Rackspace

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