Received: by 10.223.176.46 with SMTP id f43csp1170147wra; Fri, 19 Jan 2018 07:51:49 -0800 (PST) X-Google-Smtp-Source: AH8x227v2pfe01trxvZTUjyxU3sxBuvRbjt8Hfxy1evVm8LTbQef91ZS3UclceL2auLamMFv3yGh X-Received: by 10.101.82.203 with SMTP id z11mr1158787pgp.164.1516377109245; Fri, 19 Jan 2018 07:51:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516377109; cv=none; d=google.com; s=arc-20160816; b=y00+6eYNqOd5rp0eJpQjO6oOo668qm7bDEwvns/sMYBf+x/ZfLlYLkzBtuz9ZjKp/Z ZrXdQNUYLhyH8MWluGdapRLbSCkWtR5Eu67HG3TnngA0UOsp4Zd7IVeSeOgi+Mbd5kih XIn4MH3+rfO9QPoPl+jFwOYOrxBmw6m58+WYxv9Juctkmhzuc0wDIFLqqPdU9BLKzj43 IZaoI+2oFvTw/q19BzNrfOLr3ly/B8Y6jsi4BBuVPqBhGwDpe9uB7DvKaVI32unfmkOC n1//N5hHAdrGZA7tVyZX56bhQ6SFD9/gf+B2o1pTciXuj5qNuyzfiVD25MN8AC6AyqMD KjGw== 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=4eZASso/uK3284iOpMtpAByZrtT9+4zAAq2/q24M+6A=; b=imX5pc8wPHFRkN7SVi0sPX8WW0lup0VkbBucjYapcWgD19Zw7ZfwP/QGdPtUPp7g5C jDmgV1Ar8KGU9Q0YiUqlHPpQLkN0OSXiGKONs/R21RWNjWHncDpk+YAiKSKv0J075tYN 12rmBQQ5mF//ddtEh6HZ8YX93Ue2RgczcCLos5wIU2+u8eotW/vYWq+H4XM8oV1/D4ZR NHBldRLKNs7upVHSsBxR37TRu7j8shuax5LyHyIgYgVVis0KVXm6ZrZPOj30OhEY+SZd A0cQUWq/Oju1Aa0vB3nBe4vPX24jpLn7RNmcNhZyt+CfWWTUtk2IuRjXk21TB8g/1FoR B3aQ== 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 65si5173123pft.352.2018.01.19.07.51.35; Fri, 19 Jan 2018 07:51:49 -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 S1756029AbeASPui (ORCPT + 99 others); Fri, 19 Jan 2018 10:50:38 -0500 Received: from terminus.zytor.com ([65.50.211.136]:45873 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755700AbeASPuS (ORCPT ); Fri, 19 Jan 2018 10:50:18 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTP id w0JFkuZu012838; Fri, 19 Jan 2018 07:46:56 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w0JFktbN012834; Fri, 19 Jan 2018 07:46:55 -0800 Date: Fri, 19 Jan 2018 07:46:55 -0800 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Thomas Gleixner Message-ID: Cc: mingo@kernel.org, dwmw@amazon.co.uk, linux-kernel@vger.kernel.org, tglx@linutronix.de, peterz@infradead.org, hpa@zytor.com Reply-To: hpa@zytor.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, peterz@infradead.org, mingo@kernel.org, dwmw@amazon.co.uk In-Reply-To: References: To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/pti] x86/mce: Make machine check speculation protected Git-Commit-ID: 6f41c34d69eb005e7848716bbcafc979b35037d5 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 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: 6f41c34d69eb005e7848716bbcafc979b35037d5 Gitweb: https://git.kernel.org/tip/6f41c34d69eb005e7848716bbcafc979b35037d5 Author: Thomas Gleixner AuthorDate: Thu, 18 Jan 2018 16:28:26 +0100 Committer: Thomas Gleixner CommitDate: Fri, 19 Jan 2018 16:31:28 +0100 x86/mce: Make machine check speculation protected The machine check idtentry uses an indirect branch directly from the low level code. This evades the speculation protection. Replace it by a direct call into C code and issue the indirect call there so the compiler can apply the proper speculation protection. Signed-off-by: Thomas Gleixner Reviewed-by:Borislav Petkov Reviewed-by: David Woodhouse Niced-by: Peter Zijlstra Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/alpine.DEB.2.20.1801181626290.1847@nanos --- arch/x86/entry/entry_64.S | 2 +- arch/x86/include/asm/traps.h | 1 + arch/x86/kernel/cpu/mcheck/mce.c | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S index d54a0ed..63f4320 100644 --- a/arch/x86/entry/entry_64.S +++ b/arch/x86/entry/entry_64.S @@ -1258,7 +1258,7 @@ idtentry async_page_fault do_async_page_fault has_error_code=1 #endif #ifdef CONFIG_X86_MCE -idtentry machine_check has_error_code=0 paranoid=1 do_sym=*machine_check_vector(%rip) +idtentry machine_check do_mce has_error_code=0 paranoid=1 #endif /* diff --git a/arch/x86/include/asm/traps.h b/arch/x86/include/asm/traps.h index 31051f3..3de6933 100644 --- a/arch/x86/include/asm/traps.h +++ b/arch/x86/include/asm/traps.h @@ -88,6 +88,7 @@ dotraplinkage void do_simd_coprocessor_error(struct pt_regs *, long); #ifdef CONFIG_X86_32 dotraplinkage void do_iret_error(struct pt_regs *, long); #endif +dotraplinkage void do_mce(struct pt_regs *, long); static inline int get_si_code(unsigned long condition) { diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c index 3b413065..a9e898b 100644 --- a/arch/x86/kernel/cpu/mcheck/mce.c +++ b/arch/x86/kernel/cpu/mcheck/mce.c @@ -1788,6 +1788,11 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code) void (*machine_check_vector)(struct pt_regs *, long error_code) = unexpected_machine_check; +dotraplinkage void do_mce(struct pt_regs *regs, long error_code) +{ + machine_check_vector(regs, error_code); +} + /* * Called for each booted CPU to set up machine checks. * Must be called with preempt off: