]> xenbits.xensource.com Git - people/royger/xen.git/commitdiff
xen/cet: Fix __initconst_cf_clobber
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 2 Mar 2022 20:27:46 +0000 (20:27 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 3 Mar 2022 11:21:35 +0000 (11:21 +0000)
The linker script collecting .init.rodata.* ahead of .init.rodata.cf_clobber
accidentally causes __initconst_cf_clobber to be a no-op.

Rearrange the linker script to unbreak this.

The IOMMU adjust_irq_affinities() hooks currently violate the safety
requirement for being cf_clobber, by also being plain __initcall()'s.

Consolidate to a single initcall using the iommu_adjust_irq_affinities()
wrapper (satisfying the cf_clobber safety requirement by using iommu_call()
under the hood), and also removes the dubious property that we'd call into
both vendors IOMMU drivers on boot, relying on the for_each_*() loops to be
empty for safety.

With this fixed, an all-enabled build of Xen has 1681 endbr64's in .text with
382 (23%) being clobbered during boot.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/xen.lds.S
xen/drivers/passthrough/amd/iommu_init.c
xen/drivers/passthrough/vtd/iommu.c
xen/drivers/passthrough/x86/iommu.c

index 83def6541ebd3a6179a7fc03e2ba7340857b8597..b15e5b67e4a425a4cadc9b568427c6be4375894d 100644 (file)
@@ -210,6 +210,12 @@ SECTIONS
   DECL_SECTION(.init.data) {
 #endif
 
+       . = ALIGN(POINTER_ALIGN);
+       __initdata_cf_clobber_start = .;
+       *(.init.data.cf_clobber)
+       *(.init.rodata.cf_clobber)
+       __initdata_cf_clobber_end = .;
+
        *(.init.rodata)
        *(.init.rodata.*)
 
@@ -224,12 +230,6 @@ SECTIONS
        *(.initcall1.init)
        __initcall_end = .;
 
-       . = ALIGN(POINTER_ALIGN);
-       __initdata_cf_clobber_start = .;
-       *(.init.data.cf_clobber)
-       *(.init.rodata.cf_clobber)
-       __initdata_cf_clobber_end = .;
-
        *(.init.data)
        *(.init.data.rel)
        *(.init.data.rel.*)
index 657c7f619a512e18505307f8372e7449bc79669a..2e5bffa732e7734ce9d88e6ad9eb0dd5f1f4dc97 100644 (file)
@@ -831,7 +831,6 @@ int cf_check iov_adjust_irq_affinities(void)
 
     return 0;
 }
-__initcall(iov_adjust_irq_affinities);
 
 /*
  * Family15h Model 10h-1fh erratum 746 (IOMMU Logging May Stall Translations)
index 6a65ba1d827154c4c54aae858b6895674fd7a1ac..f70d51580657413e5b2634484932a52adce6a108 100644 (file)
@@ -2119,7 +2119,6 @@ static int cf_check adjust_vtd_irq_affinities(void)
 
     return 0;
 }
-__initcall(adjust_vtd_irq_affinities);
 
 static int __must_check init_vtd_hw(bool resume)
 {
index 58a422fb5f882a30ba4de938131da3d2908c3ef2..57c7b26c1a54500981bf38b20890bd40d073699c 100644 (file)
@@ -462,6 +462,12 @@ bool arch_iommu_use_permitted(const struct domain *d)
             likely(!p2m_get_hostp2m(d)->global_logdirty));
 }
 
+static int __init cf_check adjust_irq_affinities(void)
+{
+    return iommu_adjust_irq_affinities();
+}
+__initcall(adjust_irq_affinities);
+
 /*
  * Local variables:
  * mode: C