Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3538684imu; Wed, 7 Nov 2018 11:53:46 -0800 (PST) X-Google-Smtp-Source: AJdET5dE875w2ZdmN9YhT6uJnjWSZZKj6OfZlSQnM57hNTTUzWxjr6Em/lT0GY1Vx5ZNZ0HvtXNZ X-Received: by 2002:a62:b0b:: with SMTP id t11-v6mr1095924pfi.93.1541620426038; Wed, 07 Nov 2018 11:53:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541620426; cv=none; d=google.com; s=arc-20160816; b=lXJT5f+ntN9BXAG2ssXX1b7q/ZKafgdwQWqjRFkV4Dam3UAzC8x83N01exP2BxEC7q p7kilSJqeRPwSI9XnORgAQi+FG4yAozH+od+gz1qc+vS0xq9ZaUV/4vA10AiREfWmX2c AEFboTGYtUF2IaqikPefSrvgY50l42pXUvhRwX7vHxY8uniUEeIv/Cxr65LIK76xDOhk SU8iQ/X+gr4422JY1gUMD0v5FE7kP8bnhuR42hI1smZnrDH77bvKPKMY1PtuYws4SoAz T2X2F2cWEMEbCFnHs2rKg20pWX1ycCbCPis7f1xRqgzn7/pRqe9ag/icCsqfYvOYfXEx Hvdg== 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=77YM+edSdVcNNKPbWxQj4HYx6UXchcEvKs+i1EOnCSg=; b=VB8e0y34Ca9VHuHCOzHdGe7w/iM8wkR48ZuIy0LVvXjiiLtrd8vvXQrN0YEQ7pycVY 0DVnfs1HHIaxAo6mRqKvIKRXdNT5a4wU2Z0rYYT36h0L4EqMEFa6wY7/TgCwcjLrqN56 tMadaY4q69JajrZNnj3XBO9hcA9srYA+MY2k1QA0hg6dGccgEjlRZ8AgXckAwg7bD5Wn APSX+zrFwYBIohxz5YYev5vPSN5Dwx0RMxoFeBgLzW0gDOg+BtgaR7XeHG2oAcpKXTYf xzVZedpe4yWzav8fEbyfKu8uuX4uWOqTVT+86LxNN+2hsgQgjMIMzcucUZ3wK0rieQAs DiwA== 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 d3-v6si1639815plj.372.2018.11.07.11.53.26; Wed, 07 Nov 2018 11:53:46 -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 S1727508AbeKHFVM (ORCPT + 99 others); Thu, 8 Nov 2018 00:21:12 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:41895 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726948AbeKHFVM (ORCPT ); Thu, 8 Nov 2018 00:21:12 -0500 Received: from localhost ([127.0.0.1] helo=bazinga.breakpoint.cc) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1gKTpB-00070Q-Ec; Wed, 07 Nov 2018 20:49:13 +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 09/23] x86/fpu: Remove user_fpu_begin() Date: Wed, 7 Nov 2018 20:48:44 +0100 Message-Id: <20181107194858.9380-10-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 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. This field is always updated on context switch so setting it manually has no benefit. Before the removal of the ->initialized member, fpu_fpregs_owner_ctx wouldn't be updated for kernel threads. But kernel threads don't use the fpu struct so again, user_fpu_begin() would not make a difference in user context (and would be wrong in kernel context). 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 d7ef8ac8b17eb..d7f9e14c73c19 100644 --- a/arch/x86/include/asm/fpu/internal.h +++ b/arch/x86/include/asm/fpu/internal.h @@ -559,23 +559,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 2ed82c6e646b9..02bbd40fe1e95 100644 --- a/arch/x86/kernel/fpu/core.c +++ b/arch/x86/kernel/fpu/core.c @@ -328,10 +328,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 30e65085dc4d9..f61f4d804537a 100644 --- a/arch/x86/kernel/fpu/signal.c +++ b/arch/x86/kernel/fpu/signal.c @@ -328,7 +328,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.19.1