aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Zijlstra <[email protected]>2023-06-14 16:35:50 +0200
committerBorislav Petkov (AMD) <[email protected]>2023-06-14 19:02:54 +0200
commit2bd4aa9325821551648cf9738d6aa3a49317d7e5 (patch)
tree86d2e879140656fc0df9330afd349bf85490d4d7
parent9350a629e839ca1c2b529a83a916cf2370bd1c64 (diff)
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: 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]/
-rw-r--r--arch/x86/kernel/alternative.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
index bbfbf7ad17ca..a7e1ec50ad29 100644
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -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;