]> Git Repo - linux.git/commitdiff
x86/alternative: PAUSE is not a NOP
authorPeter Zijlstra <[email protected]>
Wed, 14 Jun 2023 14:35:50 +0000 (16:35 +0200)
committerBorislav Petkov (AMD) <[email protected]>
Wed, 14 Jun 2023 17:02:54 +0000 (19:02 +0200)
While chasing ghosts, I did notice that optimize_nops() was replacing
'REP NOP' aka 'PAUSE' with NOP2. This is clearly not right.

Fixes: 6c480f222128 ("x86/alternative: Rewrite optimize_nops() some")
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Signed-off-by: Borislav Petkov (AMD) <[email protected]>
Link: https://lore.kernel.org/linux-next/[email protected]/
arch/x86/kernel/alternative.c

index bbfbf7ad17ca6c5aaae71dd3f55be5d260e90958..a7e1ec50ad29d91be2da240b6e13943fc62461e0 100644 (file)
@@ -169,9 +169,12 @@ void text_poke_early(void *addr, const void *opcode, size_t len);
  */
 static bool insn_is_nop(struct insn *insn)
 {
-       if (insn->opcode.bytes[0] == 0x90)
+       /* Anything NOP, but no REP NOP */
+       if (insn->opcode.bytes[0] == 0x90 &&
+           (!insn->prefixes.nbytes || insn->prefixes.bytes[0] != 0xF3))
                return true;
 
+       /* NOPL */
        if (insn->opcode.bytes[0] == 0x0F && insn->opcode.bytes[1] == 0x1F)
                return true;
 
This page took 0.055476 seconds and 4 git commands to generate.