Received: by 10.223.148.5 with SMTP id 5csp7611187wrq; Thu, 18 Jan 2018 07:29:13 -0800 (PST) X-Google-Smtp-Source: ACJfBou93JCXD0PtI/KHGZZIEWlVlvDstjXnVE1Vc7jyKJ/qNW/pmUU9cNCDqOa6EDZF51Ugb6/E X-Received: by 10.101.76.199 with SMTP id n7mr14027406pgt.388.1516289353803; Thu, 18 Jan 2018 07:29:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516289353; cv=none; d=google.com; s=arc-20160816; b=uZdnf4xqfHXlY0hLAqjmFXvxIA4H6v5V9TuTs84Ba/rcFKXW53EDSuKkVLgpBJm+Zs TAzo4FPNEYpxW5WOnF/6S0c8ts2kt3TsCFgLB57pxDp0iW/mJnM7Q5JFjQr4i6rP4yHf I4Uj1l7saHsK76q/VwBRy30o0xzsqDa7WmHmY8gUjoVhUj10iUDc0gsyGQ/fOsva9XBS wEBzGMchW+LxWs56qhrUUHAPx9qsczHh2q8VIpYBUx9EuD6llBuKEptiX0H8sj0Jy5D3 avoJUgw6HkFBLpXOABrDpF2SOkaT44+l05Ix0jbm2XUwQIcwGZLmWPZuuiBskD47EyYu V22A== 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:message-id :subject:cc:to:from:date:arc-authentication-results; bh=m8le0q/5sZN3UBmJpfDPRoksBUn6iR2MrSQ1gV8+cjo=; b=SPWiCuqOO2nIEJPrcdzZZp5g1rsULKWTy0nc3a5/7W1BKrY88P8PTwNV/cNlFsFBHy RWWq8gJjowtJ6iiiWH2bxLEK+1RXeRODO3K3O/PuBMK3oN7upJaA4GUcZIwYMc8sQd68 isL0jmNn3+wyGN04DE0oV0Eq/OYsKwj8A3YeDt2/Lh+oyTkoViMxhSWa9Anr4AL7H4VN TPPVvt/hsDimBnl1U5+I5O47ZZtrtCNtd8XiqVEXnV0FzQkxIo7XnvD/zYdlLVGLd2uu PymXWmd2ZU52r+QLGml8rOW/kHHZj5+iGzLki4bjj8Z0tRGulg04XvlV+MHp6by7o3j+ ppKA== 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 f5si6081868pgo.803.2018.01.18.07.28.59; Thu, 18 Jan 2018 07:29:13 -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 S932642AbeARP2e (ORCPT + 99 others); Thu, 18 Jan 2018 10:28:34 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:49083 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932237AbeARP2d (ORCPT ); Thu, 18 Jan 2018 10:28:33 -0500 Received: from hsi-kbw-5-158-153-53.hsi19.kabel-badenwuerttemberg.de ([5.158.153.53] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1ecC4n-0000wj-Da; Thu, 18 Jan 2018 16:26:01 +0100 Date: Thu, 18 Jan 2018 16:28:26 +0100 (CET) From: Thomas Gleixner To: LKML cc: x86@kernel.org, Peter Zijlstra , Borislav Petkov , David Woodhouse Subject: [PATCH] x86/mce: Make machine check speculation protected Message-ID: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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(-) --- a/arch/x86/entry/entry_64.S +++ b/arch/x86/entry/entry_64.S @@ -1264,7 +1264,7 @@ idtentry async_page_fault do_async_page_ #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 /* --- a/arch/x86/include/asm/traps.h +++ b/arch/x86/include/asm/traps.h @@ -88,6 +88,7 @@ dotraplinkage void do_simd_coprocessor_e #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) { --- a/arch/x86/kernel/cpu/mcheck/mce.c +++ b/arch/x86/kernel/cpu/mcheck/mce.c @@ -1785,6 +1785,11 @@ static void unexpected_machine_check(str 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: