diff options
| author | Masami Hiramatsu <mhiramat@kernel.org> | 2018-01-18 11:14:21 -0500 |
|---|---|---|
| committer | Thomas Gleixner <tglx@linutronix.de> | 2018-01-19 10:31:28 -0500 |
| commit | 736e80a4213e9bbce40a7c050337047128b472ac (patch) | |
| tree | 1aedc475ad8df60cc8b0654e77ce7050179980a8 | |
| parent | 6f41c34d69eb005e7848716bbcafc979b35037d5 (diff) | |
retpoline: Introduce start/end markers of indirect thunk
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>
Cc: stable@vger.kernel.org
Link: https://lkml.kernel.org/r/151629206178.10241.6828804696410044771.stgit@devbox
| -rw-r--r-- | arch/x86/include/asm/nospec-branch.h | 3 | ||||
| -rw-r--r-- | arch/x86/kernel/vmlinux.lds.S | 6 | ||||
| -rw-r--r-- | arch/x86/lib/retpoline.S | 2 |
3 files changed, 10 insertions, 1 deletions
diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h index 7b45d8424150..19ba5ad19c65 100644 --- a/arch/x86/include/asm/nospec-branch.h +++ b/arch/x86/include/asm/nospec-branch.h | |||
| @@ -194,6 +194,9 @@ enum spectre_v2_mitigation { | |||
| 194 | SPECTRE_V2_IBRS, | 194 | SPECTRE_V2_IBRS, |
| 195 | }; | 195 | }; |
| 196 | 196 | ||
| 197 | extern char __indirect_thunk_start[]; | ||
| 198 | extern char __indirect_thunk_end[]; | ||
| 199 | |||
| 197 | /* | 200 | /* |
| 198 | * On VMEXIT we must ensure that no RSB predictions learned in the guest | 201 | * On VMEXIT we must ensure that no RSB predictions learned in the guest |
| 199 | * can be followed in the host, by overwriting the RSB completely. Both | 202 | * can be followed in the host, by overwriting the RSB completely. Both |
diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S index 1e413a9326aa..9b138a06c1a4 100644 --- a/arch/x86/kernel/vmlinux.lds.S +++ b/arch/x86/kernel/vmlinux.lds.S | |||
| @@ -124,6 +124,12 @@ SECTIONS | |||
| 124 | ASSERT(. - _entry_trampoline == PAGE_SIZE, "entry trampoline is too big"); | 124 | ASSERT(. - _entry_trampoline == PAGE_SIZE, "entry trampoline is too big"); |
| 125 | #endif | 125 | #endif |
| 126 | 126 | ||
| 127 | #ifdef CONFIG_RETPOLINE | ||
| 128 | __indirect_thunk_start = .; | ||
| 129 | *(.text.__x86.indirect_thunk) | ||
| 130 | __indirect_thunk_end = .; | ||
| 131 | #endif | ||
| 132 | |||
| 127 | /* End of text section */ | 133 | /* End of text section */ |
| 128 | _etext = .; | 134 | _etext = .; |
| 129 | } :text = 0x9090 | 135 | } :text = 0x9090 |
diff --git a/arch/x86/lib/retpoline.S b/arch/x86/lib/retpoline.S index cb45c6cb465f..d3415dc30f82 100644 --- a/arch/x86/lib/retpoline.S +++ b/arch/x86/lib/retpoline.S | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | #include <asm/nospec-branch.h> | 9 | #include <asm/nospec-branch.h> |
| 10 | 10 | ||
| 11 | .macro THUNK reg | 11 | .macro THUNK reg |
| 12 | .section .text.__x86.indirect_thunk.\reg | 12 | .section .text.__x86.indirect_thunk |
| 13 | 13 | ||
| 14 | ENTRY(__x86_indirect_thunk_\reg) | 14 | ENTRY(__x86_indirect_thunk_\reg) |
| 15 | CFI_STARTPROC | 15 | CFI_STARTPROC |
