Skip to content

Commit b6aa855

Browse files
author
Ingo Molnar
committed
x86/fpu: Split the state handling in fpu__drop()
Prepare fpu__drop() to use fpu->fpregs_active. There are two distinct usecases for fpu__drop() in this context: exit_thread() when called for 'current' in exit(), and when called for another task in fork(). This patch does not change behavior, it only adds a couple of debug checks and structures the code to make the ->fpregs_active change more obviously correct. All the complications will be removed later on. Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Andy Lutomirski <luto@amacapital.net> Cc: Andy Lutomirski <luto@kernel.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: Eric Biggers <ebiggers3@gmail.com> Cc: Fenghua Yu <fenghua.yu@intel.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Rik van Riel <riel@redhat.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Yu-cheng Yu <yu-cheng.yu@intel.com> Link: http://lkml.kernel.org/r/20170923130016.21448-18-mingo@kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent a10b6a1 commit b6aa855

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

arch/x86/kernel/fpu/core.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -414,12 +414,19 @@ void fpu__drop(struct fpu *fpu)
414414
{
415415
preempt_disable();
416416

417-
if (fpu->fpregs_active) {
418-
/* Ignore delayed exceptions from user space */
419-
asm volatile("1: fwait\n"
420-
"2:\n"
421-
_ASM_EXTABLE(1b, 2b));
422-
fpregs_deactivate(fpu);
417+
if (fpu == &current->thread.fpu) {
418+
WARN_ON_FPU(fpu->fpstate_active != fpu->fpregs_active);
419+
420+
if (fpu->fpregs_active) {
421+
/* Ignore delayed exceptions from user space */
422+
asm volatile("1: fwait\n"
423+
"2:\n"
424+
_ASM_EXTABLE(1b, 2b));
425+
if (fpu->fpregs_active)
426+
fpregs_deactivate(fpu);
427+
}
428+
} else {
429+
WARN_ON_FPU(fpu->fpregs_active);
423430
}
424431

425432
fpu->fpstate_active = 0;

0 commit comments

Comments
 (0)