1 #if !defined(_TRACE_KVM_H) || defined(TRACE_HEADER_MULTI_READ)
4 #include <linux/tracepoint.h>
9 #define TRACE_SYSTEM kvm
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
,
59 * Tracepoint for hypercall.
61 TRACE_EVENT(kvm_hv_hypercall
,
62 TP_PROTO(__u16 code
, bool fast
, __u16 rep_cnt
, __u16 rep_idx
,
63 __u64 ingpa
, __u64 outgpa
),
64 TP_ARGS(code
, fast
, rep_cnt
, rep_idx
, ingpa
, outgpa
),
67 __field( __u16
, rep_cnt
)
68 __field( __u16
, rep_idx
)
69 __field( __u64
, ingpa
)
70 __field( __u64
, outgpa
)
71 __field( __u16
, code
)
76 __entry
->rep_cnt
= rep_cnt
;
77 __entry
->rep_idx
= rep_idx
;
78 __entry
->ingpa
= ingpa
;
79 __entry
->outgpa
= outgpa
;
84 TP_printk("code 0x%x %s cnt 0x%x idx 0x%x in 0x%llx out 0x%llx",
85 __entry
->code
, __entry
->fast
? "fast" : "slow",
86 __entry
->rep_cnt
, __entry
->rep_idx
, __entry
->ingpa
,
94 TP_PROTO(unsigned int rw
, unsigned int port
, unsigned int size
,
96 TP_ARGS(rw
, port
, size
, count
),
99 __field( unsigned int, rw
)
100 __field( unsigned int, port
)
101 __field( unsigned int, size
)
102 __field( unsigned int, count
)
107 __entry
->port
= port
;
108 __entry
->size
= size
;
109 __entry
->count
= count
;
112 TP_printk("pio_%s at 0x%x size %d count %d",
113 __entry
->rw
? "write" : "read",
114 __entry
->port
, __entry
->size
, __entry
->count
)
118 * Tracepoint for cpuid.
120 TRACE_EVENT(kvm_cpuid
,
121 TP_PROTO(unsigned int function
, unsigned long rax
, unsigned long rbx
,
122 unsigned long rcx
, unsigned long rdx
),
123 TP_ARGS(function
, rax
, rbx
, rcx
, rdx
),
126 __field( unsigned int, function
)
127 __field( unsigned long, rax
)
128 __field( unsigned long, rbx
)
129 __field( unsigned long, rcx
)
130 __field( unsigned long, rdx
)
134 __entry
->function
= function
;
141 TP_printk("func %x rax %lx rbx %lx rcx %lx rdx %lx",
142 __entry
->function
, __entry
->rax
,
143 __entry
->rbx
, __entry
->rcx
, __entry
->rdx
)
146 #define AREG(x) { APIC_##x, "APIC_" #x }
148 #define kvm_trace_symbol_apic \
149 AREG(ID), AREG(LVR), AREG(TASKPRI), AREG(ARBPRI), AREG(PROCPRI), \
150 AREG(EOI), AREG(RRR), AREG(LDR), AREG(DFR), AREG(SPIV), AREG(ISR), \
151 AREG(TMR), AREG(IRR), AREG(ESR), AREG(ICR), AREG(ICR2), AREG(LVTT), \
152 AREG(LVTTHMR), AREG(LVTPC), AREG(LVT0), AREG(LVT1), AREG(LVTERR), \
153 AREG(TMICT), AREG(TMCCT), AREG(TDCR), AREG(SELF_IPI), AREG(EFEAT), \
156 * Tracepoint for apic access.
158 TRACE_EVENT(kvm_apic
,
159 TP_PROTO(unsigned int rw
, unsigned int reg
, unsigned int val
),
160 TP_ARGS(rw
, reg
, val
),
163 __field( unsigned int, rw
)
164 __field( unsigned int, reg
)
165 __field( unsigned int, val
)
174 TP_printk("apic_%s %s = 0x%x",
175 __entry
->rw
? "write" : "read",
176 __print_symbolic(__entry
->reg
, kvm_trace_symbol_apic
),
180 #define trace_kvm_apic_read(reg, val) trace_kvm_apic(0, reg, val)
181 #define trace_kvm_apic_write(reg, val) trace_kvm_apic(1, reg, val)
183 #define KVM_ISA_VMX 1
184 #define KVM_ISA_SVM 2
186 #define VMX_EXIT_REASONS \
187 { EXIT_REASON_EXCEPTION_NMI, "EXCEPTION_NMI" }, \
188 { EXIT_REASON_EXTERNAL_INTERRUPT, "EXTERNAL_INTERRUPT" }, \
189 { EXIT_REASON_TRIPLE_FAULT, "TRIPLE_FAULT" }, \
190 { EXIT_REASON_PENDING_INTERRUPT, "PENDING_INTERRUPT" }, \
191 { EXIT_REASON_NMI_WINDOW, "NMI_WINDOW" }, \
192 { EXIT_REASON_TASK_SWITCH, "TASK_SWITCH" }, \
193 { EXIT_REASON_CPUID, "CPUID" }, \
194 { EXIT_REASON_HLT, "HLT" }, \
195 { EXIT_REASON_INVLPG, "INVLPG" }, \
196 { EXIT_REASON_RDPMC, "RDPMC" }, \
197 { EXIT_REASON_RDTSC, "RDTSC" }, \
198 { EXIT_REASON_VMCALL, "VMCALL" }, \
199 { EXIT_REASON_VMCLEAR, "VMCLEAR" }, \
200 { EXIT_REASON_VMLAUNCH, "VMLAUNCH" }, \
201 { EXIT_REASON_VMPTRLD, "VMPTRLD" }, \
202 { EXIT_REASON_VMPTRST, "VMPTRST" }, \
203 { EXIT_REASON_VMREAD, "VMREAD" }, \
204 { EXIT_REASON_VMRESUME, "VMRESUME" }, \
205 { EXIT_REASON_VMWRITE, "VMWRITE" }, \
206 { EXIT_REASON_VMOFF, "VMOFF" }, \
207 { EXIT_REASON_VMON, "VMON" }, \
208 { EXIT_REASON_CR_ACCESS, "CR_ACCESS" }, \
209 { EXIT_REASON_DR_ACCESS, "DR_ACCESS" }, \
210 { EXIT_REASON_IO_INSTRUCTION, "IO_INSTRUCTION" }, \
211 { EXIT_REASON_MSR_READ, "MSR_READ" }, \
212 { EXIT_REASON_MSR_WRITE, "MSR_WRITE" }, \
213 { EXIT_REASON_MWAIT_INSTRUCTION, "MWAIT_INSTRUCTION" }, \
214 { EXIT_REASON_MONITOR_INSTRUCTION, "MONITOR_INSTRUCTION" }, \
215 { EXIT_REASON_PAUSE_INSTRUCTION, "PAUSE_INSTRUCTION" }, \
216 { EXIT_REASON_MCE_DURING_VMENTRY, "MCE_DURING_VMENTRY" }, \
217 { EXIT_REASON_TPR_BELOW_THRESHOLD, "TPR_BELOW_THRESHOLD" }, \
218 { EXIT_REASON_APIC_ACCESS, "APIC_ACCESS" }, \
219 { EXIT_REASON_EPT_VIOLATION, "EPT_VIOLATION" }, \
220 { EXIT_REASON_EPT_MISCONFIG, "EPT_MISCONFIG" }, \
221 { EXIT_REASON_WBINVD, "WBINVD" }
223 #define SVM_EXIT_REASONS \
224 { SVM_EXIT_READ_CR0, "read_cr0" }, \
225 { SVM_EXIT_READ_CR3, "read_cr3" }, \
226 { SVM_EXIT_READ_CR4, "read_cr4" }, \
227 { SVM_EXIT_READ_CR8, "read_cr8" }, \
228 { SVM_EXIT_WRITE_CR0, "write_cr0" }, \
229 { SVM_EXIT_WRITE_CR3, "write_cr3" }, \
230 { SVM_EXIT_WRITE_CR4, "write_cr4" }, \
231 { SVM_EXIT_WRITE_CR8, "write_cr8" }, \
232 { SVM_EXIT_READ_DR0, "read_dr0" }, \
233 { SVM_EXIT_READ_DR1, "read_dr1" }, \
234 { SVM_EXIT_READ_DR2, "read_dr2" }, \
235 { SVM_EXIT_READ_DR3, "read_dr3" }, \
236 { SVM_EXIT_WRITE_DR0, "write_dr0" }, \
237 { SVM_EXIT_WRITE_DR1, "write_dr1" }, \
238 { SVM_EXIT_WRITE_DR2, "write_dr2" }, \
239 { SVM_EXIT_WRITE_DR3, "write_dr3" }, \
240 { SVM_EXIT_WRITE_DR5, "write_dr5" }, \
241 { SVM_EXIT_WRITE_DR7, "write_dr7" }, \
242 { SVM_EXIT_EXCP_BASE + DB_VECTOR, "DB excp" }, \
243 { SVM_EXIT_EXCP_BASE + BP_VECTOR, "BP excp" }, \
244 { SVM_EXIT_EXCP_BASE + UD_VECTOR, "UD excp" }, \
245 { SVM_EXIT_EXCP_BASE + PF_VECTOR, "PF excp" }, \
246 { SVM_EXIT_EXCP_BASE + NM_VECTOR, "NM excp" }, \
247 { SVM_EXIT_EXCP_BASE + MC_VECTOR, "MC excp" }, \
248 { SVM_EXIT_INTR, "interrupt" }, \
249 { SVM_EXIT_NMI, "nmi" }, \
250 { SVM_EXIT_SMI, "smi" }, \
251 { SVM_EXIT_INIT, "init" }, \
252 { SVM_EXIT_VINTR, "vintr" }, \
253 { SVM_EXIT_CPUID, "cpuid" }, \
254 { SVM_EXIT_INVD, "invd" }, \
255 { SVM_EXIT_HLT, "hlt" }, \
256 { SVM_EXIT_INVLPG, "invlpg" }, \
257 { SVM_EXIT_INVLPGA, "invlpga" }, \
258 { SVM_EXIT_IOIO, "io" }, \
259 { SVM_EXIT_MSR, "msr" }, \
260 { SVM_EXIT_TASK_SWITCH, "task_switch" }, \
261 { SVM_EXIT_SHUTDOWN, "shutdown" }, \
262 { SVM_EXIT_VMRUN, "vmrun" }, \
263 { SVM_EXIT_VMMCALL, "hypercall" }, \
264 { SVM_EXIT_VMLOAD, "vmload" }, \
265 { SVM_EXIT_VMSAVE, "vmsave" }, \
266 { SVM_EXIT_STGI, "stgi" }, \
267 { SVM_EXIT_CLGI, "clgi" }, \
268 { SVM_EXIT_SKINIT, "skinit" }, \
269 { SVM_EXIT_WBINVD, "wbinvd" }, \
270 { SVM_EXIT_MONITOR, "monitor" }, \
271 { SVM_EXIT_MWAIT, "mwait" }, \
272 { SVM_EXIT_XSETBV, "xsetbv" }, \
273 { SVM_EXIT_NPF, "npf" }
276 * Tracepoint for kvm guest exit:
278 TRACE_EVENT(kvm_exit
,
279 TP_PROTO(unsigned int exit_reason
, struct kvm_vcpu
*vcpu
, u32 isa
),
280 TP_ARGS(exit_reason
, vcpu
, isa
),
283 __field( unsigned int, exit_reason
)
284 __field( unsigned long, guest_rip
)
286 __field( u64
, info1
)
287 __field( u64
, info2
)
291 __entry
->exit_reason
= exit_reason
;
292 __entry
->guest_rip
= kvm_rip_read(vcpu
);
294 kvm_x86_ops
->get_exit_info(vcpu
, &__entry
->info1
,
298 TP_printk("reason %s rip 0x%lx info %llx %llx",
299 (__entry
->isa
== KVM_ISA_VMX
) ?
300 __print_symbolic(__entry
->exit_reason
, VMX_EXIT_REASONS
) :
301 __print_symbolic(__entry
->exit_reason
, SVM_EXIT_REASONS
),
302 __entry
->guest_rip
, __entry
->info1
, __entry
->info2
)
306 * Tracepoint for kvm interrupt injection:
308 TRACE_EVENT(kvm_inj_virq
,
309 TP_PROTO(unsigned int irq
),
313 __field( unsigned int, irq
)
320 TP_printk("irq %u", __entry
->irq
)
323 #define EXS(x) { x##_VECTOR, "#" #x }
325 #define kvm_trace_sym_exc \
326 EXS(DE), EXS(DB), EXS(BP), EXS(OF), EXS(BR), EXS(UD), EXS(NM), \
327 EXS(DF), EXS(TS), EXS(NP), EXS(SS), EXS(GP), EXS(PF), \
331 * Tracepoint for kvm interrupt injection:
333 TRACE_EVENT(kvm_inj_exception
,
334 TP_PROTO(unsigned exception
, bool has_error
, unsigned error_code
),
335 TP_ARGS(exception
, has_error
, error_code
),
338 __field( u8
, exception
)
339 __field( u8
, has_error
)
340 __field( u32
, error_code
)
344 __entry
->exception
= exception
;
345 __entry
->has_error
= has_error
;
346 __entry
->error_code
= error_code
;
349 TP_printk("%s (0x%x)",
350 __print_symbolic(__entry
->exception
, kvm_trace_sym_exc
),
351 /* FIXME: don't print error_code if not present */
352 __entry
->has_error
? __entry
->error_code
: 0)
356 * Tracepoint for page fault.
358 TRACE_EVENT(kvm_page_fault
,
359 TP_PROTO(unsigned long fault_address
, unsigned int error_code
),
360 TP_ARGS(fault_address
, error_code
),
363 __field( unsigned long, fault_address
)
364 __field( unsigned int, error_code
)
368 __entry
->fault_address
= fault_address
;
369 __entry
->error_code
= error_code
;
372 TP_printk("address %lx error_code %x",
373 __entry
->fault_address
, __entry
->error_code
)
377 * Tracepoint for guest MSR access.
380 TP_PROTO(unsigned write
, u32 ecx
, u64 data
, bool exception
),
381 TP_ARGS(write
, ecx
, data
, exception
),
384 __field( unsigned, write
)
387 __field( u8
, exception
)
391 __entry
->write
= write
;
393 __entry
->data
= data
;
394 __entry
->exception
= exception
;
397 TP_printk("msr_%s %x = 0x%llx%s",
398 __entry
->write
? "write" : "read",
399 __entry
->ecx
, __entry
->data
,
400 __entry
->exception
? " (#GP)" : "")
403 #define trace_kvm_msr_read(ecx, data) trace_kvm_msr(0, ecx, data, false)
404 #define trace_kvm_msr_write(ecx, data) trace_kvm_msr(1, ecx, data, false)
405 #define trace_kvm_msr_read_ex(ecx) trace_kvm_msr(0, ecx, 0, true)
406 #define trace_kvm_msr_write_ex(ecx, data) trace_kvm_msr(1, ecx, data, true)
409 * Tracepoint for guest CR access.
412 TP_PROTO(unsigned int rw
, unsigned int cr
, unsigned long val
),
413 TP_ARGS(rw
, cr
, val
),
416 __field( unsigned int, rw
)
417 __field( unsigned int, cr
)
418 __field( unsigned long, val
)
427 TP_printk("cr_%s %x = 0x%lx",
428 __entry
->rw
? "write" : "read",
429 __entry
->cr
, __entry
->val
)
432 #define trace_kvm_cr_read(cr, val) trace_kvm_cr(0, cr, val)
433 #define trace_kvm_cr_write(cr, val) trace_kvm_cr(1, cr, val)
435 TRACE_EVENT(kvm_pic_set_irq
,
436 TP_PROTO(__u8 chip
, __u8 pin
, __u8 elcr
, __u8 imr
, bool coalesced
),
437 TP_ARGS(chip
, pin
, elcr
, imr
, coalesced
),
440 __field( __u8
, chip
)
442 __field( __u8
, elcr
)
444 __field( bool, coalesced
)
448 __entry
->chip
= chip
;
450 __entry
->elcr
= elcr
;
452 __entry
->coalesced
= coalesced
;
455 TP_printk("chip %u pin %u (%s%s)%s",
456 __entry
->chip
, __entry
->pin
,
457 (__entry
->elcr
& (1 << __entry
->pin
)) ? "level":"edge",
458 (__entry
->imr
& (1 << __entry
->pin
)) ? "|masked":"",
459 __entry
->coalesced
? " (coalesced)" : "")
462 #define kvm_apic_dst_shorthand \
466 {0x3, "all-but-self"}
468 TRACE_EVENT(kvm_apic_ipi
,
469 TP_PROTO(__u32 icr_low
, __u32 dest_id
),
470 TP_ARGS(icr_low
, dest_id
),
473 __field( __u32
, icr_low
)
474 __field( __u32
, dest_id
)
478 __entry
->icr_low
= icr_low
;
479 __entry
->dest_id
= dest_id
;
482 TP_printk("dst %x vec %u (%s|%s|%s|%s|%s)",
483 __entry
->dest_id
, (u8
)__entry
->icr_low
,
484 __print_symbolic((__entry
->icr_low
>> 8 & 0x7),
486 (__entry
->icr_low
& (1<<11)) ? "logical" : "physical",
487 (__entry
->icr_low
& (1<<14)) ? "assert" : "de-assert",
488 (__entry
->icr_low
& (1<<15)) ? "level" : "edge",
489 __print_symbolic((__entry
->icr_low
>> 18 & 0x3),
490 kvm_apic_dst_shorthand
))
493 TRACE_EVENT(kvm_apic_accept_irq
,
494 TP_PROTO(__u32 apicid
, __u16 dm
, __u8 tm
, __u8 vec
, bool coalesced
),
495 TP_ARGS(apicid
, dm
, tm
, vec
, coalesced
),
498 __field( __u32
, apicid
)
502 __field( bool, coalesced
)
506 __entry
->apicid
= apicid
;
510 __entry
->coalesced
= coalesced
;
513 TP_printk("apicid %x vec %u (%s|%s)%s",
514 __entry
->apicid
, __entry
->vec
,
515 __print_symbolic((__entry
->dm
>> 8 & 0x7), kvm_deliver_mode
),
516 __entry
->tm
? "level" : "edge",
517 __entry
->coalesced
? " (coalesced)" : "")
521 * Tracepoint for nested VMRUN
523 TRACE_EVENT(kvm_nested_vmrun
,
524 TP_PROTO(__u64 rip
, __u64 vmcb
, __u64 nested_rip
, __u32 int_ctl
,
525 __u32 event_inj
, bool npt
),
526 TP_ARGS(rip
, vmcb
, nested_rip
, int_ctl
, event_inj
, npt
),
529 __field( __u64
, rip
)
530 __field( __u64
, vmcb
)
531 __field( __u64
, nested_rip
)
532 __field( __u32
, int_ctl
)
533 __field( __u32
, event_inj
)
539 __entry
->vmcb
= vmcb
;
540 __entry
->nested_rip
= nested_rip
;
541 __entry
->int_ctl
= int_ctl
;
542 __entry
->event_inj
= event_inj
;
546 TP_printk("rip: 0x%016llx vmcb: 0x%016llx nrip: 0x%016llx int_ctl: 0x%08x "
547 "event_inj: 0x%08x npt: %s",
548 __entry
->rip
, __entry
->vmcb
, __entry
->nested_rip
,
549 __entry
->int_ctl
, __entry
->event_inj
,
550 __entry
->npt
? "on" : "off")
553 TRACE_EVENT(kvm_nested_intercepts
,
554 TP_PROTO(__u16 cr_read
, __u16 cr_write
, __u32 exceptions
, __u64 intercept
),
555 TP_ARGS(cr_read
, cr_write
, exceptions
, intercept
),
558 __field( __u16
, cr_read
)
559 __field( __u16
, cr_write
)
560 __field( __u32
, exceptions
)
561 __field( __u64
, intercept
)
565 __entry
->cr_read
= cr_read
;
566 __entry
->cr_write
= cr_write
;
567 __entry
->exceptions
= exceptions
;
568 __entry
->intercept
= intercept
;
571 TP_printk("cr_read: %04x cr_write: %04x excp: %08x intercept: %016llx",
572 __entry
->cr_read
, __entry
->cr_write
, __entry
->exceptions
,
576 * Tracepoint for #VMEXIT while nested
578 TRACE_EVENT(kvm_nested_vmexit
,
579 TP_PROTO(__u64 rip
, __u32 exit_code
,
580 __u64 exit_info1
, __u64 exit_info2
,
581 __u32 exit_int_info
, __u32 exit_int_info_err
, __u32 isa
),
582 TP_ARGS(rip
, exit_code
, exit_info1
, exit_info2
,
583 exit_int_info
, exit_int_info_err
, isa
),
586 __field( __u64
, rip
)
587 __field( __u32
, exit_code
)
588 __field( __u64
, exit_info1
)
589 __field( __u64
, exit_info2
)
590 __field( __u32
, exit_int_info
)
591 __field( __u32
, exit_int_info_err
)
592 __field( __u32
, isa
)
597 __entry
->exit_code
= exit_code
;
598 __entry
->exit_info1
= exit_info1
;
599 __entry
->exit_info2
= exit_info2
;
600 __entry
->exit_int_info
= exit_int_info
;
601 __entry
->exit_int_info_err
= exit_int_info_err
;
604 TP_printk("rip: 0x%016llx reason: %s ext_inf1: 0x%016llx "
605 "ext_inf2: 0x%016llx ext_int: 0x%08x ext_int_err: 0x%08x",
607 (__entry
->isa
== KVM_ISA_VMX
) ?
608 __print_symbolic(__entry
->exit_code
, VMX_EXIT_REASONS
) :
609 __print_symbolic(__entry
->exit_code
, SVM_EXIT_REASONS
),
610 __entry
->exit_info1
, __entry
->exit_info2
,
611 __entry
->exit_int_info
, __entry
->exit_int_info_err
)
615 * Tracepoint for #VMEXIT reinjected to the guest
617 TRACE_EVENT(kvm_nested_vmexit_inject
,
618 TP_PROTO(__u32 exit_code
,
619 __u64 exit_info1
, __u64 exit_info2
,
620 __u32 exit_int_info
, __u32 exit_int_info_err
, __u32 isa
),
621 TP_ARGS(exit_code
, exit_info1
, exit_info2
,
622 exit_int_info
, exit_int_info_err
, isa
),
625 __field( __u32
, exit_code
)
626 __field( __u64
, exit_info1
)
627 __field( __u64
, exit_info2
)
628 __field( __u32
, exit_int_info
)
629 __field( __u32
, exit_int_info_err
)
630 __field( __u32
, isa
)
634 __entry
->exit_code
= exit_code
;
635 __entry
->exit_info1
= exit_info1
;
636 __entry
->exit_info2
= exit_info2
;
637 __entry
->exit_int_info
= exit_int_info
;
638 __entry
->exit_int_info_err
= exit_int_info_err
;
642 TP_printk("reason: %s ext_inf1: 0x%016llx "
643 "ext_inf2: 0x%016llx ext_int: 0x%08x ext_int_err: 0x%08x",
644 (__entry
->isa
== KVM_ISA_VMX
) ?
645 __print_symbolic(__entry
->exit_code
, VMX_EXIT_REASONS
) :
646 __print_symbolic(__entry
->exit_code
, SVM_EXIT_REASONS
),
647 __entry
->exit_info1
, __entry
->exit_info2
,
648 __entry
->exit_int_info
, __entry
->exit_int_info_err
)
652 * Tracepoint for nested #vmexit because of interrupt pending
654 TRACE_EVENT(kvm_nested_intr_vmexit
,
659 __field( __u64
, rip
)
666 TP_printk("rip: 0x%016llx", __entry
->rip
)
670 * Tracepoint for nested #vmexit because of interrupt pending
672 TRACE_EVENT(kvm_invlpga
,
673 TP_PROTO(__u64 rip
, int asid
, u64 address
),
674 TP_ARGS(rip
, asid
, address
),
677 __field( __u64
, rip
)
679 __field( __u64
, address
)
684 __entry
->asid
= asid
;
685 __entry
->address
= address
;
688 TP_printk("rip: 0x%016llx asid: %d address: 0x%016llx",
689 __entry
->rip
, __entry
->asid
, __entry
->address
)
693 * Tracepoint for nested #vmexit because of interrupt pending
695 TRACE_EVENT(kvm_skinit
,
696 TP_PROTO(__u64 rip
, __u32 slb
),
700 __field( __u64
, rip
)
701 __field( __u32
, slb
)
709 TP_printk("rip: 0x%016llx slb: 0x%08x",
710 __entry
->rip
, __entry
->slb
)
713 #define __print_insn(insn, ilen) ({ \
715 const char *ret = p->buffer + p->len; \
717 for (i = 0; i < ilen; ++i) \
718 trace_seq_printf(p, " %02x", insn[i]); \
719 trace_seq_printf(p, "%c", 0); \
723 #define KVM_EMUL_INSN_F_CR0_PE (1 << 0)
724 #define KVM_EMUL_INSN_F_EFL_VM (1 << 1)
725 #define KVM_EMUL_INSN_F_CS_D (1 << 2)
726 #define KVM_EMUL_INSN_F_CS_L (1 << 3)
728 #define kvm_trace_symbol_emul_flags \
730 { KVM_EMUL_INSN_F_CR0_PE \
731 | KVM_EMUL_INSN_F_EFL_VM, "vm16" }, \
732 { KVM_EMUL_INSN_F_CR0_PE, "prot16" }, \
733 { KVM_EMUL_INSN_F_CR0_PE \
734 | KVM_EMUL_INSN_F_CS_D, "prot32" }, \
735 { KVM_EMUL_INSN_F_CR0_PE \
736 | KVM_EMUL_INSN_F_CS_L, "prot64" }
738 #define kei_decode_mode(mode) ({ \
741 case X86EMUL_MODE_REAL: \
744 case X86EMUL_MODE_VM86: \
745 flags = KVM_EMUL_INSN_F_EFL_VM; \
747 case X86EMUL_MODE_PROT16: \
748 flags = KVM_EMUL_INSN_F_CR0_PE; \
750 case X86EMUL_MODE_PROT32: \
751 flags = KVM_EMUL_INSN_F_CR0_PE \
752 | KVM_EMUL_INSN_F_CS_D; \
754 case X86EMUL_MODE_PROT64: \
755 flags = KVM_EMUL_INSN_F_CR0_PE \
756 | KVM_EMUL_INSN_F_CS_L; \
762 TRACE_EVENT(kvm_emulate_insn
,
763 TP_PROTO(struct kvm_vcpu
*vcpu
, __u8 failed
),
764 TP_ARGS(vcpu
, failed
),
767 __field( __u64
, rip
)
768 __field( __u32
, csbase
)
770 __array( __u8
, insn
, 15 )
771 __field( __u8
, flags
)
772 __field( __u8
, failed
)
776 __entry
->rip
= vcpu
->arch
.emulate_ctxt
.fetch
.start
;
777 __entry
->csbase
= kvm_x86_ops
->get_segment_base(vcpu
, VCPU_SREG_CS
);
778 __entry
->len
= vcpu
->arch
.emulate_ctxt
._eip
779 - vcpu
->arch
.emulate_ctxt
.fetch
.start
;
780 memcpy(__entry
->insn
,
781 vcpu
->arch
.emulate_ctxt
.fetch
.data
,
783 __entry
->flags
= kei_decode_mode(vcpu
->arch
.emulate_ctxt
.mode
);
784 __entry
->failed
= failed
;
787 TP_printk("%x:%llx:%s (%s)%s",
788 __entry
->csbase
, __entry
->rip
,
789 __print_insn(__entry
->insn
, __entry
->len
),
790 __print_symbolic(__entry
->flags
,
791 kvm_trace_symbol_emul_flags
),
792 __entry
->failed
? " failed" : ""
796 #define trace_kvm_emulate_insn_start(vcpu) trace_kvm_emulate_insn(vcpu, 0)
797 #define trace_kvm_emulate_insn_failed(vcpu) trace_kvm_emulate_insn(vcpu, 1)
801 TP_PROTO(gva_t gva
, gpa_t gpa
, bool write
, bool gpa_match
),
802 TP_ARGS(gva
, gpa
, write
, gpa_match
),
808 __field(bool, gpa_match
)
814 __entry
->write
= write
;
815 __entry
->gpa_match
= gpa_match
818 TP_printk("gva %#lx gpa %#llx %s %s", __entry
->gva
, __entry
->gpa
,
819 __entry
->write
? "Write" : "Read",
820 __entry
->gpa_match
? "GPA" : "GVA")
822 #endif /* _TRACE_KVM_H */
824 #undef TRACE_INCLUDE_PATH
825 #define TRACE_INCLUDE_PATH arch/x86/kvm
826 #undef TRACE_INCLUDE_FILE
827 #define TRACE_INCLUDE_FILE trace
829 /* This part must be outside protection */
830 #include <trace/define_trace.h>