]> xenbits.xensource.com Git - xen.git/commitdiff
radix-tree: introduce RADIX_TREE{,_INIT}()
authorJan Beulich <jbeulich@suse.com>
Fri, 7 Feb 2025 09:00:04 +0000 (10:00 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 7 Feb 2025 09:00:04 +0000 (10:00 +0100)
... 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@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Release-Acked-by: Oleksii Kurochko<oleksii.kurochko@gmail.com>
xen/common/radix-tree.c
xen/drivers/passthrough/amd/iommu_init.c
xen/drivers/passthrough/pci.c
xen/include/xen/radix-tree.h

index 063ff1e69d88282a65a3fd9766faead6ad925466..a623a9ff66eab5246fd60e79aee1084958e35dfa 100644 (file)
@@ -705,7 +705,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)
index 05fd3bde6e295f0400c4ebe0eff05a7b33cb9b44..ed5e684b93dad816ca81519e51b7f19199a54f16 100644 (file)
@@ -31,7 +31,7 @@ static struct tasklet amd_iommu_irq_tasklet;
 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_RO_AFTER_INIT(amd_iommu_head);
 bool iommuv2_enabled;
 
@@ -1408,7 +1408,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);
index 777c6b1a7fdcac7feb00d59cc049fb6fdd57f151..f398c3aa65dc2fcef3bdeeefb8f2cda1e4d9501e 100644 (file)
@@ -68,7 +68,7 @@ bool pcidevs_locked(void)
     return rspin_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");
 }
index 9d5ffae3eb86972c9f010aadd99475c9e950930c..40773659727b3b2526bab920ed5d00bc1b415dc6 100644 (file)
@@ -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(