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

[xen staging-4.18] radix-tree: introduce RADIX_TREE{,_INIT}()



commit 3013bdc7f773f1394a89885d9df52a1ac006af68
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Mon Feb 17 13:31:59 2025 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Mon Feb 17 13:31:59 2025 +0100

    radix-tree: introduce RADIX_TREE{,_INIT}()
    
    ... now that static initialization is possible. Use RADIX_TREE() for
    pci_segments and ivrs_maps.
    
    This then fixes an ordering issue on x86: With the call to
    radix_tree_init(), acpi_mmcfg_init()'s invocation of pci_segments_init()
    will zap the possible earlier introduction of segment 0 by
    amd_iommu_detect_one_acpi()'s call to pci_ro_device(), and thus the
    write-protection of the PCI devices representing AMD IOMMUs.
    
    Fixes: 3950f2485bbc ("x86/x2APIC: defer probe until after IOMMU ACPI table 
parsing")
    Requested-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    master commit: 26fe09e34566d701ecaea76b4563bb9934e85861
    master date: 2025-02-07 10:00:04 +0100
---
 xen/common/radix-tree.c                  | 2 +-
 xen/drivers/passthrough/amd/iommu_init.c | 3 +--
 xen/drivers/passthrough/pci.c            | 3 +--
 xen/include/xen/radix-tree.h             | 3 +++
 4 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/xen/common/radix-tree.c b/xen/common/radix-tree.c
index 994a5a3b3d..ac4bfbd3f4 100644
--- a/xen/common/radix-tree.c
+++ b/xen/common/radix-tree.c
@@ -704,7 +704,7 @@ void radix_tree_destroy(
 
 void radix_tree_init(struct radix_tree_root *root)
 {
-       memset(root, 0, sizeof(*root));
+       *root = (struct radix_tree_root)RADIX_TREE_INIT();
 }
 
 static __init unsigned long __maxindex(unsigned int height)
diff --git a/xen/drivers/passthrough/amd/iommu_init.c 
b/xen/drivers/passthrough/amd/iommu_init.c
index 9c01a49435..d672e682f8 100644
--- a/xen/drivers/passthrough/amd/iommu_init.c
+++ b/xen/drivers/passthrough/amd/iommu_init.c
@@ -32,7 +32,7 @@ static DECLARE_SOFTIRQ_TASKLET(amd_iommu_irq_tasklet, 
do_amd_iommu_irq, NULL);
 unsigned int __read_mostly amd_iommu_acpi_info;
 unsigned int __read_mostly ivrs_bdf_entries;
 u8 __read_mostly ivhd_type;
-static struct radix_tree_root ivrs_maps;
+static RADIX_TREE(ivrs_maps);
 LIST_HEAD_READ_MOSTLY(amd_iommu_head);
 bool iommuv2_enabled;
 
@@ -1406,7 +1406,6 @@ int __init amd_iommu_prepare(bool xt)
         goto error_out;
     ivrs_bdf_entries = rc;
 
-    radix_tree_init(&ivrs_maps);
     for_each_amd_iommu ( iommu )
     {
         rc = amd_iommu_prepare_one(iommu);
diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c
index 2a1e7ee89a..0852e4f172 100644
--- a/xen/drivers/passthrough/pci.c
+++ b/xen/drivers/passthrough/pci.c
@@ -68,7 +68,7 @@ bool pcidevs_locked(void)
     return !!spin_is_locked(&_pcidevs_lock);
 }
 
-static struct radix_tree_root pci_segments;
+static RADIX_TREE(pci_segments);
 
 static inline struct pci_seg *get_pseg(u16 seg)
 {
@@ -124,7 +124,6 @@ static int pci_segments_iterate(
 
 void __init pci_segments_init(void)
 {
-    radix_tree_init(&pci_segments);
     if ( !alloc_pseg(0) )
         panic("Could not initialize PCI segment 0\n");
 }
diff --git a/xen/include/xen/radix-tree.h b/xen/include/xen/radix-tree.h
index 9d5ffae3eb..4077365972 100644
--- a/xen/include/xen/radix-tree.h
+++ b/xen/include/xen/radix-tree.h
@@ -72,6 +72,9 @@ struct radix_tree_root {
  *** radix-tree API starts here **
  */
 
+#define RADIX_TREE_INIT() {}
+#define RADIX_TREE(name) struct radix_tree_root name = RADIX_TREE_INIT()
+
 void radix_tree_init(struct radix_tree_root *root);
 
 void radix_tree_destroy(
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.18



 


Rackspace

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