Commit 011545b5 authored by Ingo Molnar's avatar Ingo Molnar

x86/fpu: Split fpu__ctx_switch_init() into _cpu() and _system() portions

So fpu__ctx_switch_init() has two aspects: a once per bootup functionality
that sets up a capability flag, and a per CPU functionality that sets CR0::TS.

Split the function.

Note that at this stage we still have duplicate calls into these methods, as
both the _system() and the _cpu() methods are run on all CPUs, with lower
level on_boot_cpu flags filtering out the duplicates where needed. So add
TS flag clearing as well, to handle the aftermath of early CPU init sequences
that might call in without having eager-fpu set - don't assume the TS flag
is cleared.

Calling each from its respective init level will happen later on.
Reviewed-by: default avatarBorislav Petkov <bp@alien8.de>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 064e51e3
......@@ -117,6 +117,18 @@ static void fpstate_xstate_init_size(void)
}
}
/*
* Initialize the TS bit in CR0 according to the style of context-switches
* we are using:
*/
static void fpu__init_cpu_ctx_switch(void)
{
if (!cpu_has_eager_fpu)
stts();
else
clts();
}
/*
* Enable all supported FPU features. Called when a CPU is brought online.
*/
......@@ -167,7 +179,7 @@ __setup("eagerfpu=", eager_fpu_setup);
* setup_init_fpu_buf() is __init and it is OK to call it here because
* init_xstate_ctx will be unset only once during boot.
*/
static void fpu__ctx_switch_init(void)
static void fpu__init_system_ctx_switch(void)
{
WARN_ON(current->thread.fpu.fpstate_active);
current_thread_info()->status = 0;
......@@ -190,9 +202,6 @@ static void fpu__ctx_switch_init(void)
setup_force_cpu_cap(X86_FEATURE_EAGER_FPU);
printk_once(KERN_INFO "x86/fpu: Using '%s' FPU context switches.\n", eagerfpu == ENABLE ? "eager" : "lazy");
if (!cpu_has_eager_fpu)
stts();
}
/*
......@@ -212,7 +221,8 @@ void fpu__init_system(void)
mxcsr_feature_mask_init();
fpu__init_system_xstate();
fpu__ctx_switch_init();
fpu__init_system_ctx_switch();
fpu__init_cpu_ctx_switch();
}
void fpu__cpu_init(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment