Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

+11 -4
+11 -4
tools/objtool/arch/x86/decode.c
··· 494 494 break; 495 495 496 496 case 0x90: 497 + if (rex_b) /* XCHG %r8, %rax */ 498 + break; 499 + 500 + if (prefix == 0xf3) /* REP NOP := PAUSE */ 501 + break; 502 + 497 503 insn->type = INSN_NOP; 498 504 break; 499 505 ··· 553 547 554 548 } else if (op2 == 0x0b || op2 == 0xb9) { 555 549 556 - /* ud2 */ 550 + /* ud2, ud1 */ 557 551 insn->type = INSN_BUG; 558 552 559 - } else if (op2 == 0x0d || op2 == 0x1f) { 553 + } else if (op2 == 0x1f) { 560 554 561 - /* nopl/nopw */ 562 - insn->type = INSN_NOP; 555 + /* 0f 1f /0 := NOPL */ 556 + if (modrm_reg == 0) 557 + insn->type = INSN_NOP; 563 558 564 559 } else if (op2 == 0x1e) { 565 560