1 /* SPDX-License-Identifier: GPL-2.0 */
2 #if !defined(_TRACE_KVM_H) || defined(TRACE_HEADER_MULTI_READ)
5 #include <linux/tracepoint.h>
8 #include <asm/clocksource.h>
9 #include <asm/pvclock-abi.h>
12 #define TRACE_SYSTEM kvm
15 * Tracepoint for guest mode entry.
17 TRACE_EVENT(kvm_entry
,
18 TP_PROTO(unsigned int vcpu_id
),
22 __field( unsigned int, vcpu_id
)
26 __entry
->vcpu_id
= vcpu_id
;
29 TP_printk("vcpu %u", __entry
->vcpu_id
)
33 * Tracepoint for hypercall.
35 TRACE_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
),
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
)
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
,
62 * Tracepoint for hypercall.
64 TRACE_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
),
70 __field( __u16
, rep_cnt
)
71 __field( __u16
, rep_idx
)
72 __field( __u64
, ingpa
)
73 __field( __u64
, outgpa
)
74 __field( __u16
, code
)
79 __entry
->rep_cnt
= rep_cnt
;
80 __entry
->rep_idx
= rep_idx
;
81 __entry
->ingpa
= ingpa
;
82 __entry
->outgpa
= outgpa
;
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
,
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
),
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
)
115 __entry
->port
= port
;
116 __entry
->size
= size
;
117 __entry
->count
= count
;
119 __entry
->val
= *(unsigned char *)data
;
121 __entry
->val
= *(unsigned short *)data
;
123 __entry
->val
= *(unsigned int *)data
;
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 ? "(...)" : "")
133 * Tracepoint for fast mmio.
135 TRACE_EVENT(kvm_fast_mmio
,
147 TP_printk("fast mmio at gpa 0x%llx", __entry
->gpa
)
151 * Tracepoint for cpuid.
153 TRACE_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
),
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
)
168 __entry
->function
= function
;
173 __entry
->found
= found
;
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")
182 #define AREG(x) { APIC_##x, "APIC_" #x }
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), \
192 * Tracepoint for apic access.
194 TRACE_EVENT(kvm_apic
,
195 TP_PROTO(unsigned int rw
, unsigned int reg
, unsigned int val
),
196 TP_ARGS(rw
, reg
, val
),
199 __field( unsigned int, rw
)
200 __field( unsigned int, reg
)
201 __field( unsigned int, val
)
210 TP_printk("apic_%s %s = 0x%x",
211 __entry
->rw
? "write" : "read",
212 __print_symbolic(__entry
->reg
, kvm_trace_symbol_apic
),
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)
219 #define KVM_ISA_VMX 1
220 #define KVM_ISA_SVM 2
223 * Tracepoint for kvm guest exit:
225 TRACE_EVENT(kvm_exit
,
226 TP_PROTO(unsigned int exit_reason
, struct kvm_vcpu
*vcpu
, u32 isa
),
227 TP_ARGS(exit_reason
, vcpu
, isa
),
230 __field( unsigned int, exit_reason
)
231 __field( unsigned long, guest_rip
)
233 __field( u64
, info1
)
234 __field( u64
, info2
)
238 __entry
->exit_reason
= exit_reason
;
239 __entry
->guest_rip
= kvm_rip_read(vcpu
);
241 kvm_x86_ops
->get_exit_info(vcpu
, &__entry
->info1
,
245 TP_printk("reason %s rip 0x%lx info %llx %llx",
246 (__entry
->isa
== KVM_ISA_VMX
) ?
247 __print_symbolic(__entry
->exit_reason
, VMX_EXIT_REASONS
) :
248 __print_symbolic(__entry
->exit_reason
, SVM_EXIT_REASONS
),
249 __entry
->guest_rip
, __entry
->info1
, __entry
->info2
)
253 * Tracepoint for kvm interrupt injection:
255 TRACE_EVENT(kvm_inj_virq
,
256 TP_PROTO(unsigned int irq
),
260 __field( unsigned int, irq
)
267 TP_printk("irq %u", __entry
->irq
)
270 #define EXS(x) { x##_VECTOR, "#" #x }
272 #define kvm_trace_sym_exc \
273 EXS(DE), EXS(DB), EXS(BP), EXS(OF), EXS(BR), EXS(UD), EXS(NM), \
274 EXS(DF), EXS(TS), EXS(NP), EXS(SS), EXS(GP), EXS(PF), \
275 EXS(MF), EXS(AC), EXS(MC)
278 * Tracepoint for kvm interrupt injection:
280 TRACE_EVENT(kvm_inj_exception
,
281 TP_PROTO(unsigned exception
, bool has_error
, unsigned error_code
),
282 TP_ARGS(exception
, has_error
, error_code
),
285 __field( u8
, exception
)
286 __field( u8
, has_error
)
287 __field( u32
, error_code
)
291 __entry
->exception
= exception
;
292 __entry
->has_error
= has_error
;
293 __entry
->error_code
= error_code
;
296 TP_printk("%s (0x%x)",
297 __print_symbolic(__entry
->exception
, kvm_trace_sym_exc
),
298 /* FIXME: don't print error_code if not present */
299 __entry
->has_error
? __entry
->error_code
: 0)
303 * Tracepoint for page fault.
305 TRACE_EVENT(kvm_page_fault
,
306 TP_PROTO(unsigned long fault_address
, unsigned int error_code
),
307 TP_ARGS(fault_address
, error_code
),
310 __field( unsigned long, fault_address
)
311 __field( unsigned int, error_code
)
315 __entry
->fault_address
= fault_address
;
316 __entry
->error_code
= error_code
;
319 TP_printk("address %lx error_code %x",
320 __entry
->fault_address
, __entry
->error_code
)
324 * Tracepoint for guest MSR access.
327 TP_PROTO(unsigned write
, u32 ecx
, u64 data
, bool exception
),
328 TP_ARGS(write
, ecx
, data
, exception
),
331 __field( unsigned, write
)
334 __field( u8
, exception
)
338 __entry
->write
= write
;
340 __entry
->data
= data
;
341 __entry
->exception
= exception
;
344 TP_printk("msr_%s %x = 0x%llx%s",
345 __entry
->write
? "write" : "read",
346 __entry
->ecx
, __entry
->data
,
347 __entry
->exception
? " (#GP)" : "")
350 #define trace_kvm_msr_read(ecx, data) trace_kvm_msr(0, ecx, data, false)
351 #define trace_kvm_msr_write(ecx, data) trace_kvm_msr(1, ecx, data, false)
352 #define trace_kvm_msr_read_ex(ecx) trace_kvm_msr(0, ecx, 0, true)
353 #define trace_kvm_msr_write_ex(ecx, data) trace_kvm_msr(1, ecx, data, true)
356 * Tracepoint for guest CR access.
359 TP_PROTO(unsigned int rw
, unsigned int cr
, unsigned long val
),
360 TP_ARGS(rw
, cr
, val
),
363 __field( unsigned int, rw
)
364 __field( unsigned int, cr
)
365 __field( unsigned long, val
)
374 TP_printk("cr_%s %x = 0x%lx",
375 __entry
->rw
? "write" : "read",
376 __entry
->cr
, __entry
->val
)
379 #define trace_kvm_cr_read(cr, val) trace_kvm_cr(0, cr, val)
380 #define trace_kvm_cr_write(cr, val) trace_kvm_cr(1, cr, val)
382 TRACE_EVENT(kvm_pic_set_irq
,
383 TP_PROTO(__u8 chip
, __u8 pin
, __u8 elcr
, __u8 imr
, bool coalesced
),
384 TP_ARGS(chip
, pin
, elcr
, imr
, coalesced
),
387 __field( __u8
, chip
)
389 __field( __u8
, elcr
)
391 __field( bool, coalesced
)
395 __entry
->chip
= chip
;
397 __entry
->elcr
= elcr
;
399 __entry
->coalesced
= coalesced
;
402 TP_printk("chip %u pin %u (%s%s)%s",
403 __entry
->chip
, __entry
->pin
,
404 (__entry
->elcr
& (1 << __entry
->pin
)) ? "level":"edge",
405 (__entry
->imr
& (1 << __entry
->pin
)) ? "|masked":"",
406 __entry
->coalesced
? " (coalesced)" : "")
409 #define kvm_apic_dst_shorthand \
413 {0x3, "all-but-self"}
415 TRACE_EVENT(kvm_apic_ipi
,
416 TP_PROTO(__u32 icr_low
, __u32 dest_id
),
417 TP_ARGS(icr_low
, dest_id
),
420 __field( __u32
, icr_low
)
421 __field( __u32
, dest_id
)
425 __entry
->icr_low
= icr_low
;
426 __entry
->dest_id
= dest_id
;
429 TP_printk("dst %x vec %u (%s|%s|%s|%s|%s)",
430 __entry
->dest_id
, (u8
)__entry
->icr_low
,
431 __print_symbolic((__entry
->icr_low
>> 8 & 0x7),
433 (__entry
->icr_low
& (1<<11)) ? "logical" : "physical",
434 (__entry
->icr_low
& (1<<14)) ? "assert" : "de-assert",
435 (__entry
->icr_low
& (1<<15)) ? "level" : "edge",
436 __print_symbolic((__entry
->icr_low
>> 18 & 0x3),
437 kvm_apic_dst_shorthand
))
440 TRACE_EVENT(kvm_apic_accept_irq
,
441 TP_PROTO(__u32 apicid
, __u16 dm
, __u8 tm
, __u8 vec
),
442 TP_ARGS(apicid
, dm
, tm
, vec
),
445 __field( __u32
, apicid
)
452 __entry
->apicid
= apicid
;
458 TP_printk("apicid %x vec %u (%s|%s)",
459 __entry
->apicid
, __entry
->vec
,
460 __print_symbolic((__entry
->dm
>> 8 & 0x7), kvm_deliver_mode
),
461 __entry
->tm
? "level" : "edge")
465 TP_PROTO(struct kvm_lapic
*apic
, int vector
),
466 TP_ARGS(apic
, vector
),
469 __field( __u32
, apicid
)
470 __field( int, vector
)
474 __entry
->apicid
= apic
->vcpu
->vcpu_id
;
475 __entry
->vector
= vector
;
478 TP_printk("apicid %x vector %d", __entry
->apicid
, __entry
->vector
)
481 TRACE_EVENT(kvm_pv_eoi
,
482 TP_PROTO(struct kvm_lapic
*apic
, int vector
),
483 TP_ARGS(apic
, vector
),
486 __field( __u32
, apicid
)
487 __field( int, vector
)
491 __entry
->apicid
= apic
->vcpu
->vcpu_id
;
492 __entry
->vector
= vector
;
495 TP_printk("apicid %x vector %d", __entry
->apicid
, __entry
->vector
)
499 * Tracepoint for nested VMRUN
501 TRACE_EVENT(kvm_nested_vmrun
,
502 TP_PROTO(__u64 rip
, __u64 vmcb
, __u64 nested_rip
, __u32 int_ctl
,
503 __u32 event_inj
, bool npt
),
504 TP_ARGS(rip
, vmcb
, nested_rip
, int_ctl
, event_inj
, npt
),
507 __field( __u64
, rip
)
508 __field( __u64
, vmcb
)
509 __field( __u64
, nested_rip
)
510 __field( __u32
, int_ctl
)
511 __field( __u32
, event_inj
)
517 __entry
->vmcb
= vmcb
;
518 __entry
->nested_rip
= nested_rip
;
519 __entry
->int_ctl
= int_ctl
;
520 __entry
->event_inj
= event_inj
;
524 TP_printk("rip: 0x%016llx vmcb: 0x%016llx nrip: 0x%016llx int_ctl: 0x%08x "
525 "event_inj: 0x%08x npt: %s",
526 __entry
->rip
, __entry
->vmcb
, __entry
->nested_rip
,
527 __entry
->int_ctl
, __entry
->event_inj
,
528 __entry
->npt
? "on" : "off")
531 TRACE_EVENT(kvm_nested_intercepts
,
532 TP_PROTO(__u16 cr_read
, __u16 cr_write
, __u32 exceptions
, __u64 intercept
),
533 TP_ARGS(cr_read
, cr_write
, exceptions
, intercept
),
536 __field( __u16
, cr_read
)
537 __field( __u16
, cr_write
)
538 __field( __u32
, exceptions
)
539 __field( __u64
, intercept
)
543 __entry
->cr_read
= cr_read
;
544 __entry
->cr_write
= cr_write
;
545 __entry
->exceptions
= exceptions
;
546 __entry
->intercept
= intercept
;
549 TP_printk("cr_read: %04x cr_write: %04x excp: %08x intercept: %016llx",
550 __entry
->cr_read
, __entry
->cr_write
, __entry
->exceptions
,
554 * Tracepoint for #VMEXIT while nested
556 TRACE_EVENT(kvm_nested_vmexit
,
557 TP_PROTO(__u64 rip
, __u32 exit_code
,
558 __u64 exit_info1
, __u64 exit_info2
,
559 __u32 exit_int_info
, __u32 exit_int_info_err
, __u32 isa
),
560 TP_ARGS(rip
, exit_code
, exit_info1
, exit_info2
,
561 exit_int_info
, exit_int_info_err
, isa
),
564 __field( __u64
, rip
)
565 __field( __u32
, exit_code
)
566 __field( __u64
, exit_info1
)
567 __field( __u64
, exit_info2
)
568 __field( __u32
, exit_int_info
)
569 __field( __u32
, exit_int_info_err
)
570 __field( __u32
, isa
)
575 __entry
->exit_code
= exit_code
;
576 __entry
->exit_info1
= exit_info1
;
577 __entry
->exit_info2
= exit_info2
;
578 __entry
->exit_int_info
= exit_int_info
;
579 __entry
->exit_int_info_err
= exit_int_info_err
;
582 TP_printk("rip: 0x%016llx reason: %s ext_inf1: 0x%016llx "
583 "ext_inf2: 0x%016llx ext_int: 0x%08x ext_int_err: 0x%08x",
585 (__entry
->isa
== KVM_ISA_VMX
) ?
586 __print_symbolic(__entry
->exit_code
, VMX_EXIT_REASONS
) :
587 __print_symbolic(__entry
->exit_code
, SVM_EXIT_REASONS
),
588 __entry
->exit_info1
, __entry
->exit_info2
,
589 __entry
->exit_int_info
, __entry
->exit_int_info_err
)
593 * Tracepoint for #VMEXIT reinjected to the guest
595 TRACE_EVENT(kvm_nested_vmexit_inject
,
596 TP_PROTO(__u32 exit_code
,
597 __u64 exit_info1
, __u64 exit_info2
,
598 __u32 exit_int_info
, __u32 exit_int_info_err
, __u32 isa
),
599 TP_ARGS(exit_code
, exit_info1
, exit_info2
,
600 exit_int_info
, exit_int_info_err
, isa
),
603 __field( __u32
, exit_code
)
604 __field( __u64
, exit_info1
)
605 __field( __u64
, exit_info2
)
606 __field( __u32
, exit_int_info
)
607 __field( __u32
, exit_int_info_err
)
608 __field( __u32
, isa
)
612 __entry
->exit_code
= exit_code
;
613 __entry
->exit_info1
= exit_info1
;
614 __entry
->exit_info2
= exit_info2
;
615 __entry
->exit_int_info
= exit_int_info
;
616 __entry
->exit_int_info_err
= exit_int_info_err
;
620 TP_printk("reason: %s ext_inf1: 0x%016llx "
621 "ext_inf2: 0x%016llx ext_int: 0x%08x ext_int_err: 0x%08x",
622 (__entry
->isa
== KVM_ISA_VMX
) ?
623 __print_symbolic(__entry
->exit_code
, VMX_EXIT_REASONS
) :
624 __print_symbolic(__entry
->exit_code
, SVM_EXIT_REASONS
),
625 __entry
->exit_info1
, __entry
->exit_info2
,
626 __entry
->exit_int_info
, __entry
->exit_int_info_err
)
630 * Tracepoint for nested #vmexit because of interrupt pending
632 TRACE_EVENT(kvm_nested_intr_vmexit
,
637 __field( __u64
, rip
)
644 TP_printk("rip: 0x%016llx", __entry
->rip
)
648 * Tracepoint for nested #vmexit because of interrupt pending
650 TRACE_EVENT(kvm_invlpga
,
651 TP_PROTO(__u64 rip
, int asid
, u64 address
),
652 TP_ARGS(rip
, asid
, address
),
655 __field( __u64
, rip
)
657 __field( __u64
, address
)
662 __entry
->asid
= asid
;
663 __entry
->address
= address
;
666 TP_printk("rip: 0x%016llx asid: %d address: 0x%016llx",
667 __entry
->rip
, __entry
->asid
, __entry
->address
)
671 * Tracepoint for nested #vmexit because of interrupt pending
673 TRACE_EVENT(kvm_skinit
,
674 TP_PROTO(__u64 rip
, __u32 slb
),
678 __field( __u64
, rip
)
679 __field( __u32
, slb
)
687 TP_printk("rip: 0x%016llx slb: 0x%08x",
688 __entry
->rip
, __entry
->slb
)
691 #define KVM_EMUL_INSN_F_CR0_PE (1 << 0)
692 #define KVM_EMUL_INSN_F_EFL_VM (1 << 1)
693 #define KVM_EMUL_INSN_F_CS_D (1 << 2)
694 #define KVM_EMUL_INSN_F_CS_L (1 << 3)
696 #define kvm_trace_symbol_emul_flags \
698 { KVM_EMUL_INSN_F_CR0_PE \
699 | KVM_EMUL_INSN_F_EFL_VM, "vm16" }, \
700 { KVM_EMUL_INSN_F_CR0_PE, "prot16" }, \
701 { KVM_EMUL_INSN_F_CR0_PE \
702 | KVM_EMUL_INSN_F_CS_D, "prot32" }, \
703 { KVM_EMUL_INSN_F_CR0_PE \
704 | KVM_EMUL_INSN_F_CS_L, "prot64" }
706 #define kei_decode_mode(mode) ({ \
709 case X86EMUL_MODE_REAL: \
712 case X86EMUL_MODE_VM86: \
713 flags = KVM_EMUL_INSN_F_EFL_VM; \
715 case X86EMUL_MODE_PROT16: \
716 flags = KVM_EMUL_INSN_F_CR0_PE; \
718 case X86EMUL_MODE_PROT32: \
719 flags = KVM_EMUL_INSN_F_CR0_PE \
720 | KVM_EMUL_INSN_F_CS_D; \
722 case X86EMUL_MODE_PROT64: \
723 flags = KVM_EMUL_INSN_F_CR0_PE \
724 | KVM_EMUL_INSN_F_CS_L; \
730 TRACE_EVENT(kvm_emulate_insn
,
731 TP_PROTO(struct kvm_vcpu
*vcpu
, __u8 failed
),
732 TP_ARGS(vcpu
, failed
),
735 __field( __u64
, rip
)
736 __field( __u32
, csbase
)
738 __array( __u8
, insn
, 15 )
739 __field( __u8
, flags
)
740 __field( __u8
, failed
)
744 __entry
->csbase
= kvm_x86_ops
->get_segment_base(vcpu
, VCPU_SREG_CS
);
745 __entry
->len
= vcpu
->arch
.emulate_ctxt
.fetch
.ptr
746 - vcpu
->arch
.emulate_ctxt
.fetch
.data
;
747 __entry
->rip
= vcpu
->arch
.emulate_ctxt
._eip
- __entry
->len
;
748 memcpy(__entry
->insn
,
749 vcpu
->arch
.emulate_ctxt
.fetch
.data
,
751 __entry
->flags
= kei_decode_mode(vcpu
->arch
.emulate_ctxt
.mode
);
752 __entry
->failed
= failed
;
755 TP_printk("%x:%llx:%s (%s)%s",
756 __entry
->csbase
, __entry
->rip
,
757 __print_hex(__entry
->insn
, __entry
->len
),
758 __print_symbolic(__entry
->flags
,
759 kvm_trace_symbol_emul_flags
),
760 __entry
->failed
? " failed" : ""
764 #define trace_kvm_emulate_insn_start(vcpu) trace_kvm_emulate_insn(vcpu, 0)
765 #define trace_kvm_emulate_insn_failed(vcpu) trace_kvm_emulate_insn(vcpu, 1)
769 TP_PROTO(gva_t gva
, gpa_t gpa
, bool write
, bool gpa_match
),
770 TP_ARGS(gva
, gpa
, write
, gpa_match
),
776 __field(bool, gpa_match
)
782 __entry
->write
= write
;
783 __entry
->gpa_match
= gpa_match
786 TP_printk("gva %#lx gpa %#llx %s %s", __entry
->gva
, __entry
->gpa
,
787 __entry
->write
? "Write" : "Read",
788 __entry
->gpa_match
? "GPA" : "GVA")
791 TRACE_EVENT(kvm_write_tsc_offset
,
792 TP_PROTO(unsigned int vcpu_id
, __u64 previous_tsc_offset
,
793 __u64 next_tsc_offset
),
794 TP_ARGS(vcpu_id
, previous_tsc_offset
, next_tsc_offset
),
797 __field( unsigned int, vcpu_id
)
798 __field( __u64
, previous_tsc_offset
)
799 __field( __u64
, next_tsc_offset
)
803 __entry
->vcpu_id
= vcpu_id
;
804 __entry
->previous_tsc_offset
= previous_tsc_offset
;
805 __entry
->next_tsc_offset
= next_tsc_offset
;
808 TP_printk("vcpu=%u prev=%llu next=%llu", __entry
->vcpu_id
,
809 __entry
->previous_tsc_offset
, __entry
->next_tsc_offset
)
814 #define host_clocks \
815 {VCLOCK_NONE, "none"}, \
816 {VCLOCK_TSC, "tsc"} \
818 TRACE_EVENT(kvm_update_master_clock,
819 TP_PROTO(bool use_master_clock
, unsigned int host_clock
, bool offset_matched
),
820 TP_ARGS(use_master_clock
, host_clock
, offset_matched
),
823 __field( bool, use_master_clock
)
824 __field( unsigned int, host_clock
)
825 __field( bool, offset_matched
)
829 __entry
->use_master_clock
= use_master_clock
;
830 __entry
->host_clock
= host_clock
;
831 __entry
->offset_matched
= offset_matched
;
834 TP_printk("masterclock %d hostclock %s offsetmatched %u",
835 __entry
->use_master_clock
,
836 __print_symbolic(__entry
->host_clock
, host_clocks
),
837 __entry
->offset_matched
)
840 TRACE_EVENT(kvm_track_tsc
,
841 TP_PROTO(unsigned int vcpu_id
, unsigned int nr_matched
,
842 unsigned int online_vcpus
, bool use_master_clock
,
843 unsigned int host_clock
),
844 TP_ARGS(vcpu_id
, nr_matched
, online_vcpus
, use_master_clock
,
848 __field( unsigned int, vcpu_id
)
849 __field( unsigned int, nr_vcpus_matched_tsc
)
850 __field( unsigned int, online_vcpus
)
851 __field( bool, use_master_clock
)
852 __field( unsigned int, host_clock
)
856 __entry
->vcpu_id
= vcpu_id
;
857 __entry
->nr_vcpus_matched_tsc
= nr_matched
;
858 __entry
->online_vcpus
= online_vcpus
;
859 __entry
->use_master_clock
= use_master_clock
;
860 __entry
->host_clock
= host_clock
;
863 TP_printk("vcpu_id %u masterclock %u offsetmatched %u nr_online %u"
865 __entry
->vcpu_id
, __entry
->use_master_clock
,
866 __entry
->nr_vcpus_matched_tsc
, __entry
->online_vcpus
,
867 __print_symbolic(__entry
->host_clock
, host_clocks
))
870 #endif /* CONFIG_X86_64 */
873 * Tracepoint for PML full VMEXIT.
875 TRACE_EVENT(kvm_pml_full
,
876 TP_PROTO(unsigned int vcpu_id
),
880 __field( unsigned int, vcpu_id
)
884 __entry
->vcpu_id
= vcpu_id
;
887 TP_printk("vcpu %d: PML full", __entry
->vcpu_id
)
890 TRACE_EVENT(kvm_ple_window
,
891 TP_PROTO(bool grow
, unsigned int vcpu_id
, int new, int old
),
892 TP_ARGS(grow
, vcpu_id
, new, old
),
895 __field( bool, grow
)
896 __field( unsigned int, vcpu_id
)
902 __entry
->grow
= grow
;
903 __entry
->vcpu_id
= vcpu_id
;
908 TP_printk("vcpu %u: ple_window %d (%s %d)",
911 __entry
->grow
? "grow" : "shrink",
915 #define trace_kvm_ple_window_grow(vcpu_id, new, old) \
916 trace_kvm_ple_window(true, vcpu_id, new, old)
917 #define trace_kvm_ple_window_shrink(vcpu_id, new, old) \
918 trace_kvm_ple_window(false, vcpu_id, new, old)
920 TRACE_EVENT(kvm_pvclock_update
,
921 TP_PROTO(unsigned int vcpu_id
, struct pvclock_vcpu_time_info
*pvclock
),
922 TP_ARGS(vcpu_id
, pvclock
),
925 __field( unsigned int, vcpu_id
)
926 __field( __u32
, version
)
927 __field( __u64
, tsc_timestamp
)
928 __field( __u64
, system_time
)
929 __field( __u32
, tsc_to_system_mul
)
930 __field( __s8
, tsc_shift
)
931 __field( __u8
, flags
)
935 __entry
->vcpu_id
= vcpu_id
;
936 __entry
->version
= pvclock
->version
;
937 __entry
->tsc_timestamp
= pvclock
->tsc_timestamp
;
938 __entry
->system_time
= pvclock
->system_time
;
939 __entry
->tsc_to_system_mul
= pvclock
->tsc_to_system_mul
;
940 __entry
->tsc_shift
= pvclock
->tsc_shift
;
941 __entry
->flags
= pvclock
->flags
;
944 TP_printk("vcpu_id %u, pvclock { version %u, tsc_timestamp 0x%llx, "
945 "system_time 0x%llx, tsc_to_system_mul 0x%x, tsc_shift %d, "
949 __entry
->tsc_timestamp
,
950 __entry
->system_time
,
951 __entry
->tsc_to_system_mul
,
956 TRACE_EVENT(kvm_wait_lapic_expire
,
957 TP_PROTO(unsigned int vcpu_id
, s64 delta
),
958 TP_ARGS(vcpu_id
, delta
),
961 __field( unsigned int, vcpu_id
)
962 __field( s64
, delta
)
966 __entry
->vcpu_id
= vcpu_id
;
967 __entry
->delta
= delta
;
970 TP_printk("vcpu %u: delta %lld (%s)",
973 __entry
->delta
< 0 ? "early" : "late")
976 TRACE_EVENT(kvm_enter_smm
,
977 TP_PROTO(unsigned int vcpu_id
, u64 smbase
, bool entering
),
978 TP_ARGS(vcpu_id
, smbase
, entering
),
981 __field( unsigned int, vcpu_id
)
982 __field( u64
, smbase
)
983 __field( bool, entering
)
987 __entry
->vcpu_id
= vcpu_id
;
988 __entry
->smbase
= smbase
;
989 __entry
->entering
= entering
;
992 TP_printk("vcpu %u: %s SMM, smbase 0x%llx",
994 __entry
->entering
? "entering" : "leaving",
999 * Tracepoint for VT-d posted-interrupts.
1001 TRACE_EVENT(kvm_pi_irte_update
,
1002 TP_PROTO(unsigned int host_irq
, unsigned int vcpu_id
,
1003 unsigned int gsi
, unsigned int gvec
,
1004 u64 pi_desc_addr
, bool set
),
1005 TP_ARGS(host_irq
, vcpu_id
, gsi
, gvec
, pi_desc_addr
, set
),
1008 __field( unsigned int, host_irq
)
1009 __field( unsigned int, vcpu_id
)
1010 __field( unsigned int, gsi
)
1011 __field( unsigned int, gvec
)
1012 __field( u64
, pi_desc_addr
)
1013 __field( bool, set
)
1017 __entry
->host_irq
= host_irq
;
1018 __entry
->vcpu_id
= vcpu_id
;
1020 __entry
->gvec
= gvec
;
1021 __entry
->pi_desc_addr
= pi_desc_addr
;
1025 TP_printk("VT-d PI is %s for irq %u, vcpu %u, gsi: 0x%x, "
1026 "gvec: 0x%x, pi_desc_addr: 0x%llx",
1027 __entry
->set
? "enabled and being updated" : "disabled",
1032 __entry
->pi_desc_addr
)
1036 * Tracepoint for kvm_hv_notify_acked_sint.
1038 TRACE_EVENT(kvm_hv_notify_acked_sint
,
1039 TP_PROTO(int vcpu_id
, u32 sint
),
1040 TP_ARGS(vcpu_id
, sint
),
1043 __field(int, vcpu_id
)
1048 __entry
->vcpu_id
= vcpu_id
;
1049 __entry
->sint
= sint
;
1052 TP_printk("vcpu_id %d sint %u", __entry
->vcpu_id
, __entry
->sint
)
1056 * Tracepoint for synic_set_irq.
1058 TRACE_EVENT(kvm_hv_synic_set_irq
,
1059 TP_PROTO(int vcpu_id
, u32 sint
, int vector
, int ret
),
1060 TP_ARGS(vcpu_id
, sint
, vector
, ret
),
1063 __field(int, vcpu_id
)
1065 __field(int, vector
)
1070 __entry
->vcpu_id
= vcpu_id
;
1071 __entry
->sint
= sint
;
1072 __entry
->vector
= vector
;
1076 TP_printk("vcpu_id %d sint %u vector %d ret %d",
1077 __entry
->vcpu_id
, __entry
->sint
, __entry
->vector
,
1082 * Tracepoint for kvm_hv_synic_send_eoi.
1084 TRACE_EVENT(kvm_hv_synic_send_eoi
,
1085 TP_PROTO(int vcpu_id
, int vector
),
1086 TP_ARGS(vcpu_id
, vector
),
1089 __field(int, vcpu_id
)
1091 __field(int, vector
)
1096 __entry
->vcpu_id
= vcpu_id
;
1097 __entry
->vector
= vector
;
1100 TP_printk("vcpu_id %d vector %d", __entry
->vcpu_id
, __entry
->vector
)
1104 * Tracepoint for synic_set_msr.
1106 TRACE_EVENT(kvm_hv_synic_set_msr
,
1107 TP_PROTO(int vcpu_id
, u32 msr
, u64 data
, bool host
),
1108 TP_ARGS(vcpu_id
, msr
, data
, host
),
1111 __field(int, vcpu_id
)
1118 __entry
->vcpu_id
= vcpu_id
;
1120 __entry
->data
= data
;
1121 __entry
->host
= host
1124 TP_printk("vcpu_id %d msr 0x%x data 0x%llx host %d",
1125 __entry
->vcpu_id
, __entry
->msr
, __entry
->data
, __entry
->host
)
1129 * Tracepoint for stimer_set_config.
1131 TRACE_EVENT(kvm_hv_stimer_set_config
,
1132 TP_PROTO(int vcpu_id
, int timer_index
, u64 config
, bool host
),
1133 TP_ARGS(vcpu_id
, timer_index
, config
, host
),
1136 __field(int, vcpu_id
)
1137 __field(int, timer_index
)
1138 __field(u64
, config
)
1143 __entry
->vcpu_id
= vcpu_id
;
1144 __entry
->timer_index
= timer_index
;
1145 __entry
->config
= config
;
1146 __entry
->host
= host
;
1149 TP_printk("vcpu_id %d timer %d config 0x%llx host %d",
1150 __entry
->vcpu_id
, __entry
->timer_index
, __entry
->config
,
1155 * Tracepoint for stimer_set_count.
1157 TRACE_EVENT(kvm_hv_stimer_set_count
,
1158 TP_PROTO(int vcpu_id
, int timer_index
, u64 count
, bool host
),
1159 TP_ARGS(vcpu_id
, timer_index
, count
, host
),
1162 __field(int, vcpu_id
)
1163 __field(int, timer_index
)
1169 __entry
->vcpu_id
= vcpu_id
;
1170 __entry
->timer_index
= timer_index
;
1171 __entry
->count
= count
;
1172 __entry
->host
= host
;
1175 TP_printk("vcpu_id %d timer %d count %llu host %d",
1176 __entry
->vcpu_id
, __entry
->timer_index
, __entry
->count
,
1181 * Tracepoint for stimer_start(periodic timer case).
1183 TRACE_EVENT(kvm_hv_stimer_start_periodic
,
1184 TP_PROTO(int vcpu_id
, int timer_index
, u64 time_now
, u64 exp_time
),
1185 TP_ARGS(vcpu_id
, timer_index
, time_now
, exp_time
),
1188 __field(int, vcpu_id
)
1189 __field(int, timer_index
)
1190 __field(u64
, time_now
)
1191 __field(u64
, exp_time
)
1195 __entry
->vcpu_id
= vcpu_id
;
1196 __entry
->timer_index
= timer_index
;
1197 __entry
->time_now
= time_now
;
1198 __entry
->exp_time
= exp_time
;
1201 TP_printk("vcpu_id %d timer %d time_now %llu exp_time %llu",
1202 __entry
->vcpu_id
, __entry
->timer_index
, __entry
->time_now
,
1207 * Tracepoint for stimer_start(one-shot timer case).
1209 TRACE_EVENT(kvm_hv_stimer_start_one_shot
,
1210 TP_PROTO(int vcpu_id
, int timer_index
, u64 time_now
, u64 count
),
1211 TP_ARGS(vcpu_id
, timer_index
, time_now
, count
),
1214 __field(int, vcpu_id
)
1215 __field(int, timer_index
)
1216 __field(u64
, time_now
)
1221 __entry
->vcpu_id
= vcpu_id
;
1222 __entry
->timer_index
= timer_index
;
1223 __entry
->time_now
= time_now
;
1224 __entry
->count
= count
;
1227 TP_printk("vcpu_id %d timer %d time_now %llu count %llu",
1228 __entry
->vcpu_id
, __entry
->timer_index
, __entry
->time_now
,
1233 * Tracepoint for stimer_timer_callback.
1235 TRACE_EVENT(kvm_hv_stimer_callback
,
1236 TP_PROTO(int vcpu_id
, int timer_index
),
1237 TP_ARGS(vcpu_id
, timer_index
),
1240 __field(int, vcpu_id
)
1241 __field(int, timer_index
)
1245 __entry
->vcpu_id
= vcpu_id
;
1246 __entry
->timer_index
= timer_index
;
1249 TP_printk("vcpu_id %d timer %d",
1250 __entry
->vcpu_id
, __entry
->timer_index
)
1254 * Tracepoint for stimer_expiration.
1256 TRACE_EVENT(kvm_hv_stimer_expiration
,
1257 TP_PROTO(int vcpu_id
, int timer_index
, int msg_send_result
),
1258 TP_ARGS(vcpu_id
, timer_index
, msg_send_result
),
1261 __field(int, vcpu_id
)
1262 __field(int, timer_index
)
1263 __field(int, msg_send_result
)
1267 __entry
->vcpu_id
= vcpu_id
;
1268 __entry
->timer_index
= timer_index
;
1269 __entry
->msg_send_result
= msg_send_result
;
1272 TP_printk("vcpu_id %d timer %d msg send result %d",
1273 __entry
->vcpu_id
, __entry
->timer_index
,
1274 __entry
->msg_send_result
)
1278 * Tracepoint for stimer_cleanup.
1280 TRACE_EVENT(kvm_hv_stimer_cleanup
,
1281 TP_PROTO(int vcpu_id
, int timer_index
),
1282 TP_ARGS(vcpu_id
, timer_index
),
1285 __field(int, vcpu_id
)
1286 __field(int, timer_index
)
1290 __entry
->vcpu_id
= vcpu_id
;
1291 __entry
->timer_index
= timer_index
;
1294 TP_printk("vcpu_id %d timer %d",
1295 __entry
->vcpu_id
, __entry
->timer_index
)
1299 * Tracepoint for AMD AVIC
1301 TRACE_EVENT(kvm_avic_incomplete_ipi
,
1302 TP_PROTO(u32 vcpu
, u32 icrh
, u32 icrl
, u32 id
, u32 index
),
1303 TP_ARGS(vcpu
, icrh
, icrl
, id
, index
),
1314 __entry
->vcpu
= vcpu
;
1315 __entry
->icrh
= icrh
;
1316 __entry
->icrl
= icrl
;
1318 __entry
->index
= index
;
1321 TP_printk("vcpu=%u, icrh:icrl=%#010x:%08x, id=%u, index=%u\n",
1322 __entry
->vcpu
, __entry
->icrh
, __entry
->icrl
,
1323 __entry
->id
, __entry
->index
)
1326 TRACE_EVENT(kvm_avic_unaccelerated_access
,
1327 TP_PROTO(u32 vcpu
, u32 offset
, bool ft
, bool rw
, u32 vec
),
1328 TP_ARGS(vcpu
, offset
, ft
, rw
, vec
),
1332 __field(u32
, offset
)
1339 __entry
->vcpu
= vcpu
;
1340 __entry
->offset
= offset
;
1346 TP_printk("vcpu=%u, offset=%#x(%s), %s, %s, vec=%#x\n",
1349 __print_symbolic(__entry
->offset
, kvm_trace_symbol_apic
),
1350 __entry
->ft
? "trap" : "fault",
1351 __entry
->rw
? "write" : "read",
1355 TRACE_EVENT(kvm_hv_timer_state
,
1356 TP_PROTO(unsigned int vcpu_id
, unsigned int hv_timer_in_use
),
1357 TP_ARGS(vcpu_id
, hv_timer_in_use
),
1359 __field(unsigned int, vcpu_id
)
1360 __field(unsigned int, hv_timer_in_use
)
1363 __entry
->vcpu_id
= vcpu_id
;
1364 __entry
->hv_timer_in_use
= hv_timer_in_use
;
1366 TP_printk("vcpu_id %x hv_timer %x\n",
1368 __entry
->hv_timer_in_use
)
1370 #endif /* _TRACE_KVM_H */
1372 #undef TRACE_INCLUDE_PATH
1373 #define TRACE_INCLUDE_PATH arch/x86/kvm
1374 #undef TRACE_INCLUDE_FILE
1375 #define TRACE_INCLUDE_FILE trace
1377 /* This part must be outside protection */
1378 #include <trace/define_trace.h>