H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 1 | #ifndef _ASM_X86_LINKAGE_H |
| 2 | #define _ASM_X86_LINKAGE_H |
Harvey Harrison | 82f74e7 | 2008-01-30 13:31:07 +0100 | [diff] [blame] | 3 | |
Ingo Molnar | 78a9909 | 2008-04-17 17:40:51 +0200 | [diff] [blame] | 4 | #undef notrace |
| 5 | #define notrace __attribute__((no_instrument_function)) |
| 6 | |
Harvey Harrison | 82f74e7 | 2008-01-30 13:31:07 +0100 | [diff] [blame] | 7 | #ifdef CONFIG_X86_64 |
| 8 | #define __ALIGN .p2align 4,,15 |
| 9 | #define __ALIGN_STR ".p2align 4,,15" |
Thomas Gleixner | 96a388d | 2007-10-11 11:20:03 +0200 | [diff] [blame] | 10 | #endif |
Harvey Harrison | 82f74e7 | 2008-01-30 13:31:07 +0100 | [diff] [blame] | 11 | |
| 12 | #ifdef CONFIG_X86_32 |
| 13 | #define asmlinkage CPP_ASMLINKAGE __attribute__((regparm(0))) |
Ingo Molnar | d50efc6 | 2008-01-30 13:33:00 +0100 | [diff] [blame] | 14 | /* |
| 15 | * For 32-bit UML - mark functions implemented in assembly that use |
| 16 | * regparm input parameters: |
| 17 | */ |
| 18 | #define asmregparm __attribute__((regparm(3))) |
Roland McGrath | 54a0151 | 2008-04-10 15:37:38 -0700 | [diff] [blame] | 19 | |
Linus Torvalds | d10d89e | 2008-04-10 17:35:23 -0700 | [diff] [blame] | 20 | /* |
| 21 | * Make sure the compiler doesn't do anything stupid with the |
| 22 | * arguments on the stack - they are owned by the *caller*, not |
| 23 | * the callee. This just fools gcc into not spilling into them, |
| 24 | * and keeps it from doing tailcall recursion and/or using the |
| 25 | * stack slots for temporaries, since they are live and "used" |
| 26 | * all the way to the end of the function. |
| 27 | * |
| 28 | * NOTE! On x86-64, all the arguments are in registers, so this |
| 29 | * only matters on a 32-bit kernel. |
| 30 | */ |
Roland McGrath | 54a0151 | 2008-04-10 15:37:38 -0700 | [diff] [blame] | 31 | #define asmlinkage_protect(n, ret, args...) \ |
| 32 | __asmlinkage_protect##n(ret, ##args) |
| 33 | #define __asmlinkage_protect_n(ret, args...) \ |
| 34 | __asm__ __volatile__ ("" : "=r" (ret) : "0" (ret), ##args) |
| 35 | #define __asmlinkage_protect0(ret) \ |
| 36 | __asmlinkage_protect_n(ret) |
| 37 | #define __asmlinkage_protect1(ret, arg1) \ |
| 38 | __asmlinkage_protect_n(ret, "g" (arg1)) |
| 39 | #define __asmlinkage_protect2(ret, arg1, arg2) \ |
| 40 | __asmlinkage_protect_n(ret, "g" (arg1), "g" (arg2)) |
| 41 | #define __asmlinkage_protect3(ret, arg1, arg2, arg3) \ |
| 42 | __asmlinkage_protect_n(ret, "g" (arg1), "g" (arg2), "g" (arg3)) |
| 43 | #define __asmlinkage_protect4(ret, arg1, arg2, arg3, arg4) \ |
| 44 | __asmlinkage_protect_n(ret, "g" (arg1), "g" (arg2), "g" (arg3), \ |
| 45 | "g" (arg4)) |
| 46 | #define __asmlinkage_protect5(ret, arg1, arg2, arg3, arg4, arg5) \ |
| 47 | __asmlinkage_protect_n(ret, "g" (arg1), "g" (arg2), "g" (arg3), \ |
| 48 | "g" (arg4), "g" (arg5)) |
| 49 | #define __asmlinkage_protect6(ret, arg1, arg2, arg3, arg4, arg5, arg6) \ |
| 50 | __asmlinkage_protect_n(ret, "g" (arg1), "g" (arg2), "g" (arg3), \ |
| 51 | "g" (arg4), "g" (arg5), "g" (arg6)) |
| 52 | |
Harvey Harrison | 82f74e7 | 2008-01-30 13:31:07 +0100 | [diff] [blame] | 53 | #endif |
| 54 | |
Cyrill Gorcunov | 9569554 | 2009-02-14 00:50:18 +0300 | [diff] [blame^] | 55 | #define GLOBAL(name) \ |
| 56 | .globl name; \ |
| 57 | name: |
| 58 | |
Harvey Harrison | 82f74e7 | 2008-01-30 13:31:07 +0100 | [diff] [blame] | 59 | #ifdef CONFIG_X86_ALIGNMENT_16 |
| 60 | #define __ALIGN .align 16,0x90 |
| 61 | #define __ALIGN_STR ".align 16,0x90" |
| 62 | #endif |
| 63 | |
Cyrill Gorcunov | 3b6c52b | 2008-11-23 20:21:39 +0300 | [diff] [blame] | 64 | /* |
| 65 | * to check ENTRY_X86/END_X86 and |
| 66 | * KPROBE_ENTRY_X86/KPROBE_END_X86 |
| 67 | * unbalanced-missed-mixed appearance |
| 68 | */ |
| 69 | #define __set_entry_x86 .set ENTRY_X86_IN, 0 |
| 70 | #define __unset_entry_x86 .set ENTRY_X86_IN, 1 |
| 71 | #define __set_kprobe_x86 .set KPROBE_X86_IN, 0 |
| 72 | #define __unset_kprobe_x86 .set KPROBE_X86_IN, 1 |
| 73 | |
| 74 | #define __macro_err_x86 .error "ENTRY_X86/KPROBE_X86 unbalanced,missed,mixed" |
| 75 | |
| 76 | #define __check_entry_x86 \ |
| 77 | .ifdef ENTRY_X86_IN; \ |
| 78 | .ifeq ENTRY_X86_IN; \ |
| 79 | __macro_err_x86; \ |
| 80 | .abort; \ |
| 81 | .endif; \ |
| 82 | .endif |
| 83 | |
| 84 | #define __check_kprobe_x86 \ |
| 85 | .ifdef KPROBE_X86_IN; \ |
| 86 | .ifeq KPROBE_X86_IN; \ |
| 87 | __macro_err_x86; \ |
| 88 | .abort; \ |
| 89 | .endif; \ |
| 90 | .endif |
| 91 | |
| 92 | #define __check_entry_kprobe_x86 \ |
| 93 | __check_entry_x86; \ |
| 94 | __check_kprobe_x86 |
| 95 | |
| 96 | #define ENTRY_KPROBE_FINAL_X86 __check_entry_kprobe_x86 |
| 97 | |
| 98 | #define ENTRY_X86(name) \ |
| 99 | __check_entry_kprobe_x86; \ |
| 100 | __set_entry_x86; \ |
| 101 | .globl name; \ |
| 102 | __ALIGN; \ |
| 103 | name: |
| 104 | |
| 105 | #define END_X86(name) \ |
| 106 | __unset_entry_x86; \ |
| 107 | __check_entry_kprobe_x86; \ |
| 108 | .size name, .-name |
| 109 | |
| 110 | #define KPROBE_ENTRY_X86(name) \ |
| 111 | __check_entry_kprobe_x86; \ |
| 112 | __set_kprobe_x86; \ |
| 113 | .pushsection .kprobes.text, "ax"; \ |
| 114 | .globl name; \ |
| 115 | __ALIGN; \ |
| 116 | name: |
| 117 | |
| 118 | #define KPROBE_END_X86(name) \ |
| 119 | __unset_kprobe_x86; \ |
| 120 | __check_entry_kprobe_x86; \ |
| 121 | .size name, .-name; \ |
| 122 | .popsection |
| 123 | |
H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 124 | #endif /* _ASM_X86_LINKAGE_H */ |
Harvey Harrison | 82f74e7 | 2008-01-30 13:31:07 +0100 | [diff] [blame] | 125 | |