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

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


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Date: Wed, 24 May 2023 17:22: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=30ru+lLePwOyS4uvchiCqk6eSxy4Oc0C9zDO72tKQss=; b=FfjddFRe46QMf5MIKEHJIIyzS25SoM0VvbAGbX2vQPxxfihqF2ndELV5W9mWWeVFCHHwbo9ZtOmDdecX4Jby7dKoHXK9vMZ3ERLIJPX43Wo85Iy3rkAaUf+NApbpunU3AuZUOxckBn0MzxKFuoPRHmJL8gLD8GrWnf1erQpTJQfr7SPxHY3ZDP0EZnQnp5F6h/Wz+oiU7wB1Qb7XfD/XJvZRyhHFe/7HJEn9n2Lon+gvzFdwhEguijnqdbiyxRJZp6kEOfuomM4MTJDjdeJWZ6opawLpjKxfA/SMYFULCwfQPhQ7Wu6crJBQCcwcyGjONNhvwcxuGpiqgjgw01bZYw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KsRf5++0xf5A+sk8HxU+DbQz+3tF3tOe5pjRdABYP1nmAOv0+LtJlsomJpZxdZtaiN577t5kklZXC/fyn4Vz9WN4/J6PaBzSMgFaoXRn7bKAJ+P326/yRU6uwwR0ivmc02pEMpp81DP92+Jwu7+uvjhajwF98aMVYeP4Y/mboPXMr8ae6pZkl1Ax0gOYA3zTIVpanfwGSCrNC431Ea+1oXhSHMu2XavS2XM8fCGhN08frVe9WowwTkJAHUXr6PI8Nd9G/XJJiTK6dsXR20A9iGbi1dI/6NmRQzsEsG4szcXztK4VjEc5ndGMgPR+giWUHZ3Mrhk2ok8mApEk1LWEdg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Roger Pau Monne <roger.pau@xxxxxxxxxx>, Kevin Tian <kevin.tian@xxxxxxxxx>
  • Delivery-date: Wed, 24 May 2023 15:22:36 +0000
  • Ironport-data: A9a23:51bo66KKseUoK6FHFE+RzZQlxSXFcZb7ZxGr2PjKsXjdYENS3zVSx 2AYUWiEb/7eamX8e9p1YY6y80xXuJPVx9cxSgdlqX01Q3x08seUXt7xwmUcnc+xBpaaEB84t ZV2hv3odp1coqr0/0/1WlTZhSAgk/rOHvykU7Ss1hlZHWdMUD0mhQ9oh9k3i4tphcnRKw6Ws Jb5rta31GWNglaYCUpKrfrbwP9TlK6q4mhA4wZiPasjUGL2zBH5MrpOfcldEFOgKmVkNrbSb /rOyri/4lTY838FYj9yuu+mGqGiaue60Tmm0hK6aYD76vRxjnVaPpIAHOgdcS9qZwChxLid/ jnvWauYEm/FNoWU8AgUvoIx/ytWZcWq85efSZSzXFD6I+QrvBIAzt03ZHzaM7H09c50WnlW9 tE1BgwgMEGyn7yumo3qR+dV05FLwMnDZOvzu1lG5BSAV7MDfsqGRK/Ho9hFwD03m8ZCW+7EY NYUYiZuaxKGZABTPlAQC9Q1m+LAanvXKmUE7g7K4/RppTSIpOBy+OGF3N79YNuFSN8Thk+Fj mnH4374ElcRM9n3JT+tqyr927GQzHukMG4UPOGU1NQ1n3+y/TZQUEYvDFSmr6i9zUHrDrqzL GRRoELCt5Ma5EGtC9XwQRC8iHqFpQIHHcpdFfUg7wOAwbaS5ByWbkAHQyBAbpo6tcYwbT0sy lKN2djuAFRSXKa9THuc8vKRsmm0MC1Md2saP3dYFk0C/sXpp5w1glTXVNF/HaWpj9rzXzbt3 zSNqyt4jLIW5SIW65iGEZn8q2rEjvD0osQdvG07gkrNAttFWbOY
  • Ironport-hdrordr: A9a23:bXVz9a5l8iSwtuSMzwPXwaOCI+orL9Y04lQ7vn2ZFiY5TiXIra qTdaogviMc6Ax/ZJjvo6HjBEDmewKlyXcV2/hpAV7GZmXbUQSTXeVfBOfZowEIeBeOi9K1q5 0QFJSWYeeYZTYasS+T2njDLz9K+qjjzEnHv5a88587JjsaEJ2Ioj0JfTpyVSZNNXh7LKt8MK DZyttMpjKmd3hSRsOnBkMdV+yGi8zXmIngaRsmAQdizAWVlzun5JPzDhDdh34lInhy6IZn1V KAvx3y562lvf3+4hjA11XL55ATtMr9xsBFDMmsjNFQDjn3kA6naKloRrXHljEop+OE7kosjb D30l8dFvU2z0mUUnC+oBPr1QWl+DEy60X6wVvdpXf4u8T2SB8zFsIE3OtiA1LkwntlmOs5/L NA3mqfuZYSJRTcnB7l79yNcx1xjEK7rVcrjOZWpX1CVok1bqNXsOUkjTVoOaZFOBi/xJEsEe FoAs2ZzPFKcWmCZ3SchWVryMzEZAVAIj62Bmw5/uCF2Tlfm350i2ECwtYEo3sG/JUhD7FZ+u XtKM1T5f5zZ/5TSZg4KPYKQMOxBGCIawnLKniuLVPuE7xCE27RqqTw/K4+6IiRCdA1JaMJ6d X8uW5jxC4PkxqEM7zM4HQLyGGBfIyFZ0Wi9ikEjKIJ+IEVR9LQQF6+oR4V4o6dSs4kc7Pmss aISe5r6sDYXBTT8P5yrmvDsrlpWAwjuZ4uy6IGcmPLhP73AavXkcGeWMrvBdPWYEYZsyXEcz E+YAQ=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

When translating an address that falls inside of a superpage in the
IOMMU page tables the fetching of the PTE value wasn't masking of the
contiguous related data, which caused the returned data to be
corrupt as it would contain bits that the caller would interpret as
part of the address.

Fix this by masking off the contiguous bits.

Fixes: c71e55501a61 ('VT-d: have callers specify the target level for page 
table walks')
Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
Changes since v1:
 - Return all the PTE bits except for the contiguous count ones.
---
 xen/drivers/passthrough/vtd/iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/drivers/passthrough/vtd/iommu.c 
b/xen/drivers/passthrough/vtd/iommu.c
index 130a159cde07..d7ba9a9c349f 100644
--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -368,7 +368,7 @@ static uint64_t addr_to_dma_page_maddr(struct domain 
*domain, daddr_t addr,
                  * with the address adjusted to account for the residual of
                  * the walk.
                  */
-                pte_maddr = pte->val +
+                pte_maddr = (pte->val & ~DMA_PTE_CONTIG_MASK) +
                     (addr & ((1UL << level_to_offset_bits(level)) - 1) &
                      PAGE_MASK);
                 if ( !target )
-- 
2.40.0




 


Rackspace

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