Received: by 10.223.176.5 with SMTP id f5csp818595wra; Sat, 27 Jan 2018 10:25:27 -0800 (PST) X-Google-Smtp-Source: AH8x227ZbLutxUxbwkvA6YPJEuyeraIqjuEUrlkbmhlVOvC73Uae3SIlevG580hMRDPjiUbmarz8 X-Received: by 2002:a17:902:2702:: with SMTP id c2-v6mr15421396plb.342.1517077527691; Sat, 27 Jan 2018 10:25:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517077527; cv=none; d=google.com; s=arc-20160816; b=BRCW/l2Me2UlgvjZV/TwGGi65yUJisagoGVa1DBcHKHimdajDPW9P0XY+l8d6EcMVD hRJ9+A3j1JcaINFSewGQ8nj/2tSDPt7kccYl3snyZzkWbh2YbvCb+tgbu6i17yu0x0dS IJE/tGA2ry20CSdZF+fU8FE0Bw+X4jQDsasJ7tSJ8SWi086KvUAqNb6n7tq2u0k7LrU2 TrEcKi01Ljv51Xj2/cfwt1e3FgFRTdgoEyPCVn2HPXWMbK+AGD40WPQSOp8YvvCvL7TX cAyVejSSc23XE0aAiuP6A9nUDq1gVPc0kOPnpmNkdzP+7s12tMJrlWDRJukXzS+JRfuu tWJA== 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=6LqY7igE9FPrLPqfvVWbvMtyt60S7bai4vBO9GgZbBw=; b=KuibeEV/gtIICCuGhbv0RdOh9qcVI26mkRrJwAgwNcSmIDZhUSUV+H2mU6QNs9Z4FR eteIxOCYyw90vtQq0JMoxkI6U2/ch5wSsTAw7ED/V/g+PFo6AtzeM8DyZB6QwQvZva12 6jgJwPKTPCDBUYAFKXA01YEdiCI15WORy1D9Pmv8KrXS6ePctJl7tJzRrT74kMrQJUNN g+ZYiE4QbNPPWylYQ0DjhbG41BXcIfWdvD/5sEs4VtdkTOU8zBG87VIsTDkpZXCfDyDI 9FWtJQXm81phNj0dlreccRj+cBXa/8ukavoAqNBa3d8fxXied7aNj+xxWsBIMIYZlsK5 LxnQ== 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 q12si4676235pgc.64.2018.01.27.10.25.13; Sat, 27 Jan 2018 10:25:27 -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 S1753256AbeA0SYv (ORCPT + 99 others); Sat, 27 Jan 2018 13:24:51 -0500 Received: from terminus.zytor.com ([65.50.211.136]:38845 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750864AbeA0SYt (ORCPT ); Sat, 27 Jan 2018 13:24:49 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTP id w0RIH2hg032733; Sat, 27 Jan 2018 10:17:02 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w0RIH2HY032730; Sat, 27 Jan 2018 10:17:02 -0800 Date: Sat, 27 Jan 2018 10:17:02 -0800 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Borislav Petkov Message-ID: Cc: linux-kernel@vger.kernel.org, dwmw@amazon.co.uk, hpa@zytor.com, tglx@linutronix.de, bp@suse.de, mingo@kernel.org Reply-To: tglx@linutronix.de, hpa@zytor.com, dwmw@amazon.co.uk, linux-kernel@vger.kernel.org, mingo@kernel.org, bp@suse.de In-Reply-To: <1517070274-12128-4-git-send-email-dwmw@amazon.co.uk> References: <1517070274-12128-4-git-send-email-dwmw@amazon.co.uk> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/pti] x86/speculation: Simplify indirect_branch_prediction_barrier() Git-Commit-ID: 64e16720ea0879f8ab4547e3b9758936d483909b 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: 64e16720ea0879f8ab4547e3b9758936d483909b Gitweb: https://git.kernel.org/tip/64e16720ea0879f8ab4547e3b9758936d483909b Author: Borislav Petkov AuthorDate: Sat, 27 Jan 2018 16:24:34 +0000 Committer: Thomas Gleixner CommitDate: Sat, 27 Jan 2018 19:10:45 +0100 x86/speculation: Simplify indirect_branch_prediction_barrier() Make it all a function which does the WRMSR instead of having a hairy inline asm. [dwmw2: export it, fix CONFIG_RETPOLINE issues] Signed-off-by: Borislav Petkov Signed-off-by: David Woodhouse Signed-off-by: Thomas Gleixner Cc: ak@linux.intel.com Cc: dave.hansen@intel.com Cc: karahmed@amazon.de Cc: arjan@linux.intel.com Cc: torvalds@linux-foundation.org Cc: peterz@infradead.org Cc: bp@alien8.de Cc: pbonzini@redhat.com Cc: tim.c.chen@linux.intel.com Cc: gregkh@linux-foundation.org Link: https://lkml.kernel.org/r/1517070274-12128-4-git-send-email-dwmw@amazon.co.uk --- arch/x86/include/asm/nospec-branch.h | 13 ++++--------- arch/x86/include/asm/processor.h | 3 +++ arch/x86/kernel/cpu/bugs.c | 6 ++++++ 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h index df4ececa..d15d471 100644 --- a/arch/x86/include/asm/nospec-branch.h +++ b/arch/x86/include/asm/nospec-branch.h @@ -164,15 +164,10 @@ static inline void vmexit_fill_RSB(void) static inline void indirect_branch_prediction_barrier(void) { - asm volatile(ALTERNATIVE("", - "movl %[msr], %%ecx\n\t" - "movl %[val], %%eax\n\t" - "movl $0, %%edx\n\t" - "wrmsr", - X86_FEATURE_USE_IBPB) - : : [msr] "i" (MSR_IA32_PRED_CMD), - [val] "i" (PRED_CMD_IBPB) - : "eax", "ecx", "edx", "memory"); + alternative_input("", + "call __ibp_barrier", + X86_FEATURE_USE_IBPB, + ASM_NO_INPUT_CLOBBER("eax", "ecx", "edx", "memory")); } #endif /* __ASSEMBLY__ */ diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index 9c18da6..881ca3b 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -970,4 +970,7 @@ bool xen_set_default_idle(void); void stop_this_cpu(void *dummy); void df_debug(struct pt_regs *regs, long error_code); + +void __ibp_barrier(void); + #endif /* _ASM_X86_PROCESSOR_H */ diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 32d8e6c..3bfb2b2 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -311,3 +311,9 @@ ssize_t cpu_show_spectre_v2(struct device *dev, spectre_v2_module_string()); } #endif + +void __ibp_barrier(void) +{ + __wrmsr(MSR_IA32_PRED_CMD, PRED_CMD_IBPB, 0); +} +EXPORT_SYMBOL_GPL(__ibp_barrier);