summaryrefslogtreecommitdiff
path: root/arch/x86/kernel
diff options
context:
space:
mode:
authorBorislav Petkov (AMD) <bp@alien8.de>2024-01-30 13:59:40 +0300
committerBorislav Petkov (AMD) <bp@alien8.de>2024-04-09 19:15:03 +0300
commitc3a3cb5c3d893d7ca75c773ddd107832f13e7b57 (patch)
tree88400bf09b2c9349b7259eb0b3b5ee0a4bc6b02e /arch/x86/kernel
parentda8f9cf7e721c690ca169fa88641a6c4cee5cae4 (diff)
downloadlinux-c3a3cb5c3d893d7ca75c773ddd107832f13e7b57.tar.xz
x86/alternatives: Optimize optimize_nops()
Return early if NOPs have already been optimized. Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Link: https://lore.kernel.org/r/20240130105941.19707-4-bp@alien8.de
Diffstat (limited to 'arch/x86/kernel')
-rw-r--r--arch/x86/kernel/alternative.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
index 4b3378c71518..67dd7c371d28 100644
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -233,6 +233,10 @@ static void noinline optimize_nops(const u8 * const instr, u8 *buf, size_t len)
if (insn_is_nop(&insn)) {
int nop = i;
+ /* Has the NOP already been optimized? */
+ if (i + insn.length == len)
+ return;
+
next = skip_nops(buf, next, len);
add_nop(buf + nop, next - nop);