From: Ingo Molnar Date: Wed, 22 Apr 2015 14:40:56 +0000 (+0200) Subject: x86/fpu: Add debug check to kernel_fpu_disable() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=3103ae3a6d3e66d51bb883bb17b55574e163b77d;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git x86/fpu: Add debug check to kernel_fpu_disable() We are not supposed to call kernel_fpu_disable() if we have not previously enabled it. Also use kernel_fpu_disable()/enable() in the __kernel_fpu_begin/end() primitives, instead of writing to in_kernel_fpu directly, so that we get the debugging checks. Reviewed-by: Borislav Petkov Cc: Andy Lutomirski Cc: Dave Hansen Cc: Fenghua Yu Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Oleg Nesterov Cc: Peter Zijlstra Cc: Thomas Gleixner Signed-off-by: Ingo Molnar --- diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c index 161820526ad3..9bc573a5c9db 100644 --- a/arch/x86/kernel/fpu/core.c +++ b/arch/x86/kernel/fpu/core.c @@ -17,6 +17,7 @@ static void kernel_fpu_disable(void) static void kernel_fpu_enable(void) { + WARN_ON_ONCE(!this_cpu_read(in_kernel_fpu)); this_cpu_write(in_kernel_fpu, false); } @@ -77,7 +78,7 @@ void __kernel_fpu_begin(void) { struct task_struct *me = current; - this_cpu_write(in_kernel_fpu, true); + kernel_fpu_disable(); if (__thread_has_fpu(me)) { __save_init_fpu(me); @@ -100,7 +101,7 @@ void __kernel_fpu_end(void) stts(); } - this_cpu_write(in_kernel_fpu, false); + kernel_fpu_enable(); } EXPORT_SYMBOL(__kernel_fpu_end);