Patch "x86/retpoline: Support retpoline builds with Clang" has been added to the 4.14-stable tree
Subsystems (3)
This is a note to let you know that I've just added the patch titled
x86/retpoline: Support retpoline builds with Clang
to the 4.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
x86-retpoline-support-retpoline-builds-with-clang.patch
and it can be found in the queue-4.14 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
87358710c1fb4f1bf96bbe2349975ff9953fc9b2Mon Sep 17 00:00:00 2001
From: David Woodhouse <[email protected]>
Date: Mon, 19 Feb 2018 10:50:57 +0000
Subject: x86/retpoline: Support retpoline builds with Clang
From: David Woodhouse <[email protected]>
commit 87358710c1fb4f1bf96bbe2349975ff9953fc9b2 upstream.
--- arch/x86/Makefile | 5 ++++- include/linux/compiler-clang.h | 5 +++++ include/linux/compiler-gcc.h | 4 ++++ include/linux/init.h | 8 ++++---- 4 files changed, 17 insertions(+), 5 deletions(-)
arch/x86/Makefile +4 -1
@@ -232,7 +232,10 @@ KBUILD_CFLAGS += -fno-asynchronous-unwin # Avoid indirect branches in kernel to deal with Spectre ifdef CONFIG_RETPOLINE - RETPOLINE_CFLAGS += $(call cc-option,-mindirect-branch=thunk-extern -mindirect-branch-register) + RETPOLINE_CFLAGS_GCC := -mindirect-branch=thunk-extern -mindirect-branch-register + RETPOLINE_CFLAGS_CLANG := -mretpoline-external-thunk + + RETPOLINE_CFLAGS += $(call cc-option,$(RETPOLINE_CFLAGS_GCC),$(call cc-option,$(RETPOLINE_CFLAGS_CLANG))) ifneq ($(RETPOLINE_CFLAGS),) KBUILD_CFLAGS += $(RETPOLINE_CFLAGS) -DRETPOLINE endif
include/linux/compiler-clang.h +5 -0
@@ -19,3 +19,8 @@#define randomized_struct_fields_start struct {#define randomized_struct_fields_end }; + +/* Clang doesn't have a way to turn it off per-function, yet. */ +#ifdef __noretpoline +#undef __noretpoline +#endif
include/linux/compiler-gcc.h +4 -0
@@ -93,6 +93,10 @@#define __weak __attribute__((weak))#define __alias (symbol) __attribute__((alias(#symbol))) +#ifdef RETPOLINE +#define __noretpoline __attribute__((indirect_branch("keep"))) +#endif +/* * it doesn't make sense on ARM (currently the only user of __naked) * to trace naked functions because then mcount is called without
include/linux/init.h +4 -4
@@ -6,10 +6,10 @@#include <linux/types.h> /* Built-in __init functions needn't be compiled with retpoline */ -#if defined(RETPOLINE ) && !defined(MODULE ) -#define __noretpoline __attribute__((indirect_branch("keep"))) +#if defined(__noretpoline) && !defined(MODULE ) +#define __noinitretpoline __noretpoline#else -#define __noretpoline +#define __noinitretpoline#endif /* These macros are used to mark some functions or
@@ -47,7 +47,7 @@/* These are for everybody (although not all archs will actually discard it in modules) */ -#define __init __section(.init.text) __cold __inittrace __latent_entropy __noretpoline +#define __init __section(.init.text) __cold __inittrace __latent_entropy __noinitretpoline#define __initdata __section(.init.data)#define __initconst __section(.init.rodata)#define __exitdata __section(.exit.data)
Patches currently in stable-queue which might be from [email protected] are
queue-4.14/x86-retpoline-support-retpoline-builds-with-clang.patch queue-4.14/revert-x86-retpoline-simplify-vmexit_fill_rsb.patch queue-4.14/x86-speculation-use-ibrs-if-available-before-calling-into-firmware.patch queue-4.14/x86-speculation-objtool-annotate-indirect-calls-jumps-for-objtool.patch