Re: [PATCH v8 08/28] x86/mpx, x86/insn: Relocate insn util functions to a new insn-eval file

From: Ricardo Neri
Date: Wed Sep 06 2017 - 15:27:31 EST


On Wed, 2017-09-06 at 17:54 +0200, Borislav Petkov wrote:
> On Fri, Aug 18, 2017 at 05:27:49PM -0700, Ricardo Neri wrote:
> > Other kernel submodules can benefit from using the utility functions
> > defined in mpx.c to obtain the addresses and values of operands contained
> > in the general purpose registers. An instance of this is the emulation code
> > used for instructions protected by the Intel User-Mode Instruction
> > Prevention feature.
> >
> > Thus, these functions are relocated to a new insn-eval.c file. The reason
> > to not relocate these utilities into insn.c is that the latter solely
> > analyses instructions given by a struct insn without any knowledge of the
> > meaning of the values of instruction operands. This new utility insn-
> > eval.c aims to be used to resolve and userspace linear addresses based on
> ^
> |
>
> something's missing there - "kernel" maybe?

I have updated this line to read "This new utility insn-eval.c aims to
be used to resolve userspace linear addresses based on the contents of
the instruction operands as well as the contents of pt_regs structure."

>
> > the contents of the instruction operands as well as the contents of pt_regs
> > structure.
> >
> > These utilities come with a separate header. This is to avoid taking insn.c
> > out of sync from the instructions decoders under tools/obj and tools/perf.
> > This also avoids adding cumbersome #ifdef's for the #include'd files
> > required to decode instructions in a kernel context.
> >
> > Functions are simply relocated. There are not functional or indentation
> > changes.
>
> That text below you don't need to have in the commit message. Patch
> handling and other modalities are usually put after the "---" and before
> the diffstat below...
>
> > The checkpatch script issues the following warning with this
> > commit:
> >
> > WARNING: Avoid crashing the kernel - try using WARN_ON & recovery code
> > rather than BUG() or BUG_ON()
> > + BUG();
> >
> > This warning will be fixed in a subsequent patch.
> >
> > Cc: Borislav Petkov <bp@xxxxxxx>
> > Cc: Andy Lutomirski <luto@xxxxxxxxxx>
> > Cc: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
> > Cc: Adam Buchbinder <adam.buchbinder@xxxxxxxxx>
> > Cc: Colin Ian King <colin.king@xxxxxxxxxxxxx>
> > Cc: Lorenzo Stoakes <lstoakes@xxxxxxxxx>
> > Cc: Qiaowei Ren <qiaowei.ren@xxxxxxxxx>
> > Cc: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
> > Cc: Masami Hiramatsu <mhiramat@xxxxxxxxxx>
> > Cc: Adrian Hunter <adrian.hunter@xxxxxxxxx>
> > Cc: Kees Cook <keescook@xxxxxxxxxxxx>
> > Cc: Thomas Garnier <thgarnie@xxxxxxxxxx>
> > Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> > Cc: Dmitry Vyukov <dvyukov@xxxxxxxxxx>
> > Cc: Ravi V. Shankar <ravi.v.shankar@xxxxxxxxx>
> > Cc: x86@xxxxxxxxxx
> > Signed-off-by: Ricardo Neri <ricardo.neri-calderon@xxxxxxxxxxxxxxx>
> > ---
>
> <--- ... here. Put such notes here.

Thanks for explaining this to me. I will move the note about the warning
here.
>
> > arch/x86/include/asm/insn-eval.h | 16 ++++
> > arch/x86/lib/Makefile | 2 +-
> > arch/x86/lib/insn-eval.c | 163 +++++++++++++++++++++++++++++++++++++++
> > arch/x86/mm/mpx.c | 156 +------------------------------------
> > 4 files changed, 182 insertions(+), 155 deletions(-)
> > create mode 100644 arch/x86/include/asm/insn-eval.h
> > create mode 100644 arch/x86/lib/insn-eval.c
>
> Reviewed-by: Borislav Petkov <bp@xxxxxxx>

Thanks you!

BR,
Ricardo