Skip to contentSkip to conversation

xstate: make use_xsave non-init

PATCH In review Roger Pau Monne 2 participants 3 messages Sep 5, 2019 – Sep 6, 2019

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 xstate: make use_xsave non-init

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. The LLVM bug with the discussion about this issue can be found at:

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

---
 xen/arch/x86/xstate.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
xen/arch/x86/xstate.c +5 -1
index 3293ef834f..1dddda2818 100644
@@ -577,7 +577,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 use_xsave = true;
     boolean_param("xsave", use_xsave);
 
     bool bsp = c == &boot_cpu_data;
Signature · 7 lines
2.22.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Acked-by on v2 1/1
#1 lore raw
Quoted 5 lines · Roger Pau Monne
xen/arch/x86/xstate.c +0 -0
@@ -577,7 +577,11 @@ unsigned int xstate_ctxt_size(u64 xcr0)
 /* Collect the information of processor's extended state */
 void xstate_init(struct cpuinfo_x86 *c)

xen/arch/x86/xstate.c unsigned int xstate_ctxt_size(u64 xcr0) · line 587

Quoted 10 lines
xen/arch/x86/xstate.c +5 -1
 {
-    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 use_xsave = true;
     boolean_param("xsave", use_xsave);
 
     bool bsp = c == &boot_cpu_data;

I think we'd want to use __read_mostly then instead. Can be added while committing of course, if you agree. With the addition

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
Quoted 15 lines · Jan Beulich
Quoted 14 lines · Roger Pau Monne
xen/arch/x86/xstate.c +5 -1
@@ -577,7 +577,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 use_xsave = true;
     boolean_param("xsave", use_xsave);
 
Quoted 5 lines

xen/arch/x86/xstate.c unsigned int xstate_ctxt_size(u64 xcr0) · line 587

Quoted 1 line
xen/arch/x86/xstate.c +0 -0
     bool bsp = c == &boot_cpu_data;

I think we'd want to use __read_mostly then instead. Can be added while committing of course, if you agree. With the addition

Yes, that seems OK to me. Feel free to expand the commit message to mention the change to read_mostly if you want.

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel