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
)
235 __field( unsigned int, vcpu_id
)
239 __entry
->exit_reason
= exit_reason
;
240 __entry
->guest_rip
= kvm_rip_read(vcpu
);
242 __entry
->vcpu_id
= vcpu
->vcpu_id
;
243 kvm_x86_ops
->get_exit_info(vcpu
, &__entry
->info1
,
247 TP_printk("vcpu %u reason %s rip 0x%lx info %llx %llx",
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
)
256 * Tracepoint for kvm interrupt injection:
258 TRACE_EVENT(kvm_inj_virq
,
259 TP_PROTO(unsigned int irq
),
263 __field( unsigned int, irq
)
270 TP_printk("irq %u", __entry
->irq
)
273 #define EXS(x) { x##_VECTOR, "#" #x }
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)
281 * Tracepoint for kvm interrupt injection:
283 TRACE_EVENT(kvm_inj_exception
,
284 TP_PROTO(unsigned exception
, bool has_error
, unsigned error_code
),
285 TP_ARGS(exception
, has_error
, error_code
),
288 __field( u8
, exception
)
289 __field( u8
, has_error
)
290 __field( u32
, error_code
)
294 __entry
->exception
= exception
;
295 __entry
->has_error
= has_error
;
296 __entry
->error_code
= error_code
;
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)
306 * Tracepoint for page fault.
308 TRACE_EVENT(kvm_page_fault
,
309 TP_PROTO(unsigned long fault_address
, unsigned int error_code
),
310 TP_ARGS(fault_address
, error_code
),
313 __field( unsigned long, fault_address
)
314 __field( unsigned int, error_code
)
318 __entry
->fault_address
= fault_address
;
319 __entry
->error_code
= error_code
;
322 TP_printk("address %lx error_code %x",
323 __entry
->fault_address
, __entry
->error_code
)
327 * Tracepoint for guest MSR access.
330 TP_PROTO(unsigned write
, u32 ecx
, u64 data
, bool exception
),
331 TP_ARGS(write
, ecx
, data
, exception
),
334 __field( unsigned, write
)
337 __field( u8
, exception
)
341 __entry
->write
= write
;
343 __entry
->data
= data
;
344 __entry
->exception
= exception
;
347 TP_printk("msr_%s %x = 0x%llx%s",
348 __entry
->write
? "write" : "read",
349 __entry
->ecx
, __entry
->data
,
350 __entry
->exception
? " (#GP)" : "")
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)
359 * Tracepoint for guest CR access.
362 TP_PROTO(unsigned int rw
, unsigned int cr
, unsigned long val
),
363 TP_ARGS(rw
, cr
, val
),
366 __field( unsigned int, rw
)
367 __field( unsigned int, cr
)
368 __field( unsigned long, val
)
377 TP_printk("cr_%s %x = 0x%lx",
378 __entry
->rw
? "write" : "read",
379 __entry
->cr
, __entry
->val
)
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)
385 TRACE_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
),
390 __field( __u8
, chip
)
392 __field( __u8
, elcr
)
394 __field( bool, coalesced
)
398 __entry
->chip
= chip
;
400 __entry
->elcr
= elcr
;
402 __entry
->coalesced
= coalesced
;
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)" : "")
412 #define kvm_apic_dst_shorthand \
416 {0x3, "all-but-self"}
418 TRACE_EVENT(kvm_apic_ipi
,
419 TP_PROTO(__u32 icr_low
, __u32 dest_id
),
420 TP_ARGS(icr_low
, dest_id
),
423 __field( __u32
, icr_low
)
424 __field( __u32
, dest_id
)
428 __entry
->icr_low
= icr_low
;
429 __entry
->dest_id
= dest_id
;
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),
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
))
443 TRACE_EVENT(kvm_apic_accept_irq
,
444 TP_PROTO(__u32 apicid
, __u16 dm
, __u16 tm
, __u8 vec
),
445 TP_ARGS(apicid
, dm
, tm
, vec
),
448 __field( __u32
, apicid
)
455 __entry
->apicid
= apicid
;
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")
468 TP_PROTO(struct kvm_lapic
*apic
, int vector
),
469 TP_ARGS(apic
, vector
),
472 __field( __u32
, apicid
)
473 __field( int, vector
)
477 __entry
->apicid
= apic
->vcpu
->vcpu_id
;
478 __entry
->vector
= vector
;
481 TP_printk("apicid %x vector %d", __entry
->apicid
, __entry
->vector
)
484 TRACE_EVENT(kvm_pv_eoi
,
485 TP_PROTO(struct kvm_lapic
*apic
, int vector
),
486 TP_ARGS(apic
, vector
),
489 __field( __u32
, apicid
)
490 __field( int, vector
)
494 __entry
->apicid
= apic
->vcpu
->vcpu_id
;
495 __entry
->vector
= vector
;
498 TP_printk("apicid %x vector %d", __entry
->apicid
, __entry
->vector
)
502 * Tracepoint for nested VMRUN
504 TRACE_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
),
510 __field( __u64
, rip
)
511 __field( __u64
, vmcb
)
512 __field( __u64
, nested_rip
)
513 __field( __u32
, int_ctl
)
514 __field( __u32
, event_inj
)
520 __entry
->vmcb
= vmcb
;
521 __entry
->nested_rip
= nested_rip
;
522 __entry
->int_ctl
= int_ctl
;
523 __entry
->event_inj
= event_inj
;
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")
534 TRACE_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
),
539 __field( __u16
, cr_read
)
540 __field( __u16
, cr_write
)
541 __field( __u32
, exceptions
)
542 __field( __u64
, intercept
)
546 __entry
->cr_read
= cr_read
;
547 __entry
->cr_write
= cr_write
;
548 __entry
->exceptions
= exceptions
;
549 __entry
->intercept
= intercept
;
552 TP_printk("cr_read: %04x cr_write: %04x excp: %08x intercept: %016llx",
553 __entry
->cr_read
, __entry
->cr_write
, __entry
->exceptions
,
557 * Tracepoint for #VMEXIT while nested
559 TRACE_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
),
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
)
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
;
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",
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
)
596 * Tracepoint for #VMEXIT reinjected to the guest
598 TRACE_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
),
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
)
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
;
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
)
633 * Tracepoint for nested #vmexit because of interrupt pending
635 TRACE_EVENT(kvm_nested_intr_vmexit
,
640 __field( __u64
, rip
)
647 TP_printk("rip: 0x%016llx", __entry
->rip
)
651 * Tracepoint for nested #vmexit because of interrupt pending
653 TRACE_EVENT(kvm_invlpga
,
654 TP_PROTO(__u64 rip
, int asid
, u64 address
),
655 TP_ARGS(rip
, asid
, address
),
658 __field( __u64
, rip
)
660 __field( __u64
, address
)
665 __entry
->asid
= asid
;
666 __entry
->address
= address
;
669 TP_printk("rip: 0x%016llx asid: %d address: 0x%016llx",
670 __entry
->rip
, __entry
->asid
, __entry
->address
)
674 * Tracepoint for nested #vmexit because of interrupt pending
676 TRACE_EVENT(kvm_skinit
,
677 TP_PROTO(__u64 rip
, __u32 slb
),
681 __field( __u64
, rip
)
682 __field( __u32
, slb
)
690 TP_printk("rip: 0x%016llx slb: 0x%08x",
691 __entry
->rip
, __entry
->slb
)
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)
699 #define kvm_trace_symbol_emul_flags \
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" }
709 #define kei_decode_mode(mode) ({ \
712 case X86EMUL_MODE_REAL: \
715 case X86EMUL_MODE_VM86: \
716 flags = KVM_EMUL_INSN_F_EFL_VM; \
718 case X86EMUL_MODE_PROT16: \
719 flags = KVM_EMUL_INSN_F_CR0_PE; \
721 case X86EMUL_MODE_PROT32: \
722 flags = KVM_EMUL_INSN_F_CR0_PE \
723 | KVM_EMUL_INSN_F_CS_D; \
725 case X86EMUL_MODE_PROT64: \
726 flags = KVM_EMUL_INSN_F_CR0_PE \
727 | KVM_EMUL_INSN_F_CS_L; \
733 TRACE_EVENT(kvm_emulate_insn
,
734 TP_PROTO(struct kvm_vcpu
*vcpu
, __u8 failed
),
735 TP_ARGS(vcpu
, failed
),
738 __field( __u64
, rip
)
739 __field( __u32
, csbase
)
741 __array( __u8
, insn
, 15 )
742 __field( __u8
, flags
)
743 __field( __u8
, failed
)
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
,
754 __entry
->flags
= kei_decode_mode(vcpu
->arch
.emulate_ctxt
.mode
);
755 __entry
->failed
= failed
;
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" : ""
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)
772 TP_PROTO(gva_t gva
, gpa_t gpa
, bool write
, bool gpa_match
),
773 TP_ARGS(gva
, gpa
, write
, gpa_match
),
779 __field(bool, gpa_match
)
785 __entry
->write
= write
;
786 __entry
->gpa_match
= gpa_match
789 TP_printk("gva %#lx gpa %#llx %s %s", __entry
->gva
, __entry
->gpa
,
790 __entry
->write
? "Write" : "Read",
791 __entry
->gpa_match
? "GPA" : "GVA")
794 TRACE_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
),
800 __field( unsigned int, vcpu_id
)
801 __field( __u64
, previous_tsc_offset
)
802 __field( __u64
, next_tsc_offset
)
806 __entry
->vcpu_id
= vcpu_id
;
807 __entry
->previous_tsc_offset
= previous_tsc_offset
;
808 __entry
->next_tsc_offset
= next_tsc_offset
;
811 TP_printk("vcpu=%u prev=%llu next=%llu", __entry
->vcpu_id
,
812 __entry
->previous_tsc_offset
, __entry
->next_tsc_offset
)
817 #define host_clocks \
818 {VCLOCK_NONE, "none"}, \
819 {VCLOCK_TSC, "tsc"} \
821 TRACE_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
),
826 __field( bool, use_master_clock
)
827 __field( unsigned int, host_clock
)
828 __field( bool, offset_matched
)
832 __entry
->use_master_clock
= use_master_clock
;
833 __entry
->host_clock
= host_clock
;
834 __entry
->offset_matched
= offset_matched
;
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
)
843 TRACE_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
,
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
)
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
;
866 TP_printk("vcpu_id %u masterclock %u offsetmatched %u nr_online %u"
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
))
873 #endif /* CONFIG_X86_64 */
876 * Tracepoint for PML full VMEXIT.
878 TRACE_EVENT(kvm_pml_full
,
879 TP_PROTO(unsigned int vcpu_id
),
883 __field( unsigned int, vcpu_id
)
887 __entry
->vcpu_id
= vcpu_id
;
890 TP_printk("vcpu %d: PML full", __entry
->vcpu_id
)
893 TRACE_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
),
898 __field( unsigned int, vcpu_id
)
899 __field( unsigned int, new )
900 __field( unsigned int, old
)
904 __entry
->vcpu_id
= vcpu_id
;
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")
914 TRACE_EVENT(kvm_pvclock_update
,
915 TP_PROTO(unsigned int vcpu_id
, struct pvclock_vcpu_time_info
*pvclock
),
916 TP_ARGS(vcpu_id
, pvclock
),
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
)
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
;
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, "
943 __entry
->tsc_timestamp
,
944 __entry
->system_time
,
945 __entry
->tsc_to_system_mul
,
950 TRACE_EVENT(kvm_wait_lapic_expire
,
951 TP_PROTO(unsigned int vcpu_id
, s64 delta
),
952 TP_ARGS(vcpu_id
, delta
),
955 __field( unsigned int, vcpu_id
)
956 __field( s64
, delta
)
960 __entry
->vcpu_id
= vcpu_id
;
961 __entry
->delta
= delta
;
964 TP_printk("vcpu %u: delta %lld (%s)",
967 __entry
->delta
< 0 ? "early" : "late")
970 TRACE_EVENT(kvm_enter_smm
,
971 TP_PROTO(unsigned int vcpu_id
, u64 smbase
, bool entering
),
972 TP_ARGS(vcpu_id
, smbase
, entering
),
975 __field( unsigned int, vcpu_id
)
976 __field( u64
, smbase
)
977 __field( bool, entering
)
981 __entry
->vcpu_id
= vcpu_id
;
982 __entry
->smbase
= smbase
;
983 __entry
->entering
= entering
;
986 TP_printk("vcpu %u: %s SMM, smbase 0x%llx",
988 __entry
->entering
? "entering" : "leaving",
993 * Tracepoint for VT-d posted-interrupts.
995 TRACE_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
),
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
)
1011 __entry
->host_irq
= host_irq
;
1012 __entry
->vcpu_id
= vcpu_id
;
1014 __entry
->gvec
= gvec
;
1015 __entry
->pi_desc_addr
= pi_desc_addr
;
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",
1026 __entry
->pi_desc_addr
)
1030 * Tracepoint for kvm_hv_notify_acked_sint.
1032 TRACE_EVENT(kvm_hv_notify_acked_sint
,
1033 TP_PROTO(int vcpu_id
, u32 sint
),
1034 TP_ARGS(vcpu_id
, sint
),
1037 __field(int, vcpu_id
)
1042 __entry
->vcpu_id
= vcpu_id
;
1043 __entry
->sint
= sint
;
1046 TP_printk("vcpu_id %d sint %u", __entry
->vcpu_id
, __entry
->sint
)
1050 * Tracepoint for synic_set_irq.
1052 TRACE_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
),
1057 __field(int, vcpu_id
)
1059 __field(int, vector
)
1064 __entry
->vcpu_id
= vcpu_id
;
1065 __entry
->sint
= sint
;
1066 __entry
->vector
= vector
;
1070 TP_printk("vcpu_id %d sint %u vector %d ret %d",
1071 __entry
->vcpu_id
, __entry
->sint
, __entry
->vector
,
1076 * Tracepoint for kvm_hv_synic_send_eoi.
1078 TRACE_EVENT(kvm_hv_synic_send_eoi
,
1079 TP_PROTO(int vcpu_id
, int vector
),
1080 TP_ARGS(vcpu_id
, vector
),
1083 __field(int, vcpu_id
)
1085 __field(int, vector
)
1090 __entry
->vcpu_id
= vcpu_id
;
1091 __entry
->vector
= vector
;
1094 TP_printk("vcpu_id %d vector %d", __entry
->vcpu_id
, __entry
->vector
)
1098 * Tracepoint for synic_set_msr.
1100 TRACE_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
),
1105 __field(int, vcpu_id
)
1112 __entry
->vcpu_id
= vcpu_id
;
1114 __entry
->data
= data
;
1115 __entry
->host
= host
1118 TP_printk("vcpu_id %d msr 0x%x data 0x%llx host %d",
1119 __entry
->vcpu_id
, __entry
->msr
, __entry
->data
, __entry
->host
)
1123 * Tracepoint for stimer_set_config.
1125 TRACE_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
),
1130 __field(int, vcpu_id
)
1131 __field(int, timer_index
)
1132 __field(u64
, config
)
1137 __entry
->vcpu_id
= vcpu_id
;
1138 __entry
->timer_index
= timer_index
;
1139 __entry
->config
= config
;
1140 __entry
->host
= host
;
1143 TP_printk("vcpu_id %d timer %d config 0x%llx host %d",
1144 __entry
->vcpu_id
, __entry
->timer_index
, __entry
->config
,
1149 * Tracepoint for stimer_set_count.
1151 TRACE_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
),
1156 __field(int, vcpu_id
)
1157 __field(int, timer_index
)
1163 __entry
->vcpu_id
= vcpu_id
;
1164 __entry
->timer_index
= timer_index
;
1165 __entry
->count
= count
;
1166 __entry
->host
= host
;
1169 TP_printk("vcpu_id %d timer %d count %llu host %d",
1170 __entry
->vcpu_id
, __entry
->timer_index
, __entry
->count
,
1175 * Tracepoint for stimer_start(periodic timer case).
1177 TRACE_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
),
1182 __field(int, vcpu_id
)
1183 __field(int, timer_index
)
1184 __field(u64
, time_now
)
1185 __field(u64
, exp_time
)
1189 __entry
->vcpu_id
= vcpu_id
;
1190 __entry
->timer_index
= timer_index
;
1191 __entry
->time_now
= time_now
;
1192 __entry
->exp_time
= exp_time
;
1195 TP_printk("vcpu_id %d timer %d time_now %llu exp_time %llu",
1196 __entry
->vcpu_id
, __entry
->timer_index
, __entry
->time_now
,
1201 * Tracepoint for stimer_start(one-shot timer case).
1203 TRACE_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
),
1208 __field(int, vcpu_id
)
1209 __field(int, timer_index
)
1210 __field(u64
, time_now
)
1215 __entry
->vcpu_id
= vcpu_id
;
1216 __entry
->timer_index
= timer_index
;
1217 __entry
->time_now
= time_now
;
1218 __entry
->count
= count
;
1221 TP_printk("vcpu_id %d timer %d time_now %llu count %llu",
1222 __entry
->vcpu_id
, __entry
->timer_index
, __entry
->time_now
,
1227 * Tracepoint for stimer_timer_callback.
1229 TRACE_EVENT(kvm_hv_stimer_callback
,
1230 TP_PROTO(int vcpu_id
, int timer_index
),
1231 TP_ARGS(vcpu_id
, timer_index
),
1234 __field(int, vcpu_id
)
1235 __field(int, timer_index
)
1239 __entry
->vcpu_id
= vcpu_id
;
1240 __entry
->timer_index
= timer_index
;
1243 TP_printk("vcpu_id %d timer %d",
1244 __entry
->vcpu_id
, __entry
->timer_index
)
1248 * Tracepoint for stimer_expiration.
1250 TRACE_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
),
1255 __field(int, vcpu_id
)
1256 __field(int, timer_index
)
1257 __field(int, direct
)
1258 __field(int, msg_send_result
)
1262 __entry
->vcpu_id
= vcpu_id
;
1263 __entry
->timer_index
= timer_index
;
1264 __entry
->direct
= direct
;
1265 __entry
->msg_send_result
= msg_send_result
;
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
)
1274 * Tracepoint for stimer_cleanup.
1276 TRACE_EVENT(kvm_hv_stimer_cleanup
,
1277 TP_PROTO(int vcpu_id
, int timer_index
),
1278 TP_ARGS(vcpu_id
, timer_index
),
1281 __field(int, vcpu_id
)
1282 __field(int, timer_index
)
1286 __entry
->vcpu_id
= vcpu_id
;
1287 __entry
->timer_index
= timer_index
;
1290 TP_printk("vcpu_id %d timer %d",
1291 __entry
->vcpu_id
, __entry
->timer_index
)
1295 * Tracepoint for AMD AVIC
1297 TRACE_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
),
1310 __entry
->vcpu
= vcpu
;
1311 __entry
->icrh
= icrh
;
1312 __entry
->icrl
= icrl
;
1314 __entry
->index
= index
;
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
)
1322 TRACE_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
),
1328 __field(u32
, offset
)
1335 __entry
->vcpu
= vcpu
;
1336 __entry
->offset
= offset
;
1342 TP_printk("vcpu=%u, offset=%#x(%s), %s, %s, vec=%#x",
1345 __print_symbolic(__entry
->offset
, kvm_trace_symbol_apic
),
1346 __entry
->ft
? "trap" : "fault",
1347 __entry
->rw
? "write" : "read",
1351 TRACE_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
),
1355 __field(unsigned int, vcpu_id
)
1356 __field(unsigned int, hv_timer_in_use
)
1359 __entry
->vcpu_id
= vcpu_id
;
1360 __entry
->hv_timer_in_use
= hv_timer_in_use
;
1362 TP_printk("vcpu_id %x hv_timer %x",
1364 __entry
->hv_timer_in_use
)
1368 * Tracepoint for kvm_hv_flush_tlb.
1370 TRACE_EVENT(kvm_hv_flush_tlb
,
1371 TP_PROTO(u64 processor_mask
, u64 address_space
, u64 flags
),
1372 TP_ARGS(processor_mask
, address_space
, flags
),
1375 __field(u64
, processor_mask
)
1376 __field(u64
, address_space
)
1381 __entry
->processor_mask
= processor_mask
;
1382 __entry
->address_space
= address_space
;
1383 __entry
->flags
= flags
;
1386 TP_printk("processor_mask 0x%llx address_space 0x%llx flags 0x%llx",
1387 __entry
->processor_mask
, __entry
->address_space
,
1392 * Tracepoint for kvm_hv_flush_tlb_ex.
1394 TRACE_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
),
1399 __field(u64
, valid_bank_mask
)
1400 __field(u64
, format
)
1401 __field(u64
, address_space
)
1406 __entry
->valid_bank_mask
= valid_bank_mask
;
1407 __entry
->format
= format
;
1408 __entry
->address_space
= address_space
;
1409 __entry
->flags
= flags
;
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
)
1419 * Tracepoints for kvm_hv_send_ipi.
1421 TRACE_EVENT(kvm_hv_send_ipi
,
1422 TP_PROTO(u32 vector
, u64 processor_mask
),
1423 TP_ARGS(vector
, processor_mask
),
1426 __field(u32
, vector
)
1427 __field(u64
, processor_mask
)
1431 __entry
->vector
= vector
;
1432 __entry
->processor_mask
= processor_mask
;
1435 TP_printk("vector %x processor_mask 0x%llx",
1436 __entry
->vector
, __entry
->processor_mask
)
1439 TRACE_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
),
1444 __field(u32
, vector
)
1445 __field(u64
, format
)
1446 __field(u64
, valid_bank_mask
)
1450 __entry
->vector
= vector
;
1451 __entry
->format
= format
;
1452 __entry
->valid_bank_mask
= valid_bank_mask
;
1455 TP_printk("vector %x format %llx valid_bank_mask 0x%llx",
1456 __entry
->vector
, __entry
->format
,
1457 __entry
->valid_bank_mask
)
1460 TRACE_EVENT(kvm_pv_tlb_flush
,
1461 TP_PROTO(unsigned int vcpu_id
, bool need_flush_tlb
),
1462 TP_ARGS(vcpu_id
, need_flush_tlb
),
1465 __field( unsigned int, vcpu_id
)
1466 __field( bool, need_flush_tlb
)
1470 __entry
->vcpu_id
= vcpu_id
;
1471 __entry
->need_flush_tlb
= need_flush_tlb
;
1474 TP_printk("vcpu %u need_flush_tlb %s", __entry
->vcpu_id
,
1475 __entry
->need_flush_tlb
? "true" : "false")
1479 * Tracepoint for failed nested VMX VM-Enter.
1481 TRACE_EVENT(kvm_nested_vmenter_failed
,
1482 TP_PROTO(const char *msg
, u32 err
),
1486 __field(const char *, msg
)
1495 TP_printk("%s%s", __entry
->msg
, !__entry
->err
? "" :
1496 __print_symbolic(__entry
->err
, VMX_VMENTER_INSTRUCTION_ERRORS
))
1499 #endif /* _TRACE_KVM_H */
1501 #undef TRACE_INCLUDE_PATH
1502 #define TRACE_INCLUDE_PATH ../../arch/x86/kvm
1503 #undef TRACE_INCLUDE_FILE
1504 #define TRACE_INCLUDE_FILE trace
1506 /* This part must be outside protection */
1507 #include <trace/define_trace.h>