Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751527AbeAECG5 (ORCPT + 1 other); Thu, 4 Jan 2018 21:06:57 -0500 Received: from smtp-fw-2101.amazon.com ([72.21.196.25]:13261 "EHLO smtp-fw-2101.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751166AbeAECGz (ORCPT ); Thu, 4 Jan 2018 21:06:55 -0500 X-IronPort-AV: E=Sophos;i="5.46,316,1511827200"; d="scan'208";a="665162550" From: David Woodhouse To: Andi Kleen Cc: Paul Turner , LKML , Linus Torvalds , Greg Kroah-Hartman , Tim Chen , Dave Hansen , tglx@linutronix.de, Kees Cook , Rik van Riel , Peter Zijlstra , Andy Lutomirski , Jiri Kosina , gnomes@lxorguk.ukuu.org.uk Subject: [PATCH v4 12/13] x86/retpoline: Add boot time option to disable retpoline Date: Fri, 5 Jan 2018 02:01:08 +0000 Message-Id: <1515117669-24787-13-git-send-email-dwmw@amazon.co.uk> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515117669-24787-1-git-send-email-dwmw@amazon.co.uk> References: <1515117669-24787-1-git-send-email-dwmw@amazon.co.uk> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: From: Andi Kleen Add a noretpoline option boot to disable retpoline and patch out the extra sequences. It cannot patch out the jumps to the thunk functions generated by the compiler, but they turn into a single indirect branch now. Signed-off-by: Andi Kleen Signed-off-by: David Woodhouse --- Documentation/admin-guide/kernel-parameters.txt | 3 +++ arch/x86/kernel/cpu/intel.c | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index af7104a..c48db34 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -2623,6 +2623,9 @@ nohugeiomap [KNL,x86] Disable kernel huge I/O mappings. + noretpoline [X86] Disable the retpoline kernel indirect branch speculation + workarounds. System may allow data leaks with this option. + nosmt [KNL,S390] Disable symmetric multithreading (SMT). Equivalent to smt=1. diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c index b1af220..4ab46f5 100644 --- a/arch/x86/kernel/cpu/intel.c +++ b/arch/x86/kernel/cpu/intel.c @@ -31,6 +31,16 @@ #include #endif +#ifdef RETPOLINE +static int __init noretpoline_setup(char *__unused) +{ + pr_info("Retpoline runtime disabled\n"); + setup_force_cpu_cap(X86_BUG_NO_RETPOLINE); + return 1; +} +__setup("noretpoline", noretpoline_setup); +#endif + /* * Just in case our CPU detection goes bad, or you have a weird system, * allow a way to override the automatic disabling of MPX. -- 2.7.4