linkage.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #ifndef _ASM_X86_LINKAGE_H
  2. #define _ASM_X86_LINKAGE_H
  3. #undef notrace
  4. #define notrace __attribute__((no_instrument_function))
  5. #ifdef CONFIG_X86_64
  6. #define __ALIGN .p2align 4,,15
  7. #define __ALIGN_STR ".p2align 4,,15"
  8. #endif
  9. #ifdef CONFIG_X86_32
  10. #define asmlinkage CPP_ASMLINKAGE __attribute__((regparm(0)))
  11. /*
  12. * For 32-bit UML - mark functions implemented in assembly that use
  13. * regparm input parameters:
  14. */
  15. #define asmregparm __attribute__((regparm(3)))
  16. /*
  17. * Make sure the compiler doesn't do anything stupid with the
  18. * arguments on the stack - they are owned by the *caller*, not
  19. * the callee. This just fools gcc into not spilling into them,
  20. * and keeps it from doing tailcall recursion and/or using the
  21. * stack slots for temporaries, since they are live and "used"
  22. * all the way to the end of the function.
  23. *
  24. * NOTE! On x86-64, all the arguments are in registers, so this
  25. * only matters on a 32-bit kernel.
  26. */
  27. #define asmlinkage_protect(n, ret, args...) \
  28. __asmlinkage_protect##n(ret, ##args)
  29. #define __asmlinkage_protect_n(ret, args...) \
  30. __asm__ __volatile__ ("" : "=r" (ret) : "0" (ret), ##args)
  31. #define __asmlinkage_protect0(ret) \
  32. __asmlinkage_protect_n(ret)
  33. #define __asmlinkage_protect1(ret, arg1) \
  34. __asmlinkage_protect_n(ret, "g" (arg1))
  35. #define __asmlinkage_protect2(ret, arg1, arg2) \
  36. __asmlinkage_protect_n(ret, "g" (arg1), "g" (arg2))
  37. #define __asmlinkage_protect3(ret, arg1, arg2, arg3) \
  38. __asmlinkage_protect_n(ret, "g" (arg1), "g" (arg2), "g" (arg3))
  39. #define __asmlinkage_protect4(ret, arg1, arg2, arg3, arg4) \
  40. __asmlinkage_protect_n(ret, "g" (arg1), "g" (arg2), "g" (arg3), \
  41. "g" (arg4))
  42. #define __asmlinkage_protect5(ret, arg1, arg2, arg3, arg4, arg5) \
  43. __asmlinkage_protect_n(ret, "g" (arg1), "g" (arg2), "g" (arg3), \
  44. "g" (arg4), "g" (arg5))
  45. #define __asmlinkage_protect6(ret, arg1, arg2, arg3, arg4, arg5, arg6) \
  46. __asmlinkage_protect_n(ret, "g" (arg1), "g" (arg2), "g" (arg3), \
  47. "g" (arg4), "g" (arg5), "g" (arg6))
  48. #endif
  49. #ifdef CONFIG_X86_ALIGNMENT_16
  50. #define __ALIGN .align 16,0x90
  51. #define __ALIGN_STR ".align 16,0x90"
  52. #endif
  53. /*
  54. * to check ENTRY_X86/END_X86 and
  55. * KPROBE_ENTRY_X86/KPROBE_END_X86
  56. * unbalanced-missed-mixed appearance
  57. */
  58. #define __set_entry_x86 .set ENTRY_X86_IN, 0
  59. #define __unset_entry_x86 .set ENTRY_X86_IN, 1
  60. #define __set_kprobe_x86 .set KPROBE_X86_IN, 0
  61. #define __unset_kprobe_x86 .set KPROBE_X86_IN, 1
  62. #define __macro_err_x86 .error "ENTRY_X86/KPROBE_X86 unbalanced,missed,mixed"
  63. #define __check_entry_x86 \
  64. .ifdef ENTRY_X86_IN; \
  65. .ifeq ENTRY_X86_IN; \
  66. __macro_err_x86; \
  67. .abort; \
  68. .endif; \
  69. .endif
  70. #define __check_kprobe_x86 \
  71. .ifdef KPROBE_X86_IN; \
  72. .ifeq KPROBE_X86_IN; \
  73. __macro_err_x86; \
  74. .abort; \
  75. .endif; \
  76. .endif
  77. #define __check_entry_kprobe_x86 \
  78. __check_entry_x86; \
  79. __check_kprobe_x86
  80. #define ENTRY_KPROBE_FINAL_X86 __check_entry_kprobe_x86
  81. #define ENTRY_X86(name) \
  82. __check_entry_kprobe_x86; \
  83. __set_entry_x86; \
  84. .globl name; \
  85. __ALIGN; \
  86. name:
  87. #define END_X86(name) \
  88. __unset_entry_x86; \
  89. __check_entry_kprobe_x86; \
  90. .size name, .-name
  91. #define KPROBE_ENTRY_X86(name) \
  92. __check_entry_kprobe_x86; \
  93. __set_kprobe_x86; \
  94. .pushsection .kprobes.text, "ax"; \
  95. .globl name; \
  96. __ALIGN; \
  97. name:
  98. #define KPROBE_END_X86(name) \
  99. __unset_kprobe_x86; \
  100. __check_entry_kprobe_x86; \
  101. .size name, .-name; \
  102. .popsection
  103. #endif /* _ASM_X86_LINKAGE_H */