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

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


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Date: Tue, 9 May 2023 12:41:46 +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=+/6g8tjSBTZthJRn0IsH15R3+4hN4TP9sKJX1WwKJX4=; b=Jj4j2GAIjCplvGD9cemopphdDpWLSArcM2qdtAo1Ys8u9ANO+Rp77Ga+yD1YAK/CAIxZu+x+2U7eq3SboPauc2iNjgNaDzWnprGuh3m/EERXhV6LNhos/n1sMtAKTreb/sERHA8dFFeMLR0f5Mi3OmAk04XMoFqre77p7Hx95j/EcSDSbKZA9DEcGITDyyk30KEy7NfbPoVe4JRZNqeU0ZBOSo30SK164pSVanDfGYmBbO3maEIHZcBPZd8o1fCNCrWl6cZVtYyqsMJiWZTqdQBIKnQWBu4qdTFXxy0aCkf4OT27k31OZFpiU8h2WdZGF6UxlnMnLH6ywRqqbLJyrQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GC96wJaru1eV7ZjTFEQc46cXB+LXG/HX8QrlFRaOuO5kEVzDmqgE3k3Kf4NHRRr057oLi1CLJ+mP8Pt8UCTp8AX7CTAbrTlL0XAbXLtNudz0KIatVGVdhT3aD2Yplwf8yqmeD3F5OVuhgi3OiwypT6Tijeo2xXLG5wU1vA0Bm8N8R79zwVXWyqTsiIsr+zJab933WooCZ5w1zW7La6chGCV0v/z0R4e2Lc5q30PlJwWx2kxaFcsv8KFU0SrRwPzR3wqdXflp0UXJoU/C9atJu+VhTZRXDZKQRI1mcVThGh1HxurZsjLZvy4HsIDYd6ajurLYDTl//bjI96bexvM6ZQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: jbeulich@xxxxxxxx, Roger Pau Monne <roger.pau@xxxxxxxxxx>, Kevin Tian <kevin.tian@xxxxxxxxx>
  • Delivery-date: Tue, 09 May 2023 10:42:59 +0000
  • Ironport-data: A9a23:SM/4lqDwdovhahVW/wHiw5YqxClBgxIJ4kV8jS/XYbTApDMi3zxTx zAWCzvXaPjbYWX9e9skPdizp04PscTRmtY2QQY4rX1jcSlH+JHPbTi7wuUcHAvJd5GeExg3h yk6QoOdRCzhZiaE/n9BCpC48T8nk/nOHuGmYAL9EngZbRd+Tys8gg5Ulec8g4p56fC0GArIs t7pyyHlEAbNNwVcbyRFuspvlDs15K6p4G5A7wRnDRx2lAS2e0c9Xcp3yZ6ZdxMUcqEMdsamS uDKyq2O/2+x13/B3fv8z94X2mVTKlLjFVDmZkh+AsBOsTAbzsAG6Y4pNeJ0VKtio27hc+ada jl6ncfYpQ8BZsUgkQmGOvVSO3kW0aZuoNcrLZUj2CA6IoKvn3bEmp1T4E8K0YIwoKEoGzpp1 7siLm4CVBCto6Wd/baSRbw57igjBJGD0II3nFhFlW2cKMl8BJfJTuPN+MNS2yo2ioZWB/HCa sEFaD1pKhPdfxlIPVRRA5U79AuqriCnL3sE9xTK/uxuvDS7IA9ZidABNPLPfdOHX4NNl1uwr WPa5WXpRBodMbRzzBLcqi3z3rWQx3+TtIQ6Jf7p8P1nuASomVcZUBNRTQCa8PycsxvrMz5YA wlOksY0loAi+UruQtTjUhmQpH+fogVaS9dWC/c96gyG1uzT+QnxLmoOQyNFadcmnNQrXjFs3 ViM9/vqCCJutvuJSHub3raSsT62fyMSKAc/iTQsSAIE55zmv9s1hxeXEtJ7Svfq0pvyBC36x C2MoG4mnbIPgMUX1qK9u1fanzaroZuPRQkwjunKYl+YAspCTNbNT+SVBZLztJ6s8K7xooG9g UU5
  • Ironport-hdrordr: A9a23:v9WbYqkc2iR9NRWw2eeIGvicGgDpDfIa3DAbv31ZSRFFG/Fw9v re5cjzsCWe4gr5N0tNpTn+AtjjfZqxz/NICPAqTNSftWrdyQ2Vxf9Zg7cKqgeIcxEWkNQ86U 4KScdD4bPLbGRSvILQ5hW+Gdpl+dGb8cmT9ILjJg9WPGZXglZbnmNENjo=
  • 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 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.

Fix this by re-using the value of pte_maddr which is obtained using
dma_pte_addr().  Such change requires adjusting the previous error
path to zero pte_maddr.

Fixes: c71e55501a61 ('VT-d: have callers specify the target level for page 
table walks')
Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
 xen/drivers/passthrough/vtd/iommu.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/xen/drivers/passthrough/vtd/iommu.c 
b/xen/drivers/passthrough/vtd/iommu.c
index 130a159cde07..819e996e6269 100644
--- 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);
                 if ( !target )
-- 
2.40.0




 


Rackspace

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