xref: /openbmc/linux/tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.h (revision 052072f69f28864cebaeb6ca9dc2c9825b72c834)
12025cf9eSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
2237fae79SAdrian Hunter /*
3237fae79SAdrian Hunter  * intel_pt_insn_decoder.h: Intel Processor Trace support
4237fae79SAdrian Hunter  * Copyright (c) 2013-2014, Intel Corporation.
5237fae79SAdrian Hunter  */
6237fae79SAdrian Hunter 
7237fae79SAdrian Hunter #ifndef INCLUDE__INTEL_PT_INSN_DECODER_H__
8237fae79SAdrian Hunter #define INCLUDE__INTEL_PT_INSN_DECODER_H__
9237fae79SAdrian Hunter 
10237fae79SAdrian Hunter #include <stddef.h>
11237fae79SAdrian Hunter #include <stdint.h>
12237fae79SAdrian Hunter 
13237fae79SAdrian Hunter #define INTEL_PT_INSN_DESC_MAX		32
1432f98aabSAdrian Hunter #define INTEL_PT_INSN_BUF_SZ		16
15237fae79SAdrian Hunter 
16237fae79SAdrian Hunter enum intel_pt_insn_op {
17237fae79SAdrian Hunter 	INTEL_PT_OP_OTHER,
18237fae79SAdrian Hunter 	INTEL_PT_OP_CALL,
19237fae79SAdrian Hunter 	INTEL_PT_OP_RET,
20237fae79SAdrian Hunter 	INTEL_PT_OP_JCC,
21237fae79SAdrian Hunter 	INTEL_PT_OP_JMP,
22237fae79SAdrian Hunter 	INTEL_PT_OP_LOOP,
23237fae79SAdrian Hunter 	INTEL_PT_OP_IRET,
24237fae79SAdrian Hunter 	INTEL_PT_OP_INT,
25237fae79SAdrian Hunter 	INTEL_PT_OP_SYSCALL,
26237fae79SAdrian Hunter 	INTEL_PT_OP_SYSRET,
27b7ecc2d7SAdrian Hunter 	INTEL_PT_OP_VMENTRY,
28*052072f6SAdrian Hunter 	INTEL_PT_OP_ERETS,
29*052072f6SAdrian Hunter 	INTEL_PT_OP_ERETU,
30237fae79SAdrian Hunter };
31237fae79SAdrian Hunter 
32237fae79SAdrian Hunter enum intel_pt_insn_branch {
33237fae79SAdrian Hunter 	INTEL_PT_BR_NO_BRANCH,
34237fae79SAdrian Hunter 	INTEL_PT_BR_INDIRECT,
35237fae79SAdrian Hunter 	INTEL_PT_BR_CONDITIONAL,
36237fae79SAdrian Hunter 	INTEL_PT_BR_UNCONDITIONAL,
37237fae79SAdrian Hunter };
38237fae79SAdrian Hunter 
39237fae79SAdrian Hunter struct intel_pt_insn {
40237fae79SAdrian Hunter 	enum intel_pt_insn_op		op;
41237fae79SAdrian Hunter 	enum intel_pt_insn_branch	branch;
42d7015e50SAdrian Hunter 	bool				emulated_ptwrite;
43237fae79SAdrian Hunter 	int				length;
44237fae79SAdrian Hunter 	int32_t				rel;
4532f98aabSAdrian Hunter 	unsigned char			buf[INTEL_PT_INSN_BUF_SZ];
46237fae79SAdrian Hunter };
47237fae79SAdrian Hunter 
48237fae79SAdrian Hunter int intel_pt_get_insn(const unsigned char *buf, size_t len, int x86_64,
49237fae79SAdrian Hunter 		      struct intel_pt_insn *intel_pt_insn);
50237fae79SAdrian Hunter 
51237fae79SAdrian Hunter const char *intel_pt_insn_name(enum intel_pt_insn_op op);
52237fae79SAdrian Hunter 
53237fae79SAdrian Hunter int intel_pt_insn_desc(const struct intel_pt_insn *intel_pt_insn, char *buf,
54237fae79SAdrian Hunter 		       size_t buf_len);
55237fae79SAdrian Hunter 
56237fae79SAdrian Hunter int intel_pt_insn_type(enum intel_pt_insn_op op);
57237fae79SAdrian Hunter 
58237fae79SAdrian Hunter #endif
59