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 int index, unsigned long rax,
155 unsigned long rbx, unsigned long rcx, unsigned long rdx,
156 bool found, bool used_max_basic),
157 TP_ARGS(function, index, rax, rbx, rcx, rdx, found, used_max_basic),
160 __field( unsigned int, function )
161 __field( unsigned int, index )
162 __field( unsigned long, rax )
163 __field( unsigned long, rbx )
164 __field( unsigned long, rcx )
165 __field( unsigned long, rdx )
166 __field( bool, found )
167 __field( bool, used_max_basic )
171 __entry->function = function;
172 __entry->index = index;
177 __entry->found = found;
178 __entry->used_max_basic = used_max_basic;
181 TP_printk("func %x idx %x rax %lx rbx %lx rcx %lx rdx %lx, cpuid entry %s%s",
182 __entry->function, __entry->index, __entry->rax,
183 __entry->rbx, __entry->rcx, __entry->rdx,
184 __entry->found ? "found" : "not found",
185 __entry->used_max_basic ? ", used max basic" : "")
188 #define AREG(x) { APIC_##x, "APIC_" #x }
190 #define kvm_trace_symbol_apic \
191 AREG(ID), AREG(LVR), AREG(TASKPRI), AREG(ARBPRI), AREG(PROCPRI), \
192 AREG(EOI), AREG(RRR), AREG(LDR), AREG(DFR), AREG(SPIV), AREG(ISR), \
193 AREG(TMR), AREG(IRR), AREG(ESR), AREG(ICR), AREG(ICR2), AREG(LVTT), \
194 AREG(LVTTHMR), AREG(LVTPC), AREG(LVT0), AREG(LVT1), AREG(LVTERR), \
195 AREG(TMICT), AREG(TMCCT), AREG(TDCR), AREG(SELF_IPI), AREG(EFEAT), \
198 * Tracepoint for apic access.
200 TRACE_EVENT(kvm_apic,
201 TP_PROTO(unsigned int rw, unsigned int reg, unsigned int val),
202 TP_ARGS(rw, reg, val),
205 __field( unsigned int, rw )
206 __field( unsigned int, reg )
207 __field( unsigned int, val )
216 TP_printk("apic_%s %s = 0x%x",
217 __entry->rw ? "write" : "read",
218 __print_symbolic(__entry->reg, kvm_trace_symbol_apic),
222 #define trace_kvm_apic_read(reg, val) trace_kvm_apic(0, reg, val)
223 #define trace_kvm_apic_write(reg, val) trace_kvm_apic(1, reg, val)
225 #define KVM_ISA_VMX 1
226 #define KVM_ISA_SVM 2
228 #define kvm_print_exit_reason(exit_reason, isa) \
229 (isa == KVM_ISA_VMX) ? \
230 __print_symbolic(exit_reason & 0xffff, VMX_EXIT_REASONS) : \
231 __print_symbolic(exit_reason, SVM_EXIT_REASONS), \
232 (isa == KVM_ISA_VMX && exit_reason & ~0xffff) ? " " : "", \
233 (isa == KVM_ISA_VMX) ? \
234 __print_flags(exit_reason & ~0xffff, " ", VMX_EXIT_REASON_FLAGS) : ""
237 * Tracepoint for kvm guest exit:
239 TRACE_EVENT(kvm_exit,
240 TP_PROTO(unsigned int exit_reason, struct kvm_vcpu *vcpu, u32 isa),
241 TP_ARGS(exit_reason, vcpu, isa),
244 __field( unsigned int, exit_reason )
245 __field( unsigned long, guest_rip )
247 __field( u64, info1 )
248 __field( u64, info2 )
249 __field( unsigned int, vcpu_id )
253 __entry->exit_reason = exit_reason;
254 __entry->guest_rip = kvm_rip_read(vcpu);
256 __entry->vcpu_id = vcpu->vcpu_id;
257 kvm_x86_ops.get_exit_info(vcpu, &__entry->info1,
261 TP_printk("vcpu %u reason %s%s%s rip 0x%lx info %llx %llx",
263 kvm_print_exit_reason(__entry->exit_reason, __entry->isa),
264 __entry->guest_rip, __entry->info1, __entry->info2)
268 * Tracepoint for kvm interrupt injection:
270 TRACE_EVENT(kvm_inj_virq,
271 TP_PROTO(unsigned int irq),
275 __field( unsigned int, irq )
282 TP_printk("irq %u", __entry->irq)
285 #define EXS(x) { x##_VECTOR, "#" #x }
287 #define kvm_trace_sym_exc \
288 EXS(DE), EXS(DB), EXS(BP), EXS(OF), EXS(BR), EXS(UD), EXS(NM), \
289 EXS(DF), EXS(TS), EXS(NP), EXS(SS), EXS(GP), EXS(PF), \
290 EXS(MF), EXS(AC), EXS(MC)
293 * Tracepoint for kvm interrupt injection:
295 TRACE_EVENT(kvm_inj_exception,
296 TP_PROTO(unsigned exception, bool has_error, unsigned error_code),
297 TP_ARGS(exception, has_error, error_code),
300 __field( u8, exception )
301 __field( u8, has_error )
302 __field( u32, error_code )
306 __entry->exception = exception;
307 __entry->has_error = has_error;
308 __entry->error_code = error_code;
311 TP_printk("%s (0x%x)",
312 __print_symbolic(__entry->exception, kvm_trace_sym_exc),
313 /* FIXME: don't print error_code if not present */
314 __entry->has_error ? __entry->error_code : 0)
318 * Tracepoint for page fault.
320 TRACE_EVENT(kvm_page_fault,
321 TP_PROTO(unsigned long fault_address, unsigned int error_code),
322 TP_ARGS(fault_address, error_code),
325 __field( unsigned long, fault_address )
326 __field( unsigned int, error_code )
330 __entry->fault_address = fault_address;
331 __entry->error_code = error_code;
334 TP_printk("address %lx error_code %x",
335 __entry->fault_address, __entry->error_code)
339 * Tracepoint for guest MSR access.
342 TP_PROTO(unsigned write, u32 ecx, u64 data, bool exception),
343 TP_ARGS(write, ecx, data, exception),
346 __field( unsigned, write )
349 __field( u8, exception )
353 __entry->write = write;
355 __entry->data = data;
356 __entry->exception = exception;
359 TP_printk("msr_%s %x = 0x%llx%s",
360 __entry->write ? "write" : "read",
361 __entry->ecx, __entry->data,
362 __entry->exception ? " (#GP)" : "")
365 #define trace_kvm_msr_read(ecx, data) trace_kvm_msr(0, ecx, data, false)
366 #define trace_kvm_msr_write(ecx, data) trace_kvm_msr(1, ecx, data, false)
367 #define trace_kvm_msr_read_ex(ecx) trace_kvm_msr(0, ecx, 0, true)
368 #define trace_kvm_msr_write_ex(ecx, data) trace_kvm_msr(1, ecx, data, true)
371 * Tracepoint for guest CR access.
374 TP_PROTO(unsigned int rw, unsigned int cr, unsigned long val),
375 TP_ARGS(rw, cr, val),
378 __field( unsigned int, rw )
379 __field( unsigned int, cr )
380 __field( unsigned long, val )
389 TP_printk("cr_%s %x = 0x%lx",
390 __entry->rw ? "write" : "read",
391 __entry->cr, __entry->val)
394 #define trace_kvm_cr_read(cr, val) trace_kvm_cr(0, cr, val)
395 #define trace_kvm_cr_write(cr, val) trace_kvm_cr(1, cr, val)
397 TRACE_EVENT(kvm_pic_set_irq,
398 TP_PROTO(__u8 chip, __u8 pin, __u8 elcr, __u8 imr, bool coalesced),
399 TP_ARGS(chip, pin, elcr, imr, coalesced),
402 __field( __u8, chip )
404 __field( __u8, elcr )
406 __field( bool, coalesced )
410 __entry->chip = chip;
412 __entry->elcr = elcr;
414 __entry->coalesced = coalesced;
417 TP_printk("chip %u pin %u (%s%s)%s",
418 __entry->chip, __entry->pin,
419 (__entry->elcr & (1 << __entry->pin)) ? "level":"edge",
420 (__entry->imr & (1 << __entry->pin)) ? "|masked":"",
421 __entry->coalesced ? " (coalesced)" : "")
424 #define kvm_apic_dst_shorthand \
428 {0x3, "all-but-self"}
430 TRACE_EVENT(kvm_apic_ipi,
431 TP_PROTO(__u32 icr_low, __u32 dest_id),
432 TP_ARGS(icr_low, dest_id),
435 __field( __u32, icr_low )
436 __field( __u32, dest_id )
440 __entry->icr_low = icr_low;
441 __entry->dest_id = dest_id;
444 TP_printk("dst %x vec %u (%s|%s|%s|%s|%s)",
445 __entry->dest_id, (u8)__entry->icr_low,
446 __print_symbolic((__entry->icr_low >> 8 & 0x7),
448 (__entry->icr_low & (1<<11)) ? "logical" : "physical",
449 (__entry->icr_low & (1<<14)) ? "assert" : "de-assert",
450 (__entry->icr_low & (1<<15)) ? "level" : "edge",
451 __print_symbolic((__entry->icr_low >> 18 & 0x3),
452 kvm_apic_dst_shorthand))
455 TRACE_EVENT(kvm_apic_accept_irq,
456 TP_PROTO(__u32 apicid, __u16 dm, __u16 tm, __u8 vec),
457 TP_ARGS(apicid, dm, tm, vec),
460 __field( __u32, apicid )
467 __entry->apicid = apicid;
473 TP_printk("apicid %x vec %u (%s|%s)",
474 __entry->apicid, __entry->vec,
475 __print_symbolic((__entry->dm >> 8 & 0x7), kvm_deliver_mode),
476 __entry->tm ? "level" : "edge")
480 TP_PROTO(struct kvm_lapic *apic, int vector),
481 TP_ARGS(apic, vector),
484 __field( __u32, apicid )
485 __field( int, vector )
489 __entry->apicid = apic->vcpu->vcpu_id;
490 __entry->vector = vector;
493 TP_printk("apicid %x vector %d", __entry->apicid, __entry->vector)
496 TRACE_EVENT(kvm_pv_eoi,
497 TP_PROTO(struct kvm_lapic *apic, int vector),
498 TP_ARGS(apic, vector),
501 __field( __u32, apicid )
502 __field( int, vector )
506 __entry->apicid = apic->vcpu->vcpu_id;
507 __entry->vector = vector;
510 TP_printk("apicid %x vector %d", __entry->apicid, __entry->vector)
514 * Tracepoint for nested VMRUN
516 TRACE_EVENT(kvm_nested_vmrun,
517 TP_PROTO(__u64 rip, __u64 vmcb, __u64 nested_rip, __u32 int_ctl,
518 __u32 event_inj, bool npt),
519 TP_ARGS(rip, vmcb, nested_rip, int_ctl, event_inj, npt),
522 __field( __u64, rip )
523 __field( __u64, vmcb )
524 __field( __u64, nested_rip )
525 __field( __u32, int_ctl )
526 __field( __u32, event_inj )
532 __entry->vmcb = vmcb;
533 __entry->nested_rip = nested_rip;
534 __entry->int_ctl = int_ctl;
535 __entry->event_inj = event_inj;
539 TP_printk("rip: 0x%016llx vmcb: 0x%016llx nrip: 0x%016llx int_ctl: 0x%08x "
540 "event_inj: 0x%08x npt: %s",
541 __entry->rip, __entry->vmcb, __entry->nested_rip,
542 __entry->int_ctl, __entry->event_inj,
543 __entry->npt ? "on" : "off")
546 TRACE_EVENT(kvm_nested_intercepts,
547 TP_PROTO(__u16 cr_read, __u16 cr_write, __u32 exceptions, __u64 intercept),
548 TP_ARGS(cr_read, cr_write, exceptions, intercept),
551 __field( __u16, cr_read )
552 __field( __u16, cr_write )
553 __field( __u32, exceptions )
554 __field( __u64, intercept )
558 __entry->cr_read = cr_read;
559 __entry->cr_write = cr_write;
560 __entry->exceptions = exceptions;
561 __entry->intercept = intercept;
564 TP_printk("cr_read: %04x cr_write: %04x excp: %08x intercept: %016llx",
565 __entry->cr_read, __entry->cr_write, __entry->exceptions,
569 * Tracepoint for #VMEXIT while nested
571 TRACE_EVENT(kvm_nested_vmexit,
572 TP_PROTO(__u64 rip, __u32 exit_code,
573 __u64 exit_info1, __u64 exit_info2,
574 __u32 exit_int_info, __u32 exit_int_info_err, __u32 isa),
575 TP_ARGS(rip, exit_code, exit_info1, exit_info2,
576 exit_int_info, exit_int_info_err, isa),
579 __field( __u64, rip )
580 __field( __u32, exit_code )
581 __field( __u64, exit_info1 )
582 __field( __u64, exit_info2 )
583 __field( __u32, exit_int_info )
584 __field( __u32, exit_int_info_err )
585 __field( __u32, isa )
590 __entry->exit_code = exit_code;
591 __entry->exit_info1 = exit_info1;
592 __entry->exit_info2 = exit_info2;
593 __entry->exit_int_info = exit_int_info;
594 __entry->exit_int_info_err = exit_int_info_err;
597 TP_printk("rip: 0x%016llx reason: %s%s%s ext_inf1: 0x%016llx "
598 "ext_inf2: 0x%016llx ext_int: 0x%08x ext_int_err: 0x%08x",
600 kvm_print_exit_reason(__entry->exit_code, __entry->isa),
601 __entry->exit_info1, __entry->exit_info2,
602 __entry->exit_int_info, __entry->exit_int_info_err)
606 * Tracepoint for #VMEXIT reinjected to the guest
608 TRACE_EVENT(kvm_nested_vmexit_inject,
609 TP_PROTO(__u32 exit_code,
610 __u64 exit_info1, __u64 exit_info2,
611 __u32 exit_int_info, __u32 exit_int_info_err, __u32 isa),
612 TP_ARGS(exit_code, exit_info1, exit_info2,
613 exit_int_info, exit_int_info_err, isa),
616 __field( __u32, exit_code )
617 __field( __u64, exit_info1 )
618 __field( __u64, exit_info2 )
619 __field( __u32, exit_int_info )
620 __field( __u32, exit_int_info_err )
621 __field( __u32, isa )
625 __entry->exit_code = exit_code;
626 __entry->exit_info1 = exit_info1;
627 __entry->exit_info2 = exit_info2;
628 __entry->exit_int_info = exit_int_info;
629 __entry->exit_int_info_err = exit_int_info_err;
633 TP_printk("reason: %s%s%s ext_inf1: 0x%016llx "
634 "ext_inf2: 0x%016llx ext_int: 0x%08x ext_int_err: 0x%08x",
635 kvm_print_exit_reason(__entry->exit_code, __entry->isa),
636 __entry->exit_info1, __entry->exit_info2,
637 __entry->exit_int_info, __entry->exit_int_info_err)
641 * Tracepoint for nested #vmexit because of interrupt pending
643 TRACE_EVENT(kvm_nested_intr_vmexit,
648 __field( __u64, rip )
655 TP_printk("rip: 0x%016llx", __entry->rip)
659 * Tracepoint for nested #vmexit because of interrupt pending
661 TRACE_EVENT(kvm_invlpga,
662 TP_PROTO(__u64 rip, int asid, u64 address),
663 TP_ARGS(rip, asid, address),
666 __field( __u64, rip )
668 __field( __u64, address )
673 __entry->asid = asid;
674 __entry->address = address;
677 TP_printk("rip: 0x%016llx asid: %d address: 0x%016llx",
678 __entry->rip, __entry->asid, __entry->address)
682 * Tracepoint for nested #vmexit because of interrupt pending
684 TRACE_EVENT(kvm_skinit,
685 TP_PROTO(__u64 rip, __u32 slb),
689 __field( __u64, rip )
690 __field( __u32, slb )
698 TP_printk("rip: 0x%016llx slb: 0x%08x",
699 __entry->rip, __entry->slb)
702 #define KVM_EMUL_INSN_F_CR0_PE (1 << 0)
703 #define KVM_EMUL_INSN_F_EFL_VM (1 << 1)
704 #define KVM_EMUL_INSN_F_CS_D (1 << 2)
705 #define KVM_EMUL_INSN_F_CS_L (1 << 3)
707 #define kvm_trace_symbol_emul_flags \
709 { KVM_EMUL_INSN_F_CR0_PE \
710 | KVM_EMUL_INSN_F_EFL_VM, "vm16" }, \
711 { KVM_EMUL_INSN_F_CR0_PE, "prot16" }, \
712 { KVM_EMUL_INSN_F_CR0_PE \
713 | KVM_EMUL_INSN_F_CS_D, "prot32" }, \
714 { KVM_EMUL_INSN_F_CR0_PE \
715 | KVM_EMUL_INSN_F_CS_L, "prot64" }
717 #define kei_decode_mode(mode) ({ \
720 case X86EMUL_MODE_REAL: \
723 case X86EMUL_MODE_VM86: \
724 flags = KVM_EMUL_INSN_F_EFL_VM; \
726 case X86EMUL_MODE_PROT16: \
727 flags = KVM_EMUL_INSN_F_CR0_PE; \
729 case X86EMUL_MODE_PROT32: \
730 flags = KVM_EMUL_INSN_F_CR0_PE \
731 | KVM_EMUL_INSN_F_CS_D; \
733 case X86EMUL_MODE_PROT64: \
734 flags = KVM_EMUL_INSN_F_CR0_PE \
735 | KVM_EMUL_INSN_F_CS_L; \
741 TRACE_EVENT(kvm_emulate_insn,
742 TP_PROTO(struct kvm_vcpu *vcpu, __u8 failed),
743 TP_ARGS(vcpu, failed),
746 __field( __u64, rip )
747 __field( __u32, csbase )
749 __array( __u8, insn, 15 )
750 __field( __u8, flags )
751 __field( __u8, failed )
755 __entry->csbase = kvm_x86_ops.get_segment_base(vcpu, VCPU_SREG_CS);
756 __entry->len = vcpu->arch.emulate_ctxt->fetch.ptr
757 - vcpu->arch.emulate_ctxt->fetch.data;
758 __entry->rip = vcpu->arch.emulate_ctxt->_eip - __entry->len;
759 memcpy(__entry->insn,
760 vcpu->arch.emulate_ctxt->fetch.data,
762 __entry->flags = kei_decode_mode(vcpu->arch.emulate_ctxt->mode);
763 __entry->failed = failed;
766 TP_printk("%x:%llx:%s (%s)%s",
767 __entry->csbase, __entry->rip,
768 __print_hex(__entry->insn, __entry->len),
769 __print_symbolic(__entry->flags,
770 kvm_trace_symbol_emul_flags),
771 __entry->failed ? " failed" : ""
775 #define trace_kvm_emulate_insn_start(vcpu) trace_kvm_emulate_insn(vcpu, 0)
776 #define trace_kvm_emulate_insn_failed(vcpu) trace_kvm_emulate_insn(vcpu, 1)
780 TP_PROTO(gva_t gva, gpa_t gpa, bool write, bool gpa_match),
781 TP_ARGS(gva, gpa, write, gpa_match),
787 __field(bool, gpa_match)
793 __entry->write = write;
794 __entry->gpa_match = gpa_match
797 TP_printk("gva %#lx gpa %#llx %s %s", __entry->gva, __entry->gpa,
798 __entry->write ? "Write" : "Read",
799 __entry->gpa_match ? "GPA" : "GVA")
802 TRACE_EVENT(kvm_write_tsc_offset,
803 TP_PROTO(unsigned int vcpu_id, __u64 previous_tsc_offset,
804 __u64 next_tsc_offset),
805 TP_ARGS(vcpu_id, previous_tsc_offset, next_tsc_offset),
808 __field( unsigned int, vcpu_id )
809 __field( __u64, previous_tsc_offset )
810 __field( __u64, next_tsc_offset )
814 __entry->vcpu_id = vcpu_id;
815 __entry->previous_tsc_offset = previous_tsc_offset;
816 __entry->next_tsc_offset = next_tsc_offset;
819 TP_printk("vcpu=%u prev=%llu next=%llu", __entry->vcpu_id,
820 __entry->previous_tsc_offset, __entry->next_tsc_offset)
825 #define host_clocks \
826 {VDSO_CLOCKMODE_NONE, "none"}, \
827 {VDSO_CLOCKMODE_TSC, "tsc"} \
829 TRACE_EVENT(kvm_update_master_clock,
830 TP_PROTO(bool use_master_clock, unsigned int host_clock, bool offset_matched),
831 TP_ARGS(use_master_clock, host_clock, offset_matched),
834 __field( bool, use_master_clock )
835 __field( unsigned int, host_clock )
836 __field( bool, offset_matched )
840 __entry->use_master_clock = use_master_clock;
841 __entry->host_clock = host_clock;
842 __entry->offset_matched = offset_matched;
845 TP_printk("masterclock %d hostclock %s offsetmatched %u",
846 __entry->use_master_clock,
847 __print_symbolic(__entry->host_clock, host_clocks),
848 __entry->offset_matched)
851 TRACE_EVENT(kvm_track_tsc,
852 TP_PROTO(unsigned int vcpu_id, unsigned int nr_matched,
853 unsigned int online_vcpus, bool use_master_clock,
854 unsigned int host_clock),
855 TP_ARGS(vcpu_id, nr_matched, online_vcpus, use_master_clock,
859 __field( unsigned int, vcpu_id )
860 __field( unsigned int, nr_vcpus_matched_tsc )
861 __field( unsigned int, online_vcpus )
862 __field( bool, use_master_clock )
863 __field( unsigned int, host_clock )
867 __entry->vcpu_id = vcpu_id;
868 __entry->nr_vcpus_matched_tsc = nr_matched;
869 __entry->online_vcpus = online_vcpus;
870 __entry->use_master_clock = use_master_clock;
871 __entry->host_clock = host_clock;
874 TP_printk("vcpu_id %u masterclock %u offsetmatched %u nr_online %u"
876 __entry->vcpu_id, __entry->use_master_clock,
877 __entry->nr_vcpus_matched_tsc, __entry->online_vcpus,
878 __print_symbolic(__entry->host_clock, host_clocks))
881 #endif /* CONFIG_X86_64 */
884 * Tracepoint for PML full VMEXIT.
886 TRACE_EVENT(kvm_pml_full,
887 TP_PROTO(unsigned int vcpu_id),
891 __field( unsigned int, vcpu_id )
895 __entry->vcpu_id = vcpu_id;
898 TP_printk("vcpu %d: PML full", __entry->vcpu_id)
901 TRACE_EVENT(kvm_ple_window_update,
902 TP_PROTO(unsigned int vcpu_id, unsigned int new, unsigned int old),
903 TP_ARGS(vcpu_id, new, old),
906 __field( unsigned int, vcpu_id )
907 __field( unsigned int, new )
908 __field( unsigned int, old )
912 __entry->vcpu_id = vcpu_id;
917 TP_printk("vcpu %u old %u new %u (%s)",
918 __entry->vcpu_id, __entry->old, __entry->new,
919 __entry->old < __entry->new ? "growed" : "shrinked")
922 TRACE_EVENT(kvm_pvclock_update,
923 TP_PROTO(unsigned int vcpu_id, struct pvclock_vcpu_time_info *pvclock),
924 TP_ARGS(vcpu_id, pvclock),
927 __field( unsigned int, vcpu_id )
928 __field( __u32, version )
929 __field( __u64, tsc_timestamp )
930 __field( __u64, system_time )
931 __field( __u32, tsc_to_system_mul )
932 __field( __s8, tsc_shift )
933 __field( __u8, flags )
937 __entry->vcpu_id = vcpu_id;
938 __entry->version = pvclock->version;
939 __entry->tsc_timestamp = pvclock->tsc_timestamp;
940 __entry->system_time = pvclock->system_time;
941 __entry->tsc_to_system_mul = pvclock->tsc_to_system_mul;
942 __entry->tsc_shift = pvclock->tsc_shift;
943 __entry->flags = pvclock->flags;
946 TP_printk("vcpu_id %u, pvclock { version %u, tsc_timestamp 0x%llx, "
947 "system_time 0x%llx, tsc_to_system_mul 0x%x, tsc_shift %d, "
951 __entry->tsc_timestamp,
952 __entry->system_time,
953 __entry->tsc_to_system_mul,
958 TRACE_EVENT(kvm_wait_lapic_expire,
959 TP_PROTO(unsigned int vcpu_id, s64 delta),
960 TP_ARGS(vcpu_id, delta),
963 __field( unsigned int, vcpu_id )
964 __field( s64, delta )
968 __entry->vcpu_id = vcpu_id;
969 __entry->delta = delta;
972 TP_printk("vcpu %u: delta %lld (%s)",
975 __entry->delta < 0 ? "early" : "late")
978 TRACE_EVENT(kvm_enter_smm,
979 TP_PROTO(unsigned int vcpu_id, u64 smbase, bool entering),
980 TP_ARGS(vcpu_id, smbase, entering),
983 __field( unsigned int, vcpu_id )
984 __field( u64, smbase )
985 __field( bool, entering )
989 __entry->vcpu_id = vcpu_id;
990 __entry->smbase = smbase;
991 __entry->entering = entering;
994 TP_printk("vcpu %u: %s SMM, smbase 0x%llx",
996 __entry->entering ? "entering" : "leaving",
1001 * Tracepoint for VT-d posted-interrupts.
1003 TRACE_EVENT(kvm_pi_irte_update,
1004 TP_PROTO(unsigned int host_irq, unsigned int vcpu_id,
1005 unsigned int gsi, unsigned int gvec,
1006 u64 pi_desc_addr, bool set),
1007 TP_ARGS(host_irq, vcpu_id, gsi, gvec, pi_desc_addr, set),
1010 __field( unsigned int, host_irq )
1011 __field( unsigned int, vcpu_id )
1012 __field( unsigned int, gsi )
1013 __field( unsigned int, gvec )
1014 __field( u64, pi_desc_addr )
1015 __field( bool, set )
1019 __entry->host_irq = host_irq;
1020 __entry->vcpu_id = vcpu_id;
1022 __entry->gvec = gvec;
1023 __entry->pi_desc_addr = pi_desc_addr;
1027 TP_printk("VT-d PI is %s for irq %u, vcpu %u, gsi: 0x%x, "
1028 "gvec: 0x%x, pi_desc_addr: 0x%llx",
1029 __entry->set ? "enabled and being updated" : "disabled",
1034 __entry->pi_desc_addr)
1038 * Tracepoint for kvm_hv_notify_acked_sint.
1040 TRACE_EVENT(kvm_hv_notify_acked_sint,
1041 TP_PROTO(int vcpu_id, u32 sint),
1042 TP_ARGS(vcpu_id, sint),
1045 __field(int, vcpu_id)
1050 __entry->vcpu_id = vcpu_id;
1051 __entry->sint = sint;
1054 TP_printk("vcpu_id %d sint %u", __entry->vcpu_id, __entry->sint)
1058 * Tracepoint for synic_set_irq.
1060 TRACE_EVENT(kvm_hv_synic_set_irq,
1061 TP_PROTO(int vcpu_id, u32 sint, int vector, int ret),
1062 TP_ARGS(vcpu_id, sint, vector, ret),
1065 __field(int, vcpu_id)
1067 __field(int, vector)
1072 __entry->vcpu_id = vcpu_id;
1073 __entry->sint = sint;
1074 __entry->vector = vector;
1078 TP_printk("vcpu_id %d sint %u vector %d ret %d",
1079 __entry->vcpu_id, __entry->sint, __entry->vector,
1084 * Tracepoint for kvm_hv_synic_send_eoi.
1086 TRACE_EVENT(kvm_hv_synic_send_eoi,
1087 TP_PROTO(int vcpu_id, int vector),
1088 TP_ARGS(vcpu_id, vector),
1091 __field(int, vcpu_id)
1093 __field(int, vector)
1098 __entry->vcpu_id = vcpu_id;
1099 __entry->vector = vector;
1102 TP_printk("vcpu_id %d vector %d", __entry->vcpu_id, __entry->vector)
1106 * Tracepoint for synic_set_msr.
1108 TRACE_EVENT(kvm_hv_synic_set_msr,
1109 TP_PROTO(int vcpu_id, u32 msr, u64 data, bool host),
1110 TP_ARGS(vcpu_id, msr, data, host),
1113 __field(int, vcpu_id)
1120 __entry->vcpu_id = vcpu_id;
1122 __entry->data = data;
1123 __entry->host = host
1126 TP_printk("vcpu_id %d msr 0x%x data 0x%llx host %d",
1127 __entry->vcpu_id, __entry->msr, __entry->data, __entry->host)
1131 * Tracepoint for stimer_set_config.
1133 TRACE_EVENT(kvm_hv_stimer_set_config,
1134 TP_PROTO(int vcpu_id, int timer_index, u64 config, bool host),
1135 TP_ARGS(vcpu_id, timer_index, config, host),
1138 __field(int, vcpu_id)
1139 __field(int, timer_index)
1140 __field(u64, config)
1145 __entry->vcpu_id = vcpu_id;
1146 __entry->timer_index = timer_index;
1147 __entry->config = config;
1148 __entry->host = host;
1151 TP_printk("vcpu_id %d timer %d config 0x%llx host %d",
1152 __entry->vcpu_id, __entry->timer_index, __entry->config,
1157 * Tracepoint for stimer_set_count.
1159 TRACE_EVENT(kvm_hv_stimer_set_count,
1160 TP_PROTO(int vcpu_id, int timer_index, u64 count, bool host),
1161 TP_ARGS(vcpu_id, timer_index, count, host),
1164 __field(int, vcpu_id)
1165 __field(int, timer_index)
1171 __entry->vcpu_id = vcpu_id;
1172 __entry->timer_index = timer_index;
1173 __entry->count = count;
1174 __entry->host = host;
1177 TP_printk("vcpu_id %d timer %d count %llu host %d",
1178 __entry->vcpu_id, __entry->timer_index, __entry->count,
1183 * Tracepoint for stimer_start(periodic timer case).
1185 TRACE_EVENT(kvm_hv_stimer_start_periodic,
1186 TP_PROTO(int vcpu_id, int timer_index, u64 time_now, u64 exp_time),
1187 TP_ARGS(vcpu_id, timer_index, time_now, exp_time),
1190 __field(int, vcpu_id)
1191 __field(int, timer_index)
1192 __field(u64, time_now)
1193 __field(u64, exp_time)
1197 __entry->vcpu_id = vcpu_id;
1198 __entry->timer_index = timer_index;
1199 __entry->time_now = time_now;
1200 __entry->exp_time = exp_time;
1203 TP_printk("vcpu_id %d timer %d time_now %llu exp_time %llu",
1204 __entry->vcpu_id, __entry->timer_index, __entry->time_now,
1209 * Tracepoint for stimer_start(one-shot timer case).
1211 TRACE_EVENT(kvm_hv_stimer_start_one_shot,
1212 TP_PROTO(int vcpu_id, int timer_index, u64 time_now, u64 count),
1213 TP_ARGS(vcpu_id, timer_index, time_now, count),
1216 __field(int, vcpu_id)
1217 __field(int, timer_index)
1218 __field(u64, time_now)
1223 __entry->vcpu_id = vcpu_id;
1224 __entry->timer_index = timer_index;
1225 __entry->time_now = time_now;
1226 __entry->count = count;
1229 TP_printk("vcpu_id %d timer %d time_now %llu count %llu",
1230 __entry->vcpu_id, __entry->timer_index, __entry->time_now,
1235 * Tracepoint for stimer_timer_callback.
1237 TRACE_EVENT(kvm_hv_stimer_callback,
1238 TP_PROTO(int vcpu_id, int timer_index),
1239 TP_ARGS(vcpu_id, timer_index),
1242 __field(int, vcpu_id)
1243 __field(int, timer_index)
1247 __entry->vcpu_id = vcpu_id;
1248 __entry->timer_index = timer_index;
1251 TP_printk("vcpu_id %d timer %d",
1252 __entry->vcpu_id, __entry->timer_index)
1256 * Tracepoint for stimer_expiration.
1258 TRACE_EVENT(kvm_hv_stimer_expiration,
1259 TP_PROTO(int vcpu_id, int timer_index, int direct, int msg_send_result),
1260 TP_ARGS(vcpu_id, timer_index, direct, msg_send_result),
1263 __field(int, vcpu_id)
1264 __field(int, timer_index)
1265 __field(int, direct)
1266 __field(int, msg_send_result)
1270 __entry->vcpu_id = vcpu_id;
1271 __entry->timer_index = timer_index;
1272 __entry->direct = direct;
1273 __entry->msg_send_result = msg_send_result;
1276 TP_printk("vcpu_id %d timer %d direct %d send result %d",
1277 __entry->vcpu_id, __entry->timer_index,
1278 __entry->direct, __entry->msg_send_result)
1282 * Tracepoint for stimer_cleanup.
1284 TRACE_EVENT(kvm_hv_stimer_cleanup,
1285 TP_PROTO(int vcpu_id, int timer_index),
1286 TP_ARGS(vcpu_id, timer_index),
1289 __field(int, vcpu_id)
1290 __field(int, timer_index)
1294 __entry->vcpu_id = vcpu_id;
1295 __entry->timer_index = timer_index;
1298 TP_printk("vcpu_id %d timer %d",
1299 __entry->vcpu_id, __entry->timer_index)
1302 TRACE_EVENT(kvm_apicv_update_request,
1303 TP_PROTO(bool activate, unsigned long bit),
1304 TP_ARGS(activate, bit),
1307 __field(bool, activate)
1308 __field(unsigned long, bit)
1312 __entry->activate = activate;
1316 TP_printk("%s bit=%lu",
1317 __entry->activate ? "activate" : "deactivate",
1322 * Tracepoint for AMD AVIC
1324 TRACE_EVENT(kvm_avic_incomplete_ipi,
1325 TP_PROTO(u32 vcpu, u32 icrh, u32 icrl, u32 id, u32 index),
1326 TP_ARGS(vcpu, icrh, icrl, id, index),
1337 __entry->vcpu = vcpu;
1338 __entry->icrh = icrh;
1339 __entry->icrl = icrl;
1341 __entry->index = index;
1344 TP_printk("vcpu=%u, icrh:icrl=%#010x:%08x, id=%u, index=%u",
1345 __entry->vcpu, __entry->icrh, __entry->icrl,
1346 __entry->id, __entry->index)
1349 TRACE_EVENT(kvm_avic_unaccelerated_access,
1350 TP_PROTO(u32 vcpu, u32 offset, bool ft, bool rw, u32 vec),
1351 TP_ARGS(vcpu, offset, ft, rw, vec),
1355 __field(u32, offset)
1362 __entry->vcpu = vcpu;
1363 __entry->offset = offset;
1369 TP_printk("vcpu=%u, offset=%#x(%s), %s, %s, vec=%#x",
1372 __print_symbolic(__entry->offset, kvm_trace_symbol_apic),
1373 __entry->ft ? "trap" : "fault",
1374 __entry->rw ? "write" : "read",
1378 TRACE_EVENT(kvm_avic_ga_log,
1379 TP_PROTO(u32 vmid, u32 vcpuid),
1380 TP_ARGS(vmid, vcpuid),
1384 __field(u32, vcpuid)
1388 __entry->vmid = vmid;
1389 __entry->vcpuid = vcpuid;
1392 TP_printk("vmid=%u, vcpuid=%u",
1393 __entry->vmid, __entry->vcpuid)
1396 TRACE_EVENT(kvm_hv_timer_state,
1397 TP_PROTO(unsigned int vcpu_id, unsigned int hv_timer_in_use),
1398 TP_ARGS(vcpu_id, hv_timer_in_use),
1400 __field(unsigned int, vcpu_id)
1401 __field(unsigned int, hv_timer_in_use)
1404 __entry->vcpu_id = vcpu_id;
1405 __entry->hv_timer_in_use = hv_timer_in_use;
1407 TP_printk("vcpu_id %x hv_timer %x",
1409 __entry->hv_timer_in_use)
1413 * Tracepoint for kvm_hv_flush_tlb.
1415 TRACE_EVENT(kvm_hv_flush_tlb,
1416 TP_PROTO(u64 processor_mask, u64 address_space, u64 flags),
1417 TP_ARGS(processor_mask, address_space, flags),
1420 __field(u64, processor_mask)
1421 __field(u64, address_space)
1426 __entry->processor_mask = processor_mask;
1427 __entry->address_space = address_space;
1428 __entry->flags = flags;
1431 TP_printk("processor_mask 0x%llx address_space 0x%llx flags 0x%llx",
1432 __entry->processor_mask, __entry->address_space,
1437 * Tracepoint for kvm_hv_flush_tlb_ex.
1439 TRACE_EVENT(kvm_hv_flush_tlb_ex,
1440 TP_PROTO(u64 valid_bank_mask, u64 format, u64 address_space, u64 flags),
1441 TP_ARGS(valid_bank_mask, format, address_space, flags),
1444 __field(u64, valid_bank_mask)
1445 __field(u64, format)
1446 __field(u64, address_space)
1451 __entry->valid_bank_mask = valid_bank_mask;
1452 __entry->format = format;
1453 __entry->address_space = address_space;
1454 __entry->flags = flags;
1457 TP_printk("valid_bank_mask 0x%llx format 0x%llx "
1458 "address_space 0x%llx flags 0x%llx",
1459 __entry->valid_bank_mask, __entry->format,
1460 __entry->address_space, __entry->flags)
1464 * Tracepoints for kvm_hv_send_ipi.
1466 TRACE_EVENT(kvm_hv_send_ipi,
1467 TP_PROTO(u32 vector, u64 processor_mask),
1468 TP_ARGS(vector, processor_mask),
1471 __field(u32, vector)
1472 __field(u64, processor_mask)
1476 __entry->vector = vector;
1477 __entry->processor_mask = processor_mask;
1480 TP_printk("vector %x processor_mask 0x%llx",
1481 __entry->vector, __entry->processor_mask)
1484 TRACE_EVENT(kvm_hv_send_ipi_ex,
1485 TP_PROTO(u32 vector, u64 format, u64 valid_bank_mask),
1486 TP_ARGS(vector, format, valid_bank_mask),
1489 __field(u32, vector)
1490 __field(u64, format)
1491 __field(u64, valid_bank_mask)
1495 __entry->vector = vector;
1496 __entry->format = format;
1497 __entry->valid_bank_mask = valid_bank_mask;
1500 TP_printk("vector %x format %llx valid_bank_mask 0x%llx",
1501 __entry->vector, __entry->format,
1502 __entry->valid_bank_mask)
1505 TRACE_EVENT(kvm_pv_tlb_flush,
1506 TP_PROTO(unsigned int vcpu_id, bool need_flush_tlb),
1507 TP_ARGS(vcpu_id, need_flush_tlb),
1510 __field( unsigned int, vcpu_id )
1511 __field( bool, need_flush_tlb )
1515 __entry->vcpu_id = vcpu_id;
1516 __entry->need_flush_tlb = need_flush_tlb;
1519 TP_printk("vcpu %u need_flush_tlb %s", __entry->vcpu_id,
1520 __entry->need_flush_tlb ? "true" : "false")
1524 * Tracepoint for failed nested VMX VM-Enter.
1526 TRACE_EVENT(kvm_nested_vmenter_failed,
1527 TP_PROTO(const char *msg, u32 err),
1531 __field(const char *, msg)
1540 TP_printk("%s%s", __entry->msg, !__entry->err ? "" :
1541 __print_symbolic(__entry->err, VMX_VMENTER_INSTRUCTION_ERRORS))
1545 * Tracepoint for syndbg_set_msr.
1547 TRACE_EVENT(kvm_hv_syndbg_set_msr,
1548 TP_PROTO(int vcpu_id, u32 vp_index, u32 msr, u64 data),
1549 TP_ARGS(vcpu_id, vp_index, msr, data),
1552 __field(int, vcpu_id)
1553 __field(u32, vp_index)
1559 __entry->vcpu_id = vcpu_id;
1560 __entry->vp_index = vp_index;
1562 __entry->data = data;
1565 TP_printk("vcpu_id %d vp_index %u msr 0x%x data 0x%llx",
1566 __entry->vcpu_id, __entry->vp_index, __entry->msr,
1571 * Tracepoint for syndbg_get_msr.
1573 TRACE_EVENT(kvm_hv_syndbg_get_msr,
1574 TP_PROTO(int vcpu_id, u32 vp_index, u32 msr, u64 data),
1575 TP_ARGS(vcpu_id, vp_index, msr, data),
1578 __field(int, vcpu_id)
1579 __field(u32, vp_index)
1585 __entry->vcpu_id = vcpu_id;
1586 __entry->vp_index = vp_index;
1588 __entry->data = data;
1591 TP_printk("vcpu_id %d vp_index %u msr 0x%x data 0x%llx",
1592 __entry->vcpu_id, __entry->vp_index, __entry->msr,
1595 #endif /* _TRACE_KVM_H */
1597 #undef TRACE_INCLUDE_PATH
1598 #define TRACE_INCLUDE_PATH ../../arch/x86/kvm
1599 #undef TRACE_INCLUDE_FILE
1600 #define TRACE_INCLUDE_FILE trace
1602 /* This part must be outside protection */
1603 #include <trace/define_trace.h>