blob: c86f4e8e0bc940f3d4c09ed757b61de799cdc211 [file] [log] [blame]
Marcelo Tosatti229456f2009-06-17 09:22:14 -03001#if !defined(_TRACE_KVM_MAIN_H) || defined(TRACE_HEADER_MULTI_READ)
2#define _TRACE_KVM_MAIN_H
3
4#include <linux/tracepoint.h>
5
6#undef TRACE_SYSTEM
7#define TRACE_SYSTEM kvm
Marcelo Tosatti229456f2009-06-17 09:22:14 -03008
Gleb Natapov64be5002010-10-24 16:49:08 +02009#define ERSN(x) { KVM_EXIT_##x, "KVM_EXIT_" #x }
10
11#define kvm_trace_exit_reason \
12 ERSN(UNKNOWN), ERSN(EXCEPTION), ERSN(IO), ERSN(HYPERCALL), \
13 ERSN(DEBUG), ERSN(HLT), ERSN(MMIO), ERSN(IRQ_WINDOW_OPEN), \
14 ERSN(SHUTDOWN), ERSN(FAIL_ENTRY), ERSN(INTR), ERSN(SET_TPR), \
15 ERSN(TPR_ACCESS), ERSN(S390_SIEIC), ERSN(S390_RESET), ERSN(DCR),\
16 ERSN(NMI), ERSN(INTERNAL_ERROR), ERSN(OSI)
17
18TRACE_EVENT(kvm_userspace_exit,
19 TP_PROTO(__u32 reason, int errno),
20 TP_ARGS(reason, errno),
21
22 TP_STRUCT__entry(
23 __field( __u32, reason )
24 __field( int, errno )
25 ),
26
27 TP_fast_assign(
28 __entry->reason = reason;
29 __entry->errno = errno;
30 ),
31
32 TP_printk("reason %s (%d)",
33 __entry->errno < 0 ?
34 (__entry->errno == -EINTR ? "restart" : "error") :
35 __print_symbolic(__entry->reason, kvm_trace_exit_reason),
36 __entry->errno < 0 ? -__entry->errno : __entry->reason)
37);
38
Marcelo Tosatti229456f2009-06-17 09:22:14 -030039#if defined(__KVM_HAVE_IOAPIC)
40TRACE_EVENT(kvm_set_irq,
Avi Kivityae8c1c42009-07-01 12:09:41 +030041 TP_PROTO(unsigned int gsi, int level, int irq_source_id),
42 TP_ARGS(gsi, level, irq_source_id),
Marcelo Tosatti229456f2009-06-17 09:22:14 -030043
44 TP_STRUCT__entry(
45 __field( unsigned int, gsi )
Avi Kivityae8c1c42009-07-01 12:09:41 +030046 __field( int, level )
47 __field( int, irq_source_id )
Marcelo Tosatti229456f2009-06-17 09:22:14 -030048 ),
49
50 TP_fast_assign(
51 __entry->gsi = gsi;
Avi Kivityae8c1c42009-07-01 12:09:41 +030052 __entry->level = level;
53 __entry->irq_source_id = irq_source_id;
Marcelo Tosatti229456f2009-06-17 09:22:14 -030054 ),
55
Avi Kivityae8c1c42009-07-01 12:09:41 +030056 TP_printk("gsi %u level %d source %d",
57 __entry->gsi, __entry->level, __entry->irq_source_id)
Marcelo Tosatti229456f2009-06-17 09:22:14 -030058);
59
Gleb Natapov1000ff82009-07-07 16:00:57 +030060#define kvm_deliver_mode \
61 {0x0, "Fixed"}, \
62 {0x1, "LowPrio"}, \
63 {0x2, "SMI"}, \
64 {0x3, "Res3"}, \
65 {0x4, "NMI"}, \
66 {0x5, "INIT"}, \
67 {0x6, "SIPI"}, \
68 {0x7, "ExtINT"}
69
70TRACE_EVENT(kvm_ioapic_set_irq,
71 TP_PROTO(__u64 e, int pin, bool coalesced),
72 TP_ARGS(e, pin, coalesced),
73
74 TP_STRUCT__entry(
75 __field( __u64, e )
76 __field( int, pin )
77 __field( bool, coalesced )
78 ),
79
80 TP_fast_assign(
81 __entry->e = e;
82 __entry->pin = pin;
83 __entry->coalesced = coalesced;
84 ),
85
86 TP_printk("pin %u dst %x vec=%u (%s|%s|%s%s)%s",
87 __entry->pin, (u8)(__entry->e >> 56), (u8)__entry->e,
88 __print_symbolic((__entry->e >> 8 & 0x7), kvm_deliver_mode),
89 (__entry->e & (1<<11)) ? "logical" : "physical",
90 (__entry->e & (1<<15)) ? "level" : "edge",
91 (__entry->e & (1<<16)) ? "|masked" : "",
92 __entry->coalesced ? " (coalesced)" : "")
93);
94
95TRACE_EVENT(kvm_msi_set_irq,
96 TP_PROTO(__u64 address, __u64 data),
97 TP_ARGS(address, data),
98
99 TP_STRUCT__entry(
100 __field( __u64, address )
101 __field( __u64, data )
102 ),
103
104 TP_fast_assign(
105 __entry->address = address;
106 __entry->data = data;
107 ),
108
109 TP_printk("dst %u vec %x (%s|%s|%s%s)",
110 (u8)(__entry->address >> 12), (u8)__entry->data,
111 __print_symbolic((__entry->data >> 8 & 0x7), kvm_deliver_mode),
112 (__entry->address & (1<<2)) ? "logical" : "physical",
113 (__entry->data & (1<<15)) ? "level" : "edge",
114 (__entry->address & (1<<3)) ? "|rh" : "")
115);
Marcelo Tosatti229456f2009-06-17 09:22:14 -0300116
117#define kvm_irqchips \
118 {KVM_IRQCHIP_PIC_MASTER, "PIC master"}, \
119 {KVM_IRQCHIP_PIC_SLAVE, "PIC slave"}, \
120 {KVM_IRQCHIP_IOAPIC, "IOAPIC"}
121
122TRACE_EVENT(kvm_ack_irq,
123 TP_PROTO(unsigned int irqchip, unsigned int pin),
124 TP_ARGS(irqchip, pin),
125
126 TP_STRUCT__entry(
127 __field( unsigned int, irqchip )
128 __field( unsigned int, pin )
129 ),
130
131 TP_fast_assign(
132 __entry->irqchip = irqchip;
133 __entry->pin = pin;
134 ),
135
136 TP_printk("irqchip %s pin %u",
137 __print_symbolic(__entry->irqchip, kvm_irqchips),
138 __entry->pin)
139);
140
141
142
143#endif /* defined(__KVM_HAVE_IOAPIC) */
Avi Kivityaec51dc2009-07-01 16:01:02 +0300144
145#define KVM_TRACE_MMIO_READ_UNSATISFIED 0
146#define KVM_TRACE_MMIO_READ 1
147#define KVM_TRACE_MMIO_WRITE 2
148
149#define kvm_trace_symbol_mmio \
150 { KVM_TRACE_MMIO_READ_UNSATISFIED, "unsatisfied-read" }, \
151 { KVM_TRACE_MMIO_READ, "read" }, \
152 { KVM_TRACE_MMIO_WRITE, "write" }
153
154TRACE_EVENT(kvm_mmio,
155 TP_PROTO(int type, int len, u64 gpa, u64 val),
156 TP_ARGS(type, len, gpa, val),
157
158 TP_STRUCT__entry(
159 __field( u32, type )
160 __field( u32, len )
161 __field( u64, gpa )
162 __field( u64, val )
163 ),
164
165 TP_fast_assign(
166 __entry->type = type;
167 __entry->len = len;
168 __entry->gpa = gpa;
169 __entry->val = val;
170 ),
171
172 TP_printk("mmio %s len %u gpa 0x%llx val 0x%llx",
173 __print_symbolic(__entry->type, kvm_trace_symbol_mmio),
174 __entry->len, __entry->gpa, __entry->val)
175);
176
Avi Kivity0c048512010-01-21 15:31:52 +0200177#define kvm_fpu_load_symbol \
178 {0, "unload"}, \
179 {1, "load"}
180
181TRACE_EVENT(kvm_fpu,
182 TP_PROTO(int load),
183 TP_ARGS(load),
184
185 TP_STRUCT__entry(
186 __field( u32, load )
187 ),
188
189 TP_fast_assign(
190 __entry->load = load;
191 ),
192
193 TP_printk("%s", __print_symbolic(__entry->load, kvm_fpu_load_symbol))
194);
195
Avi Kivity90bb6fc2009-12-31 12:10:16 +0200196TRACE_EVENT(kvm_age_page,
197 TP_PROTO(ulong hva, struct kvm_memory_slot *slot, int ref),
198 TP_ARGS(hva, slot, ref),
199
200 TP_STRUCT__entry(
201 __field( u64, hva )
202 __field( u64, gfn )
203 __field( u8, referenced )
204 ),
205
206 TP_fast_assign(
207 __entry->hva = hva;
208 __entry->gfn =
209 slot->base_gfn + ((hva - slot->userspace_addr) >> PAGE_SHIFT);
210 __entry->referenced = ref;
211 ),
212
213 TP_printk("hva %llx gfn %llx %s",
214 __entry->hva, __entry->gfn,
215 __entry->referenced ? "YOUNG" : "OLD")
216);
217
Gleb Natapovaf585b92010-10-14 11:22:46 +0200218#ifdef CONFIG_KVM_ASYNC_PF
219TRACE_EVENT(
220 kvm_try_async_get_page,
221 TP_PROTO(bool async, u64 pfn),
222 TP_ARGS(async, pfn),
223
224 TP_STRUCT__entry(
225 __field(__u64, pfn)
226 ),
227
228 TP_fast_assign(
229 __entry->pfn = (!async) ? pfn : (u64)-1;
230 ),
231
232 TP_printk("pfn %#llx", __entry->pfn)
233);
234
235TRACE_EVENT(
236 kvm_async_pf_not_present,
Gleb Natapov7c907052010-10-14 11:22:53 +0200237 TP_PROTO(u64 token, u64 gva),
238 TP_ARGS(token, gva),
Gleb Natapovaf585b92010-10-14 11:22:46 +0200239
240 TP_STRUCT__entry(
Gleb Natapov7c907052010-10-14 11:22:53 +0200241 __field(__u64, token)
Gleb Natapovaf585b92010-10-14 11:22:46 +0200242 __field(__u64, gva)
243 ),
244
245 TP_fast_assign(
Gleb Natapov7c907052010-10-14 11:22:53 +0200246 __entry->token = token;
Gleb Natapovaf585b92010-10-14 11:22:46 +0200247 __entry->gva = gva;
248 ),
249
Gleb Natapov7c907052010-10-14 11:22:53 +0200250 TP_printk("token %#llx gva %#llx not present", __entry->token,
251 __entry->gva)
Gleb Natapovaf585b92010-10-14 11:22:46 +0200252);
253
254TRACE_EVENT(
255 kvm_async_pf_ready,
Gleb Natapov7c907052010-10-14 11:22:53 +0200256 TP_PROTO(u64 token, u64 gva),
257 TP_ARGS(token, gva),
Gleb Natapovaf585b92010-10-14 11:22:46 +0200258
259 TP_STRUCT__entry(
Gleb Natapov7c907052010-10-14 11:22:53 +0200260 __field(__u64, token)
Gleb Natapovaf585b92010-10-14 11:22:46 +0200261 __field(__u64, gva)
262 ),
263
264 TP_fast_assign(
Gleb Natapov7c907052010-10-14 11:22:53 +0200265 __entry->token = token;
Gleb Natapovaf585b92010-10-14 11:22:46 +0200266 __entry->gva = gva;
267 ),
268
Gleb Natapov7c907052010-10-14 11:22:53 +0200269 TP_printk("token %#llx gva %#llx ready", __entry->token, __entry->gva)
Gleb Natapovaf585b92010-10-14 11:22:46 +0200270);
271
272TRACE_EVENT(
273 kvm_async_pf_completed,
274 TP_PROTO(unsigned long address, struct page *page, u64 gva),
275 TP_ARGS(address, page, gva),
276
277 TP_STRUCT__entry(
278 __field(unsigned long, address)
279 __field(pfn_t, pfn)
280 __field(u64, gva)
281 ),
282
283 TP_fast_assign(
284 __entry->address = address;
285 __entry->pfn = page ? page_to_pfn(page) : 0;
286 __entry->gva = gva;
287 ),
288
289 TP_printk("gva %#llx address %#lx pfn %#llx", __entry->gva,
290 __entry->address, __entry->pfn)
291);
292
293TRACE_EVENT(
294 kvm_async_pf_doublefault,
295 TP_PROTO(u64 gva, u64 gfn),
296 TP_ARGS(gva, gfn),
297
298 TP_STRUCT__entry(
299 __field(u64, gva)
300 __field(u64, gfn)
301 ),
302
303 TP_fast_assign(
304 __entry->gva = gva;
305 __entry->gfn = gfn;
306 ),
307
308 TP_printk("gva = %#llx, gfn = %#llx", __entry->gva, __entry->gfn)
309);
310
311#endif
312
Marcelo Tosatti229456f2009-06-17 09:22:14 -0300313#endif /* _TRACE_KVM_MAIN_H */
314
315/* This part must be outside protection */
316#include <trace/define_trace.h>