Linux Audio

Check our new training course

Loading...
v6.2
   1/* SPDX-License-Identifier: GPL-2.0 */
   2#if !defined(_TRACE_KVM_H) || defined(TRACE_HEADER_MULTI_READ)
   3#define _TRACE_KVM_H
   4
   5#include <linux/tracepoint.h>
   6#include <asm/vmx.h>
   7#include <asm/svm.h>
   8#include <asm/clocksource.h>
   9#include <asm/pvclock-abi.h>
  10
  11#undef TRACE_SYSTEM
  12#define TRACE_SYSTEM kvm
  13
  14/*
  15 * Tracepoint for guest mode entry.
  16 */
  17TRACE_EVENT(kvm_entry,
  18	TP_PROTO(struct kvm_vcpu *vcpu),
  19	TP_ARGS(vcpu),
  20
  21	TP_STRUCT__entry(
  22		__field(	unsigned int,	vcpu_id		)
  23		__field(	unsigned long,	rip		)
  24	),
  25
  26	TP_fast_assign(
  27		__entry->vcpu_id        = vcpu->vcpu_id;
  28		__entry->rip		= kvm_rip_read(vcpu);
  29	),
  30
  31	TP_printk("vcpu %u, rip 0x%lx", __entry->vcpu_id, __entry->rip)
  32);
  33
  34/*
  35 * Tracepoint for hypercall.
  36 */
  37TRACE_EVENT(kvm_hypercall,
  38	TP_PROTO(unsigned long nr, unsigned long a0, unsigned long a1,
  39		 unsigned long a2, unsigned long a3),
  40	TP_ARGS(nr, a0, a1, a2, a3),
  41
  42	TP_STRUCT__entry(
  43		__field(	unsigned long, 	nr		)
  44		__field(	unsigned long,	a0		)
  45		__field(	unsigned long,	a1		)
  46		__field(	unsigned long,	a2		)
  47		__field(	unsigned long,	a3		)
  48	),
  49
  50	TP_fast_assign(
  51		__entry->nr		= nr;
  52		__entry->a0		= a0;
  53		__entry->a1		= a1;
  54		__entry->a2		= a2;
  55		__entry->a3		= a3;
  56	),
  57
  58	TP_printk("nr 0x%lx a0 0x%lx a1 0x%lx a2 0x%lx a3 0x%lx",
  59		 __entry->nr, __entry->a0, __entry->a1,  __entry->a2,
  60		 __entry->a3)
  61);
  62
  63/*
  64 * Tracepoint for hypercall.
  65 */
  66TRACE_EVENT(kvm_hv_hypercall,
  67	TP_PROTO(__u16 code, bool fast,  __u16 var_cnt, __u16 rep_cnt,
  68		 __u16 rep_idx, __u64 ingpa, __u64 outgpa),
  69	TP_ARGS(code, fast, var_cnt, rep_cnt, rep_idx, ingpa, outgpa),
  70
  71	TP_STRUCT__entry(
  72		__field(	__u16,		rep_cnt		)
  73		__field(	__u16,		rep_idx		)
  74		__field(	__u64,		ingpa		)
  75		__field(	__u64,		outgpa		)
  76		__field(	__u16, 		code		)
  77		__field(	__u16,		var_cnt		)
  78		__field(	bool,		fast		)
  79	),
  80
  81	TP_fast_assign(
  82		__entry->rep_cnt	= rep_cnt;
  83		__entry->rep_idx	= rep_idx;
  84		__entry->ingpa		= ingpa;
  85		__entry->outgpa		= outgpa;
  86		__entry->code		= code;
  87		__entry->var_cnt	= var_cnt;
  88		__entry->fast		= fast;
  89	),
  90
  91	TP_printk("code 0x%x %s var_cnt 0x%x rep_cnt 0x%x idx 0x%x in 0x%llx out 0x%llx",
  92		  __entry->code, __entry->fast ? "fast" : "slow",
  93		  __entry->var_cnt, __entry->rep_cnt, __entry->rep_idx,
  94		  __entry->ingpa, __entry->outgpa)
  95);
  96
  97TRACE_EVENT(kvm_hv_hypercall_done,
  98	TP_PROTO(u64 result),
  99	TP_ARGS(result),
 100
 101	TP_STRUCT__entry(
 102		__field(__u64, result)
 103	),
 104
 105	TP_fast_assign(
 106		__entry->result	= result;
 107	),
 108
 109	TP_printk("result 0x%llx", __entry->result)
 110);
 111
 112/*
 113 * Tracepoint for Xen hypercall.
 114 */
 115TRACE_EVENT(kvm_xen_hypercall,
 116	    TP_PROTO(u8 cpl, unsigned long nr,
 117		     unsigned long a0, unsigned long a1, unsigned long a2,
 118		     unsigned long a3, unsigned long a4, unsigned long a5),
 119	    TP_ARGS(cpl, nr, a0, a1, a2, a3, a4, a5),
 120
 121	TP_STRUCT__entry(
 122		__field(u8, cpl)
 123		__field(unsigned long, nr)
 124		__field(unsigned long, a0)
 125		__field(unsigned long, a1)
 126		__field(unsigned long, a2)
 127		__field(unsigned long, a3)
 128		__field(unsigned long, a4)
 129		__field(unsigned long, a5)
 130	),
 131
 132	TP_fast_assign(
 133		__entry->cpl = cpl;
 134		__entry->nr = nr;
 135		__entry->a0 = a0;
 136		__entry->a1 = a1;
 137		__entry->a2 = a2;
 138		__entry->a3 = a3;
 139		__entry->a4 = a4;
 140		__entry->a4 = a5;
 141	),
 142
 143	TP_printk("cpl %d nr 0x%lx a0 0x%lx a1 0x%lx a2 0x%lx a3 0x%lx a4 0x%lx a5 %lx",
 144		  __entry->cpl, __entry->nr,
 145		  __entry->a0, __entry->a1, __entry->a2,
 146		  __entry->a3, __entry->a4, __entry->a5)
 147);
 148
 149
 150
 151/*
 152 * Tracepoint for PIO.
 153 */
 154
 155#define KVM_PIO_IN   0
 156#define KVM_PIO_OUT  1
 157
 158TRACE_EVENT(kvm_pio,
 159	TP_PROTO(unsigned int rw, unsigned int port, unsigned int size,
 160		 unsigned int count, const void *data),
 161	TP_ARGS(rw, port, size, count, data),
 162
 163	TP_STRUCT__entry(
 164		__field(	unsigned int, 	rw		)
 165		__field(	unsigned int, 	port		)
 166		__field(	unsigned int, 	size		)
 167		__field(	unsigned int,	count		)
 168		__field(	unsigned int,	val		)
 169	),
 170
 171	TP_fast_assign(
 172		__entry->rw		= rw;
 173		__entry->port		= port;
 174		__entry->size		= size;
 175		__entry->count		= count;
 176		if (size == 1)
 177			__entry->val	= *(unsigned char *)data;
 178		else if (size == 2)
 179			__entry->val	= *(unsigned short *)data;
 180		else
 181			__entry->val	= *(unsigned int *)data;
 182	),
 183
 184	TP_printk("pio_%s at 0x%x size %d count %d val 0x%x %s",
 185		  __entry->rw ? "write" : "read",
 186		  __entry->port, __entry->size, __entry->count, __entry->val,
 187		  __entry->count > 1 ? "(...)" : "")
 188);
 189
 190/*
 191 * Tracepoint for fast mmio.
 192 */
 193TRACE_EVENT(kvm_fast_mmio,
 194	TP_PROTO(u64 gpa),
 195	TP_ARGS(gpa),
 196
 197	TP_STRUCT__entry(
 198		__field(u64,	gpa)
 199	),
 200
 201	TP_fast_assign(
 202		__entry->gpa		= gpa;
 203	),
 204
 205	TP_printk("fast mmio at gpa 0x%llx", __entry->gpa)
 206);
 207
 208/*
 209 * Tracepoint for cpuid.
 210 */
 211TRACE_EVENT(kvm_cpuid,
 212	TP_PROTO(unsigned int function, unsigned int index, unsigned long rax,
 213		 unsigned long rbx, unsigned long rcx, unsigned long rdx,
 214		 bool found, bool used_max_basic),
 215	TP_ARGS(function, index, rax, rbx, rcx, rdx, found, used_max_basic),
 216
 217	TP_STRUCT__entry(
 218		__field(	unsigned int,	function	)
 219		__field(	unsigned int,	index		)
 220		__field(	unsigned long,	rax		)
 221		__field(	unsigned long,	rbx		)
 222		__field(	unsigned long,	rcx		)
 223		__field(	unsigned long,	rdx		)
 224		__field(	bool,		found		)
 225		__field(	bool,		used_max_basic	)
 226	),
 227
 228	TP_fast_assign(
 229		__entry->function	= function;
 230		__entry->index		= index;
 231		__entry->rax		= rax;
 232		__entry->rbx		= rbx;
 233		__entry->rcx		= rcx;
 234		__entry->rdx		= rdx;
 235		__entry->found		= found;
 236		__entry->used_max_basic	= used_max_basic;
 237	),
 238
 239	TP_printk("func %x idx %x rax %lx rbx %lx rcx %lx rdx %lx, cpuid entry %s%s",
 240		  __entry->function, __entry->index, __entry->rax,
 241		  __entry->rbx, __entry->rcx, __entry->rdx,
 242		  __entry->found ? "found" : "not found",
 243		  __entry->used_max_basic ? ", used max basic" : "")
 244);
 245
 246#define AREG(x) { APIC_##x, "APIC_" #x }
 247
 248#define kvm_trace_symbol_apic						    \
 249	AREG(ID), AREG(LVR), AREG(TASKPRI), AREG(ARBPRI), AREG(PROCPRI),    \
 250	AREG(EOI), AREG(RRR), AREG(LDR), AREG(DFR), AREG(SPIV), AREG(ISR),  \
 251	AREG(TMR), AREG(IRR), AREG(ESR), AREG(ICR), AREG(ICR2), AREG(LVTT), \
 252	AREG(LVTTHMR), AREG(LVTPC), AREG(LVT0), AREG(LVT1), AREG(LVTERR),   \
 253	AREG(TMICT), AREG(TMCCT), AREG(TDCR), AREG(SELF_IPI), AREG(EFEAT),  \
 254	AREG(ECTRL)
 255/*
 256 * Tracepoint for apic access.
 257 */
 258TRACE_EVENT(kvm_apic,
 259	TP_PROTO(unsigned int rw, unsigned int reg, u64 val),
 260	TP_ARGS(rw, reg, val),
 261
 262	TP_STRUCT__entry(
 263		__field(	unsigned int,	rw		)
 264		__field(	unsigned int,	reg		)
 265		__field(	u64,		val		)
 266	),
 267
 268	TP_fast_assign(
 269		__entry->rw		= rw;
 270		__entry->reg		= reg;
 271		__entry->val		= val;
 272	),
 273
 274	TP_printk("apic_%s %s = 0x%llx",
 275		  __entry->rw ? "write" : "read",
 276		  __print_symbolic(__entry->reg, kvm_trace_symbol_apic),
 277		  __entry->val)
 278);
 279
 280#define trace_kvm_apic_read(reg, val)		trace_kvm_apic(0, reg, val)
 281#define trace_kvm_apic_write(reg, val)		trace_kvm_apic(1, reg, val)
 282
 283#define KVM_ISA_VMX   1
 284#define KVM_ISA_SVM   2
 285
 286#define kvm_print_exit_reason(exit_reason, isa)				\
 287	(isa == KVM_ISA_VMX) ?						\
 288	__print_symbolic(exit_reason & 0xffff, VMX_EXIT_REASONS) :	\
 289	__print_symbolic(exit_reason, SVM_EXIT_REASONS),		\
 290	(isa == KVM_ISA_VMX && exit_reason & ~0xffff) ? " " : "",	\
 291	(isa == KVM_ISA_VMX) ?						\
 292	__print_flags(exit_reason & ~0xffff, " ", VMX_EXIT_REASON_FLAGS) : ""
 293
 294#define TRACE_EVENT_KVM_EXIT(name)					     \
 295TRACE_EVENT(name,							     \
 296	TP_PROTO(struct kvm_vcpu *vcpu, u32 isa),			     \
 297	TP_ARGS(vcpu, isa),						     \
 298									     \
 299	TP_STRUCT__entry(						     \
 300		__field(	unsigned int,	exit_reason	)	     \
 301		__field(	unsigned long,	guest_rip	)	     \
 302		__field(	u32,	        isa             )	     \
 303		__field(	u64,	        info1           )	     \
 304		__field(	u64,	        info2           )	     \
 305		__field(	u32,	        intr_info	)	     \
 306		__field(	u32,	        error_code	)	     \
 307		__field(	unsigned int,	vcpu_id         )	     \
 308	),								     \
 309									     \
 310	TP_fast_assign(							     \
 311		__entry->guest_rip	= kvm_rip_read(vcpu);		     \
 312		__entry->isa            = isa;				     \
 313		__entry->vcpu_id        = vcpu->vcpu_id;		     \
 314		static_call(kvm_x86_get_exit_info)(vcpu,		     \
 315					  &__entry->exit_reason,	     \
 316					  &__entry->info1,		     \
 317					  &__entry->info2,		     \
 318					  &__entry->intr_info,		     \
 319					  &__entry->error_code);	     \
 320	),								     \
 321									     \
 322	TP_printk("vcpu %u reason %s%s%s rip 0x%lx info1 0x%016llx "	     \
 323		  "info2 0x%016llx intr_info 0x%08x error_code 0x%08x",	     \
 324		  __entry->vcpu_id,					     \
 325		  kvm_print_exit_reason(__entry->exit_reason, __entry->isa), \
 326		  __entry->guest_rip, __entry->info1, __entry->info2,	     \
 327		  __entry->intr_info, __entry->error_code)		     \
 328)
 329
 330/*
 331 * Tracepoint for kvm guest exit:
 332 */
 333TRACE_EVENT_KVM_EXIT(kvm_exit);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 334
 335/*
 336 * Tracepoint for kvm interrupt injection:
 337 */
 338TRACE_EVENT(kvm_inj_virq,
 339	TP_PROTO(unsigned int vector, bool soft, bool reinjected),
 340	TP_ARGS(vector, soft, reinjected),
 341
 342	TP_STRUCT__entry(
 343		__field(	unsigned int,	vector		)
 344		__field(	bool,		soft		)
 345		__field(	bool,		reinjected	)
 346	),
 347
 348	TP_fast_assign(
 349		__entry->vector		= vector;
 350		__entry->soft		= soft;
 351		__entry->reinjected	= reinjected;
 352	),
 353
 354	TP_printk("%s 0x%x%s",
 355		  __entry->soft ? "Soft/INTn" : "IRQ", __entry->vector,
 356		  __entry->reinjected ? " [reinjected]" : "")
 357);
 358
 359#define EXS(x) { x##_VECTOR, "#" #x }
 360
 361#define kvm_trace_sym_exc						\
 362	EXS(DE), EXS(DB), EXS(BP), EXS(OF), EXS(BR), EXS(UD), EXS(NM),	\
 363	EXS(DF), EXS(TS), EXS(NP), EXS(SS), EXS(GP), EXS(PF),		\
 364	EXS(MF), EXS(AC), EXS(MC)
 365
 366/*
 367 * Tracepoint for kvm interrupt injection:
 368 */
 369TRACE_EVENT(kvm_inj_exception,
 370	TP_PROTO(unsigned exception, bool has_error, unsigned error_code,
 371		 bool reinjected),
 372	TP_ARGS(exception, has_error, error_code, reinjected),
 373
 374	TP_STRUCT__entry(
 375		__field(	u8,	exception	)
 376		__field(	u8,	has_error	)
 377		__field(	u32,	error_code	)
 378		__field(	bool,	reinjected	)
 379	),
 380
 381	TP_fast_assign(
 382		__entry->exception	= exception;
 383		__entry->has_error	= has_error;
 384		__entry->error_code	= error_code;
 385		__entry->reinjected	= reinjected;
 386	),
 387
 388	TP_printk("%s%s%s%s%s",
 389		  __print_symbolic(__entry->exception, kvm_trace_sym_exc),
 390		  !__entry->has_error ? "" : " (",
 391		  !__entry->has_error ? "" : __print_symbolic(__entry->error_code, { }),
 392		  !__entry->has_error ? "" : ")",
 393		  __entry->reinjected ? " [reinjected]" : "")
 394);
 395
 396/*
 397 * Tracepoint for page fault.
 398 */
 399TRACE_EVENT(kvm_page_fault,
 400	TP_PROTO(struct kvm_vcpu *vcpu, u64 fault_address, u64 error_code),
 401	TP_ARGS(vcpu, fault_address, error_code),
 402
 403	TP_STRUCT__entry(
 404		__field(	unsigned int,	vcpu_id		)
 405		__field(	unsigned long,	guest_rip	)
 406		__field(	u64,		fault_address	)
 407		__field(	u64,		error_code	)
 408	),
 409
 410	TP_fast_assign(
 411		__entry->vcpu_id	= vcpu->vcpu_id;
 412		__entry->guest_rip	= kvm_rip_read(vcpu);
 413		__entry->fault_address	= fault_address;
 414		__entry->error_code	= error_code;
 415	),
 416
 417	TP_printk("vcpu %u rip 0x%lx address 0x%016llx error_code 0x%llx",
 418		  __entry->vcpu_id, __entry->guest_rip,
 419		  __entry->fault_address, __entry->error_code)
 420);
 421
 422/*
 423 * Tracepoint for guest MSR access.
 424 */
 425TRACE_EVENT(kvm_msr,
 426	TP_PROTO(unsigned write, u32 ecx, u64 data, bool exception),
 427	TP_ARGS(write, ecx, data, exception),
 428
 429	TP_STRUCT__entry(
 430		__field(	unsigned,	write		)
 431		__field(	u32,		ecx		)
 432		__field(	u64,		data		)
 433		__field(	u8,		exception	)
 434	),
 435
 436	TP_fast_assign(
 437		__entry->write		= write;
 438		__entry->ecx		= ecx;
 439		__entry->data		= data;
 440		__entry->exception	= exception;
 441	),
 442
 443	TP_printk("msr_%s %x = 0x%llx%s",
 444		  __entry->write ? "write" : "read",
 445		  __entry->ecx, __entry->data,
 446		  __entry->exception ? " (#GP)" : "")
 447);
 448
 449#define trace_kvm_msr_read(ecx, data)      trace_kvm_msr(0, ecx, data, false)
 450#define trace_kvm_msr_write(ecx, data)     trace_kvm_msr(1, ecx, data, false)
 451#define trace_kvm_msr_read_ex(ecx)         trace_kvm_msr(0, ecx, 0, true)
 452#define trace_kvm_msr_write_ex(ecx, data)  trace_kvm_msr(1, ecx, data, true)
 453
 454/*
 455 * Tracepoint for guest CR access.
 456 */
 457TRACE_EVENT(kvm_cr,
 458	TP_PROTO(unsigned int rw, unsigned int cr, unsigned long val),
 459	TP_ARGS(rw, cr, val),
 460
 461	TP_STRUCT__entry(
 462		__field(	unsigned int,	rw		)
 463		__field(	unsigned int,	cr		)
 464		__field(	unsigned long,	val		)
 465	),
 466
 467	TP_fast_assign(
 468		__entry->rw		= rw;
 469		__entry->cr		= cr;
 470		__entry->val		= val;
 471	),
 472
 473	TP_printk("cr_%s %x = 0x%lx",
 474		  __entry->rw ? "write" : "read",
 475		  __entry->cr, __entry->val)
 476);
 477
 478#define trace_kvm_cr_read(cr, val)		trace_kvm_cr(0, cr, val)
 479#define trace_kvm_cr_write(cr, val)		trace_kvm_cr(1, cr, val)
 480
 481TRACE_EVENT(kvm_pic_set_irq,
 482	    TP_PROTO(__u8 chip, __u8 pin, __u8 elcr, __u8 imr, bool coalesced),
 483	    TP_ARGS(chip, pin, elcr, imr, coalesced),
 484
 485	TP_STRUCT__entry(
 486		__field(	__u8,		chip		)
 487		__field(	__u8,		pin		)
 488		__field(	__u8,		elcr		)
 489		__field(	__u8,		imr		)
 490		__field(	bool,		coalesced	)
 491	),
 492
 493	TP_fast_assign(
 494		__entry->chip		= chip;
 495		__entry->pin		= pin;
 496		__entry->elcr		= elcr;
 497		__entry->imr		= imr;
 498		__entry->coalesced	= coalesced;
 499	),
 500
 501	TP_printk("chip %u pin %u (%s%s)%s",
 502		  __entry->chip, __entry->pin,
 503		  (__entry->elcr & (1 << __entry->pin)) ? "level":"edge",
 504		  (__entry->imr & (1 << __entry->pin)) ? "|masked":"",
 505		  __entry->coalesced ? " (coalesced)" : "")
 506);
 507
 508#define kvm_apic_dst_shorthand		\
 509	{0x0, "dst"},			\
 510	{0x1, "self"},			\
 511	{0x2, "all"},			\
 512	{0x3, "all-but-self"}
 513
 514TRACE_EVENT(kvm_apic_ipi,
 515	    TP_PROTO(__u32 icr_low, __u32 dest_id),
 516	    TP_ARGS(icr_low, dest_id),
 517
 518	TP_STRUCT__entry(
 519		__field(	__u32,		icr_low		)
 520		__field(	__u32,		dest_id		)
 521	),
 522
 523	TP_fast_assign(
 524		__entry->icr_low	= icr_low;
 525		__entry->dest_id	= dest_id;
 526	),
 527
 528	TP_printk("dst %x vec %u (%s|%s|%s|%s|%s)",
 529		  __entry->dest_id, (u8)__entry->icr_low,
 530		  __print_symbolic((__entry->icr_low >> 8 & 0x7),
 531				   kvm_deliver_mode),
 532		  (__entry->icr_low & (1<<11)) ? "logical" : "physical",
 533		  (__entry->icr_low & (1<<14)) ? "assert" : "de-assert",
 534		  (__entry->icr_low & (1<<15)) ? "level" : "edge",
 535		  __print_symbolic((__entry->icr_low >> 18 & 0x3),
 536				   kvm_apic_dst_shorthand))
 537);
 538
 539TRACE_EVENT(kvm_apic_accept_irq,
 540	    TP_PROTO(__u32 apicid, __u16 dm, __u16 tm, __u8 vec),
 541	    TP_ARGS(apicid, dm, tm, vec),
 542
 543	TP_STRUCT__entry(
 544		__field(	__u32,		apicid		)
 545		__field(	__u16,		dm		)
 546		__field(	__u16,		tm		)
 547		__field(	__u8,		vec		)
 548	),
 549
 550	TP_fast_assign(
 551		__entry->apicid		= apicid;
 552		__entry->dm		= dm;
 553		__entry->tm		= tm;
 554		__entry->vec		= vec;
 555	),
 556
 557	TP_printk("apicid %x vec %u (%s|%s)",
 558		  __entry->apicid, __entry->vec,
 559		  __print_symbolic((__entry->dm >> 8 & 0x7), kvm_deliver_mode),
 560		  __entry->tm ? "level" : "edge")
 561);
 562
 563TRACE_EVENT(kvm_eoi,
 564	    TP_PROTO(struct kvm_lapic *apic, int vector),
 565	    TP_ARGS(apic, vector),
 566
 567	TP_STRUCT__entry(
 568		__field(	__u32,		apicid		)
 569		__field(	int,		vector		)
 570	),
 571
 572	TP_fast_assign(
 573		__entry->apicid		= apic->vcpu->vcpu_id;
 574		__entry->vector		= vector;
 575	),
 576
 577	TP_printk("apicid %x vector %d", __entry->apicid, __entry->vector)
 578);
 579
 580TRACE_EVENT(kvm_pv_eoi,
 581	    TP_PROTO(struct kvm_lapic *apic, int vector),
 582	    TP_ARGS(apic, vector),
 583
 584	TP_STRUCT__entry(
 585		__field(	__u32,		apicid		)
 586		__field(	int,		vector		)
 587	),
 588
 589	TP_fast_assign(
 590		__entry->apicid		= apic->vcpu->vcpu_id;
 591		__entry->vector		= vector;
 592	),
 593
 594	TP_printk("apicid %x vector %d", __entry->apicid, __entry->vector)
 595);
 596
 597/*
 598 * Tracepoint for nested VMRUN
 599 */
 600TRACE_EVENT(kvm_nested_vmenter,
 601	    TP_PROTO(__u64 rip, __u64 vmcb, __u64 nested_rip, __u32 int_ctl,
 602		     __u32 event_inj, bool tdp_enabled, __u64 guest_tdp_pgd,
 603		     __u64 guest_cr3, __u32 isa),
 604	    TP_ARGS(rip, vmcb, nested_rip, int_ctl, event_inj, tdp_enabled,
 605		    guest_tdp_pgd, guest_cr3, isa),
 606
 607	TP_STRUCT__entry(
 608		__field(	__u64,		rip		)
 609		__field(	__u64,		vmcb		)
 610		__field(	__u64,		nested_rip	)
 611		__field(	__u32,		int_ctl		)
 612		__field(	__u32,		event_inj	)
 613		__field(	bool,		tdp_enabled	)
 614		__field(	__u64,		guest_pgd	)
 615		__field(	__u32,		isa		)
 616	),
 617
 618	TP_fast_assign(
 619		__entry->rip		= rip;
 620		__entry->vmcb		= vmcb;
 621		__entry->nested_rip	= nested_rip;
 622		__entry->int_ctl	= int_ctl;
 623		__entry->event_inj	= event_inj;
 624		__entry->tdp_enabled	= tdp_enabled;
 625		__entry->guest_pgd	= tdp_enabled ? guest_tdp_pgd : guest_cr3;
 626		__entry->isa		= isa;
 627	),
 628
 629	TP_printk("rip: 0x%016llx %s: 0x%016llx nested_rip: 0x%016llx "
 630		  "int_ctl: 0x%08x event_inj: 0x%08x nested_%s=%s %s: 0x%016llx",
 631		  __entry->rip,
 632		  __entry->isa == KVM_ISA_VMX ? "vmcs" : "vmcb",
 633		  __entry->vmcb,
 634		  __entry->nested_rip,
 635		  __entry->int_ctl,
 636		  __entry->event_inj,
 637		  __entry->isa == KVM_ISA_VMX ? "ept" : "npt",
 638		  __entry->tdp_enabled ? "y" : "n",
 639		  !__entry->tdp_enabled ? "guest_cr3" :
 640		  __entry->isa == KVM_ISA_VMX ? "nested_eptp" : "nested_cr3",
 641		  __entry->guest_pgd)
 642);
 643
 644TRACE_EVENT(kvm_nested_intercepts,
 645	    TP_PROTO(__u16 cr_read, __u16 cr_write, __u32 exceptions,
 646		     __u32 intercept1, __u32 intercept2, __u32 intercept3),
 647	    TP_ARGS(cr_read, cr_write, exceptions, intercept1,
 648		    intercept2, intercept3),
 649
 650	TP_STRUCT__entry(
 651		__field(	__u16,		cr_read		)
 652		__field(	__u16,		cr_write	)
 653		__field(	__u32,		exceptions	)
 654		__field(	__u32,		intercept1	)
 655		__field(	__u32,		intercept2	)
 656		__field(	__u32,		intercept3	)
 657	),
 658
 659	TP_fast_assign(
 660		__entry->cr_read	= cr_read;
 661		__entry->cr_write	= cr_write;
 662		__entry->exceptions	= exceptions;
 663		__entry->intercept1	= intercept1;
 664		__entry->intercept2	= intercept2;
 665		__entry->intercept3	= intercept3;
 666	),
 667
 668	TP_printk("cr_read: %04x cr_write: %04x excp: %08x "
 669		  "intercepts: %08x %08x %08x",
 670		  __entry->cr_read, __entry->cr_write, __entry->exceptions,
 671		  __entry->intercept1, __entry->intercept2, __entry->intercept3)
 672);
 673/*
 674 * Tracepoint for #VMEXIT while nested
 675 */
 676TRACE_EVENT_KVM_EXIT(kvm_nested_vmexit);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 677
 678/*
 679 * Tracepoint for #VMEXIT reinjected to the guest
 680 */
 681TRACE_EVENT(kvm_nested_vmexit_inject,
 682	    TP_PROTO(__u32 exit_code,
 683		     __u64 exit_info1, __u64 exit_info2,
 684		     __u32 exit_int_info, __u32 exit_int_info_err, __u32 isa),
 685	    TP_ARGS(exit_code, exit_info1, exit_info2,
 686		    exit_int_info, exit_int_info_err, isa),
 687
 688	TP_STRUCT__entry(
 689		__field(	__u32,		exit_code		)
 690		__field(	__u64,		exit_info1		)
 691		__field(	__u64,		exit_info2		)
 692		__field(	__u32,		exit_int_info		)
 693		__field(	__u32,		exit_int_info_err	)
 694		__field(	__u32,		isa			)
 695	),
 696
 697	TP_fast_assign(
 698		__entry->exit_code		= exit_code;
 699		__entry->exit_info1		= exit_info1;
 700		__entry->exit_info2		= exit_info2;
 701		__entry->exit_int_info		= exit_int_info;
 702		__entry->exit_int_info_err	= exit_int_info_err;
 703		__entry->isa			= isa;
 704	),
 705
 706	TP_printk("reason: %s%s%s ext_inf1: 0x%016llx "
 707		  "ext_inf2: 0x%016llx ext_int: 0x%08x ext_int_err: 0x%08x",
 708		  kvm_print_exit_reason(__entry->exit_code, __entry->isa),
 709		  __entry->exit_info1, __entry->exit_info2,
 710		  __entry->exit_int_info, __entry->exit_int_info_err)
 
 
 711);
 712
 713/*
 714 * Tracepoint for nested #vmexit because of interrupt pending
 715 */
 716TRACE_EVENT(kvm_nested_intr_vmexit,
 717	    TP_PROTO(__u64 rip),
 718	    TP_ARGS(rip),
 719
 720	TP_STRUCT__entry(
 721		__field(	__u64,	rip	)
 722	),
 723
 724	TP_fast_assign(
 725		__entry->rip	=	rip
 726	),
 727
 728	TP_printk("rip: 0x%016llx", __entry->rip)
 729);
 730
 731/*
 732 * Tracepoint for nested #vmexit because of interrupt pending
 733 */
 734TRACE_EVENT(kvm_invlpga,
 735	    TP_PROTO(__u64 rip, int asid, u64 address),
 736	    TP_ARGS(rip, asid, address),
 737
 738	TP_STRUCT__entry(
 739		__field(	__u64,	rip	)
 740		__field(	int,	asid	)
 741		__field(	__u64,	address	)
 742	),
 743
 744	TP_fast_assign(
 745		__entry->rip		=	rip;
 746		__entry->asid		=	asid;
 747		__entry->address	=	address;
 748	),
 749
 750	TP_printk("rip: 0x%016llx asid: %d address: 0x%016llx",
 751		  __entry->rip, __entry->asid, __entry->address)
 752);
 753
 754/*
 755 * Tracepoint for nested #vmexit because of interrupt pending
 756 */
 757TRACE_EVENT(kvm_skinit,
 758	    TP_PROTO(__u64 rip, __u32 slb),
 759	    TP_ARGS(rip, slb),
 760
 761	TP_STRUCT__entry(
 762		__field(	__u64,	rip	)
 763		__field(	__u32,	slb	)
 764	),
 765
 766	TP_fast_assign(
 767		__entry->rip		=	rip;
 768		__entry->slb		=	slb;
 769	),
 770
 771	TP_printk("rip: 0x%016llx slb: 0x%08x",
 772		  __entry->rip, __entry->slb)
 773);
 774
 775#define KVM_EMUL_INSN_F_CR0_PE (1 << 0)
 776#define KVM_EMUL_INSN_F_EFL_VM (1 << 1)
 777#define KVM_EMUL_INSN_F_CS_D   (1 << 2)
 778#define KVM_EMUL_INSN_F_CS_L   (1 << 3)
 779
 780#define kvm_trace_symbol_emul_flags	                  \
 781	{ 0,   			    "real" },		  \
 782	{ KVM_EMUL_INSN_F_CR0_PE			  \
 783	  | KVM_EMUL_INSN_F_EFL_VM, "vm16" },		  \
 784	{ KVM_EMUL_INSN_F_CR0_PE,   "prot16" },		  \
 785	{ KVM_EMUL_INSN_F_CR0_PE			  \
 786	  | KVM_EMUL_INSN_F_CS_D,   "prot32" },		  \
 787	{ KVM_EMUL_INSN_F_CR0_PE			  \
 788	  | KVM_EMUL_INSN_F_CS_L,   "prot64" }
 789
 790#define kei_decode_mode(mode) ({			\
 791	u8 flags = 0xff;				\
 792	switch (mode) {					\
 793	case X86EMUL_MODE_REAL:				\
 794		flags = 0;				\
 795		break;					\
 796	case X86EMUL_MODE_VM86:				\
 797		flags = KVM_EMUL_INSN_F_EFL_VM;		\
 798		break;					\
 799	case X86EMUL_MODE_PROT16:			\
 800		flags = KVM_EMUL_INSN_F_CR0_PE;		\
 801		break;					\
 802	case X86EMUL_MODE_PROT32:			\
 803		flags = KVM_EMUL_INSN_F_CR0_PE		\
 804			| KVM_EMUL_INSN_F_CS_D;		\
 805		break;					\
 806	case X86EMUL_MODE_PROT64:			\
 807		flags = KVM_EMUL_INSN_F_CR0_PE		\
 808			| KVM_EMUL_INSN_F_CS_L;		\
 809		break;					\
 810	}						\
 811	flags;						\
 812	})
 813
 814TRACE_EVENT(kvm_emulate_insn,
 815	TP_PROTO(struct kvm_vcpu *vcpu, __u8 failed),
 816	TP_ARGS(vcpu, failed),
 817
 818	TP_STRUCT__entry(
 819		__field(    __u64, rip                       )
 820		__field(    __u32, csbase                    )
 821		__field(    __u8,  len                       )
 822		__array(    __u8,  insn,    15	             )
 823		__field(    __u8,  flags       	   	     )
 824		__field(    __u8,  failed                    )
 825		),
 826
 827	TP_fast_assign(
 828		__entry->csbase = static_call(kvm_x86_get_segment_base)(vcpu, VCPU_SREG_CS);
 829		__entry->len = vcpu->arch.emulate_ctxt->fetch.ptr
 830			       - vcpu->arch.emulate_ctxt->fetch.data;
 831		__entry->rip = vcpu->arch.emulate_ctxt->_eip - __entry->len;
 832		memcpy(__entry->insn,
 833		       vcpu->arch.emulate_ctxt->fetch.data,
 834		       15);
 835		__entry->flags = kei_decode_mode(vcpu->arch.emulate_ctxt->mode);
 836		__entry->failed = failed;
 837		),
 838
 839	TP_printk("%x:%llx:%s (%s)%s",
 840		  __entry->csbase, __entry->rip,
 841		  __print_hex(__entry->insn, __entry->len),
 842		  __print_symbolic(__entry->flags,
 843				   kvm_trace_symbol_emul_flags),
 844		  __entry->failed ? " failed" : ""
 845		)
 846	);
 847
 848#define trace_kvm_emulate_insn_start(vcpu) trace_kvm_emulate_insn(vcpu, 0)
 849#define trace_kvm_emulate_insn_failed(vcpu) trace_kvm_emulate_insn(vcpu, 1)
 850
 851TRACE_EVENT(
 852	vcpu_match_mmio,
 853	TP_PROTO(gva_t gva, gpa_t gpa, bool write, bool gpa_match),
 854	TP_ARGS(gva, gpa, write, gpa_match),
 855
 856	TP_STRUCT__entry(
 857		__field(gva_t, gva)
 858		__field(gpa_t, gpa)
 859		__field(bool, write)
 860		__field(bool, gpa_match)
 861		),
 862
 863	TP_fast_assign(
 864		__entry->gva = gva;
 865		__entry->gpa = gpa;
 866		__entry->write = write;
 867		__entry->gpa_match = gpa_match
 868		),
 869
 870	TP_printk("gva %#lx gpa %#llx %s %s", __entry->gva, __entry->gpa,
 871		  __entry->write ? "Write" : "Read",
 872		  __entry->gpa_match ? "GPA" : "GVA")
 873);
 874
 875TRACE_EVENT(kvm_write_tsc_offset,
 876	TP_PROTO(unsigned int vcpu_id, __u64 previous_tsc_offset,
 877		 __u64 next_tsc_offset),
 878	TP_ARGS(vcpu_id, previous_tsc_offset, next_tsc_offset),
 879
 880	TP_STRUCT__entry(
 881		__field( unsigned int,	vcpu_id				)
 882		__field(	__u64,	previous_tsc_offset		)
 883		__field(	__u64,	next_tsc_offset			)
 884	),
 885
 886	TP_fast_assign(
 887		__entry->vcpu_id		= vcpu_id;
 888		__entry->previous_tsc_offset	= previous_tsc_offset;
 889		__entry->next_tsc_offset	= next_tsc_offset;
 890	),
 891
 892	TP_printk("vcpu=%u prev=%llu next=%llu", __entry->vcpu_id,
 893		  __entry->previous_tsc_offset, __entry->next_tsc_offset)
 894);
 895
 896#ifdef CONFIG_X86_64
 897
 898#define host_clocks					\
 899	{VDSO_CLOCKMODE_NONE, "none"},			\
 900	{VDSO_CLOCKMODE_TSC,  "tsc"}			\
 901
 902TRACE_EVENT(kvm_update_master_clock,
 903	TP_PROTO(bool use_master_clock, unsigned int host_clock, bool offset_matched),
 904	TP_ARGS(use_master_clock, host_clock, offset_matched),
 905
 906	TP_STRUCT__entry(
 907		__field(		bool,	use_master_clock	)
 908		__field(	unsigned int,	host_clock		)
 909		__field(		bool,	offset_matched		)
 910	),
 911
 912	TP_fast_assign(
 913		__entry->use_master_clock	= use_master_clock;
 914		__entry->host_clock		= host_clock;
 915		__entry->offset_matched		= offset_matched;
 916	),
 917
 918	TP_printk("masterclock %d hostclock %s offsetmatched %u",
 919		  __entry->use_master_clock,
 920		  __print_symbolic(__entry->host_clock, host_clocks),
 921		  __entry->offset_matched)
 922);
 923
 924TRACE_EVENT(kvm_track_tsc,
 925	TP_PROTO(unsigned int vcpu_id, unsigned int nr_matched,
 926		 unsigned int online_vcpus, bool use_master_clock,
 927		 unsigned int host_clock),
 928	TP_ARGS(vcpu_id, nr_matched, online_vcpus, use_master_clock,
 929		host_clock),
 930
 931	TP_STRUCT__entry(
 932		__field(	unsigned int,	vcpu_id			)
 933		__field(	unsigned int,	nr_vcpus_matched_tsc	)
 934		__field(	unsigned int,	online_vcpus		)
 935		__field(	bool,		use_master_clock	)
 936		__field(	unsigned int,	host_clock		)
 937	),
 938
 939	TP_fast_assign(
 940		__entry->vcpu_id		= vcpu_id;
 941		__entry->nr_vcpus_matched_tsc	= nr_matched;
 942		__entry->online_vcpus		= online_vcpus;
 943		__entry->use_master_clock	= use_master_clock;
 944		__entry->host_clock		= host_clock;
 945	),
 946
 947	TP_printk("vcpu_id %u masterclock %u offsetmatched %u nr_online %u"
 948		  " hostclock %s",
 949		  __entry->vcpu_id, __entry->use_master_clock,
 950		  __entry->nr_vcpus_matched_tsc, __entry->online_vcpus,
 951		  __print_symbolic(__entry->host_clock, host_clocks))
 952);
 953
 954#endif /* CONFIG_X86_64 */
 955
 956/*
 957 * Tracepoint for PML full VMEXIT.
 958 */
 959TRACE_EVENT(kvm_pml_full,
 960	TP_PROTO(unsigned int vcpu_id),
 961	TP_ARGS(vcpu_id),
 962
 963	TP_STRUCT__entry(
 964		__field(	unsigned int,	vcpu_id			)
 965	),
 966
 967	TP_fast_assign(
 968		__entry->vcpu_id		= vcpu_id;
 969	),
 970
 971	TP_printk("vcpu %d: PML full", __entry->vcpu_id)
 972);
 973
 974TRACE_EVENT(kvm_ple_window_update,
 975	TP_PROTO(unsigned int vcpu_id, unsigned int new, unsigned int old),
 976	TP_ARGS(vcpu_id, new, old),
 977
 978	TP_STRUCT__entry(
 
 979		__field(        unsigned int,   vcpu_id         )
 980		__field(        unsigned int,       new         )
 981		__field(        unsigned int,       old         )
 982	),
 983
 984	TP_fast_assign(
 
 985		__entry->vcpu_id        = vcpu_id;
 986		__entry->new            = new;
 987		__entry->old            = old;
 988	),
 989
 990	TP_printk("vcpu %u old %u new %u (%s)",
 991	          __entry->vcpu_id, __entry->old, __entry->new,
 992		  __entry->old < __entry->new ? "growed" : "shrinked")
 
 
 993);
 994
 
 
 
 
 
 995TRACE_EVENT(kvm_pvclock_update,
 996	TP_PROTO(unsigned int vcpu_id, struct pvclock_vcpu_time_info *pvclock),
 997	TP_ARGS(vcpu_id, pvclock),
 998
 999	TP_STRUCT__entry(
1000		__field(	unsigned int,	vcpu_id			)
1001		__field(	__u32,		version			)
1002		__field(	__u64,		tsc_timestamp		)
1003		__field(	__u64,		system_time		)
1004		__field(	__u32,		tsc_to_system_mul	)
1005		__field(	__s8,		tsc_shift		)
1006		__field(	__u8,		flags			)
1007	),
1008
1009	TP_fast_assign(
1010		__entry->vcpu_id	   = vcpu_id;
1011		__entry->version	   = pvclock->version;
1012		__entry->tsc_timestamp	   = pvclock->tsc_timestamp;
1013		__entry->system_time	   = pvclock->system_time;
1014		__entry->tsc_to_system_mul = pvclock->tsc_to_system_mul;
1015		__entry->tsc_shift	   = pvclock->tsc_shift;
1016		__entry->flags		   = pvclock->flags;
1017	),
1018
1019	TP_printk("vcpu_id %u, pvclock { version %u, tsc_timestamp 0x%llx, "
1020		  "system_time 0x%llx, tsc_to_system_mul 0x%x, tsc_shift %d, "
1021		  "flags 0x%x }",
1022		  __entry->vcpu_id,
1023		  __entry->version,
1024		  __entry->tsc_timestamp,
1025		  __entry->system_time,
1026		  __entry->tsc_to_system_mul,
1027		  __entry->tsc_shift,
1028		  __entry->flags)
1029);
1030
1031TRACE_EVENT(kvm_wait_lapic_expire,
1032	TP_PROTO(unsigned int vcpu_id, s64 delta),
1033	TP_ARGS(vcpu_id, delta),
1034
1035	TP_STRUCT__entry(
1036		__field(	unsigned int,	vcpu_id		)
1037		__field(	s64,		delta		)
1038	),
1039
1040	TP_fast_assign(
1041		__entry->vcpu_id	   = vcpu_id;
1042		__entry->delta             = delta;
1043	),
1044
1045	TP_printk("vcpu %u: delta %lld (%s)",
1046		  __entry->vcpu_id,
1047		  __entry->delta,
1048		  __entry->delta < 0 ? "early" : "late")
1049);
1050
1051TRACE_EVENT(kvm_smm_transition,
1052	TP_PROTO(unsigned int vcpu_id, u64 smbase, bool entering),
1053	TP_ARGS(vcpu_id, smbase, entering),
1054
1055	TP_STRUCT__entry(
1056		__field(	unsigned int,	vcpu_id		)
1057		__field(	u64,		smbase		)
1058		__field(	bool,		entering	)
1059	),
1060
1061	TP_fast_assign(
1062		__entry->vcpu_id	= vcpu_id;
1063		__entry->smbase		= smbase;
1064		__entry->entering	= entering;
1065	),
1066
1067	TP_printk("vcpu %u: %s SMM, smbase 0x%llx",
1068		  __entry->vcpu_id,
1069		  __entry->entering ? "entering" : "leaving",
1070		  __entry->smbase)
1071);
1072
1073/*
1074 * Tracepoint for VT-d posted-interrupts.
1075 */
1076TRACE_EVENT(kvm_pi_irte_update,
1077	TP_PROTO(unsigned int host_irq, unsigned int vcpu_id,
1078		 unsigned int gsi, unsigned int gvec,
1079		 u64 pi_desc_addr, bool set),
1080	TP_ARGS(host_irq, vcpu_id, gsi, gvec, pi_desc_addr, set),
1081
1082	TP_STRUCT__entry(
1083		__field(	unsigned int,	host_irq	)
1084		__field(	unsigned int,	vcpu_id		)
1085		__field(	unsigned int,	gsi		)
1086		__field(	unsigned int,	gvec		)
1087		__field(	u64,		pi_desc_addr	)
1088		__field(	bool,		set		)
1089	),
1090
1091	TP_fast_assign(
1092		__entry->host_irq	= host_irq;
1093		__entry->vcpu_id	= vcpu_id;
1094		__entry->gsi		= gsi;
1095		__entry->gvec		= gvec;
1096		__entry->pi_desc_addr	= pi_desc_addr;
1097		__entry->set		= set;
1098	),
1099
1100	TP_printk("VT-d PI is %s for irq %u, vcpu %u, gsi: 0x%x, "
1101		  "gvec: 0x%x, pi_desc_addr: 0x%llx",
1102		  __entry->set ? "enabled and being updated" : "disabled",
1103		  __entry->host_irq,
1104		  __entry->vcpu_id,
1105		  __entry->gsi,
1106		  __entry->gvec,
1107		  __entry->pi_desc_addr)
1108);
1109
1110/*
1111 * Tracepoint for kvm_hv_notify_acked_sint.
1112 */
1113TRACE_EVENT(kvm_hv_notify_acked_sint,
1114	TP_PROTO(int vcpu_id, u32 sint),
1115	TP_ARGS(vcpu_id, sint),
1116
1117	TP_STRUCT__entry(
1118		__field(int, vcpu_id)
1119		__field(u32, sint)
1120	),
1121
1122	TP_fast_assign(
1123		__entry->vcpu_id = vcpu_id;
1124		__entry->sint = sint;
1125	),
1126
1127	TP_printk("vcpu_id %d sint %u", __entry->vcpu_id, __entry->sint)
1128);
1129
1130/*
1131 * Tracepoint for synic_set_irq.
1132 */
1133TRACE_EVENT(kvm_hv_synic_set_irq,
1134	TP_PROTO(int vcpu_id, u32 sint, int vector, int ret),
1135	TP_ARGS(vcpu_id, sint, vector, ret),
1136
1137	TP_STRUCT__entry(
1138		__field(int, vcpu_id)
1139		__field(u32, sint)
1140		__field(int, vector)
1141		__field(int, ret)
1142	),
1143
1144	TP_fast_assign(
1145		__entry->vcpu_id = vcpu_id;
1146		__entry->sint = sint;
1147		__entry->vector = vector;
1148		__entry->ret = ret;
1149	),
1150
1151	TP_printk("vcpu_id %d sint %u vector %d ret %d",
1152		  __entry->vcpu_id, __entry->sint, __entry->vector,
1153		  __entry->ret)
1154);
1155
1156/*
1157 * Tracepoint for kvm_hv_synic_send_eoi.
1158 */
1159TRACE_EVENT(kvm_hv_synic_send_eoi,
1160	TP_PROTO(int vcpu_id, int vector),
1161	TP_ARGS(vcpu_id, vector),
1162
1163	TP_STRUCT__entry(
1164		__field(int, vcpu_id)
1165		__field(u32, sint)
1166		__field(int, vector)
1167		__field(int, ret)
1168	),
1169
1170	TP_fast_assign(
1171		__entry->vcpu_id = vcpu_id;
1172		__entry->vector	= vector;
1173	),
1174
1175	TP_printk("vcpu_id %d vector %d", __entry->vcpu_id, __entry->vector)
1176);
1177
1178/*
1179 * Tracepoint for synic_set_msr.
1180 */
1181TRACE_EVENT(kvm_hv_synic_set_msr,
1182	TP_PROTO(int vcpu_id, u32 msr, u64 data, bool host),
1183	TP_ARGS(vcpu_id, msr, data, host),
1184
1185	TP_STRUCT__entry(
1186		__field(int, vcpu_id)
1187		__field(u32, msr)
1188		__field(u64, data)
1189		__field(bool, host)
1190	),
1191
1192	TP_fast_assign(
1193		__entry->vcpu_id = vcpu_id;
1194		__entry->msr = msr;
1195		__entry->data = data;
1196		__entry->host = host
1197	),
1198
1199	TP_printk("vcpu_id %d msr 0x%x data 0x%llx host %d",
1200		  __entry->vcpu_id, __entry->msr, __entry->data, __entry->host)
1201);
1202
1203/*
1204 * Tracepoint for stimer_set_config.
1205 */
1206TRACE_EVENT(kvm_hv_stimer_set_config,
1207	TP_PROTO(int vcpu_id, int timer_index, u64 config, bool host),
1208	TP_ARGS(vcpu_id, timer_index, config, host),
1209
1210	TP_STRUCT__entry(
1211		__field(int, vcpu_id)
1212		__field(int, timer_index)
1213		__field(u64, config)
1214		__field(bool, host)
1215	),
1216
1217	TP_fast_assign(
1218		__entry->vcpu_id = vcpu_id;
1219		__entry->timer_index = timer_index;
1220		__entry->config = config;
1221		__entry->host = host;
1222	),
1223
1224	TP_printk("vcpu_id %d timer %d config 0x%llx host %d",
1225		  __entry->vcpu_id, __entry->timer_index, __entry->config,
1226		  __entry->host)
1227);
1228
1229/*
1230 * Tracepoint for stimer_set_count.
1231 */
1232TRACE_EVENT(kvm_hv_stimer_set_count,
1233	TP_PROTO(int vcpu_id, int timer_index, u64 count, bool host),
1234	TP_ARGS(vcpu_id, timer_index, count, host),
1235
1236	TP_STRUCT__entry(
1237		__field(int, vcpu_id)
1238		__field(int, timer_index)
1239		__field(u64, count)
1240		__field(bool, host)
1241	),
1242
1243	TP_fast_assign(
1244		__entry->vcpu_id = vcpu_id;
1245		__entry->timer_index = timer_index;
1246		__entry->count = count;
1247		__entry->host = host;
1248	),
1249
1250	TP_printk("vcpu_id %d timer %d count %llu host %d",
1251		  __entry->vcpu_id, __entry->timer_index, __entry->count,
1252		  __entry->host)
1253);
1254
1255/*
1256 * Tracepoint for stimer_start(periodic timer case).
1257 */
1258TRACE_EVENT(kvm_hv_stimer_start_periodic,
1259	TP_PROTO(int vcpu_id, int timer_index, u64 time_now, u64 exp_time),
1260	TP_ARGS(vcpu_id, timer_index, time_now, exp_time),
1261
1262	TP_STRUCT__entry(
1263		__field(int, vcpu_id)
1264		__field(int, timer_index)
1265		__field(u64, time_now)
1266		__field(u64, exp_time)
1267	),
1268
1269	TP_fast_assign(
1270		__entry->vcpu_id = vcpu_id;
1271		__entry->timer_index = timer_index;
1272		__entry->time_now = time_now;
1273		__entry->exp_time = exp_time;
1274	),
1275
1276	TP_printk("vcpu_id %d timer %d time_now %llu exp_time %llu",
1277		  __entry->vcpu_id, __entry->timer_index, __entry->time_now,
1278		  __entry->exp_time)
1279);
1280
1281/*
1282 * Tracepoint for stimer_start(one-shot timer case).
1283 */
1284TRACE_EVENT(kvm_hv_stimer_start_one_shot,
1285	TP_PROTO(int vcpu_id, int timer_index, u64 time_now, u64 count),
1286	TP_ARGS(vcpu_id, timer_index, time_now, count),
1287
1288	TP_STRUCT__entry(
1289		__field(int, vcpu_id)
1290		__field(int, timer_index)
1291		__field(u64, time_now)
1292		__field(u64, count)
1293	),
1294
1295	TP_fast_assign(
1296		__entry->vcpu_id = vcpu_id;
1297		__entry->timer_index = timer_index;
1298		__entry->time_now = time_now;
1299		__entry->count = count;
1300	),
1301
1302	TP_printk("vcpu_id %d timer %d time_now %llu count %llu",
1303		  __entry->vcpu_id, __entry->timer_index, __entry->time_now,
1304		  __entry->count)
1305);
1306
1307/*
1308 * Tracepoint for stimer_timer_callback.
1309 */
1310TRACE_EVENT(kvm_hv_stimer_callback,
1311	TP_PROTO(int vcpu_id, int timer_index),
1312	TP_ARGS(vcpu_id, timer_index),
1313
1314	TP_STRUCT__entry(
1315		__field(int, vcpu_id)
1316		__field(int, timer_index)
1317	),
1318
1319	TP_fast_assign(
1320		__entry->vcpu_id = vcpu_id;
1321		__entry->timer_index = timer_index;
1322	),
1323
1324	TP_printk("vcpu_id %d timer %d",
1325		  __entry->vcpu_id, __entry->timer_index)
1326);
1327
1328/*
1329 * Tracepoint for stimer_expiration.
1330 */
1331TRACE_EVENT(kvm_hv_stimer_expiration,
1332	TP_PROTO(int vcpu_id, int timer_index, int direct, int msg_send_result),
1333	TP_ARGS(vcpu_id, timer_index, direct, msg_send_result),
1334
1335	TP_STRUCT__entry(
1336		__field(int, vcpu_id)
1337		__field(int, timer_index)
1338		__field(int, direct)
1339		__field(int, msg_send_result)
1340	),
1341
1342	TP_fast_assign(
1343		__entry->vcpu_id = vcpu_id;
1344		__entry->timer_index = timer_index;
1345		__entry->direct = direct;
1346		__entry->msg_send_result = msg_send_result;
1347	),
1348
1349	TP_printk("vcpu_id %d timer %d direct %d send result %d",
1350		  __entry->vcpu_id, __entry->timer_index,
1351		  __entry->direct, __entry->msg_send_result)
1352);
1353
1354/*
1355 * Tracepoint for stimer_cleanup.
1356 */
1357TRACE_EVENT(kvm_hv_stimer_cleanup,
1358	TP_PROTO(int vcpu_id, int timer_index),
1359	TP_ARGS(vcpu_id, timer_index),
1360
1361	TP_STRUCT__entry(
1362		__field(int, vcpu_id)
1363		__field(int, timer_index)
1364	),
1365
1366	TP_fast_assign(
1367		__entry->vcpu_id = vcpu_id;
1368		__entry->timer_index = timer_index;
1369	),
1370
1371	TP_printk("vcpu_id %d timer %d",
1372		  __entry->vcpu_id, __entry->timer_index)
1373);
1374
1375TRACE_EVENT(kvm_apicv_inhibit_changed,
1376	    TP_PROTO(int reason, bool set, unsigned long inhibits),
1377	    TP_ARGS(reason, set, inhibits),
1378
1379	TP_STRUCT__entry(
1380		__field(int, reason)
1381		__field(bool, set)
1382		__field(unsigned long, inhibits)
1383	),
1384
1385	TP_fast_assign(
1386		__entry->reason = reason;
1387		__entry->set = set;
1388		__entry->inhibits = inhibits;
1389	),
1390
1391	TP_printk("%s reason=%u, inhibits=0x%lx",
1392		  __entry->set ? "set" : "cleared",
1393		  __entry->reason, __entry->inhibits)
1394);
1395
1396TRACE_EVENT(kvm_apicv_accept_irq,
1397	    TP_PROTO(__u32 apicid, __u16 dm, __u16 tm, __u8 vec),
1398	    TP_ARGS(apicid, dm, tm, vec),
1399
1400	TP_STRUCT__entry(
1401		__field(	__u32,		apicid		)
1402		__field(	__u16,		dm		)
1403		__field(	__u16,		tm		)
1404		__field(	__u8,		vec		)
1405	),
1406
1407	TP_fast_assign(
1408		__entry->apicid		= apicid;
1409		__entry->dm		= dm;
1410		__entry->tm		= tm;
1411		__entry->vec		= vec;
1412	),
1413
1414	TP_printk("apicid %x vec %u (%s|%s)",
1415		  __entry->apicid, __entry->vec,
1416		  __print_symbolic((__entry->dm >> 8 & 0x7), kvm_deliver_mode),
1417		  __entry->tm ? "level" : "edge")
1418);
1419
1420/*
1421 * Tracepoint for AMD AVIC
1422 */
1423TRACE_EVENT(kvm_avic_incomplete_ipi,
1424	    TP_PROTO(u32 vcpu, u32 icrh, u32 icrl, u32 id, u32 index),
1425	    TP_ARGS(vcpu, icrh, icrl, id, index),
1426
1427	TP_STRUCT__entry(
1428		__field(u32, vcpu)
1429		__field(u32, icrh)
1430		__field(u32, icrl)
1431		__field(u32, id)
1432		__field(u32, index)
1433	),
1434
1435	TP_fast_assign(
1436		__entry->vcpu = vcpu;
1437		__entry->icrh = icrh;
1438		__entry->icrl = icrl;
1439		__entry->id = id;
1440		__entry->index = index;
1441	),
1442
1443	TP_printk("vcpu=%u, icrh:icrl=%#010x:%08x, id=%u, index=%u",
1444		  __entry->vcpu, __entry->icrh, __entry->icrl,
1445		  __entry->id, __entry->index)
1446);
1447
1448TRACE_EVENT(kvm_avic_unaccelerated_access,
1449	    TP_PROTO(u32 vcpu, u32 offset, bool ft, bool rw, u32 vec),
1450	    TP_ARGS(vcpu, offset, ft, rw, vec),
1451
1452	TP_STRUCT__entry(
1453		__field(u32, vcpu)
1454		__field(u32, offset)
1455		__field(bool, ft)
1456		__field(bool, rw)
1457		__field(u32, vec)
1458	),
1459
1460	TP_fast_assign(
1461		__entry->vcpu = vcpu;
1462		__entry->offset = offset;
1463		__entry->ft = ft;
1464		__entry->rw = rw;
1465		__entry->vec = vec;
1466	),
1467
1468	TP_printk("vcpu=%u, offset=%#x(%s), %s, %s, vec=%#x",
1469		  __entry->vcpu,
1470		  __entry->offset,
1471		  __print_symbolic(__entry->offset, kvm_trace_symbol_apic),
1472		  __entry->ft ? "trap" : "fault",
1473		  __entry->rw ? "write" : "read",
1474		  __entry->vec)
1475);
1476
1477TRACE_EVENT(kvm_avic_ga_log,
1478	    TP_PROTO(u32 vmid, u32 vcpuid),
1479	    TP_ARGS(vmid, vcpuid),
1480
1481	TP_STRUCT__entry(
1482		__field(u32, vmid)
1483		__field(u32, vcpuid)
1484	),
1485
1486	TP_fast_assign(
1487		__entry->vmid = vmid;
1488		__entry->vcpuid = vcpuid;
1489	),
1490
1491	TP_printk("vmid=%u, vcpuid=%u",
1492		  __entry->vmid, __entry->vcpuid)
1493);
1494
1495TRACE_EVENT(kvm_avic_kick_vcpu_slowpath,
1496	    TP_PROTO(u32 icrh, u32 icrl, u32 index),
1497	    TP_ARGS(icrh, icrl, index),
1498
1499	TP_STRUCT__entry(
1500		__field(u32, icrh)
1501		__field(u32, icrl)
1502		__field(u32, index)
1503	),
1504
1505	TP_fast_assign(
1506		__entry->icrh = icrh;
1507		__entry->icrl = icrl;
1508		__entry->index = index;
1509	),
1510
1511	TP_printk("icrh:icrl=%#08x:%08x, index=%u",
1512		  __entry->icrh, __entry->icrl, __entry->index)
1513);
1514
1515TRACE_EVENT(kvm_avic_doorbell,
1516	    TP_PROTO(u32 vcpuid, u32 apicid),
1517	    TP_ARGS(vcpuid, apicid),
1518
1519	TP_STRUCT__entry(
1520		__field(u32, vcpuid)
1521		__field(u32, apicid)
1522	),
1523
1524	TP_fast_assign(
1525		__entry->vcpuid = vcpuid;
1526		__entry->apicid = apicid;
1527	),
1528
1529	TP_printk("vcpuid=%u, apicid=%u",
1530		  __entry->vcpuid, __entry->apicid)
1531);
1532
1533TRACE_EVENT(kvm_hv_timer_state,
1534		TP_PROTO(unsigned int vcpu_id, unsigned int hv_timer_in_use),
1535		TP_ARGS(vcpu_id, hv_timer_in_use),
1536		TP_STRUCT__entry(
1537			__field(unsigned int, vcpu_id)
1538			__field(unsigned int, hv_timer_in_use)
1539			),
1540		TP_fast_assign(
1541			__entry->vcpu_id = vcpu_id;
1542			__entry->hv_timer_in_use = hv_timer_in_use;
1543			),
1544		TP_printk("vcpu_id %x hv_timer %x",
1545			__entry->vcpu_id,
1546			__entry->hv_timer_in_use)
1547);
1548
1549/*
1550 * Tracepoint for kvm_hv_flush_tlb.
1551 */
1552TRACE_EVENT(kvm_hv_flush_tlb,
1553	TP_PROTO(u64 processor_mask, u64 address_space, u64 flags, bool guest_mode),
1554	TP_ARGS(processor_mask, address_space, flags, guest_mode),
1555
1556	TP_STRUCT__entry(
1557		__field(u64, processor_mask)
1558		__field(u64, address_space)
1559		__field(u64, flags)
1560		__field(bool, guest_mode)
1561	),
1562
1563	TP_fast_assign(
1564		__entry->processor_mask = processor_mask;
1565		__entry->address_space = address_space;
1566		__entry->flags = flags;
1567		__entry->guest_mode = guest_mode;
1568	),
1569
1570	TP_printk("processor_mask 0x%llx address_space 0x%llx flags 0x%llx %s",
1571		  __entry->processor_mask, __entry->address_space,
1572		  __entry->flags, __entry->guest_mode ? "(L2)" : "")
1573);
1574
1575/*
1576 * Tracepoint for kvm_hv_flush_tlb_ex.
1577 */
1578TRACE_EVENT(kvm_hv_flush_tlb_ex,
1579	TP_PROTO(u64 valid_bank_mask, u64 format, u64 address_space, u64 flags, bool guest_mode),
1580	TP_ARGS(valid_bank_mask, format, address_space, flags, guest_mode),
1581
1582	TP_STRUCT__entry(
1583		__field(u64, valid_bank_mask)
1584		__field(u64, format)
1585		__field(u64, address_space)
1586		__field(u64, flags)
1587		__field(bool, guest_mode)
1588	),
1589
1590	TP_fast_assign(
1591		__entry->valid_bank_mask = valid_bank_mask;
1592		__entry->format = format;
1593		__entry->address_space = address_space;
1594		__entry->flags = flags;
1595		__entry->guest_mode = guest_mode;
1596	),
1597
1598	TP_printk("valid_bank_mask 0x%llx format 0x%llx "
1599		  "address_space 0x%llx flags 0x%llx %s",
1600		  __entry->valid_bank_mask, __entry->format,
1601		  __entry->address_space, __entry->flags,
1602		  __entry->guest_mode ? "(L2)" : "")
1603);
1604
1605/*
1606 * Tracepoints for kvm_hv_send_ipi.
1607 */
1608TRACE_EVENT(kvm_hv_send_ipi,
1609	TP_PROTO(u32 vector, u64 processor_mask),
1610	TP_ARGS(vector, processor_mask),
1611
1612	TP_STRUCT__entry(
1613		__field(u32, vector)
1614		__field(u64, processor_mask)
1615	),
1616
1617	TP_fast_assign(
1618		__entry->vector = vector;
1619		__entry->processor_mask = processor_mask;
1620	),
1621
1622	TP_printk("vector %x processor_mask 0x%llx",
1623		  __entry->vector, __entry->processor_mask)
1624);
1625
1626TRACE_EVENT(kvm_hv_send_ipi_ex,
1627	TP_PROTO(u32 vector, u64 format, u64 valid_bank_mask),
1628	TP_ARGS(vector, format, valid_bank_mask),
1629
1630	TP_STRUCT__entry(
1631		__field(u32, vector)
1632		__field(u64, format)
1633		__field(u64, valid_bank_mask)
1634	),
1635
1636	TP_fast_assign(
1637		__entry->vector = vector;
1638		__entry->format = format;
1639		__entry->valid_bank_mask = valid_bank_mask;
1640	),
1641
1642	TP_printk("vector %x format %llx valid_bank_mask 0x%llx",
1643		  __entry->vector, __entry->format,
1644		  __entry->valid_bank_mask)
1645);
1646
1647TRACE_EVENT(kvm_pv_tlb_flush,
1648	TP_PROTO(unsigned int vcpu_id, bool need_flush_tlb),
1649	TP_ARGS(vcpu_id, need_flush_tlb),
1650
1651	TP_STRUCT__entry(
1652		__field(	unsigned int,	vcpu_id		)
1653		__field(	bool,	need_flush_tlb		)
1654	),
1655
1656	TP_fast_assign(
1657		__entry->vcpu_id	= vcpu_id;
1658		__entry->need_flush_tlb = need_flush_tlb;
1659	),
1660
1661	TP_printk("vcpu %u need_flush_tlb %s", __entry->vcpu_id,
1662		__entry->need_flush_tlb ? "true" : "false")
1663);
1664
1665/*
1666 * Tracepoint for failed nested VMX VM-Enter.
1667 */
1668TRACE_EVENT(kvm_nested_vmenter_failed,
1669	TP_PROTO(const char *msg, u32 err),
1670	TP_ARGS(msg, err),
1671
1672	TP_STRUCT__entry(
1673		__string(msg, msg)
1674		__field(u32, err)
1675	),
1676
1677	TP_fast_assign(
1678		__assign_str(msg, msg);
1679		__entry->err = err;
1680	),
1681
1682	TP_printk("%s%s", __get_str(msg), !__entry->err ? "" :
1683		__print_symbolic(__entry->err, VMX_VMENTER_INSTRUCTION_ERRORS))
1684);
1685
1686/*
1687 * Tracepoint for syndbg_set_msr.
1688 */
1689TRACE_EVENT(kvm_hv_syndbg_set_msr,
1690	TP_PROTO(int vcpu_id, u32 vp_index, u32 msr, u64 data),
1691	TP_ARGS(vcpu_id, vp_index, msr, data),
1692
1693	TP_STRUCT__entry(
1694		__field(int, vcpu_id)
1695		__field(u32, vp_index)
1696		__field(u32, msr)
1697		__field(u64, data)
1698	),
1699
1700	TP_fast_assign(
1701		__entry->vcpu_id = vcpu_id;
1702		__entry->vp_index = vp_index;
1703		__entry->msr = msr;
1704		__entry->data = data;
1705	),
1706
1707	TP_printk("vcpu_id %d vp_index %u msr 0x%x data 0x%llx",
1708		  __entry->vcpu_id, __entry->vp_index, __entry->msr,
1709		  __entry->data)
1710);
1711
1712/*
1713 * Tracepoint for syndbg_get_msr.
1714 */
1715TRACE_EVENT(kvm_hv_syndbg_get_msr,
1716	TP_PROTO(int vcpu_id, u32 vp_index, u32 msr, u64 data),
1717	TP_ARGS(vcpu_id, vp_index, msr, data),
1718
1719	TP_STRUCT__entry(
1720		__field(int, vcpu_id)
1721		__field(u32, vp_index)
1722		__field(u32, msr)
1723		__field(u64, data)
1724	),
1725
1726	TP_fast_assign(
1727		__entry->vcpu_id = vcpu_id;
1728		__entry->vp_index = vp_index;
1729		__entry->msr = msr;
1730		__entry->data = data;
1731	),
1732
1733	TP_printk("vcpu_id %d vp_index %u msr 0x%x data 0x%llx",
1734		  __entry->vcpu_id, __entry->vp_index, __entry->msr,
1735		  __entry->data)
1736);
1737
1738/*
1739 * Tracepoint for the start of VMGEXIT processing
1740 */
1741TRACE_EVENT(kvm_vmgexit_enter,
1742	TP_PROTO(unsigned int vcpu_id, struct ghcb *ghcb),
1743	TP_ARGS(vcpu_id, ghcb),
1744
1745	TP_STRUCT__entry(
1746		__field(unsigned int, vcpu_id)
1747		__field(u64, exit_reason)
1748		__field(u64, info1)
1749		__field(u64, info2)
1750	),
1751
1752	TP_fast_assign(
1753		__entry->vcpu_id     = vcpu_id;
1754		__entry->exit_reason = ghcb->save.sw_exit_code;
1755		__entry->info1       = ghcb->save.sw_exit_info_1;
1756		__entry->info2       = ghcb->save.sw_exit_info_2;
1757	),
1758
1759	TP_printk("vcpu %u, exit_reason %llx, exit_info1 %llx, exit_info2 %llx",
1760		  __entry->vcpu_id, __entry->exit_reason,
1761		  __entry->info1, __entry->info2)
1762);
1763
1764/*
1765 * Tracepoint for the end of VMGEXIT processing
1766 */
1767TRACE_EVENT(kvm_vmgexit_exit,
1768	TP_PROTO(unsigned int vcpu_id, struct ghcb *ghcb),
1769	TP_ARGS(vcpu_id, ghcb),
1770
1771	TP_STRUCT__entry(
1772		__field(unsigned int, vcpu_id)
1773		__field(u64, exit_reason)
1774		__field(u64, info1)
1775		__field(u64, info2)
1776	),
1777
1778	TP_fast_assign(
1779		__entry->vcpu_id     = vcpu_id;
1780		__entry->exit_reason = ghcb->save.sw_exit_code;
1781		__entry->info1       = ghcb->save.sw_exit_info_1;
1782		__entry->info2       = ghcb->save.sw_exit_info_2;
1783	),
1784
1785	TP_printk("vcpu %u, exit_reason %llx, exit_info1 %llx, exit_info2 %llx",
1786		  __entry->vcpu_id, __entry->exit_reason,
1787		  __entry->info1, __entry->info2)
1788);
1789
1790/*
1791 * Tracepoint for the start of VMGEXIT MSR procotol processing
1792 */
1793TRACE_EVENT(kvm_vmgexit_msr_protocol_enter,
1794	TP_PROTO(unsigned int vcpu_id, u64 ghcb_gpa),
1795	TP_ARGS(vcpu_id, ghcb_gpa),
1796
1797	TP_STRUCT__entry(
1798		__field(unsigned int, vcpu_id)
1799		__field(u64, ghcb_gpa)
1800	),
1801
1802	TP_fast_assign(
1803		__entry->vcpu_id  = vcpu_id;
1804		__entry->ghcb_gpa = ghcb_gpa;
1805	),
1806
1807	TP_printk("vcpu %u, ghcb_gpa %016llx",
1808		  __entry->vcpu_id, __entry->ghcb_gpa)
1809);
1810
1811/*
1812 * Tracepoint for the end of VMGEXIT MSR procotol processing
1813 */
1814TRACE_EVENT(kvm_vmgexit_msr_protocol_exit,
1815	TP_PROTO(unsigned int vcpu_id, u64 ghcb_gpa, int result),
1816	TP_ARGS(vcpu_id, ghcb_gpa, result),
1817
1818	TP_STRUCT__entry(
1819		__field(unsigned int, vcpu_id)
1820		__field(u64, ghcb_gpa)
1821		__field(int, result)
1822	),
1823
1824	TP_fast_assign(
1825		__entry->vcpu_id  = vcpu_id;
1826		__entry->ghcb_gpa = ghcb_gpa;
1827		__entry->result   = result;
1828	),
1829
1830	TP_printk("vcpu %u, ghcb_gpa %016llx, result %d",
1831		  __entry->vcpu_id, __entry->ghcb_gpa, __entry->result)
1832);
1833
1834#endif /* _TRACE_KVM_H */
1835
1836#undef TRACE_INCLUDE_PATH
1837#define TRACE_INCLUDE_PATH ../../arch/x86/kvm
1838#undef TRACE_INCLUDE_FILE
1839#define TRACE_INCLUDE_FILE trace
1840
1841/* This part must be outside protection */
1842#include <trace/define_trace.h>
v4.17
   1/* SPDX-License-Identifier: GPL-2.0 */
   2#if !defined(_TRACE_KVM_H) || defined(TRACE_HEADER_MULTI_READ)
   3#define _TRACE_KVM_H
   4
   5#include <linux/tracepoint.h>
   6#include <asm/vmx.h>
   7#include <asm/svm.h>
   8#include <asm/clocksource.h>
   9#include <asm/pvclock-abi.h>
  10
  11#undef TRACE_SYSTEM
  12#define TRACE_SYSTEM kvm
  13
  14/*
  15 * Tracepoint for guest mode entry.
  16 */
  17TRACE_EVENT(kvm_entry,
  18	TP_PROTO(unsigned int vcpu_id),
  19	TP_ARGS(vcpu_id),
  20
  21	TP_STRUCT__entry(
  22		__field(	unsigned int,	vcpu_id		)
 
  23	),
  24
  25	TP_fast_assign(
  26		__entry->vcpu_id	= vcpu_id;
 
  27	),
  28
  29	TP_printk("vcpu %u", __entry->vcpu_id)
  30);
  31
  32/*
  33 * Tracepoint for hypercall.
  34 */
  35TRACE_EVENT(kvm_hypercall,
  36	TP_PROTO(unsigned long nr, unsigned long a0, unsigned long a1,
  37		 unsigned long a2, unsigned long a3),
  38	TP_ARGS(nr, a0, a1, a2, a3),
  39
  40	TP_STRUCT__entry(
  41		__field(	unsigned long, 	nr		)
  42		__field(	unsigned long,	a0		)
  43		__field(	unsigned long,	a1		)
  44		__field(	unsigned long,	a2		)
  45		__field(	unsigned long,	a3		)
  46	),
  47
  48	TP_fast_assign(
  49		__entry->nr		= nr;
  50		__entry->a0		= a0;
  51		__entry->a1		= a1;
  52		__entry->a2		= a2;
  53		__entry->a3		= a3;
  54	),
  55
  56	TP_printk("nr 0x%lx a0 0x%lx a1 0x%lx a2 0x%lx a3 0x%lx",
  57		 __entry->nr, __entry->a0, __entry->a1,  __entry->a2,
  58		 __entry->a3)
  59);
  60
  61/*
  62 * Tracepoint for hypercall.
  63 */
  64TRACE_EVENT(kvm_hv_hypercall,
  65	TP_PROTO(__u16 code, bool fast, __u16 rep_cnt, __u16 rep_idx,
  66		 __u64 ingpa, __u64 outgpa),
  67	TP_ARGS(code, fast, rep_cnt, rep_idx, ingpa, outgpa),
  68
  69	TP_STRUCT__entry(
  70		__field(	__u16,		rep_cnt		)
  71		__field(	__u16,		rep_idx		)
  72		__field(	__u64,		ingpa		)
  73		__field(	__u64,		outgpa		)
  74		__field(	__u16, 		code		)
 
  75		__field(	bool,		fast		)
  76	),
  77
  78	TP_fast_assign(
  79		__entry->rep_cnt	= rep_cnt;
  80		__entry->rep_idx	= rep_idx;
  81		__entry->ingpa		= ingpa;
  82		__entry->outgpa		= outgpa;
  83		__entry->code		= code;
 
  84		__entry->fast		= fast;
  85	),
  86
  87	TP_printk("code 0x%x %s cnt 0x%x idx 0x%x in 0x%llx out 0x%llx",
  88		  __entry->code, __entry->fast ? "fast" : "slow",
  89		  __entry->rep_cnt, __entry->rep_idx,  __entry->ingpa,
  90		  __entry->outgpa)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  91);
  92
  93/*
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  94 * Tracepoint for PIO.
  95 */
  96
  97#define KVM_PIO_IN   0
  98#define KVM_PIO_OUT  1
  99
 100TRACE_EVENT(kvm_pio,
 101	TP_PROTO(unsigned int rw, unsigned int port, unsigned int size,
 102		 unsigned int count, void *data),
 103	TP_ARGS(rw, port, size, count, data),
 104
 105	TP_STRUCT__entry(
 106		__field(	unsigned int, 	rw		)
 107		__field(	unsigned int, 	port		)
 108		__field(	unsigned int, 	size		)
 109		__field(	unsigned int,	count		)
 110		__field(	unsigned int,	val		)
 111	),
 112
 113	TP_fast_assign(
 114		__entry->rw		= rw;
 115		__entry->port		= port;
 116		__entry->size		= size;
 117		__entry->count		= count;
 118		if (size == 1)
 119			__entry->val	= *(unsigned char *)data;
 120		else if (size == 2)
 121			__entry->val	= *(unsigned short *)data;
 122		else
 123			__entry->val	= *(unsigned int *)data;
 124	),
 125
 126	TP_printk("pio_%s at 0x%x size %d count %d val 0x%x %s",
 127		  __entry->rw ? "write" : "read",
 128		  __entry->port, __entry->size, __entry->count, __entry->val,
 129		  __entry->count > 1 ? "(...)" : "")
 130);
 131
 132/*
 133 * Tracepoint for fast mmio.
 134 */
 135TRACE_EVENT(kvm_fast_mmio,
 136	TP_PROTO(u64 gpa),
 137	TP_ARGS(gpa),
 138
 139	TP_STRUCT__entry(
 140		__field(u64,	gpa)
 141	),
 142
 143	TP_fast_assign(
 144		__entry->gpa		= gpa;
 145	),
 146
 147	TP_printk("fast mmio at gpa 0x%llx", __entry->gpa)
 148);
 149
 150/*
 151 * Tracepoint for cpuid.
 152 */
 153TRACE_EVENT(kvm_cpuid,
 154	TP_PROTO(unsigned int function, unsigned long rax, unsigned long rbx,
 155		 unsigned long rcx, unsigned long rdx, bool found),
 156	TP_ARGS(function, rax, rbx, rcx, rdx, found),
 
 157
 158	TP_STRUCT__entry(
 159		__field(	unsigned int,	function	)
 
 160		__field(	unsigned long,	rax		)
 161		__field(	unsigned long,	rbx		)
 162		__field(	unsigned long,	rcx		)
 163		__field(	unsigned long,	rdx		)
 164		__field(	bool,		found		)
 
 165	),
 166
 167	TP_fast_assign(
 168		__entry->function	= function;
 
 169		__entry->rax		= rax;
 170		__entry->rbx		= rbx;
 171		__entry->rcx		= rcx;
 172		__entry->rdx		= rdx;
 173		__entry->found		= found;
 
 174	),
 175
 176	TP_printk("func %x rax %lx rbx %lx rcx %lx rdx %lx, cpuid entry %s",
 177		  __entry->function, __entry->rax,
 178		  __entry->rbx, __entry->rcx, __entry->rdx,
 179		  __entry->found ? "found" : "not found")
 
 180);
 181
 182#define AREG(x) { APIC_##x, "APIC_" #x }
 183
 184#define kvm_trace_symbol_apic						    \
 185	AREG(ID), AREG(LVR), AREG(TASKPRI), AREG(ARBPRI), AREG(PROCPRI),    \
 186	AREG(EOI), AREG(RRR), AREG(LDR), AREG(DFR), AREG(SPIV), AREG(ISR),  \
 187	AREG(TMR), AREG(IRR), AREG(ESR), AREG(ICR), AREG(ICR2), AREG(LVTT), \
 188	AREG(LVTTHMR), AREG(LVTPC), AREG(LVT0), AREG(LVT1), AREG(LVTERR),   \
 189	AREG(TMICT), AREG(TMCCT), AREG(TDCR), AREG(SELF_IPI), AREG(EFEAT),  \
 190	AREG(ECTRL)
 191/*
 192 * Tracepoint for apic access.
 193 */
 194TRACE_EVENT(kvm_apic,
 195	TP_PROTO(unsigned int rw, unsigned int reg, unsigned int val),
 196	TP_ARGS(rw, reg, val),
 197
 198	TP_STRUCT__entry(
 199		__field(	unsigned int,	rw		)
 200		__field(	unsigned int,	reg		)
 201		__field(	unsigned int,	val		)
 202	),
 203
 204	TP_fast_assign(
 205		__entry->rw		= rw;
 206		__entry->reg		= reg;
 207		__entry->val		= val;
 208	),
 209
 210	TP_printk("apic_%s %s = 0x%x",
 211		  __entry->rw ? "write" : "read",
 212		  __print_symbolic(__entry->reg, kvm_trace_symbol_apic),
 213		  __entry->val)
 214);
 215
 216#define trace_kvm_apic_read(reg, val)		trace_kvm_apic(0, reg, val)
 217#define trace_kvm_apic_write(reg, val)		trace_kvm_apic(1, reg, val)
 218
 219#define KVM_ISA_VMX   1
 220#define KVM_ISA_SVM   2
 221
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 222/*
 223 * Tracepoint for kvm guest exit:
 224 */
 225TRACE_EVENT(kvm_exit,
 226	TP_PROTO(unsigned int exit_reason, struct kvm_vcpu *vcpu, u32 isa),
 227	TP_ARGS(exit_reason, vcpu, isa),
 228
 229	TP_STRUCT__entry(
 230		__field(	unsigned int,	exit_reason	)
 231		__field(	unsigned long,	guest_rip	)
 232		__field(	u32,	        isa             )
 233		__field(	u64,	        info1           )
 234		__field(	u64,	        info2           )
 235	),
 236
 237	TP_fast_assign(
 238		__entry->exit_reason	= exit_reason;
 239		__entry->guest_rip	= kvm_rip_read(vcpu);
 240		__entry->isa            = isa;
 241		kvm_x86_ops->get_exit_info(vcpu, &__entry->info1,
 242					   &__entry->info2);
 243	),
 244
 245	TP_printk("reason %s rip 0x%lx info %llx %llx",
 246		 (__entry->isa == KVM_ISA_VMX) ?
 247		 __print_symbolic(__entry->exit_reason, VMX_EXIT_REASONS) :
 248		 __print_symbolic(__entry->exit_reason, SVM_EXIT_REASONS),
 249		 __entry->guest_rip, __entry->info1, __entry->info2)
 250);
 251
 252/*
 253 * Tracepoint for kvm interrupt injection:
 254 */
 255TRACE_EVENT(kvm_inj_virq,
 256	TP_PROTO(unsigned int irq),
 257	TP_ARGS(irq),
 258
 259	TP_STRUCT__entry(
 260		__field(	unsigned int,	irq		)
 
 
 261	),
 262
 263	TP_fast_assign(
 264		__entry->irq		= irq;
 
 
 265	),
 266
 267	TP_printk("irq %u", __entry->irq)
 
 
 268);
 269
 270#define EXS(x) { x##_VECTOR, "#" #x }
 271
 272#define kvm_trace_sym_exc						\
 273	EXS(DE), EXS(DB), EXS(BP), EXS(OF), EXS(BR), EXS(UD), EXS(NM),	\
 274	EXS(DF), EXS(TS), EXS(NP), EXS(SS), EXS(GP), EXS(PF),		\
 275	EXS(MF), EXS(AC), EXS(MC)
 276
 277/*
 278 * Tracepoint for kvm interrupt injection:
 279 */
 280TRACE_EVENT(kvm_inj_exception,
 281	TP_PROTO(unsigned exception, bool has_error, unsigned error_code),
 282	TP_ARGS(exception, has_error, error_code),
 
 283
 284	TP_STRUCT__entry(
 285		__field(	u8,	exception	)
 286		__field(	u8,	has_error	)
 287		__field(	u32,	error_code	)
 
 288	),
 289
 290	TP_fast_assign(
 291		__entry->exception	= exception;
 292		__entry->has_error	= has_error;
 293		__entry->error_code	= error_code;
 
 294	),
 295
 296	TP_printk("%s (0x%x)",
 297		  __print_symbolic(__entry->exception, kvm_trace_sym_exc),
 298		  /* FIXME: don't print error_code if not present */
 299		  __entry->has_error ? __entry->error_code : 0)
 
 
 300);
 301
 302/*
 303 * Tracepoint for page fault.
 304 */
 305TRACE_EVENT(kvm_page_fault,
 306	TP_PROTO(unsigned long fault_address, unsigned int error_code),
 307	TP_ARGS(fault_address, error_code),
 308
 309	TP_STRUCT__entry(
 310		__field(	unsigned long,	fault_address	)
 311		__field(	unsigned int,	error_code	)
 
 
 312	),
 313
 314	TP_fast_assign(
 
 
 315		__entry->fault_address	= fault_address;
 316		__entry->error_code	= error_code;
 317	),
 318
 319	TP_printk("address %lx error_code %x",
 
 320		  __entry->fault_address, __entry->error_code)
 321);
 322
 323/*
 324 * Tracepoint for guest MSR access.
 325 */
 326TRACE_EVENT(kvm_msr,
 327	TP_PROTO(unsigned write, u32 ecx, u64 data, bool exception),
 328	TP_ARGS(write, ecx, data, exception),
 329
 330	TP_STRUCT__entry(
 331		__field(	unsigned,	write		)
 332		__field(	u32,		ecx		)
 333		__field(	u64,		data		)
 334		__field(	u8,		exception	)
 335	),
 336
 337	TP_fast_assign(
 338		__entry->write		= write;
 339		__entry->ecx		= ecx;
 340		__entry->data		= data;
 341		__entry->exception	= exception;
 342	),
 343
 344	TP_printk("msr_%s %x = 0x%llx%s",
 345		  __entry->write ? "write" : "read",
 346		  __entry->ecx, __entry->data,
 347		  __entry->exception ? " (#GP)" : "")
 348);
 349
 350#define trace_kvm_msr_read(ecx, data)      trace_kvm_msr(0, ecx, data, false)
 351#define trace_kvm_msr_write(ecx, data)     trace_kvm_msr(1, ecx, data, false)
 352#define trace_kvm_msr_read_ex(ecx)         trace_kvm_msr(0, ecx, 0, true)
 353#define trace_kvm_msr_write_ex(ecx, data)  trace_kvm_msr(1, ecx, data, true)
 354
 355/*
 356 * Tracepoint for guest CR access.
 357 */
 358TRACE_EVENT(kvm_cr,
 359	TP_PROTO(unsigned int rw, unsigned int cr, unsigned long val),
 360	TP_ARGS(rw, cr, val),
 361
 362	TP_STRUCT__entry(
 363		__field(	unsigned int,	rw		)
 364		__field(	unsigned int,	cr		)
 365		__field(	unsigned long,	val		)
 366	),
 367
 368	TP_fast_assign(
 369		__entry->rw		= rw;
 370		__entry->cr		= cr;
 371		__entry->val		= val;
 372	),
 373
 374	TP_printk("cr_%s %x = 0x%lx",
 375		  __entry->rw ? "write" : "read",
 376		  __entry->cr, __entry->val)
 377);
 378
 379#define trace_kvm_cr_read(cr, val)		trace_kvm_cr(0, cr, val)
 380#define trace_kvm_cr_write(cr, val)		trace_kvm_cr(1, cr, val)
 381
 382TRACE_EVENT(kvm_pic_set_irq,
 383	    TP_PROTO(__u8 chip, __u8 pin, __u8 elcr, __u8 imr, bool coalesced),
 384	    TP_ARGS(chip, pin, elcr, imr, coalesced),
 385
 386	TP_STRUCT__entry(
 387		__field(	__u8,		chip		)
 388		__field(	__u8,		pin		)
 389		__field(	__u8,		elcr		)
 390		__field(	__u8,		imr		)
 391		__field(	bool,		coalesced	)
 392	),
 393
 394	TP_fast_assign(
 395		__entry->chip		= chip;
 396		__entry->pin		= pin;
 397		__entry->elcr		= elcr;
 398		__entry->imr		= imr;
 399		__entry->coalesced	= coalesced;
 400	),
 401
 402	TP_printk("chip %u pin %u (%s%s)%s",
 403		  __entry->chip, __entry->pin,
 404		  (__entry->elcr & (1 << __entry->pin)) ? "level":"edge",
 405		  (__entry->imr & (1 << __entry->pin)) ? "|masked":"",
 406		  __entry->coalesced ? " (coalesced)" : "")
 407);
 408
 409#define kvm_apic_dst_shorthand		\
 410	{0x0, "dst"},			\
 411	{0x1, "self"},			\
 412	{0x2, "all"},			\
 413	{0x3, "all-but-self"}
 414
 415TRACE_EVENT(kvm_apic_ipi,
 416	    TP_PROTO(__u32 icr_low, __u32 dest_id),
 417	    TP_ARGS(icr_low, dest_id),
 418
 419	TP_STRUCT__entry(
 420		__field(	__u32,		icr_low		)
 421		__field(	__u32,		dest_id		)
 422	),
 423
 424	TP_fast_assign(
 425		__entry->icr_low	= icr_low;
 426		__entry->dest_id	= dest_id;
 427	),
 428
 429	TP_printk("dst %x vec %u (%s|%s|%s|%s|%s)",
 430		  __entry->dest_id, (u8)__entry->icr_low,
 431		  __print_symbolic((__entry->icr_low >> 8 & 0x7),
 432				   kvm_deliver_mode),
 433		  (__entry->icr_low & (1<<11)) ? "logical" : "physical",
 434		  (__entry->icr_low & (1<<14)) ? "assert" : "de-assert",
 435		  (__entry->icr_low & (1<<15)) ? "level" : "edge",
 436		  __print_symbolic((__entry->icr_low >> 18 & 0x3),
 437				   kvm_apic_dst_shorthand))
 438);
 439
 440TRACE_EVENT(kvm_apic_accept_irq,
 441	    TP_PROTO(__u32 apicid, __u16 dm, __u8 tm, __u8 vec),
 442	    TP_ARGS(apicid, dm, tm, vec),
 443
 444	TP_STRUCT__entry(
 445		__field(	__u32,		apicid		)
 446		__field(	__u16,		dm		)
 447		__field(	__u8,		tm		)
 448		__field(	__u8,		vec		)
 449	),
 450
 451	TP_fast_assign(
 452		__entry->apicid		= apicid;
 453		__entry->dm		= dm;
 454		__entry->tm		= tm;
 455		__entry->vec		= vec;
 456	),
 457
 458	TP_printk("apicid %x vec %u (%s|%s)",
 459		  __entry->apicid, __entry->vec,
 460		  __print_symbolic((__entry->dm >> 8 & 0x7), kvm_deliver_mode),
 461		  __entry->tm ? "level" : "edge")
 462);
 463
 464TRACE_EVENT(kvm_eoi,
 465	    TP_PROTO(struct kvm_lapic *apic, int vector),
 466	    TP_ARGS(apic, vector),
 467
 468	TP_STRUCT__entry(
 469		__field(	__u32,		apicid		)
 470		__field(	int,		vector		)
 471	),
 472
 473	TP_fast_assign(
 474		__entry->apicid		= apic->vcpu->vcpu_id;
 475		__entry->vector		= vector;
 476	),
 477
 478	TP_printk("apicid %x vector %d", __entry->apicid, __entry->vector)
 479);
 480
 481TRACE_EVENT(kvm_pv_eoi,
 482	    TP_PROTO(struct kvm_lapic *apic, int vector),
 483	    TP_ARGS(apic, vector),
 484
 485	TP_STRUCT__entry(
 486		__field(	__u32,		apicid		)
 487		__field(	int,		vector		)
 488	),
 489
 490	TP_fast_assign(
 491		__entry->apicid		= apic->vcpu->vcpu_id;
 492		__entry->vector		= vector;
 493	),
 494
 495	TP_printk("apicid %x vector %d", __entry->apicid, __entry->vector)
 496);
 497
 498/*
 499 * Tracepoint for nested VMRUN
 500 */
 501TRACE_EVENT(kvm_nested_vmrun,
 502	    TP_PROTO(__u64 rip, __u64 vmcb, __u64 nested_rip, __u32 int_ctl,
 503		     __u32 event_inj, bool npt),
 504	    TP_ARGS(rip, vmcb, nested_rip, int_ctl, event_inj, npt),
 
 
 505
 506	TP_STRUCT__entry(
 507		__field(	__u64,		rip		)
 508		__field(	__u64,		vmcb		)
 509		__field(	__u64,		nested_rip	)
 510		__field(	__u32,		int_ctl		)
 511		__field(	__u32,		event_inj	)
 512		__field(	bool,		npt		)
 
 
 513	),
 514
 515	TP_fast_assign(
 516		__entry->rip		= rip;
 517		__entry->vmcb		= vmcb;
 518		__entry->nested_rip	= nested_rip;
 519		__entry->int_ctl	= int_ctl;
 520		__entry->event_inj	= event_inj;
 521		__entry->npt		= npt;
 
 
 522	),
 523
 524	TP_printk("rip: 0x%016llx vmcb: 0x%016llx nrip: 0x%016llx int_ctl: 0x%08x "
 525		  "event_inj: 0x%08x npt: %s",
 526		__entry->rip, __entry->vmcb, __entry->nested_rip,
 527		__entry->int_ctl, __entry->event_inj,
 528		__entry->npt ? "on" : "off")
 
 
 
 
 
 
 
 
 529);
 530
 531TRACE_EVENT(kvm_nested_intercepts,
 532	    TP_PROTO(__u16 cr_read, __u16 cr_write, __u32 exceptions, __u64 intercept),
 533	    TP_ARGS(cr_read, cr_write, exceptions, intercept),
 
 
 534
 535	TP_STRUCT__entry(
 536		__field(	__u16,		cr_read		)
 537		__field(	__u16,		cr_write	)
 538		__field(	__u32,		exceptions	)
 539		__field(	__u64,		intercept	)
 
 
 540	),
 541
 542	TP_fast_assign(
 543		__entry->cr_read	= cr_read;
 544		__entry->cr_write	= cr_write;
 545		__entry->exceptions	= exceptions;
 546		__entry->intercept	= intercept;
 
 
 547	),
 548
 549	TP_printk("cr_read: %04x cr_write: %04x excp: %08x intercept: %016llx",
 550		__entry->cr_read, __entry->cr_write, __entry->exceptions,
 551		__entry->intercept)
 
 552);
 553/*
 554 * Tracepoint for #VMEXIT while nested
 555 */
 556TRACE_EVENT(kvm_nested_vmexit,
 557	    TP_PROTO(__u64 rip, __u32 exit_code,
 558		     __u64 exit_info1, __u64 exit_info2,
 559		     __u32 exit_int_info, __u32 exit_int_info_err, __u32 isa),
 560	    TP_ARGS(rip, exit_code, exit_info1, exit_info2,
 561		    exit_int_info, exit_int_info_err, isa),
 562
 563	TP_STRUCT__entry(
 564		__field(	__u64,		rip			)
 565		__field(	__u32,		exit_code		)
 566		__field(	__u64,		exit_info1		)
 567		__field(	__u64,		exit_info2		)
 568		__field(	__u32,		exit_int_info		)
 569		__field(	__u32,		exit_int_info_err	)
 570		__field(	__u32,		isa			)
 571	),
 572
 573	TP_fast_assign(
 574		__entry->rip			= rip;
 575		__entry->exit_code		= exit_code;
 576		__entry->exit_info1		= exit_info1;
 577		__entry->exit_info2		= exit_info2;
 578		__entry->exit_int_info		= exit_int_info;
 579		__entry->exit_int_info_err	= exit_int_info_err;
 580		__entry->isa			= isa;
 581	),
 582	TP_printk("rip: 0x%016llx reason: %s ext_inf1: 0x%016llx "
 583		  "ext_inf2: 0x%016llx ext_int: 0x%08x ext_int_err: 0x%08x",
 584		  __entry->rip,
 585		 (__entry->isa == KVM_ISA_VMX) ?
 586		 __print_symbolic(__entry->exit_code, VMX_EXIT_REASONS) :
 587		 __print_symbolic(__entry->exit_code, SVM_EXIT_REASONS),
 588		  __entry->exit_info1, __entry->exit_info2,
 589		  __entry->exit_int_info, __entry->exit_int_info_err)
 590);
 591
 592/*
 593 * Tracepoint for #VMEXIT reinjected to the guest
 594 */
 595TRACE_EVENT(kvm_nested_vmexit_inject,
 596	    TP_PROTO(__u32 exit_code,
 597		     __u64 exit_info1, __u64 exit_info2,
 598		     __u32 exit_int_info, __u32 exit_int_info_err, __u32 isa),
 599	    TP_ARGS(exit_code, exit_info1, exit_info2,
 600		    exit_int_info, exit_int_info_err, isa),
 601
 602	TP_STRUCT__entry(
 603		__field(	__u32,		exit_code		)
 604		__field(	__u64,		exit_info1		)
 605		__field(	__u64,		exit_info2		)
 606		__field(	__u32,		exit_int_info		)
 607		__field(	__u32,		exit_int_info_err	)
 608		__field(	__u32,		isa			)
 609	),
 610
 611	TP_fast_assign(
 612		__entry->exit_code		= exit_code;
 613		__entry->exit_info1		= exit_info1;
 614		__entry->exit_info2		= exit_info2;
 615		__entry->exit_int_info		= exit_int_info;
 616		__entry->exit_int_info_err	= exit_int_info_err;
 617		__entry->isa			= isa;
 618	),
 619
 620	TP_printk("reason: %s ext_inf1: 0x%016llx "
 621		  "ext_inf2: 0x%016llx ext_int: 0x%08x ext_int_err: 0x%08x",
 622		 (__entry->isa == KVM_ISA_VMX) ?
 623		 __print_symbolic(__entry->exit_code, VMX_EXIT_REASONS) :
 624		 __print_symbolic(__entry->exit_code, SVM_EXIT_REASONS),
 625		__entry->exit_info1, __entry->exit_info2,
 626		__entry->exit_int_info, __entry->exit_int_info_err)
 627);
 628
 629/*
 630 * Tracepoint for nested #vmexit because of interrupt pending
 631 */
 632TRACE_EVENT(kvm_nested_intr_vmexit,
 633	    TP_PROTO(__u64 rip),
 634	    TP_ARGS(rip),
 635
 636	TP_STRUCT__entry(
 637		__field(	__u64,	rip	)
 638	),
 639
 640	TP_fast_assign(
 641		__entry->rip	=	rip
 642	),
 643
 644	TP_printk("rip: 0x%016llx", __entry->rip)
 645);
 646
 647/*
 648 * Tracepoint for nested #vmexit because of interrupt pending
 649 */
 650TRACE_EVENT(kvm_invlpga,
 651	    TP_PROTO(__u64 rip, int asid, u64 address),
 652	    TP_ARGS(rip, asid, address),
 653
 654	TP_STRUCT__entry(
 655		__field(	__u64,	rip	)
 656		__field(	int,	asid	)
 657		__field(	__u64,	address	)
 658	),
 659
 660	TP_fast_assign(
 661		__entry->rip		=	rip;
 662		__entry->asid		=	asid;
 663		__entry->address	=	address;
 664	),
 665
 666	TP_printk("rip: 0x%016llx asid: %d address: 0x%016llx",
 667		  __entry->rip, __entry->asid, __entry->address)
 668);
 669
 670/*
 671 * Tracepoint for nested #vmexit because of interrupt pending
 672 */
 673TRACE_EVENT(kvm_skinit,
 674	    TP_PROTO(__u64 rip, __u32 slb),
 675	    TP_ARGS(rip, slb),
 676
 677	TP_STRUCT__entry(
 678		__field(	__u64,	rip	)
 679		__field(	__u32,	slb	)
 680	),
 681
 682	TP_fast_assign(
 683		__entry->rip		=	rip;
 684		__entry->slb		=	slb;
 685	),
 686
 687	TP_printk("rip: 0x%016llx slb: 0x%08x",
 688		  __entry->rip, __entry->slb)
 689);
 690
 691#define KVM_EMUL_INSN_F_CR0_PE (1 << 0)
 692#define KVM_EMUL_INSN_F_EFL_VM (1 << 1)
 693#define KVM_EMUL_INSN_F_CS_D   (1 << 2)
 694#define KVM_EMUL_INSN_F_CS_L   (1 << 3)
 695
 696#define kvm_trace_symbol_emul_flags	                  \
 697	{ 0,   			    "real" },		  \
 698	{ KVM_EMUL_INSN_F_CR0_PE			  \
 699	  | KVM_EMUL_INSN_F_EFL_VM, "vm16" },		  \
 700	{ KVM_EMUL_INSN_F_CR0_PE,   "prot16" },		  \
 701	{ KVM_EMUL_INSN_F_CR0_PE			  \
 702	  | KVM_EMUL_INSN_F_CS_D,   "prot32" },		  \
 703	{ KVM_EMUL_INSN_F_CR0_PE			  \
 704	  | KVM_EMUL_INSN_F_CS_L,   "prot64" }
 705
 706#define kei_decode_mode(mode) ({			\
 707	u8 flags = 0xff;				\
 708	switch (mode) {					\
 709	case X86EMUL_MODE_REAL:				\
 710		flags = 0;				\
 711		break;					\
 712	case X86EMUL_MODE_VM86:				\
 713		flags = KVM_EMUL_INSN_F_EFL_VM;		\
 714		break;					\
 715	case X86EMUL_MODE_PROT16:			\
 716		flags = KVM_EMUL_INSN_F_CR0_PE;		\
 717		break;					\
 718	case X86EMUL_MODE_PROT32:			\
 719		flags = KVM_EMUL_INSN_F_CR0_PE		\
 720			| KVM_EMUL_INSN_F_CS_D;		\
 721		break;					\
 722	case X86EMUL_MODE_PROT64:			\
 723		flags = KVM_EMUL_INSN_F_CR0_PE		\
 724			| KVM_EMUL_INSN_F_CS_L;		\
 725		break;					\
 726	}						\
 727	flags;						\
 728	})
 729
 730TRACE_EVENT(kvm_emulate_insn,
 731	TP_PROTO(struct kvm_vcpu *vcpu, __u8 failed),
 732	TP_ARGS(vcpu, failed),
 733
 734	TP_STRUCT__entry(
 735		__field(    __u64, rip                       )
 736		__field(    __u32, csbase                    )
 737		__field(    __u8,  len                       )
 738		__array(    __u8,  insn,    15	             )
 739		__field(    __u8,  flags       	   	     )
 740		__field(    __u8,  failed                    )
 741		),
 742
 743	TP_fast_assign(
 744		__entry->csbase = kvm_x86_ops->get_segment_base(vcpu, VCPU_SREG_CS);
 745		__entry->len = vcpu->arch.emulate_ctxt.fetch.ptr
 746			       - vcpu->arch.emulate_ctxt.fetch.data;
 747		__entry->rip = vcpu->arch.emulate_ctxt._eip - __entry->len;
 748		memcpy(__entry->insn,
 749		       vcpu->arch.emulate_ctxt.fetch.data,
 750		       15);
 751		__entry->flags = kei_decode_mode(vcpu->arch.emulate_ctxt.mode);
 752		__entry->failed = failed;
 753		),
 754
 755	TP_printk("%x:%llx:%s (%s)%s",
 756		  __entry->csbase, __entry->rip,
 757		  __print_hex(__entry->insn, __entry->len),
 758		  __print_symbolic(__entry->flags,
 759				   kvm_trace_symbol_emul_flags),
 760		  __entry->failed ? " failed" : ""
 761		)
 762	);
 763
 764#define trace_kvm_emulate_insn_start(vcpu) trace_kvm_emulate_insn(vcpu, 0)
 765#define trace_kvm_emulate_insn_failed(vcpu) trace_kvm_emulate_insn(vcpu, 1)
 766
 767TRACE_EVENT(
 768	vcpu_match_mmio,
 769	TP_PROTO(gva_t gva, gpa_t gpa, bool write, bool gpa_match),
 770	TP_ARGS(gva, gpa, write, gpa_match),
 771
 772	TP_STRUCT__entry(
 773		__field(gva_t, gva)
 774		__field(gpa_t, gpa)
 775		__field(bool, write)
 776		__field(bool, gpa_match)
 777		),
 778
 779	TP_fast_assign(
 780		__entry->gva = gva;
 781		__entry->gpa = gpa;
 782		__entry->write = write;
 783		__entry->gpa_match = gpa_match
 784		),
 785
 786	TP_printk("gva %#lx gpa %#llx %s %s", __entry->gva, __entry->gpa,
 787		  __entry->write ? "Write" : "Read",
 788		  __entry->gpa_match ? "GPA" : "GVA")
 789);
 790
 791TRACE_EVENT(kvm_write_tsc_offset,
 792	TP_PROTO(unsigned int vcpu_id, __u64 previous_tsc_offset,
 793		 __u64 next_tsc_offset),
 794	TP_ARGS(vcpu_id, previous_tsc_offset, next_tsc_offset),
 795
 796	TP_STRUCT__entry(
 797		__field( unsigned int,	vcpu_id				)
 798		__field(	__u64,	previous_tsc_offset		)
 799		__field(	__u64,	next_tsc_offset			)
 800	),
 801
 802	TP_fast_assign(
 803		__entry->vcpu_id		= vcpu_id;
 804		__entry->previous_tsc_offset	= previous_tsc_offset;
 805		__entry->next_tsc_offset	= next_tsc_offset;
 806	),
 807
 808	TP_printk("vcpu=%u prev=%llu next=%llu", __entry->vcpu_id,
 809		  __entry->previous_tsc_offset, __entry->next_tsc_offset)
 810);
 811
 812#ifdef CONFIG_X86_64
 813
 814#define host_clocks					\
 815	{VCLOCK_NONE, "none"},				\
 816	{VCLOCK_TSC,  "tsc"}				\
 817
 818TRACE_EVENT(kvm_update_master_clock,
 819	TP_PROTO(bool use_master_clock, unsigned int host_clock, bool offset_matched),
 820	TP_ARGS(use_master_clock, host_clock, offset_matched),
 821
 822	TP_STRUCT__entry(
 823		__field(		bool,	use_master_clock	)
 824		__field(	unsigned int,	host_clock		)
 825		__field(		bool,	offset_matched		)
 826	),
 827
 828	TP_fast_assign(
 829		__entry->use_master_clock	= use_master_clock;
 830		__entry->host_clock		= host_clock;
 831		__entry->offset_matched		= offset_matched;
 832	),
 833
 834	TP_printk("masterclock %d hostclock %s offsetmatched %u",
 835		  __entry->use_master_clock,
 836		  __print_symbolic(__entry->host_clock, host_clocks),
 837		  __entry->offset_matched)
 838);
 839
 840TRACE_EVENT(kvm_track_tsc,
 841	TP_PROTO(unsigned int vcpu_id, unsigned int nr_matched,
 842		 unsigned int online_vcpus, bool use_master_clock,
 843		 unsigned int host_clock),
 844	TP_ARGS(vcpu_id, nr_matched, online_vcpus, use_master_clock,
 845		host_clock),
 846
 847	TP_STRUCT__entry(
 848		__field(	unsigned int,	vcpu_id			)
 849		__field(	unsigned int,	nr_vcpus_matched_tsc	)
 850		__field(	unsigned int,	online_vcpus		)
 851		__field(	bool,		use_master_clock	)
 852		__field(	unsigned int,	host_clock		)
 853	),
 854
 855	TP_fast_assign(
 856		__entry->vcpu_id		= vcpu_id;
 857		__entry->nr_vcpus_matched_tsc	= nr_matched;
 858		__entry->online_vcpus		= online_vcpus;
 859		__entry->use_master_clock	= use_master_clock;
 860		__entry->host_clock		= host_clock;
 861	),
 862
 863	TP_printk("vcpu_id %u masterclock %u offsetmatched %u nr_online %u"
 864		  " hostclock %s",
 865		  __entry->vcpu_id, __entry->use_master_clock,
 866		  __entry->nr_vcpus_matched_tsc, __entry->online_vcpus,
 867		  __print_symbolic(__entry->host_clock, host_clocks))
 868);
 869
 870#endif /* CONFIG_X86_64 */
 871
 872/*
 873 * Tracepoint for PML full VMEXIT.
 874 */
 875TRACE_EVENT(kvm_pml_full,
 876	TP_PROTO(unsigned int vcpu_id),
 877	TP_ARGS(vcpu_id),
 878
 879	TP_STRUCT__entry(
 880		__field(	unsigned int,	vcpu_id			)
 881	),
 882
 883	TP_fast_assign(
 884		__entry->vcpu_id		= vcpu_id;
 885	),
 886
 887	TP_printk("vcpu %d: PML full", __entry->vcpu_id)
 888);
 889
 890TRACE_EVENT(kvm_ple_window,
 891	TP_PROTO(bool grow, unsigned int vcpu_id, int new, int old),
 892	TP_ARGS(grow, vcpu_id, new, old),
 893
 894	TP_STRUCT__entry(
 895		__field(                bool,      grow         )
 896		__field(        unsigned int,   vcpu_id         )
 897		__field(                 int,       new         )
 898		__field(                 int,       old         )
 899	),
 900
 901	TP_fast_assign(
 902		__entry->grow           = grow;
 903		__entry->vcpu_id        = vcpu_id;
 904		__entry->new            = new;
 905		__entry->old            = old;
 906	),
 907
 908	TP_printk("vcpu %u: ple_window %d (%s %d)",
 909	          __entry->vcpu_id,
 910	          __entry->new,
 911	          __entry->grow ? "grow" : "shrink",
 912	          __entry->old)
 913);
 914
 915#define trace_kvm_ple_window_grow(vcpu_id, new, old) \
 916	trace_kvm_ple_window(true, vcpu_id, new, old)
 917#define trace_kvm_ple_window_shrink(vcpu_id, new, old) \
 918	trace_kvm_ple_window(false, vcpu_id, new, old)
 919
 920TRACE_EVENT(kvm_pvclock_update,
 921	TP_PROTO(unsigned int vcpu_id, struct pvclock_vcpu_time_info *pvclock),
 922	TP_ARGS(vcpu_id, pvclock),
 923
 924	TP_STRUCT__entry(
 925		__field(	unsigned int,	vcpu_id			)
 926		__field(	__u32,		version			)
 927		__field(	__u64,		tsc_timestamp		)
 928		__field(	__u64,		system_time		)
 929		__field(	__u32,		tsc_to_system_mul	)
 930		__field(	__s8,		tsc_shift		)
 931		__field(	__u8,		flags			)
 932	),
 933
 934	TP_fast_assign(
 935		__entry->vcpu_id	   = vcpu_id;
 936		__entry->version	   = pvclock->version;
 937		__entry->tsc_timestamp	   = pvclock->tsc_timestamp;
 938		__entry->system_time	   = pvclock->system_time;
 939		__entry->tsc_to_system_mul = pvclock->tsc_to_system_mul;
 940		__entry->tsc_shift	   = pvclock->tsc_shift;
 941		__entry->flags		   = pvclock->flags;
 942	),
 943
 944	TP_printk("vcpu_id %u, pvclock { version %u, tsc_timestamp 0x%llx, "
 945		  "system_time 0x%llx, tsc_to_system_mul 0x%x, tsc_shift %d, "
 946		  "flags 0x%x }",
 947		  __entry->vcpu_id,
 948		  __entry->version,
 949		  __entry->tsc_timestamp,
 950		  __entry->system_time,
 951		  __entry->tsc_to_system_mul,
 952		  __entry->tsc_shift,
 953		  __entry->flags)
 954);
 955
 956TRACE_EVENT(kvm_wait_lapic_expire,
 957	TP_PROTO(unsigned int vcpu_id, s64 delta),
 958	TP_ARGS(vcpu_id, delta),
 959
 960	TP_STRUCT__entry(
 961		__field(	unsigned int,	vcpu_id		)
 962		__field(	s64,		delta		)
 963	),
 964
 965	TP_fast_assign(
 966		__entry->vcpu_id	   = vcpu_id;
 967		__entry->delta             = delta;
 968	),
 969
 970	TP_printk("vcpu %u: delta %lld (%s)",
 971		  __entry->vcpu_id,
 972		  __entry->delta,
 973		  __entry->delta < 0 ? "early" : "late")
 974);
 975
 976TRACE_EVENT(kvm_enter_smm,
 977	TP_PROTO(unsigned int vcpu_id, u64 smbase, bool entering),
 978	TP_ARGS(vcpu_id, smbase, entering),
 979
 980	TP_STRUCT__entry(
 981		__field(	unsigned int,	vcpu_id		)
 982		__field(	u64,		smbase		)
 983		__field(	bool,		entering	)
 984	),
 985
 986	TP_fast_assign(
 987		__entry->vcpu_id	= vcpu_id;
 988		__entry->smbase		= smbase;
 989		__entry->entering	= entering;
 990	),
 991
 992	TP_printk("vcpu %u: %s SMM, smbase 0x%llx",
 993		  __entry->vcpu_id,
 994		  __entry->entering ? "entering" : "leaving",
 995		  __entry->smbase)
 996);
 997
 998/*
 999 * Tracepoint for VT-d posted-interrupts.
1000 */
1001TRACE_EVENT(kvm_pi_irte_update,
1002	TP_PROTO(unsigned int host_irq, unsigned int vcpu_id,
1003		 unsigned int gsi, unsigned int gvec,
1004		 u64 pi_desc_addr, bool set),
1005	TP_ARGS(host_irq, vcpu_id, gsi, gvec, pi_desc_addr, set),
1006
1007	TP_STRUCT__entry(
1008		__field(	unsigned int,	host_irq	)
1009		__field(	unsigned int,	vcpu_id		)
1010		__field(	unsigned int,	gsi		)
1011		__field(	unsigned int,	gvec		)
1012		__field(	u64,		pi_desc_addr	)
1013		__field(	bool,		set		)
1014	),
1015
1016	TP_fast_assign(
1017		__entry->host_irq	= host_irq;
1018		__entry->vcpu_id	= vcpu_id;
1019		__entry->gsi		= gsi;
1020		__entry->gvec		= gvec;
1021		__entry->pi_desc_addr	= pi_desc_addr;
1022		__entry->set		= set;
1023	),
1024
1025	TP_printk("VT-d PI is %s for irq %u, vcpu %u, gsi: 0x%x, "
1026		  "gvec: 0x%x, pi_desc_addr: 0x%llx",
1027		  __entry->set ? "enabled and being updated" : "disabled",
1028		  __entry->host_irq,
1029		  __entry->vcpu_id,
1030		  __entry->gsi,
1031		  __entry->gvec,
1032		  __entry->pi_desc_addr)
1033);
1034
1035/*
1036 * Tracepoint for kvm_hv_notify_acked_sint.
1037 */
1038TRACE_EVENT(kvm_hv_notify_acked_sint,
1039	TP_PROTO(int vcpu_id, u32 sint),
1040	TP_ARGS(vcpu_id, sint),
1041
1042	TP_STRUCT__entry(
1043		__field(int, vcpu_id)
1044		__field(u32, sint)
1045	),
1046
1047	TP_fast_assign(
1048		__entry->vcpu_id = vcpu_id;
1049		__entry->sint = sint;
1050	),
1051
1052	TP_printk("vcpu_id %d sint %u", __entry->vcpu_id, __entry->sint)
1053);
1054
1055/*
1056 * Tracepoint for synic_set_irq.
1057 */
1058TRACE_EVENT(kvm_hv_synic_set_irq,
1059	TP_PROTO(int vcpu_id, u32 sint, int vector, int ret),
1060	TP_ARGS(vcpu_id, sint, vector, ret),
1061
1062	TP_STRUCT__entry(
1063		__field(int, vcpu_id)
1064		__field(u32, sint)
1065		__field(int, vector)
1066		__field(int, ret)
1067	),
1068
1069	TP_fast_assign(
1070		__entry->vcpu_id = vcpu_id;
1071		__entry->sint = sint;
1072		__entry->vector = vector;
1073		__entry->ret = ret;
1074	),
1075
1076	TP_printk("vcpu_id %d sint %u vector %d ret %d",
1077		  __entry->vcpu_id, __entry->sint, __entry->vector,
1078		  __entry->ret)
1079);
1080
1081/*
1082 * Tracepoint for kvm_hv_synic_send_eoi.
1083 */
1084TRACE_EVENT(kvm_hv_synic_send_eoi,
1085	TP_PROTO(int vcpu_id, int vector),
1086	TP_ARGS(vcpu_id, vector),
1087
1088	TP_STRUCT__entry(
1089		__field(int, vcpu_id)
1090		__field(u32, sint)
1091		__field(int, vector)
1092		__field(int, ret)
1093	),
1094
1095	TP_fast_assign(
1096		__entry->vcpu_id = vcpu_id;
1097		__entry->vector	= vector;
1098	),
1099
1100	TP_printk("vcpu_id %d vector %d", __entry->vcpu_id, __entry->vector)
1101);
1102
1103/*
1104 * Tracepoint for synic_set_msr.
1105 */
1106TRACE_EVENT(kvm_hv_synic_set_msr,
1107	TP_PROTO(int vcpu_id, u32 msr, u64 data, bool host),
1108	TP_ARGS(vcpu_id, msr, data, host),
1109
1110	TP_STRUCT__entry(
1111		__field(int, vcpu_id)
1112		__field(u32, msr)
1113		__field(u64, data)
1114		__field(bool, host)
1115	),
1116
1117	TP_fast_assign(
1118		__entry->vcpu_id = vcpu_id;
1119		__entry->msr = msr;
1120		__entry->data = data;
1121		__entry->host = host
1122	),
1123
1124	TP_printk("vcpu_id %d msr 0x%x data 0x%llx host %d",
1125		  __entry->vcpu_id, __entry->msr, __entry->data, __entry->host)
1126);
1127
1128/*
1129 * Tracepoint for stimer_set_config.
1130 */
1131TRACE_EVENT(kvm_hv_stimer_set_config,
1132	TP_PROTO(int vcpu_id, int timer_index, u64 config, bool host),
1133	TP_ARGS(vcpu_id, timer_index, config, host),
1134
1135	TP_STRUCT__entry(
1136		__field(int, vcpu_id)
1137		__field(int, timer_index)
1138		__field(u64, config)
1139		__field(bool, host)
1140	),
1141
1142	TP_fast_assign(
1143		__entry->vcpu_id = vcpu_id;
1144		__entry->timer_index = timer_index;
1145		__entry->config = config;
1146		__entry->host = host;
1147	),
1148
1149	TP_printk("vcpu_id %d timer %d config 0x%llx host %d",
1150		  __entry->vcpu_id, __entry->timer_index, __entry->config,
1151		  __entry->host)
1152);
1153
1154/*
1155 * Tracepoint for stimer_set_count.
1156 */
1157TRACE_EVENT(kvm_hv_stimer_set_count,
1158	TP_PROTO(int vcpu_id, int timer_index, u64 count, bool host),
1159	TP_ARGS(vcpu_id, timer_index, count, host),
1160
1161	TP_STRUCT__entry(
1162		__field(int, vcpu_id)
1163		__field(int, timer_index)
1164		__field(u64, count)
1165		__field(bool, host)
1166	),
1167
1168	TP_fast_assign(
1169		__entry->vcpu_id = vcpu_id;
1170		__entry->timer_index = timer_index;
1171		__entry->count = count;
1172		__entry->host = host;
1173	),
1174
1175	TP_printk("vcpu_id %d timer %d count %llu host %d",
1176		  __entry->vcpu_id, __entry->timer_index, __entry->count,
1177		  __entry->host)
1178);
1179
1180/*
1181 * Tracepoint for stimer_start(periodic timer case).
1182 */
1183TRACE_EVENT(kvm_hv_stimer_start_periodic,
1184	TP_PROTO(int vcpu_id, int timer_index, u64 time_now, u64 exp_time),
1185	TP_ARGS(vcpu_id, timer_index, time_now, exp_time),
1186
1187	TP_STRUCT__entry(
1188		__field(int, vcpu_id)
1189		__field(int, timer_index)
1190		__field(u64, time_now)
1191		__field(u64, exp_time)
1192	),
1193
1194	TP_fast_assign(
1195		__entry->vcpu_id = vcpu_id;
1196		__entry->timer_index = timer_index;
1197		__entry->time_now = time_now;
1198		__entry->exp_time = exp_time;
1199	),
1200
1201	TP_printk("vcpu_id %d timer %d time_now %llu exp_time %llu",
1202		  __entry->vcpu_id, __entry->timer_index, __entry->time_now,
1203		  __entry->exp_time)
1204);
1205
1206/*
1207 * Tracepoint for stimer_start(one-shot timer case).
1208 */
1209TRACE_EVENT(kvm_hv_stimer_start_one_shot,
1210	TP_PROTO(int vcpu_id, int timer_index, u64 time_now, u64 count),
1211	TP_ARGS(vcpu_id, timer_index, time_now, count),
1212
1213	TP_STRUCT__entry(
1214		__field(int, vcpu_id)
1215		__field(int, timer_index)
1216		__field(u64, time_now)
1217		__field(u64, count)
1218	),
1219
1220	TP_fast_assign(
1221		__entry->vcpu_id = vcpu_id;
1222		__entry->timer_index = timer_index;
1223		__entry->time_now = time_now;
1224		__entry->count = count;
1225	),
1226
1227	TP_printk("vcpu_id %d timer %d time_now %llu count %llu",
1228		  __entry->vcpu_id, __entry->timer_index, __entry->time_now,
1229		  __entry->count)
1230);
1231
1232/*
1233 * Tracepoint for stimer_timer_callback.
1234 */
1235TRACE_EVENT(kvm_hv_stimer_callback,
1236	TP_PROTO(int vcpu_id, int timer_index),
1237	TP_ARGS(vcpu_id, timer_index),
1238
1239	TP_STRUCT__entry(
1240		__field(int, vcpu_id)
1241		__field(int, timer_index)
1242	),
1243
1244	TP_fast_assign(
1245		__entry->vcpu_id = vcpu_id;
1246		__entry->timer_index = timer_index;
1247	),
1248
1249	TP_printk("vcpu_id %d timer %d",
1250		  __entry->vcpu_id, __entry->timer_index)
1251);
1252
1253/*
1254 * Tracepoint for stimer_expiration.
1255 */
1256TRACE_EVENT(kvm_hv_stimer_expiration,
1257	TP_PROTO(int vcpu_id, int timer_index, int msg_send_result),
1258	TP_ARGS(vcpu_id, timer_index, msg_send_result),
1259
1260	TP_STRUCT__entry(
1261		__field(int, vcpu_id)
1262		__field(int, timer_index)
 
1263		__field(int, msg_send_result)
1264	),
1265
1266	TP_fast_assign(
1267		__entry->vcpu_id = vcpu_id;
1268		__entry->timer_index = timer_index;
 
1269		__entry->msg_send_result = msg_send_result;
1270	),
1271
1272	TP_printk("vcpu_id %d timer %d msg send result %d",
1273		  __entry->vcpu_id, __entry->timer_index,
1274		  __entry->msg_send_result)
1275);
1276
1277/*
1278 * Tracepoint for stimer_cleanup.
1279 */
1280TRACE_EVENT(kvm_hv_stimer_cleanup,
1281	TP_PROTO(int vcpu_id, int timer_index),
1282	TP_ARGS(vcpu_id, timer_index),
1283
1284	TP_STRUCT__entry(
1285		__field(int, vcpu_id)
1286		__field(int, timer_index)
1287	),
1288
1289	TP_fast_assign(
1290		__entry->vcpu_id = vcpu_id;
1291		__entry->timer_index = timer_index;
1292	),
1293
1294	TP_printk("vcpu_id %d timer %d",
1295		  __entry->vcpu_id, __entry->timer_index)
1296);
1297
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1298/*
1299 * Tracepoint for AMD AVIC
1300 */
1301TRACE_EVENT(kvm_avic_incomplete_ipi,
1302	    TP_PROTO(u32 vcpu, u32 icrh, u32 icrl, u32 id, u32 index),
1303	    TP_ARGS(vcpu, icrh, icrl, id, index),
1304
1305	TP_STRUCT__entry(
1306		__field(u32, vcpu)
1307		__field(u32, icrh)
1308		__field(u32, icrl)
1309		__field(u32, id)
1310		__field(u32, index)
1311	),
1312
1313	TP_fast_assign(
1314		__entry->vcpu = vcpu;
1315		__entry->icrh = icrh;
1316		__entry->icrl = icrl;
1317		__entry->id = id;
1318		__entry->index = index;
1319	),
1320
1321	TP_printk("vcpu=%u, icrh:icrl=%#010x:%08x, id=%u, index=%u\n",
1322		  __entry->vcpu, __entry->icrh, __entry->icrl,
1323		  __entry->id, __entry->index)
1324);
1325
1326TRACE_EVENT(kvm_avic_unaccelerated_access,
1327	    TP_PROTO(u32 vcpu, u32 offset, bool ft, bool rw, u32 vec),
1328	    TP_ARGS(vcpu, offset, ft, rw, vec),
1329
1330	TP_STRUCT__entry(
1331		__field(u32, vcpu)
1332		__field(u32, offset)
1333		__field(bool, ft)
1334		__field(bool, rw)
1335		__field(u32, vec)
1336	),
1337
1338	TP_fast_assign(
1339		__entry->vcpu = vcpu;
1340		__entry->offset = offset;
1341		__entry->ft = ft;
1342		__entry->rw = rw;
1343		__entry->vec = vec;
1344	),
1345
1346	TP_printk("vcpu=%u, offset=%#x(%s), %s, %s, vec=%#x\n",
1347		  __entry->vcpu,
1348		  __entry->offset,
1349		  __print_symbolic(__entry->offset, kvm_trace_symbol_apic),
1350		  __entry->ft ? "trap" : "fault",
1351		  __entry->rw ? "write" : "read",
1352		  __entry->vec)
1353);
1354
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1355TRACE_EVENT(kvm_hv_timer_state,
1356		TP_PROTO(unsigned int vcpu_id, unsigned int hv_timer_in_use),
1357		TP_ARGS(vcpu_id, hv_timer_in_use),
1358		TP_STRUCT__entry(
1359			__field(unsigned int, vcpu_id)
1360			__field(unsigned int, hv_timer_in_use)
1361			),
1362		TP_fast_assign(
1363			__entry->vcpu_id = vcpu_id;
1364			__entry->hv_timer_in_use = hv_timer_in_use;
1365			),
1366		TP_printk("vcpu_id %x hv_timer %x\n",
1367			__entry->vcpu_id,
1368			__entry->hv_timer_in_use)
1369);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1370#endif /* _TRACE_KVM_H */
1371
1372#undef TRACE_INCLUDE_PATH
1373#define TRACE_INCLUDE_PATH arch/x86/kvm
1374#undef TRACE_INCLUDE_FILE
1375#define TRACE_INCLUDE_FILE trace
1376
1377/* This part must be outside protection */
1378#include <trace/define_trace.h>