diff options
author | David Woodhouse <dwmw@amazon.co.uk> | 2018-02-01 11:27:20 +0000 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2018-03-19 18:59:15 +0000 |
commit | f63a8c783f0de68418551ab850f65c1eb54b9b03 (patch) | |
tree | 662611ad5d245359412e5c42d8c2c25127022a65 /include | |
parent | c2453bdbedac62eaf0a94dc007b778e79c6878e7 (diff) | |
download | linux-stable-f63a8c783f0de68418551ab850f65c1eb54b9b03.tar.gz linux-stable-f63a8c783f0de68418551ab850f65c1eb54b9b03.tar.bz2 linux-stable-f63a8c783f0de68418551ab850f65c1eb54b9b03.zip |
x86/retpoline: Avoid retpolines for built-in __init functions
commit 66f793099a636862a71c59d4a6ba91387b155e0c upstream.
There's no point in building init code with retpolines, since it runs before
any potentially hostile userspace does. And before the retpoline is actually
ALTERNATIVEd into place, for much of it.
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: karahmed@amazon.de
Cc: peterz@infradead.org
Cc: bp@alien8.de
Link: https://lkml.kernel.org/r/1517484441-1420-2-git-send-email-dwmw@amazon.co.uk
[bwh: Backported to 3.16: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/init.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/include/linux/init.h b/include/linux/init.h index 2df8e8dd10a4..487febe50917 100644 --- a/include/linux/init.h +++ b/include/linux/init.h @@ -4,6 +4,13 @@ #include <linux/compiler.h> #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"))) +#else +#define __noretpoline +#endif + /* These macros are used to mark some functions or * initialized data (doesn't apply to uninitialized data) * as `initialization' functions. The kernel can take this @@ -39,7 +46,7 @@ /* These are for everybody (although not all archs will actually discard it in modules) */ -#define __init __section(.init.text) __cold notrace +#define __init __section(.init.text) __cold notrace __noretpoline #define __initdata __section(.init.data) #define __initconst __constsection(.init.rodata) #define __exitdata __section(.exit.data) |