Re: [PATCH v3 04/21] x86/insn: Add an insn_decode() API

From: Arnaldo Carvalho de Melo
Date: Wed Mar 24 2021 - 09:44:10 EST


Em Tue, Mar 16, 2021 at 06:14:54PM -0700, Ian Rogers escreveu:
> On Thu, Mar 4, 2021 at 9:56 AM Borislav Petkov <bp@xxxxxxxxx> wrote:
> > From: Borislav Petkov <bp@xxxxxxx>
> >
> > Users of the instruction decoder should use this to decode instruction
> > bytes. For that, have insn*() helpers return an int value to denote
> > success/failure. When there's an error fetching the next insn byte and
> > the insn falls short, return -ENODATA to denote that.
> >
> > While at it, make insn_get_opcode() more stricter as to whether what has
> > seen so far is a valid insn and if not.
> >
> > Copy linux/kconfig.h for the tools-version of the decoder so that it can
> > use IS_ENABLED().
> >
> > Also, cast the INSN_MODE_KERN dummy define value to (enum insn_mode)
> > for tools use of the decoder because perf tool builds with -Werror and
> > errors out with -Werror=sign-compare otherwise.
> >
> > Signed-off-by: Borislav Petkov <bp@xxxxxxx>
> > Acked-by: Masami Hiramatsu <mhiramat@xxxxxxxxxx>

> > +++ b/tools/arch/x86/lib/insn.c
> > @@ -11,10 +11,13 @@
> > #else
> > #include <string.h>
> > #endif
> > -#include "../include/asm/inat.h" /* __ignore_sync_check__ */
> > -#include "../include/asm/insn.h" /* __ignore_sync_check__ */
> > +#include <asm/inat.h> /*__ignore_sync_check__ */
> > +#include <asm/insn.h> /* __ignore_sync_check__ */
>
> Hi, this change is breaking non-x86 builds of perf for me in
> tip.git/master. The reason being that non-x86 builds compile the
> intel-pt-decoder, which includes this file, but don't have their
> include paths set to find tools/arch/x86. I think we want to keep the
> relative paths.

Borislav, was this addressed? Ian?

- Arnaldo