Received: by 10.223.176.5 with SMTP id f5csp2847433wra; Mon, 5 Feb 2018 10:53:05 -0800 (PST) X-Google-Smtp-Source: AH8x2279uAJaPnLCvepXb7PNhY+ezT2U3xCgbIQa1noe7xN2Jl2NAkegw2CRolW0UVsCHAmCkxeo X-Received: by 2002:a17:902:bf01:: with SMTP id bi1-v6mr14888606plb.254.1517856785321; Mon, 05 Feb 2018 10:53:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517856785; cv=none; d=google.com; s=arc-20160816; b=nwnRbGDqB7Aclm1QZP6cOGIKU4c2BvYVOrZEaQmjbAgwj9cGDAHQ8GkFc5yCcniIkb eBvZ5+KI/OhMusadEzBGmzbs+ao+kLH3Wi3cH45hpeLEuuPKfxFiz93dGaxqio2miRCo TzheGBEFJVYsSEJPywVh5gPBebV6XV16+VVMWZj32YmMQ3t5Yf0aWfdph3eR6vJrfIZj T+b9ZY7/pxQu4JsPOX6S8eigUP0Ma3HlqJArNoAIYOoTfmWxgrEqnXqbmwuxRC8reFln i8heIKv2BUXxRCKpHN9bbKW5f0rjCDE89F3pMFEHSllbxN/7+bmCn2XzaHUXpXZHQLEL K8zg== 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=5Mssj9LRNZfsnjBCsEwQbGOX3qBc0x1rWsQizdmxsns=; b=KTRcl3gGKJ0KXNfB64ygigvlfpGklTPmVf6ItAOAKrtDU/5Y8184RpiRcY2gn6sOlx fI5WpVQa3qv+EjGfuE5OXi4GFpCjO5mw5WvtQqbpvh7NvZfFCgGtw31imoRfSq4KX2wT Q2Q9hRmEgonjSup0QpxWz5HHPnoNsJSGD0NCO7YnUi5wzwmJNhmxEBSv/j+6TE0imJ1Q h+CTLOBCB0PgpC9S7Sf7m2eP86UbB8/01ngmbg0E8HokoOMRPGgvP8C+sgW9j0FwhCHg 5zL8wx03j2fFARq+7/Eau5dYAho6QqjV9hPi1A8JDpe9iPPAiY2zxh7DerXHVa7kHgoz /Plw== 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 a15-v6si7245151pll.304.2018.02.05.10.52.50; Mon, 05 Feb 2018 10:53:05 -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 S1753820AbeBESwd (ORCPT + 99 others); Mon, 5 Feb 2018 13:52:33 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:52922 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753809AbeBESZr (ORCPT ); Mon, 5 Feb 2018 13:25:47 -0500 Received: from localhost (unknown [104.132.1.108]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 9E4CD1141; Mon, 5 Feb 2018 18:25:30 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Borislav Petkov , David Woodhouse , Thomas Gleixner , ak@linux.intel.com, dave.hansen@intel.com, karahmed@amazon.de, arjan@linux.intel.com, torvalds@linux-foundation.org, peterz@infradead.org, bp@alien8.de, pbonzini@redhat.com, tim.c.chen@linux.intel.com, gregkh@linux-foundation.org Subject: [PATCH 4.15 17/60] x86/speculation: Simplify indirect_branch_prediction_barrier() Date: Mon, 5 Feb 2018 10:22:50 -0800 Message-Id: <20180205182214.630922743@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180205182213.902626065@linuxfoundation.org> References: <20180205182213.902626065@linuxfoundation.org> User-Agent: quilt/0.65 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.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Borislav Petkov bp@suse.de commit 64e16720ea0879f8ab4547e3b9758936d483909b 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 Signed-off-by: Greg Kroah-Hartman --- 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(-) --- 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__ */ --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -971,4 +971,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 */ --- 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 devic spectre_v2_module_string()); } #endif + +void __ibp_barrier(void) +{ + __wrmsr(MSR_IA32_PRED_CMD, PRED_CMD_IBPB, 0); +} +EXPORT_SYMBOL_GPL(__ibp_barrier);