Linux Audio

Check our new training course

Loading...
v3.1
  1#if !defined(_TRACE_KVM_H) || defined(TRACE_HEADER_MULTI_READ)
  2#define _TRACE_KVM_H
  3
  4#include <linux/tracepoint.h>
 
 
 
 
  5
  6#undef TRACE_SYSTEM
  7#define TRACE_SYSTEM kvm
  8
  9/*
 10 * Tracepoint for guest mode entry.
 11 */
 12TRACE_EVENT(kvm_entry,
 13	TP_PROTO(unsigned int vcpu_id),
 14	TP_ARGS(vcpu_id),
 15
 16	TP_STRUCT__entry(
 17		__field(	unsigned int,	vcpu_id		)
 18	),
 19
 20	TP_fast_assign(
 21		__entry->vcpu_id	= vcpu_id;
 22	),
 23
 24	TP_printk("vcpu %u", __entry->vcpu_id)
 25);
 26
 27/*
 28 * Tracepoint for hypercall.
 29 */
 30TRACE_EVENT(kvm_hypercall,
 31	TP_PROTO(unsigned long nr, unsigned long a0, unsigned long a1,
 32		 unsigned long a2, unsigned long a3),
 33	TP_ARGS(nr, a0, a1, a2, a3),
 34
 35	TP_STRUCT__entry(
 36		__field(	unsigned long, 	nr		)
 37		__field(	unsigned long,	a0		)
 38		__field(	unsigned long,	a1		)
 39		__field(	unsigned long,	a2		)
 40		__field(	unsigned long,	a3		)
 41	),
 42
 43	TP_fast_assign(
 44		__entry->nr		= nr;
 45		__entry->a0		= a0;
 46		__entry->a1		= a1;
 47		__entry->a2		= a2;
 48		__entry->a3		= a3;
 49	),
 50
 51	TP_printk("nr 0x%lx a0 0x%lx a1 0x%lx a2 0x%lx a3 0x%lx",
 52		 __entry->nr, __entry->a0, __entry->a1,  __entry->a2,
 53		 __entry->a3)
 54);
 55
 56/*
 57 * Tracepoint for hypercall.
 58 */
 59TRACE_EVENT(kvm_hv_hypercall,
 60	TP_PROTO(__u16 code, bool fast, __u16 rep_cnt, __u16 rep_idx,
 61		 __u64 ingpa, __u64 outgpa),
 62	TP_ARGS(code, fast, rep_cnt, rep_idx, ingpa, outgpa),
 63
 64	TP_STRUCT__entry(
 65		__field(	__u16,		rep_cnt		)
 66		__field(	__u16,		rep_idx		)
 67		__field(	__u64,		ingpa		)
 68		__field(	__u64,		outgpa		)
 69		__field(	__u16, 		code		)
 70		__field(	bool,		fast		)
 71	),
 72
 73	TP_fast_assign(
 74		__entry->rep_cnt	= rep_cnt;
 75		__entry->rep_idx	= rep_idx;
 76		__entry->ingpa		= ingpa;
 77		__entry->outgpa		= outgpa;
 78		__entry->code		= code;
 79		__entry->fast		= fast;
 80	),
 81
 82	TP_printk("code 0x%x %s cnt 0x%x idx 0x%x in 0x%llx out 0x%llx",
 83		  __entry->code, __entry->fast ? "fast" : "slow",
 84		  __entry->rep_cnt, __entry->rep_idx,  __entry->ingpa,
 85		  __entry->outgpa)
 86);
 87
 88/*
 89 * Tracepoint for PIO.
 90 */
 
 
 
 
 91TRACE_EVENT(kvm_pio,
 92	TP_PROTO(unsigned int rw, unsigned int port, unsigned int size,
 93		 unsigned int count),
 94	TP_ARGS(rw, port, size, count),
 95
 96	TP_STRUCT__entry(
 97		__field(	unsigned int, 	rw		)
 98		__field(	unsigned int, 	port		)
 99		__field(	unsigned int, 	size		)
100		__field(	unsigned int,	count		)
 
101	),
102
103	TP_fast_assign(
104		__entry->rw		= rw;
105		__entry->port		= port;
106		__entry->size		= size;
107		__entry->count		= count;
 
 
 
 
 
 
108	),
109
110	TP_printk("pio_%s at 0x%x size %d count %d",
111		  __entry->rw ? "write" : "read",
112		  __entry->port, __entry->size, __entry->count)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113);
114
115/*
116 * Tracepoint for cpuid.
117 */
118TRACE_EVENT(kvm_cpuid,
119	TP_PROTO(unsigned int function, unsigned long rax, unsigned long rbx,
120		 unsigned long rcx, unsigned long rdx),
121	TP_ARGS(function, rax, rbx, rcx, rdx),
122
123	TP_STRUCT__entry(
124		__field(	unsigned int,	function	)
125		__field(	unsigned long,	rax		)
126		__field(	unsigned long,	rbx		)
127		__field(	unsigned long,	rcx		)
128		__field(	unsigned long,	rdx		)
129	),
130
131	TP_fast_assign(
132		__entry->function	= function;
133		__entry->rax		= rax;
134		__entry->rbx		= rbx;
135		__entry->rcx		= rcx;
136		__entry->rdx		= rdx;
137	),
138
139	TP_printk("func %x rax %lx rbx %lx rcx %lx rdx %lx",
140		  __entry->function, __entry->rax,
141		  __entry->rbx, __entry->rcx, __entry->rdx)
142);
143
144#define AREG(x) { APIC_##x, "APIC_" #x }
145
146#define kvm_trace_symbol_apic						    \
147	AREG(ID), AREG(LVR), AREG(TASKPRI), AREG(ARBPRI), AREG(PROCPRI),    \
148	AREG(EOI), AREG(RRR), AREG(LDR), AREG(DFR), AREG(SPIV), AREG(ISR),  \
149	AREG(TMR), AREG(IRR), AREG(ESR), AREG(ICR), AREG(ICR2), AREG(LVTT), \
150	AREG(LVTTHMR), AREG(LVTPC), AREG(LVT0), AREG(LVT1), AREG(LVTERR),   \
151	AREG(TMICT), AREG(TMCCT), AREG(TDCR), AREG(SELF_IPI), AREG(EFEAT),  \
152	AREG(ECTRL)
153/*
154 * Tracepoint for apic access.
155 */
156TRACE_EVENT(kvm_apic,
157	TP_PROTO(unsigned int rw, unsigned int reg, unsigned int val),
158	TP_ARGS(rw, reg, val),
159
160	TP_STRUCT__entry(
161		__field(	unsigned int,	rw		)
162		__field(	unsigned int,	reg		)
163		__field(	unsigned int,	val		)
164	),
165
166	TP_fast_assign(
167		__entry->rw		= rw;
168		__entry->reg		= reg;
169		__entry->val		= val;
170	),
171
172	TP_printk("apic_%s %s = 0x%x",
173		  __entry->rw ? "write" : "read",
174		  __print_symbolic(__entry->reg, kvm_trace_symbol_apic),
175		  __entry->val)
176);
177
178#define trace_kvm_apic_read(reg, val)		trace_kvm_apic(0, reg, val)
179#define trace_kvm_apic_write(reg, val)		trace_kvm_apic(1, reg, val)
180
181#define KVM_ISA_VMX   1
182#define KVM_ISA_SVM   2
183
184/*
185 * Tracepoint for kvm guest exit:
186 */
187TRACE_EVENT(kvm_exit,
188	TP_PROTO(unsigned int exit_reason, struct kvm_vcpu *vcpu, u32 isa),
189	TP_ARGS(exit_reason, vcpu, isa),
190
191	TP_STRUCT__entry(
192		__field(	unsigned int,	exit_reason	)
193		__field(	unsigned long,	guest_rip	)
194		__field(	u32,	        isa             )
195		__field(	u64,	        info1           )
196		__field(	u64,	        info2           )
197	),
198
199	TP_fast_assign(
200		__entry->exit_reason	= exit_reason;
201		__entry->guest_rip	= kvm_rip_read(vcpu);
202		__entry->isa            = isa;
203		kvm_x86_ops->get_exit_info(vcpu, &__entry->info1,
204					   &__entry->info2);
205	),
206
207	TP_printk("reason %s rip 0x%lx info %llx %llx",
208		 ftrace_print_symbols_seq(p, __entry->exit_reason,
209					  kvm_x86_ops->exit_reasons_str),
 
210		 __entry->guest_rip, __entry->info1, __entry->info2)
211);
212
213/*
214 * Tracepoint for kvm interrupt injection:
215 */
216TRACE_EVENT(kvm_inj_virq,
217	TP_PROTO(unsigned int irq),
218	TP_ARGS(irq),
219
220	TP_STRUCT__entry(
221		__field(	unsigned int,	irq		)
222	),
223
224	TP_fast_assign(
225		__entry->irq		= irq;
226	),
227
228	TP_printk("irq %u", __entry->irq)
229);
230
231#define EXS(x) { x##_VECTOR, "#" #x }
232
233#define kvm_trace_sym_exc						\
234	EXS(DE), EXS(DB), EXS(BP), EXS(OF), EXS(BR), EXS(UD), EXS(NM),	\
235	EXS(DF), EXS(TS), EXS(NP), EXS(SS), EXS(GP), EXS(PF),		\
236	EXS(MF), EXS(MC)
237
238/*
239 * Tracepoint for kvm interrupt injection:
240 */
241TRACE_EVENT(kvm_inj_exception,
242	TP_PROTO(unsigned exception, bool has_error, unsigned error_code),
243	TP_ARGS(exception, has_error, error_code),
244
245	TP_STRUCT__entry(
246		__field(	u8,	exception	)
247		__field(	u8,	has_error	)
248		__field(	u32,	error_code	)
249	),
250
251	TP_fast_assign(
252		__entry->exception	= exception;
253		__entry->has_error	= has_error;
254		__entry->error_code	= error_code;
255	),
256
257	TP_printk("%s (0x%x)",
258		  __print_symbolic(__entry->exception, kvm_trace_sym_exc),
259		  /* FIXME: don't print error_code if not present */
260		  __entry->has_error ? __entry->error_code : 0)
261);
262
263/*
264 * Tracepoint for page fault.
265 */
266TRACE_EVENT(kvm_page_fault,
267	TP_PROTO(unsigned long fault_address, unsigned int error_code),
268	TP_ARGS(fault_address, error_code),
269
270	TP_STRUCT__entry(
271		__field(	unsigned long,	fault_address	)
272		__field(	unsigned int,	error_code	)
273	),
274
275	TP_fast_assign(
276		__entry->fault_address	= fault_address;
277		__entry->error_code	= error_code;
278	),
279
280	TP_printk("address %lx error_code %x",
281		  __entry->fault_address, __entry->error_code)
282);
283
284/*
285 * Tracepoint for guest MSR access.
286 */
287TRACE_EVENT(kvm_msr,
288	TP_PROTO(unsigned write, u32 ecx, u64 data, bool exception),
289	TP_ARGS(write, ecx, data, exception),
290
291	TP_STRUCT__entry(
292		__field(	unsigned,	write		)
293		__field(	u32,		ecx		)
294		__field(	u64,		data		)
295		__field(	u8,		exception	)
296	),
297
298	TP_fast_assign(
299		__entry->write		= write;
300		__entry->ecx		= ecx;
301		__entry->data		= data;
302		__entry->exception	= exception;
303	),
304
305	TP_printk("msr_%s %x = 0x%llx%s",
306		  __entry->write ? "write" : "read",
307		  __entry->ecx, __entry->data,
308		  __entry->exception ? " (#GP)" : "")
309);
310
311#define trace_kvm_msr_read(ecx, data)      trace_kvm_msr(0, ecx, data, false)
312#define trace_kvm_msr_write(ecx, data)     trace_kvm_msr(1, ecx, data, false)
313#define trace_kvm_msr_read_ex(ecx)         trace_kvm_msr(0, ecx, 0, true)
314#define trace_kvm_msr_write_ex(ecx, data)  trace_kvm_msr(1, ecx, data, true)
315
316/*
317 * Tracepoint for guest CR access.
318 */
319TRACE_EVENT(kvm_cr,
320	TP_PROTO(unsigned int rw, unsigned int cr, unsigned long val),
321	TP_ARGS(rw, cr, val),
322
323	TP_STRUCT__entry(
324		__field(	unsigned int,	rw		)
325		__field(	unsigned int,	cr		)
326		__field(	unsigned long,	val		)
327	),
328
329	TP_fast_assign(
330		__entry->rw		= rw;
331		__entry->cr		= cr;
332		__entry->val		= val;
333	),
334
335	TP_printk("cr_%s %x = 0x%lx",
336		  __entry->rw ? "write" : "read",
337		  __entry->cr, __entry->val)
338);
339
340#define trace_kvm_cr_read(cr, val)		trace_kvm_cr(0, cr, val)
341#define trace_kvm_cr_write(cr, val)		trace_kvm_cr(1, cr, val)
342
343TRACE_EVENT(kvm_pic_set_irq,
344	    TP_PROTO(__u8 chip, __u8 pin, __u8 elcr, __u8 imr, bool coalesced),
345	    TP_ARGS(chip, pin, elcr, imr, coalesced),
346
347	TP_STRUCT__entry(
348		__field(	__u8,		chip		)
349		__field(	__u8,		pin		)
350		__field(	__u8,		elcr		)
351		__field(	__u8,		imr		)
352		__field(	bool,		coalesced	)
353	),
354
355	TP_fast_assign(
356		__entry->chip		= chip;
357		__entry->pin		= pin;
358		__entry->elcr		= elcr;
359		__entry->imr		= imr;
360		__entry->coalesced	= coalesced;
361	),
362
363	TP_printk("chip %u pin %u (%s%s)%s",
364		  __entry->chip, __entry->pin,
365		  (__entry->elcr & (1 << __entry->pin)) ? "level":"edge",
366		  (__entry->imr & (1 << __entry->pin)) ? "|masked":"",
367		  __entry->coalesced ? " (coalesced)" : "")
368);
369
370#define kvm_apic_dst_shorthand		\
371	{0x0, "dst"},			\
372	{0x1, "self"},			\
373	{0x2, "all"},			\
374	{0x3, "all-but-self"}
375
376TRACE_EVENT(kvm_apic_ipi,
377	    TP_PROTO(__u32 icr_low, __u32 dest_id),
378	    TP_ARGS(icr_low, dest_id),
379
380	TP_STRUCT__entry(
381		__field(	__u32,		icr_low		)
382		__field(	__u32,		dest_id		)
383	),
384
385	TP_fast_assign(
386		__entry->icr_low	= icr_low;
387		__entry->dest_id	= dest_id;
388	),
389
390	TP_printk("dst %x vec %u (%s|%s|%s|%s|%s)",
391		  __entry->dest_id, (u8)__entry->icr_low,
392		  __print_symbolic((__entry->icr_low >> 8 & 0x7),
393				   kvm_deliver_mode),
394		  (__entry->icr_low & (1<<11)) ? "logical" : "physical",
395		  (__entry->icr_low & (1<<14)) ? "assert" : "de-assert",
396		  (__entry->icr_low & (1<<15)) ? "level" : "edge",
397		  __print_symbolic((__entry->icr_low >> 18 & 0x3),
398				   kvm_apic_dst_shorthand))
399);
400
401TRACE_EVENT(kvm_apic_accept_irq,
402	    TP_PROTO(__u32 apicid, __u16 dm, __u8 tm, __u8 vec, bool coalesced),
403	    TP_ARGS(apicid, dm, tm, vec, coalesced),
404
405	TP_STRUCT__entry(
406		__field(	__u32,		apicid		)
407		__field(	__u16,		dm		)
408		__field(	__u8,		tm		)
409		__field(	__u8,		vec		)
410		__field(	bool,		coalesced	)
411	),
412
413	TP_fast_assign(
414		__entry->apicid		= apicid;
415		__entry->dm		= dm;
416		__entry->tm		= tm;
417		__entry->vec		= vec;
418		__entry->coalesced	= coalesced;
419	),
420
421	TP_printk("apicid %x vec %u (%s|%s)%s",
422		  __entry->apicid, __entry->vec,
423		  __print_symbolic((__entry->dm >> 8 & 0x7), kvm_deliver_mode),
424		  __entry->tm ? "level" : "edge",
425		  __entry->coalesced ? " (coalesced)" : "")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
426);
427
428/*
429 * Tracepoint for nested VMRUN
430 */
431TRACE_EVENT(kvm_nested_vmrun,
432	    TP_PROTO(__u64 rip, __u64 vmcb, __u64 nested_rip, __u32 int_ctl,
433		     __u32 event_inj, bool npt),
434	    TP_ARGS(rip, vmcb, nested_rip, int_ctl, event_inj, npt),
435
436	TP_STRUCT__entry(
437		__field(	__u64,		rip		)
438		__field(	__u64,		vmcb		)
439		__field(	__u64,		nested_rip	)
440		__field(	__u32,		int_ctl		)
441		__field(	__u32,		event_inj	)
442		__field(	bool,		npt		)
443	),
444
445	TP_fast_assign(
446		__entry->rip		= rip;
447		__entry->vmcb		= vmcb;
448		__entry->nested_rip	= nested_rip;
449		__entry->int_ctl	= int_ctl;
450		__entry->event_inj	= event_inj;
451		__entry->npt		= npt;
452	),
453
454	TP_printk("rip: 0x%016llx vmcb: 0x%016llx nrip: 0x%016llx int_ctl: 0x%08x "
455		  "event_inj: 0x%08x npt: %s",
456		__entry->rip, __entry->vmcb, __entry->nested_rip,
457		__entry->int_ctl, __entry->event_inj,
458		__entry->npt ? "on" : "off")
459);
460
461TRACE_EVENT(kvm_nested_intercepts,
462	    TP_PROTO(__u16 cr_read, __u16 cr_write, __u32 exceptions, __u64 intercept),
463	    TP_ARGS(cr_read, cr_write, exceptions, intercept),
464
465	TP_STRUCT__entry(
466		__field(	__u16,		cr_read		)
467		__field(	__u16,		cr_write	)
468		__field(	__u32,		exceptions	)
469		__field(	__u64,		intercept	)
470	),
471
472	TP_fast_assign(
473		__entry->cr_read	= cr_read;
474		__entry->cr_write	= cr_write;
475		__entry->exceptions	= exceptions;
476		__entry->intercept	= intercept;
477	),
478
479	TP_printk("cr_read: %04x cr_write: %04x excp: %08x intercept: %016llx",
480		__entry->cr_read, __entry->cr_write, __entry->exceptions,
481		__entry->intercept)
482);
483/*
484 * Tracepoint for #VMEXIT while nested
485 */
486TRACE_EVENT(kvm_nested_vmexit,
487	    TP_PROTO(__u64 rip, __u32 exit_code,
488		     __u64 exit_info1, __u64 exit_info2,
489		     __u32 exit_int_info, __u32 exit_int_info_err),
490	    TP_ARGS(rip, exit_code, exit_info1, exit_info2,
491		    exit_int_info, exit_int_info_err),
492
493	TP_STRUCT__entry(
494		__field(	__u64,		rip			)
495		__field(	__u32,		exit_code		)
496		__field(	__u64,		exit_info1		)
497		__field(	__u64,		exit_info2		)
498		__field(	__u32,		exit_int_info		)
499		__field(	__u32,		exit_int_info_err	)
 
500	),
501
502	TP_fast_assign(
503		__entry->rip			= rip;
504		__entry->exit_code		= exit_code;
505		__entry->exit_info1		= exit_info1;
506		__entry->exit_info2		= exit_info2;
507		__entry->exit_int_info		= exit_int_info;
508		__entry->exit_int_info_err	= exit_int_info_err;
 
509	),
510	TP_printk("rip: 0x%016llx reason: %s ext_inf1: 0x%016llx "
511		  "ext_inf2: 0x%016llx ext_int: 0x%08x ext_int_err: 0x%08x",
512		  __entry->rip,
513		  ftrace_print_symbols_seq(p, __entry->exit_code,
514					   kvm_x86_ops->exit_reasons_str),
 
515		  __entry->exit_info1, __entry->exit_info2,
516		  __entry->exit_int_info, __entry->exit_int_info_err)
517);
518
519/*
520 * Tracepoint for #VMEXIT reinjected to the guest
521 */
522TRACE_EVENT(kvm_nested_vmexit_inject,
523	    TP_PROTO(__u32 exit_code,
524		     __u64 exit_info1, __u64 exit_info2,
525		     __u32 exit_int_info, __u32 exit_int_info_err),
526	    TP_ARGS(exit_code, exit_info1, exit_info2,
527		    exit_int_info, exit_int_info_err),
528
529	TP_STRUCT__entry(
530		__field(	__u32,		exit_code		)
531		__field(	__u64,		exit_info1		)
532		__field(	__u64,		exit_info2		)
533		__field(	__u32,		exit_int_info		)
534		__field(	__u32,		exit_int_info_err	)
 
535	),
536
537	TP_fast_assign(
538		__entry->exit_code		= exit_code;
539		__entry->exit_info1		= exit_info1;
540		__entry->exit_info2		= exit_info2;
541		__entry->exit_int_info		= exit_int_info;
542		__entry->exit_int_info_err	= exit_int_info_err;
 
543	),
544
545	TP_printk("reason: %s ext_inf1: 0x%016llx "
546		  "ext_inf2: 0x%016llx ext_int: 0x%08x ext_int_err: 0x%08x",
547		  ftrace_print_symbols_seq(p, __entry->exit_code,
548					   kvm_x86_ops->exit_reasons_str),
 
549		__entry->exit_info1, __entry->exit_info2,
550		__entry->exit_int_info, __entry->exit_int_info_err)
551);
552
553/*
554 * Tracepoint for nested #vmexit because of interrupt pending
555 */
556TRACE_EVENT(kvm_nested_intr_vmexit,
557	    TP_PROTO(__u64 rip),
558	    TP_ARGS(rip),
559
560	TP_STRUCT__entry(
561		__field(	__u64,	rip	)
562	),
563
564	TP_fast_assign(
565		__entry->rip	=	rip
566	),
567
568	TP_printk("rip: 0x%016llx", __entry->rip)
569);
570
571/*
572 * Tracepoint for nested #vmexit because of interrupt pending
573 */
574TRACE_EVENT(kvm_invlpga,
575	    TP_PROTO(__u64 rip, int asid, u64 address),
576	    TP_ARGS(rip, asid, address),
577
578	TP_STRUCT__entry(
579		__field(	__u64,	rip	)
580		__field(	int,	asid	)
581		__field(	__u64,	address	)
582	),
583
584	TP_fast_assign(
585		__entry->rip		=	rip;
586		__entry->asid		=	asid;
587		__entry->address	=	address;
588	),
589
590	TP_printk("rip: 0x%016llx asid: %d address: 0x%016llx",
591		  __entry->rip, __entry->asid, __entry->address)
592);
593
594/*
595 * Tracepoint for nested #vmexit because of interrupt pending
596 */
597TRACE_EVENT(kvm_skinit,
598	    TP_PROTO(__u64 rip, __u32 slb),
599	    TP_ARGS(rip, slb),
600
601	TP_STRUCT__entry(
602		__field(	__u64,	rip	)
603		__field(	__u32,	slb	)
604	),
605
606	TP_fast_assign(
607		__entry->rip		=	rip;
608		__entry->slb		=	slb;
609	),
610
611	TP_printk("rip: 0x%016llx slb: 0x%08x",
612		  __entry->rip, __entry->slb)
613);
614
615#define __print_insn(insn, ilen) ({		                 \
616	int i;							 \
617	const char *ret = p->buffer + p->len;			 \
618								 \
619	for (i = 0; i < ilen; ++i)				 \
620		trace_seq_printf(p, " %02x", insn[i]);		 \
621	trace_seq_printf(p, "%c", 0);				 \
622	ret;							 \
623	})
624
625#define KVM_EMUL_INSN_F_CR0_PE (1 << 0)
626#define KVM_EMUL_INSN_F_EFL_VM (1 << 1)
627#define KVM_EMUL_INSN_F_CS_D   (1 << 2)
628#define KVM_EMUL_INSN_F_CS_L   (1 << 3)
629
630#define kvm_trace_symbol_emul_flags	                  \
631	{ 0,   			    "real" },		  \
632	{ KVM_EMUL_INSN_F_CR0_PE			  \
633	  | KVM_EMUL_INSN_F_EFL_VM, "vm16" },		  \
634	{ KVM_EMUL_INSN_F_CR0_PE,   "prot16" },		  \
635	{ KVM_EMUL_INSN_F_CR0_PE			  \
636	  | KVM_EMUL_INSN_F_CS_D,   "prot32" },		  \
637	{ KVM_EMUL_INSN_F_CR0_PE			  \
638	  | KVM_EMUL_INSN_F_CS_L,   "prot64" }
639
640#define kei_decode_mode(mode) ({			\
641	u8 flags = 0xff;				\
642	switch (mode) {					\
643	case X86EMUL_MODE_REAL:				\
644		flags = 0;				\
645		break;					\
646	case X86EMUL_MODE_VM86:				\
647		flags = KVM_EMUL_INSN_F_EFL_VM;		\
648		break;					\
649	case X86EMUL_MODE_PROT16:			\
650		flags = KVM_EMUL_INSN_F_CR0_PE;		\
651		break;					\
652	case X86EMUL_MODE_PROT32:			\
653		flags = KVM_EMUL_INSN_F_CR0_PE		\
654			| KVM_EMUL_INSN_F_CS_D;		\
655		break;					\
656	case X86EMUL_MODE_PROT64:			\
657		flags = KVM_EMUL_INSN_F_CR0_PE		\
658			| KVM_EMUL_INSN_F_CS_L;		\
659		break;					\
660	}						\
661	flags;						\
662	})
663
664TRACE_EVENT(kvm_emulate_insn,
665	TP_PROTO(struct kvm_vcpu *vcpu, __u8 failed),
666	TP_ARGS(vcpu, failed),
667
668	TP_STRUCT__entry(
669		__field(    __u64, rip                       )
670		__field(    __u32, csbase                    )
671		__field(    __u8,  len                       )
672		__array(    __u8,  insn,    15	             )
673		__field(    __u8,  flags       	   	     )
674		__field(    __u8,  failed                    )
675		),
676
677	TP_fast_assign(
678		__entry->rip = vcpu->arch.emulate_ctxt.fetch.start;
679		__entry->csbase = kvm_x86_ops->get_segment_base(vcpu, VCPU_SREG_CS);
680		__entry->len = vcpu->arch.emulate_ctxt._eip
681			       - vcpu->arch.emulate_ctxt.fetch.start;
 
682		memcpy(__entry->insn,
683		       vcpu->arch.emulate_ctxt.fetch.data,
684		       15);
685		__entry->flags = kei_decode_mode(vcpu->arch.emulate_ctxt.mode);
686		__entry->failed = failed;
687		),
688
689	TP_printk("%x:%llx:%s (%s)%s",
690		  __entry->csbase, __entry->rip,
691		  __print_insn(__entry->insn, __entry->len),
692		  __print_symbolic(__entry->flags,
693				   kvm_trace_symbol_emul_flags),
694		  __entry->failed ? " failed" : ""
695		)
696	);
697
698#define trace_kvm_emulate_insn_start(vcpu) trace_kvm_emulate_insn(vcpu, 0)
699#define trace_kvm_emulate_insn_failed(vcpu) trace_kvm_emulate_insn(vcpu, 1)
700
701TRACE_EVENT(
702	vcpu_match_mmio,
703	TP_PROTO(gva_t gva, gpa_t gpa, bool write, bool gpa_match),
704	TP_ARGS(gva, gpa, write, gpa_match),
705
706	TP_STRUCT__entry(
707		__field(gva_t, gva)
708		__field(gpa_t, gpa)
709		__field(bool, write)
710		__field(bool, gpa_match)
711		),
712
713	TP_fast_assign(
714		__entry->gva = gva;
715		__entry->gpa = gpa;
716		__entry->write = write;
717		__entry->gpa_match = gpa_match
718		),
719
720	TP_printk("gva %#lx gpa %#llx %s %s", __entry->gva, __entry->gpa,
721		  __entry->write ? "Write" : "Read",
722		  __entry->gpa_match ? "GPA" : "GVA")
723);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
724#endif /* _TRACE_KVM_H */
725
726#undef TRACE_INCLUDE_PATH
727#define TRACE_INCLUDE_PATH arch/x86/kvm
728#undef TRACE_INCLUDE_FILE
729#define TRACE_INCLUDE_FILE trace
730
731/* This part must be outside protection */
732#include <trace/define_trace.h>
v4.6
   1#if !defined(_TRACE_KVM_H) || defined(TRACE_HEADER_MULTI_READ)
   2#define _TRACE_KVM_H
   3
   4#include <linux/tracepoint.h>
   5#include <asm/vmx.h>
   6#include <asm/svm.h>
   7#include <asm/clocksource.h>
   8#include <asm/pvclock-abi.h>
   9
  10#undef TRACE_SYSTEM
  11#define TRACE_SYSTEM kvm
  12
  13/*
  14 * Tracepoint for guest mode entry.
  15 */
  16TRACE_EVENT(kvm_entry,
  17	TP_PROTO(unsigned int vcpu_id),
  18	TP_ARGS(vcpu_id),
  19
  20	TP_STRUCT__entry(
  21		__field(	unsigned int,	vcpu_id		)
  22	),
  23
  24	TP_fast_assign(
  25		__entry->vcpu_id	= vcpu_id;
  26	),
  27
  28	TP_printk("vcpu %u", __entry->vcpu_id)
  29);
  30
  31/*
  32 * Tracepoint for hypercall.
  33 */
  34TRACE_EVENT(kvm_hypercall,
  35	TP_PROTO(unsigned long nr, unsigned long a0, unsigned long a1,
  36		 unsigned long a2, unsigned long a3),
  37	TP_ARGS(nr, a0, a1, a2, a3),
  38
  39	TP_STRUCT__entry(
  40		__field(	unsigned long, 	nr		)
  41		__field(	unsigned long,	a0		)
  42		__field(	unsigned long,	a1		)
  43		__field(	unsigned long,	a2		)
  44		__field(	unsigned long,	a3		)
  45	),
  46
  47	TP_fast_assign(
  48		__entry->nr		= nr;
  49		__entry->a0		= a0;
  50		__entry->a1		= a1;
  51		__entry->a2		= a2;
  52		__entry->a3		= a3;
  53	),
  54
  55	TP_printk("nr 0x%lx a0 0x%lx a1 0x%lx a2 0x%lx a3 0x%lx",
  56		 __entry->nr, __entry->a0, __entry->a1,  __entry->a2,
  57		 __entry->a3)
  58);
  59
  60/*
  61 * Tracepoint for hypercall.
  62 */
  63TRACE_EVENT(kvm_hv_hypercall,
  64	TP_PROTO(__u16 code, bool fast, __u16 rep_cnt, __u16 rep_idx,
  65		 __u64 ingpa, __u64 outgpa),
  66	TP_ARGS(code, fast, rep_cnt, rep_idx, ingpa, outgpa),
  67
  68	TP_STRUCT__entry(
  69		__field(	__u16,		rep_cnt		)
  70		__field(	__u16,		rep_idx		)
  71		__field(	__u64,		ingpa		)
  72		__field(	__u64,		outgpa		)
  73		__field(	__u16, 		code		)
  74		__field(	bool,		fast		)
  75	),
  76
  77	TP_fast_assign(
  78		__entry->rep_cnt	= rep_cnt;
  79		__entry->rep_idx	= rep_idx;
  80		__entry->ingpa		= ingpa;
  81		__entry->outgpa		= outgpa;
  82		__entry->code		= code;
  83		__entry->fast		= fast;
  84	),
  85
  86	TP_printk("code 0x%x %s cnt 0x%x idx 0x%x in 0x%llx out 0x%llx",
  87		  __entry->code, __entry->fast ? "fast" : "slow",
  88		  __entry->rep_cnt, __entry->rep_idx,  __entry->ingpa,
  89		  __entry->outgpa)
  90);
  91
  92/*
  93 * Tracepoint for PIO.
  94 */
  95
  96#define KVM_PIO_IN   0
  97#define KVM_PIO_OUT  1
  98
  99TRACE_EVENT(kvm_pio,
 100	TP_PROTO(unsigned int rw, unsigned int port, unsigned int size,
 101		 unsigned int count, void *data),
 102	TP_ARGS(rw, port, size, count, data),
 103
 104	TP_STRUCT__entry(
 105		__field(	unsigned int, 	rw		)
 106		__field(	unsigned int, 	port		)
 107		__field(	unsigned int, 	size		)
 108		__field(	unsigned int,	count		)
 109		__field(	unsigned int,	val		)
 110	),
 111
 112	TP_fast_assign(
 113		__entry->rw		= rw;
 114		__entry->port		= port;
 115		__entry->size		= size;
 116		__entry->count		= count;
 117		if (size == 1)
 118			__entry->val	= *(unsigned char *)data;
 119		else if (size == 2)
 120			__entry->val	= *(unsigned short *)data;
 121		else
 122			__entry->val	= *(unsigned int *)data;
 123	),
 124
 125	TP_printk("pio_%s at 0x%x size %d count %d val 0x%x %s",
 126		  __entry->rw ? "write" : "read",
 127		  __entry->port, __entry->size, __entry->count, __entry->val,
 128		  __entry->count > 1 ? "(...)" : "")
 129);
 130
 131/*
 132 * Tracepoint for fast mmio.
 133 */
 134TRACE_EVENT(kvm_fast_mmio,
 135	TP_PROTO(u64 gpa),
 136	TP_ARGS(gpa),
 137
 138	TP_STRUCT__entry(
 139		__field(u64,	gpa)
 140	),
 141
 142	TP_fast_assign(
 143		__entry->gpa		= gpa;
 144	),
 145
 146	TP_printk("fast mmio at gpa 0x%llx", __entry->gpa)
 147);
 148
 149/*
 150 * Tracepoint for cpuid.
 151 */
 152TRACE_EVENT(kvm_cpuid,
 153	TP_PROTO(unsigned int function, unsigned long rax, unsigned long rbx,
 154		 unsigned long rcx, unsigned long rdx),
 155	TP_ARGS(function, rax, rbx, rcx, rdx),
 156
 157	TP_STRUCT__entry(
 158		__field(	unsigned int,	function	)
 159		__field(	unsigned long,	rax		)
 160		__field(	unsigned long,	rbx		)
 161		__field(	unsigned long,	rcx		)
 162		__field(	unsigned long,	rdx		)
 163	),
 164
 165	TP_fast_assign(
 166		__entry->function	= function;
 167		__entry->rax		= rax;
 168		__entry->rbx		= rbx;
 169		__entry->rcx		= rcx;
 170		__entry->rdx		= rdx;
 171	),
 172
 173	TP_printk("func %x rax %lx rbx %lx rcx %lx rdx %lx",
 174		  __entry->function, __entry->rax,
 175		  __entry->rbx, __entry->rcx, __entry->rdx)
 176);
 177
 178#define AREG(x) { APIC_##x, "APIC_" #x }
 179
 180#define kvm_trace_symbol_apic						    \
 181	AREG(ID), AREG(LVR), AREG(TASKPRI), AREG(ARBPRI), AREG(PROCPRI),    \
 182	AREG(EOI), AREG(RRR), AREG(LDR), AREG(DFR), AREG(SPIV), AREG(ISR),  \
 183	AREG(TMR), AREG(IRR), AREG(ESR), AREG(ICR), AREG(ICR2), AREG(LVTT), \
 184	AREG(LVTTHMR), AREG(LVTPC), AREG(LVT0), AREG(LVT1), AREG(LVTERR),   \
 185	AREG(TMICT), AREG(TMCCT), AREG(TDCR), AREG(SELF_IPI), AREG(EFEAT),  \
 186	AREG(ECTRL)
 187/*
 188 * Tracepoint for apic access.
 189 */
 190TRACE_EVENT(kvm_apic,
 191	TP_PROTO(unsigned int rw, unsigned int reg, unsigned int val),
 192	TP_ARGS(rw, reg, val),
 193
 194	TP_STRUCT__entry(
 195		__field(	unsigned int,	rw		)
 196		__field(	unsigned int,	reg		)
 197		__field(	unsigned int,	val		)
 198	),
 199
 200	TP_fast_assign(
 201		__entry->rw		= rw;
 202		__entry->reg		= reg;
 203		__entry->val		= val;
 204	),
 205
 206	TP_printk("apic_%s %s = 0x%x",
 207		  __entry->rw ? "write" : "read",
 208		  __print_symbolic(__entry->reg, kvm_trace_symbol_apic),
 209		  __entry->val)
 210);
 211
 212#define trace_kvm_apic_read(reg, val)		trace_kvm_apic(0, reg, val)
 213#define trace_kvm_apic_write(reg, val)		trace_kvm_apic(1, reg, val)
 214
 215#define KVM_ISA_VMX   1
 216#define KVM_ISA_SVM   2
 217
 218/*
 219 * Tracepoint for kvm guest exit:
 220 */
 221TRACE_EVENT(kvm_exit,
 222	TP_PROTO(unsigned int exit_reason, struct kvm_vcpu *vcpu, u32 isa),
 223	TP_ARGS(exit_reason, vcpu, isa),
 224
 225	TP_STRUCT__entry(
 226		__field(	unsigned int,	exit_reason	)
 227		__field(	unsigned long,	guest_rip	)
 228		__field(	u32,	        isa             )
 229		__field(	u64,	        info1           )
 230		__field(	u64,	        info2           )
 231	),
 232
 233	TP_fast_assign(
 234		__entry->exit_reason	= exit_reason;
 235		__entry->guest_rip	= kvm_rip_read(vcpu);
 236		__entry->isa            = isa;
 237		kvm_x86_ops->get_exit_info(vcpu, &__entry->info1,
 238					   &__entry->info2);
 239	),
 240
 241	TP_printk("reason %s rip 0x%lx info %llx %llx",
 242		 (__entry->isa == KVM_ISA_VMX) ?
 243		 __print_symbolic(__entry->exit_reason, VMX_EXIT_REASONS) :
 244		 __print_symbolic(__entry->exit_reason, SVM_EXIT_REASONS),
 245		 __entry->guest_rip, __entry->info1, __entry->info2)
 246);
 247
 248/*
 249 * Tracepoint for kvm interrupt injection:
 250 */
 251TRACE_EVENT(kvm_inj_virq,
 252	TP_PROTO(unsigned int irq),
 253	TP_ARGS(irq),
 254
 255	TP_STRUCT__entry(
 256		__field(	unsigned int,	irq		)
 257	),
 258
 259	TP_fast_assign(
 260		__entry->irq		= irq;
 261	),
 262
 263	TP_printk("irq %u", __entry->irq)
 264);
 265
 266#define EXS(x) { x##_VECTOR, "#" #x }
 267
 268#define kvm_trace_sym_exc						\
 269	EXS(DE), EXS(DB), EXS(BP), EXS(OF), EXS(BR), EXS(UD), EXS(NM),	\
 270	EXS(DF), EXS(TS), EXS(NP), EXS(SS), EXS(GP), EXS(PF),		\
 271	EXS(MF), EXS(AC), EXS(MC)
 272
 273/*
 274 * Tracepoint for kvm interrupt injection:
 275 */
 276TRACE_EVENT(kvm_inj_exception,
 277	TP_PROTO(unsigned exception, bool has_error, unsigned error_code),
 278	TP_ARGS(exception, has_error, error_code),
 279
 280	TP_STRUCT__entry(
 281		__field(	u8,	exception	)
 282		__field(	u8,	has_error	)
 283		__field(	u32,	error_code	)
 284	),
 285
 286	TP_fast_assign(
 287		__entry->exception	= exception;
 288		__entry->has_error	= has_error;
 289		__entry->error_code	= error_code;
 290	),
 291
 292	TP_printk("%s (0x%x)",
 293		  __print_symbolic(__entry->exception, kvm_trace_sym_exc),
 294		  /* FIXME: don't print error_code if not present */
 295		  __entry->has_error ? __entry->error_code : 0)
 296);
 297
 298/*
 299 * Tracepoint for page fault.
 300 */
 301TRACE_EVENT(kvm_page_fault,
 302	TP_PROTO(unsigned long fault_address, unsigned int error_code),
 303	TP_ARGS(fault_address, error_code),
 304
 305	TP_STRUCT__entry(
 306		__field(	unsigned long,	fault_address	)
 307		__field(	unsigned int,	error_code	)
 308	),
 309
 310	TP_fast_assign(
 311		__entry->fault_address	= fault_address;
 312		__entry->error_code	= error_code;
 313	),
 314
 315	TP_printk("address %lx error_code %x",
 316		  __entry->fault_address, __entry->error_code)
 317);
 318
 319/*
 320 * Tracepoint for guest MSR access.
 321 */
 322TRACE_EVENT(kvm_msr,
 323	TP_PROTO(unsigned write, u32 ecx, u64 data, bool exception),
 324	TP_ARGS(write, ecx, data, exception),
 325
 326	TP_STRUCT__entry(
 327		__field(	unsigned,	write		)
 328		__field(	u32,		ecx		)
 329		__field(	u64,		data		)
 330		__field(	u8,		exception	)
 331	),
 332
 333	TP_fast_assign(
 334		__entry->write		= write;
 335		__entry->ecx		= ecx;
 336		__entry->data		= data;
 337		__entry->exception	= exception;
 338	),
 339
 340	TP_printk("msr_%s %x = 0x%llx%s",
 341		  __entry->write ? "write" : "read",
 342		  __entry->ecx, __entry->data,
 343		  __entry->exception ? " (#GP)" : "")
 344);
 345
 346#define trace_kvm_msr_read(ecx, data)      trace_kvm_msr(0, ecx, data, false)
 347#define trace_kvm_msr_write(ecx, data)     trace_kvm_msr(1, ecx, data, false)
 348#define trace_kvm_msr_read_ex(ecx)         trace_kvm_msr(0, ecx, 0, true)
 349#define trace_kvm_msr_write_ex(ecx, data)  trace_kvm_msr(1, ecx, data, true)
 350
 351/*
 352 * Tracepoint for guest CR access.
 353 */
 354TRACE_EVENT(kvm_cr,
 355	TP_PROTO(unsigned int rw, unsigned int cr, unsigned long val),
 356	TP_ARGS(rw, cr, val),
 357
 358	TP_STRUCT__entry(
 359		__field(	unsigned int,	rw		)
 360		__field(	unsigned int,	cr		)
 361		__field(	unsigned long,	val		)
 362	),
 363
 364	TP_fast_assign(
 365		__entry->rw		= rw;
 366		__entry->cr		= cr;
 367		__entry->val		= val;
 368	),
 369
 370	TP_printk("cr_%s %x = 0x%lx",
 371		  __entry->rw ? "write" : "read",
 372		  __entry->cr, __entry->val)
 373);
 374
 375#define trace_kvm_cr_read(cr, val)		trace_kvm_cr(0, cr, val)
 376#define trace_kvm_cr_write(cr, val)		trace_kvm_cr(1, cr, val)
 377
 378TRACE_EVENT(kvm_pic_set_irq,
 379	    TP_PROTO(__u8 chip, __u8 pin, __u8 elcr, __u8 imr, bool coalesced),
 380	    TP_ARGS(chip, pin, elcr, imr, coalesced),
 381
 382	TP_STRUCT__entry(
 383		__field(	__u8,		chip		)
 384		__field(	__u8,		pin		)
 385		__field(	__u8,		elcr		)
 386		__field(	__u8,		imr		)
 387		__field(	bool,		coalesced	)
 388	),
 389
 390	TP_fast_assign(
 391		__entry->chip		= chip;
 392		__entry->pin		= pin;
 393		__entry->elcr		= elcr;
 394		__entry->imr		= imr;
 395		__entry->coalesced	= coalesced;
 396	),
 397
 398	TP_printk("chip %u pin %u (%s%s)%s",
 399		  __entry->chip, __entry->pin,
 400		  (__entry->elcr & (1 << __entry->pin)) ? "level":"edge",
 401		  (__entry->imr & (1 << __entry->pin)) ? "|masked":"",
 402		  __entry->coalesced ? " (coalesced)" : "")
 403);
 404
 405#define kvm_apic_dst_shorthand		\
 406	{0x0, "dst"},			\
 407	{0x1, "self"},			\
 408	{0x2, "all"},			\
 409	{0x3, "all-but-self"}
 410
 411TRACE_EVENT(kvm_apic_ipi,
 412	    TP_PROTO(__u32 icr_low, __u32 dest_id),
 413	    TP_ARGS(icr_low, dest_id),
 414
 415	TP_STRUCT__entry(
 416		__field(	__u32,		icr_low		)
 417		__field(	__u32,		dest_id		)
 418	),
 419
 420	TP_fast_assign(
 421		__entry->icr_low	= icr_low;
 422		__entry->dest_id	= dest_id;
 423	),
 424
 425	TP_printk("dst %x vec %u (%s|%s|%s|%s|%s)",
 426		  __entry->dest_id, (u8)__entry->icr_low,
 427		  __print_symbolic((__entry->icr_low >> 8 & 0x7),
 428				   kvm_deliver_mode),
 429		  (__entry->icr_low & (1<<11)) ? "logical" : "physical",
 430		  (__entry->icr_low & (1<<14)) ? "assert" : "de-assert",
 431		  (__entry->icr_low & (1<<15)) ? "level" : "edge",
 432		  __print_symbolic((__entry->icr_low >> 18 & 0x3),
 433				   kvm_apic_dst_shorthand))
 434);
 435
 436TRACE_EVENT(kvm_apic_accept_irq,
 437	    TP_PROTO(__u32 apicid, __u16 dm, __u8 tm, __u8 vec),
 438	    TP_ARGS(apicid, dm, tm, vec),
 439
 440	TP_STRUCT__entry(
 441		__field(	__u32,		apicid		)
 442		__field(	__u16,		dm		)
 443		__field(	__u8,		tm		)
 444		__field(	__u8,		vec		)
 
 445	),
 446
 447	TP_fast_assign(
 448		__entry->apicid		= apicid;
 449		__entry->dm		= dm;
 450		__entry->tm		= tm;
 451		__entry->vec		= vec;
 
 452	),
 453
 454	TP_printk("apicid %x vec %u (%s|%s)",
 455		  __entry->apicid, __entry->vec,
 456		  __print_symbolic((__entry->dm >> 8 & 0x7), kvm_deliver_mode),
 457		  __entry->tm ? "level" : "edge")
 458);
 459
 460TRACE_EVENT(kvm_eoi,
 461	    TP_PROTO(struct kvm_lapic *apic, int vector),
 462	    TP_ARGS(apic, vector),
 463
 464	TP_STRUCT__entry(
 465		__field(	__u32,		apicid		)
 466		__field(	int,		vector		)
 467	),
 468
 469	TP_fast_assign(
 470		__entry->apicid		= apic->vcpu->vcpu_id;
 471		__entry->vector		= vector;
 472	),
 473
 474	TP_printk("apicid %x vector %d", __entry->apicid, __entry->vector)
 475);
 476
 477TRACE_EVENT(kvm_pv_eoi,
 478	    TP_PROTO(struct kvm_lapic *apic, int vector),
 479	    TP_ARGS(apic, vector),
 480
 481	TP_STRUCT__entry(
 482		__field(	__u32,		apicid		)
 483		__field(	int,		vector		)
 484	),
 485
 486	TP_fast_assign(
 487		__entry->apicid		= apic->vcpu->vcpu_id;
 488		__entry->vector		= vector;
 489	),
 490
 491	TP_printk("apicid %x vector %d", __entry->apicid, __entry->vector)
 492);
 493
 494/*
 495 * Tracepoint for nested VMRUN
 496 */
 497TRACE_EVENT(kvm_nested_vmrun,
 498	    TP_PROTO(__u64 rip, __u64 vmcb, __u64 nested_rip, __u32 int_ctl,
 499		     __u32 event_inj, bool npt),
 500	    TP_ARGS(rip, vmcb, nested_rip, int_ctl, event_inj, npt),
 501
 502	TP_STRUCT__entry(
 503		__field(	__u64,		rip		)
 504		__field(	__u64,		vmcb		)
 505		__field(	__u64,		nested_rip	)
 506		__field(	__u32,		int_ctl		)
 507		__field(	__u32,		event_inj	)
 508		__field(	bool,		npt		)
 509	),
 510
 511	TP_fast_assign(
 512		__entry->rip		= rip;
 513		__entry->vmcb		= vmcb;
 514		__entry->nested_rip	= nested_rip;
 515		__entry->int_ctl	= int_ctl;
 516		__entry->event_inj	= event_inj;
 517		__entry->npt		= npt;
 518	),
 519
 520	TP_printk("rip: 0x%016llx vmcb: 0x%016llx nrip: 0x%016llx int_ctl: 0x%08x "
 521		  "event_inj: 0x%08x npt: %s",
 522		__entry->rip, __entry->vmcb, __entry->nested_rip,
 523		__entry->int_ctl, __entry->event_inj,
 524		__entry->npt ? "on" : "off")
 525);
 526
 527TRACE_EVENT(kvm_nested_intercepts,
 528	    TP_PROTO(__u16 cr_read, __u16 cr_write, __u32 exceptions, __u64 intercept),
 529	    TP_ARGS(cr_read, cr_write, exceptions, intercept),
 530
 531	TP_STRUCT__entry(
 532		__field(	__u16,		cr_read		)
 533		__field(	__u16,		cr_write	)
 534		__field(	__u32,		exceptions	)
 535		__field(	__u64,		intercept	)
 536	),
 537
 538	TP_fast_assign(
 539		__entry->cr_read	= cr_read;
 540		__entry->cr_write	= cr_write;
 541		__entry->exceptions	= exceptions;
 542		__entry->intercept	= intercept;
 543	),
 544
 545	TP_printk("cr_read: %04x cr_write: %04x excp: %08x intercept: %016llx",
 546		__entry->cr_read, __entry->cr_write, __entry->exceptions,
 547		__entry->intercept)
 548);
 549/*
 550 * Tracepoint for #VMEXIT while nested
 551 */
 552TRACE_EVENT(kvm_nested_vmexit,
 553	    TP_PROTO(__u64 rip, __u32 exit_code,
 554		     __u64 exit_info1, __u64 exit_info2,
 555		     __u32 exit_int_info, __u32 exit_int_info_err, __u32 isa),
 556	    TP_ARGS(rip, exit_code, exit_info1, exit_info2,
 557		    exit_int_info, exit_int_info_err, isa),
 558
 559	TP_STRUCT__entry(
 560		__field(	__u64,		rip			)
 561		__field(	__u32,		exit_code		)
 562		__field(	__u64,		exit_info1		)
 563		__field(	__u64,		exit_info2		)
 564		__field(	__u32,		exit_int_info		)
 565		__field(	__u32,		exit_int_info_err	)
 566		__field(	__u32,		isa			)
 567	),
 568
 569	TP_fast_assign(
 570		__entry->rip			= rip;
 571		__entry->exit_code		= exit_code;
 572		__entry->exit_info1		= exit_info1;
 573		__entry->exit_info2		= exit_info2;
 574		__entry->exit_int_info		= exit_int_info;
 575		__entry->exit_int_info_err	= exit_int_info_err;
 576		__entry->isa			= isa;
 577	),
 578	TP_printk("rip: 0x%016llx reason: %s ext_inf1: 0x%016llx "
 579		  "ext_inf2: 0x%016llx ext_int: 0x%08x ext_int_err: 0x%08x",
 580		  __entry->rip,
 581		 (__entry->isa == KVM_ISA_VMX) ?
 582		 __print_symbolic(__entry->exit_code, VMX_EXIT_REASONS) :
 583		 __print_symbolic(__entry->exit_code, SVM_EXIT_REASONS),
 584		  __entry->exit_info1, __entry->exit_info2,
 585		  __entry->exit_int_info, __entry->exit_int_info_err)
 586);
 587
 588/*
 589 * Tracepoint for #VMEXIT reinjected to the guest
 590 */
 591TRACE_EVENT(kvm_nested_vmexit_inject,
 592	    TP_PROTO(__u32 exit_code,
 593		     __u64 exit_info1, __u64 exit_info2,
 594		     __u32 exit_int_info, __u32 exit_int_info_err, __u32 isa),
 595	    TP_ARGS(exit_code, exit_info1, exit_info2,
 596		    exit_int_info, exit_int_info_err, isa),
 597
 598	TP_STRUCT__entry(
 599		__field(	__u32,		exit_code		)
 600		__field(	__u64,		exit_info1		)
 601		__field(	__u64,		exit_info2		)
 602		__field(	__u32,		exit_int_info		)
 603		__field(	__u32,		exit_int_info_err	)
 604		__field(	__u32,		isa			)
 605	),
 606
 607	TP_fast_assign(
 608		__entry->exit_code		= exit_code;
 609		__entry->exit_info1		= exit_info1;
 610		__entry->exit_info2		= exit_info2;
 611		__entry->exit_int_info		= exit_int_info;
 612		__entry->exit_int_info_err	= exit_int_info_err;
 613		__entry->isa			= isa;
 614	),
 615
 616	TP_printk("reason: %s ext_inf1: 0x%016llx "
 617		  "ext_inf2: 0x%016llx ext_int: 0x%08x ext_int_err: 0x%08x",
 618		 (__entry->isa == KVM_ISA_VMX) ?
 619		 __print_symbolic(__entry->exit_code, VMX_EXIT_REASONS) :
 620		 __print_symbolic(__entry->exit_code, SVM_EXIT_REASONS),
 621		__entry->exit_info1, __entry->exit_info2,
 622		__entry->exit_int_info, __entry->exit_int_info_err)
 623);
 624
 625/*
 626 * Tracepoint for nested #vmexit because of interrupt pending
 627 */
 628TRACE_EVENT(kvm_nested_intr_vmexit,
 629	    TP_PROTO(__u64 rip),
 630	    TP_ARGS(rip),
 631
 632	TP_STRUCT__entry(
 633		__field(	__u64,	rip	)
 634	),
 635
 636	TP_fast_assign(
 637		__entry->rip	=	rip
 638	),
 639
 640	TP_printk("rip: 0x%016llx", __entry->rip)
 641);
 642
 643/*
 644 * Tracepoint for nested #vmexit because of interrupt pending
 645 */
 646TRACE_EVENT(kvm_invlpga,
 647	    TP_PROTO(__u64 rip, int asid, u64 address),
 648	    TP_ARGS(rip, asid, address),
 649
 650	TP_STRUCT__entry(
 651		__field(	__u64,	rip	)
 652		__field(	int,	asid	)
 653		__field(	__u64,	address	)
 654	),
 655
 656	TP_fast_assign(
 657		__entry->rip		=	rip;
 658		__entry->asid		=	asid;
 659		__entry->address	=	address;
 660	),
 661
 662	TP_printk("rip: 0x%016llx asid: %d address: 0x%016llx",
 663		  __entry->rip, __entry->asid, __entry->address)
 664);
 665
 666/*
 667 * Tracepoint for nested #vmexit because of interrupt pending
 668 */
 669TRACE_EVENT(kvm_skinit,
 670	    TP_PROTO(__u64 rip, __u32 slb),
 671	    TP_ARGS(rip, slb),
 672
 673	TP_STRUCT__entry(
 674		__field(	__u64,	rip	)
 675		__field(	__u32,	slb	)
 676	),
 677
 678	TP_fast_assign(
 679		__entry->rip		=	rip;
 680		__entry->slb		=	slb;
 681	),
 682
 683	TP_printk("rip: 0x%016llx slb: 0x%08x",
 684		  __entry->rip, __entry->slb)
 685);
 686
 
 
 
 
 
 
 
 
 
 
 687#define KVM_EMUL_INSN_F_CR0_PE (1 << 0)
 688#define KVM_EMUL_INSN_F_EFL_VM (1 << 1)
 689#define KVM_EMUL_INSN_F_CS_D   (1 << 2)
 690#define KVM_EMUL_INSN_F_CS_L   (1 << 3)
 691
 692#define kvm_trace_symbol_emul_flags	                  \
 693	{ 0,   			    "real" },		  \
 694	{ KVM_EMUL_INSN_F_CR0_PE			  \
 695	  | KVM_EMUL_INSN_F_EFL_VM, "vm16" },		  \
 696	{ KVM_EMUL_INSN_F_CR0_PE,   "prot16" },		  \
 697	{ KVM_EMUL_INSN_F_CR0_PE			  \
 698	  | KVM_EMUL_INSN_F_CS_D,   "prot32" },		  \
 699	{ KVM_EMUL_INSN_F_CR0_PE			  \
 700	  | KVM_EMUL_INSN_F_CS_L,   "prot64" }
 701
 702#define kei_decode_mode(mode) ({			\
 703	u8 flags = 0xff;				\
 704	switch (mode) {					\
 705	case X86EMUL_MODE_REAL:				\
 706		flags = 0;				\
 707		break;					\
 708	case X86EMUL_MODE_VM86:				\
 709		flags = KVM_EMUL_INSN_F_EFL_VM;		\
 710		break;					\
 711	case X86EMUL_MODE_PROT16:			\
 712		flags = KVM_EMUL_INSN_F_CR0_PE;		\
 713		break;					\
 714	case X86EMUL_MODE_PROT32:			\
 715		flags = KVM_EMUL_INSN_F_CR0_PE		\
 716			| KVM_EMUL_INSN_F_CS_D;		\
 717		break;					\
 718	case X86EMUL_MODE_PROT64:			\
 719		flags = KVM_EMUL_INSN_F_CR0_PE		\
 720			| KVM_EMUL_INSN_F_CS_L;		\
 721		break;					\
 722	}						\
 723	flags;						\
 724	})
 725
 726TRACE_EVENT(kvm_emulate_insn,
 727	TP_PROTO(struct kvm_vcpu *vcpu, __u8 failed),
 728	TP_ARGS(vcpu, failed),
 729
 730	TP_STRUCT__entry(
 731		__field(    __u64, rip                       )
 732		__field(    __u32, csbase                    )
 733		__field(    __u8,  len                       )
 734		__array(    __u8,  insn,    15	             )
 735		__field(    __u8,  flags       	   	     )
 736		__field(    __u8,  failed                    )
 737		),
 738
 739	TP_fast_assign(
 
 740		__entry->csbase = kvm_x86_ops->get_segment_base(vcpu, VCPU_SREG_CS);
 741		__entry->len = vcpu->arch.emulate_ctxt.fetch.ptr
 742			       - vcpu->arch.emulate_ctxt.fetch.data;
 743		__entry->rip = vcpu->arch.emulate_ctxt._eip - __entry->len;
 744		memcpy(__entry->insn,
 745		       vcpu->arch.emulate_ctxt.fetch.data,
 746		       15);
 747		__entry->flags = kei_decode_mode(vcpu->arch.emulate_ctxt.mode);
 748		__entry->failed = failed;
 749		),
 750
 751	TP_printk("%x:%llx:%s (%s)%s",
 752		  __entry->csbase, __entry->rip,
 753		  __print_hex(__entry->insn, __entry->len),
 754		  __print_symbolic(__entry->flags,
 755				   kvm_trace_symbol_emul_flags),
 756		  __entry->failed ? " failed" : ""
 757		)
 758	);
 759
 760#define trace_kvm_emulate_insn_start(vcpu) trace_kvm_emulate_insn(vcpu, 0)
 761#define trace_kvm_emulate_insn_failed(vcpu) trace_kvm_emulate_insn(vcpu, 1)
 762
 763TRACE_EVENT(
 764	vcpu_match_mmio,
 765	TP_PROTO(gva_t gva, gpa_t gpa, bool write, bool gpa_match),
 766	TP_ARGS(gva, gpa, write, gpa_match),
 767
 768	TP_STRUCT__entry(
 769		__field(gva_t, gva)
 770		__field(gpa_t, gpa)
 771		__field(bool, write)
 772		__field(bool, gpa_match)
 773		),
 774
 775	TP_fast_assign(
 776		__entry->gva = gva;
 777		__entry->gpa = gpa;
 778		__entry->write = write;
 779		__entry->gpa_match = gpa_match
 780		),
 781
 782	TP_printk("gva %#lx gpa %#llx %s %s", __entry->gva, __entry->gpa,
 783		  __entry->write ? "Write" : "Read",
 784		  __entry->gpa_match ? "GPA" : "GVA")
 785);
 786
 787TRACE_EVENT(kvm_write_tsc_offset,
 788	TP_PROTO(unsigned int vcpu_id, __u64 previous_tsc_offset,
 789		 __u64 next_tsc_offset),
 790	TP_ARGS(vcpu_id, previous_tsc_offset, next_tsc_offset),
 791
 792	TP_STRUCT__entry(
 793		__field( unsigned int,	vcpu_id				)
 794		__field(	__u64,	previous_tsc_offset		)
 795		__field(	__u64,	next_tsc_offset			)
 796	),
 797
 798	TP_fast_assign(
 799		__entry->vcpu_id		= vcpu_id;
 800		__entry->previous_tsc_offset	= previous_tsc_offset;
 801		__entry->next_tsc_offset	= next_tsc_offset;
 802	),
 803
 804	TP_printk("vcpu=%u prev=%llu next=%llu", __entry->vcpu_id,
 805		  __entry->previous_tsc_offset, __entry->next_tsc_offset)
 806);
 807
 808#ifdef CONFIG_X86_64
 809
 810#define host_clocks					\
 811	{VCLOCK_NONE, "none"},				\
 812	{VCLOCK_TSC,  "tsc"},				\
 813	{VCLOCK_HPET, "hpet"}				\
 814
 815TRACE_EVENT(kvm_update_master_clock,
 816	TP_PROTO(bool use_master_clock, unsigned int host_clock, bool offset_matched),
 817	TP_ARGS(use_master_clock, host_clock, offset_matched),
 818
 819	TP_STRUCT__entry(
 820		__field(		bool,	use_master_clock	)
 821		__field(	unsigned int,	host_clock		)
 822		__field(		bool,	offset_matched		)
 823	),
 824
 825	TP_fast_assign(
 826		__entry->use_master_clock	= use_master_clock;
 827		__entry->host_clock		= host_clock;
 828		__entry->offset_matched		= offset_matched;
 829	),
 830
 831	TP_printk("masterclock %d hostclock %s offsetmatched %u",
 832		  __entry->use_master_clock,
 833		  __print_symbolic(__entry->host_clock, host_clocks),
 834		  __entry->offset_matched)
 835);
 836
 837TRACE_EVENT(kvm_track_tsc,
 838	TP_PROTO(unsigned int vcpu_id, unsigned int nr_matched,
 839		 unsigned int online_vcpus, bool use_master_clock,
 840		 unsigned int host_clock),
 841	TP_ARGS(vcpu_id, nr_matched, online_vcpus, use_master_clock,
 842		host_clock),
 843
 844	TP_STRUCT__entry(
 845		__field(	unsigned int,	vcpu_id			)
 846		__field(	unsigned int,	nr_vcpus_matched_tsc	)
 847		__field(	unsigned int,	online_vcpus		)
 848		__field(	bool,		use_master_clock	)
 849		__field(	unsigned int,	host_clock		)
 850	),
 851
 852	TP_fast_assign(
 853		__entry->vcpu_id		= vcpu_id;
 854		__entry->nr_vcpus_matched_tsc	= nr_matched;
 855		__entry->online_vcpus		= online_vcpus;
 856		__entry->use_master_clock	= use_master_clock;
 857		__entry->host_clock		= host_clock;
 858	),
 859
 860	TP_printk("vcpu_id %u masterclock %u offsetmatched %u nr_online %u"
 861		  " hostclock %s",
 862		  __entry->vcpu_id, __entry->use_master_clock,
 863		  __entry->nr_vcpus_matched_tsc, __entry->online_vcpus,
 864		  __print_symbolic(__entry->host_clock, host_clocks))
 865);
 866
 867#endif /* CONFIG_X86_64 */
 868
 869/*
 870 * Tracepoint for PML full VMEXIT.
 871 */
 872TRACE_EVENT(kvm_pml_full,
 873	TP_PROTO(unsigned int vcpu_id),
 874	TP_ARGS(vcpu_id),
 875
 876	TP_STRUCT__entry(
 877		__field(	unsigned int,	vcpu_id			)
 878	),
 879
 880	TP_fast_assign(
 881		__entry->vcpu_id		= vcpu_id;
 882	),
 883
 884	TP_printk("vcpu %d: PML full", __entry->vcpu_id)
 885);
 886
 887TRACE_EVENT(kvm_ple_window,
 888	TP_PROTO(bool grow, unsigned int vcpu_id, int new, int old),
 889	TP_ARGS(grow, vcpu_id, new, old),
 890
 891	TP_STRUCT__entry(
 892		__field(                bool,      grow         )
 893		__field(        unsigned int,   vcpu_id         )
 894		__field(                 int,       new         )
 895		__field(                 int,       old         )
 896	),
 897
 898	TP_fast_assign(
 899		__entry->grow           = grow;
 900		__entry->vcpu_id        = vcpu_id;
 901		__entry->new            = new;
 902		__entry->old            = old;
 903	),
 904
 905	TP_printk("vcpu %u: ple_window %d (%s %d)",
 906	          __entry->vcpu_id,
 907	          __entry->new,
 908	          __entry->grow ? "grow" : "shrink",
 909	          __entry->old)
 910);
 911
 912#define trace_kvm_ple_window_grow(vcpu_id, new, old) \
 913	trace_kvm_ple_window(true, vcpu_id, new, old)
 914#define trace_kvm_ple_window_shrink(vcpu_id, new, old) \
 915	trace_kvm_ple_window(false, vcpu_id, new, old)
 916
 917TRACE_EVENT(kvm_pvclock_update,
 918	TP_PROTO(unsigned int vcpu_id, struct pvclock_vcpu_time_info *pvclock),
 919	TP_ARGS(vcpu_id, pvclock),
 920
 921	TP_STRUCT__entry(
 922		__field(	unsigned int,	vcpu_id			)
 923		__field(	__u32,		version			)
 924		__field(	__u64,		tsc_timestamp		)
 925		__field(	__u64,		system_time		)
 926		__field(	__u32,		tsc_to_system_mul	)
 927		__field(	__s8,		tsc_shift		)
 928		__field(	__u8,		flags			)
 929	),
 930
 931	TP_fast_assign(
 932		__entry->vcpu_id	   = vcpu_id;
 933		__entry->version	   = pvclock->version;
 934		__entry->tsc_timestamp	   = pvclock->tsc_timestamp;
 935		__entry->system_time	   = pvclock->system_time;
 936		__entry->tsc_to_system_mul = pvclock->tsc_to_system_mul;
 937		__entry->tsc_shift	   = pvclock->tsc_shift;
 938		__entry->flags		   = pvclock->flags;
 939	),
 940
 941	TP_printk("vcpu_id %u, pvclock { version %u, tsc_timestamp 0x%llx, "
 942		  "system_time 0x%llx, tsc_to_system_mul 0x%x, tsc_shift %d, "
 943		  "flags 0x%x }",
 944		  __entry->vcpu_id,
 945		  __entry->version,
 946		  __entry->tsc_timestamp,
 947		  __entry->system_time,
 948		  __entry->tsc_to_system_mul,
 949		  __entry->tsc_shift,
 950		  __entry->flags)
 951);
 952
 953TRACE_EVENT(kvm_wait_lapic_expire,
 954	TP_PROTO(unsigned int vcpu_id, s64 delta),
 955	TP_ARGS(vcpu_id, delta),
 956
 957	TP_STRUCT__entry(
 958		__field(	unsigned int,	vcpu_id		)
 959		__field(	s64,		delta		)
 960	),
 961
 962	TP_fast_assign(
 963		__entry->vcpu_id	   = vcpu_id;
 964		__entry->delta             = delta;
 965	),
 966
 967	TP_printk("vcpu %u: delta %lld (%s)",
 968		  __entry->vcpu_id,
 969		  __entry->delta,
 970		  __entry->delta < 0 ? "early" : "late")
 971);
 972
 973TRACE_EVENT(kvm_enter_smm,
 974	TP_PROTO(unsigned int vcpu_id, u64 smbase, bool entering),
 975	TP_ARGS(vcpu_id, smbase, entering),
 976
 977	TP_STRUCT__entry(
 978		__field(	unsigned int,	vcpu_id		)
 979		__field(	u64,		smbase		)
 980		__field(	bool,		entering	)
 981	),
 982
 983	TP_fast_assign(
 984		__entry->vcpu_id	= vcpu_id;
 985		__entry->smbase		= smbase;
 986		__entry->entering	= entering;
 987	),
 988
 989	TP_printk("vcpu %u: %s SMM, smbase 0x%llx",
 990		  __entry->vcpu_id,
 991		  __entry->entering ? "entering" : "leaving",
 992		  __entry->smbase)
 993);
 994
 995/*
 996 * Tracepoint for VT-d posted-interrupts.
 997 */
 998TRACE_EVENT(kvm_pi_irte_update,
 999	TP_PROTO(unsigned int host_irq, unsigned int vcpu_id,
1000		 unsigned int gsi, unsigned int gvec,
1001		 u64 pi_desc_addr, bool set),
1002	TP_ARGS(host_irq, vcpu_id, gsi, gvec, pi_desc_addr, set),
1003
1004	TP_STRUCT__entry(
1005		__field(	unsigned int,	host_irq	)
1006		__field(	unsigned int,	vcpu_id		)
1007		__field(	unsigned int,	gsi		)
1008		__field(	unsigned int,	gvec		)
1009		__field(	u64,		pi_desc_addr	)
1010		__field(	bool,		set		)
1011	),
1012
1013	TP_fast_assign(
1014		__entry->host_irq	= host_irq;
1015		__entry->vcpu_id	= vcpu_id;
1016		__entry->gsi		= gsi;
1017		__entry->gvec		= gvec;
1018		__entry->pi_desc_addr	= pi_desc_addr;
1019		__entry->set		= set;
1020	),
1021
1022	TP_printk("VT-d PI is %s for irq %u, vcpu %u, gsi: 0x%x, "
1023		  "gvec: 0x%x, pi_desc_addr: 0x%llx",
1024		  __entry->set ? "enabled and being updated" : "disabled",
1025		  __entry->host_irq,
1026		  __entry->vcpu_id,
1027		  __entry->gsi,
1028		  __entry->gvec,
1029		  __entry->pi_desc_addr)
1030);
1031
1032/*
1033 * Tracepoint for kvm_hv_notify_acked_sint.
1034 */
1035TRACE_EVENT(kvm_hv_notify_acked_sint,
1036	TP_PROTO(int vcpu_id, u32 sint),
1037	TP_ARGS(vcpu_id, sint),
1038
1039	TP_STRUCT__entry(
1040		__field(int, vcpu_id)
1041		__field(u32, sint)
1042	),
1043
1044	TP_fast_assign(
1045		__entry->vcpu_id = vcpu_id;
1046		__entry->sint = sint;
1047	),
1048
1049	TP_printk("vcpu_id %d sint %u", __entry->vcpu_id, __entry->sint)
1050);
1051
1052/*
1053 * Tracepoint for synic_set_irq.
1054 */
1055TRACE_EVENT(kvm_hv_synic_set_irq,
1056	TP_PROTO(int vcpu_id, u32 sint, int vector, int ret),
1057	TP_ARGS(vcpu_id, sint, vector, ret),
1058
1059	TP_STRUCT__entry(
1060		__field(int, vcpu_id)
1061		__field(u32, sint)
1062		__field(int, vector)
1063		__field(int, ret)
1064	),
1065
1066	TP_fast_assign(
1067		__entry->vcpu_id = vcpu_id;
1068		__entry->sint = sint;
1069		__entry->vector = vector;
1070		__entry->ret = ret;
1071	),
1072
1073	TP_printk("vcpu_id %d sint %u vector %d ret %d",
1074		  __entry->vcpu_id, __entry->sint, __entry->vector,
1075		  __entry->ret)
1076);
1077
1078/*
1079 * Tracepoint for kvm_hv_synic_send_eoi.
1080 */
1081TRACE_EVENT(kvm_hv_synic_send_eoi,
1082	TP_PROTO(int vcpu_id, int vector),
1083	TP_ARGS(vcpu_id, vector),
1084
1085	TP_STRUCT__entry(
1086		__field(int, vcpu_id)
1087		__field(u32, sint)
1088		__field(int, vector)
1089		__field(int, ret)
1090	),
1091
1092	TP_fast_assign(
1093		__entry->vcpu_id = vcpu_id;
1094		__entry->vector	= vector;
1095	),
1096
1097	TP_printk("vcpu_id %d vector %d", __entry->vcpu_id, __entry->vector)
1098);
1099
1100/*
1101 * Tracepoint for synic_set_msr.
1102 */
1103TRACE_EVENT(kvm_hv_synic_set_msr,
1104	TP_PROTO(int vcpu_id, u32 msr, u64 data, bool host),
1105	TP_ARGS(vcpu_id, msr, data, host),
1106
1107	TP_STRUCT__entry(
1108		__field(int, vcpu_id)
1109		__field(u32, msr)
1110		__field(u64, data)
1111		__field(bool, host)
1112	),
1113
1114	TP_fast_assign(
1115		__entry->vcpu_id = vcpu_id;
1116		__entry->msr = msr;
1117		__entry->data = data;
1118		__entry->host = host
1119	),
1120
1121	TP_printk("vcpu_id %d msr 0x%x data 0x%llx host %d",
1122		  __entry->vcpu_id, __entry->msr, __entry->data, __entry->host)
1123);
1124
1125/*
1126 * Tracepoint for stimer_set_config.
1127 */
1128TRACE_EVENT(kvm_hv_stimer_set_config,
1129	TP_PROTO(int vcpu_id, int timer_index, u64 config, bool host),
1130	TP_ARGS(vcpu_id, timer_index, config, host),
1131
1132	TP_STRUCT__entry(
1133		__field(int, vcpu_id)
1134		__field(int, timer_index)
1135		__field(u64, config)
1136		__field(bool, host)
1137	),
1138
1139	TP_fast_assign(
1140		__entry->vcpu_id = vcpu_id;
1141		__entry->timer_index = timer_index;
1142		__entry->config = config;
1143		__entry->host = host;
1144	),
1145
1146	TP_printk("vcpu_id %d timer %d config 0x%llx host %d",
1147		  __entry->vcpu_id, __entry->timer_index, __entry->config,
1148		  __entry->host)
1149);
1150
1151/*
1152 * Tracepoint for stimer_set_count.
1153 */
1154TRACE_EVENT(kvm_hv_stimer_set_count,
1155	TP_PROTO(int vcpu_id, int timer_index, u64 count, bool host),
1156	TP_ARGS(vcpu_id, timer_index, count, host),
1157
1158	TP_STRUCT__entry(
1159		__field(int, vcpu_id)
1160		__field(int, timer_index)
1161		__field(u64, count)
1162		__field(bool, host)
1163	),
1164
1165	TP_fast_assign(
1166		__entry->vcpu_id = vcpu_id;
1167		__entry->timer_index = timer_index;
1168		__entry->count = count;
1169		__entry->host = host;
1170	),
1171
1172	TP_printk("vcpu_id %d timer %d count %llu host %d",
1173		  __entry->vcpu_id, __entry->timer_index, __entry->count,
1174		  __entry->host)
1175);
1176
1177/*
1178 * Tracepoint for stimer_start(periodic timer case).
1179 */
1180TRACE_EVENT(kvm_hv_stimer_start_periodic,
1181	TP_PROTO(int vcpu_id, int timer_index, u64 time_now, u64 exp_time),
1182	TP_ARGS(vcpu_id, timer_index, time_now, exp_time),
1183
1184	TP_STRUCT__entry(
1185		__field(int, vcpu_id)
1186		__field(int, timer_index)
1187		__field(u64, time_now)
1188		__field(u64, exp_time)
1189	),
1190
1191	TP_fast_assign(
1192		__entry->vcpu_id = vcpu_id;
1193		__entry->timer_index = timer_index;
1194		__entry->time_now = time_now;
1195		__entry->exp_time = exp_time;
1196	),
1197
1198	TP_printk("vcpu_id %d timer %d time_now %llu exp_time %llu",
1199		  __entry->vcpu_id, __entry->timer_index, __entry->time_now,
1200		  __entry->exp_time)
1201);
1202
1203/*
1204 * Tracepoint for stimer_start(one-shot timer case).
1205 */
1206TRACE_EVENT(kvm_hv_stimer_start_one_shot,
1207	TP_PROTO(int vcpu_id, int timer_index, u64 time_now, u64 count),
1208	TP_ARGS(vcpu_id, timer_index, time_now, count),
1209
1210	TP_STRUCT__entry(
1211		__field(int, vcpu_id)
1212		__field(int, timer_index)
1213		__field(u64, time_now)
1214		__field(u64, count)
1215	),
1216
1217	TP_fast_assign(
1218		__entry->vcpu_id = vcpu_id;
1219		__entry->timer_index = timer_index;
1220		__entry->time_now = time_now;
1221		__entry->count = count;
1222	),
1223
1224	TP_printk("vcpu_id %d timer %d time_now %llu count %llu",
1225		  __entry->vcpu_id, __entry->timer_index, __entry->time_now,
1226		  __entry->count)
1227);
1228
1229/*
1230 * Tracepoint for stimer_timer_callback.
1231 */
1232TRACE_EVENT(kvm_hv_stimer_callback,
1233	TP_PROTO(int vcpu_id, int timer_index),
1234	TP_ARGS(vcpu_id, timer_index),
1235
1236	TP_STRUCT__entry(
1237		__field(int, vcpu_id)
1238		__field(int, timer_index)
1239	),
1240
1241	TP_fast_assign(
1242		__entry->vcpu_id = vcpu_id;
1243		__entry->timer_index = timer_index;
1244	),
1245
1246	TP_printk("vcpu_id %d timer %d",
1247		  __entry->vcpu_id, __entry->timer_index)
1248);
1249
1250/*
1251 * Tracepoint for stimer_expiration.
1252 */
1253TRACE_EVENT(kvm_hv_stimer_expiration,
1254	TP_PROTO(int vcpu_id, int timer_index, int msg_send_result),
1255	TP_ARGS(vcpu_id, timer_index, msg_send_result),
1256
1257	TP_STRUCT__entry(
1258		__field(int, vcpu_id)
1259		__field(int, timer_index)
1260		__field(int, msg_send_result)
1261	),
1262
1263	TP_fast_assign(
1264		__entry->vcpu_id = vcpu_id;
1265		__entry->timer_index = timer_index;
1266		__entry->msg_send_result = msg_send_result;
1267	),
1268
1269	TP_printk("vcpu_id %d timer %d msg send result %d",
1270		  __entry->vcpu_id, __entry->timer_index,
1271		  __entry->msg_send_result)
1272);
1273
1274/*
1275 * Tracepoint for stimer_cleanup.
1276 */
1277TRACE_EVENT(kvm_hv_stimer_cleanup,
1278	TP_PROTO(int vcpu_id, int timer_index),
1279	TP_ARGS(vcpu_id, timer_index),
1280
1281	TP_STRUCT__entry(
1282		__field(int, vcpu_id)
1283		__field(int, timer_index)
1284	),
1285
1286	TP_fast_assign(
1287		__entry->vcpu_id = vcpu_id;
1288		__entry->timer_index = timer_index;
1289	),
1290
1291	TP_printk("vcpu_id %d timer %d",
1292		  __entry->vcpu_id, __entry->timer_index)
1293);
1294
1295#endif /* _TRACE_KVM_H */
1296
1297#undef TRACE_INCLUDE_PATH
1298#define TRACE_INCLUDE_PATH arch/x86/kvm
1299#undef TRACE_INCLUDE_FILE
1300#define TRACE_INCLUDE_FILE trace
1301
1302/* This part must be outside protection */
1303#include <trace/define_trace.h>