2017-10-27 20:25:36 +00:00
|
|
|
#ifndef _ASM_X86_INSN_EVAL_H
|
|
|
|
#define _ASM_X86_INSN_EVAL_H
|
|
|
|
/*
|
|
|
|
* A collection of utility functions for x86 instruction analysis to be
|
|
|
|
* used in a kernel context. Useful when, for instance, making sense
|
|
|
|
* of the registers indicated by operands.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/compiler.h>
|
|
|
|
#include <linux/bug.h>
|
|
|
|
#include <linux/err.h>
|
|
|
|
#include <asm/ptrace.h>
|
|
|
|
|
2017-10-27 20:25:43 +00:00
|
|
|
#define INSN_CODE_SEG_ADDR_SZ(params) ((params >> 4) & 0xf)
|
|
|
|
#define INSN_CODE_SEG_OPND_SZ(params) (params & 0xf)
|
|
|
|
#define INSN_CODE_SEG_PARAMS(oper_sz, addr_sz) (oper_sz | (addr_sz << 4))
|
|
|
|
|
2020-09-07 13:15:12 +00:00
|
|
|
bool insn_has_rep_prefix(struct insn *insn);
|
2017-10-27 20:25:36 +00:00
|
|
|
void __user *insn_get_addr_ref(struct insn *insn, struct pt_regs *regs);
|
2017-10-27 20:25:38 +00:00
|
|
|
int insn_get_modrm_rm_off(struct insn *insn, struct pt_regs *regs);
|
2020-09-07 13:15:11 +00:00
|
|
|
int insn_get_modrm_reg_off(struct insn *insn, struct pt_regs *regs);
|
2017-10-27 20:25:42 +00:00
|
|
|
unsigned long insn_get_seg_base(struct pt_regs *regs, int seg_reg_idx);
|
2017-11-23 09:19:51 +00:00
|
|
|
int insn_get_code_seg_params(struct pt_regs *regs);
|
2020-09-07 13:15:09 +00:00
|
|
|
int insn_fetch_from_user(struct pt_regs *regs,
|
|
|
|
unsigned char buf[MAX_INSN_SIZE]);
|
2021-03-03 14:17:16 +00:00
|
|
|
int insn_fetch_from_user_inatomic(struct pt_regs *regs,
|
|
|
|
unsigned char buf[MAX_INSN_SIZE]);
|
2020-11-02 17:47:34 +00:00
|
|
|
bool insn_decode_from_regs(struct insn *insn, struct pt_regs *regs,
|
|
|
|
unsigned char buf[MAX_INSN_SIZE], int buf_size);
|
2017-10-27 20:25:36 +00:00
|
|
|
|
|
|
|
#endif /* _ASM_X86_INSN_EVAL_H */
|