1 #ifndef _ASM_X86_ASM_H 2 #define _ASM_X86_ASM_H 3 4 #ifdef __ASSEMBLY__ 5 # define __ASM_FORM(x) x 6 # define __ASM_FORM_RAW(x) x 7 # define __ASM_FORM_COMMA(x) x, 8 #else 9 # define __ASM_FORM(x) " " #x " " 10 # define __ASM_FORM_RAW(x) #x 11 # define __ASM_FORM_COMMA(x) " " #x "," 12 #endif 13 14 #ifndef __x86_64__ 15 /* 32 bit */ 16 # define __ASM_SEL(a,b) __ASM_FORM(a) 17 # define __ASM_SEL_RAW(a,b) __ASM_FORM_RAW(a) 18 #else 19 /* 64 bit */ 20 # define __ASM_SEL(a,b) __ASM_FORM(b) 21 # define __ASM_SEL_RAW(a,b) __ASM_FORM_RAW(b) 22 #endif 23 24 #define __ASM_SIZE(inst, ...) __ASM_SEL(inst##l##__VA_ARGS__, \ 25 inst##q##__VA_ARGS__) 26 #define __ASM_REG(reg) __ASM_SEL_RAW(e##reg, r##reg) 27 28 #define _ASM_PTR __ASM_SEL(.long, .quad) 29 #define _ASM_ALIGN __ASM_SEL(.balign 4, .balign 8) 30 31 #define _ASM_MOV __ASM_SIZE(mov) 32 #define _ASM_INC __ASM_SIZE(inc) 33 #define _ASM_DEC __ASM_SIZE(dec) 34 #define _ASM_ADD __ASM_SIZE(add) 35 #define _ASM_SUB __ASM_SIZE(sub) 36 #define _ASM_XADD __ASM_SIZE(xadd) 37 #define _ASM_MUL __ASM_SIZE(mul) 38 39 #define _ASM_AX __ASM_REG(ax) 40 #define _ASM_BX __ASM_REG(bx) 41 #define _ASM_CX __ASM_REG(cx) 42 #define _ASM_DX __ASM_REG(dx) 43 #define _ASM_SP __ASM_REG(sp) 44 #define _ASM_BP __ASM_REG(bp) 45 #define _ASM_SI __ASM_REG(si) 46 #define _ASM_DI __ASM_REG(di) 47 48 #ifndef __x86_64__ 49 /* 32 bit */ 50 51 #define _ASM_ARG1 _ASM_AX 52 #define _ASM_ARG2 _ASM_DX 53 #define _ASM_ARG3 _ASM_CX 54 55 #define _ASM_ARG1L eax 56 #define _ASM_ARG2L edx 57 #define _ASM_ARG3L ecx 58 59 #define _ASM_ARG1W ax 60 #define _ASM_ARG2W dx 61 #define _ASM_ARG3W cx 62 63 #define _ASM_ARG1B al 64 #define _ASM_ARG2B dl 65 #define _ASM_ARG3B cl 66 67 #else 68 /* 64 bit */ 69 70 #define _ASM_ARG1 _ASM_DI 71 #define _ASM_ARG2 _ASM_SI 72 #define _ASM_ARG3 _ASM_DX 73 #define _ASM_ARG4 _ASM_CX 74 #define _ASM_ARG5 r8 75 #define _ASM_ARG6 r9 76 77 #define _ASM_ARG1Q rdi 78 #define _ASM_ARG2Q rsi 79 #define _ASM_ARG3Q rdx 80 #define _ASM_ARG4Q rcx 81 #define _ASM_ARG5Q r8 82 #define _ASM_ARG6Q r9 83 84 #define _ASM_ARG1L edi 85 #define _ASM_ARG2L esi 86 #define _ASM_ARG3L edx 87 #define _ASM_ARG4L ecx 88 #define _ASM_ARG5L r8d 89 #define _ASM_ARG6L r9d 90 91 #define _ASM_ARG1W di 92 #define _ASM_ARG2W si 93 #define _ASM_ARG3W dx 94 #define _ASM_ARG4W cx 95 #define _ASM_ARG5W r8w 96 #define _ASM_ARG6W r9w 97 98 #define _ASM_ARG1B dil 99 #define _ASM_ARG2B sil 100 #define _ASM_ARG3B dl 101 #define _ASM_ARG4B cl 102 #define _ASM_ARG5B r8b 103 #define _ASM_ARG6B r9b 104 105 #endif 106 107 /* Exception table entry */ 108 #ifdef __ASSEMBLY__ 109 # define _ASM_EXTABLE(from,to) \ 110 .pushsection "__ex_table","a" ; \ 111 .balign 8 ; \ 112 .long (from) - . ; \ 113 .long (to) - . ; \ 114 .popsection 115 116 # define _ASM_EXTABLE_EX(from,to) \ 117 .pushsection "__ex_table","a" ; \ 118 .balign 8 ; \ 119 .long (from) - . ; \ 120 .long (to) - . + 0x7ffffff0 ; \ 121 .popsection 122 123 # define _ASM_NOKPROBE(entry) \ 124 .pushsection "_kprobe_blacklist","aw" ; \ 125 _ASM_ALIGN ; \ 126 _ASM_PTR (entry); \ 127 .popsection 128 129 .macro ALIGN_DESTINATION 130 /* check for bad alignment of destination */ 131 movl %edi,%ecx 132 andl $7,%ecx 133 jz 102f /* already aligned */ 134 subl $8,%ecx 135 negl %ecx 136 subl %ecx,%edx 137 100: movb (%rsi),%al 138 101: movb %al,(%rdi) 139 incq %rsi 140 incq %rdi 141 decl %ecx 142 jnz 100b 143 102: 144 .section .fixup,"ax" 145 103: addl %ecx,%edx /* ecx is zerorest also */ 146 jmp copy_user_handle_tail 147 .previous 148 149 _ASM_EXTABLE(100b,103b) 150 _ASM_EXTABLE(101b,103b) 151 .endm 152 153 #else 154 # define _ASM_EXTABLE(from,to) \ 155 " .pushsection \"__ex_table\",\"a\"\n" \ 156 " .balign 8\n" \ 157 " .long (" #from ") - .\n" \ 158 " .long (" #to ") - .\n" \ 159 " .popsection\n" 160 161 # define _ASM_EXTABLE_EX(from,to) \ 162 " .pushsection \"__ex_table\",\"a\"\n" \ 163 " .balign 8\n" \ 164 " .long (" #from ") - .\n" \ 165 " .long (" #to ") - . + 0x7ffffff0\n" \ 166 " .popsection\n" 167 /* For C file, we already have NOKPROBE_SYMBOL macro */ 168 #endif 169 170 #ifndef __ASSEMBLY__ 171 /* 172 * This output constraint should be used for any inline asm which has a "call" 173 * instruction. Otherwise the asm may be inserted before the frame pointer 174 * gets set up by the containing function. If you forget to do this, objtool 175 * may print a "call without frame pointer save/setup" warning. 176 */ 177 register unsigned long current_stack_pointer asm(_ASM_SP); 178 #define ASM_CALL_CONSTRAINT "+r" (current_stack_pointer) 179 #endif 180 181 #endif /* _ASM_X86_ASM_H */ 182