1 #if !defined(_TRACE_KVM_H) || defined(TRACE_HEADER_MULTI_READ)
4 #include <linux/tracepoint.h>
7 #define TRACE_SYSTEM kvm
8 #define TRACE_INCLUDE_PATH arch/x86/kvm
9 #define TRACE_INCLUDE_FILE trace
12 * Tracepoint for guest mode entry.
14 TRACE_EVENT(kvm_entry
,
15 TP_PROTO(unsigned int vcpu_id
),
19 __field( unsigned int, vcpu_id
)
23 __entry
->vcpu_id
= vcpu_id
;
26 TP_printk("vcpu %u", __entry
->vcpu_id
)
30 * Tracepoint for hypercall.
32 TRACE_EVENT(kvm_hypercall
,
33 TP_PROTO(unsigned long nr
, unsigned long a0
, unsigned long a1
,
34 unsigned long a2
, unsigned long a3
),
35 TP_ARGS(nr
, a0
, a1
, a2
, a3
),
38 __field( unsigned long, nr
)
39 __field( unsigned long, a0
)
40 __field( unsigned long, a1
)
41 __field( unsigned long, a2
)
42 __field( unsigned long, a3
)
53 TP_printk("nr 0x%lx a0 0x%lx a1 0x%lx a2 0x%lx a3 0x%lx",
54 __entry
->nr
, __entry
->a0
, __entry
->a1
, __entry
->a2
,
62 TP_PROTO(unsigned int rw
, unsigned int port
, unsigned int size
,
64 TP_ARGS(rw
, port
, size
, count
),
67 __field( unsigned int, rw
)
68 __field( unsigned int, port
)
69 __field( unsigned int, size
)
70 __field( unsigned int, count
)
77 __entry
->count
= count
;
80 TP_printk("pio_%s at 0x%x size %d count %d",
81 __entry
->rw
? "write" : "read",
82 __entry
->port
, __entry
->size
, __entry
->count
)
86 * Tracepoint for cpuid.
88 TRACE_EVENT(kvm_cpuid
,
89 TP_PROTO(unsigned int function
, unsigned long rax
, unsigned long rbx
,
90 unsigned long rcx
, unsigned long rdx
),
91 TP_ARGS(function
, rax
, rbx
, rcx
, rdx
),
94 __field( unsigned int, function
)
95 __field( unsigned long, rax
)
96 __field( unsigned long, rbx
)
97 __field( unsigned long, rcx
)
98 __field( unsigned long, rdx
)
102 __entry
->function
= function
;
109 TP_printk("func %x rax %lx rbx %lx rcx %lx rdx %lx",
110 __entry
->function
, __entry
->rax
,
111 __entry
->rbx
, __entry
->rcx
, __entry
->rdx
)
114 #define AREG(x) { APIC_##x, "APIC_" #x }
116 #define kvm_trace_symbol_apic \
117 AREG(ID), AREG(LVR), AREG(TASKPRI), AREG(ARBPRI), AREG(PROCPRI), \
118 AREG(EOI), AREG(RRR), AREG(LDR), AREG(DFR), AREG(SPIV), AREG(ISR), \
119 AREG(TMR), AREG(IRR), AREG(ESR), AREG(ICR), AREG(ICR2), AREG(LVTT), \
120 AREG(LVTTHMR), AREG(LVTPC), AREG(LVT0), AREG(LVT1), AREG(LVTERR), \
121 AREG(TMICT), AREG(TMCCT), AREG(TDCR), AREG(SELF_IPI), AREG(EFEAT), \
124 * Tracepoint for apic access.
126 TRACE_EVENT(kvm_apic
,
127 TP_PROTO(unsigned int rw
, unsigned int reg
, unsigned int val
),
128 TP_ARGS(rw
, reg
, val
),
131 __field( unsigned int, rw
)
132 __field( unsigned int, reg
)
133 __field( unsigned int, val
)
142 TP_printk("apic_%s %s = 0x%x",
143 __entry
->rw
? "write" : "read",
144 __print_symbolic(__entry
->reg
, kvm_trace_symbol_apic
),
148 #define trace_kvm_apic_read(reg, val) trace_kvm_apic(0, reg, val)
149 #define trace_kvm_apic_write(reg, val) trace_kvm_apic(1, reg, val)
152 * Tracepoint for kvm guest exit:
154 TRACE_EVENT(kvm_exit
,
155 TP_PROTO(unsigned int exit_reason
, unsigned long guest_rip
),
156 TP_ARGS(exit_reason
, guest_rip
),
159 __field( unsigned int, exit_reason
)
160 __field( unsigned long, guest_rip
)
164 __entry
->exit_reason
= exit_reason
;
165 __entry
->guest_rip
= guest_rip
;
168 TP_printk("reason %s rip 0x%lx",
169 ftrace_print_symbols_seq(p
, __entry
->exit_reason
,
170 kvm_x86_ops
->exit_reasons_str
),
175 * Tracepoint for kvm interrupt injection:
177 TRACE_EVENT(kvm_inj_virq
,
178 TP_PROTO(unsigned int irq
),
182 __field( unsigned int, irq
)
189 TP_printk("irq %u", __entry
->irq
)
193 * Tracepoint for page fault.
195 TRACE_EVENT(kvm_page_fault
,
196 TP_PROTO(unsigned long fault_address
, unsigned int error_code
),
197 TP_ARGS(fault_address
, error_code
),
200 __field( unsigned long, fault_address
)
201 __field( unsigned int, error_code
)
205 __entry
->fault_address
= fault_address
;
206 __entry
->error_code
= error_code
;
209 TP_printk("address %lx error_code %x",
210 __entry
->fault_address
, __entry
->error_code
)
214 * Tracepoint for guest MSR access.
217 TP_PROTO(unsigned int rw
, unsigned int ecx
, unsigned long data
),
218 TP_ARGS(rw
, ecx
, data
),
221 __field( unsigned int, rw
)
222 __field( unsigned int, ecx
)
223 __field( unsigned long, data
)
229 __entry
->data
= data
;
232 TP_printk("msr_%s %x = 0x%lx",
233 __entry
->rw
? "write" : "read",
234 __entry
->ecx
, __entry
->data
)
237 #define trace_kvm_msr_read(ecx, data) trace_kvm_msr(0, ecx, data)
238 #define trace_kvm_msr_write(ecx, data) trace_kvm_msr(1, ecx, data)
241 * Tracepoint for guest CR access.
244 TP_PROTO(unsigned int rw
, unsigned int cr
, unsigned long val
),
245 TP_ARGS(rw
, cr
, val
),
248 __field( unsigned int, rw
)
249 __field( unsigned int, cr
)
250 __field( unsigned long, val
)
259 TP_printk("cr_%s %x = 0x%lx",
260 __entry
->rw
? "write" : "read",
261 __entry
->cr
, __entry
->val
)
264 #define trace_kvm_cr_read(cr, val) trace_kvm_cr(0, cr, val)
265 #define trace_kvm_cr_write(cr, val) trace_kvm_cr(1, cr, val)
267 TRACE_EVENT(kvm_pic_set_irq
,
268 TP_PROTO(__u8 chip
, __u8 pin
, __u8 elcr
, __u8 imr
, bool coalesced
),
269 TP_ARGS(chip
, pin
, elcr
, imr
, coalesced
),
272 __field( __u8
, chip
)
274 __field( __u8
, elcr
)
276 __field( bool, coalesced
)
280 __entry
->chip
= chip
;
282 __entry
->elcr
= elcr
;
284 __entry
->coalesced
= coalesced
;
287 TP_printk("chip %u pin %u (%s%s)%s",
288 __entry
->chip
, __entry
->pin
,
289 (__entry
->elcr
& (1 << __entry
->pin
)) ? "level":"edge",
290 (__entry
->imr
& (1 << __entry
->pin
)) ? "|masked":"",
291 __entry
->coalesced
? " (coalesced)" : "")
294 #define kvm_apic_dst_shorthand \
298 {0x3, "all-but-self"}
300 TRACE_EVENT(kvm_apic_ipi
,
301 TP_PROTO(__u32 icr_low
, __u32 dest_id
),
302 TP_ARGS(icr_low
, dest_id
),
305 __field( __u32
, icr_low
)
306 __field( __u32
, dest_id
)
310 __entry
->icr_low
= icr_low
;
311 __entry
->dest_id
= dest_id
;
314 TP_printk("dst %x vec %u (%s|%s|%s|%s|%s)",
315 __entry
->dest_id
, (u8
)__entry
->icr_low
,
316 __print_symbolic((__entry
->icr_low
>> 8 & 0x7),
318 (__entry
->icr_low
& (1<<11)) ? "logical" : "physical",
319 (__entry
->icr_low
& (1<<14)) ? "assert" : "de-assert",
320 (__entry
->icr_low
& (1<<15)) ? "level" : "edge",
321 __print_symbolic((__entry
->icr_low
>> 18 & 0x3),
322 kvm_apic_dst_shorthand
))
325 TRACE_EVENT(kvm_apic_accept_irq
,
326 TP_PROTO(__u32 apicid
, __u16 dm
, __u8 tm
, __u8 vec
, bool coalesced
),
327 TP_ARGS(apicid
, dm
, tm
, vec
, coalesced
),
330 __field( __u32
, apicid
)
334 __field( bool, coalesced
)
338 __entry
->apicid
= apicid
;
342 __entry
->coalesced
= coalesced
;
345 TP_printk("apicid %x vec %u (%s|%s)%s",
346 __entry
->apicid
, __entry
->vec
,
347 __print_symbolic((__entry
->dm
>> 8 & 0x7), kvm_deliver_mode
),
348 __entry
->tm
? "level" : "edge",
349 __entry
->coalesced
? " (coalesced)" : "")
352 #endif /* _TRACE_KVM_H */
354 /* This part must be outside protection */
355 #include <trace/define_trace.h>