Back to home page

OSCL-LXR

 
 

    


0001 #ifndef _ASM_X86_INSN_EVAL_H
0002 #define _ASM_X86_INSN_EVAL_H
0003 /*
0004  * A collection of utility functions for x86 instruction analysis to be
0005  * used in a kernel context. Useful when, for instance, making sense
0006  * of the registers indicated by operands.
0007  */
0008 
0009 #include <linux/compiler.h>
0010 #include <linux/bug.h>
0011 #include <linux/err.h>
0012 #include <asm/ptrace.h>
0013 
0014 #define INSN_CODE_SEG_ADDR_SZ(params) ((params >> 4) & 0xf)
0015 #define INSN_CODE_SEG_OPND_SZ(params) (params & 0xf)
0016 #define INSN_CODE_SEG_PARAMS(oper_sz, addr_sz) (oper_sz | (addr_sz << 4))
0017 
0018 int pt_regs_offset(struct pt_regs *regs, int regno);
0019 
0020 bool insn_has_rep_prefix(struct insn *insn);
0021 void __user *insn_get_addr_ref(struct insn *insn, struct pt_regs *regs);
0022 int insn_get_modrm_rm_off(struct insn *insn, struct pt_regs *regs);
0023 int insn_get_modrm_reg_off(struct insn *insn, struct pt_regs *regs);
0024 unsigned long *insn_get_modrm_reg_ptr(struct insn *insn, struct pt_regs *regs);
0025 unsigned long insn_get_seg_base(struct pt_regs *regs, int seg_reg_idx);
0026 int insn_get_code_seg_params(struct pt_regs *regs);
0027 int insn_get_effective_ip(struct pt_regs *regs, unsigned long *ip);
0028 int insn_fetch_from_user(struct pt_regs *regs,
0029              unsigned char buf[MAX_INSN_SIZE]);
0030 int insn_fetch_from_user_inatomic(struct pt_regs *regs,
0031                   unsigned char buf[MAX_INSN_SIZE]);
0032 bool insn_decode_from_regs(struct insn *insn, struct pt_regs *regs,
0033                unsigned char buf[MAX_INSN_SIZE], int buf_size);
0034 
0035 enum mmio_type {
0036     MMIO_DECODE_FAILED,
0037     MMIO_WRITE,
0038     MMIO_WRITE_IMM,
0039     MMIO_READ,
0040     MMIO_READ_ZERO_EXTEND,
0041     MMIO_READ_SIGN_EXTEND,
0042     MMIO_MOVS,
0043 };
0044 
0045 enum mmio_type insn_decode_mmio(struct insn *insn, int *bytes);
0046 
0047 #endif /* _ASM_X86_INSN_EVAL_H */