From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759972AbbEEQxO (ORCPT ); Tue, 5 May 2015 12:53:14 -0400 Received: from mail-wg0-f44.google.com ([74.125.82.44]:34116 "EHLO mail-wg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761031AbbEEQ3J (ORCPT ); Tue, 5 May 2015 12:29:09 -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 053/208] x86/fpu: Document fpu__unlazy_stopped() Date: Tue, 5 May 2015 18:24:33 +0200 Message-Id: <1430843228-13749-54-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 Explain its usage and also document a TODO item. 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 | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c index b8e3dbbcdc16..0235df54cd48 100644 --- a/arch/x86/kernel/fpu/core.c +++ b/arch/x86/kernel/fpu/core.c @@ -284,10 +284,27 @@ int fpstate_alloc_init(struct task_struct *curr) EXPORT_SYMBOL_GPL(fpstate_alloc_init); /* - * The _current_ task is using the FPU for the first time - * so initialize it and set the mxcsr to its default - * value at reset if we support XMM instructions and then - * remember the current task has used the FPU. + * This function is called before we modify a stopped child's + * FPU state context. + * + * If the child has not used the FPU before then initialize its + * FPU context. + * + * If the child has used the FPU before then unlazy it. + * + * [ After this function call, after the context is modified and + * the child task is woken up, the child task will restore + * the modified FPU state from the modified context. If we + * didn't clear its lazy status here then the lazy in-registers + * state pending on its former CPU could be restored, losing + * the modifications. ] + * + * This function is also called before we read a stopped child's + * FPU state - to make sure it's modified. + * + * TODO: A future optimization would be to skip the unlazying in + * the read-only case, it's not strictly necessary for + * read-only access to the context. */ static int fpu__unlazy_stopped(struct task_struct *child) { -- 2.1.0