Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1739038imu; Wed, 28 Nov 2018 14:23:27 -0800 (PST) X-Google-Smtp-Source: AFSGD/VXAfvtOdEbQjXDhjx/MpFVe3YYDMAhYGSnPd7jUJlTBv1vQi2lIZQikJc6+mDtJijo4hV2 X-Received: by 2002:a63:e40c:: with SMTP id a12mr6642619pgi.28.1543443807367; Wed, 28 Nov 2018 14:23:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543443807; cv=none; d=google.com; s=arc-20160816; b=JtdWGSrcx6fkfi57eqvFBWrcaEoRvgQogCCKiL0LBi/XUMrwkL5LuPQtyyoPmzEhIz EztU04/3lzxOtZz0SllkJMJv3oGG9C2Wz5WUBxzQMfvbwt1/G3ihDwKMXObxSZKzhe+s W3J8aeAhYdiZPTdW9DJ+odq8y09uVGgtOQw0/oVRCtPs2aaokhLG3AQz8N1UMJrJizD2 2FEyqoi31LBR8dCPd9IMtPS3y3djwvFvRpuvHi3FBIfIunh+yUOo9dPr3y1aNYpk2JrM ZwfIMxXnYB7RAuVaAlx7bVepp5Wl6SABlOcbdQy5JV6mqy9jGU2CGhvUzqiOkkdEQe0g t4tg== 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=fGO4v9JOopKE1H4v77MgIsE4izC2JxKv+NTQX2q62n4=; b=P3QpE+q/8vN2nGY+ZzewQbMQCRCURbn/fISLCQBNxL0uWyw4XlqeXkPY3Bm1XwAMPp GbxZMSByupktWaVBLIjAPq8CLdFQGai4swHMdL3rj5Pj0mUyTdM4o1GHMk1pDqFMuV/A ryXbSQdOZbDzVHNZZ5sMAcDOEGqFz1zcQKF1Iv+US4ZdjmxerIoUPi8JXgC/U+Wb9KhM 1E+MnCCnvVaA+TpynEdT3rDkk00fDdmYccY8/6zLKKSznKkDNpV3NLR1UOGTjlJgyyg0 RJuBDoVhExO7w4PcADFwK6UvZ29cpVXWCEOR3Oot14hqWWIXZfuqrYcd7XWK3QGChBHo 15zg== 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 e8si8455017pgn.325.2018.11.28.14.23.12; Wed, 28 Nov 2018 14:23:27 -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 S1727028AbeK2JYX (ORCPT + 99 others); Thu, 29 Nov 2018 04:24:23 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:33144 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726870AbeK2JYW (ORCPT ); Thu, 29 Nov 2018 04:24:22 -0500 Received: from localhost ([127.0.0.1] helo=bazinga.breakpoint.cc) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1gS8Ch-0001GX-Qt; Wed, 28 Nov 2018 23:21:08 +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 15/29] x86/fpu: Remove user_fpu_begin() Date: Wed, 28 Nov 2018 23:20:21 +0100 Message-Id: <20181128222035.2996-16-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 user_fpu_begin() sets fpu_fpregs_owner_ctx to task's fpu struct. This is always the case since there is no lazy FPU anymore. fpu_fpregs_owner_ctx is used during context switch to decide if it needs to load the saved registers or if the currently loaded registers are valid. It could be skipped during taskA -> kernel thread -> taskA because the switch to kernel thread would not alter the CPU's FPU state. Since this field is always updated during context switch and never invalidated, setting it manually (in user context) makes no difference. A kernel thread with kernel_fpu_begin() block could set fpu_fpregs_owner_ctx to NULL but a kernel thread does not use user_fpu_begin(). This is a leftover from the lazy-FPU time. Remove user_fpu_begin(), it does not change fpu_fpregs_owner_ctx's content. Signed-off-by: Sebastian Andrzej Siewior --- arch/x86/include/asm/fpu/internal.h | 17 ----------------- arch/x86/kernel/fpu/core.c | 4 +--- arch/x86/kernel/fpu/signal.c | 1 - 3 files changed, 1 insertion(+), 21 deletions(-) diff --git a/arch/x86/include/asm/fpu/internal.h b/arch/x86/include/asm/fpu/internal.h index 932b4577e2f0f..a8b4c1e92c010 100644 --- a/arch/x86/include/asm/fpu/internal.h +++ b/arch/x86/include/asm/fpu/internal.h @@ -558,23 +558,6 @@ static inline void switch_fpu_finish(struct fpu *new_fpu, int cpu) } } -/* - * Needs to be preemption-safe. - * - * NOTE! user_fpu_begin() must be used only immediately before restoring - * the save state. It does not do any saving/restoring on its own. In - * lazy FPU mode, it is just an optimization to avoid a #NM exception, - * the task can lose the FPU right after preempt_enable(). - */ -static inline void user_fpu_begin(void) -{ - struct fpu *fpu = ¤t->thread.fpu; - - preempt_disable(); - fpregs_activate(fpu); - preempt_enable(); -} - /* * MXCSR and XCR definitions: */ diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c index 3a4668c9d24f1..78d8037635932 100644 --- a/arch/x86/kernel/fpu/core.c +++ b/arch/x86/kernel/fpu/core.c @@ -335,10 +335,8 @@ void fpu__clear(struct fpu *fpu) * Make sure fpstate is cleared and initialized. */ fpu__initialize(fpu); - if (static_cpu_has(X86_FEATURE_FPU)) { - user_fpu_begin(); + if (static_cpu_has(X86_FEATURE_FPU)) copy_init_fpstate_to_fpregs(); - } } /* diff --git a/arch/x86/kernel/fpu/signal.c b/arch/x86/kernel/fpu/signal.c index 3a59c578440e2..5f42de8a21deb 100644 --- a/arch/x86/kernel/fpu/signal.c +++ b/arch/x86/kernel/fpu/signal.c @@ -325,7 +325,6 @@ static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size) * For 64-bit frames and 32-bit fsave frames, restore the user * state to the registers directly (with exceptions handled). */ - user_fpu_begin(); if (copy_user_to_fpregs_zeroing(buf_fx, xfeatures, fx_only)) { fpu__clear(fpu); return -1; -- 2.20.0.rc1