| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | 
|---|
| 2 | /* | 
|---|
| 3 | * Common place for both 32- and 64-bit entry routines. | 
|---|
| 4 | */ | 
|---|
| 5 |  | 
|---|
| 6 | #include <linux/export.h> | 
|---|
| 7 | #include <linux/linkage.h> | 
|---|
| 8 | #include <linux/objtool.h> | 
|---|
| 9 | #include <asm/msr-index.h> | 
|---|
| 10 | #include <asm/unwind_hints.h> | 
|---|
| 11 | #include <asm/segment.h> | 
|---|
| 12 | #include <asm/cache.h> | 
|---|
| 13 | #include <asm/cpufeatures.h> | 
|---|
| 14 | #include <asm/nospec-branch.h> | 
|---|
| 15 |  | 
|---|
| 16 | #include "calling.h" | 
|---|
| 17 |  | 
|---|
| 18 | .pushsection .noinstr.text, "ax" | 
|---|
| 19 |  | 
|---|
| 20 | /* Clobbers AX, CX, DX */ | 
|---|
| 21 | SYM_FUNC_START(write_ibpb) | 
|---|
| 22 | ANNOTATE_NOENDBR | 
|---|
| 23 | movl	$MSR_IA32_PRED_CMD, %ecx | 
|---|
| 24 | movl	_ASM_RIP(x86_pred_cmd), %eax | 
|---|
| 25 | xorl	%edx, %edx | 
|---|
| 26 | wrmsr | 
|---|
| 27 |  | 
|---|
| 28 | /* Make sure IBPB clears return stack preductions too. */ | 
|---|
| 29 | FILL_RETURN_BUFFER %rax, RSB_CLEAR_LOOPS, X86_BUG_IBPB_NO_RET | 
|---|
| 30 | RET | 
|---|
| 31 | SYM_FUNC_END(write_ibpb) | 
|---|
| 32 | /* For KVM */ | 
|---|
| 33 | EXPORT_SYMBOL_GPL(write_ibpb); | 
|---|
| 34 |  | 
|---|
| 35 | .popsection | 
|---|
| 36 |  | 
|---|
| 37 | /* | 
|---|
| 38 | * Define the VERW operand that is disguised as entry code so that | 
|---|
| 39 | * it can be referenced with KPTI enabled. This ensures VERW can be | 
|---|
| 40 | * used late in exit-to-user path after page tables are switched. | 
|---|
| 41 | */ | 
|---|
| 42 | .pushsection .entry.text, "ax" | 
|---|
| 43 |  | 
|---|
| 44 | .align L1_CACHE_BYTES, 0xcc | 
|---|
| 45 | SYM_CODE_START_NOALIGN(x86_verw_sel) | 
|---|
| 46 | UNWIND_HINT_UNDEFINED | 
|---|
| 47 | ANNOTATE_NOENDBR | 
|---|
| 48 | .word __KERNEL_DS | 
|---|
| 49 | .align L1_CACHE_BYTES, 0xcc | 
|---|
| 50 | SYM_CODE_END(x86_verw_sel); | 
|---|
| 51 | /* For KVM */ | 
|---|
| 52 | EXPORT_SYMBOL_GPL(x86_verw_sel); | 
|---|
| 53 |  | 
|---|
| 54 | .popsection | 
|---|
| 55 |  | 
|---|
| 56 | THUNK warn_thunk_thunk, __warn_thunk | 
|---|
| 57 |  | 
|---|
| 58 | /* | 
|---|
| 59 | * Clang's implementation of TLS stack cookies requires the variable in | 
|---|
| 60 | * question to be a TLS variable. If the variable happens to be defined as an | 
|---|
| 61 | * ordinary variable with external linkage in the same compilation unit (which | 
|---|
| 62 | * amounts to the whole of vmlinux with LTO enabled), Clang will drop the | 
|---|
| 63 | * segment register prefix from the references, resulting in broken code. Work | 
|---|
| 64 | * around this by avoiding the symbol used in -mstack-protector-guard-symbol= | 
|---|
| 65 | * entirely in the C code, and use an alias emitted by the linker script | 
|---|
| 66 | * instead. | 
|---|
| 67 | */ | 
|---|
| 68 | #if defined(CONFIG_STACKPROTECTOR) && defined(CONFIG_SMP) | 
|---|
| 69 | EXPORT_SYMBOL(__ref_stack_chk_guard); | 
|---|
| 70 | #endif | 
|---|
| 71 |  | 
|---|