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 | |
Cyrill Gorcunov | bb7f5f6 | 2009-03-09 20:19:51 +0300 | [diff] [blame] | 4 | #include <linux/stringify.h> |
| 5 | |
Ingo Molnar | 78a9909 | 2008-04-17 17:40:51 +0200 | [diff] [blame] | 6 | #undef notrace |
| 7 | #define notrace __attribute__((no_instrument_function)) |
| 8 | |
Harvey Harrison | 82f74e7 | 2008-01-30 13:31:07 +0100 | [diff] [blame] | 9 | #ifdef CONFIG_X86_32 |
| 10 | #define asmlinkage CPP_ASMLINKAGE __attribute__((regparm(0))) |
Roland McGrath | 54a0151 | 2008-04-10 15:37:38 -0700 | [diff] [blame] | 11 | |
Linus Torvalds | d10d89e | 2008-04-10 17:35:23 -0700 | [diff] [blame] | 12 | /* |
| 13 | * Make sure the compiler doesn't do anything stupid with the |
| 14 | * arguments on the stack - they are owned by the *caller*, not |
| 15 | * the callee. This just fools gcc into not spilling into them, |
| 16 | * and keeps it from doing tailcall recursion and/or using the |
| 17 | * stack slots for temporaries, since they are live and "used" |
| 18 | * all the way to the end of the function. |
| 19 | * |
| 20 | * NOTE! On x86-64, all the arguments are in registers, so this |
| 21 | * only matters on a 32-bit kernel. |
| 22 | */ |
Roland McGrath | 54a0151 | 2008-04-10 15:37:38 -0700 | [diff] [blame] | 23 | #define asmlinkage_protect(n, ret, args...) \ |
| 24 | __asmlinkage_protect##n(ret, ##args) |
| 25 | #define __asmlinkage_protect_n(ret, args...) \ |
| 26 | __asm__ __volatile__ ("" : "=r" (ret) : "0" (ret), ##args) |
| 27 | #define __asmlinkage_protect0(ret) \ |
| 28 | __asmlinkage_protect_n(ret) |
| 29 | #define __asmlinkage_protect1(ret, arg1) \ |
Jan Beulich | d59fe3f | 2013-01-22 11:24:12 +0000 | [diff] [blame] | 30 | __asmlinkage_protect_n(ret, "m" (arg1)) |
Roland McGrath | 54a0151 | 2008-04-10 15:37:38 -0700 | [diff] [blame] | 31 | #define __asmlinkage_protect2(ret, arg1, arg2) \ |
Jan Beulich | d59fe3f | 2013-01-22 11:24:12 +0000 | [diff] [blame] | 32 | __asmlinkage_protect_n(ret, "m" (arg1), "m" (arg2)) |
Roland McGrath | 54a0151 | 2008-04-10 15:37:38 -0700 | [diff] [blame] | 33 | #define __asmlinkage_protect3(ret, arg1, arg2, arg3) \ |
Jan Beulich | d59fe3f | 2013-01-22 11:24:12 +0000 | [diff] [blame] | 34 | __asmlinkage_protect_n(ret, "m" (arg1), "m" (arg2), "m" (arg3)) |
Roland McGrath | 54a0151 | 2008-04-10 15:37:38 -0700 | [diff] [blame] | 35 | #define __asmlinkage_protect4(ret, arg1, arg2, arg3, arg4) \ |
Jan Beulich | d59fe3f | 2013-01-22 11:24:12 +0000 | [diff] [blame] | 36 | __asmlinkage_protect_n(ret, "m" (arg1), "m" (arg2), "m" (arg3), \ |
| 37 | "m" (arg4)) |
Roland McGrath | 54a0151 | 2008-04-10 15:37:38 -0700 | [diff] [blame] | 38 | #define __asmlinkage_protect5(ret, arg1, arg2, arg3, arg4, arg5) \ |
Jan Beulich | d59fe3f | 2013-01-22 11:24:12 +0000 | [diff] [blame] | 39 | __asmlinkage_protect_n(ret, "m" (arg1), "m" (arg2), "m" (arg3), \ |
| 40 | "m" (arg4), "m" (arg5)) |
Roland McGrath | 54a0151 | 2008-04-10 15:37:38 -0700 | [diff] [blame] | 41 | #define __asmlinkage_protect6(ret, arg1, arg2, arg3, arg4, arg5, arg6) \ |
Jan Beulich | d59fe3f | 2013-01-22 11:24:12 +0000 | [diff] [blame] | 42 | __asmlinkage_protect_n(ret, "m" (arg1), "m" (arg2), "m" (arg3), \ |
| 43 | "m" (arg4), "m" (arg5), "m" (arg6)) |
Roland McGrath | 54a0151 | 2008-04-10 15:37:38 -0700 | [diff] [blame] | 44 | |
Cyrill Gorcunov | 7ab1524 | 2009-03-06 19:08:34 +0300 | [diff] [blame] | 45 | #endif /* CONFIG_X86_32 */ |
| 46 | |
| 47 | #ifdef __ASSEMBLY__ |
Harvey Harrison | 82f74e7 | 2008-01-30 13:31:07 +0100 | [diff] [blame] | 48 | |
Cyrill Gorcunov | 9569554 | 2009-02-14 00:50:18 +0300 | [diff] [blame] | 49 | #define GLOBAL(name) \ |
| 50 | .globl name; \ |
| 51 | name: |
| 52 | |
Cyrill Gorcunov | bb7f5f6 | 2009-03-09 20:19:51 +0300 | [diff] [blame] | 53 | #if defined(CONFIG_X86_64) || defined(CONFIG_X86_ALIGNMENT_16) |
| 54 | #define __ALIGN .p2align 4, 0x90 |
| 55 | #define __ALIGN_STR __stringify(__ALIGN) |
Harvey Harrison | 82f74e7 | 2008-01-30 13:31:07 +0100 | [diff] [blame] | 56 | #endif |
| 57 | |
Cyrill Gorcunov | 7ab1524 | 2009-03-06 19:08:34 +0300 | [diff] [blame] | 58 | #endif /* __ASSEMBLY__ */ |
| 59 | |
H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 60 | #endif /* _ASM_X86_LINKAGE_H */ |
Harvey Harrison | 82f74e7 | 2008-01-30 13:31:07 +0100 | [diff] [blame] | 61 | |