Linux Perf
insn.h File Reference
#include "inat.h"
Include dependency graph for insn.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  insn_field
 
struct  insn
 

Macros

#define MAX_INSN_SIZE   15
 
#define X86_MODRM_MOD(modrm)   (((modrm) & 0xc0) >> 6)
 
#define X86_MODRM_REG(modrm)   (((modrm) & 0x38) >> 3)
 
#define X86_MODRM_RM(modrm)   ((modrm) & 0x07)
 
#define X86_SIB_SCALE(sib)   (((sib) & 0xc0) >> 6)
 
#define X86_SIB_INDEX(sib)   (((sib) & 0x38) >> 3)
 
#define X86_SIB_BASE(sib)   ((sib) & 0x07)
 
#define X86_REX_W(rex)   ((rex) & 8)
 
#define X86_REX_R(rex)   ((rex) & 4)
 
#define X86_REX_X(rex)   ((rex) & 2)
 
#define X86_REX_B(rex)   ((rex) & 1)
 
#define X86_VEX_W(vex)   ((vex) & 0x80) /* VEX3 Byte2 */
 
#define X86_VEX_R(vex)   ((vex) & 0x80) /* VEX2/3 Byte1 */
 
#define X86_VEX_X(vex)   ((vex) & 0x40) /* VEX3 Byte1 */
 
#define X86_VEX_B(vex)   ((vex) & 0x20) /* VEX3 Byte1 */
 
#define X86_VEX_L(vex)   ((vex) & 0x04) /* VEX3 Byte2, VEX2 Byte1 */
 
#define X86_EVEX_M(vex)   ((vex) & 0x03) /* EVEX Byte1 */
 
#define X86_VEX3_M(vex)   ((vex) & 0x1f) /* VEX3 Byte1 */
 
#define X86_VEX2_M   1 /* VEX2.M always 1 */
 
#define X86_VEX_V(vex)   (((vex) & 0x78) >> 3) /* VEX3 Byte2, VEX2 Byte1 */
 
#define X86_VEX_P(vex)   ((vex) & 0x03) /* VEX3 Byte2, VEX2 Byte1 */
 
#define X86_VEX_M_MAX   0x1f /* VEX3.M Maximum value */
 
#define POP_SS_OPCODE   0x1f
 
#define MOV_SREG_OPCODE   0x8e
 

Functions

void insn_init (struct insn *insn, const void *kaddr, int buf_len, int x86_64)
 
void insn_get_prefixes (struct insn *insn)
 
void insn_get_opcode (struct insn *insn)
 
void insn_get_modrm (struct insn *insn)
 
void insn_get_sib (struct insn *insn)
 
void insn_get_displacement (struct insn *insn)
 
void insn_get_immediate (struct insn *insn)
 
void insn_get_length (struct insn *insn)
 
static void insn_get_attribute (struct insn *insn)
 
int insn_rip_relative (struct insn *insn)
 
static void kernel_insn_init (struct insn *insn, const void *kaddr, int buf_len)
 
static int insn_is_avx (struct insn *insn)
 
static int insn_is_evex (struct insn *insn)
 
static int insn_complete (struct insn *insn)
 
static insn_byte_t insn_vex_m_bits (struct insn *insn)
 
static insn_byte_t insn_vex_p_bits (struct insn *insn)
 
static int insn_last_prefix_id (struct insn *insn)
 
static int insn_offset_rex_prefix (struct insn *insn)
 
static int insn_offset_vex_prefix (struct insn *insn)
 
static int insn_offset_opcode (struct insn *insn)
 
static int insn_offset_modrm (struct insn *insn)
 
static int insn_offset_sib (struct insn *insn)
 
static int insn_offset_displacement (struct insn *insn)
 
static int insn_offset_immediate (struct insn *insn)
 
static int insn_masking_exception (struct insn *insn)
 

Macro Definition Documentation

◆ MAX_INSN_SIZE

#define MAX_INSN_SIZE   15

Definition at line 72 of file insn.h.

◆ MOV_SREG_OPCODE

#define MOV_SREG_OPCODE   0x8e

Definition at line 212 of file insn.h.

◆ POP_SS_OPCODE

#define POP_SS_OPCODE   0x1f

Definition at line 211 of file insn.h.

◆ X86_EVEX_M

#define X86_EVEX_M (   vex)    ((vex) & 0x03) /* EVEX Byte1 */

Definition at line 94 of file insn.h.

◆ X86_MODRM_MOD

#define X86_MODRM_MOD (   modrm)    (((modrm) & 0xc0) >> 6)

Definition at line 74 of file insn.h.

◆ X86_MODRM_REG

#define X86_MODRM_REG (   modrm)    (((modrm) & 0x38) >> 3)

Definition at line 75 of file insn.h.

◆ X86_MODRM_RM

#define X86_MODRM_RM (   modrm)    ((modrm) & 0x07)

Definition at line 76 of file insn.h.

◆ X86_REX_B

#define X86_REX_B (   rex)    ((rex) & 1)

Definition at line 85 of file insn.h.

◆ X86_REX_R

#define X86_REX_R (   rex)    ((rex) & 4)

Definition at line 83 of file insn.h.

◆ X86_REX_W

#define X86_REX_W (   rex)    ((rex) & 8)

Definition at line 82 of file insn.h.

◆ X86_REX_X

#define X86_REX_X (   rex)    ((rex) & 2)

Definition at line 84 of file insn.h.

◆ X86_SIB_BASE

#define X86_SIB_BASE (   sib)    ((sib) & 0x07)

Definition at line 80 of file insn.h.

◆ X86_SIB_INDEX

#define X86_SIB_INDEX (   sib)    (((sib) & 0x38) >> 3)

Definition at line 79 of file insn.h.

◆ X86_SIB_SCALE

#define X86_SIB_SCALE (   sib)    (((sib) & 0xc0) >> 6)

Definition at line 78 of file insn.h.

◆ X86_VEX2_M

#define X86_VEX2_M   1 /* VEX2.M always 1 */

Definition at line 96 of file insn.h.

◆ X86_VEX3_M

#define X86_VEX3_M (   vex)    ((vex) & 0x1f) /* VEX3 Byte1 */

Definition at line 95 of file insn.h.

◆ X86_VEX_B

#define X86_VEX_B (   vex)    ((vex) & 0x20) /* VEX3 Byte1 */

Definition at line 91 of file insn.h.

◆ X86_VEX_L

#define X86_VEX_L (   vex)    ((vex) & 0x04) /* VEX3 Byte2, VEX2 Byte1 */

Definition at line 92 of file insn.h.

◆ X86_VEX_M_MAX

#define X86_VEX_M_MAX   0x1f /* VEX3.M Maximum value */

Definition at line 99 of file insn.h.

◆ X86_VEX_P

#define X86_VEX_P (   vex)    ((vex) & 0x03) /* VEX3 Byte2, VEX2 Byte1 */

Definition at line 98 of file insn.h.

◆ X86_VEX_R

#define X86_VEX_R (   vex)    ((vex) & 0x80) /* VEX2/3 Byte1 */

Definition at line 89 of file insn.h.

◆ X86_VEX_V

#define X86_VEX_V (   vex)    (((vex) & 0x78) >> 3) /* VEX3 Byte2, VEX2 Byte1 */

Definition at line 97 of file insn.h.

◆ X86_VEX_W

#define X86_VEX_W (   vex)    ((vex) & 0x80) /* VEX3 Byte2 */

Definition at line 88 of file insn.h.

◆ X86_VEX_X

#define X86_VEX_X (   vex)    ((vex) & 0x40) /* VEX3 Byte1 */

Definition at line 90 of file insn.h.

Function Documentation

◆ insn_complete()

static int insn_complete ( struct insn insn)
inlinestatic

Definition at line 145 of file insn.h.

◆ insn_get_attribute()

static void insn_get_attribute ( struct insn insn)
inlinestatic

Definition at line 111 of file insn.h.

Here is the call graph for this function:

◆ insn_get_displacement()

void insn_get_displacement ( struct insn insn)

insn_get_displacement() - Get the displacement of instruction : &struct insn containing instruction

If necessary, first collects the instruction up to and including the SIB byte. Displacement value is sign-expanded.

Definition at line 357 of file insn.c.

Here is the call graph for this function:

◆ insn_get_immediate()

void insn_get_immediate ( struct insn insn)

insn_get_immediate() - Get the immediates of instruction : &struct insn containing instruction

If necessary, first collects the instruction up to and including the displacement bytes. Basically, most of immediates are sign-expanded. Unsigned-value can be get by bit masking with ((1 << (nbytes * 8)) - 1)

Definition at line 528 of file insn.c.

Here is the call graph for this function:

◆ insn_get_length()

void insn_get_length ( struct insn insn)

insn_get_length() - Get the length of instruction : &struct insn containing instruction

If necessary, first collects the instruction up to and including the immediates bytes.

Definition at line 598 of file insn.c.

Here is the call graph for this function:

◆ insn_get_modrm()

void insn_get_modrm ( struct insn insn)

insn_get_modrm - collect ModRM byte, if any : &struct insn containing instruction

Populates ->modrm and updates ->next_byte to point past the ModRM byte, if any. If necessary, first collects the preceding bytes (prefixes and opcode(s)). No effect if ->modrm.got is already 1.

Definition at line 266 of file insn.c.

Here is the call graph for this function:

◆ insn_get_opcode()

void insn_get_opcode ( struct insn insn)

insn_get_opcode - collect opcode(s) : &struct insn containing instruction

Populates ->opcode, updates ->next_byte to point past the opcode byte(s), and set ->attr (except for groups). If necessary, first collects any preceding (prefix) bytes. Sets ->opcode.value = opcode1. No effect if ->opcode.got is already 1.

Definition at line 213 of file insn.c.

Here is the call graph for this function:

◆ insn_get_prefixes()

void insn_get_prefixes ( struct insn insn)

insn_get_prefixes - scan x86 instruction prefix bytes : &struct insn containing instruction

Populates the ->prefixes bitmap, and updates ->next_byte to point to the (first) opcode. No effect if ->prefixes.got is already set.

Definition at line 82 of file insn.c.

Here is the call graph for this function:

◆ insn_get_sib()

void insn_get_sib ( struct insn insn)

insn_get_sib() - Get the SIB byte of instruction : &struct insn containing instruction

If necessary, first collects the instruction up to and including the ModRM byte.

Definition at line 326 of file insn.c.

Here is the call graph for this function:

◆ insn_init()

void insn_init ( struct insn insn,
const void *  kaddr,
int  buf_len,
int  x86_64 
)

insn_init() - initialize struct insn : &struct insn to be initialized : address (in kernel memory) of instruction (or copy thereof) : !0 for 64-bit kernel or 64-bit app

Definition at line 53 of file insn.c.

Here is the call graph for this function:

◆ insn_is_avx()

static int insn_is_avx ( struct insn insn)
inlinestatic

Definition at line 130 of file insn.h.

Here is the call graph for this function:

◆ insn_is_evex()

static int insn_is_evex ( struct insn insn)
inlinestatic

Definition at line 137 of file insn.h.

Here is the call graph for this function:

◆ insn_last_prefix_id()

static int insn_last_prefix_id ( struct insn insn)
inlinestatic

Definition at line 170 of file insn.h.

Here is the call graph for this function:

◆ insn_masking_exception()

static int insn_masking_exception ( struct insn insn)
inlinestatic

Definition at line 222 of file insn.h.

◆ insn_offset_displacement()

static int insn_offset_displacement ( struct insn insn)
inlinestatic

Definition at line 202 of file insn.h.

Here is the call graph for this function:

◆ insn_offset_immediate()

static int insn_offset_immediate ( struct insn insn)
inlinestatic

Definition at line 206 of file insn.h.

Here is the call graph for this function:

◆ insn_offset_modrm()

static int insn_offset_modrm ( struct insn insn)
inlinestatic

Definition at line 194 of file insn.h.

Here is the call graph for this function:

◆ insn_offset_opcode()

static int insn_offset_opcode ( struct insn insn)
inlinestatic

Definition at line 190 of file insn.h.

Here is the call graph for this function:

◆ insn_offset_rex_prefix()

static int insn_offset_rex_prefix ( struct insn insn)
inlinestatic

Definition at line 182 of file insn.h.

◆ insn_offset_sib()

static int insn_offset_sib ( struct insn insn)
inlinestatic

Definition at line 198 of file insn.h.

Here is the call graph for this function:

◆ insn_offset_vex_prefix()

static int insn_offset_vex_prefix ( struct insn insn)
inlinestatic

Definition at line 186 of file insn.h.

Here is the call graph for this function:

◆ insn_rip_relative()

int insn_rip_relative ( struct insn insn)

insn_rip_relative() - Does instruction use RIP-relative addressing mode? : &struct insn containing instruction

If necessary, first collects the instruction up to and including the ModRM byte. No effect if ->x86_64 is 0.

Definition at line 304 of file insn.c.

Here is the call graph for this function:

◆ insn_vex_m_bits()

static insn_byte_t insn_vex_m_bits ( struct insn insn)
inlinestatic

Definition at line 151 of file insn.h.

◆ insn_vex_p_bits()

static insn_byte_t insn_vex_p_bits ( struct insn insn)
inlinestatic

Definition at line 161 of file insn.h.

◆ kernel_insn_init()

static void kernel_insn_init ( struct insn insn,
const void *  kaddr,
int  buf_len 
)
inlinestatic

Definition at line 120 of file insn.h.

Here is the call graph for this function: