1 #ifndef _ASM_X86_ALTERNATIVE_ASM_H
2 #define _ASM_X86_ALTERNATIVE_ASM_H
11 .pushsection
.smp_locks
,"a"
22 * Issue one struct alt_instr descriptor entry (need to put it into
23 * the section .altinstructions, see below). This entry contains
24 * enough information for the alternatives patching code to patch an
25 * instruction. See apply_alternatives().
27 .macro altinstruction_entry orig alt feature orig_len alt_len pad_len
37 * Define an alternative between two instructions. If @feature is
38 * present, early code in apply_alternatives() replaces @oldinstr with
39 * @newinstr. ".skip" directive takes care of proper instruction padding
40 * in case @newinstr is longer than @oldinstr.
42 .macro ALTERNATIVE oldinstr
, newinstr
, feature
46 .skip
-(((144f
-143f
)-(141b
-140b
)) > 0) * ((144f
-143f
)-(141b
-140b
)),0x90
49 .pushsection
.altinstructions
,"a"
50 altinstruction_entry
140b
,143f
,\feature
,142b
-140b
,144f
-143f
,142b
-141b
53 .pushsection
.altinstr_replacement
,"ax"
60 #define old_len 141b-140b
61 #define new_len1 144f-143f
62 #define new_len2 145f-144f
65 * max without conditionals. Idea adapted from:
66 * http://graphics.stanford.edu/~seander/bithacks.html#IntegerMinOrMax
68 #define alt_max_short(a, b) ((a) ^ (((a) ^ (b)) & -(-((a) < (b)))))
72 * Same as ALTERNATIVE macro above but for two alternatives. If CPU
73 * has @feature1, it replaces @oldinstr with @newinstr1. If CPU has
74 * @feature2, it replaces @oldinstr with @feature2.
76 .macro ALTERNATIVE_2 oldinstr
, newinstr1
, feature1
, newinstr2
, feature2
80 .skip
-((alt_max_short(new_len1
, new_len2
) - (old_len
)) > 0) * \
81 (alt_max_short(new_len1
, new_len2
) - (old_len
)),0x90
84 .pushsection
.altinstructions
,"a"
85 altinstruction_entry
140b
,143f
,\feature
1,142b
-140b
,144f
-143f
,142b
-141b
86 altinstruction_entry
140b
,144f
,\feature
2,142b
-140b
,145f
-144f
,142b
-141b
89 .pushsection
.altinstr_replacement
,"ax"
98 #endif /* __ASSEMBLY__ */
100 #endif /* _ASM_X86_ALTERNATIVE_ASM_H */