Skip to content

Commit 22371c4

Browse files
mhiramatgregkh
authored andcommitted
retpoline: Introduce start/end markers of indirect thunk
commit 736e80a upstream. Introduce start/end markers of __x86_indirect_thunk_* functions. To make it easy, consolidate .text.__x86.indirect_thunk.* sections to one .text.__x86.indirect_thunk section and put it in the end of kernel text section and adds __indirect_thunk_start/end so that other subsystem (e.g. kprobes) can identify it. Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: David Woodhouse <dwmw@amazon.co.uk> Cc: Andi Kleen <ak@linux.intel.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com> Cc: Arjan van de Ven <arjan@linux.intel.com> Cc: Greg Kroah-Hartman <gregkh@linux-foundation.org> Link: https://lkml.kernel.org/r/151629206178.10241.6828804696410044771.stgit@devbox Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 020c755 commit 22371c4

3 files changed

Lines changed: 10 additions & 1 deletion

File tree

arch/x86/include/asm/nospec-branch.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ enum spectre_v2_mitigation {
194194
SPECTRE_V2_IBRS,
195195
};
196196

197+
extern char __indirect_thunk_start[];
198+
extern char __indirect_thunk_end[];
199+
197200
/*
198201
* On VMEXIT we must ensure that no RSB predictions learned in the guest
199202
* can be followed in the host, by overwriting the RSB completely. Both

arch/x86/kernel/vmlinux.lds.S

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ SECTIONS
124124
ASSERT(. - _entry_trampoline == PAGE_SIZE, "entry trampoline is too big");
125125
#endif
126126

127+
#ifdef CONFIG_RETPOLINE
128+
__indirect_thunk_start = .;
129+
*(.text.__x86.indirect_thunk)
130+
__indirect_thunk_end = .;
131+
#endif
132+
127133
/* End of text section */
128134
_etext = .;
129135
} :text = 0x9090

arch/x86/lib/retpoline.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <asm/nospec-branch.h>
1010

1111
.macro THUNK reg
12-
.section .text.__x86.indirect_thunk.\reg
12+
.section .text.__x86.indirect_thunk
1313

1414
ENTRY(__x86_indirect_thunk_\reg)
1515
CFI_STARTPROC

0 commit comments

Comments
 (0)