Skip to content

Commit 66f7930

Browse files
dwmw2KAGA-KOKO
authored andcommitted
x86/retpoline: Avoid retpolines for built-in __init functions
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
1 parent 085331d commit 66f7930

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

include/linux/init.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
#include <linux/compiler.h>
66
#include <linux/types.h>
77

8+
/* Built-in __init functions needn't be compiled with retpoline */
9+
#if defined(RETPOLINE) && !defined(MODULE)
10+
#define __noretpoline __attribute__((indirect_branch("keep")))
11+
#else
12+
#define __noretpoline
13+
#endif
14+
815
/* These macros are used to mark some functions or
916
* initialized data (doesn't apply to uninitialized data)
1017
* as `initialization' functions. The kernel can take this
@@ -40,7 +47,7 @@
4047

4148
/* These are for everybody (although not all archs will actually
4249
discard it in modules) */
43-
#define __init __section(.init.text) __cold __latent_entropy
50+
#define __init __section(.init.text) __cold __latent_entropy __noretpoline
4451
#define __initdata __section(.init.data)
4552
#define __initconst __section(.init.rodata)
4653
#define __exitdata __section(.exit.data)

0 commit comments

Comments
 (0)