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(struct kvm_vcpu
*vcpu
, bool force_immediate_exit
),
19 TP_ARGS(vcpu
, force_immediate_exit
),
22 __field( unsigned int, vcpu_id
)
23 __field( unsigned long, rip
)
24 __field( bool, immediate_exit
)
28 __entry
->vcpu_id
= vcpu
->vcpu_id
;
29 __entry
->rip
= kvm_rip_read(vcpu
);
30 __entry
->immediate_exit
= force_immediate_exit
;
33 TP_printk("vcpu %u, rip 0x%lx%s", __entry
->vcpu_id
, __entry
->rip
,
34 __entry
->immediate_exit
? "[immediate exit]" : "")
38 * Tracepoint for hypercall.
40 TRACE_EVENT(kvm_hypercall
,
41 TP_PROTO(unsigned long nr
, unsigned long a0
, unsigned long a1
,
42 unsigned long a2
, unsigned long a3
),
43 TP_ARGS(nr
, a0
, a1
, a2
, a3
),
46 __field( unsigned long, nr
)
47 __field( unsigned long, a0
)
48 __field( unsigned long, a1
)
49 __field( unsigned long, a2
)
50 __field( unsigned long, a3
)
61 TP_printk("nr 0x%lx a0 0x%lx a1 0x%lx a2 0x%lx a3 0x%lx",
62 __entry
->nr
, __entry
->a0
, __entry
->a1
, __entry
->a2
,
67 * Tracepoint for hypercall.
69 TRACE_EVENT(kvm_hv_hypercall
,
70 TP_PROTO(__u16 code
, bool fast
, __u16 var_cnt
, __u16 rep_cnt
,
71 __u16 rep_idx
, __u64 ingpa
, __u64 outgpa
),
72 TP_ARGS(code
, fast
, var_cnt
, rep_cnt
, rep_idx
, ingpa
, outgpa
),
75 __field( __u16
, rep_cnt
)
76 __field( __u16
, rep_idx
)
77 __field( __u64
, ingpa
)
78 __field( __u64
, outgpa
)
79 __field( __u16
, code
)
80 __field( __u16
, var_cnt
)
85 __entry
->rep_cnt
= rep_cnt
;
86 __entry
->rep_idx
= rep_idx
;
87 __entry
->ingpa
= ingpa
;
88 __entry
->outgpa
= outgpa
;
90 __entry
->var_cnt
= var_cnt
;
94 TP_printk("code 0x%x %s var_cnt 0x%x rep_cnt 0x%x idx 0x%x in 0x%llx out 0x%llx",
95 __entry
->code
, __entry
->fast
? "fast" : "slow",
96 __entry
->var_cnt
, __entry
->rep_cnt
, __entry
->rep_idx
,
97 __entry
->ingpa
, __entry
->outgpa
)
100 TRACE_EVENT(kvm_hv_hypercall_done
,
101 TP_PROTO(u64 result
),
105 __field(__u64
, result
)
109 __entry
->result
= result
;
112 TP_printk("result 0x%llx", __entry
->result
)
116 * Tracepoint for Xen hypercall.
118 TRACE_EVENT(kvm_xen_hypercall
,
119 TP_PROTO(u8 cpl
, unsigned long nr
,
120 unsigned long a0
, unsigned long a1
, unsigned long a2
,
121 unsigned long a3
, unsigned long a4
, unsigned long a5
),
122 TP_ARGS(cpl
, nr
, a0
, a1
, a2
, a3
, a4
, a5
),
126 __field(unsigned long, nr
)
127 __field(unsigned long, a0
)
128 __field(unsigned long, a1
)
129 __field(unsigned long, a2
)
130 __field(unsigned long, a3
)
131 __field(unsigned long, a4
)
132 __field(unsigned long, a5
)
146 TP_printk("cpl %d nr 0x%lx a0 0x%lx a1 0x%lx a2 0x%lx a3 0x%lx a4 0x%lx a5 %lx",
147 __entry
->cpl
, __entry
->nr
,
148 __entry
->a0
, __entry
->a1
, __entry
->a2
,
149 __entry
->a3
, __entry
->a4
, __entry
->a5
)
155 * Tracepoint for PIO.
159 #define KVM_PIO_OUT 1
162 TP_PROTO(unsigned int rw
, unsigned int port
, unsigned int size
,
163 unsigned int count
, const void *data
),
164 TP_ARGS(rw
, port
, size
, count
, data
),
167 __field( unsigned int, rw
)
168 __field( unsigned int, port
)
169 __field( unsigned int, size
)
170 __field( unsigned int, count
)
171 __field( unsigned int, val
)
176 __entry
->port
= port
;
177 __entry
->size
= size
;
178 __entry
->count
= count
;
180 __entry
->val
= *(unsigned char *)data
;
182 __entry
->val
= *(unsigned short *)data
;
184 __entry
->val
= *(unsigned int *)data
;
187 TP_printk("pio_%s at 0x%x size %d count %d val 0x%x %s",
188 __entry
->rw
? "write" : "read",
189 __entry
->port
, __entry
->size
, __entry
->count
, __entry
->val
,
190 __entry
->count
> 1 ? "(...)" : "")
194 * Tracepoint for fast mmio.
196 TRACE_EVENT(kvm_fast_mmio
,
208 TP_printk("fast mmio at gpa 0x%llx", __entry
->gpa
)
212 * Tracepoint for cpuid.
214 TRACE_EVENT(kvm_cpuid
,
215 TP_PROTO(unsigned int function
, unsigned int index
, unsigned long rax
,
216 unsigned long rbx
, unsigned long rcx
, unsigned long rdx
,
217 bool found
, bool used_max_basic
),
218 TP_ARGS(function
, index
, rax
, rbx
, rcx
, rdx
, found
, used_max_basic
),
221 __field( unsigned int, function
)
222 __field( unsigned int, index
)
223 __field( unsigned long, rax
)
224 __field( unsigned long, rbx
)
225 __field( unsigned long, rcx
)
226 __field( unsigned long, rdx
)
227 __field( bool, found
)
228 __field( bool, used_max_basic
)
232 __entry
->function
= function
;
233 __entry
->index
= index
;
238 __entry
->found
= found
;
239 __entry
->used_max_basic
= used_max_basic
;
242 TP_printk("func %x idx %x rax %lx rbx %lx rcx %lx rdx %lx, cpuid entry %s%s",
243 __entry
->function
, __entry
->index
, __entry
->rax
,
244 __entry
->rbx
, __entry
->rcx
, __entry
->rdx
,
245 __entry
->found
? "found" : "not found",
246 __entry
->used_max_basic
? ", used max basic" : "")
249 #define AREG(x) { APIC_##x, "APIC_" #x }
251 #define kvm_trace_symbol_apic \
252 AREG(ID), AREG(LVR), AREG(TASKPRI), AREG(ARBPRI), AREG(PROCPRI), \
253 AREG(EOI), AREG(RRR), AREG(LDR), AREG(DFR), AREG(SPIV), AREG(ISR), \
254 AREG(TMR), AREG(IRR), AREG(ESR), AREG(ICR), AREG(ICR2), AREG(LVTT), \
255 AREG(LVTTHMR), AREG(LVTPC), AREG(LVT0), AREG(LVT1), AREG(LVTERR), \
256 AREG(TMICT), AREG(TMCCT), AREG(TDCR), AREG(SELF_IPI), AREG(EFEAT), \
259 * Tracepoint for apic access.
261 TRACE_EVENT(kvm_apic
,
262 TP_PROTO(unsigned int rw
, unsigned int reg
, u64 val
),
263 TP_ARGS(rw
, reg
, val
),
266 __field( unsigned int, rw
)
267 __field( unsigned int, reg
)
277 TP_printk("apic_%s %s = 0x%llx",
278 __entry
->rw
? "write" : "read",
279 __print_symbolic(__entry
->reg
, kvm_trace_symbol_apic
),
283 #define trace_kvm_apic_read(reg, val) trace_kvm_apic(0, reg, val)
284 #define trace_kvm_apic_write(reg, val) trace_kvm_apic(1, reg, val)
286 #define KVM_ISA_VMX 1
287 #define KVM_ISA_SVM 2
289 #define kvm_print_exit_reason(exit_reason, isa) \
290 (isa == KVM_ISA_VMX) ? \
291 __print_symbolic(exit_reason & 0xffff, VMX_EXIT_REASONS) : \
292 __print_symbolic(exit_reason, SVM_EXIT_REASONS), \
293 (isa == KVM_ISA_VMX && exit_reason & ~0xffff) ? " " : "", \
294 (isa == KVM_ISA_VMX) ? \
295 __print_flags(exit_reason & ~0xffff, " ", VMX_EXIT_REASON_FLAGS) : ""
297 #define TRACE_EVENT_KVM_EXIT(name) \
299 TP_PROTO(struct kvm_vcpu *vcpu, u32 isa), \
300 TP_ARGS(vcpu, isa), \
303 __field( unsigned int, exit_reason ) \
304 __field( unsigned long, guest_rip ) \
305 __field( u32, isa ) \
306 __field( u64, info1 ) \
307 __field( u64, info2 ) \
308 __field( u32, intr_info ) \
309 __field( u32, error_code ) \
310 __field( unsigned int, vcpu_id ) \
314 __entry->guest_rip = kvm_rip_read(vcpu); \
315 __entry->isa = isa; \
316 __entry->vcpu_id = vcpu->vcpu_id; \
317 kvm_x86_call(get_exit_info)(vcpu, \
318 &__entry->exit_reason, \
321 &__entry->intr_info, \
322 &__entry->error_code); \
325 TP_printk("vcpu %u reason %s%s%s rip 0x%lx info1 0x%016llx " \
326 "info2 0x%016llx intr_info 0x%08x error_code 0x%08x", \
328 kvm_print_exit_reason(__entry->exit_reason, __entry->isa), \
329 __entry->guest_rip, __entry->info1, __entry->info2, \
330 __entry->intr_info, __entry->error_code) \
334 * Tracepoint for kvm guest exit:
336 TRACE_EVENT_KVM_EXIT(kvm_exit
);
339 * Tracepoint for kvm interrupt injection:
341 TRACE_EVENT(kvm_inj_virq
,
342 TP_PROTO(unsigned int vector
, bool soft
, bool reinjected
),
343 TP_ARGS(vector
, soft
, reinjected
),
346 __field( unsigned int, vector
)
347 __field( bool, soft
)
348 __field( bool, reinjected
)
352 __entry
->vector
= vector
;
353 __entry
->soft
= soft
;
354 __entry
->reinjected
= reinjected
;
357 TP_printk("%s 0x%x%s",
358 __entry
->soft
? "Soft/INTn" : "IRQ", __entry
->vector
,
359 __entry
->reinjected
? " [reinjected]" : "")
362 #define EXS(x) { x##_VECTOR, "#" #x }
364 #define kvm_trace_sym_exc \
365 EXS(DE), EXS(DB), EXS(BP), EXS(OF), EXS(BR), EXS(UD), EXS(NM), \
366 EXS(DF), EXS(TS), EXS(NP), EXS(SS), EXS(GP), EXS(PF), \
367 EXS(MF), EXS(AC), EXS(MC)
370 * Tracepoint for kvm interrupt injection:
372 TRACE_EVENT(kvm_inj_exception
,
373 TP_PROTO(unsigned exception
, bool has_error
, unsigned error_code
,
375 TP_ARGS(exception
, has_error
, error_code
, reinjected
),
378 __field( u8
, exception
)
379 __field( u8
, has_error
)
380 __field( u32
, error_code
)
381 __field( bool, reinjected
)
385 __entry
->exception
= exception
;
386 __entry
->has_error
= has_error
;
387 __entry
->error_code
= error_code
;
388 __entry
->reinjected
= reinjected
;
391 TP_printk("%s%s%s%s%s",
392 __print_symbolic(__entry
->exception
, kvm_trace_sym_exc
),
393 !__entry
->has_error
? "" : " (",
394 !__entry
->has_error
? "" : __print_symbolic(__entry
->error_code
, { }),
395 !__entry
->has_error
? "" : ")",
396 __entry
->reinjected
? " [reinjected]" : "")
400 * Tracepoint for page fault.
402 TRACE_EVENT(kvm_page_fault
,
403 TP_PROTO(struct kvm_vcpu
*vcpu
, u64 fault_address
, u64 error_code
),
404 TP_ARGS(vcpu
, fault_address
, error_code
),
407 __field( unsigned int, vcpu_id
)
408 __field( unsigned long, guest_rip
)
409 __field( u64
, fault_address
)
410 __field( u64
, error_code
)
414 __entry
->vcpu_id
= vcpu
->vcpu_id
;
415 __entry
->guest_rip
= kvm_rip_read(vcpu
);
416 __entry
->fault_address
= fault_address
;
417 __entry
->error_code
= error_code
;
420 TP_printk("vcpu %u rip 0x%lx address 0x%016llx error_code 0x%llx",
421 __entry
->vcpu_id
, __entry
->guest_rip
,
422 __entry
->fault_address
, __entry
->error_code
)
426 * Tracepoint for guest MSR access.
429 TP_PROTO(unsigned write
, u32 ecx
, u64 data
, bool exception
),
430 TP_ARGS(write
, ecx
, data
, exception
),
433 __field( unsigned, write
)
436 __field( u8
, exception
)
440 __entry
->write
= write
;
442 __entry
->data
= data
;
443 __entry
->exception
= exception
;
446 TP_printk("msr_%s %x = 0x%llx%s",
447 __entry
->write
? "write" : "read",
448 __entry
->ecx
, __entry
->data
,
449 __entry
->exception
? " (#GP)" : "")
452 #define trace_kvm_msr_read(ecx, data) trace_kvm_msr(0, ecx, data, false)
453 #define trace_kvm_msr_write(ecx, data) trace_kvm_msr(1, ecx, data, false)
454 #define trace_kvm_msr_read_ex(ecx) trace_kvm_msr(0, ecx, 0, true)
455 #define trace_kvm_msr_write_ex(ecx, data) trace_kvm_msr(1, ecx, data, true)
458 * Tracepoint for guest CR access.
461 TP_PROTO(unsigned int rw
, unsigned int cr
, unsigned long val
),
462 TP_ARGS(rw
, cr
, val
),
465 __field( unsigned int, rw
)
466 __field( unsigned int, cr
)
467 __field( unsigned long, val
)
476 TP_printk("cr_%s %x = 0x%lx",
477 __entry
->rw
? "write" : "read",
478 __entry
->cr
, __entry
->val
)
481 #define trace_kvm_cr_read(cr, val) trace_kvm_cr(0, cr, val)
482 #define trace_kvm_cr_write(cr, val) trace_kvm_cr(1, cr, val)
484 TRACE_EVENT(kvm_pic_set_irq
,
485 TP_PROTO(__u8 chip
, __u8 pin
, __u8 elcr
, __u8 imr
, bool coalesced
),
486 TP_ARGS(chip
, pin
, elcr
, imr
, coalesced
),
489 __field( __u8
, chip
)
491 __field( __u8
, elcr
)
493 __field( bool, coalesced
)
497 __entry
->chip
= chip
;
499 __entry
->elcr
= elcr
;
501 __entry
->coalesced
= coalesced
;
504 TP_printk("chip %u pin %u (%s%s)%s",
505 __entry
->chip
, __entry
->pin
,
506 (__entry
->elcr
& (1 << __entry
->pin
)) ? "level":"edge",
507 (__entry
->imr
& (1 << __entry
->pin
)) ? "|masked":"",
508 __entry
->coalesced
? " (coalesced)" : "")
511 #define kvm_apic_dst_shorthand \
515 {0x3, "all-but-self"}
517 TRACE_EVENT(kvm_apic_ipi
,
518 TP_PROTO(__u32 icr_low
, __u32 dest_id
),
519 TP_ARGS(icr_low
, dest_id
),
522 __field( __u32
, icr_low
)
523 __field( __u32
, dest_id
)
527 __entry
->icr_low
= icr_low
;
528 __entry
->dest_id
= dest_id
;
531 TP_printk("dst %x vec %u (%s|%s|%s|%s|%s)",
532 __entry
->dest_id
, (u8
)__entry
->icr_low
,
533 __print_symbolic((__entry
->icr_low
>> 8 & 0x7),
535 (__entry
->icr_low
& (1<<11)) ? "logical" : "physical",
536 (__entry
->icr_low
& (1<<14)) ? "assert" : "de-assert",
537 (__entry
->icr_low
& (1<<15)) ? "level" : "edge",
538 __print_symbolic((__entry
->icr_low
>> 18 & 0x3),
539 kvm_apic_dst_shorthand
))
542 TRACE_EVENT(kvm_apic_accept_irq
,
543 TP_PROTO(__u32 apicid
, __u16 dm
, __u16 tm
, __u8 vec
),
544 TP_ARGS(apicid
, dm
, tm
, vec
),
547 __field( __u32
, apicid
)
554 __entry
->apicid
= apicid
;
560 TP_printk("apicid %x vec %u (%s|%s)",
561 __entry
->apicid
, __entry
->vec
,
562 __print_symbolic((__entry
->dm
>> 8 & 0x7), kvm_deliver_mode
),
563 __entry
->tm
? "level" : "edge")
567 TP_PROTO(struct kvm_lapic
*apic
, int vector
),
568 TP_ARGS(apic
, vector
),
571 __field( __u32
, apicid
)
572 __field( int, vector
)
576 __entry
->apicid
= apic
->vcpu
->vcpu_id
;
577 __entry
->vector
= vector
;
580 TP_printk("apicid %x vector %d", __entry
->apicid
, __entry
->vector
)
583 TRACE_EVENT(kvm_pv_eoi
,
584 TP_PROTO(struct kvm_lapic
*apic
, int vector
),
585 TP_ARGS(apic
, vector
),
588 __field( __u32
, apicid
)
589 __field( int, vector
)
593 __entry
->apicid
= apic
->vcpu
->vcpu_id
;
594 __entry
->vector
= vector
;
597 TP_printk("apicid %x vector %d", __entry
->apicid
, __entry
->vector
)
601 * Tracepoint for nested VMRUN
603 TRACE_EVENT(kvm_nested_vmenter
,
604 TP_PROTO(__u64 rip
, __u64 vmcb
, __u64 nested_rip
, __u32 int_ctl
,
605 __u32 event_inj
, bool tdp_enabled
, __u64 guest_tdp_pgd
,
606 __u64 guest_cr3
, __u32 isa
),
607 TP_ARGS(rip
, vmcb
, nested_rip
, int_ctl
, event_inj
, tdp_enabled
,
608 guest_tdp_pgd
, guest_cr3
, isa
),
611 __field( __u64
, rip
)
612 __field( __u64
, vmcb
)
613 __field( __u64
, nested_rip
)
614 __field( __u32
, int_ctl
)
615 __field( __u32
, event_inj
)
616 __field( bool, tdp_enabled
)
617 __field( __u64
, guest_pgd
)
618 __field( __u32
, isa
)
623 __entry
->vmcb
= vmcb
;
624 __entry
->nested_rip
= nested_rip
;
625 __entry
->int_ctl
= int_ctl
;
626 __entry
->event_inj
= event_inj
;
627 __entry
->tdp_enabled
= tdp_enabled
;
628 __entry
->guest_pgd
= tdp_enabled
? guest_tdp_pgd
: guest_cr3
;
632 TP_printk("rip: 0x%016llx %s: 0x%016llx nested_rip: 0x%016llx "
633 "int_ctl: 0x%08x event_inj: 0x%08x nested_%s=%s %s: 0x%016llx",
635 __entry
->isa
== KVM_ISA_VMX
? "vmcs" : "vmcb",
640 __entry
->isa
== KVM_ISA_VMX
? "ept" : "npt",
641 __entry
->tdp_enabled
? "y" : "n",
642 !__entry
->tdp_enabled
? "guest_cr3" :
643 __entry
->isa
== KVM_ISA_VMX
? "nested_eptp" : "nested_cr3",
647 TRACE_EVENT(kvm_nested_intercepts
,
648 TP_PROTO(__u16 cr_read
, __u16 cr_write
, __u32 exceptions
,
649 __u32 intercept1
, __u32 intercept2
, __u32 intercept3
),
650 TP_ARGS(cr_read
, cr_write
, exceptions
, intercept1
,
651 intercept2
, intercept3
),
654 __field( __u16
, cr_read
)
655 __field( __u16
, cr_write
)
656 __field( __u32
, exceptions
)
657 __field( __u32
, intercept1
)
658 __field( __u32
, intercept2
)
659 __field( __u32
, intercept3
)
663 __entry
->cr_read
= cr_read
;
664 __entry
->cr_write
= cr_write
;
665 __entry
->exceptions
= exceptions
;
666 __entry
->intercept1
= intercept1
;
667 __entry
->intercept2
= intercept2
;
668 __entry
->intercept3
= intercept3
;
671 TP_printk("cr_read: %04x cr_write: %04x excp: %08x "
672 "intercepts: %08x %08x %08x",
673 __entry
->cr_read
, __entry
->cr_write
, __entry
->exceptions
,
674 __entry
->intercept1
, __entry
->intercept2
, __entry
->intercept3
)
677 * Tracepoint for #VMEXIT while nested
679 TRACE_EVENT_KVM_EXIT(kvm_nested_vmexit
);
682 * Tracepoint for #VMEXIT reinjected to the guest
684 TRACE_EVENT(kvm_nested_vmexit_inject
,
685 TP_PROTO(__u32 exit_code
,
686 __u64 exit_info1
, __u64 exit_info2
,
687 __u32 exit_int_info
, __u32 exit_int_info_err
, __u32 isa
),
688 TP_ARGS(exit_code
, exit_info1
, exit_info2
,
689 exit_int_info
, exit_int_info_err
, isa
),
692 __field( __u32
, exit_code
)
693 __field( __u64
, exit_info1
)
694 __field( __u64
, exit_info2
)
695 __field( __u32
, exit_int_info
)
696 __field( __u32
, exit_int_info_err
)
697 __field( __u32
, isa
)
701 __entry
->exit_code
= exit_code
;
702 __entry
->exit_info1
= exit_info1
;
703 __entry
->exit_info2
= exit_info2
;
704 __entry
->exit_int_info
= exit_int_info
;
705 __entry
->exit_int_info_err
= exit_int_info_err
;
709 TP_printk("reason: %s%s%s ext_inf1: 0x%016llx "
710 "ext_inf2: 0x%016llx ext_int: 0x%08x ext_int_err: 0x%08x",
711 kvm_print_exit_reason(__entry
->exit_code
, __entry
->isa
),
712 __entry
->exit_info1
, __entry
->exit_info2
,
713 __entry
->exit_int_info
, __entry
->exit_int_info_err
)
717 * Tracepoint for nested #vmexit because of interrupt pending
719 TRACE_EVENT(kvm_nested_intr_vmexit
,
724 __field( __u64
, rip
)
731 TP_printk("rip: 0x%016llx", __entry
->rip
)
735 * Tracepoint for nested #vmexit because of interrupt pending
737 TRACE_EVENT(kvm_invlpga
,
738 TP_PROTO(__u64 rip
, unsigned int asid
, u64 address
),
739 TP_ARGS(rip
, asid
, address
),
742 __field( __u64
, rip
)
743 __field( unsigned int, asid
)
744 __field( __u64
, address
)
749 __entry
->asid
= asid
;
750 __entry
->address
= address
;
753 TP_printk("rip: 0x%016llx asid: %u address: 0x%016llx",
754 __entry
->rip
, __entry
->asid
, __entry
->address
)
758 * Tracepoint for nested #vmexit because of interrupt pending
760 TRACE_EVENT(kvm_skinit
,
761 TP_PROTO(__u64 rip
, __u32 slb
),
765 __field( __u64
, rip
)
766 __field( __u32
, slb
)
774 TP_printk("rip: 0x%016llx slb: 0x%08x",
775 __entry
->rip
, __entry
->slb
)
778 #define KVM_EMUL_INSN_F_CR0_PE (1 << 0)
779 #define KVM_EMUL_INSN_F_EFL_VM (1 << 1)
780 #define KVM_EMUL_INSN_F_CS_D (1 << 2)
781 #define KVM_EMUL_INSN_F_CS_L (1 << 3)
783 #define kvm_trace_symbol_emul_flags \
785 { KVM_EMUL_INSN_F_CR0_PE \
786 | KVM_EMUL_INSN_F_EFL_VM, "vm16" }, \
787 { KVM_EMUL_INSN_F_CR0_PE, "prot16" }, \
788 { KVM_EMUL_INSN_F_CR0_PE \
789 | KVM_EMUL_INSN_F_CS_D, "prot32" }, \
790 { KVM_EMUL_INSN_F_CR0_PE \
791 | KVM_EMUL_INSN_F_CS_L, "prot64" }
793 #define kei_decode_mode(mode) ({ \
796 case X86EMUL_MODE_REAL: \
799 case X86EMUL_MODE_VM86: \
800 flags = KVM_EMUL_INSN_F_EFL_VM; \
802 case X86EMUL_MODE_PROT16: \
803 flags = KVM_EMUL_INSN_F_CR0_PE; \
805 case X86EMUL_MODE_PROT32: \
806 flags = KVM_EMUL_INSN_F_CR0_PE \
807 | KVM_EMUL_INSN_F_CS_D; \
809 case X86EMUL_MODE_PROT64: \
810 flags = KVM_EMUL_INSN_F_CR0_PE \
811 | KVM_EMUL_INSN_F_CS_L; \
817 TRACE_EVENT(kvm_emulate_insn
,
818 TP_PROTO(struct kvm_vcpu
*vcpu
, __u8 failed
),
819 TP_ARGS(vcpu
, failed
),
822 __field( __u64
, rip
)
823 __field( __u32
, csbase
)
825 __array( __u8
, insn
, 15 )
826 __field( __u8
, flags
)
827 __field( __u8
, failed
)
831 __entry
->csbase
= kvm_x86_call(get_segment_base
)(vcpu
,
833 __entry
->len
= vcpu
->arch
.emulate_ctxt
->fetch
.ptr
834 - vcpu
->arch
.emulate_ctxt
->fetch
.data
;
835 __entry
->rip
= vcpu
->arch
.emulate_ctxt
->_eip
- __entry
->len
;
836 memcpy(__entry
->insn
,
837 vcpu
->arch
.emulate_ctxt
->fetch
.data
,
839 __entry
->flags
= kei_decode_mode(vcpu
->arch
.emulate_ctxt
->mode
);
840 __entry
->failed
= failed
;
843 TP_printk("%x:%llx:%s (%s)%s",
844 __entry
->csbase
, __entry
->rip
,
845 __print_hex(__entry
->insn
, __entry
->len
),
846 __print_symbolic(__entry
->flags
,
847 kvm_trace_symbol_emul_flags
),
848 __entry
->failed
? " failed" : ""
852 #define trace_kvm_emulate_insn_start(vcpu) trace_kvm_emulate_insn(vcpu, 0)
853 #define trace_kvm_emulate_insn_failed(vcpu) trace_kvm_emulate_insn(vcpu, 1)
857 TP_PROTO(gva_t gva
, gpa_t gpa
, bool write
, bool gpa_match
),
858 TP_ARGS(gva
, gpa
, write
, gpa_match
),
864 __field(bool, gpa_match
)
870 __entry
->write
= write
;
871 __entry
->gpa_match
= gpa_match
874 TP_printk("gva %#lx gpa %#llx %s %s", __entry
->gva
, __entry
->gpa
,
875 __entry
->write
? "Write" : "Read",
876 __entry
->gpa_match
? "GPA" : "GVA")
879 TRACE_EVENT(kvm_write_tsc_offset
,
880 TP_PROTO(unsigned int vcpu_id
, __u64 previous_tsc_offset
,
881 __u64 next_tsc_offset
),
882 TP_ARGS(vcpu_id
, previous_tsc_offset
, next_tsc_offset
),
885 __field( unsigned int, vcpu_id
)
886 __field( __u64
, previous_tsc_offset
)
887 __field( __u64
, next_tsc_offset
)
891 __entry
->vcpu_id
= vcpu_id
;
892 __entry
->previous_tsc_offset
= previous_tsc_offset
;
893 __entry
->next_tsc_offset
= next_tsc_offset
;
896 TP_printk("vcpu=%u prev=%llu next=%llu", __entry
->vcpu_id
,
897 __entry
->previous_tsc_offset
, __entry
->next_tsc_offset
)
902 #define host_clocks \
903 {VDSO_CLOCKMODE_NONE, "none"}, \
904 {VDSO_CLOCKMODE_TSC, "tsc"} \
906 TRACE_EVENT(kvm_update_master_clock,
907 TP_PROTO(bool use_master_clock
, unsigned int host_clock
, bool offset_matched
),
908 TP_ARGS(use_master_clock
, host_clock
, offset_matched
),
911 __field( bool, use_master_clock
)
912 __field( unsigned int, host_clock
)
913 __field( bool, offset_matched
)
917 __entry
->use_master_clock
= use_master_clock
;
918 __entry
->host_clock
= host_clock
;
919 __entry
->offset_matched
= offset_matched
;
922 TP_printk("masterclock %d hostclock %s offsetmatched %u",
923 __entry
->use_master_clock
,
924 __print_symbolic(__entry
->host_clock
, host_clocks
),
925 __entry
->offset_matched
)
928 TRACE_EVENT(kvm_track_tsc
,
929 TP_PROTO(unsigned int vcpu_id
, unsigned int nr_matched
,
930 unsigned int online_vcpus
, bool use_master_clock
,
931 unsigned int host_clock
),
932 TP_ARGS(vcpu_id
, nr_matched
, online_vcpus
, use_master_clock
,
936 __field( unsigned int, vcpu_id
)
937 __field( unsigned int, nr_vcpus_matched_tsc
)
938 __field( unsigned int, online_vcpus
)
939 __field( bool, use_master_clock
)
940 __field( unsigned int, host_clock
)
944 __entry
->vcpu_id
= vcpu_id
;
945 __entry
->nr_vcpus_matched_tsc
= nr_matched
;
946 __entry
->online_vcpus
= online_vcpus
;
947 __entry
->use_master_clock
= use_master_clock
;
948 __entry
->host_clock
= host_clock
;
951 TP_printk("vcpu_id %u masterclock %u offsetmatched %u nr_online %u"
953 __entry
->vcpu_id
, __entry
->use_master_clock
,
954 __entry
->nr_vcpus_matched_tsc
, __entry
->online_vcpus
,
955 __print_symbolic(__entry
->host_clock
, host_clocks
))
958 #endif /* CONFIG_X86_64 */
961 * Tracepoint for PML full VMEXIT.
963 TRACE_EVENT(kvm_pml_full
,
964 TP_PROTO(unsigned int vcpu_id
),
968 __field( unsigned int, vcpu_id
)
972 __entry
->vcpu_id
= vcpu_id
;
975 TP_printk("vcpu %d: PML full", __entry
->vcpu_id
)
978 TRACE_EVENT(kvm_ple_window_update
,
979 TP_PROTO(unsigned int vcpu_id
, unsigned int new, unsigned int old
),
980 TP_ARGS(vcpu_id
, new, old
),
983 __field( unsigned int, vcpu_id
)
984 __field( unsigned int, new )
985 __field( unsigned int, old
)
989 __entry
->vcpu_id
= vcpu_id
;
994 TP_printk("vcpu %u old %u new %u (%s)",
995 __entry
->vcpu_id
, __entry
->old
, __entry
->new,
996 __entry
->old
< __entry
->new ? "growed" : "shrinked")
999 TRACE_EVENT(kvm_pvclock_update
,
1000 TP_PROTO(unsigned int vcpu_id
, struct pvclock_vcpu_time_info
*pvclock
),
1001 TP_ARGS(vcpu_id
, pvclock
),
1004 __field( unsigned int, vcpu_id
)
1005 __field( __u32
, version
)
1006 __field( __u64
, tsc_timestamp
)
1007 __field( __u64
, system_time
)
1008 __field( __u32
, tsc_to_system_mul
)
1009 __field( __s8
, tsc_shift
)
1010 __field( __u8
, flags
)
1014 __entry
->vcpu_id
= vcpu_id
;
1015 __entry
->version
= pvclock
->version
;
1016 __entry
->tsc_timestamp
= pvclock
->tsc_timestamp
;
1017 __entry
->system_time
= pvclock
->system_time
;
1018 __entry
->tsc_to_system_mul
= pvclock
->tsc_to_system_mul
;
1019 __entry
->tsc_shift
= pvclock
->tsc_shift
;
1020 __entry
->flags
= pvclock
->flags
;
1023 TP_printk("vcpu_id %u, pvclock { version %u, tsc_timestamp 0x%llx, "
1024 "system_time 0x%llx, tsc_to_system_mul 0x%x, tsc_shift %d, "
1028 __entry
->tsc_timestamp
,
1029 __entry
->system_time
,
1030 __entry
->tsc_to_system_mul
,
1035 TRACE_EVENT(kvm_wait_lapic_expire
,
1036 TP_PROTO(unsigned int vcpu_id
, s64 delta
),
1037 TP_ARGS(vcpu_id
, delta
),
1040 __field( unsigned int, vcpu_id
)
1041 __field( s64
, delta
)
1045 __entry
->vcpu_id
= vcpu_id
;
1046 __entry
->delta
= delta
;
1049 TP_printk("vcpu %u: delta %lld (%s)",
1052 __entry
->delta
< 0 ? "early" : "late")
1055 TRACE_EVENT(kvm_smm_transition
,
1056 TP_PROTO(unsigned int vcpu_id
, u64 smbase
, bool entering
),
1057 TP_ARGS(vcpu_id
, smbase
, entering
),
1060 __field( unsigned int, vcpu_id
)
1061 __field( u64
, smbase
)
1062 __field( bool, entering
)
1066 __entry
->vcpu_id
= vcpu_id
;
1067 __entry
->smbase
= smbase
;
1068 __entry
->entering
= entering
;
1071 TP_printk("vcpu %u: %s SMM, smbase 0x%llx",
1073 __entry
->entering
? "entering" : "leaving",
1078 * Tracepoint for VT-d posted-interrupts and AMD-Vi Guest Virtual APIC.
1080 TRACE_EVENT(kvm_pi_irte_update
,
1081 TP_PROTO(unsigned int host_irq
, unsigned int vcpu_id
,
1082 unsigned int gsi
, unsigned int gvec
,
1083 u64 pi_desc_addr
, bool set
),
1084 TP_ARGS(host_irq
, vcpu_id
, gsi
, gvec
, pi_desc_addr
, set
),
1087 __field( unsigned int, host_irq
)
1088 __field( unsigned int, vcpu_id
)
1089 __field( unsigned int, gsi
)
1090 __field( unsigned int, gvec
)
1091 __field( u64
, pi_desc_addr
)
1092 __field( bool, set
)
1096 __entry
->host_irq
= host_irq
;
1097 __entry
->vcpu_id
= vcpu_id
;
1099 __entry
->gvec
= gvec
;
1100 __entry
->pi_desc_addr
= pi_desc_addr
;
1104 TP_printk("PI is %s for irq %u, vcpu %u, gsi: 0x%x, "
1105 "gvec: 0x%x, pi_desc_addr: 0x%llx",
1106 __entry
->set
? "enabled and being updated" : "disabled",
1111 __entry
->pi_desc_addr
)
1115 * Tracepoint for kvm_hv_notify_acked_sint.
1117 TRACE_EVENT(kvm_hv_notify_acked_sint
,
1118 TP_PROTO(int vcpu_id
, u32 sint
),
1119 TP_ARGS(vcpu_id
, sint
),
1122 __field(int, vcpu_id
)
1127 __entry
->vcpu_id
= vcpu_id
;
1128 __entry
->sint
= sint
;
1131 TP_printk("vcpu_id %d sint %u", __entry
->vcpu_id
, __entry
->sint
)
1135 * Tracepoint for synic_set_irq.
1137 TRACE_EVENT(kvm_hv_synic_set_irq
,
1138 TP_PROTO(int vcpu_id
, u32 sint
, int vector
, int ret
),
1139 TP_ARGS(vcpu_id
, sint
, vector
, ret
),
1142 __field(int, vcpu_id
)
1144 __field(int, vector
)
1149 __entry
->vcpu_id
= vcpu_id
;
1150 __entry
->sint
= sint
;
1151 __entry
->vector
= vector
;
1155 TP_printk("vcpu_id %d sint %u vector %d ret %d",
1156 __entry
->vcpu_id
, __entry
->sint
, __entry
->vector
,
1161 * Tracepoint for kvm_hv_synic_send_eoi.
1163 TRACE_EVENT(kvm_hv_synic_send_eoi
,
1164 TP_PROTO(int vcpu_id
, int vector
),
1165 TP_ARGS(vcpu_id
, vector
),
1168 __field(int, vcpu_id
)
1170 __field(int, vector
)
1175 __entry
->vcpu_id
= vcpu_id
;
1176 __entry
->vector
= vector
;
1179 TP_printk("vcpu_id %d vector %d", __entry
->vcpu_id
, __entry
->vector
)
1183 * Tracepoint for synic_set_msr.
1185 TRACE_EVENT(kvm_hv_synic_set_msr
,
1186 TP_PROTO(int vcpu_id
, u32 msr
, u64 data
, bool host
),
1187 TP_ARGS(vcpu_id
, msr
, data
, host
),
1190 __field(int, vcpu_id
)
1197 __entry
->vcpu_id
= vcpu_id
;
1199 __entry
->data
= data
;
1200 __entry
->host
= host
1203 TP_printk("vcpu_id %d msr 0x%x data 0x%llx host %d",
1204 __entry
->vcpu_id
, __entry
->msr
, __entry
->data
, __entry
->host
)
1208 * Tracepoint for stimer_set_config.
1210 TRACE_EVENT(kvm_hv_stimer_set_config
,
1211 TP_PROTO(int vcpu_id
, int timer_index
, u64 config
, bool host
),
1212 TP_ARGS(vcpu_id
, timer_index
, config
, host
),
1215 __field(int, vcpu_id
)
1216 __field(int, timer_index
)
1217 __field(u64
, config
)
1222 __entry
->vcpu_id
= vcpu_id
;
1223 __entry
->timer_index
= timer_index
;
1224 __entry
->config
= config
;
1225 __entry
->host
= host
;
1228 TP_printk("vcpu_id %d timer %d config 0x%llx host %d",
1229 __entry
->vcpu_id
, __entry
->timer_index
, __entry
->config
,
1234 * Tracepoint for stimer_set_count.
1236 TRACE_EVENT(kvm_hv_stimer_set_count
,
1237 TP_PROTO(int vcpu_id
, int timer_index
, u64 count
, bool host
),
1238 TP_ARGS(vcpu_id
, timer_index
, count
, host
),
1241 __field(int, vcpu_id
)
1242 __field(int, timer_index
)
1248 __entry
->vcpu_id
= vcpu_id
;
1249 __entry
->timer_index
= timer_index
;
1250 __entry
->count
= count
;
1251 __entry
->host
= host
;
1254 TP_printk("vcpu_id %d timer %d count %llu host %d",
1255 __entry
->vcpu_id
, __entry
->timer_index
, __entry
->count
,
1260 * Tracepoint for stimer_start(periodic timer case).
1262 TRACE_EVENT(kvm_hv_stimer_start_periodic
,
1263 TP_PROTO(int vcpu_id
, int timer_index
, u64 time_now
, u64 exp_time
),
1264 TP_ARGS(vcpu_id
, timer_index
, time_now
, exp_time
),
1267 __field(int, vcpu_id
)
1268 __field(int, timer_index
)
1269 __field(u64
, time_now
)
1270 __field(u64
, exp_time
)
1274 __entry
->vcpu_id
= vcpu_id
;
1275 __entry
->timer_index
= timer_index
;
1276 __entry
->time_now
= time_now
;
1277 __entry
->exp_time
= exp_time
;
1280 TP_printk("vcpu_id %d timer %d time_now %llu exp_time %llu",
1281 __entry
->vcpu_id
, __entry
->timer_index
, __entry
->time_now
,
1286 * Tracepoint for stimer_start(one-shot timer case).
1288 TRACE_EVENT(kvm_hv_stimer_start_one_shot
,
1289 TP_PROTO(int vcpu_id
, int timer_index
, u64 time_now
, u64 count
),
1290 TP_ARGS(vcpu_id
, timer_index
, time_now
, count
),
1293 __field(int, vcpu_id
)
1294 __field(int, timer_index
)
1295 __field(u64
, time_now
)
1300 __entry
->vcpu_id
= vcpu_id
;
1301 __entry
->timer_index
= timer_index
;
1302 __entry
->time_now
= time_now
;
1303 __entry
->count
= count
;
1306 TP_printk("vcpu_id %d timer %d time_now %llu count %llu",
1307 __entry
->vcpu_id
, __entry
->timer_index
, __entry
->time_now
,
1312 * Tracepoint for stimer_timer_callback.
1314 TRACE_EVENT(kvm_hv_stimer_callback
,
1315 TP_PROTO(int vcpu_id
, int timer_index
),
1316 TP_ARGS(vcpu_id
, timer_index
),
1319 __field(int, vcpu_id
)
1320 __field(int, timer_index
)
1324 __entry
->vcpu_id
= vcpu_id
;
1325 __entry
->timer_index
= timer_index
;
1328 TP_printk("vcpu_id %d timer %d",
1329 __entry
->vcpu_id
, __entry
->timer_index
)
1333 * Tracepoint for stimer_expiration.
1335 TRACE_EVENT(kvm_hv_stimer_expiration
,
1336 TP_PROTO(int vcpu_id
, int timer_index
, int direct
, int msg_send_result
),
1337 TP_ARGS(vcpu_id
, timer_index
, direct
, msg_send_result
),
1340 __field(int, vcpu_id
)
1341 __field(int, timer_index
)
1342 __field(int, direct
)
1343 __field(int, msg_send_result
)
1347 __entry
->vcpu_id
= vcpu_id
;
1348 __entry
->timer_index
= timer_index
;
1349 __entry
->direct
= direct
;
1350 __entry
->msg_send_result
= msg_send_result
;
1353 TP_printk("vcpu_id %d timer %d direct %d send result %d",
1354 __entry
->vcpu_id
, __entry
->timer_index
,
1355 __entry
->direct
, __entry
->msg_send_result
)
1359 * Tracepoint for stimer_cleanup.
1361 TRACE_EVENT(kvm_hv_stimer_cleanup
,
1362 TP_PROTO(int vcpu_id
, int timer_index
),
1363 TP_ARGS(vcpu_id
, timer_index
),
1366 __field(int, vcpu_id
)
1367 __field(int, timer_index
)
1371 __entry
->vcpu_id
= vcpu_id
;
1372 __entry
->timer_index
= timer_index
;
1375 TP_printk("vcpu_id %d timer %d",
1376 __entry
->vcpu_id
, __entry
->timer_index
)
1379 #define kvm_print_apicv_inhibit_reasons(inhibits) \
1380 (inhibits), (inhibits) ? " " : "", \
1381 (inhibits) ? __print_flags(inhibits, "|", APICV_INHIBIT_REASONS) : ""
1383 TRACE_EVENT(kvm_apicv_inhibit_changed
,
1384 TP_PROTO(int reason
, bool set
, unsigned long inhibits
),
1385 TP_ARGS(reason
, set
, inhibits
),
1388 __field(int, reason
)
1390 __field(unsigned long, inhibits
)
1394 __entry
->reason
= reason
;
1396 __entry
->inhibits
= inhibits
;
1399 TP_printk("%s reason=%u, inhibits=0x%lx%s%s",
1400 __entry
->set
? "set" : "cleared",
1402 kvm_print_apicv_inhibit_reasons(__entry
->inhibits
))
1405 TRACE_EVENT(kvm_apicv_accept_irq
,
1406 TP_PROTO(__u32 apicid
, __u16 dm
, __u16 tm
, __u8 vec
),
1407 TP_ARGS(apicid
, dm
, tm
, vec
),
1410 __field( __u32
, apicid
)
1411 __field( __u16
, dm
)
1412 __field( __u16
, tm
)
1413 __field( __u8
, vec
)
1417 __entry
->apicid
= apicid
;
1423 TP_printk("apicid %x vec %u (%s|%s)",
1424 __entry
->apicid
, __entry
->vec
,
1425 __print_symbolic((__entry
->dm
>> 8 & 0x7), kvm_deliver_mode
),
1426 __entry
->tm
? "level" : "edge")
1430 * Tracepoint for AMD AVIC
1432 TRACE_EVENT(kvm_avic_incomplete_ipi
,
1433 TP_PROTO(u32 vcpu
, u32 icrh
, u32 icrl
, u32 id
, u32 index
),
1434 TP_ARGS(vcpu
, icrh
, icrl
, id
, index
),
1445 __entry
->vcpu
= vcpu
;
1446 __entry
->icrh
= icrh
;
1447 __entry
->icrl
= icrl
;
1449 __entry
->index
= index
;
1452 TP_printk("vcpu=%u, icrh:icrl=%#010x:%08x, id=%u, index=%u",
1453 __entry
->vcpu
, __entry
->icrh
, __entry
->icrl
,
1454 __entry
->id
, __entry
->index
)
1457 TRACE_EVENT(kvm_avic_unaccelerated_access
,
1458 TP_PROTO(u32 vcpu
, u32 offset
, bool ft
, bool rw
, u32 vec
),
1459 TP_ARGS(vcpu
, offset
, ft
, rw
, vec
),
1463 __field(u32
, offset
)
1470 __entry
->vcpu
= vcpu
;
1471 __entry
->offset
= offset
;
1477 TP_printk("vcpu=%u, offset=%#x(%s), %s, %s, vec=%#x",
1480 __print_symbolic(__entry
->offset
, kvm_trace_symbol_apic
),
1481 __entry
->ft
? "trap" : "fault",
1482 __entry
->rw
? "write" : "read",
1486 TRACE_EVENT(kvm_avic_ga_log
,
1487 TP_PROTO(u32 vmid
, u32 vcpuid
),
1488 TP_ARGS(vmid
, vcpuid
),
1492 __field(u32
, vcpuid
)
1496 __entry
->vmid
= vmid
;
1497 __entry
->vcpuid
= vcpuid
;
1500 TP_printk("vmid=%u, vcpuid=%u",
1501 __entry
->vmid
, __entry
->vcpuid
)
1504 TRACE_EVENT(kvm_avic_kick_vcpu_slowpath
,
1505 TP_PROTO(u32 icrh
, u32 icrl
, u32 index
),
1506 TP_ARGS(icrh
, icrl
, index
),
1515 __entry
->icrh
= icrh
;
1516 __entry
->icrl
= icrl
;
1517 __entry
->index
= index
;
1520 TP_printk("icrh:icrl=%#08x:%08x, index=%u",
1521 __entry
->icrh
, __entry
->icrl
, __entry
->index
)
1524 TRACE_EVENT(kvm_avic_doorbell
,
1525 TP_PROTO(u32 vcpuid
, u32 apicid
),
1526 TP_ARGS(vcpuid
, apicid
),
1529 __field(u32
, vcpuid
)
1530 __field(u32
, apicid
)
1534 __entry
->vcpuid
= vcpuid
;
1535 __entry
->apicid
= apicid
;
1538 TP_printk("vcpuid=%u, apicid=%u",
1539 __entry
->vcpuid
, __entry
->apicid
)
1542 TRACE_EVENT(kvm_hv_timer_state
,
1543 TP_PROTO(unsigned int vcpu_id
, unsigned int hv_timer_in_use
),
1544 TP_ARGS(vcpu_id
, hv_timer_in_use
),
1546 __field(unsigned int, vcpu_id
)
1547 __field(unsigned int, hv_timer_in_use
)
1550 __entry
->vcpu_id
= vcpu_id
;
1551 __entry
->hv_timer_in_use
= hv_timer_in_use
;
1553 TP_printk("vcpu_id %x hv_timer %x",
1555 __entry
->hv_timer_in_use
)
1559 * Tracepoint for kvm_hv_flush_tlb.
1561 TRACE_EVENT(kvm_hv_flush_tlb
,
1562 TP_PROTO(u64 processor_mask
, u64 address_space
, u64 flags
, bool guest_mode
),
1563 TP_ARGS(processor_mask
, address_space
, flags
, guest_mode
),
1566 __field(u64
, processor_mask
)
1567 __field(u64
, address_space
)
1569 __field(bool, guest_mode
)
1573 __entry
->processor_mask
= processor_mask
;
1574 __entry
->address_space
= address_space
;
1575 __entry
->flags
= flags
;
1576 __entry
->guest_mode
= guest_mode
;
1579 TP_printk("processor_mask 0x%llx address_space 0x%llx flags 0x%llx %s",
1580 __entry
->processor_mask
, __entry
->address_space
,
1581 __entry
->flags
, __entry
->guest_mode
? "(L2)" : "")
1585 * Tracepoint for kvm_hv_flush_tlb_ex.
1587 TRACE_EVENT(kvm_hv_flush_tlb_ex
,
1588 TP_PROTO(u64 valid_bank_mask
, u64 format
, u64 address_space
, u64 flags
, bool guest_mode
),
1589 TP_ARGS(valid_bank_mask
, format
, address_space
, flags
, guest_mode
),
1592 __field(u64
, valid_bank_mask
)
1593 __field(u64
, format
)
1594 __field(u64
, address_space
)
1596 __field(bool, guest_mode
)
1600 __entry
->valid_bank_mask
= valid_bank_mask
;
1601 __entry
->format
= format
;
1602 __entry
->address_space
= address_space
;
1603 __entry
->flags
= flags
;
1604 __entry
->guest_mode
= guest_mode
;
1607 TP_printk("valid_bank_mask 0x%llx format 0x%llx "
1608 "address_space 0x%llx flags 0x%llx %s",
1609 __entry
->valid_bank_mask
, __entry
->format
,
1610 __entry
->address_space
, __entry
->flags
,
1611 __entry
->guest_mode
? "(L2)" : "")
1615 * Tracepoints for kvm_hv_send_ipi.
1617 TRACE_EVENT(kvm_hv_send_ipi
,
1618 TP_PROTO(u32 vector
, u64 processor_mask
),
1619 TP_ARGS(vector
, processor_mask
),
1622 __field(u32
, vector
)
1623 __field(u64
, processor_mask
)
1627 __entry
->vector
= vector
;
1628 __entry
->processor_mask
= processor_mask
;
1631 TP_printk("vector %x processor_mask 0x%llx",
1632 __entry
->vector
, __entry
->processor_mask
)
1635 TRACE_EVENT(kvm_hv_send_ipi_ex
,
1636 TP_PROTO(u32 vector
, u64 format
, u64 valid_bank_mask
),
1637 TP_ARGS(vector
, format
, valid_bank_mask
),
1640 __field(u32
, vector
)
1641 __field(u64
, format
)
1642 __field(u64
, valid_bank_mask
)
1646 __entry
->vector
= vector
;
1647 __entry
->format
= format
;
1648 __entry
->valid_bank_mask
= valid_bank_mask
;
1651 TP_printk("vector %x format %llx valid_bank_mask 0x%llx",
1652 __entry
->vector
, __entry
->format
,
1653 __entry
->valid_bank_mask
)
1656 TRACE_EVENT(kvm_pv_tlb_flush
,
1657 TP_PROTO(unsigned int vcpu_id
, bool need_flush_tlb
),
1658 TP_ARGS(vcpu_id
, need_flush_tlb
),
1661 __field( unsigned int, vcpu_id
)
1662 __field( bool, need_flush_tlb
)
1666 __entry
->vcpu_id
= vcpu_id
;
1667 __entry
->need_flush_tlb
= need_flush_tlb
;
1670 TP_printk("vcpu %u need_flush_tlb %s", __entry
->vcpu_id
,
1671 __entry
->need_flush_tlb
? "true" : "false")
1675 * Tracepoint for failed nested VMX VM-Enter.
1677 TRACE_EVENT(kvm_nested_vmenter_failed
,
1678 TP_PROTO(const char *msg
, u32 err
),
1691 TP_printk("%s%s", __get_str(msg
), !__entry
->err
? "" :
1692 __print_symbolic(__entry
->err
, VMX_VMENTER_INSTRUCTION_ERRORS
))
1696 * Tracepoint for syndbg_set_msr.
1698 TRACE_EVENT(kvm_hv_syndbg_set_msr
,
1699 TP_PROTO(int vcpu_id
, u32 vp_index
, u32 msr
, u64 data
),
1700 TP_ARGS(vcpu_id
, vp_index
, msr
, data
),
1703 __field(int, vcpu_id
)
1704 __field(u32
, vp_index
)
1710 __entry
->vcpu_id
= vcpu_id
;
1711 __entry
->vp_index
= vp_index
;
1713 __entry
->data
= data
;
1716 TP_printk("vcpu_id %d vp_index %u msr 0x%x data 0x%llx",
1717 __entry
->vcpu_id
, __entry
->vp_index
, __entry
->msr
,
1722 * Tracepoint for syndbg_get_msr.
1724 TRACE_EVENT(kvm_hv_syndbg_get_msr
,
1725 TP_PROTO(int vcpu_id
, u32 vp_index
, u32 msr
, u64 data
),
1726 TP_ARGS(vcpu_id
, vp_index
, msr
, data
),
1729 __field(int, vcpu_id
)
1730 __field(u32
, vp_index
)
1736 __entry
->vcpu_id
= vcpu_id
;
1737 __entry
->vp_index
= vp_index
;
1739 __entry
->data
= data
;
1742 TP_printk("vcpu_id %d vp_index %u msr 0x%x data 0x%llx",
1743 __entry
->vcpu_id
, __entry
->vp_index
, __entry
->msr
,
1748 * Tracepoint for the start of VMGEXIT processing
1750 TRACE_EVENT(kvm_vmgexit_enter
,
1751 TP_PROTO(unsigned int vcpu_id
, struct ghcb
*ghcb
),
1752 TP_ARGS(vcpu_id
, ghcb
),
1755 __field(unsigned int, vcpu_id
)
1756 __field(u64
, exit_reason
)
1762 __entry
->vcpu_id
= vcpu_id
;
1763 __entry
->exit_reason
= ghcb
->save
.sw_exit_code
;
1764 __entry
->info1
= ghcb
->save
.sw_exit_info_1
;
1765 __entry
->info2
= ghcb
->save
.sw_exit_info_2
;
1768 TP_printk("vcpu %u, exit_reason %llx, exit_info1 %llx, exit_info2 %llx",
1769 __entry
->vcpu_id
, __entry
->exit_reason
,
1770 __entry
->info1
, __entry
->info2
)
1774 * Tracepoint for the end of VMGEXIT processing
1776 TRACE_EVENT(kvm_vmgexit_exit
,
1777 TP_PROTO(unsigned int vcpu_id
, struct ghcb
*ghcb
),
1778 TP_ARGS(vcpu_id
, ghcb
),
1781 __field(unsigned int, vcpu_id
)
1782 __field(u64
, exit_reason
)
1788 __entry
->vcpu_id
= vcpu_id
;
1789 __entry
->exit_reason
= ghcb
->save
.sw_exit_code
;
1790 __entry
->info1
= ghcb
->save
.sw_exit_info_1
;
1791 __entry
->info2
= ghcb
->save
.sw_exit_info_2
;
1794 TP_printk("vcpu %u, exit_reason %llx, exit_info1 %llx, exit_info2 %llx",
1795 __entry
->vcpu_id
, __entry
->exit_reason
,
1796 __entry
->info1
, __entry
->info2
)
1800 * Tracepoint for the start of VMGEXIT MSR procotol processing
1802 TRACE_EVENT(kvm_vmgexit_msr_protocol_enter
,
1803 TP_PROTO(unsigned int vcpu_id
, u64 ghcb_gpa
),
1804 TP_ARGS(vcpu_id
, ghcb_gpa
),
1807 __field(unsigned int, vcpu_id
)
1808 __field(u64
, ghcb_gpa
)
1812 __entry
->vcpu_id
= vcpu_id
;
1813 __entry
->ghcb_gpa
= ghcb_gpa
;
1816 TP_printk("vcpu %u, ghcb_gpa %016llx",
1817 __entry
->vcpu_id
, __entry
->ghcb_gpa
)
1821 * Tracepoint for the end of VMGEXIT MSR procotol processing
1823 TRACE_EVENT(kvm_vmgexit_msr_protocol_exit
,
1824 TP_PROTO(unsigned int vcpu_id
, u64 ghcb_gpa
, int result
),
1825 TP_ARGS(vcpu_id
, ghcb_gpa
, result
),
1828 __field(unsigned int, vcpu_id
)
1829 __field(u64
, ghcb_gpa
)
1830 __field(int, result
)
1834 __entry
->vcpu_id
= vcpu_id
;
1835 __entry
->ghcb_gpa
= ghcb_gpa
;
1836 __entry
->result
= result
;
1839 TP_printk("vcpu %u, ghcb_gpa %016llx, result %d",
1840 __entry
->vcpu_id
, __entry
->ghcb_gpa
, __entry
->result
)
1844 * Tracepoint for #NPFs due to RMP faults.
1846 TRACE_EVENT(kvm_rmp_fault
,
1847 TP_PROTO(struct kvm_vcpu
*vcpu
, u64 gpa
, u64 pfn
, u64 error_code
,
1848 int rmp_level
, int psmash_ret
),
1849 TP_ARGS(vcpu
, gpa
, pfn
, error_code
, rmp_level
, psmash_ret
),
1852 __field(unsigned int, vcpu_id
)
1855 __field(u64
, error_code
)
1856 __field(int, rmp_level
)
1857 __field(int, psmash_ret
)
1861 __entry
->vcpu_id
= vcpu
->vcpu_id
;
1864 __entry
->error_code
= error_code
;
1865 __entry
->rmp_level
= rmp_level
;
1866 __entry
->psmash_ret
= psmash_ret
;
1869 TP_printk("vcpu %u gpa %016llx pfn 0x%llx error_code 0x%llx rmp_level %d psmash_ret %d",
1870 __entry
->vcpu_id
, __entry
->gpa
, __entry
->pfn
,
1871 __entry
->error_code
, __entry
->rmp_level
, __entry
->psmash_ret
)
1874 #endif /* _TRACE_KVM_H */
1876 #undef TRACE_INCLUDE_PATH
1877 #define TRACE_INCLUDE_PATH ../../arch/x86/kvm
1878 #undef TRACE_INCLUDE_FILE
1879 #define TRACE_INCLUDE_FILE trace
1881 /* This part must be outside protection */
1882 #include <trace/define_trace.h>