Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3537752imu; Wed, 7 Nov 2018 11:52:54 -0800 (PST) X-Google-Smtp-Source: AJdET5c5zC5VgiNw1bCT0evXRSLbFP8/bf0/4O2kCfP3eQwNhnJw9iNqD5HzBXQdhL6Q7fZkqrhg X-Received: by 2002:a17:902:6b82:: with SMTP id p2-v6mr1636920plk.50.1541620373988; Wed, 07 Nov 2018 11:52:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541620373; cv=none; d=google.com; s=arc-20160816; b=pQklhn8h7k+bd3qKoLRI6dAcTWWcmJKz9A9ta+PBvwMusQwauVfwOgjdEPr5JP6TAq iDfzUd37rmxnDYmMcHF04edFL6AvL5PP/wbBFBVcwa1z2s6Xa7a6S4iavyFkbDIiPpdz RkRVeB895GupDIn+CgjpMHcqP5hlb/79fhsSYyLUgq8HwjGftn44m4qJKksjThaz02bs ybiay4WCBpTxXmd21sLke9NOZrxPULYzlNggkn9fIs+xCY81WiVJgxmFVHL3a3+PO983 tMramus2tV2dTBY+/re0+zZJPOzo3mqKVumiLbYE21bvOhGvMX2qkoamOLi/FGQOIvtm nEoA== 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=zugfUpSJMqop9VIeTUEsJL4JVK3HXyJfHdjTzVOfz9I=; b=CXJ0V9u7uxh95vCoiaJ2NIYMTPT3xMWv8sl8UJzk0aYPoCbNVs7EuTw+Zf+OZdHs7U 6OurH/bXxcOrjgsLkSR3gERPGIXgFxWj+EZ+Glz+C9KHTe+rxOwxZB/f5zIUEdWhIN14 ak+uqIj+Ecw+znim5TIyB4D1s17z1gREGELBbxxnkHQSlLeHyfN6FGJaMNX+GFkRrUDg /mvwreUPSKbmAAY5UdBFBONFMXsbqr5sIGnSGiT9JBpOLzignxvhGoeCp/q1t7L85xyW HCK7VOZoUeP2Rg7Gvr/Fj2paaSIVyfNKNE3C7j/34adm+AX74ovYhyY2goKnSNnEgyeX yXvQ== 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 p61-v6si1619989plb.382.2018.11.07.11.52.38; Wed, 07 Nov 2018 11:52:53 -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 S1727238AbeKHFVF (ORCPT + 99 others); Thu, 8 Nov 2018 00:21:05 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:41851 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726435AbeKHFVF (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 1gKTp8-00070Q-DB; Wed, 07 Nov 2018 20:49:10 +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 06/23] x86/fpu: Always init the `state' in fpu__clear() Date: Wed, 7 Nov 2018 20:48:41 +0100 Message-Id: <20181107194858.9380-7-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 fpu__clear() only initializes the `state' if the FPU is present. This initialisation is also required for the FPU-less system and takes place math_emulate(). Since fpu__initialize() only performs the initialization if ->initialized is zero it does not matter that it is invoked each time an opcode is emulated. It makes the removal of ->initialized easier if the struct is also initialized in FPU-less case at the same time. Move fpu__initialize() before the FPU check so it is also performed in FPU-less case. Signed-off-by: Sebastian Andrzej Siewior --- arch/x86/include/asm/fpu/internal.h | 1 - arch/x86/kernel/fpu/core.c | 5 ++--- arch/x86/math-emu/fpu_entry.c | 3 --- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/arch/x86/include/asm/fpu/internal.h b/arch/x86/include/asm/fpu/internal.h index 32ea458f13b5c..971fb0988d56f 100644 --- a/arch/x86/include/asm/fpu/internal.h +++ b/arch/x86/include/asm/fpu/internal.h @@ -24,7 +24,6 @@ /* * High level FPU state handling functions: */ -extern void fpu__initialize(struct fpu *fpu); extern void fpu__prepare_read(struct fpu *fpu); extern void fpu__prepare_write(struct fpu *fpu); extern void fpu__save(struct fpu *fpu); diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c index b7d9b19ab8116..8391debc57265 100644 --- a/arch/x86/kernel/fpu/core.c +++ b/arch/x86/kernel/fpu/core.c @@ -225,7 +225,7 @@ int fpu__copy(struct fpu *dst_fpu, struct fpu *src_fpu) * Activate the current task's in-memory FPU context, * if it has not been used before: */ -void fpu__initialize(struct fpu *fpu) +static void fpu__initialize(struct fpu *fpu) { WARN_ON_FPU(fpu != ¤t->thread.fpu); @@ -238,7 +238,6 @@ void fpu__initialize(struct fpu *fpu) fpu->initialized = 1; } } -EXPORT_SYMBOL_GPL(fpu__initialize); /* * This function must be called before we read a task's fpstate. @@ -367,8 +366,8 @@ void fpu__clear(struct fpu *fpu) /* * Make sure fpstate is cleared and initialized. */ + fpu__initialize(fpu); if (static_cpu_has(X86_FEATURE_FPU)) { - fpu__initialize(fpu); user_fpu_begin(); copy_init_fpstate_to_fpregs(); } diff --git a/arch/x86/math-emu/fpu_entry.c b/arch/x86/math-emu/fpu_entry.c index 9e2ba7e667f61..a873da6b46d6b 100644 --- a/arch/x86/math-emu/fpu_entry.c +++ b/arch/x86/math-emu/fpu_entry.c @@ -113,9 +113,6 @@ void math_emulate(struct math_emu_info *info) unsigned long code_base = 0; unsigned long code_limit = 0; /* Initialized to stop compiler warnings */ struct desc_struct code_descriptor; - struct fpu *fpu = ¤t->thread.fpu; - - fpu__initialize(fpu); #ifdef RE_ENTRANT_CHECKING if (emulating) { -- 2.19.1