entry.S 1.8 KB

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