blob: 7005d1109ec94c8c2839bbff6984395e20e8a873 [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),\
Cornelia Huckdcce0482012-06-11 18:39:50 +020016 ERSN(NMI), ERSN(INTERNAL_ERROR), ERSN(OSI), ERSN(PAPR_HCALL), \
Cornelia Huckf79ed822013-01-08 13:00:01 +010017 ERSN(S390_UCONTROL), ERSN(WATCHDOG), ERSN(S390_TSCH)
Gleb Natapov64be5002010-10-24 16:49:08 +020018
19TRACE_EVENT(kvm_userspace_exit,
20 TP_PROTO(__u32 reason, int errno),
21 TP_ARGS(reason, errno),
22
23 TP_STRUCT__entry(
24 __field( __u32, reason )
25 __field( int, errno )
26 ),
27
28 TP_fast_assign(
29 __entry->reason = reason;
30 __entry->errno = errno;
31 ),
32
33 TP_printk("reason %s (%d)",
34 __entry->errno < 0 ?
35 (__entry->errno == -EINTR ? "restart" : "error") :
36 __print_symbolic(__entry->reason, kvm_trace_exit_reason),
37 __entry->errno < 0 ? -__entry->errno : __entry->reason)
38);
39
Alexander Graf1c9f8522013-04-15 23:04:10 +020040#if defined(CONFIG_HAVE_KVM_IRQCHIP)
Marcelo Tosatti229456f2009-06-17 09:22:14 -030041TRACE_EVENT(kvm_set_irq,
Avi Kivityae8c1c42009-07-01 12:09:41 +030042 TP_PROTO(unsigned int gsi, int level, int irq_source_id),
43 TP_ARGS(gsi, level, irq_source_id),
Marcelo Tosatti229456f2009-06-17 09:22:14 -030044
45 TP_STRUCT__entry(
46 __field( unsigned int, gsi )
Avi Kivityae8c1c42009-07-01 12:09:41 +030047 __field( int, level )
48 __field( int, irq_source_id )
Marcelo Tosatti229456f2009-06-17 09:22:14 -030049 ),
50
51 TP_fast_assign(
52 __entry->gsi = gsi;
Avi Kivityae8c1c42009-07-01 12:09:41 +030053 __entry->level = level;
54 __entry->irq_source_id = irq_source_id;
Marcelo Tosatti229456f2009-06-17 09:22:14 -030055 ),
56
Avi Kivityae8c1c42009-07-01 12:09:41 +030057 TP_printk("gsi %u level %d source %d",
58 __entry->gsi, __entry->level, __entry->irq_source_id)
Marcelo Tosatti229456f2009-06-17 09:22:14 -030059);
Christoffer Dalla1e4ccb2012-06-15 15:07:13 -040060#endif
Marcelo Tosatti229456f2009-06-17 09:22:14 -030061
Christoffer Dalla1e4ccb2012-06-15 15:07:13 -040062#if defined(__KVM_HAVE_IOAPIC)
Gleb Natapov1000ff82009-07-07 16:00:57 +030063#define kvm_deliver_mode \
64 {0x0, "Fixed"}, \
65 {0x1, "LowPrio"}, \
66 {0x2, "SMI"}, \
67 {0x3, "Res3"}, \
68 {0x4, "NMI"}, \
69 {0x5, "INIT"}, \
70 {0x6, "SIPI"}, \
71 {0x7, "ExtINT"}
72
73TRACE_EVENT(kvm_ioapic_set_irq,
74 TP_PROTO(__u64 e, int pin, bool coalesced),
75 TP_ARGS(e, pin, coalesced),
76
77 TP_STRUCT__entry(
78 __field( __u64, e )
79 __field( int, pin )
80 __field( bool, coalesced )
81 ),
82
83 TP_fast_assign(
84 __entry->e = e;
85 __entry->pin = pin;
86 __entry->coalesced = coalesced;
87 ),
88
89 TP_printk("pin %u dst %x vec=%u (%s|%s|%s%s)%s",
90 __entry->pin, (u8)(__entry->e >> 56), (u8)__entry->e,
91 __print_symbolic((__entry->e >> 8 & 0x7), kvm_deliver_mode),
92 (__entry->e & (1<<11)) ? "logical" : "physical",
93 (__entry->e & (1<<15)) ? "level" : "edge",
94 (__entry->e & (1<<16)) ? "|masked" : "",
95 __entry->coalesced ? " (coalesced)" : "")
96);
97
98TRACE_EVENT(kvm_msi_set_irq,
99 TP_PROTO(__u64 address, __u64 data),
100 TP_ARGS(address, data),
101
102 TP_STRUCT__entry(
103 __field( __u64, address )
104 __field( __u64, data )
105 ),
106
107 TP_fast_assign(
108 __entry->address = address;
109 __entry->data = data;
110 ),
111
112 TP_printk("dst %u vec %x (%s|%s|%s%s)",
113 (u8)(__entry->address >> 12), (u8)__entry->data,
114 __print_symbolic((__entry->data >> 8 & 0x7), kvm_deliver_mode),
115 (__entry->address & (1<<2)) ? "logical" : "physical",
116 (__entry->data & (1<<15)) ? "level" : "edge",
117 (__entry->address & (1<<3)) ? "|rh" : "")
118);
Marcelo Tosatti229456f2009-06-17 09:22:14 -0300119
120#define kvm_irqchips \
121 {KVM_IRQCHIP_PIC_MASTER, "PIC master"}, \
122 {KVM_IRQCHIP_PIC_SLAVE, "PIC slave"}, \
123 {KVM_IRQCHIP_IOAPIC, "IOAPIC"}
124
Alexander Graf1c9f8522013-04-15 23:04:10 +0200125#endif /* defined(__KVM_HAVE_IOAPIC) */
126
127#if defined(CONFIG_HAVE_KVM_IRQCHIP)
128
Marcelo Tosatti229456f2009-06-17 09:22:14 -0300129TRACE_EVENT(kvm_ack_irq,
130 TP_PROTO(unsigned int irqchip, unsigned int pin),
131 TP_ARGS(irqchip, pin),
132
133 TP_STRUCT__entry(
134 __field( unsigned int, irqchip )
135 __field( unsigned int, pin )
136 ),
137
138 TP_fast_assign(
139 __entry->irqchip = irqchip;
140 __entry->pin = pin;
141 ),
142
Alexander Graf1c9f8522013-04-15 23:04:10 +0200143#ifdef kvm_irqchips
Marcelo Tosatti229456f2009-06-17 09:22:14 -0300144 TP_printk("irqchip %s pin %u",
145 __print_symbolic(__entry->irqchip, kvm_irqchips),
146 __entry->pin)
Alexander Graf1c9f8522013-04-15 23:04:10 +0200147#else
148 TP_printk("irqchip %d pin %u", __entry->irqchip, __entry->pin)
149#endif
Marcelo Tosatti229456f2009-06-17 09:22:14 -0300150);
151
Alexander Graf1c9f8522013-04-15 23:04:10 +0200152#endif /* defined(CONFIG_HAVE_KVM_IRQCHIP) */
Marcelo Tosatti229456f2009-06-17 09:22:14 -0300153
154
Avi Kivityaec51dc2009-07-01 16:01:02 +0300155
156#define KVM_TRACE_MMIO_READ_UNSATISFIED 0
157#define KVM_TRACE_MMIO_READ 1
158#define KVM_TRACE_MMIO_WRITE 2
159
160#define kvm_trace_symbol_mmio \
161 { KVM_TRACE_MMIO_READ_UNSATISFIED, "unsatisfied-read" }, \
162 { KVM_TRACE_MMIO_READ, "read" }, \
163 { KVM_TRACE_MMIO_WRITE, "write" }
164
165TRACE_EVENT(kvm_mmio,
166 TP_PROTO(int type, int len, u64 gpa, u64 val),
167 TP_ARGS(type, len, gpa, val),
168
169 TP_STRUCT__entry(
170 __field( u32, type )
171 __field( u32, len )
172 __field( u64, gpa )
173 __field( u64, val )
174 ),
175
176 TP_fast_assign(
177 __entry->type = type;
178 __entry->len = len;
179 __entry->gpa = gpa;
180 __entry->val = val;
181 ),
182
183 TP_printk("mmio %s len %u gpa 0x%llx val 0x%llx",
184 __print_symbolic(__entry->type, kvm_trace_symbol_mmio),
185 __entry->len, __entry->gpa, __entry->val)
186);
187
Avi Kivity0c048512010-01-21 15:31:52 +0200188#define kvm_fpu_load_symbol \
189 {0, "unload"}, \
190 {1, "load"}
191
192TRACE_EVENT(kvm_fpu,
193 TP_PROTO(int load),
194 TP_ARGS(load),
195
196 TP_STRUCT__entry(
197 __field( u32, load )
198 ),
199
200 TP_fast_assign(
201 __entry->load = load;
202 ),
203
204 TP_printk("%s", __print_symbolic(__entry->load, kvm_fpu_load_symbol))
205);
206
Avi Kivity90bb6fc2009-12-31 12:10:16 +0200207TRACE_EVENT(kvm_age_page,
208 TP_PROTO(ulong hva, struct kvm_memory_slot *slot, int ref),
209 TP_ARGS(hva, slot, ref),
210
211 TP_STRUCT__entry(
212 __field( u64, hva )
213 __field( u64, gfn )
214 __field( u8, referenced )
215 ),
216
217 TP_fast_assign(
218 __entry->hva = hva;
219 __entry->gfn =
220 slot->base_gfn + ((hva - slot->userspace_addr) >> PAGE_SHIFT);
221 __entry->referenced = ref;
222 ),
223
224 TP_printk("hva %llx gfn %llx %s",
225 __entry->hva, __entry->gfn,
226 __entry->referenced ? "YOUNG" : "OLD")
227);
228
Gleb Natapovaf585b92010-10-14 11:22:46 +0200229#ifdef CONFIG_KVM_ASYNC_PF
Xiao Guangrong07303882010-11-01 16:59:39 +0800230DECLARE_EVENT_CLASS(kvm_async_get_page_class,
231
Xiao Guangrongc9b263d2010-11-01 16:58:43 +0800232 TP_PROTO(u64 gva, u64 gfn),
Xiao Guangrong07303882010-11-01 16:59:39 +0800233
Xiao Guangrongc9b263d2010-11-01 16:58:43 +0800234 TP_ARGS(gva, gfn),
Gleb Natapovaf585b92010-10-14 11:22:46 +0200235
236 TP_STRUCT__entry(
Xiao Guangrong07303882010-11-01 16:59:39 +0800237 __field(__u64, gva)
Xiao Guangrongc9b263d2010-11-01 16:58:43 +0800238 __field(u64, gfn)
Xiao Guangrong07303882010-11-01 16:59:39 +0800239 ),
Gleb Natapovaf585b92010-10-14 11:22:46 +0200240
241 TP_fast_assign(
Xiao Guangrongc9b263d2010-11-01 16:58:43 +0800242 __entry->gva = gva;
243 __entry->gfn = gfn;
Xiao Guangrong07303882010-11-01 16:59:39 +0800244 ),
Gleb Natapovaf585b92010-10-14 11:22:46 +0200245
Xiao Guangrongc9b263d2010-11-01 16:58:43 +0800246 TP_printk("gva = %#llx, gfn = %#llx", __entry->gva, __entry->gfn)
Gleb Natapovaf585b92010-10-14 11:22:46 +0200247);
248
Xiao Guangrong07303882010-11-01 16:59:39 +0800249DEFINE_EVENT(kvm_async_get_page_class, kvm_try_async_get_page,
Gleb Natapovaf585b92010-10-14 11:22:46 +0200250
Xiao Guangrong07303882010-11-01 16:59:39 +0800251 TP_PROTO(u64 gva, u64 gfn),
Gleb Natapovaf585b92010-10-14 11:22:46 +0200252
Xiao Guangrong07303882010-11-01 16:59:39 +0800253 TP_ARGS(gva, gfn)
Gleb Natapovaf585b92010-10-14 11:22:46 +0200254);
255
Xiao Guangrong07303882010-11-01 16:59:39 +0800256DEFINE_EVENT(kvm_async_get_page_class, kvm_async_pf_doublefault,
257
258 TP_PROTO(u64 gva, u64 gfn),
259
260 TP_ARGS(gva, gfn)
261);
262
263DECLARE_EVENT_CLASS(kvm_async_pf_nopresent_ready,
264
Gleb Natapov7c907052010-10-14 11:22:53 +0200265 TP_PROTO(u64 token, u64 gva),
Xiao Guangrong07303882010-11-01 16:59:39 +0800266
Gleb Natapov7c907052010-10-14 11:22:53 +0200267 TP_ARGS(token, gva),
Gleb Natapovaf585b92010-10-14 11:22:46 +0200268
269 TP_STRUCT__entry(
Gleb Natapov7c907052010-10-14 11:22:53 +0200270 __field(__u64, token)
Gleb Natapovaf585b92010-10-14 11:22:46 +0200271 __field(__u64, gva)
Xiao Guangrong07303882010-11-01 16:59:39 +0800272 ),
Gleb Natapovaf585b92010-10-14 11:22:46 +0200273
274 TP_fast_assign(
Gleb Natapov7c907052010-10-14 11:22:53 +0200275 __entry->token = token;
Gleb Natapovaf585b92010-10-14 11:22:46 +0200276 __entry->gva = gva;
Xiao Guangrong07303882010-11-01 16:59:39 +0800277 ),
Gleb Natapovaf585b92010-10-14 11:22:46 +0200278
Xiao Guangrong07303882010-11-01 16:59:39 +0800279 TP_printk("token %#llx gva %#llx", __entry->token, __entry->gva)
280
281);
282
283DEFINE_EVENT(kvm_async_pf_nopresent_ready, kvm_async_pf_not_present,
284
285 TP_PROTO(u64 token, u64 gva),
286
287 TP_ARGS(token, gva)
288);
289
290DEFINE_EVENT(kvm_async_pf_nopresent_ready, kvm_async_pf_ready,
291
292 TP_PROTO(u64 token, u64 gva),
293
294 TP_ARGS(token, gva)
Gleb Natapovaf585b92010-10-14 11:22:46 +0200295);
296
297TRACE_EVENT(
298 kvm_async_pf_completed,
299 TP_PROTO(unsigned long address, struct page *page, u64 gva),
300 TP_ARGS(address, page, gva),
301
302 TP_STRUCT__entry(
303 __field(unsigned long, address)
304 __field(pfn_t, pfn)
305 __field(u64, gva)
306 ),
307
308 TP_fast_assign(
309 __entry->address = address;
310 __entry->pfn = page ? page_to_pfn(page) : 0;
311 __entry->gva = gva;
312 ),
313
314 TP_printk("gva %#llx address %#lx pfn %#llx", __entry->gva,
315 __entry->address, __entry->pfn)
316);
317
Gleb Natapovaf585b92010-10-14 11:22:46 +0200318#endif
319
Marcelo Tosatti229456f2009-06-17 09:22:14 -0300320#endif /* _TRACE_KVM_MAIN_H */
321
322/* This part must be outside protection */
323#include <trace/define_trace.h>