From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752594AbdAZCLi (ORCPT ); Wed, 25 Jan 2017 21:11:38 -0500 Received: from mail.kernel.org ([198.145.29.136]:59744 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752299AbdAZCLg (ORCPT ); Wed, 25 Jan 2017 21:11:36 -0500 Date: Thu, 26 Jan 2017 11:11:21 +0900 From: Masami Hiramatsu To: Ricardo Neri Cc: Ingo Molnar , Thomas Gleixner , "H. Peter Anvin" , Andy Lutomirski , Borislav Petkov , Peter Zijlstra , Andrew Morton , Brian Gerst , Chris Metcalf , Dave Hansen , Paolo Bonzini , Liang Z Li , Masami Hiramatsu , Huang Rui , Jiri Slaby , Jonathan Corbet , "Michael S. Tsirkin" , Paul Gortmaker , Vlastimil Babka , Chen Yucong , Alexandre Julliard , Fenghua Yu , Stas Sergeev , "Ravi V. Shankar" , Shuah Khan , linux-kernel@vger.kernel.org, x86@kernel.org, linux-msdos@vger.kernel.org, wine-devel@winehq.org, Adam Buchbinder , Colin Ian King , Lorenzo Stoakes , Qiaowei Ren , Arnaldo Carvalho de Melo , Adrian Hunter , Kees Cook , Thomas Garnier , Dmitry Vyukov Subject: Re: [v3 PATCH 04/10] x86/insn-kernel: Add a function to obtain register offset in ModRM Message-Id: <20170126111121.2936732c88f1d60fbdc6835a@kernel.org> In-Reply-To: <20170125202353.101059-5-ricardo.neri-calderon@linux.intel.com> References: <20170125202353.101059-1-ricardo.neri-calderon@linux.intel.com> <20170125202353.101059-5-ricardo.neri-calderon@linux.intel.com> X-Mailer: Sylpheed 3.5.0 (GTK+ 2.24.30; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 25 Jan 2017 12:23:47 -0800 Ricardo Neri wrote: > The function insn_get_reg_offset requires a type to indicate whether > the returned offset is that given by by the ModRM or the SIB byte. > Callers of this function would need the definition of the type struct. > This is not needed. Instead, auxiliary functions can be defined for > this purpose. > > When the operand is a register, the emulation code for User-Mode > Instruction Prevention needs to know the offset of the register indicated > in the r/m part of the ModRM byte. Thus, start by adding an auxiliary > function for this purpose. Hmm, why wouldn't you just rename it to insn_get_reg_offset() and export it? Thank you, > > 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: Borislav Petkov > Cc: Dmitry Vyukov > Cc: Ravi V. Shankar > Cc: x86@kernel.org > Signed-off-by: Ricardo Neri > --- > arch/x86/include/asm/insn-kernel.h | 1 + > arch/x86/lib/insn-kernel.c | 5 +++++ > 2 files changed, 6 insertions(+) > > diff --git a/arch/x86/include/asm/insn-kernel.h b/arch/x86/include/asm/insn-kernel.h > index aef416a..3f34649 100644 > --- a/arch/x86/include/asm/insn-kernel.h > +++ b/arch/x86/include/asm/insn-kernel.h > @@ -12,5 +12,6 @@ > #include > > void __user *insn_get_addr_ref(struct insn *insn, struct pt_regs *regs); > +int insn_get_reg_offset_rm(struct insn *insn, struct pt_regs *regs); > > #endif /* _ASM_X86_INSN_KERNEL_H */ > diff --git a/arch/x86/lib/insn-kernel.c b/arch/x86/lib/insn-kernel.c > index 8072abe..267cab4 100644 > --- a/arch/x86/lib/insn-kernel.c > +++ b/arch/x86/lib/insn-kernel.c > @@ -95,6 +95,11 @@ static int get_reg_offset(struct insn *insn, struct pt_regs *regs, > return regoff[regno]; > } > > +int insn_get_reg_offset_rm(struct insn *insn, struct pt_regs *regs) > +{ > + return get_reg_offset(insn, regs, REG_TYPE_RM); > +} > + > /* > * return the address being referenced be instruction > * for rm=3 returning the content of the rm reg > -- > 2.9.3 > -- Masami Hiramatsu