Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp5992144ybc; Wed, 27 Nov 2019 13:03:12 -0800 (PST) X-Google-Smtp-Source: APXvYqwri48wSbu7KhwZ3mrq62PUqx238FwX09kF6LAgcGMDyIGnBuSxb4bvE94og6vRdpS77OX7 X-Received: by 2002:a50:8c02:: with SMTP id p2mr34193569edp.30.1574888592710; Wed, 27 Nov 2019 13:03:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574888592; cv=none; d=google.com; s=arc-20160816; b=fY7nm10Bg5hTxRhvikoq5/UNeCKG5hnmClbVec8rWcn8y0+7SO87jusptpZcBpns/j Kv5P7zhvv33Rk2vzqXsOO3wsc1QIh7Bxl5OxcXRD6BE8iNVH1tMLgeXyjXpm1oB2cCoY MxichHCNtLGN6X3Bnbt6Llcqodbd/KYaCk/j0jA0APKmyCQPaxxTmcHqb9XfeTQtri8X 97kw+tlVE7Minvvum5ejZmNGaCLc84rRwBsA845oDsYUjTX+ENb+DnaUe/r/jSklfbF3 K8EiFv0P3S86/FdBkBvE8wZLrZRIrzdomRojbi6CWQh4QY9kajYltAYEqQ07SLdrJWr0 AdnA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2WOChZ4VaXngSUTWvphDvL0v5rqZ1i1HsuO5bM2jO7Y=; b=JBnpr3oRPNSsb3nXRY97g84cQA2XO1vK3e1ima0ZuIj3naOY+7nsGbNTIxkEQABagZ JXqy7u2t93C3vkb8UrEyXB2XGTCZSGKGIaQypoGkSquSYhFcHPgQz+LZ8peWbVd6/70s hz0f/kH38jDcrodOcNaCVexAXtOiCVgxVYvprPd51g6Z3GY3i2fRMakQlaTl/FrdiYBu rZYggyTZWzC7Xc1I1XwpQkAh/RbrmE96qZaYAK2je9t+IYsHZxhdjcD95uSx4G/zmZVd 4ntlMvR9s7dETu1hex57jXllsNP3jWrcVQ7rHZdpPnG8bmlrkvdIA//Tqvmi6MBZv3bY M2xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aTBrLGKx; 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 e7si12659162ede.66.2019.11.27.13.02.48; Wed, 27 Nov 2019 13:03:12 -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; dkim=pass header.i=@kernel.org header.s=default header.b=aTBrLGKx; 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 S1731741AbfK0VBt (ORCPT + 99 others); Wed, 27 Nov 2019 16:01:49 -0500 Received: from mail.kernel.org ([198.145.29.99]:54242 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731206AbfK0VBs (ORCPT ); Wed, 27 Nov 2019 16:01:48 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E1649217AB; Wed, 27 Nov 2019 21:01:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888507; bh=zWF5U4xg7nt3/h5P3T6bRnH5eZb0im/xahs52GP8njM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aTBrLGKxRP+20BisoB0ufDZsCugsq8/rUYK3d4EoRfADyYMm/Gco2mTWssx47vAL9 kcX1L+byUDVUDwEs40x0oN7B1S7JALmIwMuOcLthInWBBEdeWM4nEs1ML3L5NjDPMd axexLQjjUNl/IIOxeKYPfGNRht43K80y8XIm5cVc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Felipe Rechia , Michael Ellerman , Sasha Levin Subject: [PATCH 4.19 144/306] powerpc/process: Fix flush_all_to_thread for SPE Date: Wed, 27 Nov 2019 21:29:54 +0100 Message-Id: <20191127203125.902612534@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203114.766709977@linuxfoundation.org> References: <20191127203114.766709977@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Felipe Rechia [ Upstream commit e901378578c62202594cba0f6c076f3df365ec91 ] Fix a bug introduced by the creation of flush_all_to_thread() for processors that have SPE (Signal Processing Engine) and use it to compute floating-point operations. >From userspace perspective, the problem was seen in attempts of computing floating-point operations which should generate exceptions. For example: fork(); float x = 0.0 / 0.0; isnan(x); // forked process returns False (should be True) The operation above also should always cause the SPEFSCR FINV bit to be set. However, the SPE floating-point exceptions were turned off after a fork(). Kernel versions prior to the bug used flush_spe_to_thread(), which first saves SPEFSCR register values in tsk->thread and then calls giveup_spe(tsk). After commit 579e633e764e, the save_all() function was called first to giveup_spe(), and then the SPEFSCR register values were saved in tsk->thread. This would save the SPEFSCR register values after disabling SPE for that thread, causing the bug described above. Fixes 579e633e764e ("powerpc: create flush_all_to_thread()") Signed-off-by: Felipe Rechia Signed-off-by: Michael Ellerman Signed-off-by: Sasha Levin --- arch/powerpc/kernel/process.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c index 909c9407e392a..02b69a68139cc 100644 --- a/arch/powerpc/kernel/process.c +++ b/arch/powerpc/kernel/process.c @@ -575,12 +575,11 @@ void flush_all_to_thread(struct task_struct *tsk) if (tsk->thread.regs) { preempt_disable(); BUG_ON(tsk != current); - save_all(tsk); - #ifdef CONFIG_SPE if (tsk->thread.regs->msr & MSR_SPE) tsk->thread.spefscr = mfspr(SPRN_SPEFSCR); #endif + save_all(tsk); preempt_enable(); } -- 2.20.1