]> xenbits.xensource.com Git - people/iwj/xen.git/commitdiff
x86/xstate: make use_xsave non-init
authorRoger Pau Monné <roger.pau@citrix.com>
Fri, 6 Sep 2019 15:04:39 +0000 (17:04 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 6 Sep 2019 15:04:39 +0000 (17:04 +0200)
LLVM code generation can attempt to load from a variable in the next
condition of an expression under certain circumstances, thus
attempting to load use_xsave regardless of the value of the bsp
variable, which leads to a page fault when the init section has
already been unmapped.

Fix this by making use_xsave non-init, thus preventing the page fault;
use __read_mostly instead. The LLVM bug with the discussion about this
issue can be found at:

https://bugs.llvm.org/show_bug.cgi?id=39707

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/xstate.c

index 10016a05d0d1bd88f783ba184e5857f20a3b10d8..243495ed07d41faa9d776681b50c555309db9901 100644 (file)
@@ -576,7 +576,11 @@ unsigned int xstate_ctxt_size(u64 xcr0)
 /* Collect the information of processor's extended state */
 void xstate_init(struct cpuinfo_x86 *c)
 {
-    static bool __initdata use_xsave = true;
+    /*
+     * NB: use_xsave cannot live in initdata because llvm might optimize
+     * reading it, see: https://bugs.llvm.org/show_bug.cgi?id=39707
+     */
+    static bool __read_mostly use_xsave = true;
     boolean_param("xsave", use_xsave);
 
     bool bsp = c == &boot_cpu_data;