Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp917893imu; Thu, 13 Dec 2018 06:37:25 -0800 (PST) X-Google-Smtp-Source: AFSGD/UKKksYybxEdu8nCbvsCqxRWGN63r2SeCD9LFvzCXLNVpT1VMqo8epa0ooYKovDVjr7o4iu X-Received: by 2002:a62:6f88:: with SMTP id k130mr24131202pfc.234.1544711845871; Thu, 13 Dec 2018 06:37:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544711845; cv=none; d=google.com; s=arc-20160816; b=Gam6LIe5KS78aSwucxDJ/u8xvRyQKbmKQN92QiT3k2pJtW70+M7RufyVXGx9XSFHON 6Ba4mUB6tpZBEFhyBWWa4KjeUi8xm2kf9bMVYxOhZgMGm5CTzuknpkSitiKmzt3okSPm OK8NyWH66NSWL2mVoRBrzE3A1esE3Z1zp+n1rhikNzyQ9gtfFjVCnvBfo9QcWwa7do8v bxSdI9i3cegHL/y+BMrDP+3s5PtOlhYPqGs97clJHysYFGNUKHJz0+uzTiyIOrw3VXOq pNBqIZaLxZHzqtACY5lwREKMSCAcd3Fpdjzo3dA7hBPaKjKYzVb4/h80yajHa9kZ2/GL oMVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=3tT9OycFCfDwn90bOkIdKY47Osa0u1wU3YSf3XpK/es=; b=n0KrRIq5VcjgTCGYBxkFiWKn24Hy9nUVGAfmTWAJXS3lT+QUZxD8iU4HgnSppQJeYS APB46E33nLgsJD0k/zUoaSt9LRF/SIXOi+l27Eh1qBy2YgAIpQnc7xYgeAsfAxZMqkaf grEJvkwXHV1ru4/Tccb2IkDDGOW3LNFi67nwekMv22kbdSNoR0aShkOQl0kFLJWoHLXD vq1VLbg22dNEHBmDfmhjJnPYAVLLW7YvaQnYXk/no/y8Rd497MjtAW4SMdNhXzOVBvyf SrTdgfXd7MNdCTnwazABcZWSnsiW+FwNF79TpIjY8rNPCzG31uI/5a3WaLE2aL3R19fA EPog== 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 b11si1673157pla.405.2018.12.13.06.37.10; Thu, 13 Dec 2018 06:37:25 -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 S1728850AbeLMOf7 (ORCPT + 99 others); Thu, 13 Dec 2018 09:35:59 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:46703 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728591AbeLMOf7 (ORCPT ); Thu, 13 Dec 2018 09:35:59 -0500 Received: from bigeasy by Galois.linutronix.de with local (Exim 4.80) (envelope-from ) id 1gXS5h-0001kD-Nd; Thu, 13 Dec 2018 15:35:53 +0100 Date: Thu, 13 Dec 2018 15:35:53 +0100 From: Sebastian Andrzej Siewior To: Borislav Petkov Cc: linux-kernel@vger.kernel.org, x86@kernel.org, Andy Lutomirski , Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , kvm@vger.kernel.org, "Jason A. Donenfeld" , Rik van Riel , Dave Hansen Subject: Re: [PATCH 11/29] x86/fpu: Always init the `state' in fpu__clear() Message-ID: <20181213143553.7ktfajxeewgiclxa@linutronix.de> References: <20181128222035.2996-1-bigeasy@linutronix.de> <20181128222035.2996-12-bigeasy@linutronix.de> <20181212171129.GD6653@zn.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20181212171129.GD6653@zn.tnic> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-12-12 18:11:29 [+0100], Borislav Petkov wrote: > > 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); > > Ok, you're removing it here but where is the FPU going to be initialized > now in the FPU-less case? > > IOW, it is not clear to me where fpu__clear() get called for the FPU > emulation case now... During fork() fpu__initialize() is called for both (with and without FPU) systems. The difference is made in fpu__clear() where the init is avoided in the FPU-less case. With this hunk: --- a/arch/x86/kernel/fpu/core.c +++ b/arch/x86/kernel/fpu/core.c @@ -365,8 +364,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(); } we have the initialization in both cases. The only "negative" thing might be that we now have a memset(, 0, 684) (fpstate_init_soft()) during fork which would be avoided in case the FPU-less system has a userland which is compiled with a soft-FPU toolchain. I would worry about it once someone complains (and I doubt someone complains even if we remove soft FPU support). Sebastian