Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752378AbdIFT1Y (ORCPT ); Wed, 6 Sep 2017 15:27:24 -0400 Received: from mga07.intel.com ([134.134.136.100]:54997 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751941AbdIFT1X (ORCPT ); Wed, 6 Sep 2017 15:27:23 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,355,1500966000"; d="scan'208";a="132483275" Message-ID: <1504726041.19040.10.camel@ranerica-desktop> Subject: Re: [PATCH v8 08/28] x86/mpx, x86/insn: Relocate insn util functions to a new insn-eval file From: Ricardo Neri To: Borislav Petkov Cc: Ingo Molnar , Thomas Gleixner , "H. Peter Anvin" , Andy Lutomirski , Peter Zijlstra , Andrew Morton , Brian Gerst , Chris Metcalf , Dave Hansen , Paolo Bonzini , Masami Hiramatsu , Huang Rui , Jiri Slaby , Jonathan Corbet , "Michael S. Tsirkin" , Paul Gortmaker , Vlastimil Babka , Chen Yucong , "Ravi V. Shankar" , Shuah Khan , linux-kernel@vger.kernel.org, x86@kernel.org, Adam Buchbinder , Colin Ian King , Lorenzo Stoakes , Qiaowei Ren , Arnaldo Carvalho de Melo , Adrian Hunter , Kees Cook , Thomas Garnier , Dmitry Vyukov Date: Wed, 06 Sep 2017 12:27:21 -0700 In-Reply-To: <20170906155430.afl6ym3lyfvpfs5g@pd.tnic> References: <20170819002809.111312-1-ricardo.neri-calderon@linux.intel.com> <20170819002809.111312-9-ricardo.neri-calderon@linux.intel.com> <20170906155430.afl6ym3lyfvpfs5g@pd.tnic> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3484 Lines: 85 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 > > Cc: Andy Lutomirski > > Cc: Dave Hansen > > Cc: Adam Buchbinder > > Cc: Colin Ian King > > Cc: Lorenzo Stoakes > > Cc: Qiaowei Ren > > Cc: Arnaldo Carvalho de Melo > > Cc: Masami Hiramatsu > > Cc: Adrian Hunter > > Cc: Kees Cook > > Cc: Thomas Garnier > > Cc: Peter Zijlstra > > Cc: Dmitry Vyukov > > Cc: Ravi V. Shankar > > Cc: x86@kernel.org > > Signed-off-by: Ricardo Neri > > --- > > <--- ... 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 Thanks you! BR, Ricardo