[v3 PATCH 04/10] x86/insn-kernel: Add a function to obtain register offset in ModRM
Masami Hiramatsu
mhiramat at kernel.org
Wed Jan 25 20:11:21 CST 2017
On Wed, 25 Jan 2017 12:23:47 -0800
Ricardo Neri <ricardo.neri-calderon at linux.intel.com> 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 <dave.hansen at linux.intel.com>
> Cc: Adam Buchbinder <adam.buchbinder at gmail.com>
> Cc: Colin Ian King <colin.king at canonical.com>
> Cc: Lorenzo Stoakes <lstoakes at gmail.com>
> Cc: Qiaowei Ren <qiaowei.ren at intel.com>
> Cc: Arnaldo Carvalho de Melo <acme at redhat.com>
> Cc: Masami Hiramatsu <mhiramat at kernel.org>
> Cc: Adrian Hunter <adrian.hunter at intel.com>
> Cc: Kees Cook <keescook at chromium.org>
> Cc: Thomas Garnier <thgarnie at google.com>
> Cc: Peter Zijlstra <peterz at infradead.org>
> Cc: Borislav Petkov <bp at suse.de>
> Cc: Dmitry Vyukov <dvyukov at google.com>
> Cc: Ravi V. Shankar <ravi.v.shankar at intel.com>
> Cc: x86 at kernel.org
> Signed-off-by: Ricardo Neri <ricardo.neri-calderon at linux.intel.com>
> ---
> 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 <asm/ptrace.h>
>
> 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 <mhiramat at kernel.org>
More information about the wine-devel
mailing list