* [PATCH] x86/alternative: PAUSE is not a NOP
@ 2023-06-14 14:35 Peter Zijlstra
0 siblings, 0 replies; only message in thread
From: Peter Zijlstra @ 2023-06-14 14:35 UTC (permalink / raw)
To: Borislav Petkov; +Cc: linux-kernel, x86
Subject: x86/alternative: PAUSE is not a NOP
From: Peter Zijlstra <peterz@infradead.org>
Date: Wed Jun 14 16:31:35 CEST 2023
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) <peterz@infradead.org>
Link: https://lore.kernel.org/linux-next/20230524130104.GR83892@hirez.programming.kicks-ass.net/
---
arch/x86/kernel/alternative.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -169,9 +169,12 @@ void text_poke_early(void *addr, const v
*/
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;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-06-14 14:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-14 14:35 [PATCH] x86/alternative: PAUSE is not a NOP Peter Zijlstra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®