Received: by 10.223.185.116 with SMTP id b49csp6384159wrg; Wed, 28 Feb 2018 08:31:36 -0800 (PST) X-Google-Smtp-Source: AH8x227duGQMqvf5R59OBB7Bpa+RjH1zGAHvG5CiDS2GXfEMax34iXQDen9F4BCCC1Qejrc8l7V/ X-Received: by 10.101.77.195 with SMTP id q3mr14119809pgt.283.1519835495930; Wed, 28 Feb 2018 08:31:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519835495; cv=none; d=google.com; s=arc-20160816; b=GiOI6TuCDQFjNLjHEiM8YqDFNHRhUFZFEMhLIOskpWIaErH3wTkX+qLukWj3cTkryJ 33KFesOWZtIaOgQltwMVYyoICENDToK35q6suVPTtMrzXEee2sbMQSyeIFcU2IA+NYiG bCsp7PGJ8q2qOgnbTHMHeuOv7PZL3tYl+mQiWM9zBU2OfUylAJO6CEvIzfm5/P0lfrNW 9dGYbaOMov/ubAgDVDtbjzAQdMftYJsfxl287z/8m0vKLQ6e672eFMbsG/dpd547crPZ kY3U2PFI2VentDr4ZE+un9TYbBQz3fGECKSd7ePKW0DrYUs5UjcnIG/1kpV6l2r087V9 K6jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=ud4XTHsc1Juhg2zrvLWH1oE6lWQaH1fhpiSgS08ehoo=; b=dsHLfUdkvj0L7DTx8/N2en0LBEzHRQSyTcNygJURZWfJPEPjTTuCfc+YcXJq6I7KlM SN07lJNMAXS7SJaqug90U3CmjV3qJdTj2+euI/0bVGs/EvsN3Y98fQ+r0tYlF0zOv+G5 vtAJ0Kisj7BaBSlueAq6QnQdatUrpgTTjCWKwxlckv12n68OSOi/e34SxO6gTGMU3Aio E6gdaUe4tvN2/1SA/jqCkB8pruQEK7NMD8IrC7Tm6CmvimE2LVJyf7prD/zU5a1Tdbw3 FWCIkgSmLSlZG2/M8wXamq2PEK8frqTb/gN+4Ak4TGwxImXbWnCF0WBgO7bvQ7a9CuCC fsTA== 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 u36si1204650pgn.702.2018.02.28.08.31.20; Wed, 28 Feb 2018 08:31:35 -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 S934787AbeB1QPQ (ORCPT + 99 others); Wed, 28 Feb 2018 11:15:16 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:35163 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934530AbeB1QPN (ORCPT ); Wed, 28 Feb 2018 11:15:13 -0500 Received: from [2a02:8011:400e:2:6f00:88c8:c921:d332] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1er3Yt-0006Xe-Gp; Wed, 28 Feb 2018 15:22:31 +0000 Received: from ben by deadeye with local (Exim 4.90_1) (envelope-from ) id 1er3Yg-0008WF-7V; Wed, 28 Feb 2018 15:22:18 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Maciej W. Rozycki" , linux-mips@linux-mips.org, "Ralf Baechle" Date: Wed, 28 Feb 2018 15:20:18 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 097/254] MIPS: Always clear FCSR cause bits after emulation In-Reply-To: X-SA-Exim-Connect-IP: 2a02:8011:400e:2:6f00:88c8:c921:d332 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.55-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: "Maciej W. Rozycki" commit 443c44032a54f9acf027a8e688380fddc809bc19 upstream. Clear any FCSR cause bits recorded in the saved FPU context after emulation in all cases rather than in `do_fpe' only, so that any unmasked IEEE 754 exception left from emulation does not cause a fatal kernel-mode FPE hardware exception with the CTC1 instruction used by the kernel to subsequently restore FCSR hardware from the saved FPU context. Signed-off-by: Maciej W. Rozycki Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/9704/ Signed-off-by: Ralf Baechle [bwh: Backported to 3.16: drop changes in mips-r2-to-r6-emul and simulate_fp()] Signed-off-by: Ben Hutchings --- --- a/arch/mips/kernel/traps.c +++ b/arch/mips/kernel/traps.c @@ -775,7 +775,7 @@ asmlinkage void do_fpe(struct pt_regs *r /* * We can't allow the emulated instruction to leave any of - * the cause bit set in $fcr31. + * the cause bits set in $fcr31. */ current->thread.fpu.fcr31 &= ~FPU_CSR_ALL_X; @@ -1292,6 +1292,13 @@ asmlinkage void do_cpu(struct pt_regs *r sig = fpu_emulator_cop1Handler(regs, ¤t->thread.fpu, 0, &fault_addr); + + /* + * We can't allow the emulated instruction to leave + * any of the cause bits set in $fcr31. + */ + current->thread.fpu.fcr31 &= ~FPU_CSR_ALL_X; + if (!process_fpemu_return(sig, fault_addr) && !err) mt_ase_fp_affinity(); }