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
),
46 __field( bool, waited
)
51 __entry
->waited
= waited
;
54 TP_printk("%s time %lld ns",
55 __entry
->waited
? "wait" : "poll",
59 #if defined(CONFIG_HAVE_KVM_IRQFD)
60 TRACE_EVENT(kvm_set_irq
,
61 TP_PROTO(unsigned int gsi
, int level
, int irq_source_id
),
62 TP_ARGS(gsi
, level
, irq_source_id
),
65 __field( unsigned int, gsi
)
67 __field( int, irq_source_id
)
72 __entry
->level
= level
;
73 __entry
->irq_source_id
= irq_source_id
;
76 TP_printk("gsi %u level %d source %d",
77 __entry
->gsi
, __entry
->level
, __entry
->irq_source_id
)
79 #endif /* defined(CONFIG_HAVE_KVM_IRQFD) */
81 #if defined(__KVM_HAVE_IOAPIC)
82 #define kvm_deliver_mode \
92 TRACE_EVENT(kvm_ioapic_set_irq
,
93 TP_PROTO(__u64 e
, int pin
, bool coalesced
),
94 TP_ARGS(e
, pin
, coalesced
),
99 __field( bool, coalesced
)
105 __entry
->coalesced
= coalesced
;
108 TP_printk("pin %u dst %x vec=%u (%s|%s|%s%s)%s",
109 __entry
->pin
, (u8
)(__entry
->e
>> 56), (u8
)__entry
->e
,
110 __print_symbolic((__entry
->e
>> 8 & 0x7), kvm_deliver_mode
),
111 (__entry
->e
& (1<<11)) ? "logical" : "physical",
112 (__entry
->e
& (1<<15)) ? "level" : "edge",
113 (__entry
->e
& (1<<16)) ? "|masked" : "",
114 __entry
->coalesced
? " (coalesced)" : "")
117 TRACE_EVENT(kvm_ioapic_delayed_eoi_inj
,
129 TP_printk("dst %x vec=%u (%s|%s|%s%s)",
130 (u8
)(__entry
->e
>> 56), (u8
)__entry
->e
,
131 __print_symbolic((__entry
->e
>> 8 & 0x7), kvm_deliver_mode
),
132 (__entry
->e
& (1<<11)) ? "logical" : "physical",
133 (__entry
->e
& (1<<15)) ? "level" : "edge",
134 (__entry
->e
& (1<<16)) ? "|masked" : "")
137 TRACE_EVENT(kvm_msi_set_irq
,
138 TP_PROTO(__u64 address
, __u64 data
),
139 TP_ARGS(address
, data
),
142 __field( __u64
, address
)
143 __field( __u64
, data
)
147 __entry
->address
= address
;
148 __entry
->data
= data
;
151 TP_printk("dst %u vec %x (%s|%s|%s%s)",
152 (u8
)(__entry
->address
>> 12), (u8
)__entry
->data
,
153 __print_symbolic((__entry
->data
>> 8 & 0x7), kvm_deliver_mode
),
154 (__entry
->address
& (1<<2)) ? "logical" : "physical",
155 (__entry
->data
& (1<<15)) ? "level" : "edge",
156 (__entry
->address
& (1<<3)) ? "|rh" : "")
159 #define kvm_irqchips \
160 {KVM_IRQCHIP_PIC_MASTER, "PIC master"}, \
161 {KVM_IRQCHIP_PIC_SLAVE, "PIC slave"}, \
162 {KVM_IRQCHIP_IOAPIC, "IOAPIC"}
164 #endif /* defined(__KVM_HAVE_IOAPIC) */
166 #if defined(CONFIG_HAVE_KVM_IRQFD)
169 #define kvm_ack_irq_string "irqchip %s pin %u"
170 #define kvm_ack_irq_parm __print_symbolic(__entry->irqchip, kvm_irqchips), __entry->pin
172 #define kvm_ack_irq_string "irqchip %d pin %u"
173 #define kvm_ack_irq_parm __entry->irqchip, __entry->pin
176 TRACE_EVENT(kvm_ack_irq
,
177 TP_PROTO(unsigned int irqchip
, unsigned int pin
),
178 TP_ARGS(irqchip
, pin
),
181 __field( unsigned int, irqchip
)
182 __field( unsigned int, pin
)
186 __entry
->irqchip
= irqchip
;
190 TP_printk(kvm_ack_irq_string
, kvm_ack_irq_parm
)
193 #endif /* defined(CONFIG_HAVE_KVM_IRQFD) */
197 #define KVM_TRACE_MMIO_READ_UNSATISFIED 0
198 #define KVM_TRACE_MMIO_READ 1
199 #define KVM_TRACE_MMIO_WRITE 2
201 #define kvm_trace_symbol_mmio \
202 { KVM_TRACE_MMIO_READ_UNSATISFIED, "unsatisfied-read" }, \
203 { KVM_TRACE_MMIO_READ, "read" }, \
204 { KVM_TRACE_MMIO_WRITE, "write" }
206 TRACE_EVENT(kvm_mmio
,
207 TP_PROTO(int type
, int len
, u64 gpa
, u64 val
),
208 TP_ARGS(type
, len
, gpa
, val
),
218 __entry
->type
= type
;
224 TP_printk("mmio %s len %u gpa 0x%llx val 0x%llx",
225 __print_symbolic(__entry
->type
, kvm_trace_symbol_mmio
),
226 __entry
->len
, __entry
->gpa
, __entry
->val
)
229 #define kvm_fpu_load_symbol \
242 __entry
->load
= load
;
245 TP_printk("%s", __print_symbolic(__entry
->load
, kvm_fpu_load_symbol
))
248 TRACE_EVENT(kvm_age_page
,
249 TP_PROTO(ulong gfn
, int level
, struct kvm_memory_slot
*slot
, int ref
),
250 TP_ARGS(gfn
, level
, slot
, ref
),
256 __field( u8
, referenced
)
261 __entry
->level
= level
;
262 __entry
->hva
= ((gfn
- slot
->base_gfn
) <<
263 PAGE_SHIFT
) + slot
->userspace_addr
;
264 __entry
->referenced
= ref
;
267 TP_printk("hva %llx gfn %llx level %u %s",
268 __entry
->hva
, __entry
->gfn
, __entry
->level
,
269 __entry
->referenced
? "YOUNG" : "OLD")
272 #ifdef CONFIG_KVM_ASYNC_PF
273 DECLARE_EVENT_CLASS(kvm_async_get_page_class
,
275 TP_PROTO(u64 gva
, u64 gfn
),
289 TP_printk("gva = %#llx, gfn = %#llx", __entry
->gva
, __entry
->gfn
)
292 DEFINE_EVENT(kvm_async_get_page_class
, kvm_try_async_get_page
,
294 TP_PROTO(u64 gva
, u64 gfn
),
299 DEFINE_EVENT(kvm_async_get_page_class
, kvm_async_pf_doublefault
,
301 TP_PROTO(u64 gva
, u64 gfn
),
306 DECLARE_EVENT_CLASS(kvm_async_pf_nopresent_ready
,
308 TP_PROTO(u64 token
, u64 gva
),
313 __field(__u64
, token
)
318 __entry
->token
= token
;
322 TP_printk("token %#llx gva %#llx", __entry
->token
, __entry
->gva
)
326 DEFINE_EVENT(kvm_async_pf_nopresent_ready
, kvm_async_pf_not_present
,
328 TP_PROTO(u64 token
, u64 gva
),
333 DEFINE_EVENT(kvm_async_pf_nopresent_ready
, kvm_async_pf_ready
,
335 TP_PROTO(u64 token
, u64 gva
),
341 kvm_async_pf_completed
,
342 TP_PROTO(unsigned long address
, u64 gva
),
343 TP_ARGS(address
, gva
),
346 __field(unsigned long, address
)
351 __entry
->address
= address
;
355 TP_printk("gva %#llx address %#lx", __entry
->gva
,
361 TRACE_EVENT(kvm_halt_poll_ns
,
362 TP_PROTO(bool grow
, unsigned int vcpu_id
, int new, int old
),
363 TP_ARGS(grow
, vcpu_id
, new, old
),
367 __field(unsigned int, vcpu_id
)
373 __entry
->grow
= grow
;
374 __entry
->vcpu_id
= vcpu_id
;
379 TP_printk("vcpu %u: halt_poll_ns %d (%s %d)",
382 __entry
->grow
? "grow" : "shrink",
386 #define trace_kvm_halt_poll_ns_grow(vcpu_id, new, old) \
387 trace_kvm_halt_poll_ns(true, vcpu_id, new, old)
388 #define trace_kvm_halt_poll_ns_shrink(vcpu_id, new, old) \
389 trace_kvm_halt_poll_ns(false, vcpu_id, new, old)
391 #endif /* _TRACE_KVM_MAIN_H */
393 /* This part must be outside protection */
394 #include <trace/define_trace.h>