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
This commit is contained in:
Borislav Petkov (AMD)
2024-01-30 11:59:40 +01:00
parent da8f9cf7e7
commit c3a3cb5c3d

View File

@@ -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);