x86/fpu: Add CONFIG_X86_DEBUG_FPU=y FPU debugging code
There are various internal FPU state debugging checks that never trigger in practice, but which are useful for FPU code development. Separate these out into CONFIG_X86_DEBUG_FPU=y, and also add a couple of new ones. The size difference is about 0.5K of code on defconfig: text data bss filename 15028906 2578816 1638400 vmlinux 15029430 2578816 1638400 vmlinux ( Keep this enabled by default until the new FPU code is debugged. ) Cc: Andy Lutomirski <luto@amacapital.net> Cc: Borislav Petkov <bp@alien8.de> 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:
@@ -59,6 +59,15 @@ extern void fpu__clear(struct fpu *fpu);
|
||||
extern void fpu__init_check_bugs(void);
|
||||
extern void fpu__resume_cpu(void);
|
||||
|
||||
/*
|
||||
* Debugging facility:
|
||||
*/
|
||||
#ifdef CONFIG_X86_DEBUG_FPU
|
||||
# define WARN_ON_FPU(x) WARN_ON_ONCE(x)
|
||||
#else
|
||||
# define WARN_ON_FPU(x) ({ 0; })
|
||||
#endif
|
||||
|
||||
DECLARE_PER_CPU(struct fpu *, fpu_fpregs_owner_ctx);
|
||||
|
||||
/*
|
||||
@@ -296,6 +305,8 @@ static inline void __fpregs_deactivate_hw(void)
|
||||
/* Must be paired with an 'stts' (fpregs_deactivate_hw()) after! */
|
||||
static inline void __fpregs_deactivate(struct fpu *fpu)
|
||||
{
|
||||
WARN_ON_FPU(!fpu->fpregs_active);
|
||||
|
||||
fpu->fpregs_active = 0;
|
||||
this_cpu_write(fpu_fpregs_owner_ctx, NULL);
|
||||
}
|
||||
@@ -303,6 +314,8 @@ static inline void __fpregs_deactivate(struct fpu *fpu)
|
||||
/* Must be paired with a 'clts' (fpregs_activate_hw()) before! */
|
||||
static inline void __fpregs_activate(struct fpu *fpu)
|
||||
{
|
||||
WARN_ON_FPU(fpu->fpregs_active);
|
||||
|
||||
fpu->fpregs_active = 1;
|
||||
this_cpu_write(fpu_fpregs_owner_ctx, fpu);
|
||||
}
|
||||
@@ -433,8 +446,10 @@ switch_fpu_prepare(struct fpu *old_fpu, struct fpu *new_fpu, int cpu)
|
||||
static inline void switch_fpu_finish(struct fpu *new_fpu, fpu_switch_t fpu_switch)
|
||||
{
|
||||
if (fpu_switch.preload) {
|
||||
if (unlikely(copy_fpstate_to_fpregs(new_fpu)))
|
||||
if (unlikely(copy_fpstate_to_fpregs(new_fpu))) {
|
||||
WARN_ON_FPU(1);
|
||||
fpu__clear(new_fpu);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user