Received: by 10.223.185.116 with SMTP id b49csp6367426wrg; Wed, 28 Feb 2018 08:15:29 -0800 (PST) X-Google-Smtp-Source: AH8x224VPlwEvgbVqEg/ng6FK/QuMmrgBXJIb8wX/bOuTfuCrO8GPwIaXAuRv0KBd6bSA/MfdGap X-Received: by 10.99.151.74 with SMTP id d10mr14678274pgo.350.1519834529397; Wed, 28 Feb 2018 08:15:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519834529; cv=none; d=google.com; s=arc-20160816; b=ve3EDLzLR9U/pTDfRBUUh8OU/csHaIx3x4oi9HY8MWumwqHhsYe7MYNdB0QTUX3p0d 764ZVnasVQ96H13JmHHCPd62HCfnVMV0Ql7IzyFPL2+4vJHvkAO+XVHLp7qiVEhALUGa N36JCKyybXuw9bB3k3YUbi0YshzKcWjdcM8+RqccBBnuZ5U9BNnndyBWJyYc4XO/TNS/ FF4CIp1v9sAuLexY2DQINi0LEOpIfCACNostBU5s22Pat2/iUUanyR9v27SSJ+1x2qeX nP7oV5fiAVHGSytVjjghHUppP61tlgpVhmPVX4iDlxgAG3G8azmkQQ105eTvsdgpbCsO z6gQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=y43Y+Br2nos8zKNy8NPcNYfOwJUseCJnAMBf2ZN8WP8=; b=fma5GBjD2EOttksGV26qCLHRcDGmorkNV8oleotyUwp4Lz1dzpbPRmoBPKNQh8IgGU nZe1l37SXkJvSJDnZpVc93ate0owPbBHi174lGDCX0x4eJvDdcNVLkrVzfGtHuZ7Z47i tVDZhCYNcsrHG6+FYgWcEnGJYsjTWrkI4mbeVa5v2/6V5vGfy67UWVoApSHaVri9S/+Y iHIPAWcfuV+/xibb0EXw+1uIaOmiRA7mHkmKZ+K7Kez34hlajcla8wwMUXvWf3XYZhKe qjpdF3un53e0d4WI/1dLa7J4ez6XPn5iW03HIMLAPrKvJIcGK1GXcQGsX3Dm/gS6xDzR nCzA== 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 l19si1190294pgo.629.2018.02.28.08.15.14; Wed, 28 Feb 2018 08:15:29 -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 S934474AbeB1QOc (ORCPT + 99 others); Wed, 28 Feb 2018 11:14:32 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:35114 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753118AbeB1QO3 (ORCPT ); Wed, 28 Feb 2018 11:14:29 -0500 Received: from [2a02:8011:400e:2:6f00:88c8:c921:d332] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1er3Yo-0006Xl-8n; Wed, 28 Feb 2018 15:22:26 +0000 Received: from ben by deadeye with local (Exim 4.90_1) (envelope-from ) id 1er3Yk-0000Hm-CZ; Wed, 28 Feb 2018 15:22:22 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Thomas Gleixner" , "David Woodhouse" , "Borislav Petkov" Date: Wed, 28 Feb 2018 15:20:18 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 222/254] x86/mce: Make machine check speculation protected In-Reply-To: X-SA-Exim-Connect-IP: 2a02:8011:400e:2:6f00:88c8:c921:d332 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.55-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Thomas Gleixner commit 6f41c34d69eb005e7848716bbcafc979b35037d5 upstream. 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 Link: https://lkml.kernel.org/r/alpine.DEB.2.20.1801181626290.1847@nanos [bwh: Backported to 3.16 - #include in mce.c - Adjust filename, context] Signed-off-by: Ben Hutchings --- --- a/arch/x86/include/asm/traps.h +++ b/arch/x86/include/asm/traps.h @@ -91,6 +91,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 @@ -46,6 +46,7 @@ #include #include #include +#include #include "mce-internal.h" @@ -1693,6 +1694,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: --- a/arch/x86/kernel/entry_64.S +++ b/arch/x86/kernel/entry_64.S @@ -1320,7 +1320,7 @@ trace_idtentry page_fault do_page_fault 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 /*