blob: aec1c43f2b442300676d9a6df756d04038e5e421 [file] [log] [blame]
Sanjay Lal669e8462012-11-21 18:34:02 -08001/*
Deng-Cheng Zhud116e812014-06-26 12:11:34 -07002 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.
7 * Authors: Sanjay Lal <sanjayl@kymasys.com>
8 */
Sanjay Lal669e8462012-11-21 18:34:02 -08009
10#if !defined(_TRACE_KVM_H) || defined(TRACE_HEADER_MULTI_READ)
11#define _TRACE_KVM_H
12
13#include <linux/tracepoint.h>
14
15#undef TRACE_SYSTEM
16#define TRACE_SYSTEM kvm
17#define TRACE_INCLUDE_PATH .
18#define TRACE_INCLUDE_FILE trace
19
James Hogan93258602016-06-14 09:40:14 +010020/*
21 * Tracepoints for VM enters
22 */
23TRACE_EVENT(kvm_enter,
24 TP_PROTO(struct kvm_vcpu *vcpu),
25 TP_ARGS(vcpu),
26 TP_STRUCT__entry(
27 __field(unsigned long, pc)
28 ),
29
30 TP_fast_assign(
31 __entry->pc = vcpu->arch.pc;
32 ),
33
34 TP_printk("PC: 0x%08lx",
35 __entry->pc)
36);
37
38TRACE_EVENT(kvm_reenter,
39 TP_PROTO(struct kvm_vcpu *vcpu),
40 TP_ARGS(vcpu),
41 TP_STRUCT__entry(
42 __field(unsigned long, pc)
43 ),
44
45 TP_fast_assign(
46 __entry->pc = vcpu->arch.pc;
47 ),
48
49 TP_printk("PC: 0x%08lx",
50 __entry->pc)
51);
52
53TRACE_EVENT(kvm_out,
54 TP_PROTO(struct kvm_vcpu *vcpu),
55 TP_ARGS(vcpu),
56 TP_STRUCT__entry(
57 __field(unsigned long, pc)
58 ),
59
60 TP_fast_assign(
61 __entry->pc = vcpu->arch.pc;
62 ),
63
64 TP_printk("PC: 0x%08lx",
65 __entry->pc)
66);
67
James Hogan1e09e862016-06-14 09:40:12 +010068/* The first 32 exit reasons correspond to Cause.ExcCode */
69#define KVM_TRACE_EXIT_INT 0
70#define KVM_TRACE_EXIT_TLBMOD 1
71#define KVM_TRACE_EXIT_TLBMISS_LD 2
72#define KVM_TRACE_EXIT_TLBMISS_ST 3
73#define KVM_TRACE_EXIT_ADDRERR_LD 4
74#define KVM_TRACE_EXIT_ADDRERR_ST 5
75#define KVM_TRACE_EXIT_SYSCALL 8
76#define KVM_TRACE_EXIT_BREAK_INST 9
77#define KVM_TRACE_EXIT_RESVD_INST 10
78#define KVM_TRACE_EXIT_COP_UNUSABLE 11
79#define KVM_TRACE_EXIT_TRAP_INST 13
80#define KVM_TRACE_EXIT_MSA_FPE 14
81#define KVM_TRACE_EXIT_FPE 15
82#define KVM_TRACE_EXIT_MSA_DISABLED 21
83/* Further exit reasons */
84#define KVM_TRACE_EXIT_WAIT 32
85#define KVM_TRACE_EXIT_CACHE 33
86#define KVM_TRACE_EXIT_SIGNAL 34
87
88/* Tracepoints for VM exits */
89#define kvm_trace_symbol_exit_types \
90 { KVM_TRACE_EXIT_INT, "Interrupt" }, \
91 { KVM_TRACE_EXIT_TLBMOD, "TLB Mod" }, \
92 { KVM_TRACE_EXIT_TLBMISS_LD, "TLB Miss (LD)" }, \
93 { KVM_TRACE_EXIT_TLBMISS_ST, "TLB Miss (ST)" }, \
94 { KVM_TRACE_EXIT_ADDRERR_LD, "Address Error (LD)" }, \
95 { KVM_TRACE_EXIT_ADDRERR_ST, "Address Err (ST)" }, \
96 { KVM_TRACE_EXIT_SYSCALL, "System Call" }, \
97 { KVM_TRACE_EXIT_BREAK_INST, "Break Inst" }, \
98 { KVM_TRACE_EXIT_RESVD_INST, "Reserved Inst" }, \
99 { KVM_TRACE_EXIT_COP_UNUSABLE, "COP0/1 Unusable" }, \
100 { KVM_TRACE_EXIT_TRAP_INST, "Trap Inst" }, \
101 { KVM_TRACE_EXIT_MSA_FPE, "MSA FPE" }, \
102 { KVM_TRACE_EXIT_FPE, "FPE" }, \
103 { KVM_TRACE_EXIT_MSA_DISABLED, "MSA Disabled" }, \
104 { KVM_TRACE_EXIT_WAIT, "WAIT" }, \
105 { KVM_TRACE_EXIT_CACHE, "CACHE" }, \
106 { KVM_TRACE_EXIT_SIGNAL, "Signal" }
Sanjay Lal669e8462012-11-21 18:34:02 -0800107
108TRACE_EVENT(kvm_exit,
109 TP_PROTO(struct kvm_vcpu *vcpu, unsigned int reason),
110 TP_ARGS(vcpu, reason),
111 TP_STRUCT__entry(
James Hoganb3cffac2015-02-24 11:46:20 +0000112 __field(unsigned long, pc)
Sanjay Lal669e8462012-11-21 18:34:02 -0800113 __field(unsigned int, reason)
114 ),
115
116 TP_fast_assign(
James Hoganb3cffac2015-02-24 11:46:20 +0000117 __entry->pc = vcpu->arch.pc;
Sanjay Lal669e8462012-11-21 18:34:02 -0800118 __entry->reason = reason;
119 ),
120
121 TP_printk("[%s]PC: 0x%08lx",
James Hogan1e09e862016-06-14 09:40:12 +0100122 __print_symbolic(__entry->reason,
123 kvm_trace_symbol_exit_types),
James Hoganb3cffac2015-02-24 11:46:20 +0000124 __entry->pc)
Sanjay Lal669e8462012-11-21 18:34:02 -0800125);
126
James Hogan04ebebf2016-06-14 09:40:11 +0100127#define KVM_TRACE_AUX_RESTORE 0
128#define KVM_TRACE_AUX_SAVE 1
129#define KVM_TRACE_AUX_ENABLE 2
130#define KVM_TRACE_AUX_DISABLE 3
131#define KVM_TRACE_AUX_DISCARD 4
132
133#define KVM_TRACE_AUX_FPU 1
134#define KVM_TRACE_AUX_MSA 2
135#define KVM_TRACE_AUX_FPU_MSA 3
136
137#define kvm_trace_symbol_aux_op \
138 { KVM_TRACE_AUX_RESTORE, "restore" }, \
139 { KVM_TRACE_AUX_SAVE, "save" }, \
140 { KVM_TRACE_AUX_ENABLE, "enable" }, \
141 { KVM_TRACE_AUX_DISABLE, "disable" }, \
142 { KVM_TRACE_AUX_DISCARD, "discard" }
143
144#define kvm_trace_symbol_aux_state \
145 { KVM_TRACE_AUX_FPU, "FPU" }, \
146 { KVM_TRACE_AUX_MSA, "MSA" }, \
147 { KVM_TRACE_AUX_FPU_MSA, "FPU & MSA" }
148
149TRACE_EVENT(kvm_aux,
150 TP_PROTO(struct kvm_vcpu *vcpu, unsigned int op,
151 unsigned int state),
152 TP_ARGS(vcpu, op, state),
153 TP_STRUCT__entry(
154 __field(unsigned long, pc)
155 __field(u8, op)
156 __field(u8, state)
157 ),
158
159 TP_fast_assign(
160 __entry->pc = vcpu->arch.pc;
161 __entry->op = op;
162 __entry->state = state;
163 ),
164
165 TP_printk("%s %s PC: 0x%08lx",
166 __print_symbolic(__entry->op,
167 kvm_trace_symbol_aux_op),
168 __print_symbolic(__entry->state,
169 kvm_trace_symbol_aux_state),
170 __entry->pc)
171);
172
James Hogan9887d1c2016-06-14 09:40:13 +0100173TRACE_EVENT(kvm_asid_change,
174 TP_PROTO(struct kvm_vcpu *vcpu, unsigned int old_asid,
175 unsigned int new_asid),
176 TP_ARGS(vcpu, old_asid, new_asid),
177 TP_STRUCT__entry(
178 __field(unsigned long, pc)
179 __field(u8, old_asid)
180 __field(u8, new_asid)
181 ),
182
183 TP_fast_assign(
184 __entry->pc = vcpu->arch.pc;
185 __entry->old_asid = old_asid;
186 __entry->new_asid = new_asid;
187 ),
188
189 TP_printk("PC: 0x%08lx old: 0x%02x new: 0x%02x",
190 __entry->pc,
191 __entry->old_asid,
192 __entry->new_asid)
193);
194
Sanjay Lal669e8462012-11-21 18:34:02 -0800195#endif /* _TRACE_KVM_H */
196
197/* This part must be outside protection */
198#include <trace/define_trace.h>