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>
v5.4
   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		__field(	unsigned int,	vcpu_id         )
 236	),
 237
 238	TP_fast_assign(
 239		__entry->exit_reason	= exit_reason;
 240		__entry->guest_rip	= kvm_rip_read(vcpu);
 241		__entry->isa            = isa;
 242		__entry->vcpu_id        = vcpu->vcpu_id;
 243		kvm_x86_ops->get_exit_info(vcpu, &__entry->info1,
 244					   &__entry->info2);
 245	),
 246
 247	TP_printk("vcpu %u reason %s rip 0x%lx info %llx %llx",
 248		  __entry->vcpu_id,
 249		 (__entry->isa == KVM_ISA_VMX) ?
 250		 __print_symbolic(__entry->exit_reason, VMX_EXIT_REASONS) :
 251		 __print_symbolic(__entry->exit_reason, SVM_EXIT_REASONS),
 252		 __entry->guest_rip, __entry->info1, __entry->info2)
 253);
 254
 255/*
 256 * Tracepoint for kvm interrupt injection:
 257 */
 258TRACE_EVENT(kvm_inj_virq,
 259	TP_PROTO(unsigned int irq),
 260	TP_ARGS(irq),
 261
 262	TP_STRUCT__entry(
 263		__field(	unsigned int,	irq		)
 
 
 264	),
 265
 266	TP_fast_assign(
 267		__entry->irq		= irq;
 
 
 268	),
 269
 270	TP_printk("irq %u", __entry->irq)
 
 
 271);
 272
 273#define EXS(x) { x##_VECTOR, "#" #x }
 274
 275#define kvm_trace_sym_exc						\
 276	EXS(DE), EXS(DB), EXS(BP), EXS(OF), EXS(BR), EXS(UD), EXS(NM),	\
 277	EXS(DF), EXS(TS), EXS(NP), EXS(SS), EXS(GP), EXS(PF),		\
 278	EXS(MF), EXS(AC), EXS(MC)
 279
 280/*
 281 * Tracepoint for kvm interrupt injection:
 282 */
 283TRACE_EVENT(kvm_inj_exception,
 284	TP_PROTO(unsigned exception, bool has_error, unsigned error_code),
 285	TP_ARGS(exception, has_error, error_code),
 
 286
 287	TP_STRUCT__entry(
 288		__field(	u8,	exception	)
 289		__field(	u8,	has_error	)
 290		__field(	u32,	error_code	)
 
 291	),
 292
 293	TP_fast_assign(
 294		__entry->exception	= exception;
 295		__entry->has_error	= has_error;
 296		__entry->error_code	= error_code;
 
 297	),
 298
 299	TP_printk("%s (0x%x)",
 300		  __print_symbolic(__entry->exception, kvm_trace_sym_exc),
 301		  /* FIXME: don't print error_code if not present */
 302		  __entry->has_error ? __entry->error_code : 0)
 
 
 303);
 304
 305/*
 306 * Tracepoint for page fault.
 307 */
 308TRACE_EVENT(kvm_page_fault,
 309	TP_PROTO(unsigned long fault_address, unsigned int error_code),
 310	TP_ARGS(fault_address, error_code),
 311
 312	TP_STRUCT__entry(
 313		__field(	unsigned long,	fault_address	)
 314		__field(	unsigned int,	error_code	)
 
 
 315	),
 316
 317	TP_fast_assign(
 
 
 318		__entry->fault_address	= fault_address;
 319		__entry->error_code	= error_code;
 320	),
 321
 322	TP_printk("address %lx error_code %x",
 
 323		  __entry->fault_address, __entry->error_code)
 324);
 325
 326/*
 327 * Tracepoint for guest MSR access.
 328 */
 329TRACE_EVENT(kvm_msr,
 330	TP_PROTO(unsigned write, u32 ecx, u64 data, bool exception),
 331	TP_ARGS(write, ecx, data, exception),
 332
 333	TP_STRUCT__entry(
 334		__field(	unsigned,	write		)
 335		__field(	u32,		ecx		)
 336		__field(	u64,		data		)
 337		__field(	u8,		exception	)
 338	),
 339
 340	TP_fast_assign(
 341		__entry->write		= write;
 342		__entry->ecx		= ecx;
 343		__entry->data		= data;
 344		__entry->exception	= exception;
 345	),
 346
 347	TP_printk("msr_%s %x = 0x%llx%s",
 348		  __entry->write ? "write" : "read",
 349		  __entry->ecx, __entry->data,
 350		  __entry->exception ? " (#GP)" : "")
 351);
 352
 353#define trace_kvm_msr_read(ecx, data)      trace_kvm_msr(0, ecx, data, false)
 354#define trace_kvm_msr_write(ecx, data)     trace_kvm_msr(1, ecx, data, false)
 355#define trace_kvm_msr_read_ex(ecx)         trace_kvm_msr(0, ecx, 0, true)
 356#define trace_kvm_msr_write_ex(ecx, data)  trace_kvm_msr(1, ecx, data, true)
 357
 358/*
 359 * Tracepoint for guest CR access.
 360 */
 361TRACE_EVENT(kvm_cr,
 362	TP_PROTO(unsigned int rw, unsigned int cr, unsigned long val),
 363	TP_ARGS(rw, cr, val),
 364
 365	TP_STRUCT__entry(
 366		__field(	unsigned int,	rw		)
 367		__field(	unsigned int,	cr		)
 368		__field(	unsigned long,	val		)
 369	),
 370
 371	TP_fast_assign(
 372		__entry->rw		= rw;
 373		__entry->cr		= cr;
 374		__entry->val		= val;
 375	),
 376
 377	TP_printk("cr_%s %x = 0x%lx",
 378		  __entry->rw ? "write" : "read",
 379		  __entry->cr, __entry->val)
 380);
 381
 382#define trace_kvm_cr_read(cr, val)		trace_kvm_cr(0, cr, val)
 383#define trace_kvm_cr_write(cr, val)		trace_kvm_cr(1, cr, val)
 384
 385TRACE_EVENT(kvm_pic_set_irq,
 386	    TP_PROTO(__u8 chip, __u8 pin, __u8 elcr, __u8 imr, bool coalesced),
 387	    TP_ARGS(chip, pin, elcr, imr, coalesced),
 388
 389	TP_STRUCT__entry(
 390		__field(	__u8,		chip		)
 391		__field(	__u8,		pin		)
 392		__field(	__u8,		elcr		)
 393		__field(	__u8,		imr		)
 394		__field(	bool,		coalesced	)
 395	),
 396
 397	TP_fast_assign(
 398		__entry->chip		= chip;
 399		__entry->pin		= pin;
 400		__entry->elcr		= elcr;
 401		__entry->imr		= imr;
 402		__entry->coalesced	= coalesced;
 403	),
 404
 405	TP_printk("chip %u pin %u (%s%s)%s",
 406		  __entry->chip, __entry->pin,
 407		  (__entry->elcr & (1 << __entry->pin)) ? "level":"edge",
 408		  (__entry->imr & (1 << __entry->pin)) ? "|masked":"",
 409		  __entry->coalesced ? " (coalesced)" : "")
 410);
 411
 412#define kvm_apic_dst_shorthand		\
 413	{0x0, "dst"},			\
 414	{0x1, "self"},			\
 415	{0x2, "all"},			\
 416	{0x3, "all-but-self"}
 417
 418TRACE_EVENT(kvm_apic_ipi,
 419	    TP_PROTO(__u32 icr_low, __u32 dest_id),
 420	    TP_ARGS(icr_low, dest_id),
 421
 422	TP_STRUCT__entry(
 423		__field(	__u32,		icr_low		)
 424		__field(	__u32,		dest_id		)
 425	),
 426
 427	TP_fast_assign(
 428		__entry->icr_low	= icr_low;
 429		__entry->dest_id	= dest_id;
 430	),
 431
 432	TP_printk("dst %x vec %u (%s|%s|%s|%s|%s)",
 433		  __entry->dest_id, (u8)__entry->icr_low,
 434		  __print_symbolic((__entry->icr_low >> 8 & 0x7),
 435				   kvm_deliver_mode),
 436		  (__entry->icr_low & (1<<11)) ? "logical" : "physical",
 437		  (__entry->icr_low & (1<<14)) ? "assert" : "de-assert",
 438		  (__entry->icr_low & (1<<15)) ? "level" : "edge",
 439		  __print_symbolic((__entry->icr_low >> 18 & 0x3),
 440				   kvm_apic_dst_shorthand))
 441);
 442
 443TRACE_EVENT(kvm_apic_accept_irq,
 444	    TP_PROTO(__u32 apicid, __u16 dm, __u16 tm, __u8 vec),
 445	    TP_ARGS(apicid, dm, tm, vec),
 446
 447	TP_STRUCT__entry(
 448		__field(	__u32,		apicid		)
 449		__field(	__u16,		dm		)
 450		__field(	__u16,		tm		)
 451		__field(	__u8,		vec		)
 452	),
 453
 454	TP_fast_assign(
 455		__entry->apicid		= apicid;
 456		__entry->dm		= dm;
 457		__entry->tm		= tm;
 458		__entry->vec		= vec;
 459	),
 460
 461	TP_printk("apicid %x vec %u (%s|%s)",
 462		  __entry->apicid, __entry->vec,
 463		  __print_symbolic((__entry->dm >> 8 & 0x7), kvm_deliver_mode),
 464		  __entry->tm ? "level" : "edge")
 465);
 466
 467TRACE_EVENT(kvm_eoi,
 468	    TP_PROTO(struct kvm_lapic *apic, int vector),
 469	    TP_ARGS(apic, vector),
 470
 471	TP_STRUCT__entry(
 472		__field(	__u32,		apicid		)
 473		__field(	int,		vector		)
 474	),
 475
 476	TP_fast_assign(
 477		__entry->apicid		= apic->vcpu->vcpu_id;
 478		__entry->vector		= vector;
 479	),
 480
 481	TP_printk("apicid %x vector %d", __entry->apicid, __entry->vector)
 482);
 483
 484TRACE_EVENT(kvm_pv_eoi,
 485	    TP_PROTO(struct kvm_lapic *apic, int vector),
 486	    TP_ARGS(apic, vector),
 487
 488	TP_STRUCT__entry(
 489		__field(	__u32,		apicid		)
 490		__field(	int,		vector		)
 491	),
 492
 493	TP_fast_assign(
 494		__entry->apicid		= apic->vcpu->vcpu_id;
 495		__entry->vector		= vector;
 496	),
 497
 498	TP_printk("apicid %x vector %d", __entry->apicid, __entry->vector)
 499);
 500
 501/*
 502 * Tracepoint for nested VMRUN
 503 */
 504TRACE_EVENT(kvm_nested_vmrun,
 505	    TP_PROTO(__u64 rip, __u64 vmcb, __u64 nested_rip, __u32 int_ctl,
 506		     __u32 event_inj, bool npt),
 507	    TP_ARGS(rip, vmcb, nested_rip, int_ctl, event_inj, npt),
 
 
 508
 509	TP_STRUCT__entry(
 510		__field(	__u64,		rip		)
 511		__field(	__u64,		vmcb		)
 512		__field(	__u64,		nested_rip	)
 513		__field(	__u32,		int_ctl		)
 514		__field(	__u32,		event_inj	)
 515		__field(	bool,		npt		)
 
 
 516	),
 517
 518	TP_fast_assign(
 519		__entry->rip		= rip;
 520		__entry->vmcb		= vmcb;
 521		__entry->nested_rip	= nested_rip;
 522		__entry->int_ctl	= int_ctl;
 523		__entry->event_inj	= event_inj;
 524		__entry->npt		= npt;
 
 
 525	),
 526
 527	TP_printk("rip: 0x%016llx vmcb: 0x%016llx nrip: 0x%016llx int_ctl: 0x%08x "
 528		  "event_inj: 0x%08x npt: %s",
 529		__entry->rip, __entry->vmcb, __entry->nested_rip,
 530		__entry->int_ctl, __entry->event_inj,
 531		__entry->npt ? "on" : "off")
 
 
 
 
 
 
 
 
 532);
 533
 534TRACE_EVENT(kvm_nested_intercepts,
 535	    TP_PROTO(__u16 cr_read, __u16 cr_write, __u32 exceptions, __u64 intercept),
 536	    TP_ARGS(cr_read, cr_write, exceptions, intercept),
 
 
 537
 538	TP_STRUCT__entry(
 539		__field(	__u16,		cr_read		)
 540		__field(	__u16,		cr_write	)
 541		__field(	__u32,		exceptions	)
 542		__field(	__u64,		intercept	)
 
 
 543	),
 544
 545	TP_fast_assign(
 546		__entry->cr_read	= cr_read;
 547		__entry->cr_write	= cr_write;
 548		__entry->exceptions	= exceptions;
 549		__entry->intercept	= intercept;
 
 
 550	),
 551
 552	TP_printk("cr_read: %04x cr_write: %04x excp: %08x intercept: %016llx",
 553		__entry->cr_read, __entry->cr_write, __entry->exceptions,
 554		__entry->intercept)
 
 555);
 556/*
 557 * Tracepoint for #VMEXIT while nested
 558 */
 559TRACE_EVENT(kvm_nested_vmexit,
 560	    TP_PROTO(__u64 rip, __u32 exit_code,
 561		     __u64 exit_info1, __u64 exit_info2,
 562		     __u32 exit_int_info, __u32 exit_int_info_err, __u32 isa),
 563	    TP_ARGS(rip, exit_code, exit_info1, exit_info2,
 564		    exit_int_info, exit_int_info_err, isa),
 565
 566	TP_STRUCT__entry(
 567		__field(	__u64,		rip			)
 568		__field(	__u32,		exit_code		)
 569		__field(	__u64,		exit_info1		)
 570		__field(	__u64,		exit_info2		)
 571		__field(	__u32,		exit_int_info		)
 572		__field(	__u32,		exit_int_info_err	)
 573		__field(	__u32,		isa			)
 574	),
 575
 576	TP_fast_assign(
 577		__entry->rip			= rip;
 578		__entry->exit_code		= exit_code;
 579		__entry->exit_info1		= exit_info1;
 580		__entry->exit_info2		= exit_info2;
 581		__entry->exit_int_info		= exit_int_info;
 582		__entry->exit_int_info_err	= exit_int_info_err;
 583		__entry->isa			= isa;
 584	),
 585	TP_printk("rip: 0x%016llx reason: %s ext_inf1: 0x%016llx "
 586		  "ext_inf2: 0x%016llx ext_int: 0x%08x ext_int_err: 0x%08x",
 587		  __entry->rip,
 588		 (__entry->isa == KVM_ISA_VMX) ?
 589		 __print_symbolic(__entry->exit_code, VMX_EXIT_REASONS) :
 590		 __print_symbolic(__entry->exit_code, SVM_EXIT_REASONS),
 591		  __entry->exit_info1, __entry->exit_info2,
 592		  __entry->exit_int_info, __entry->exit_int_info_err)
 593);
 594
 595/*
 596 * Tracepoint for #VMEXIT reinjected to the guest
 597 */
 598TRACE_EVENT(kvm_nested_vmexit_inject,
 599	    TP_PROTO(__u32 exit_code,
 600		     __u64 exit_info1, __u64 exit_info2,
 601		     __u32 exit_int_info, __u32 exit_int_info_err, __u32 isa),
 602	    TP_ARGS(exit_code, exit_info1, exit_info2,
 603		    exit_int_info, exit_int_info_err, isa),
 604
 605	TP_STRUCT__entry(
 606		__field(	__u32,		exit_code		)
 607		__field(	__u64,		exit_info1		)
 608		__field(	__u64,		exit_info2		)
 609		__field(	__u32,		exit_int_info		)
 610		__field(	__u32,		exit_int_info_err	)
 611		__field(	__u32,		isa			)
 612	),
 613
 614	TP_fast_assign(
 615		__entry->exit_code		= exit_code;
 616		__entry->exit_info1		= exit_info1;
 617		__entry->exit_info2		= exit_info2;
 618		__entry->exit_int_info		= exit_int_info;
 619		__entry->exit_int_info_err	= exit_int_info_err;
 620		__entry->isa			= isa;
 621	),
 622
 623	TP_printk("reason: %s ext_inf1: 0x%016llx "
 624		  "ext_inf2: 0x%016llx ext_int: 0x%08x ext_int_err: 0x%08x",
 625		 (__entry->isa == KVM_ISA_VMX) ?
 626		 __print_symbolic(__entry->exit_code, VMX_EXIT_REASONS) :
 627		 __print_symbolic(__entry->exit_code, SVM_EXIT_REASONS),
 628		__entry->exit_info1, __entry->exit_info2,
 629		__entry->exit_int_info, __entry->exit_int_info_err)
 630);
 631
 632/*
 633 * Tracepoint for nested #vmexit because of interrupt pending
 634 */
 635TRACE_EVENT(kvm_nested_intr_vmexit,
 636	    TP_PROTO(__u64 rip),
 637	    TP_ARGS(rip),
 638
 639	TP_STRUCT__entry(
 640		__field(	__u64,	rip	)
 641	),
 642
 643	TP_fast_assign(
 644		__entry->rip	=	rip
 645	),
 646
 647	TP_printk("rip: 0x%016llx", __entry->rip)
 648);
 649
 650/*
 651 * Tracepoint for nested #vmexit because of interrupt pending
 652 */
 653TRACE_EVENT(kvm_invlpga,
 654	    TP_PROTO(__u64 rip, int asid, u64 address),
 655	    TP_ARGS(rip, asid, address),
 656
 657	TP_STRUCT__entry(
 658		__field(	__u64,	rip	)
 659		__field(	int,	asid	)
 660		__field(	__u64,	address	)
 661	),
 662
 663	TP_fast_assign(
 664		__entry->rip		=	rip;
 665		__entry->asid		=	asid;
 666		__entry->address	=	address;
 667	),
 668
 669	TP_printk("rip: 0x%016llx asid: %d address: 0x%016llx",
 670		  __entry->rip, __entry->asid, __entry->address)
 671);
 672
 673/*
 674 * Tracepoint for nested #vmexit because of interrupt pending
 675 */
 676TRACE_EVENT(kvm_skinit,
 677	    TP_PROTO(__u64 rip, __u32 slb),
 678	    TP_ARGS(rip, slb),
 679
 680	TP_STRUCT__entry(
 681		__field(	__u64,	rip	)
 682		__field(	__u32,	slb	)
 683	),
 684
 685	TP_fast_assign(
 686		__entry->rip		=	rip;
 687		__entry->slb		=	slb;
 688	),
 689
 690	TP_printk("rip: 0x%016llx slb: 0x%08x",
 691		  __entry->rip, __entry->slb)
 692);
 693
 694#define KVM_EMUL_INSN_F_CR0_PE (1 << 0)
 695#define KVM_EMUL_INSN_F_EFL_VM (1 << 1)
 696#define KVM_EMUL_INSN_F_CS_D   (1 << 2)
 697#define KVM_EMUL_INSN_F_CS_L   (1 << 3)
 698
 699#define kvm_trace_symbol_emul_flags	                  \
 700	{ 0,   			    "real" },		  \
 701	{ KVM_EMUL_INSN_F_CR0_PE			  \
 702	  | KVM_EMUL_INSN_F_EFL_VM, "vm16" },		  \
 703	{ KVM_EMUL_INSN_F_CR0_PE,   "prot16" },		  \
 704	{ KVM_EMUL_INSN_F_CR0_PE			  \
 705	  | KVM_EMUL_INSN_F_CS_D,   "prot32" },		  \
 706	{ KVM_EMUL_INSN_F_CR0_PE			  \
 707	  | KVM_EMUL_INSN_F_CS_L,   "prot64" }
 708
 709#define kei_decode_mode(mode) ({			\
 710	u8 flags = 0xff;				\
 711	switch (mode) {					\
 712	case X86EMUL_MODE_REAL:				\
 713		flags = 0;				\
 714		break;					\
 715	case X86EMUL_MODE_VM86:				\
 716		flags = KVM_EMUL_INSN_F_EFL_VM;		\
 717		break;					\
 718	case X86EMUL_MODE_PROT16:			\
 719		flags = KVM_EMUL_INSN_F_CR0_PE;		\
 720		break;					\
 721	case X86EMUL_MODE_PROT32:			\
 722		flags = KVM_EMUL_INSN_F_CR0_PE		\
 723			| KVM_EMUL_INSN_F_CS_D;		\
 724		break;					\
 725	case X86EMUL_MODE_PROT64:			\
 726		flags = KVM_EMUL_INSN_F_CR0_PE		\
 727			| KVM_EMUL_INSN_F_CS_L;		\
 728		break;					\
 729	}						\
 730	flags;						\
 731	})
 732
 733TRACE_EVENT(kvm_emulate_insn,
 734	TP_PROTO(struct kvm_vcpu *vcpu, __u8 failed),
 735	TP_ARGS(vcpu, failed),
 736
 737	TP_STRUCT__entry(
 738		__field(    __u64, rip                       )
 739		__field(    __u32, csbase                    )
 740		__field(    __u8,  len                       )
 741		__array(    __u8,  insn,    15	             )
 742		__field(    __u8,  flags       	   	     )
 743		__field(    __u8,  failed                    )
 744		),
 745
 746	TP_fast_assign(
 747		__entry->csbase = kvm_x86_ops->get_segment_base(vcpu, VCPU_SREG_CS);
 748		__entry->len = vcpu->arch.emulate_ctxt.fetch.ptr
 749			       - vcpu->arch.emulate_ctxt.fetch.data;
 750		__entry->rip = vcpu->arch.emulate_ctxt._eip - __entry->len;
 751		memcpy(__entry->insn,
 752		       vcpu->arch.emulate_ctxt.fetch.data,
 753		       15);
 754		__entry->flags = kei_decode_mode(vcpu->arch.emulate_ctxt.mode);
 755		__entry->failed = failed;
 756		),
 757
 758	TP_printk("%x:%llx:%s (%s)%s",
 759		  __entry->csbase, __entry->rip,
 760		  __print_hex(__entry->insn, __entry->len),
 761		  __print_symbolic(__entry->flags,
 762				   kvm_trace_symbol_emul_flags),
 763		  __entry->failed ? " failed" : ""
 764		)
 765	);
 766
 767#define trace_kvm_emulate_insn_start(vcpu) trace_kvm_emulate_insn(vcpu, 0)
 768#define trace_kvm_emulate_insn_failed(vcpu) trace_kvm_emulate_insn(vcpu, 1)
 769
 770TRACE_EVENT(
 771	vcpu_match_mmio,
 772	TP_PROTO(gva_t gva, gpa_t gpa, bool write, bool gpa_match),
 773	TP_ARGS(gva, gpa, write, gpa_match),
 774
 775	TP_STRUCT__entry(
 776		__field(gva_t, gva)
 777		__field(gpa_t, gpa)
 778		__field(bool, write)
 779		__field(bool, gpa_match)
 780		),
 781
 782	TP_fast_assign(
 783		__entry->gva = gva;
 784		__entry->gpa = gpa;
 785		__entry->write = write;
 786		__entry->gpa_match = gpa_match
 787		),
 788
 789	TP_printk("gva %#lx gpa %#llx %s %s", __entry->gva, __entry->gpa,
 790		  __entry->write ? "Write" : "Read",
 791		  __entry->gpa_match ? "GPA" : "GVA")
 792);
 793
 794TRACE_EVENT(kvm_write_tsc_offset,
 795	TP_PROTO(unsigned int vcpu_id, __u64 previous_tsc_offset,
 796		 __u64 next_tsc_offset),
 797	TP_ARGS(vcpu_id, previous_tsc_offset, next_tsc_offset),
 798
 799	TP_STRUCT__entry(
 800		__field( unsigned int,	vcpu_id				)
 801		__field(	__u64,	previous_tsc_offset		)
 802		__field(	__u64,	next_tsc_offset			)
 803	),
 804
 805	TP_fast_assign(
 806		__entry->vcpu_id		= vcpu_id;
 807		__entry->previous_tsc_offset	= previous_tsc_offset;
 808		__entry->next_tsc_offset	= next_tsc_offset;
 809	),
 810
 811	TP_printk("vcpu=%u prev=%llu next=%llu", __entry->vcpu_id,
 812		  __entry->previous_tsc_offset, __entry->next_tsc_offset)
 813);
 814
 815#ifdef CONFIG_X86_64
 816
 817#define host_clocks					\
 818	{VCLOCK_NONE, "none"},				\
 819	{VCLOCK_TSC,  "tsc"}				\
 820
 821TRACE_EVENT(kvm_update_master_clock,
 822	TP_PROTO(bool use_master_clock, unsigned int host_clock, bool offset_matched),
 823	TP_ARGS(use_master_clock, host_clock, offset_matched),
 824
 825	TP_STRUCT__entry(
 826		__field(		bool,	use_master_clock	)
 827		__field(	unsigned int,	host_clock		)
 828		__field(		bool,	offset_matched		)
 829	),
 830
 831	TP_fast_assign(
 832		__entry->use_master_clock	= use_master_clock;
 833		__entry->host_clock		= host_clock;
 834		__entry->offset_matched		= offset_matched;
 835	),
 836
 837	TP_printk("masterclock %d hostclock %s offsetmatched %u",
 838		  __entry->use_master_clock,
 839		  __print_symbolic(__entry->host_clock, host_clocks),
 840		  __entry->offset_matched)
 841);
 842
 843TRACE_EVENT(kvm_track_tsc,
 844	TP_PROTO(unsigned int vcpu_id, unsigned int nr_matched,
 845		 unsigned int online_vcpus, bool use_master_clock,
 846		 unsigned int host_clock),
 847	TP_ARGS(vcpu_id, nr_matched, online_vcpus, use_master_clock,
 848		host_clock),
 849
 850	TP_STRUCT__entry(
 851		__field(	unsigned int,	vcpu_id			)
 852		__field(	unsigned int,	nr_vcpus_matched_tsc	)
 853		__field(	unsigned int,	online_vcpus		)
 854		__field(	bool,		use_master_clock	)
 855		__field(	unsigned int,	host_clock		)
 856	),
 857
 858	TP_fast_assign(
 859		__entry->vcpu_id		= vcpu_id;
 860		__entry->nr_vcpus_matched_tsc	= nr_matched;
 861		__entry->online_vcpus		= online_vcpus;
 862		__entry->use_master_clock	= use_master_clock;
 863		__entry->host_clock		= host_clock;
 864	),
 865
 866	TP_printk("vcpu_id %u masterclock %u offsetmatched %u nr_online %u"
 867		  " hostclock %s",
 868		  __entry->vcpu_id, __entry->use_master_clock,
 869		  __entry->nr_vcpus_matched_tsc, __entry->online_vcpus,
 870		  __print_symbolic(__entry->host_clock, host_clocks))
 871);
 872
 873#endif /* CONFIG_X86_64 */
 874
 875/*
 876 * Tracepoint for PML full VMEXIT.
 877 */
 878TRACE_EVENT(kvm_pml_full,
 879	TP_PROTO(unsigned int vcpu_id),
 880	TP_ARGS(vcpu_id),
 881
 882	TP_STRUCT__entry(
 883		__field(	unsigned int,	vcpu_id			)
 884	),
 885
 886	TP_fast_assign(
 887		__entry->vcpu_id		= vcpu_id;
 888	),
 889
 890	TP_printk("vcpu %d: PML full", __entry->vcpu_id)
 891);
 892
 893TRACE_EVENT(kvm_ple_window_update,
 894	TP_PROTO(unsigned int vcpu_id, unsigned int new, unsigned int old),
 895	TP_ARGS(vcpu_id, new, old),
 896
 897	TP_STRUCT__entry(
 898		__field(        unsigned int,   vcpu_id         )
 899		__field(        unsigned int,       new         )
 900		__field(        unsigned int,       old         )
 901	),
 902
 903	TP_fast_assign(
 904		__entry->vcpu_id        = vcpu_id;
 905		__entry->new            = new;
 906		__entry->old            = old;
 907	),
 908
 909	TP_printk("vcpu %u old %u new %u (%s)",
 910	          __entry->vcpu_id, __entry->old, __entry->new,
 911		  __entry->old < __entry->new ? "growed" : "shrinked")
 912);
 913
 914TRACE_EVENT(kvm_pvclock_update,
 915	TP_PROTO(unsigned int vcpu_id, struct pvclock_vcpu_time_info *pvclock),
 916	TP_ARGS(vcpu_id, pvclock),
 917
 918	TP_STRUCT__entry(
 919		__field(	unsigned int,	vcpu_id			)
 920		__field(	__u32,		version			)
 921		__field(	__u64,		tsc_timestamp		)
 922		__field(	__u64,		system_time		)
 923		__field(	__u32,		tsc_to_system_mul	)
 924		__field(	__s8,		tsc_shift		)
 925		__field(	__u8,		flags			)
 926	),
 927
 928	TP_fast_assign(
 929		__entry->vcpu_id	   = vcpu_id;
 930		__entry->version	   = pvclock->version;
 931		__entry->tsc_timestamp	   = pvclock->tsc_timestamp;
 932		__entry->system_time	   = pvclock->system_time;
 933		__entry->tsc_to_system_mul = pvclock->tsc_to_system_mul;
 934		__entry->tsc_shift	   = pvclock->tsc_shift;
 935		__entry->flags		   = pvclock->flags;
 936	),
 937
 938	TP_printk("vcpu_id %u, pvclock { version %u, tsc_timestamp 0x%llx, "
 939		  "system_time 0x%llx, tsc_to_system_mul 0x%x, tsc_shift %d, "
 940		  "flags 0x%x }",
 941		  __entry->vcpu_id,
 942		  __entry->version,
 943		  __entry->tsc_timestamp,
 944		  __entry->system_time,
 945		  __entry->tsc_to_system_mul,
 946		  __entry->tsc_shift,
 947		  __entry->flags)
 948);
 949
 950TRACE_EVENT(kvm_wait_lapic_expire,
 951	TP_PROTO(unsigned int vcpu_id, s64 delta),
 952	TP_ARGS(vcpu_id, delta),
 953
 954	TP_STRUCT__entry(
 955		__field(	unsigned int,	vcpu_id		)
 956		__field(	s64,		delta		)
 957	),
 958
 959	TP_fast_assign(
 960		__entry->vcpu_id	   = vcpu_id;
 961		__entry->delta             = delta;
 962	),
 963
 964	TP_printk("vcpu %u: delta %lld (%s)",
 965		  __entry->vcpu_id,
 966		  __entry->delta,
 967		  __entry->delta < 0 ? "early" : "late")
 968);
 969
 970TRACE_EVENT(kvm_enter_smm,
 971	TP_PROTO(unsigned int vcpu_id, u64 smbase, bool entering),
 972	TP_ARGS(vcpu_id, smbase, entering),
 973
 974	TP_STRUCT__entry(
 975		__field(	unsigned int,	vcpu_id		)
 976		__field(	u64,		smbase		)
 977		__field(	bool,		entering	)
 978	),
 979
 980	TP_fast_assign(
 981		__entry->vcpu_id	= vcpu_id;
 982		__entry->smbase		= smbase;
 983		__entry->entering	= entering;
 984	),
 985
 986	TP_printk("vcpu %u: %s SMM, smbase 0x%llx",
 987		  __entry->vcpu_id,
 988		  __entry->entering ? "entering" : "leaving",
 989		  __entry->smbase)
 990);
 991
 992/*
 993 * Tracepoint for VT-d posted-interrupts.
 994 */
 995TRACE_EVENT(kvm_pi_irte_update,
 996	TP_PROTO(unsigned int host_irq, unsigned int vcpu_id,
 997		 unsigned int gsi, unsigned int gvec,
 998		 u64 pi_desc_addr, bool set),
 999	TP_ARGS(host_irq, vcpu_id, gsi, gvec, pi_desc_addr, set),
1000
1001	TP_STRUCT__entry(
1002		__field(	unsigned int,	host_irq	)
1003		__field(	unsigned int,	vcpu_id		)
1004		__field(	unsigned int,	gsi		)
1005		__field(	unsigned int,	gvec		)
1006		__field(	u64,		pi_desc_addr	)
1007		__field(	bool,		set		)
1008	),
1009
1010	TP_fast_assign(
1011		__entry->host_irq	= host_irq;
1012		__entry->vcpu_id	= vcpu_id;
1013		__entry->gsi		= gsi;
1014		__entry->gvec		= gvec;
1015		__entry->pi_desc_addr	= pi_desc_addr;
1016		__entry->set		= set;
1017	),
1018
1019	TP_printk("VT-d PI is %s for irq %u, vcpu %u, gsi: 0x%x, "
1020		  "gvec: 0x%x, pi_desc_addr: 0x%llx",
1021		  __entry->set ? "enabled and being updated" : "disabled",
1022		  __entry->host_irq,
1023		  __entry->vcpu_id,
1024		  __entry->gsi,
1025		  __entry->gvec,
1026		  __entry->pi_desc_addr)
1027);
1028
1029/*
1030 * Tracepoint for kvm_hv_notify_acked_sint.
1031 */
1032TRACE_EVENT(kvm_hv_notify_acked_sint,
1033	TP_PROTO(int vcpu_id, u32 sint),
1034	TP_ARGS(vcpu_id, sint),
1035
1036	TP_STRUCT__entry(
1037		__field(int, vcpu_id)
1038		__field(u32, sint)
1039	),
1040
1041	TP_fast_assign(
1042		__entry->vcpu_id = vcpu_id;
1043		__entry->sint = sint;
1044	),
1045
1046	TP_printk("vcpu_id %d sint %u", __entry->vcpu_id, __entry->sint)
1047);
1048
1049/*
1050 * Tracepoint for synic_set_irq.
1051 */
1052TRACE_EVENT(kvm_hv_synic_set_irq,
1053	TP_PROTO(int vcpu_id, u32 sint, int vector, int ret),
1054	TP_ARGS(vcpu_id, sint, vector, ret),
1055
1056	TP_STRUCT__entry(
1057		__field(int, vcpu_id)
1058		__field(u32, sint)
1059		__field(int, vector)
1060		__field(int, ret)
1061	),
1062
1063	TP_fast_assign(
1064		__entry->vcpu_id = vcpu_id;
1065		__entry->sint = sint;
1066		__entry->vector = vector;
1067		__entry->ret = ret;
1068	),
1069
1070	TP_printk("vcpu_id %d sint %u vector %d ret %d",
1071		  __entry->vcpu_id, __entry->sint, __entry->vector,
1072		  __entry->ret)
1073);
1074
1075/*
1076 * Tracepoint for kvm_hv_synic_send_eoi.
1077 */
1078TRACE_EVENT(kvm_hv_synic_send_eoi,
1079	TP_PROTO(int vcpu_id, int vector),
1080	TP_ARGS(vcpu_id, vector),
1081
1082	TP_STRUCT__entry(
1083		__field(int, vcpu_id)
1084		__field(u32, sint)
1085		__field(int, vector)
1086		__field(int, ret)
1087	),
1088
1089	TP_fast_assign(
1090		__entry->vcpu_id = vcpu_id;
1091		__entry->vector	= vector;
1092	),
1093
1094	TP_printk("vcpu_id %d vector %d", __entry->vcpu_id, __entry->vector)
1095);
1096
1097/*
1098 * Tracepoint for synic_set_msr.
1099 */
1100TRACE_EVENT(kvm_hv_synic_set_msr,
1101	TP_PROTO(int vcpu_id, u32 msr, u64 data, bool host),
1102	TP_ARGS(vcpu_id, msr, data, host),
1103
1104	TP_STRUCT__entry(
1105		__field(int, vcpu_id)
1106		__field(u32, msr)
1107		__field(u64, data)
1108		__field(bool, host)
1109	),
1110
1111	TP_fast_assign(
1112		__entry->vcpu_id = vcpu_id;
1113		__entry->msr = msr;
1114		__entry->data = data;
1115		__entry->host = host
1116	),
1117
1118	TP_printk("vcpu_id %d msr 0x%x data 0x%llx host %d",
1119		  __entry->vcpu_id, __entry->msr, __entry->data, __entry->host)
1120);
1121
1122/*
1123 * Tracepoint for stimer_set_config.
1124 */
1125TRACE_EVENT(kvm_hv_stimer_set_config,
1126	TP_PROTO(int vcpu_id, int timer_index, u64 config, bool host),
1127	TP_ARGS(vcpu_id, timer_index, config, host),
1128
1129	TP_STRUCT__entry(
1130		__field(int, vcpu_id)
1131		__field(int, timer_index)
1132		__field(u64, config)
1133		__field(bool, host)
1134	),
1135
1136	TP_fast_assign(
1137		__entry->vcpu_id = vcpu_id;
1138		__entry->timer_index = timer_index;
1139		__entry->config = config;
1140		__entry->host = host;
1141	),
1142
1143	TP_printk("vcpu_id %d timer %d config 0x%llx host %d",
1144		  __entry->vcpu_id, __entry->timer_index, __entry->config,
1145		  __entry->host)
1146);
1147
1148/*
1149 * Tracepoint for stimer_set_count.
1150 */
1151TRACE_EVENT(kvm_hv_stimer_set_count,
1152	TP_PROTO(int vcpu_id, int timer_index, u64 count, bool host),
1153	TP_ARGS(vcpu_id, timer_index, count, host),
1154
1155	TP_STRUCT__entry(
1156		__field(int, vcpu_id)
1157		__field(int, timer_index)
1158		__field(u64, count)
1159		__field(bool, host)
1160	),
1161
1162	TP_fast_assign(
1163		__entry->vcpu_id = vcpu_id;
1164		__entry->timer_index = timer_index;
1165		__entry->count = count;
1166		__entry->host = host;
1167	),
1168
1169	TP_printk("vcpu_id %d timer %d count %llu host %d",
1170		  __entry->vcpu_id, __entry->timer_index, __entry->count,
1171		  __entry->host)
1172);
1173
1174/*
1175 * Tracepoint for stimer_start(periodic timer case).
1176 */
1177TRACE_EVENT(kvm_hv_stimer_start_periodic,
1178	TP_PROTO(int vcpu_id, int timer_index, u64 time_now, u64 exp_time),
1179	TP_ARGS(vcpu_id, timer_index, time_now, exp_time),
1180
1181	TP_STRUCT__entry(
1182		__field(int, vcpu_id)
1183		__field(int, timer_index)
1184		__field(u64, time_now)
1185		__field(u64, exp_time)
1186	),
1187
1188	TP_fast_assign(
1189		__entry->vcpu_id = vcpu_id;
1190		__entry->timer_index = timer_index;
1191		__entry->time_now = time_now;
1192		__entry->exp_time = exp_time;
1193	),
1194
1195	TP_printk("vcpu_id %d timer %d time_now %llu exp_time %llu",
1196		  __entry->vcpu_id, __entry->timer_index, __entry->time_now,
1197		  __entry->exp_time)
1198);
1199
1200/*
1201 * Tracepoint for stimer_start(one-shot timer case).
1202 */
1203TRACE_EVENT(kvm_hv_stimer_start_one_shot,
1204	TP_PROTO(int vcpu_id, int timer_index, u64 time_now, u64 count),
1205	TP_ARGS(vcpu_id, timer_index, time_now, count),
1206
1207	TP_STRUCT__entry(
1208		__field(int, vcpu_id)
1209		__field(int, timer_index)
1210		__field(u64, time_now)
1211		__field(u64, count)
1212	),
1213
1214	TP_fast_assign(
1215		__entry->vcpu_id = vcpu_id;
1216		__entry->timer_index = timer_index;
1217		__entry->time_now = time_now;
1218		__entry->count = count;
1219	),
1220
1221	TP_printk("vcpu_id %d timer %d time_now %llu count %llu",
1222		  __entry->vcpu_id, __entry->timer_index, __entry->time_now,
1223		  __entry->count)
1224);
1225
1226/*
1227 * Tracepoint for stimer_timer_callback.
1228 */
1229TRACE_EVENT(kvm_hv_stimer_callback,
1230	TP_PROTO(int vcpu_id, int timer_index),
1231	TP_ARGS(vcpu_id, timer_index),
1232
1233	TP_STRUCT__entry(
1234		__field(int, vcpu_id)
1235		__field(int, timer_index)
1236	),
1237
1238	TP_fast_assign(
1239		__entry->vcpu_id = vcpu_id;
1240		__entry->timer_index = timer_index;
1241	),
1242
1243	TP_printk("vcpu_id %d timer %d",
1244		  __entry->vcpu_id, __entry->timer_index)
1245);
1246
1247/*
1248 * Tracepoint for stimer_expiration.
1249 */
1250TRACE_EVENT(kvm_hv_stimer_expiration,
1251	TP_PROTO(int vcpu_id, int timer_index, int direct, int msg_send_result),
1252	TP_ARGS(vcpu_id, timer_index, direct, msg_send_result),
1253
1254	TP_STRUCT__entry(
1255		__field(int, vcpu_id)
1256		__field(int, timer_index)
1257		__field(int, direct)
1258		__field(int, msg_send_result)
1259	),
1260
1261	TP_fast_assign(
1262		__entry->vcpu_id = vcpu_id;
1263		__entry->timer_index = timer_index;
1264		__entry->direct = direct;
1265		__entry->msg_send_result = msg_send_result;
1266	),
1267
1268	TP_printk("vcpu_id %d timer %d direct %d send result %d",
1269		  __entry->vcpu_id, __entry->timer_index,
1270		  __entry->direct, __entry->msg_send_result)
1271);
1272
1273/*
1274 * Tracepoint for stimer_cleanup.
1275 */
1276TRACE_EVENT(kvm_hv_stimer_cleanup,
1277	TP_PROTO(int vcpu_id, int timer_index),
1278	TP_ARGS(vcpu_id, timer_index),
1279
1280	TP_STRUCT__entry(
1281		__field(int, vcpu_id)
1282		__field(int, timer_index)
1283	),
1284
1285	TP_fast_assign(
1286		__entry->vcpu_id = vcpu_id;
1287		__entry->timer_index = timer_index;
1288	),
1289
1290	TP_printk("vcpu_id %d timer %d",
1291		  __entry->vcpu_id, __entry->timer_index)
1292);
1293
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1294/*
1295 * Tracepoint for AMD AVIC
1296 */
1297TRACE_EVENT(kvm_avic_incomplete_ipi,
1298	    TP_PROTO(u32 vcpu, u32 icrh, u32 icrl, u32 id, u32 index),
1299	    TP_ARGS(vcpu, icrh, icrl, id, index),
1300
1301	TP_STRUCT__entry(
1302		__field(u32, vcpu)
1303		__field(u32, icrh)
1304		__field(u32, icrl)
1305		__field(u32, id)
1306		__field(u32, index)
1307	),
1308
1309	TP_fast_assign(
1310		__entry->vcpu = vcpu;
1311		__entry->icrh = icrh;
1312		__entry->icrl = icrl;
1313		__entry->id = id;
1314		__entry->index = index;
1315	),
1316
1317	TP_printk("vcpu=%u, icrh:icrl=%#010x:%08x, id=%u, index=%u",
1318		  __entry->vcpu, __entry->icrh, __entry->icrl,
1319		  __entry->id, __entry->index)
1320);
1321
1322TRACE_EVENT(kvm_avic_unaccelerated_access,
1323	    TP_PROTO(u32 vcpu, u32 offset, bool ft, bool rw, u32 vec),
1324	    TP_ARGS(vcpu, offset, ft, rw, vec),
1325
1326	TP_STRUCT__entry(
1327		__field(u32, vcpu)
1328		__field(u32, offset)
1329		__field(bool, ft)
1330		__field(bool, rw)
1331		__field(u32, vec)
1332	),
1333
1334	TP_fast_assign(
1335		__entry->vcpu = vcpu;
1336		__entry->offset = offset;
1337		__entry->ft = ft;
1338		__entry->rw = rw;
1339		__entry->vec = vec;
1340	),
1341
1342	TP_printk("vcpu=%u, offset=%#x(%s), %s, %s, vec=%#x",
1343		  __entry->vcpu,
1344		  __entry->offset,
1345		  __print_symbolic(__entry->offset, kvm_trace_symbol_apic),
1346		  __entry->ft ? "trap" : "fault",
1347		  __entry->rw ? "write" : "read",
1348		  __entry->vec)
1349);
1350
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1351TRACE_EVENT(kvm_hv_timer_state,
1352		TP_PROTO(unsigned int vcpu_id, unsigned int hv_timer_in_use),
1353		TP_ARGS(vcpu_id, hv_timer_in_use),
1354		TP_STRUCT__entry(
1355			__field(unsigned int, vcpu_id)
1356			__field(unsigned int, hv_timer_in_use)
1357			),
1358		TP_fast_assign(
1359			__entry->vcpu_id = vcpu_id;
1360			__entry->hv_timer_in_use = hv_timer_in_use;
1361			),
1362		TP_printk("vcpu_id %x hv_timer %x",
1363			__entry->vcpu_id,
1364			__entry->hv_timer_in_use)
1365);
1366
1367/*
1368 * Tracepoint for kvm_hv_flush_tlb.
1369 */
1370TRACE_EVENT(kvm_hv_flush_tlb,
1371	TP_PROTO(u64 processor_mask, u64 address_space, u64 flags),
1372	TP_ARGS(processor_mask, address_space, flags),
1373
1374	TP_STRUCT__entry(
1375		__field(u64, processor_mask)
1376		__field(u64, address_space)
1377		__field(u64, flags)
 
1378	),
1379
1380	TP_fast_assign(
1381		__entry->processor_mask = processor_mask;
1382		__entry->address_space = address_space;
1383		__entry->flags = flags;
 
1384	),
1385
1386	TP_printk("processor_mask 0x%llx address_space 0x%llx flags 0x%llx",
1387		  __entry->processor_mask, __entry->address_space,
1388		  __entry->flags)
1389);
1390
1391/*
1392 * Tracepoint for kvm_hv_flush_tlb_ex.
1393 */
1394TRACE_EVENT(kvm_hv_flush_tlb_ex,
1395	TP_PROTO(u64 valid_bank_mask, u64 format, u64 address_space, u64 flags),
1396	TP_ARGS(valid_bank_mask, format, address_space, flags),
1397
1398	TP_STRUCT__entry(
1399		__field(u64, valid_bank_mask)
1400		__field(u64, format)
1401		__field(u64, address_space)
1402		__field(u64, flags)
 
1403	),
1404
1405	TP_fast_assign(
1406		__entry->valid_bank_mask = valid_bank_mask;
1407		__entry->format = format;
1408		__entry->address_space = address_space;
1409		__entry->flags = flags;
 
1410	),
1411
1412	TP_printk("valid_bank_mask 0x%llx format 0x%llx "
1413		  "address_space 0x%llx flags 0x%llx",
1414		  __entry->valid_bank_mask, __entry->format,
1415		  __entry->address_space, __entry->flags)
 
1416);
1417
1418/*
1419 * Tracepoints for kvm_hv_send_ipi.
1420 */
1421TRACE_EVENT(kvm_hv_send_ipi,
1422	TP_PROTO(u32 vector, u64 processor_mask),
1423	TP_ARGS(vector, processor_mask),
1424
1425	TP_STRUCT__entry(
1426		__field(u32, vector)
1427		__field(u64, processor_mask)
1428	),
1429
1430	TP_fast_assign(
1431		__entry->vector = vector;
1432		__entry->processor_mask = processor_mask;
1433	),
1434
1435	TP_printk("vector %x processor_mask 0x%llx",
1436		  __entry->vector, __entry->processor_mask)
1437);
1438
1439TRACE_EVENT(kvm_hv_send_ipi_ex,
1440	TP_PROTO(u32 vector, u64 format, u64 valid_bank_mask),
1441	TP_ARGS(vector, format, valid_bank_mask),
1442
1443	TP_STRUCT__entry(
1444		__field(u32, vector)
1445		__field(u64, format)
1446		__field(u64, valid_bank_mask)
1447	),
1448
1449	TP_fast_assign(
1450		__entry->vector = vector;
1451		__entry->format = format;
1452		__entry->valid_bank_mask = valid_bank_mask;
1453	),
1454
1455	TP_printk("vector %x format %llx valid_bank_mask 0x%llx",
1456		  __entry->vector, __entry->format,
1457		  __entry->valid_bank_mask)
1458);
1459
1460TRACE_EVENT(kvm_pv_tlb_flush,
1461	TP_PROTO(unsigned int vcpu_id, bool need_flush_tlb),
1462	TP_ARGS(vcpu_id, need_flush_tlb),
1463
1464	TP_STRUCT__entry(
1465		__field(	unsigned int,	vcpu_id		)
1466		__field(	bool,	need_flush_tlb		)
1467	),
1468
1469	TP_fast_assign(
1470		__entry->vcpu_id	= vcpu_id;
1471		__entry->need_flush_tlb = need_flush_tlb;
1472	),
1473
1474	TP_printk("vcpu %u need_flush_tlb %s", __entry->vcpu_id,
1475		__entry->need_flush_tlb ? "true" : "false")
1476);
1477
1478/*
1479 * Tracepoint for failed nested VMX VM-Enter.
1480 */
1481TRACE_EVENT(kvm_nested_vmenter_failed,
1482	TP_PROTO(const char *msg, u32 err),
1483	TP_ARGS(msg, err),
1484
1485	TP_STRUCT__entry(
1486		__field(const char *, msg)
1487		__field(u32, err)
1488	),
1489
1490	TP_fast_assign(
1491		__entry->msg = msg;
1492		__entry->err = err;
1493	),
1494
1495	TP_printk("%s%s", __entry->msg, !__entry->err ? "" :
1496		__print_symbolic(__entry->err, VMX_VMENTER_INSTRUCTION_ERRORS))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1497);
1498
1499#endif /* _TRACE_KVM_H */
1500
1501#undef TRACE_INCLUDE_PATH
1502#define TRACE_INCLUDE_PATH ../../arch/x86/kvm
1503#undef TRACE_INCLUDE_FILE
1504#define TRACE_INCLUDE_FILE trace
1505
1506/* This part must be outside protection */
1507#include <trace/define_trace.h>