summaryrefslogtreecommitdiffstats
path: root/arch/x86/lib/memset_64.S
diff options
context:
space:
mode:
authorBorislav Petkov <bp@suse.de>2014-12-27 10:41:52 +0100
committerBorislav Petkov <bp@suse.de>2015-02-23 13:44:00 +0100
commit4332195c5615bf748624094ce4ff6797e475024d (patch)
tree7caa974cd666a8280882e9ed6d2093723159b569 /arch/x86/lib/memset_64.S
parentx86/alternatives: Cleanup DPRINTK macro (diff)
downloadlinux-4332195c5615bf748624094ce4ff6797e475024d.tar.xz
linux-4332195c5615bf748624094ce4ff6797e475024d.zip
x86/alternatives: Add instruction padding
Up until now we have always paid attention to make sure the length of the new instruction replacing the old one is at least less or equal to the length of the old instruction. If the new instruction is longer, at the time it replaces the old instruction it will overwrite the beginning of the next instruction in the kernel image and cause your pants to catch fire. So instead of having to pay attention, teach the alternatives framework to pad shorter old instructions with NOPs at buildtime - but only in the case when len(old instruction(s)) < len(new instruction(s)) and add nothing in the >= case. (In that case we do add_nops() when patching). This way the alternatives user shouldn't have to care about instruction sizes and simply use the macros. Add asm ALTERNATIVE* flavor macros too, while at it. Also, we need to save the pad length in a separate struct alt_instr member for NOP optimization and the way to do that reliably is to carry the pad length instead of trying to detect whether we're looking at single-byte NOPs or at pathological instruction offsets like e9 90 90 90 90, for example, which is a valid instruction. Thanks to Michael Matz for the great help with toolchain questions. Signed-off-by: Borislav Petkov <bp@suse.de>
Diffstat (limited to 'arch/x86/lib/memset_64.S')
-rw-r--r--arch/x86/lib/memset_64.S4
1 files changed, 2 insertions, 2 deletions
diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
index 6f44935c6a60..f6153c1cdddc 100644
--- a/arch/x86/lib/memset_64.S
+++ b/arch/x86/lib/memset_64.S
@@ -150,7 +150,7 @@ ENDPROC(__memset)
*/
.section .altinstructions,"a"
altinstruction_entry __memset,.Lmemset_c,X86_FEATURE_REP_GOOD,\
- .Lfinal-__memset,.Lmemset_e-.Lmemset_c
+ .Lfinal-__memset,.Lmemset_e-.Lmemset_c,0
altinstruction_entry __memset,.Lmemset_c_e,X86_FEATURE_ERMS, \
- .Lfinal-__memset,.Lmemset_e_e-.Lmemset_c_e
+ .Lfinal-__memset,.Lmemset_e_e-.Lmemset_c_e,0
.previous