Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3539216imu; Wed, 7 Nov 2018 11:54:17 -0800 (PST) X-Google-Smtp-Source: AJdET5ci0k+JjmbexpBi1LVuu3lMxB5g/aZ7CjDZ5F2YC3fZTpDBN/UMfzEKQYXpx59v60F3kZf5 X-Received: by 2002:a63:62c3:: with SMTP id w186mr1358054pgb.345.1541620457058; Wed, 07 Nov 2018 11:54:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541620457; cv=none; d=google.com; s=arc-20160816; b=OdjnYKqDW5R4CCpJ2rtTj4fGNzlfR9LFD63vgY0py7Yta/goWGDdosdc9jZVY7faGm +CyTesrrVgPBgjnBZOflk5XpxiS3Ibm/A51aB5LyL+1HxRW7gORvG69FCWPCQjHJKY6K kV4BpFsk4vQsB0qVAbkAHKIZIlpwoLgyHZNOGitovYhkwc2cXDzvANomOOju7QBa4clJ ApharvBTsoIiMGIX4kvPxf8Bb5Zx3Py97BKWCP6wxxzXYaP098SMQ/jZD7kL7iCuRZqq jQHdDg5wvJbD3Ii8HrtO7+sCGZWcnXW0fNli0/5MTdCABLErKl2WgGYeVGZMlMACwoaz dKyg== 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=cJkmmcx/TAubOFsA83SVWrNputIGMetJYXNiDNNMfA0=; b=sf/SiYafLq+b+VC50jNwtrsXDNm2D2//TozR8RStaZ9YomNzI/r5Fuhuk9LTEPcPNL KM10e+9t+BmkTy3l7jbxHoqHS1Z0yedRPn+PTsZYbZ7YKtDPLFWZt6NMogYqPN3bsakc f5A5y+WV8fejQcOyKCxAFgyJ0+UzutzGaJ0FP8g+QBnoSi8dqgGe7xKcaaNe+CGmpBDu pR2aKwuTTayV5MwSMAkpFGvNcyfLDUDl3UJa1948Av7tpvtRBMNJexpxtvDHBP0yrMzj 9PrT9W/cPjVSxhcbCKbMCDYZLB0y8Any1jWDwLyAVoPn23Q5Uzd8XLKzV12go0zlzY1R GLJA== 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 5-v6si1500429plx.310.2018.11.07.11.54.02; Wed, 07 Nov 2018 11:54:17 -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 S1727271AbeKHFVG (ORCPT + 99 others); Thu, 8 Nov 2018 00:21:06 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:41861 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725953AbeKHFVF (ORCPT ); Thu, 8 Nov 2018 00:21:05 -0500 Received: from localhost ([127.0.0.1] helo=bazinga.breakpoint.cc) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1gKTp9-00070Q-7D; Wed, 07 Nov 2018 20:49:11 +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 07/23] x86/fpu: Remove fpu->initialized usage in copy_fpstate_to_sigframe() Date: Wed, 7 Nov 2018 20:48:42 +0100 Message-Id: <20181107194858.9380-8-bigeasy@linutronix.de> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181107194858.9380-1-bigeasy@linutronix.de> References: <20181107194858.9380-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 Since ->initialized is always true for user tasks and kernel threads don't get this far, we always save the registers directly to userspace. Remove check for ->initialized because it is always true and remove the false condition. Signed-off-by: Sebastian Andrzej Siewior --- arch/x86/kernel/fpu/signal.c | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/arch/x86/kernel/fpu/signal.c b/arch/x86/kernel/fpu/signal.c index 5777ee0c32fed..30e65085dc4d9 100644 --- a/arch/x86/kernel/fpu/signal.c +++ b/arch/x86/kernel/fpu/signal.c @@ -157,7 +157,6 @@ static inline int copy_fpregs_to_sigframe(struct xregs_state __user *buf) int copy_fpstate_to_sigframe(void __user *buf, void __user *buf_fx, int size) { struct fpu *fpu = ¤t->thread.fpu; - struct xregs_state *xsave = &fpu->state.xsave; struct task_struct *tsk = current; int ia32_fxstate = (buf != buf_fx); @@ -172,29 +171,12 @@ 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; - if (fpu->initialized || using_compacted_format()) { - /* Save the live register state to the user directly. */ - if (copy_fpregs_to_sigframe(buf_fx)) - return -1; - /* Update the thread's fxstate to save the fsave header. */ - if (ia32_fxstate) - copy_fxregs_to_kernel(fpu); - } else { - /* - * It is a *bug* if kernel uses compacted-format for xsave - * area and we copy it out directly to a signal frame. It - * should have been handled above by saving the registers - * directly. - */ - if (boot_cpu_has(X86_FEATURE_XSAVES)) { - WARN_ONCE(1, "x86/fpu: saving compacted-format xsave area to a signal frame!\n"); - return -1; - } - - fpstate_sanitize_xstate(fpu); - if (__copy_to_user(buf_fx, xsave, fpu_user_xstate_size)) - return -1; - } + /* Save the live register state to the user directly. */ + if (copy_fpregs_to_sigframe(buf_fx)) + return -1; + /* Update the thread's fxstate to save the fsave header. */ + if (ia32_fxstate) + copy_fxregs_to_kernel(fpu); /* Save the fsave header for the 32-bit frames. */ if ((ia32_fxstate || !use_fxsr()) && save_fsave_header(tsk, buf)) -- 2.19.1