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 #if defined(CONFIG_HAVE_KVM_IRQCHIP)
41 TRACE_EVENT(kvm_set_irq
,
42 TP_PROTO(unsigned int gsi
, int level
, int irq_source_id
),
43 TP_ARGS(gsi
, level
, irq_source_id
),
46 __field( unsigned int, gsi
)
48 __field( int, irq_source_id
)
53 __entry
->level
= level
;
54 __entry
->irq_source_id
= irq_source_id
;
57 TP_printk("gsi %u level %d source %d",
58 __entry
->gsi
, __entry
->level
, __entry
->irq_source_id
)
62 #if defined(__KVM_HAVE_IOAPIC)
63 #define kvm_deliver_mode \
73 TRACE_EVENT(kvm_ioapic_set_irq
,
74 TP_PROTO(__u64 e
, int pin
, bool coalesced
),
75 TP_ARGS(e
, pin
, coalesced
),
80 __field( bool, coalesced
)
86 __entry
->coalesced
= coalesced
;
89 TP_printk("pin %u dst %x vec=%u (%s|%s|%s%s)%s",
90 __entry
->pin
, (u8
)(__entry
->e
>> 56), (u8
)__entry
->e
,
91 __print_symbolic((__entry
->e
>> 8 & 0x7), kvm_deliver_mode
),
92 (__entry
->e
& (1<<11)) ? "logical" : "physical",
93 (__entry
->e
& (1<<15)) ? "level" : "edge",
94 (__entry
->e
& (1<<16)) ? "|masked" : "",
95 __entry
->coalesced
? " (coalesced)" : "")
98 TRACE_EVENT(kvm_msi_set_irq
,
99 TP_PROTO(__u64 address
, __u64 data
),
100 TP_ARGS(address
, data
),
103 __field( __u64
, address
)
104 __field( __u64
, data
)
108 __entry
->address
= address
;
109 __entry
->data
= data
;
112 TP_printk("dst %u vec %x (%s|%s|%s%s)",
113 (u8
)(__entry
->address
>> 12), (u8
)__entry
->data
,
114 __print_symbolic((__entry
->data
>> 8 & 0x7), kvm_deliver_mode
),
115 (__entry
->address
& (1<<2)) ? "logical" : "physical",
116 (__entry
->data
& (1<<15)) ? "level" : "edge",
117 (__entry
->address
& (1<<3)) ? "|rh" : "")
120 #define kvm_irqchips \
121 {KVM_IRQCHIP_PIC_MASTER, "PIC master"}, \
122 {KVM_IRQCHIP_PIC_SLAVE, "PIC slave"}, \
123 {KVM_IRQCHIP_IOAPIC, "IOAPIC"}
125 #endif /* defined(__KVM_HAVE_IOAPIC) */
127 #if defined(CONFIG_HAVE_KVM_IRQCHIP)
129 TRACE_EVENT(kvm_ack_irq
,
130 TP_PROTO(unsigned int irqchip
, unsigned int pin
),
131 TP_ARGS(irqchip
, pin
),
134 __field( unsigned int, irqchip
)
135 __field( unsigned int, pin
)
139 __entry
->irqchip
= irqchip
;
144 TP_printk("irqchip %s pin %u",
145 __print_symbolic(__entry
->irqchip
, kvm_irqchips
),
148 TP_printk("irqchip %d pin %u", __entry
->irqchip
, __entry
->pin
)
152 #endif /* defined(CONFIG_HAVE_KVM_IRQCHIP) */
156 #define KVM_TRACE_MMIO_READ_UNSATISFIED 0
157 #define KVM_TRACE_MMIO_READ 1
158 #define KVM_TRACE_MMIO_WRITE 2
160 #define kvm_trace_symbol_mmio \
161 { KVM_TRACE_MMIO_READ_UNSATISFIED, "unsatisfied-read" }, \
162 { KVM_TRACE_MMIO_READ, "read" }, \
163 { KVM_TRACE_MMIO_WRITE, "write" }
165 TRACE_EVENT(kvm_mmio
,
166 TP_PROTO(int type
, int len
, u64 gpa
, u64 val
),
167 TP_ARGS(type
, len
, gpa
, val
),
177 __entry
->type
= type
;
183 TP_printk("mmio %s len %u gpa 0x%llx val 0x%llx",
184 __print_symbolic(__entry
->type
, kvm_trace_symbol_mmio
),
185 __entry
->len
, __entry
->gpa
, __entry
->val
)
188 #define kvm_fpu_load_symbol \
201 __entry
->load
= load
;
204 TP_printk("%s", __print_symbolic(__entry
->load
, kvm_fpu_load_symbol
))
207 TRACE_EVENT(kvm_age_page
,
208 TP_PROTO(ulong hva
, struct kvm_memory_slot
*slot
, int ref
),
209 TP_ARGS(hva
, slot
, ref
),
214 __field( u8
, referenced
)
220 slot
->base_gfn
+ ((hva
- slot
->userspace_addr
) >> PAGE_SHIFT
);
221 __entry
->referenced
= ref
;
224 TP_printk("hva %llx gfn %llx %s",
225 __entry
->hva
, __entry
->gfn
,
226 __entry
->referenced
? "YOUNG" : "OLD")
229 #ifdef CONFIG_KVM_ASYNC_PF
230 DECLARE_EVENT_CLASS(kvm_async_get_page_class
,
232 TP_PROTO(u64 gva
, u64 gfn
),
246 TP_printk("gva = %#llx, gfn = %#llx", __entry
->gva
, __entry
->gfn
)
249 DEFINE_EVENT(kvm_async_get_page_class
, kvm_try_async_get_page
,
251 TP_PROTO(u64 gva
, u64 gfn
),
256 DEFINE_EVENT(kvm_async_get_page_class
, kvm_async_pf_doublefault
,
258 TP_PROTO(u64 gva
, u64 gfn
),
263 DECLARE_EVENT_CLASS(kvm_async_pf_nopresent_ready
,
265 TP_PROTO(u64 token
, u64 gva
),
270 __field(__u64
, token
)
275 __entry
->token
= token
;
279 TP_printk("token %#llx gva %#llx", __entry
->token
, __entry
->gva
)
283 DEFINE_EVENT(kvm_async_pf_nopresent_ready
, kvm_async_pf_not_present
,
285 TP_PROTO(u64 token
, u64 gva
),
290 DEFINE_EVENT(kvm_async_pf_nopresent_ready
, kvm_async_pf_ready
,
292 TP_PROTO(u64 token
, u64 gva
),
298 kvm_async_pf_completed
,
299 TP_PROTO(unsigned long address
, u64 gva
),
300 TP_ARGS(address
, gva
),
303 __field(unsigned long, address
)
308 __entry
->address
= address
;
312 TP_printk("gva %#llx address %#lx", __entry
->gva
,
318 #endif /* _TRACE_KVM_MAIN_H */
320 /* This part must be outside protection */
321 #include <trace/define_trace.h>