Skip to content

Commit 2bd4aa9

Browse files
Peter Zijlstrabp3tk0v
authored andcommitted
x86/alternative: PAUSE is not a NOP
While chasing ghosts, I did notice that optimize_nops() was replacing 'REP NOP' aka 'PAUSE' with NOP2. This is clearly not right. Fixes: 6c480f2 ("x86/alternative: Rewrite optimize_nops() some") Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Link: https://lore.kernel.org/linux-next/20230524130104.GR83892@hirez.programming.kicks-ass.net/
1 parent 9350a62 commit 2bd4aa9

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

arch/x86/kernel/alternative.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,12 @@ void text_poke_early(void *addr, const void *opcode, size_t len);
169169
*/
170170
static bool insn_is_nop(struct insn *insn)
171171
{
172-
if (insn->opcode.bytes[0] == 0x90)
172+
/* Anything NOP, but no REP NOP */
173+
if (insn->opcode.bytes[0] == 0x90 &&
174+
(!insn->prefixes.nbytes || insn->prefixes.bytes[0] != 0xF3))
173175
return true;
174176

177+
/* NOPL */
175178
if (insn->opcode.bytes[0] == 0x0F && insn->opcode.bytes[1] == 0x1F)
176179
return true;
177180

0 commit comments

Comments
 (0)