1 #ifndef __ASM_ALTERNATIVE_H
2 #define __ASM_ALTERNATIVE_H
4 #include <linux/types.h>
5 #include <linux/stddef.h>
6 #include <linux/stringify.h>
9 s32 orig_offset; /* offset to original instruction */
10 s32 alt_offset; /* offset to replacement instruction */
11 u16 cpufeature; /* cpufeature bit set for replacement */
12 u8 orig_len; /* size of original instruction(s) */
13 u8 alt_len; /* size of new instruction(s), <= orig_len */
16 void apply_alternatives_all(void);
17 void apply_alternatives(void *start, size_t length);
18 void free_alternatives_memory(void);
20 #define ALTINSTR_ENTRY(feature) \
21 " .word 661b - .\n" /* label */ \
22 " .word 663f - .\n" /* new instruction */ \
23 " .hword " __stringify(feature) "\n" /* feature bit */ \
24 " .byte 662b-661b\n" /* source len */ \
25 " .byte 664f-663f\n" /* replacement len */
27 /* alternative assembly primitive: */
28 #define ALTERNATIVE(oldinstr, newinstr, feature) \
32 ".pushsection .altinstructions,\"a\"\n" \
33 ALTINSTR_ENTRY(feature) \
35 ".pushsection .altinstr_replacement, \"a\"\n" \
40 ".if ((664b-663b) != (662b-661b))\n\t" \
41 " .error \"Alternatives instruction length mismatch\"\n\t"\
44 #endif /* __ASM_ALTERNATIVE_H */