Skip to content

Commit

Permalink
x86/alternatives: Optimize optimize_nops()
Browse files Browse the repository at this point in the history
Return early if NOPs have already been optimized.

Signed-off-by: Borislav Petkov (AMD) <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
  • Loading branch information
bp3tk0v committed Apr 9, 2024
1 parent da8f9cf commit c3a3cb5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions arch/x86/kernel/alternative.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c3a3cb5

Please sign in to comment.