Messages in this thread Patch in this message | | | From | Masami Hiramatsu <> | Subject | [PATCH v1 tip/master 1/3] retpoline: Introduce start/end markers of indirect thunk | Date | Thu, 18 Jan 2018 21:01:19 +0900 |
| |
Introduce start/end markers of __x86_indirect_thunk_* functions. These thunk functions are placed in .text.__x86.indirect_thunk.* sections. So this puts those sections in the end of kernel text and adds __indirect_thunk_start/end so that other subsystem (e.g. kprobes) can identify it.
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org> --- arch/x86/include/asm/nospec-branch.h | 3 +++ arch/x86/kernel/vmlinux.lds.S | 35 ++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+)
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 { SPECTRE_V2_IBRS, }; +extern char __indirect_thunk_start[]; +extern char __indirect_thunk_end[]; + /* * On VMEXIT we must ensure that no RSB predictions learned in the guest * 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..1a5a663620ce 100644 --- a/arch/x86/kernel/vmlinux.lds.S +++ b/arch/x86/kernel/vmlinux.lds.S @@ -74,6 +74,9 @@ jiffies_64 = jiffies; #endif +#define X86_INDIRECT_THUNK(reg) \ + *(.text.__x86.indirect_thunk.##reg) + PHDRS { text PT_LOAD FLAGS(5); /* R_E */ data PT_LOAD FLAGS(6); /* RW_ */ @@ -124,6 +127,38 @@ SECTIONS ASSERT(. - _entry_trampoline == PAGE_SIZE, "entry trampoline is too big"); #endif +#ifdef CONFIG_RETPOLINE + __indirect_thunk_start = .; +#ifdef CONFIG_X86_64 + X86_INDIRECT_THUNK(rax) + X86_INDIRECT_THUNK(rbx) + X86_INDIRECT_THUNK(rcx) + X86_INDIRECT_THUNK(rdx) + X86_INDIRECT_THUNK(rsi) + X86_INDIRECT_THUNK(rdi) + X86_INDIRECT_THUNK(rbp) + X86_INDIRECT_THUNK(rsp) + X86_INDIRECT_THUNK(r8) + X86_INDIRECT_THUNK(r9) + X86_INDIRECT_THUNK(r10) + X86_INDIRECT_THUNK(r11) + X86_INDIRECT_THUNK(r12) + X86_INDIRECT_THUNK(r13) + X86_INDIRECT_THUNK(r14) + X86_INDIRECT_THUNK(r15) +#else + X86_INDIRECT_THUNK(eax) + X86_INDIRECT_THUNK(ebx) + X86_INDIRECT_THUNK(ecx) + X86_INDIRECT_THUNK(edx) + X86_INDIRECT_THUNK(esi) + X86_INDIRECT_THUNK(edi) + X86_INDIRECT_THUNK(ebp) + X86_INDIRECT_THUNK(esp) +#endif + __indirect_thunk_end = .; +#endif + /* End of text section */ _etext = .; } :text = 0x9090
| |