1 #if !defined(_TRACE_KVM_MAIN_H) || defined(TRACE_HEADER_MULTI_READ)
2 #define _TRACE_KVM_MAIN_H
4 #include <linux/tracepoint.h>
7 #define TRACE_SYSTEM kvm
9 #define ERSN(x) { KVM_EXIT_##x, "KVM_EXIT_" #x }
11 #define kvm_trace_exit_reason \
12 ERSN(UNKNOWN), ERSN(EXCEPTION), ERSN(IO), ERSN(HYPERCALL), \
13 ERSN(DEBUG), ERSN(HLT), ERSN(MMIO), ERSN(IRQ_WINDOW_OPEN), \
14 ERSN(SHUTDOWN), ERSN(FAIL_ENTRY), ERSN(INTR), ERSN(SET_TPR), \
15 ERSN(TPR_ACCESS), ERSN(S390_SIEIC), ERSN(S390_RESET), ERSN(DCR),\
16 ERSN(NMI), ERSN(INTERNAL_ERROR), ERSN(OSI), ERSN(PAPR_HCALL), \
17 ERSN(S390_UCONTROL), ERSN(WATCHDOG), ERSN(S390_TSCH)
19 TRACE_EVENT(kvm_userspace_exit
,
20 TP_PROTO(__u32 reason
, int errno
),
21 TP_ARGS(reason
, errno
),
24 __field( __u32
, reason
)
29 __entry
->reason
= reason
;
30 __entry
->errno
= errno
;
33 TP_printk("reason %s (%d)",
35 (__entry
->errno
== -EINTR
? "restart" : "error") :
36 __print_symbolic(__entry
->reason
, kvm_trace_exit_reason
),
37 __entry
->errno
< 0 ? -__entry
->errno
: __entry
->reason
)
40 TRACE_EVENT(kvm_vcpu_wakeup
,
41 TP_PROTO(__u64 ns
, bool waited
, bool valid
),
42 TP_ARGS(ns
, waited
, valid
),
46 __field( bool, waited
)
47 __field( bool, valid
)
52 __entry
->waited
= waited
;
53 __entry
->valid
= valid
;
56 TP_printk("%s time %lld ns, polling %s",
57 __entry
->waited
? "wait" : "poll",
59 __entry
->valid
? "valid" : "invalid")
62 #if defined(CONFIG_HAVE_KVM_IRQFD)
63 TRACE_EVENT(kvm_set_irq
,
64 TP_PROTO(unsigned int gsi
, int level
, int irq_source_id
),
65 TP_ARGS(gsi
, level
, irq_source_id
),
68 __field( unsigned int, gsi
)
70 __field( int, irq_source_id
)
75 __entry
->level
= level
;
76 __entry
->irq_source_id
= irq_source_id
;
79 TP_printk("gsi %u level %d source %d",
80 __entry
->gsi
, __entry
->level
, __entry
->irq_source_id
)
82 #endif /* defined(CONFIG_HAVE_KVM_IRQFD) */
84 #if defined(__KVM_HAVE_IOAPIC)
85 #define kvm_deliver_mode \
95 TRACE_EVENT(kvm_ioapic_set_irq
,
96 TP_PROTO(__u64 e
, int pin
, bool coalesced
),
97 TP_ARGS(e
, pin
, coalesced
),
102 __field( bool, coalesced
)
108 __entry
->coalesced
= coalesced
;
111 TP_printk("pin %u dst %x vec %u (%s|%s|%s%s)%s",
112 __entry
->pin
, (u8
)(__entry
->e
>> 56), (u8
)__entry
->e
,
113 __print_symbolic((__entry
->e
>> 8 & 0x7), kvm_deliver_mode
),
114 (__entry
->e
& (1<<11)) ? "logical" : "physical",
115 (__entry
->e
& (1<<15)) ? "level" : "edge",
116 (__entry
->e
& (1<<16)) ? "|masked" : "",
117 __entry
->coalesced
? " (coalesced)" : "")
120 TRACE_EVENT(kvm_ioapic_delayed_eoi_inj
,
132 TP_printk("dst %x vec %u (%s|%s|%s%s)",
133 (u8
)(__entry
->e
>> 56), (u8
)__entry
->e
,
134 __print_symbolic((__entry
->e
>> 8 & 0x7), kvm_deliver_mode
),
135 (__entry
->e
& (1<<11)) ? "logical" : "physical",
136 (__entry
->e
& (1<<15)) ? "level" : "edge",
137 (__entry
->e
& (1<<16)) ? "|masked" : "")
140 TRACE_EVENT(kvm_msi_set_irq
,
141 TP_PROTO(__u64 address
, __u64 data
),
142 TP_ARGS(address
, data
),
145 __field( __u64
, address
)
146 __field( __u64
, data
)
150 __entry
->address
= address
;
151 __entry
->data
= data
;
154 TP_printk("dst %llx vec %u (%s|%s|%s%s)",
155 (u8
)(__entry
->address
>> 12) | ((__entry
->address
>> 32) & 0xffffff00),
157 __print_symbolic((__entry
->data
>> 8 & 0x7), kvm_deliver_mode
),
158 (__entry
->address
& (1<<2)) ? "logical" : "physical",
159 (__entry
->data
& (1<<15)) ? "level" : "edge",
160 (__entry
->address
& (1<<3)) ? "|rh" : "")
163 #define kvm_irqchips \
164 {KVM_IRQCHIP_PIC_MASTER, "PIC master"}, \
165 {KVM_IRQCHIP_PIC_SLAVE, "PIC slave"}, \
166 {KVM_IRQCHIP_IOAPIC, "IOAPIC"}
168 #endif /* defined(__KVM_HAVE_IOAPIC) */
170 #if defined(CONFIG_HAVE_KVM_IRQFD)
173 #define kvm_ack_irq_string "irqchip %s pin %u"
174 #define kvm_ack_irq_parm __print_symbolic(__entry->irqchip, kvm_irqchips), __entry->pin
176 #define kvm_ack_irq_string "irqchip %d pin %u"
177 #define kvm_ack_irq_parm __entry->irqchip, __entry->pin
180 TRACE_EVENT(kvm_ack_irq
,
181 TP_PROTO(unsigned int irqchip
, unsigned int pin
),
182 TP_ARGS(irqchip
, pin
),
185 __field( unsigned int, irqchip
)
186 __field( unsigned int, pin
)
190 __entry
->irqchip
= irqchip
;
194 TP_printk(kvm_ack_irq_string
, kvm_ack_irq_parm
)
197 #endif /* defined(CONFIG_HAVE_KVM_IRQFD) */
201 #define KVM_TRACE_MMIO_READ_UNSATISFIED 0
202 #define KVM_TRACE_MMIO_READ 1
203 #define KVM_TRACE_MMIO_WRITE 2
205 #define kvm_trace_symbol_mmio \
206 { KVM_TRACE_MMIO_READ_UNSATISFIED, "unsatisfied-read" }, \
207 { KVM_TRACE_MMIO_READ, "read" }, \
208 { KVM_TRACE_MMIO_WRITE, "write" }
210 TRACE_EVENT(kvm_mmio
,
211 TP_PROTO(int type
, int len
, u64 gpa
, u64 val
),
212 TP_ARGS(type
, len
, gpa
, val
),
222 __entry
->type
= type
;
228 TP_printk("mmio %s len %u gpa 0x%llx val 0x%llx",
229 __print_symbolic(__entry
->type
, kvm_trace_symbol_mmio
),
230 __entry
->len
, __entry
->gpa
, __entry
->val
)
233 #define kvm_fpu_load_symbol \
246 __entry
->load
= load
;
249 TP_printk("%s", __print_symbolic(__entry
->load
, kvm_fpu_load_symbol
))
252 TRACE_EVENT(kvm_age_page
,
253 TP_PROTO(ulong gfn
, int level
, struct kvm_memory_slot
*slot
, int ref
),
254 TP_ARGS(gfn
, level
, slot
, ref
),
260 __field( u8
, referenced
)
265 __entry
->level
= level
;
266 __entry
->hva
= ((gfn
- slot
->base_gfn
) <<
267 PAGE_SHIFT
) + slot
->userspace_addr
;
268 __entry
->referenced
= ref
;
271 TP_printk("hva %llx gfn %llx level %u %s",
272 __entry
->hva
, __entry
->gfn
, __entry
->level
,
273 __entry
->referenced
? "YOUNG" : "OLD")
276 #ifdef CONFIG_KVM_ASYNC_PF
277 DECLARE_EVENT_CLASS(kvm_async_get_page_class
,
279 TP_PROTO(u64 gva
, u64 gfn
),
293 TP_printk("gva = %#llx, gfn = %#llx", __entry
->gva
, __entry
->gfn
)
296 DEFINE_EVENT(kvm_async_get_page_class
, kvm_try_async_get_page
,
298 TP_PROTO(u64 gva
, u64 gfn
),
303 DEFINE_EVENT(kvm_async_get_page_class
, kvm_async_pf_doublefault
,
305 TP_PROTO(u64 gva
, u64 gfn
),
310 DECLARE_EVENT_CLASS(kvm_async_pf_nopresent_ready
,
312 TP_PROTO(u64 token
, u64 gva
),
317 __field(__u64
, token
)
322 __entry
->token
= token
;
326 TP_printk("token %#llx gva %#llx", __entry
->token
, __entry
->gva
)
330 DEFINE_EVENT(kvm_async_pf_nopresent_ready
, kvm_async_pf_not_present
,
332 TP_PROTO(u64 token
, u64 gva
),
337 DEFINE_EVENT(kvm_async_pf_nopresent_ready
, kvm_async_pf_ready
,
339 TP_PROTO(u64 token
, u64 gva
),
345 kvm_async_pf_completed
,
346 TP_PROTO(unsigned long address
, u64 gva
),
347 TP_ARGS(address
, gva
),
350 __field(unsigned long, address
)
355 __entry
->address
= address
;
359 TP_printk("gva %#llx address %#lx", __entry
->gva
,
365 TRACE_EVENT(kvm_halt_poll_ns
,
366 TP_PROTO(bool grow
, unsigned int vcpu_id
, unsigned int new,
368 TP_ARGS(grow
, vcpu_id
, new, old
),
372 __field(unsigned int, vcpu_id
)
373 __field(unsigned int, new)
374 __field(unsigned int, old
)
378 __entry
->grow
= grow
;
379 __entry
->vcpu_id
= vcpu_id
;
384 TP_printk("vcpu %u: halt_poll_ns %u (%s %u)",
387 __entry
->grow
? "grow" : "shrink",
391 #define trace_kvm_halt_poll_ns_grow(vcpu_id, new, old) \
392 trace_kvm_halt_poll_ns(true, vcpu_id, new, old)
393 #define trace_kvm_halt_poll_ns_shrink(vcpu_id, new, old) \
394 trace_kvm_halt_poll_ns(false, vcpu_id, new, old)
396 #endif /* _TRACE_KVM_MAIN_H */
398 /* This part must be outside protection */
399 #include <trace/define_trace.h>