From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753465AbbEEQ4v (ORCPT ); Tue, 5 May 2015 12:56:51 -0400 Received: from mail-wi0-f178.google.com ([209.85.212.178]:35049 "EHLO mail-wi0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760949AbbEEQ2x (ORCPT ); Tue, 5 May 2015 12:28:53 -0400 From: Ingo Molnar To: linux-kernel@vger.kernel.org Cc: Andy Lutomirski , Borislav Petkov , Dave Hansen , Fenghua Yu , "H. Peter Anvin" , Linus Torvalds , Oleg Nesterov , Thomas Gleixner Subject: [PATCH 043/208] x86/fpu: Add debugging check to fpu_copy() Date: Tue, 5 May 2015 18:24:23 +0200 Message-Id: <1430843228-13749-44-git-send-email-mingo@kernel.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1430843228-13749-1-git-send-email-mingo@kernel.org> References: <1430843228-13749-1-git-send-email-mingo@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Also add a bit of documentation. Reviewed-by: Borislav Petkov Cc: Andy Lutomirski Cc: Dave Hansen Cc: Fenghua Yu Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Oleg Nesterov Cc: Thomas Gleixner Signed-off-by: Ingo Molnar --- arch/x86/kernel/fpu/core.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c index 3f3c79c75e37..7711539bcda5 100644 --- a/arch/x86/kernel/fpu/core.c +++ b/arch/x86/kernel/fpu/core.c @@ -203,8 +203,18 @@ void fpstate_free(struct fpu *fpu) } EXPORT_SYMBOL_GPL(fpstate_free); +/* + * Copy the current task's FPU state to a new task's FPU context. + * + * In the 'eager' case we just save to the destination context. + * + * In the 'lazy' case we save to the source context, mark the FPU lazy + * via stts() and copy the source context into the destination context. + */ static void fpu_copy(struct task_struct *dst, struct task_struct *src) { + WARN_ON(src != current); + if (use_eager_fpu()) { memset(&dst->thread.fpu.state->xsave, 0, xstate_size); __save_fpu(dst); -- 2.1.0