Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp553781imm; Wed, 20 Jun 2018 02:50:02 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIGnsx7uZBqVCKUsTb+ScSfHDVj1W3MdtbB8K42+hM9H2Q8noarxuIbZcBzMFXKPkH9izWT X-Received: by 2002:a62:5991:: with SMTP id k17-v6mr21951737pfj.94.1529488202450; Wed, 20 Jun 2018 02:50:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529488202; cv=none; d=google.com; s=arc-20160816; b=yGrUrwx0BiS2FASC5P0o7Rx+xzvx7xfsfs5mpGIjHuMYk3yTcPxo7+CvINR0qSn8ni gGc9w3steAN7+ut88Qz8bRQBVMm59bpbndkwFztJ82wlYxcTqIg8b7OZMj3zd57ABYox 9Z4uF4Sfx6/XmL4XmGKI94c8z7ye5iCPXRn+UhFlI1dZVm+/ACYOmS59HxLdGKJjvFp3 y6fbocLnLasGDfGr8h+/SFvBkV74WOw+EDfzMCSmnDH4+FMM3AuIbKQK/UUzFgEFJyuk sot7MeRGvhnFMVNp+Z6iV3WQFcGszv8fTLFpk5I7l/yuD4RQWa0drqSCmzAVWXugzrPE dcUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=c5WFEv7oqiY6s+4OhbJ20scoKxbEFnNShTSvbYzyOVk=; b=iVfQ/hOI8iUlEWRidirF55k3+hzPzu5cJNgJv+Bdbcsj+nQ8Ni9ceBKRSfXeIUCodB 3H0DkzPF1gkrb13X6va0GDRx0rCm6jhspZ5KR7xZwMnKGaMMPTMjhtOtPjoFU3VxZn0R WDryx9ME+YH/RhDl4V0gNYTdtJBwZHKCPA/6PcApIW+lzZ4AluBvF/RhWxBHCvtpkTf3 Xuev/qTj90oL05RYFoCbgbv7vS2We24QKV+gkgmuAbJ/yiEejLmIPpTMYdb3czgveIf1 0FIuDLPNnd7oOQrxHcWjHtRXc25kHAUuvESAK2Hn26QqojwpXuZE8bcdDA9kzYFwRVtI 3b2Q== 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 s9-v6si2024248plr.332.2018.06.20.02.49.48; Wed, 20 Jun 2018 02:50:02 -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 S1754137AbeFTJtC (ORCPT + 99 others); Wed, 20 Jun 2018 05:49:02 -0400 Received: from terminus.zytor.com ([198.137.202.136]:45365 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751311AbeFTJs7 (ORCPT ); Wed, 20 Jun 2018 05:48:59 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w5K9mnR63451673 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 20 Jun 2018 02:48:49 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w5K9mmIm3451670; Wed, 20 Jun 2018 02:48:48 -0700 Date: Wed, 20 Jun 2018 02:48:48 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Siarhei Liakh Message-ID: Cc: Siarhei.Liakh@concurrent-rt.com, linux-kernel@vger.kernel.org, bpetkov@suse.de, tglx@linutronix.de, siarhei.liakh@concurrent-rt.com, mingo@kernel.org, luto@kernel.org, hpa@zytor.com Reply-To: bpetkov@suse.de, linux-kernel@vger.kernel.org, Siarhei.Liakh@concurrent-rt.com, tglx@linutronix.de, mingo@kernel.org, siarhei.liakh@concurrent-rt.com, hpa@zytor.com, luto@kernel.org In-Reply-To: References: To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/urgent] x86: Call fixup_exception() before notify_die() in math_error() Git-Commit-ID: 3ae6295ccb7cf6d344908209701badbbbb503e40 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, T_DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 3ae6295ccb7cf6d344908209701badbbbb503e40 Gitweb: https://git.kernel.org/tip/3ae6295ccb7cf6d344908209701badbbbb503e40 Author: Siarhei Liakh AuthorDate: Thu, 14 Jun 2018 19:36:07 +0000 Committer: Thomas Gleixner CommitDate: Wed, 20 Jun 2018 11:44:56 +0200 x86: Call fixup_exception() before notify_die() in math_error() 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 --- arch/x86/kernel/traps.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index 03f3d7695dac..162a31d80ad5 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c @@ -834,16 +834,18 @@ static void math_error(struct pt_regs *regs, int error_code, int trapnr) 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; }