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

[PATCH 1/8] IOMMU/x86: drop locking from quarantine_init() hooks


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 11 Apr 2022 11:35:54 +0200
  • 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=2I9BVFSj3uMESwf/DYdlBGh3Zmde/zF778cT9zilJi4=; b=V6r32wYFX387ulMhJDXYbZQM/Zgt/TdIij3xBU7heFsvc+7gsmUiQ41K3jP3VvULrVJls9bwqphtY0XhVqMQli8Qw9044Vbcspi9QaMngHGKVEOioDuE26T6J2TqHVZZKQ4oHkkQ8APkJbB9oF0H4I0b0cRFIJeQ01SJSfJGs2KPwFK0VqCcWJC/4CBIM4RkxScnldVWO5GlDNy8IBmRfw24agVSuR5i1hu9/78Hv8v3yUqo8i8GJSHTqCiJ/vcQ8a0vX0x3M3DmcksNZ/z9kzVo7DMIjTJy1p0YmjZU5AG3tRb0iwY7wOQNHmUvWSxoJhFL+BTo4AwshR33xQ5CLA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h+uSVko+/BfXswIpZbkuk5xrFvG9G5Xf1E3mK9X9DDwXMlKw2x8fnQWOD3OEWRvk3dZN/tCJtmJmdStaLCUCI1FjmPIO50lLt0u0q3lrkQW7i8po5xZWu77K6L62aEGgwJspR3pIQMnlScLgxkXMr5l+RChada0CVZePlFukExvl4uDUUpxCT7Vv7QS0vsM1BsX6x0d2UsDFk9O6fpfry2Z/7S53htoUaH2pAzKzDszhX+k0jeBcrD4nKiJzTWxgHvMDrnquna8MAr7dij/a05q5lugbv2W1VIZXDN3r4WFUatPT+tKBFgU+dOC+Pl1YXEHsbmDwTlXKelsZn5jl5Q==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Kevin Tian <kevin.tian@xxxxxxxxx>, Paul Durrant <paul@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Mon, 11 Apr 2022 09:36:05 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Prior extension of these functions to enable per-device quarantine page
tables already didn't add more locking there, but merely left in place
what had been there before. But really locking is unnecessary here:
We're running with pcidevs_lock held (i.e. multiple invocations of the
same function [or their teardown equivalents] are impossible, and hence
there are no "local" races), while all consuming of the data being
populated here can't race anyway due to happening sequentially
afterwards. See also the comment in struct arch_pci_dev.

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

--- a/xen/drivers/passthrough/amd/iommu_map.c
+++ b/xen/drivers/passthrough/amd/iommu_map.c
@@ -699,15 +699,11 @@ int cf_check amd_iommu_quarantine_init(s
         union amd_iommu_pte *root;
         struct page_info *pgs[IOMMU_MAX_PT_LEVELS] = {};
 
-        spin_lock(&hd->arch.mapping_lock);
-
         root = __map_domain_page(pdev->arch.amd.root_table);
         rc = fill_qpt(root, level - 1, pgs);
         unmap_domain_page(root);
 
         pdev->arch.leaf_mfn = page_to_mfn(pgs[0]);
-
-        spin_unlock(&hd->arch.mapping_lock);
     }
 
     page_list_move(&pdev->arch.pgtables_list, &hd->arch.pgtables.list);
--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -3054,15 +3054,11 @@ static int cf_check intel_iommu_quaranti
         struct dma_pte *root;
         struct page_info *pgs[6] = {};
 
-        spin_lock(&hd->arch.mapping_lock);
-
         root = map_vtd_domain_page(pdev->arch.vtd.pgd_maddr);
         rc = fill_qpt(root, level - 1, pgs);
         unmap_vtd_domain_page(root);
 
         pdev->arch.leaf_mfn = page_to_mfn(pgs[0]);
-
-        spin_unlock(&hd->arch.mapping_lock);
     }
 
     page_list_move(&pdev->arch.pgtables_list, &hd->arch.pgtables.list);




 


Rackspace

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