x86, xsave: Make xstate_enable_boot_cpu() __init, protect on CPU 0
xstate_enable_boot_cpu() is, as the name implies, only used on the boot CPU; furthermore, it invokes alloc_bootmem(), which is __init; hence it needs to be tagged __init rather than __cpuinit. Furthermore, it is *not* safe in the long run to rely on CPU 0 only coming online during the early boot -- at some point we're going to support offlining (and re-onlining) the boot CPU, and at that point we must not call xstate_enable_boot_cpu() again. The code is a fair bit more obscure than one would like, because the __ref overrides aren't quite powerful enough. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com> Acked-by: Suresh Siddha <suresh.b.siddha@intel.com> Cc: Robert Richter <robert.richter@amd.com> LKML-Reference: <4C476236.1020302@zytor.com>
This commit is contained in:
Родитель
4995b9dba9
Коммит
1cff92d8fd
|
@ -360,10 +360,10 @@ unsigned int sig_xstate_size = sizeof(struct _fpstate);
|
||||||
/*
|
/*
|
||||||
* Enable the extended processor state save/restore feature
|
* Enable the extended processor state save/restore feature
|
||||||
*/
|
*/
|
||||||
static inline void xstate_enable(u64 mask)
|
static inline void xstate_enable(void)
|
||||||
{
|
{
|
||||||
set_in_cr4(X86_CR4_OSXSAVE);
|
set_in_cr4(X86_CR4_OSXSAVE);
|
||||||
xsetbv(XCR_XFEATURE_ENABLED_MASK, mask);
|
xsetbv(XCR_XFEATURE_ENABLED_MASK, pcntxt_mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -421,7 +421,7 @@ static void __init setup_xstate_init(void)
|
||||||
/*
|
/*
|
||||||
* Enable and initialize the xsave feature.
|
* Enable and initialize the xsave feature.
|
||||||
*/
|
*/
|
||||||
static void __cpuinit xstate_enable_boot_cpu(void)
|
static void __init xstate_enable_boot_cpu(void)
|
||||||
{
|
{
|
||||||
unsigned int eax, ebx, ecx, edx;
|
unsigned int eax, ebx, ecx, edx;
|
||||||
|
|
||||||
|
@ -444,7 +444,7 @@ static void __cpuinit xstate_enable_boot_cpu(void)
|
||||||
*/
|
*/
|
||||||
pcntxt_mask = pcntxt_mask & XCNTXT_MASK;
|
pcntxt_mask = pcntxt_mask & XCNTXT_MASK;
|
||||||
|
|
||||||
xstate_enable(pcntxt_mask);
|
xstate_enable();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Recompute the context size for enabled features
|
* Recompute the context size for enabled features
|
||||||
|
@ -462,16 +462,22 @@ static void __cpuinit xstate_enable_boot_cpu(void)
|
||||||
pcntxt_mask, xstate_size);
|
pcntxt_mask, xstate_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* For the very first instance, this calls xstate_enable_boot_cpu();
|
||||||
|
* for all subsequent instances, this calls xstate_enable().
|
||||||
|
*
|
||||||
|
* This is somewhat obfuscated due to the lack of powerful enough
|
||||||
|
* overrides for the section checks.
|
||||||
|
*/
|
||||||
void __cpuinit xsave_init(void)
|
void __cpuinit xsave_init(void)
|
||||||
{
|
{
|
||||||
|
static __refdata void (*next_func)(void) = xstate_enable_boot_cpu;
|
||||||
|
void (*this_func)(void);
|
||||||
|
|
||||||
if (!cpu_has_xsave)
|
if (!cpu_has_xsave)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/*
|
this_func = next_func;
|
||||||
* Boot processor to setup the FP and extended state context info.
|
next_func = xstate_enable;
|
||||||
*/
|
this_func();
|
||||||
if (!smp_processor_id())
|
|
||||||
xstate_enable_boot_cpu();
|
|
||||||
else
|
|
||||||
xstate_enable(pcntxt_mask);
|
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче