^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) #ifndef _ASM_X86_INSN_EVAL_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #define _ASM_X86_INSN_EVAL_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * A collection of utility functions for x86 instruction analysis to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * used in a kernel context. Useful when, for instance, making sense
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * of the registers indicated by operands.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/compiler.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/bug.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/err.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <asm/ptrace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #define INSN_CODE_SEG_ADDR_SZ(params) ((params >> 4) & 0xf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #define INSN_CODE_SEG_OPND_SZ(params) (params & 0xf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #define INSN_CODE_SEG_PARAMS(oper_sz, addr_sz) (oper_sz | (addr_sz << 4))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) bool insn_has_rep_prefix(struct insn *insn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) void __user *insn_get_addr_ref(struct insn *insn, struct pt_regs *regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) int insn_get_modrm_rm_off(struct insn *insn, struct pt_regs *regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) int insn_get_modrm_reg_off(struct insn *insn, struct pt_regs *regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) unsigned long insn_get_seg_base(struct pt_regs *regs, int seg_reg_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) int insn_get_code_seg_params(struct pt_regs *regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) unsigned long insn_get_effective_ip(struct pt_regs *regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) int insn_fetch_from_user(struct pt_regs *regs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) unsigned char buf[MAX_INSN_SIZE]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) int insn_fetch_from_user_inatomic(struct pt_regs *regs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) unsigned char buf[MAX_INSN_SIZE]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) bool insn_decode(struct insn *insn, struct pt_regs *regs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) unsigned char buf[MAX_INSN_SIZE], int buf_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #endif /* _ASM_X86_INSN_EVAL_H */