mirror of
https://github.com/torvalds/linux.git
synced 2024-12-24 03:42:52 +00:00
x86/fpu: Remove 'init_xstate_buf' bootmem allocation
Make init_xstate_buf allocated statically at build time. This structure's maximum size is around 1KB - and it's allocated even on most modern embedded x86 CPUs which strive for FPU instruction set parity with desktop and server CPUs, so it's not like we can save much on smaller systems. This removes the last bootmem allocation from the FPU init path, allowing it to be called earlier in the boot sequence. Reviewed-by: Borislav 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: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
parent
26b1f5d05a
commit
3e5e126774
@ -373,9 +373,9 @@ static inline void drop_fpu(struct fpu *fpu)
|
|||||||
static inline void restore_init_xstate(void)
|
static inline void restore_init_xstate(void)
|
||||||
{
|
{
|
||||||
if (use_xsave())
|
if (use_xsave())
|
||||||
xrstor_state(init_xstate_buf, -1);
|
xrstor_state(&init_xstate_ctx, -1);
|
||||||
else
|
else
|
||||||
fxrstor_checking(&init_xstate_buf->i387);
|
fxrstor_checking(&init_xstate_ctx.i387);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
extern unsigned int xstate_size;
|
extern unsigned int xstate_size;
|
||||||
extern u64 xfeatures_mask;
|
extern u64 xfeatures_mask;
|
||||||
extern u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
|
extern u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
|
||||||
extern struct xsave_struct *init_xstate_buf;
|
extern struct xsave_struct init_xstate_ctx;
|
||||||
|
|
||||||
extern void xsave_init(void);
|
extern void xsave_init(void);
|
||||||
extern void update_regset_xstate_info(unsigned int size, u64 xstate_mask);
|
extern void update_regset_xstate_info(unsigned int size, u64 xstate_mask);
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
*
|
*
|
||||||
* Author: Suresh Siddha <suresh.b.siddha@intel.com>
|
* Author: Suresh Siddha <suresh.b.siddha@intel.com>
|
||||||
*/
|
*/
|
||||||
#include <linux/bootmem.h>
|
|
||||||
#include <linux/compat.h>
|
#include <linux/compat.h>
|
||||||
#include <linux/cpu.h>
|
#include <linux/cpu.h>
|
||||||
#include <asm/fpu/api.h>
|
#include <asm/fpu/api.h>
|
||||||
@ -20,7 +19,7 @@ u64 xfeatures_mask;
|
|||||||
/*
|
/*
|
||||||
* Represents init state for the supported extended state.
|
* Represents init state for the supported extended state.
|
||||||
*/
|
*/
|
||||||
struct xsave_struct *init_xstate_buf;
|
struct xsave_struct init_xstate_ctx;
|
||||||
|
|
||||||
static struct _fpx_sw_bytes fx_sw_reserved, fx_sw_reserved_ia32;
|
static struct _fpx_sw_bytes fx_sw_reserved, fx_sw_reserved_ia32;
|
||||||
static unsigned int xstate_offsets[XFEATURES_NR_MAX], xstate_sizes[XFEATURES_NR_MAX];
|
static unsigned int xstate_offsets[XFEATURES_NR_MAX], xstate_sizes[XFEATURES_NR_MAX];
|
||||||
@ -98,7 +97,7 @@ void __sanitize_i387_state(struct task_struct *tsk)
|
|||||||
int size = xstate_sizes[feature_bit];
|
int size = xstate_sizes[feature_bit];
|
||||||
|
|
||||||
memcpy((void *)fx + offset,
|
memcpy((void *)fx + offset,
|
||||||
(void *)init_xstate_buf + offset,
|
(void *)&init_xstate_ctx + offset,
|
||||||
size);
|
size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,12 +324,12 @@ static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
|
|||||||
if (use_xsave()) {
|
if (use_xsave()) {
|
||||||
if ((unsigned long)buf % 64 || fx_only) {
|
if ((unsigned long)buf % 64 || fx_only) {
|
||||||
u64 init_bv = xfeatures_mask & ~XSTATE_FPSSE;
|
u64 init_bv = xfeatures_mask & ~XSTATE_FPSSE;
|
||||||
xrstor_state(init_xstate_buf, init_bv);
|
xrstor_state(&init_xstate_ctx, init_bv);
|
||||||
return fxrstor_user(buf);
|
return fxrstor_user(buf);
|
||||||
} else {
|
} else {
|
||||||
u64 init_bv = xfeatures_mask & ~xbv;
|
u64 init_bv = xfeatures_mask & ~xbv;
|
||||||
if (unlikely(init_bv))
|
if (unlikely(init_bv))
|
||||||
xrstor_state(init_xstate_buf, init_bv);
|
xrstor_state(&init_xstate_ctx, init_bv);
|
||||||
return xrestore_user(buf, xbv);
|
return xrestore_user(buf, xbv);
|
||||||
}
|
}
|
||||||
} else if (use_fxsr()) {
|
} else if (use_fxsr()) {
|
||||||
@ -574,12 +573,10 @@ static void setup_init_fpu_buf(void)
|
|||||||
on_boot_cpu = 0;
|
on_boot_cpu = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Setup init_xstate_buf to represent the init state of
|
* Setup init_xstate_ctx to represent the init state of
|
||||||
* all the features managed by the xsave
|
* all the features managed by the xsave
|
||||||
*/
|
*/
|
||||||
init_xstate_buf = alloc_bootmem_align(xstate_size,
|
fx_finit(&init_xstate_ctx.i387);
|
||||||
__alignof__(struct xsave_struct));
|
|
||||||
fx_finit(&init_xstate_buf->i387);
|
|
||||||
|
|
||||||
if (!cpu_has_xsave)
|
if (!cpu_has_xsave)
|
||||||
return;
|
return;
|
||||||
@ -588,21 +585,20 @@ static void setup_init_fpu_buf(void)
|
|||||||
print_xstate_features();
|
print_xstate_features();
|
||||||
|
|
||||||
if (cpu_has_xsaves) {
|
if (cpu_has_xsaves) {
|
||||||
init_xstate_buf->header.xcomp_bv =
|
init_xstate_ctx.header.xcomp_bv = (u64)1 << 63 | xfeatures_mask;
|
||||||
(u64)1 << 63 | xfeatures_mask;
|
init_xstate_ctx.header.xfeatures = xfeatures_mask;
|
||||||
init_xstate_buf->header.xfeatures = xfeatures_mask;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Init all the features state with header_bv being 0x0
|
* Init all the features state with header_bv being 0x0
|
||||||
*/
|
*/
|
||||||
xrstor_state_booting(init_xstate_buf, -1);
|
xrstor_state_booting(&init_xstate_ctx, -1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Dump the init state again. This is to identify the init state
|
* Dump the init state again. This is to identify the init state
|
||||||
* of any feature which is not represented by all zero's.
|
* of any feature which is not represented by all zero's.
|
||||||
*/
|
*/
|
||||||
xsave_state_booting(init_xstate_buf);
|
xsave_state_booting(&init_xstate_ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum { AUTO, ENABLE, DISABLE } eagerfpu = AUTO;
|
static enum { AUTO, ENABLE, DISABLE } eagerfpu = AUTO;
|
||||||
@ -727,7 +723,7 @@ void xsave_init(void)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* setup_init_fpu_buf() is __init and it is OK to call it here because
|
* setup_init_fpu_buf() is __init and it is OK to call it here because
|
||||||
* init_xstate_buf will be unset only once during boot.
|
* init_xstate_ctx will be unset only once during boot.
|
||||||
*/
|
*/
|
||||||
void __init_refok eager_fpu_init(void)
|
void __init_refok eager_fpu_init(void)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user