Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1740666imu; Wed, 28 Nov 2018 14:25:41 -0800 (PST) X-Google-Smtp-Source: AFSGD/XKxXbhQUziYxTw6d0eZ281Y+yhjwkf1z6Ixdy6d3O1NdRn25s7iHTD/xAFJ1WJhs5bAKg0 X-Received: by 2002:a62:1d4c:: with SMTP id d73mr25665131pfd.90.1543443940885; Wed, 28 Nov 2018 14:25:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543443940; cv=none; d=google.com; s=arc-20160816; b=ii3LW9dPkyPtkb4JX2va/dHMTUhQxXvclRRxze6uHvZXPSOLlfYVo1xLNI/OSD8vqJ 0VBt0+ZRkAiL8caTCdsBL90kb9SKB0TWsnFhL7NFLjFhLpVa8st4Js0sP3uFGq7VoOJM t9qo7lSYPDeePXzU7fA33Piy4GC1BsD+Wm9YkhYYS1WEuFnHIoRp2MrJtXUwNL+BCvzE EW6M5BEh46+1btDuZqyUPkiw0+n07yoYVeCWBzZp159QQDwIuW2IHcJqkvY6+vl/laqW EV9iF35VUEJctpid3vMBcF+DB8AgFLdDBgY99qv4HdillhoaYhe9KqOP7963dnc58ODe fEmg== 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=vKccwk9QnY5BOrggHhP0vr46Ja6nCgkNtjO3ScigU1U=; b=HHi4CtdaazS7gUCfZeRyxzfkTGPMU6Qv1hkQ6Y0yXqQxBTOUcogVY8jtesmv+EvhuK 9+qaKfdCgBLbViTo8aID48MQCS48pwrblqKviLpclipF7c5lg+Bj9VdF2I9CBeyvkFkx wjbQw049OqdD5sRj+srEuDEihnm/tE0/b7GcwxDaw2E2/5zGZeGuoayICgKlmhLOauQ2 rExWakrNnIePkzG5xHouTQm0WGQSzQnPkh7gYY1GdI2eqTAu/0UmrNQzExP9r8B79Vy7 6SzTfZWbMY3hX1JcAWLxhCEr0GN5N9GLLivl72vR+hGh1TqnWGAbvV6xG38gtc08tiqr JqZg== 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 p14si9073185pfi.12.2018.11.28.14.25.26; Wed, 28 Nov 2018 14:25:40 -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 S1726935AbeK2JYS (ORCPT + 99 others); Thu, 29 Nov 2018 04:24:18 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:33119 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726734AbeK2JYR (ORCPT ); Thu, 29 Nov 2018 04:24:17 -0500 Received: from localhost ([127.0.0.1] helo=bazinga.breakpoint.cc) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1gS8Cd-0001GX-Bv; Wed, 28 Nov 2018 23:21:03 +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 12/29] x86/fpu: Remove fpu->initialized usage in copy_fpstate_to_sigframe() Date: Wed, 28 Nov 2018 23:20:18 +0100 Message-Id: <20181128222035.2996-13-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 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 9c35598697b94..42e0f98f34f54 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.20.0.rc1