Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/alternatives: Document macros

Add some text to the macro magic for future reference and against
failing human memory.

Requested-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Borislav Petkov and committed by
Ingo Molnar
5b673a48 d9ee948d

+18
+18
arch/x86/include/asm/alternative-asm.h
··· 18 18 .endm 19 19 #endif 20 20 21 + /* 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(). 26 + */ 21 27 .macro altinstruction_entry orig alt feature orig_len alt_len pad_len 22 28 .long \orig - . 23 29 .long \alt - . ··· 33 27 .byte \pad_len 34 28 .endm 35 29 30 + /* 31 + * Define an alternative between two instructions. If @feature is 32 + * present, early code in apply_alternatives() replaces @oldinstr with 33 + * @newinstr. ".skip" directive takes care of proper instruction padding 34 + * in case @newinstr is longer than @oldinstr. 35 + */ 36 36 .macro ALTERNATIVE oldinstr, newinstr, feature 37 37 140: 38 38 \oldinstr ··· 67 55 */ 68 56 #define alt_max_short(a, b) ((a) ^ (((a) ^ (b)) & -(-((a) < (b))))) 69 57 58 + 59 + /* 60 + * Same as ALTERNATIVE macro above but for two alternatives. If CPU 61 + * has @feature1, it replaces @oldinstr with @newinstr1. If CPU has 62 + * @feature2, it replaces @oldinstr with @feature2. 63 + */ 70 64 .macro ALTERNATIVE_2 oldinstr, newinstr1, feature1, newinstr2, feature2 71 65 140: 72 66 \oldinstr