retpoline.S 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #include <linux/stringify.h>
  3. #include <linux/linkage.h>
  4. #include <asm/dwarf2.h>
  5. #include <asm/cpufeatures.h>
  6. #include <asm/alternative-asm.h>
  7. #include <asm-generic/export.h>
  8. #include <asm/nospec-branch.h>
  9. .macro THUNK reg
  10. .section .text.__x86.indirect_thunk
  11. ENTRY(__x86_indirect_thunk_\reg)
  12. CFI_STARTPROC
  13. JMP_NOSPEC %\reg
  14. CFI_ENDPROC
  15. ENDPROC(__x86_indirect_thunk_\reg)
  16. .endm
  17. /*
  18. * Despite being an assembler file we can't just use .irp here
  19. * because __KSYM_DEPS__ only uses the C preprocessor and would
  20. * only see one instance of "__x86_indirect_thunk_\reg" rather
  21. * than one per register with the correct names. So we do it
  22. * the simple and nasty way...
  23. */
  24. #define __EXPORT_THUNK(sym) _ASM_NOKPROBE(sym); EXPORT_SYMBOL(sym)
  25. #define EXPORT_THUNK(reg) __EXPORT_THUNK(__x86_indirect_thunk_ ## reg)
  26. #define GENERATE_THUNK(reg) THUNK reg ; EXPORT_THUNK(reg)
  27. GENERATE_THUNK(_ASM_AX)
  28. GENERATE_THUNK(_ASM_BX)
  29. GENERATE_THUNK(_ASM_CX)
  30. GENERATE_THUNK(_ASM_DX)
  31. GENERATE_THUNK(_ASM_SI)
  32. GENERATE_THUNK(_ASM_DI)
  33. GENERATE_THUNK(_ASM_BP)
  34. #ifdef CONFIG_64BIT
  35. GENERATE_THUNK(r8)
  36. GENERATE_THUNK(r9)
  37. GENERATE_THUNK(r10)
  38. GENERATE_THUNK(r11)
  39. GENERATE_THUNK(r12)
  40. GENERATE_THUNK(r13)
  41. GENERATE_THUNK(r14)
  42. GENERATE_THUNK(r15)
  43. #endif