Re: [PATCH 3/3] objtool/x86: Fix NOP decode

From: Peter Zijlstra
Date: Thu Sep 25 2025 - 06:03:36 EST


On Thu, Sep 25, 2025 at 11:55:23AM +0200, Alexandre Chartre wrote:
>
> On 9/24/25 20:41, Peter Zijlstra wrote:
> > On Wed, Sep 24, 2025 at 07:34:00PM +0200, Alexandre Chartre wrote:
> > >
> > > On 9/24/25 15:45, Peter Zijlstra wrote:
> > > > 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@xxxxxxxxxxxxx>
> > > > ---
> > > > tools/objtool/arch/x86/decode.c | 12 +++++++-----
> > > > 1 file changed, 7 insertions(+), 5 deletions(-)
> > > >
> > > > --- a/tools/objtool/arch/x86/decode.c
> > > > +++ b/tools/objtool/arch/x86/decode.c
> > > > @@ -494,7 +494,8 @@ int arch_decode_instruction(struct objto
> > > > break;
> > > > case 0x90:
> > > > + if (prefix != 0xf3) /* REP NOP := PAUSE */
> > > > + insn->type = INSN_NOP;
> > > > break;
> > >
> > > So this covers NOP1 (0x90) and NOP2 (0x66 0x90), right?
> >
> > Yes. Everything with opcode 0x90, except 0xf3 0x90, which as stated is
> > PAUSE.
> >
>
> What about 0x49 0x90, which is xchg (XCHG r8,rAX) ?

Ooh, that is a nice one. Yes, that needs fixing. Thanks!