xref: /linux/arch/x86/entry/entry.S (revision d7484babd2c4dcfa1ca02e7e303fab3fab529d75)
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
20SYM_FUNC_START(entry_ibpb)
21	ANNOTATE_NOENDBR
22	movl	$MSR_IA32_PRED_CMD, %ecx
23	movl	$PRED_CMD_IBPB, %eax
24	xorl	%edx, %edx
25	wrmsr
26
27	/* Make sure IBPB clears return stack preductions too. */
28	FILL_RETURN_BUFFER %rax, RSB_CLEAR_LOOPS, X86_BUG_IBPB_NO_RET
29	RET
30SYM_FUNC_END(entry_ibpb)
31/* For KVM */
32EXPORT_SYMBOL_GPL(entry_ibpb);
33
34.popsection
35
36/*
37 * Define the VERW operand that is disguised as entry code so that
38 * it can be referenced with KPTI enabled. This ensure VERW can be
39 * used late in exit-to-user path after page tables are switched.
40 */
41.pushsection .entry.text, "ax"
42
43.align L1_CACHE_BYTES, 0xcc
44SYM_CODE_START_NOALIGN(mds_verw_sel)
45	UNWIND_HINT_UNDEFINED
46	ANNOTATE_NOENDBR
47	.word __KERNEL_DS
48.align L1_CACHE_BYTES, 0xcc
49SYM_CODE_END(mds_verw_sel);
50/* For KVM */
51EXPORT_SYMBOL_GPL(mds_verw_sel);
52
53.popsection
54
55THUNK warn_thunk_thunk, __warn_thunk
56
57/*
58 * Clang's implementation of TLS stack cookies requires the variable in
59 * question to be a TLS variable. If the variable happens to be defined as an
60 * ordinary variable with external linkage in the same compilation unit (which
61 * amounts to the whole of vmlinux with LTO enabled), Clang will drop the
62 * segment register prefix from the references, resulting in broken code. Work
63 * around this by avoiding the symbol used in -mstack-protector-guard-symbol=
64 * entirely in the C code, and use an alias emitted by the linker script
65 * instead.
66 */
67#if defined(CONFIG_STACKPROTECTOR) && defined(CONFIG_SMP)
68EXPORT_SYMBOL(__ref_stack_chk_guard);
69#endif
70