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)
18 TRACE_EVENT(kvm_userspace_exit
,
19 TP_PROTO(__u32 reason
, int errno
),
20 TP_ARGS(reason
, errno
),
23 __field( __u32
, reason
)
28 __entry
->reason
= reason
;
29 __entry
->errno
= errno
;
32 TP_printk("reason %s (%d)",
34 (__entry
->errno
== -EINTR
? "restart" : "error") :
35 __print_symbolic(__entry
->reason
, kvm_trace_exit_reason
),
36 __entry
->errno
< 0 ? -__entry
->errno
: __entry
->reason
)
39 #if defined(__KVM_HAVE_IOAPIC)
40 TRACE_EVENT(kvm_set_irq
,
41 TP_PROTO(unsigned int gsi
, int level
, int irq_source_id
),
42 TP_ARGS(gsi
, level
, irq_source_id
),
45 __field( unsigned int, gsi
)
47 __field( int, irq_source_id
)
52 __entry
->level
= level
;
53 __entry
->irq_source_id
= irq_source_id
;
56 TP_printk("gsi %u level %d source %d",
57 __entry
->gsi
, __entry
->level
, __entry
->irq_source_id
)
60 #define kvm_deliver_mode \
70 TRACE_EVENT(kvm_ioapic_set_irq
,
71 TP_PROTO(__u64 e
, int pin
, bool coalesced
),
72 TP_ARGS(e
, pin
, coalesced
),
77 __field( bool, coalesced
)
83 __entry
->coalesced
= coalesced
;
86 TP_printk("pin %u dst %x vec=%u (%s|%s|%s%s)%s",
87 __entry
->pin
, (u8
)(__entry
->e
>> 56), (u8
)__entry
->e
,
88 __print_symbolic((__entry
->e
>> 8 & 0x7), kvm_deliver_mode
),
89 (__entry
->e
& (1<<11)) ? "logical" : "physical",
90 (__entry
->e
& (1<<15)) ? "level" : "edge",
91 (__entry
->e
& (1<<16)) ? "|masked" : "",
92 __entry
->coalesced
? " (coalesced)" : "")
95 TRACE_EVENT(kvm_msi_set_irq
,
96 TP_PROTO(__u64 address
, __u64 data
),
97 TP_ARGS(address
, data
),
100 __field( __u64
, address
)
101 __field( __u64
, data
)
105 __entry
->address
= address
;
106 __entry
->data
= data
;
109 TP_printk("dst %u vec %x (%s|%s|%s%s)",
110 (u8
)(__entry
->address
>> 12), (u8
)__entry
->data
,
111 __print_symbolic((__entry
->data
>> 8 & 0x7), kvm_deliver_mode
),
112 (__entry
->address
& (1<<2)) ? "logical" : "physical",
113 (__entry
->data
& (1<<15)) ? "level" : "edge",
114 (__entry
->address
& (1<<3)) ? "|rh" : "")
117 #define kvm_irqchips \
118 {KVM_IRQCHIP_PIC_MASTER, "PIC master"}, \
119 {KVM_IRQCHIP_PIC_SLAVE, "PIC slave"}, \
120 {KVM_IRQCHIP_IOAPIC, "IOAPIC"}
122 TRACE_EVENT(kvm_ack_irq
,
123 TP_PROTO(unsigned int irqchip
, unsigned int pin
),
124 TP_ARGS(irqchip
, pin
),
127 __field( unsigned int, irqchip
)
128 __field( unsigned int, pin
)
132 __entry
->irqchip
= irqchip
;
136 TP_printk("irqchip %s pin %u",
137 __print_symbolic(__entry
->irqchip
, kvm_irqchips
),
143 #endif /* defined(__KVM_HAVE_IOAPIC) */
145 #define KVM_TRACE_MMIO_READ_UNSATISFIED 0
146 #define KVM_TRACE_MMIO_READ 1
147 #define KVM_TRACE_MMIO_WRITE 2
149 #define kvm_trace_symbol_mmio \
150 { KVM_TRACE_MMIO_READ_UNSATISFIED, "unsatisfied-read" }, \
151 { KVM_TRACE_MMIO_READ, "read" }, \
152 { KVM_TRACE_MMIO_WRITE, "write" }
154 TRACE_EVENT(kvm_mmio
,
155 TP_PROTO(int type
, int len
, u64 gpa
, u64 val
),
156 TP_ARGS(type
, len
, gpa
, val
),
166 __entry
->type
= type
;
172 TP_printk("mmio %s len %u gpa 0x%llx val 0x%llx",
173 __print_symbolic(__entry
->type
, kvm_trace_symbol_mmio
),
174 __entry
->len
, __entry
->gpa
, __entry
->val
)
177 #define kvm_fpu_load_symbol \
190 __entry
->load
= load
;
193 TP_printk("%s", __print_symbolic(__entry
->load
, kvm_fpu_load_symbol
))
196 TRACE_EVENT(kvm_age_page
,
197 TP_PROTO(ulong hva
, struct kvm_memory_slot
*slot
, int ref
),
198 TP_ARGS(hva
, slot
, ref
),
203 __field( u8
, referenced
)
209 slot
->base_gfn
+ ((hva
- slot
->userspace_addr
) >> PAGE_SHIFT
);
210 __entry
->referenced
= ref
;
213 TP_printk("hva %llx gfn %llx %s",
214 __entry
->hva
, __entry
->gfn
,
215 __entry
->referenced
? "YOUNG" : "OLD")
218 #ifdef CONFIG_KVM_ASYNC_PF
219 DECLARE_EVENT_CLASS(kvm_async_get_page_class
,
221 TP_PROTO(u64 gva
, u64 gfn
),
235 TP_printk("gva = %#llx, gfn = %#llx", __entry
->gva
, __entry
->gfn
)
238 DEFINE_EVENT(kvm_async_get_page_class
, kvm_try_async_get_page
,
240 TP_PROTO(u64 gva
, u64 gfn
),
245 DEFINE_EVENT(kvm_async_get_page_class
, kvm_async_pf_doublefault
,
247 TP_PROTO(u64 gva
, u64 gfn
),
252 DECLARE_EVENT_CLASS(kvm_async_pf_nopresent_ready
,
254 TP_PROTO(u64 token
, u64 gva
),
259 __field(__u64
, token
)
264 __entry
->token
= token
;
268 TP_printk("token %#llx gva %#llx", __entry
->token
, __entry
->gva
)
272 DEFINE_EVENT(kvm_async_pf_nopresent_ready
, kvm_async_pf_not_present
,
274 TP_PROTO(u64 token
, u64 gva
),
279 DEFINE_EVENT(kvm_async_pf_nopresent_ready
, kvm_async_pf_ready
,
281 TP_PROTO(u64 token
, u64 gva
),
287 kvm_async_pf_completed
,
288 TP_PROTO(unsigned long address
, struct page
*page
, u64 gva
),
289 TP_ARGS(address
, page
, gva
),
292 __field(unsigned long, address
)
298 __entry
->address
= address
;
299 __entry
->pfn
= page
? page_to_pfn(page
) : 0;
303 TP_printk("gva %#llx address %#lx pfn %#llx", __entry
->gva
,
304 __entry
->address
, __entry
->pfn
)
309 #endif /* _TRACE_KVM_MAIN_H */
311 /* This part must be outside protection */
312 #include <trace/define_trace.h>