blob: e1d3b4ce8a925350df55f898dbdb9cf0f416881f [file] [log] [blame]
Ricardo Neri32542ee2017-10-27 13:25:36 -07001#ifndef _ASM_X86_INSN_EVAL_H
2#define _ASM_X86_INSN_EVAL_H
3/*
4 * A collection of utility functions for x86 instruction analysis to be
5 * used in a kernel context. Useful when, for instance, making sense
6 * of the registers indicated by operands.
7 */
8
9#include <linux/compiler.h>
10#include <linux/bug.h>
11#include <linux/err.h>
12#include <asm/ptrace.h>
13
Ricardo Neri4efea852017-10-27 13:25:43 -070014#define INSN_CODE_SEG_ADDR_SZ(params) ((params >> 4) & 0xf)
15#define INSN_CODE_SEG_OPND_SZ(params) (params & 0xf)
16#define INSN_CODE_SEG_PARAMS(oper_sz, addr_sz) (oper_sz | (addr_sz << 4))
17
Ricardo Neri32542ee2017-10-27 13:25:36 -070018void __user *insn_get_addr_ref(struct insn *insn, struct pt_regs *regs);
Ricardo Nerie5e45f12017-10-27 13:25:38 -070019int insn_get_modrm_rm_off(struct insn *insn, struct pt_regs *regs);
Ricardo Neribd5a4102017-10-27 13:25:42 -070020unsigned long insn_get_seg_base(struct pt_regs *regs, int seg_reg_idx);
Ricardo Neri4efea852017-10-27 13:25:43 -070021char insn_get_code_seg_params(struct pt_regs *regs);
Ricardo Neri32542ee2017-10-27 13:25:36 -070022
23#endif /* _ASM_X86_INSN_EVAL_H */