[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YUycliX+lPSMhWfR@otcwcpicx3.sc.intel.com>
Date: Thu, 23 Sep 2021 15:26:14 +0000
From: Fenghua Yu <fenghua.yu@...el.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
Andy Lutomirski <luto@...nel.org>,
Dave Hansen <dave.hansen@...el.com>,
Tony Luck <tony.luck@...el.com>,
Lu Baolu <baolu.lu@...ux.intel.com>,
Joerg Roedel <joro@...tes.org>,
Josh Poimboeuf <jpoimboe@...hat.com>,
Dave Jiang <dave.jiang@...el.com>,
Jacob Jun Pan <jacob.jun.pan@...el.com>,
Ashok Raj <ashok.raj@...el.com>,
Ravi V Shankar <ravi.v.shankar@...el.com>,
iommu@...ts.linux-foundation.org, x86 <x86@...nel.org>,
linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 7/8] tools/objtool: Check for use of the ENQCMD
instruction in the kernel
Hi, Peter,
On Thu, Sep 23, 2021 at 09:17:01AM +0200, Peter Zijlstra wrote:
> On Wed, Sep 22, 2021 at 11:44:41PM +0000, Fenghua Yu wrote:
>
> > > Since you're making it a fatal error, before doing much of anything
> > > else, you might at well fail decode and keep it all in the x86/decode.c
> > > file, no need to spread this 'knowledge' any further.
>
> > Is the following updated patch a right one?
>
> Yes, that's what I was thinking of.
>
> > diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c
> > index bc821056aba9..3e0f928e28a5 100644
> > --- a/tools/objtool/arch/x86/decode.c
> > +++ b/tools/objtool/arch/x86/decode.c
> > @@ -110,7 +110,7 @@ int arch_decode_instruction(const struct elf *elf, const struct section *sec,
> > {
> > struct insn insn;
> > int x86_64, ret;
> > - unsigned char op1, op2,
> > + unsigned char op1, op2, op3,
> > rex = 0, rex_b = 0, rex_r = 0, rex_w = 0, rex_x = 0,
> > modrm = 0, modrm_mod = 0, modrm_rm = 0, modrm_reg = 0,
> > sib = 0, /* sib_scale = 0, */ sib_index = 0, sib_base = 0;
> > @@ -137,6 +137,7 @@ int arch_decode_instruction(const struct elf *elf, const struct section *sec,
> >
> > op1 = insn.opcode.bytes[0];
> > op2 = insn.opcode.bytes[1];
> > + op3 = insn.opcode.bytes[2];
> >
> > if (insn.rex_prefix.nbytes) {
> > rex = insn.rex_prefix.bytes[0];
> > @@ -489,6 +490,16 @@ int arch_decode_instruction(const struct elf *elf, const struct section *sec,
> > /* nopl/nopw */
> > *type = INSN_NOP;
> >
> > + } else if (op2 == 0x38 && op3 == 0xf8) {
> > + if (insn.prefixes.nbytes == 1 &&
> > + insn.prefixes.bytes[0] == 0xf2) {
> > + /* ENQCMD cannot be used in the kernel. */
> > + WARN("ENQCMD instruction at %s:%lx", sec->name,
> > + offset);
> > +
> > + return -1;
> > + }
>
> The only concern here is if we want it to be fatal or not. But otherwise
> this seems to be all that's required.
objtool doesn't fail kernel build on this fatal warning.
Returning -1 here stops checking the rest of the file and won't report any
further warnings unless this ENQCMD warning is fixed. Not returning -1
continues checking the rest of the file and may report more warnings.
Seems that's the only difference b/w them.
Should I keep this "return -1" or not? Please advice.
-Fenghua
Powered by blists - more mailing lists