Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5478744imm; Wed, 12 Sep 2018 06:38:36 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdan76x22E/HvgCDd5j5cJAoTyHPyz3jzTO9X5VBkbo3mNz+8OSa317JURS95LGDoy1Td6Jk X-Received: by 2002:a17:902:4203:: with SMTP id g3-v6mr2402818pld.30.1536759516618; Wed, 12 Sep 2018 06:38:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536759516; cv=none; d=google.com; s=arc-20160816; b=BXcyC2pPA1T6VzEbMqJAmaeERtuLA5ugnlj2a8o4UcuFI72S+BaDFJSt3HNSjmbOSG a9yKEHBFQb4J7QRu0fuk1oDdTGeUh+7mNCqFrmK70BOdrXPW8HXVc4wLdQgrHsUQOnth P9T4pYyYFawnlV8AzrKVyO+UU57Vv7x/T0zKbGwrIJYFfuEr1Fen/tHcLWP9IVNe2vd+ SJeE9fGJpMDXAzAmBK3mV0NjLiU4Hyulynp/fZMT/qvWIVZdbsWPvnT15RxYCFxUBT72 fo/pMQE3czyuq1ctRog3GcHA2ENaWD35fMauGVFPpmfrmyvleqyrJb/ENptabt1aRkp2 AEUA== 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=msvYhIy8PxMYEZeANF6wkIsDuHjr8UqHaEf3brbXgPw=; b=p8Uy/eZWhZQcc/Kn+gym7VyJsEOknWX0h1XG3Yd6sElnqNPEXDU1QRh9Cl4WaKDVfJ HnX40+aFbllWxcopikN+Gw0qDd3Y7pokQNA/WrBjk9WyHP9vqXVp8ue/JvvhqogDAd45 e7qPmHUcs0kPCemav9QFPb5H9ZLAG7meBzlrnC5CrPVleM+kGDBWmg5+iGrvLs7dHGnk k4I7rEOCwYlpAjXgbIrvMex6/RxKarQOjQFzvsD9efI3dFGvqyYSXDnI6JXnGUbOxgfD iMy6Msxszyc642c6ug1dj09RU78s6VSZ5LB6gksl4T5DZSi3QB9Dl3Fja6Vr352z8/4n fXKg== 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 y6-v6si1010777pfy.140.2018.09.12.06.38.12; Wed, 12 Sep 2018 06:38:36 -0700 (PDT) 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 S1728168AbeILSlD (ORCPT + 99 others); Wed, 12 Sep 2018 14:41:03 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:43916 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728038AbeILSkf (ORCPT ); Wed, 12 Sep 2018 14:40:35 -0400 Received: from localhost ([127.0.0.1] helo=bazinga.breakpoint.cc) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1g05JF-0001Ap-Il; Wed, 12 Sep 2018 15:35:57 +0200 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 , Sebastian Andrzej Siewior Subject: [RFC PATCH 08/10] x86/fpu: prepare copy_fpstate_to_sigframe for TIF_LOAD_FPU Date: Wed, 12 Sep 2018 15:33:51 +0200 Message-Id: <20180912133353.20595-9-bigeasy@linutronix.de> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180912133353.20595-1-bigeasy@linutronix.de> References: <20180912133353.20595-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 If TIF_LOAD_FPU is set, then the registers are saved (not loaded). In that case we skip the saving part. Signed-off-by: Rik van Riel Signed-off-by: Sebastian Andrzej Siewior --- arch/x86/kernel/fpu/signal.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/fpu/signal.c b/arch/x86/kernel/fpu/signal.c index ff6e7a67522d8..906efd9572ffa 100644 --- a/arch/x86/kernel/fpu/signal.c +++ b/arch/x86/kernel/fpu/signal.c @@ -155,13 +155,17 @@ 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; - /* Update the thread's fxstate to save the fsave header. */ - if (ia32_fxstate) - copy_fxregs_to_kernel(fpu); - else { - copy_fpregs_to_fpstate(fpu); - fpregs_deactivate(fpu); + __fpregs_changes_begin(); + if (!test_thread_flag(TIF_LOAD_FPU)) { + /* Update the thread's fxstate to save the fsave header. */ + if (ia32_fxstate) + copy_fxregs_to_kernel(fpu); + else { + copy_fpregs_to_fpstate(fpu); + fpregs_deactivate(fpu); + } } + __fpregs_changes_end(); if (using_compacted_format()) { copy_xstate_to_user(buf_fx, xsave, 0, size); -- 2.19.0