diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h index ba32af062f61d69164a792630e3257c8cdc6deb5..7bfc85bbb8ffc0578011ceac2c08548bd140ade3 100644 --- a/arch/x86/include/asm/alternative.h +++ b/arch/x86/include/asm/alternative.h @@ -52,6 +52,12 @@ struct alt_instr { u8 padlen; /* length of build-time padding */ } __packed; +/* + * Debug flag that can be tested to see whether alternative + * instructions were patched in already: + */ +extern int alternatives_patched; + extern void alternative_instructions(void); extern void apply_alternatives(struct alt_instr *start, struct alt_instr *end); diff --git a/arch/x86/include/asm/fpu/xstate.h b/arch/x86/include/asm/fpu/xstate.h index 31a002ad5aeb715811ed7e41b6bdf35c99052d65..ab2c507b58b65d9909116878b611faf78c592474 100644 --- a/arch/x86/include/asm/fpu/xstate.h +++ b/arch/x86/include/asm/fpu/xstate.h @@ -119,7 +119,7 @@ static inline int xsave_state(struct xsave_struct *fx) u32 hmask = mask >> 32; int err = 0; - WARN_ON(system_state == SYSTEM_BOOTING); + WARN_ON(!alternatives_patched); /* * If xsaves is enabled, xsaves replaces xsaveopt because diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c index aef65319316065eab845f35141682c3550f18a22..7fe0972353769a49243d514493c8a0d9d207ccbe 100644 --- a/arch/x86/kernel/alternative.c +++ b/arch/x86/kernel/alternative.c @@ -21,6 +21,10 @@ #include #include +int __read_mostly alternatives_patched; + +EXPORT_SYMBOL_GPL(alternatives_patched); + #define MAX_PATCH_LEN (255-1) static int __initdata_or_module debug_alternative; @@ -627,6 +631,7 @@ void __init alternative_instructions(void) apply_paravirt(__parainstructions, __parainstructions_end); restart_nmi(); + alternatives_patched = 1; } /**