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

[PATCH v3 03/23] VT-d: limit page table population in domain_pgd_maddr()


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 10 Jan 2022 17:23:22 +0100
  • 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=XbTDn+4UMa6dRTZFvW2eulMSRTVqS5JomnC2oSl1l9Q=; b=Dl3MSBXHOdyULwK3qt+jE/CGfJlTf3QTrkBBB2yIQUN/4jyMMw1SZGCM+iiGR35G6G/KCfNw8UjUz61e80XQLL+/R4BKUaDo9/cGsZ8jb763MXF0mEqiYr75C+TuwMdgWBsfP4hEmNX8hoAboX4keTr8YWjkkBOqiwLtk6H15kFHX0cpXwYFBnMkNHW4baKvrlgK3jfabfsHkIyKya4m/wPb0oscSj0hjVOnyqLINAoKagCyobfnJfz3MTKmQU7JKCAZh6HI24EBko72kxMzz2NlaMRDfMZQjwkvE436AAkoKFj4RdePQJzGKds73qZX/gltJ4gyaZfsW2GF1njubQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B4E/CxPk3hp20gDSvpBXWvzQtI5wH/bxQ85CO1rquwN5E8mMvW1P435RWw/HX6jEW/8gYc21d+H/B2wGoZZk/AoCDu8XTf/Ud1dRtAVCcf+63H5XwHaFrIvN26/XMPN9oHNCAxB0l2FuWpu2paw7MrE6qa3f2lnDFRtzaRsJoqyA6RaoRMX/18EKlpr7sibDk8Etpwh5A8vAleweA8sT7eiUeGD60aH3Sa3Fmk8e1gZ0/UsP24oHTzFuPHIaTkbGlc6fwtofu7jtIlx5PNmsyj445dMdLKXbvPpPeyByn2+gMA5GclYLI1eDD7AzJN233HO7Fn0pt8CucB1oYoIfpQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Paul Durrant <paul@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Kevin Tian <kevin.tian@xxxxxxxxx>
  • Delivery-date: Mon, 10 Jan 2022 16:23:29 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

I have to admit that I never understood why domain_pgd_maddr() wants to
populate all page table levels for DFN 0. I can only assume that despite
the comment there what is needed is population just down to the smallest
possible nr_pt_levels that the loop later in the function may need to
run to. Hence what is needed is the minimum of all possible
iommu->nr_pt_levels, to then be passed into addr_to_dma_page_maddr()
instead of literal 1.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
v3: New.

--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -55,6 +55,7 @@ bool __read_mostly iommu_snoop = true;
 #endif
 
 static unsigned int __read_mostly nr_iommus;
+static unsigned int __read_mostly min_pt_levels = UINT_MAX;
 
 static struct iommu_ops vtd_ops;
 static struct tasklet vtd_fault_tasklet;
@@ -482,8 +483,11 @@ static uint64_t domain_pgd_maddr(struct
     {
         if ( !hd->arch.vtd.pgd_maddr )
         {
-            /* Ensure we have pagetables allocated down to leaf PTE. */
-            addr_to_dma_page_maddr(d, 0, 1, NULL, true);
+            /*
+             * Ensure we have pagetables allocated down to the smallest
+             * level the loop below may need to run to.
+             */
+            addr_to_dma_page_maddr(d, 0, min_pt_levels, NULL, true);
 
             if ( !hd->arch.vtd.pgd_maddr )
                 return 0;
@@ -1381,6 +1385,8 @@ int __init iommu_alloc(struct acpi_drhd_
         return -ENODEV;
     }
     iommu->nr_pt_levels = agaw_to_level(agaw);
+    if ( min_pt_levels > iommu->nr_pt_levels )
+        min_pt_levels = iommu->nr_pt_levels;
 
     if ( !ecap_coherent(iommu->ecap) )
         vtd_ops.sync_cache = sync_cache;




 


Rackspace

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