summaryrefslogtreecommitdiff
path: root/tools/objtool/arch
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2025-09-24 15:27:03 +0200
committerPeter Zijlstra <peterz@infradead.org>2025-10-14 13:43:11 +0200
commit044f721ccd33103349eebbb960825584bc6d8e23 (patch)
tree3e9c6be0aa5d332a7e50798611fafdd60b7a7a1e /tools/objtool/arch
parent76e1851a1bc28e760d6acc7a54ec9dce05717028 (diff)
objtool/x86: Fix NOP decode
For x86_64 the kernel consistently uses 2 instructions for all NOPs: 90 - NOP 0f 1f /0 - NOPL Notably: - REP NOP is PAUSE, not a NOP instruction. - 0f {0c...0f} is reserved space, except for 0f 0d /1, which is PREFETCHW, not a NOP. - 0f {19,1c...1f} is reserved space, except for 0f 1f /0, which is NOPL. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Diffstat (limited to 'tools/objtool/arch')
-rw-r--r--tools/objtool/arch/x86/decode.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c
index ef6e96db8ce4..204e2ad1fada 100644
--- a/tools/objtool/arch/x86/decode.c
+++ b/tools/objtool/arch/x86/decode.c
@@ -494,6 +494,12 @@ int arch_decode_instruction(struct objtool_file *file, const struct section *sec
break;
case 0x90:
+ if (rex_b) /* XCHG %r8, %rax */
+ break;
+
+ if (prefix == 0xf3) /* REP NOP := PAUSE */
+ break;
+
insn->type = INSN_NOP;
break;
@@ -547,13 +553,14 @@ int arch_decode_instruction(struct objtool_file *file, const struct section *sec
} else if (op2 == 0x0b || op2 == 0xb9) {
- /* ud2 */
+ /* ud2, ud1 */
insn->type = INSN_BUG;
- } else if (op2 == 0x0d || op2 == 0x1f) {
+ } else if (op2 == 0x1f) {
- /* nopl/nopw */
- insn->type = INSN_NOP;
+ /* 0f 1f /0 := NOPL */
+ if (modrm_reg == 0)
+ insn->type = INSN_NOP;
} else if (op2 == 0x1e) {