Lines Matching refs:insn
23 struct insn { struct
89 extern void insn_init(struct insn *insn, const void *kaddr, int buf_len, int x86_64);
90 extern int insn_get_prefixes(struct insn *insn);
91 extern int insn_get_opcode(struct insn *insn);
92 extern int insn_get_modrm(struct insn *insn);
93 extern int insn_get_sib(struct insn *insn);
94 extern int insn_get_displacement(struct insn *insn);
95 extern int insn_get_immediate(struct insn *insn);
96 extern int insn_get_length(struct insn *insn);
106 extern int insn_decode(struct insn *insn, const void *kaddr, int buf_len, enum insn_mode m);
111 static inline void insn_get_attribute(struct insn *insn) in insn_get_attribute() argument
113 insn_get_modrm(insn); in insn_get_attribute()
117 extern int insn_rip_relative(struct insn *insn);
120 static inline void kernel_insn_init(struct insn *insn, in kernel_insn_init() argument
124 insn_init(insn, kaddr, buf_len, 1); in kernel_insn_init()
126 insn_init(insn, kaddr, buf_len, 0); in kernel_insn_init()
130 static inline int insn_is_avx(struct insn *insn) in insn_is_avx() argument
132 if (!insn->prefixes.got) in insn_is_avx()
133 insn_get_prefixes(insn); in insn_is_avx()
134 return (insn->vex_prefix.value != 0); in insn_is_avx()
137 static inline int insn_is_evex(struct insn *insn) in insn_is_evex() argument
139 if (!insn->prefixes.got) in insn_is_evex()
140 insn_get_prefixes(insn); in insn_is_evex()
141 return (insn->vex_prefix.nbytes == 4); in insn_is_evex()
144 static inline int insn_has_emulate_prefix(struct insn *insn) in insn_has_emulate_prefix() argument
146 return !!insn->emulate_prefix_size; in insn_has_emulate_prefix()
150 static inline int insn_complete(struct insn *insn) in insn_complete() argument
152 return insn->opcode.got && insn->modrm.got && insn->sib.got && in insn_complete()
153 insn->displacement.got && insn->immediate.got; in insn_complete()
156 static inline insn_byte_t insn_vex_m_bits(struct insn *insn) in insn_vex_m_bits() argument
158 if (insn->vex_prefix.nbytes == 2) /* 2 bytes VEX */ in insn_vex_m_bits()
160 else if (insn->vex_prefix.nbytes == 3) /* 3 bytes VEX */ in insn_vex_m_bits()
161 return X86_VEX3_M(insn->vex_prefix.bytes[1]); in insn_vex_m_bits()
163 return X86_EVEX_M(insn->vex_prefix.bytes[1]); in insn_vex_m_bits()
166 static inline insn_byte_t insn_vex_p_bits(struct insn *insn) in insn_vex_p_bits() argument
168 if (insn->vex_prefix.nbytes == 2) /* 2 bytes VEX */ in insn_vex_p_bits()
169 return X86_VEX_P(insn->vex_prefix.bytes[1]); in insn_vex_p_bits()
171 return X86_VEX_P(insn->vex_prefix.bytes[2]); in insn_vex_p_bits()
175 static inline int insn_last_prefix_id(struct insn *insn) in insn_last_prefix_id() argument
177 if (insn_is_avx(insn)) in insn_last_prefix_id()
178 return insn_vex_p_bits(insn); /* VEX_p is a SIMD prefix id */ in insn_last_prefix_id()
180 if (insn->prefixes.bytes[3]) in insn_last_prefix_id()
181 return inat_get_last_prefix_id(insn->prefixes.bytes[3]); in insn_last_prefix_id()
187 static inline int insn_offset_rex_prefix(struct insn *insn) in insn_offset_rex_prefix() argument
189 return insn->prefixes.nbytes; in insn_offset_rex_prefix()
191 static inline int insn_offset_vex_prefix(struct insn *insn) in insn_offset_vex_prefix() argument
193 return insn_offset_rex_prefix(insn) + insn->rex_prefix.nbytes; in insn_offset_vex_prefix()
195 static inline int insn_offset_opcode(struct insn *insn) in insn_offset_opcode() argument
197 return insn_offset_vex_prefix(insn) + insn->vex_prefix.nbytes; in insn_offset_opcode()
199 static inline int insn_offset_modrm(struct insn *insn) in insn_offset_modrm() argument
201 return insn_offset_opcode(insn) + insn->opcode.nbytes; in insn_offset_modrm()
203 static inline int insn_offset_sib(struct insn *insn) in insn_offset_sib() argument
205 return insn_offset_modrm(insn) + insn->modrm.nbytes; in insn_offset_sib()
207 static inline int insn_offset_displacement(struct insn *insn) in insn_offset_displacement() argument
209 return insn_offset_sib(insn) + insn->sib.nbytes; in insn_offset_displacement()
211 static inline int insn_offset_immediate(struct insn *insn) in insn_offset_immediate() argument
213 return insn_offset_displacement(insn) + insn->displacement.nbytes; in insn_offset_immediate()
228 #define for_each_insn_prefix(insn, idx, prefix) \ argument
229 …for (idx = 0; idx < ARRAY_SIZE(insn->prefixes.bytes) && (prefix = insn->prefixes.bytes[idx]) != 0;…
242 static inline int insn_masking_exception(struct insn *insn) in insn_masking_exception() argument
244 return insn->opcode.bytes[0] == POP_SS_OPCODE || in insn_masking_exception()
245 (insn->opcode.bytes[0] == MOV_SREG_OPCODE && in insn_masking_exception()
246 X86_MODRM_REG(insn->modrm.bytes[0]) == 2); in insn_masking_exception()