Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3023463imm; Sun, 1 Jul 2018 10:30:33 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfAen7LDt1FcqpYqHrdlCq7d5sanmLGArGq8N2/kdZ8detDpkQod5wYE8PVd+hxAEOdAeBB X-Received: by 2002:a62:2942:: with SMTP id p63-v6mr22358788pfp.62.1530466232969; Sun, 01 Jul 2018 10:30:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530466232; cv=none; d=google.com; s=arc-20160816; b=bAyF3ykDWK1Wil8486oWMS69RexwzhE8zCJpZdwMSP5BtaZmpvhLx+gTVddpD3J+YB cdItug08VBwUQX+0zeyrbz8XEM9C0OSD3dpsmP8Rl+jCwnZ/9oh+irG1UfHgvfU3up1h NaPhr6nsJCmyp38MGTxIu4al/ovIb+oXYO7DJx+5Vvhmt7rA87NEjoba2NWB4YT/eeYp 3+zL0IsXAVeqIiyCHhPcEiyUZlgE1nSI8gdez9LGGGirjUhRiJgSJv4EHtAGp5yvJGJS PkwM6CipSSxhS/vZI4AEd7W7uWvAeUlX7dNkciXcHgrFB3YpybrM84EGOsrzRzv1edZX LLSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=0TMhLjZAgDS6SVHVkHQfm4qv4gDQ8eBdPjYMXZ/OjeE=; b=MomaAI7v5o9ygh07092G1jRFtV1LwewKC1b/SLqsyWshspdCyfsInJ2TN2CjeUxc/3 zcs4Y7YVE16V25AKrM887htWJ/deDyugSNEdxNBY3PkD3/XSoYBbXghR3+Tns7Whjjv5 o8Zbzghw9Kbfh/lL8JrICuMv+BBXnkisFhev0DtF4TtIOWoiJXLhmW7iavwj7THy3kId lF4+YQ0qMGZQIj01SgFk8m++ePpnG2XRtGykjxDLom6+BJVPNbFlWqV01yo5EPO8h0vk phqpaN81iDB9r+KhZY6jwIWqhbwtnAX5oDBSRgOCoaxCqo64fbKvDoGho8vr8y1s6+ti +M5Q== 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 3-v6si14512118plc.415.2018.07.01.10.30.18; Sun, 01 Jul 2018 10:30:32 -0700 (PDT) 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 S1031100AbeGAR3Q (ORCPT + 99 others); Sun, 1 Jul 2018 13:29:16 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:36122 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031011AbeGAQgu (ORCPT ); Sun, 1 Jul 2018 12:36:50 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id C442FAA6; Sun, 1 Jul 2018 16:36:49 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Siarhei Liakh , Thomas Gleixner , Andy Lutomirski , "H. Peter Anvin" , "Borislav Petkov" Subject: [PATCH 4.17 010/220] x86: Call fixup_exception() before notify_die() in math_error() Date: Sun, 1 Jul 2018 18:20:34 +0200 Message-Id: <20180701160908.768105921@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701160908.272447118@linuxfoundation.org> References: <20180701160908.272447118@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.17-stable review patch. If anyone has any objections, please let me know. ------------------ From: Siarhei Liakh commit 3ae6295ccb7cf6d344908209701badbbbb503e40 upstream. fpu__drop() has an explicit fwait which under some conditions can trigger a fixable FPU exception while in kernel. Thus, we should attempt to fixup the exception first, and only call notify_die() if the fixup failed just like in do_general_protection(). The original call sequence incorrectly triggers KDB entry on debug kernels under particular FPU-intensive workloads. Andy noted, that this makes the whole conditional irq enable thing even more inconsistent, but fixing that it outside the scope of this. Signed-off-by: Siarhei Liakh Signed-off-by: Thomas Gleixner Reviewed-by: Andy Lutomirski Cc: "H. Peter Anvin" Cc: "Borislav Petkov" Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/DM5PR11MB201156F1CAB2592B07C79A03B17D0@DM5PR11MB2011.namprd11.prod.outlook.com Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/traps.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c @@ -834,16 +834,18 @@ static void math_error(struct pt_regs *r char *str = (trapnr == X86_TRAP_MF) ? "fpu exception" : "simd exception"; - if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, SIGFPE) == NOTIFY_STOP) - return; cond_local_irq_enable(regs); if (!user_mode(regs)) { - if (!fixup_exception(regs, trapnr)) { - task->thread.error_code = error_code; - task->thread.trap_nr = trapnr; + if (fixup_exception(regs, trapnr)) + return; + + task->thread.error_code = error_code; + task->thread.trap_nr = trapnr; + + if (notify_die(DIE_TRAP, str, regs, error_code, + trapnr, SIGFPE) != NOTIFY_STOP) die(str, regs, error_code); - } return; }