Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1738955imu; Wed, 28 Nov 2018 14:23:22 -0800 (PST) X-Google-Smtp-Source: AFSGD/VYuYbEhxkKAzFcJouqDYTdBWrrmV4mJbjTWyYMiJAGRTMgmMash5zsrNLfJL5e6KV7B1AJ X-Received: by 2002:a17:902:d01:: with SMTP id 1mr39401062plu.127.1543443802534; Wed, 28 Nov 2018 14:23:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543443802; cv=none; d=google.com; s=arc-20160816; b=UV+NQgU/PERGBLwrxwpGksW20wYyIJwJKn5lKSGJAwHv8QBNqlnWFs10ns2MHayBgN GYu07mH4aPGtom7++oKRtOrpyJgn2ZjKKY1VPHErwy8KBuWy3+kMpTCRdlCv25opx2jr 7uR1YRuqYNoQOD3rw/PuGoUR0PjE+BXyCpe9gXLvCWwUo5XROT+HOXeDchYZJgoxq0np JC5FZ3+Fg1OFAo/v/f7sWKYYZ7V96627a6cenLcNvKbZ3vFkskDE/pRbEmjlTg5/8USP Qt9BwsH/G0J++KFH/mNnzYU12uoGhkWvsYVL+HG2+5VyABhZV3SOm+0OWs/MNym5JLNV Om1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=v8nXesdNQ5utO4+SE4Q8XRLkIN4wyiY/ECNysrMcECc=; b=FaW5hG7eFrjuHlDrPczjiC5GYCtWtRj6f3GOTNK0Mn7dDKCvQBUbF6h1dOCFd35y8O MXYSn9fwEKRoiMoZyt/QZod8ooAnviAUvKQbAp6WvHQ7az4+ZJu0qpHcaba1mNGCQg60 cnpHnlVSUXMUNunz+sL9ACX/jbJCmTXWMHgU8v3UE5esLshxJn7OqR4Wkl3UsSsMk4fP NTfrH46240P0BbPyai7XS3y1tu7UxR0YF6HJ5weZo43jLABiKI6/BQIRjH5RT22/hYBP ktoT9G8xB/RJIlvEqZbM7cdKNNhnyte2HbEOsvvL8hjPpVL1xfJRLgw+EnurSqoTJ5gg Dxkg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 28si8812488pgw.364.2018.11.28.14.23.07; Wed, 28 Nov 2018 14:23:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727301AbeK2JYj (ORCPT + 99 others); Thu, 29 Nov 2018 04:24:39 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:33221 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727223AbeK2JYi (ORCPT ); Thu, 29 Nov 2018 04:24:38 -0500 Received: from localhost ([127.0.0.1] helo=bazinga.breakpoint.cc) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1gS8Cy-0001GX-3f; Wed, 28 Nov 2018 23:21:24 +0100 From: Sebastian Andrzej Siewior To: linux-kernel@vger.kernel.org Cc: x86@kernel.org, Andy Lutomirski , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , kvm@vger.kernel.org, "Jason A. Donenfeld" , Rik van Riel , Dave Hansen , Sebastian Andrzej Siewior Subject: [PATCH 24/29] x86/fpu: Prepare copy_fpstate_to_sigframe() for TIF_NEED_FPU_LOAD Date: Wed, 28 Nov 2018 23:20:30 +0100 Message-Id: <20181128222035.2996-25-bigeasy@linutronix.de> X-Mailer: git-send-email 2.20.0.rc1 In-Reply-To: <20181128222035.2996-1-bigeasy@linutronix.de> References: <20181128222035.2996-1-bigeasy@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rik van Riel The FPU registers need only to be saved if TIF_NEED_FPU_LOAD is not set. Otherwise this has been already done and can be skipped. Signed-off-by: Rik van Riel Signed-off-by: Sebastian Andrzej Siewior --- arch/x86/kernel/fpu/signal.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/fpu/signal.c b/arch/x86/kernel/fpu/signal.c index d8c2242877040..6e516eeaea328 100644 --- a/arch/x86/kernel/fpu/signal.c +++ b/arch/x86/kernel/fpu/signal.c @@ -156,7 +156,16 @@ int copy_fpstate_to_sigframe(void __user *buf, void __user *buf_fx, int size) sizeof(struct user_i387_ia32_struct), NULL, (struct _fpstate_32 __user *) buf) ? -1 : 1; - copy_fpregs_to_fpstate(fpu); + __fpregs_changes_begin(); + /* + * If we do not need to load the FPU registers at return to userspace + * then the CPU has the current state and we need to save it. Otherwise + * it is already done and we can skip it. + */ + if (!test_thread_flag(TIF_NEED_FPU_LOAD)) + copy_fpregs_to_fpstate(fpu); + + __fpregs_changes_end(); if (using_compacted_format()) { copy_xstate_to_user(buf_fx, xsave, 0, size); -- 2.20.0.rc1