]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - arch/x86/include/asm/asm.h
x86/bugs, KVM: Support the combination of guest and host IBRS
[mirror_ubuntu-artful-kernel.git] / arch / x86 / include / asm / asm.h
CommitLineData
1965aae3
PA
1#ifndef _ASM_X86_ASM_H
2#define _ASM_X86_ASM_H
e845c06b 3
e6e07d8a
JF
4#ifdef __ASSEMBLY__
5# define __ASM_FORM(x) x
3e9b2327 6# define __ASM_FORM_RAW(x) x
a750036f 7# define __ASM_FORM_COMMA(x) x,
e6e07d8a
JF
8#else
9# define __ASM_FORM(x) " " #x " "
3e9b2327 10# define __ASM_FORM_RAW(x) #x
a750036f 11# define __ASM_FORM_COMMA(x) " " #x ","
e6e07d8a 12#endif
8ee5797a 13
e6e07d8a
JF
14#ifdef CONFIG_X86_32
15# define __ASM_SEL(a,b) __ASM_FORM(a)
3e9b2327 16# define __ASM_SEL_RAW(a,b) __ASM_FORM_RAW(a)
e845c06b 17#else
e6e07d8a 18# define __ASM_SEL(a,b) __ASM_FORM(b)
3e9b2327 19# define __ASM_SEL_RAW(a,b) __ASM_FORM_RAW(b)
e6e07d8a 20#endif
e845c06b 21
4625cd63
JB
22#define __ASM_SIZE(inst, ...) __ASM_SEL(inst##l##__VA_ARGS__, \
23 inst##q##__VA_ARGS__)
3e9b2327 24#define __ASM_REG(reg) __ASM_SEL_RAW(e##reg, r##reg)
e845c06b 25
e6e07d8a
JF
26#define _ASM_PTR __ASM_SEL(.long, .quad)
27#define _ASM_ALIGN __ASM_SEL(.balign 4, .balign 8)
8ee5797a 28
8df9676d 29#define _ASM_MOV __ASM_SIZE(mov)
e6e07d8a
JF
30#define _ASM_INC __ASM_SIZE(inc)
31#define _ASM_DEC __ASM_SIZE(dec)
32#define _ASM_ADD __ASM_SIZE(add)
33#define _ASM_SUB __ASM_SIZE(sub)
34#define _ASM_XADD __ASM_SIZE(xadd)
121843eb 35#define _ASM_MUL __ASM_SIZE(mul)
8df9676d 36
40faf463 37#define _ASM_AX __ASM_REG(ax)
2528de43
GC
38#define _ASM_BX __ASM_REG(bx)
39#define _ASM_CX __ASM_REG(cx)
40faf463 40#define _ASM_DX __ASM_REG(dx)
8df9676d
PA
41#define _ASM_SP __ASM_REG(sp)
42#define _ASM_BP __ASM_REG(bp)
43#define _ASM_SI __ASM_REG(si)
44#define _ASM_DI __ASM_REG(di)
e845c06b 45
ff3554b4
PA
46/*
47 * Macros to generate condition code outputs from inline assembly,
48 * The output operand must be type "bool".
49 */
50#ifdef __GCC_ASM_FLAG_OUTPUTS__
51# define CC_SET(c) "\n\t/* output condition code " #c "*/\n"
52# define CC_OUT(c) "=@cc" #c
53#else
54# define CC_SET(c) "\n\tset" #c " %[_cc_" #c "]\n"
55# define CC_OUT(c) [_cc_ ## c] "=qm"
56#endif
57
a34746bc 58/* Exception table entry */
709972b1 59#ifdef __ASSEMBLY__
548acf19 60# define _ASM_EXTABLE_HANDLE(from, to, handler) \
535c0c34 61 .pushsection "__ex_table","a" ; \
548acf19 62 .balign 4 ; \
70627654
PA
63 .long (from) - . ; \
64 .long (to) - . ; \
548acf19 65 .long (handler) - . ; \
535c0c34
PA
66 .popsection
67
548acf19
TL
68# define _ASM_EXTABLE(from, to) \
69 _ASM_EXTABLE_HANDLE(from, to, ex_handler_default)
70
71# define _ASM_EXTABLE_FAULT(from, to) \
72 _ASM_EXTABLE_HANDLE(from, to, ex_handler_fault)
73
74# define _ASM_EXTABLE_EX(from, to) \
75 _ASM_EXTABLE_HANDLE(from, to, ex_handler_ext)
376e2424
MH
76
77# define _ASM_NOKPROBE(entry) \
78 .pushsection "_kprobe_blacklist","aw" ; \
79 _ASM_ALIGN ; \
80 _ASM_PTR (entry); \
81 .popsection
9e6b13f7
BP
82
83.macro ALIGN_DESTINATION
84 /* check for bad alignment of destination */
85 movl %edi,%ecx
86 andl $7,%ecx
87 jz 102f /* already aligned */
88 subl $8,%ecx
89 negl %ecx
90 subl %ecx,%edx
91100: movb (%rsi),%al
92101: movb %al,(%rdi)
93 incq %rsi
94 incq %rdi
95 decl %ecx
96 jnz 100b
97102:
98 .section .fixup,"ax"
99103: addl %ecx,%edx /* ecx is zerorest also */
100 jmp copy_user_handle_tail
101 .previous
102
103 _ASM_EXTABLE(100b,103b)
104 _ASM_EXTABLE(101b,103b)
105 .endm
106
709972b1 107#else
548acf19
TL
108# define _EXPAND_EXTABLE_HANDLE(x) #x
109# define _ASM_EXTABLE_HANDLE(from, to, handler) \
535c0c34 110 " .pushsection \"__ex_table\",\"a\"\n" \
548acf19 111 " .balign 4\n" \
70627654
PA
112 " .long (" #from ") - .\n" \
113 " .long (" #to ") - .\n" \
548acf19 114 " .long (" _EXPAND_EXTABLE_HANDLE(handler) ") - .\n" \
535c0c34
PA
115 " .popsection\n"
116
548acf19
TL
117# define _ASM_EXTABLE(from, to) \
118 _ASM_EXTABLE_HANDLE(from, to, ex_handler_default)
119
120# define _ASM_EXTABLE_FAULT(from, to) \
121 _ASM_EXTABLE_HANDLE(from, to, ex_handler_fault)
122
123# define _ASM_EXTABLE_EX(from, to) \
124 _ASM_EXTABLE_HANDLE(from, to, ex_handler_ext)
125
376e2424 126/* For C file, we already have NOKPROBE_SYMBOL macro */
709972b1 127#endif
a34746bc 128
0d3109a1
JP
129#ifndef __ASSEMBLY__
130/*
131 * This output constraint should be used for any inline asm which has a "call"
132 * instruction. Otherwise the asm may be inserted before the frame pointer
133 * gets set up by the containing function. If you forget to do this, objtool
134 * may print a "call without frame pointer save/setup" warning.
135 */
136register unsigned int __asm_call_sp asm("esp");
137#define ASM_CALL_CONSTRAINT "+r" (__asm_call_sp)
138#endif
139
1965aae3 140#endif /* _ASM_X86_ASM_H */