Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp2973078imm; Sun, 1 Jul 2018 09:28:06 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIYd6rVbpJeMl7d7du8g/Jjat3+IA29LsC6leD87/HZgBIvMrk7Ly8a78wiZ9dlqfQwe1VN X-Received: by 2002:a63:743:: with SMTP id 64-v6mr19489545pgh.216.1530462485947; Sun, 01 Jul 2018 09:28:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530462485; cv=none; d=google.com; s=arc-20160816; b=p4uNWz3oDz/ohA5A+AxYXVas5RfUoZYffjc1izixk6Er679nvr0dAWJMCNrNZGC+ke dIyTdF8Gj/Z5YjzEHr/8SPJEJguBvhNENkOk/3MOm9cXH9wpZqQDQ7AzE4PjbAhGcBwJ GDzOobFxH/LLu1BXgqbTOBJp0kI/f2A+fhzWcp1WJ1fY9hpDHQmODm//qhbw3c40fgW2 /hwpiKefqyzIFCv0oAKyd5fTmnfmlyx6D0y1c/s3/zzrOJ6KXwmpiGT61bmcxOV92OKg 9KyfjCSIGah17FGnV6C+T/SivTAxsJXLF5nQFVo82hCM8fiKA2BOBmySmULd0wmAZXUf vlrw== 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=RzoPGC6MGIV4xIzwTthwam5wzfO/rXd39rNyWuW2Prw=; b=ZH7dSY9swPdKwO8N+tGKYwL+Jhnv0ED0p9T1Q1aJfztA71auMKat81sTd/BjEuXjK/ xq3UbqUe6dRacoLpc0VNUaW5U77ynZ04jy+WzxR+MQGIr10qtGbaoX5tohb5jJahFOr+ dCJcj8nOq6dxU3HRHOqZguU2iN6JV2lkCNo2a5KIgOMXNTFixj/InOQoIXpqFVcR3zLX XLwWHsGrbHtYZe2LLC8wIAFeCn0FDx/m9nbuO1ZbPxy12ywZvxfd11UKSgFCsW4y/6gk CsUmGtdphIL7wS4lBQe1r9b5twqLRLG1Rk8NjsXkvTZ0Cc2hKV65deSFnZ23WOWX8aXc 4K+g== 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 a5-v6si3447738pll.412.2018.07.01.09.27.51; Sun, 01 Jul 2018 09:28:05 -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 S965278AbeGAQ0E (ORCPT + 99 others); Sun, 1 Jul 2018 12:26:04 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:33758 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933898AbeGAQZ5 (ORCPT ); Sun, 1 Jul 2018 12:25:57 -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 46333AEF; Sun, 1 Jul 2018 16:25:56 +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.9 006/101] x86: Call fixup_exception() before notify_die() in math_error() Date: Sun, 1 Jul 2018 18:20:52 +0200 Message-Id: <20180701160757.395224196@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701160757.138608453@linuxfoundation.org> References: <20180701160757.138608453@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.9-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 @@ -799,16 +799,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; }