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 .
9 #define TRACE_INCLUDE_FILE trace
12 * Tracepoint for guest mode entry.
14 TRACE_EVENT(kvm_ppc_instr
,
15 TP_PROTO(unsigned int inst
, unsigned long _pc
, unsigned int emulate
),
16 TP_ARGS(inst
, _pc
, emulate
),
19 __field( unsigned int, inst
)
20 __field( unsigned long, pc
)
21 __field( unsigned int, emulate
)
27 __entry
->emulate
= emulate
;
30 TP_printk("inst %u pc 0x%lx emulate %u\n",
31 __entry
->inst
, __entry
->pc
, __entry
->emulate
)
34 #ifdef CONFIG_PPC_BOOK3S
35 #define kvm_trace_symbol_exit \
36 {0x100, "SYSTEM_RESET"}, \
37 {0x200, "MACHINE_CHECK"}, \
38 {0x300, "DATA_STORAGE"}, \
39 {0x380, "DATA_SEGMENT"}, \
40 {0x400, "INST_STORAGE"}, \
41 {0x480, "INST_SEGMENT"}, \
42 {0x500, "EXTERNAL"}, \
43 {0x501, "EXTERNAL_LEVEL"}, \
44 {0x502, "EXTERNAL_HV"}, \
45 {0x600, "ALIGNMENT"}, \
47 {0x800, "FP_UNAVAIL"}, \
48 {0x900, "DECREMENTER"}, \
49 {0x980, "HV_DECREMENTER"}, \
52 {0xe00, "H_DATA_STORAGE"}, \
53 {0xe20, "H_INST_STORAGE"}, \
54 {0xe40, "H_EMUL_ASSIST"}, \
59 #define kvm_trace_symbol_exit \
61 {1, "MACHINE_CHECK"}, \
62 {2, "DATA_STORAGE"}, \
63 {3, "INST_STORAGE"}, \
70 {10, "DECREMENTER"}, \
76 {32, "SPE_UNAVAIL"}, \
77 {33, "SPE_FP_DATA"}, \
78 {34, "SPE_FP_ROUND"}, \
79 {35, "PERFORMANCE_MONITOR"}, \
81 {37, "DOORBELL_CRITICAL"}, \
82 {38, "GUEST_DBELL"}, \
83 {39, "GUEST_DBELL_CRIT"}, \
89 TP_PROTO(unsigned int exit_nr
, struct kvm_vcpu
*vcpu
),
90 TP_ARGS(exit_nr
, vcpu
),
93 __field( unsigned int, exit_nr
)
94 __field( unsigned long, pc
)
95 __field( unsigned long, msr
)
96 __field( unsigned long, dar
)
97 #ifdef CONFIG_KVM_BOOK3S_PR
98 __field( unsigned long, srr1
)
100 __field( unsigned long, last_inst
)
104 #ifdef CONFIG_KVM_BOOK3S_PR
105 struct kvmppc_book3s_shadow_vcpu
*svcpu
;
107 __entry
->exit_nr
= exit_nr
;
108 __entry
->pc
= kvmppc_get_pc(vcpu
);
109 __entry
->dar
= kvmppc_get_fault_dar(vcpu
);
110 __entry
->msr
= vcpu
->arch
.shared
->msr
;
111 #ifdef CONFIG_KVM_BOOK3S_PR
112 svcpu
= svcpu_get(vcpu
);
113 __entry
->srr1
= svcpu
->shadow_srr1
;
116 __entry
->last_inst
= vcpu
->arch
.last_inst
;
123 #ifdef CONFIG_KVM_BOOK3S_PR
128 __print_symbolic(__entry
->exit_nr
, kvm_trace_symbol_exit
),
132 #ifdef CONFIG_KVM_BOOK3S_PR
139 TRACE_EVENT(kvm_unmap_hva
,
140 TP_PROTO(unsigned long hva
),
144 __field( unsigned long, hva
)
151 TP_printk("unmap hva 0x%lx\n", __entry
->hva
)
154 TRACE_EVENT(kvm_stlb_inval
,
155 TP_PROTO(unsigned int stlb_index
),
159 __field( unsigned int, stlb_index
)
163 __entry
->stlb_index
= stlb_index
;
166 TP_printk("stlb_index %u", __entry
->stlb_index
)
169 TRACE_EVENT(kvm_stlb_write
,
170 TP_PROTO(unsigned int victim
, unsigned int tid
, unsigned int word0
,
171 unsigned int word1
, unsigned int word2
),
172 TP_ARGS(victim
, tid
, word0
, word1
, word2
),
175 __field( unsigned int, victim
)
176 __field( unsigned int, tid
)
177 __field( unsigned int, word0
)
178 __field( unsigned int, word1
)
179 __field( unsigned int, word2
)
183 __entry
->victim
= victim
;
185 __entry
->word0
= word0
;
186 __entry
->word1
= word1
;
187 __entry
->word2
= word2
;
190 TP_printk("victim %u tid %u w0 %u w1 %u w2 %u",
191 __entry
->victim
, __entry
->tid
, __entry
->word0
,
192 __entry
->word1
, __entry
->word2
)
195 TRACE_EVENT(kvm_gtlb_write
,
196 TP_PROTO(unsigned int gtlb_index
, unsigned int tid
, unsigned int word0
,
197 unsigned int word1
, unsigned int word2
),
198 TP_ARGS(gtlb_index
, tid
, word0
, word1
, word2
),
201 __field( unsigned int, gtlb_index
)
202 __field( unsigned int, tid
)
203 __field( unsigned int, word0
)
204 __field( unsigned int, word1
)
205 __field( unsigned int, word2
)
209 __entry
->gtlb_index
= gtlb_index
;
211 __entry
->word0
= word0
;
212 __entry
->word1
= word1
;
213 __entry
->word2
= word2
;
216 TP_printk("gtlb_index %u tid %u w0 %u w1 %u w2 %u",
217 __entry
->gtlb_index
, __entry
->tid
, __entry
->word0
,
218 __entry
->word1
, __entry
->word2
)
221 TRACE_EVENT(kvm_check_requests
,
222 TP_PROTO(struct kvm_vcpu
*vcpu
),
226 __field( __u32
, cpu_nr
)
227 __field( __u32
, requests
)
231 __entry
->cpu_nr
= vcpu
->vcpu_id
;
232 __entry
->requests
= vcpu
->requests
;
235 TP_printk("vcpu=%x requests=%x",
236 __entry
->cpu_nr
, __entry
->requests
)
240 /*************************************************************************
241 * Book3S trace points *
242 *************************************************************************/
244 #ifdef CONFIG_KVM_BOOK3S_PR
246 TRACE_EVENT(kvm_book3s_reenter
,
247 TP_PROTO(int r
, struct kvm_vcpu
*vcpu
),
251 __field( unsigned int, r
)
252 __field( unsigned long, pc
)
257 __entry
->pc
= kvmppc_get_pc(vcpu
);
260 TP_printk("reentry r=%d | pc=0x%lx", __entry
->r
, __entry
->pc
)
263 #ifdef CONFIG_PPC_BOOK3S_64
265 TRACE_EVENT(kvm_book3s_64_mmu_map
,
266 TP_PROTO(int rflags
, ulong hpteg
, ulong va
, pfn_t hpaddr
,
267 struct kvmppc_pte
*orig_pte
),
268 TP_ARGS(rflags
, hpteg
, va
, hpaddr
, orig_pte
),
271 __field( unsigned char, flag_w
)
272 __field( unsigned char, flag_x
)
273 __field( unsigned long, eaddr
)
274 __field( unsigned long, hpteg
)
275 __field( unsigned long, va
)
276 __field( unsigned long long, vpage
)
277 __field( unsigned long, hpaddr
)
281 __entry
->flag_w
= ((rflags
& HPTE_R_PP
) == 3) ? '-' : 'w';
282 __entry
->flag_x
= (rflags
& HPTE_R_N
) ? '-' : 'x';
283 __entry
->eaddr
= orig_pte
->eaddr
;
284 __entry
->hpteg
= hpteg
;
286 __entry
->vpage
= orig_pte
->vpage
;
287 __entry
->hpaddr
= hpaddr
;
290 TP_printk("KVM: %c%c Map 0x%lx: [%lx] 0x%lx (0x%llx) -> %lx",
291 __entry
->flag_w
, __entry
->flag_x
, __entry
->eaddr
,
292 __entry
->hpteg
, __entry
->va
, __entry
->vpage
, __entry
->hpaddr
)
295 #endif /* CONFIG_PPC_BOOK3S_64 */
297 TRACE_EVENT(kvm_book3s_mmu_map
,
298 TP_PROTO(struct hpte_cache
*pte
),
302 __field( u64
, host_vpn
)
304 __field( ulong
, eaddr
)
305 __field( u64
, vpage
)
306 __field( ulong
, raddr
)
307 __field( int, flags
)
311 __entry
->host_vpn
= pte
->host_vpn
;
312 __entry
->pfn
= pte
->pfn
;
313 __entry
->eaddr
= pte
->pte
.eaddr
;
314 __entry
->vpage
= pte
->pte
.vpage
;
315 __entry
->raddr
= pte
->pte
.raddr
;
316 __entry
->flags
= (pte
->pte
.may_read
? 0x4 : 0) |
317 (pte
->pte
.may_write
? 0x2 : 0) |
318 (pte
->pte
.may_execute
? 0x1 : 0);
321 TP_printk("Map: hvpn=%llx pfn=%llx ea=%lx vp=%llx ra=%lx [%x]",
322 __entry
->host_vpn
, __entry
->pfn
, __entry
->eaddr
,
323 __entry
->vpage
, __entry
->raddr
, __entry
->flags
)
326 TRACE_EVENT(kvm_book3s_mmu_invalidate
,
327 TP_PROTO(struct hpte_cache
*pte
),
331 __field( u64
, host_vpn
)
333 __field( ulong
, eaddr
)
334 __field( u64
, vpage
)
335 __field( ulong
, raddr
)
336 __field( int, flags
)
340 __entry
->host_vpn
= pte
->host_vpn
;
341 __entry
->pfn
= pte
->pfn
;
342 __entry
->eaddr
= pte
->pte
.eaddr
;
343 __entry
->vpage
= pte
->pte
.vpage
;
344 __entry
->raddr
= pte
->pte
.raddr
;
345 __entry
->flags
= (pte
->pte
.may_read
? 0x4 : 0) |
346 (pte
->pte
.may_write
? 0x2 : 0) |
347 (pte
->pte
.may_execute
? 0x1 : 0);
350 TP_printk("Flush: hva=%llx pfn=%llx ea=%lx vp=%llx ra=%lx [%x]",
351 __entry
->host_vpn
, __entry
->pfn
, __entry
->eaddr
,
352 __entry
->vpage
, __entry
->raddr
, __entry
->flags
)
355 TRACE_EVENT(kvm_book3s_mmu_flush
,
356 TP_PROTO(const char *type
, struct kvm_vcpu
*vcpu
, unsigned long long p1
,
357 unsigned long long p2
),
358 TP_ARGS(type
, vcpu
, p1
, p2
),
361 __field( int, count
)
362 __field( unsigned long long, p1
)
363 __field( unsigned long long, p2
)
364 __field( const char *, type
)
368 __entry
->count
= to_book3s(vcpu
)->hpte_cache_count
;
371 __entry
->type
= type
;
374 TP_printk("Flush %d %sPTEs: %llx - %llx",
375 __entry
->count
, __entry
->type
, __entry
->p1
, __entry
->p2
)
378 TRACE_EVENT(kvm_book3s_slb_found
,
379 TP_PROTO(unsigned long long gvsid
, unsigned long long hvsid
),
380 TP_ARGS(gvsid
, hvsid
),
383 __field( unsigned long long, gvsid
)
384 __field( unsigned long long, hvsid
)
388 __entry
->gvsid
= gvsid
;
389 __entry
->hvsid
= hvsid
;
392 TP_printk("%llx -> %llx", __entry
->gvsid
, __entry
->hvsid
)
395 TRACE_EVENT(kvm_book3s_slb_fail
,
396 TP_PROTO(u16 sid_map_mask
, unsigned long long gvsid
),
397 TP_ARGS(sid_map_mask
, gvsid
),
400 __field( unsigned short, sid_map_mask
)
401 __field( unsigned long long, gvsid
)
405 __entry
->sid_map_mask
= sid_map_mask
;
406 __entry
->gvsid
= gvsid
;
409 TP_printk("%x/%x: %llx", __entry
->sid_map_mask
,
410 SID_MAP_MASK
- __entry
->sid_map_mask
, __entry
->gvsid
)
413 TRACE_EVENT(kvm_book3s_slb_map
,
414 TP_PROTO(u16 sid_map_mask
, unsigned long long gvsid
,
415 unsigned long long hvsid
),
416 TP_ARGS(sid_map_mask
, gvsid
, hvsid
),
419 __field( unsigned short, sid_map_mask
)
420 __field( unsigned long long, guest_vsid
)
421 __field( unsigned long long, host_vsid
)
425 __entry
->sid_map_mask
= sid_map_mask
;
426 __entry
->guest_vsid
= gvsid
;
427 __entry
->host_vsid
= hvsid
;
430 TP_printk("%x: %llx -> %llx", __entry
->sid_map_mask
,
431 __entry
->guest_vsid
, __entry
->host_vsid
)
434 TRACE_EVENT(kvm_book3s_slbmte
,
435 TP_PROTO(u64 slb_vsid
, u64 slb_esid
),
436 TP_ARGS(slb_vsid
, slb_esid
),
439 __field( u64
, slb_vsid
)
440 __field( u64
, slb_esid
)
444 __entry
->slb_vsid
= slb_vsid
;
445 __entry
->slb_esid
= slb_esid
;
448 TP_printk("%llx, %llx", __entry
->slb_vsid
, __entry
->slb_esid
)
451 #endif /* CONFIG_PPC_BOOK3S */
454 /*************************************************************************
455 * Book3E trace points *
456 *************************************************************************/
460 TRACE_EVENT(kvm_booke206_stlb_write
,
461 TP_PROTO(__u32 mas0
, __u32 mas8
, __u32 mas1
, __u64 mas2
, __u64 mas7_3
),
462 TP_ARGS(mas0
, mas8
, mas1
, mas2
, mas7_3
),
465 __field( __u32
, mas0
)
466 __field( __u32
, mas8
)
467 __field( __u32
, mas1
)
468 __field( __u64
, mas2
)
469 __field( __u64
, mas7_3
)
473 __entry
->mas0
= mas0
;
474 __entry
->mas8
= mas8
;
475 __entry
->mas1
= mas1
;
476 __entry
->mas2
= mas2
;
477 __entry
->mas7_3
= mas7_3
;
480 TP_printk("mas0=%x mas8=%x mas1=%x mas2=%llx mas7_3=%llx",
481 __entry
->mas0
, __entry
->mas8
, __entry
->mas1
,
482 __entry
->mas2
, __entry
->mas7_3
)
485 TRACE_EVENT(kvm_booke206_gtlb_write
,
486 TP_PROTO(__u32 mas0
, __u32 mas1
, __u64 mas2
, __u64 mas7_3
),
487 TP_ARGS(mas0
, mas1
, mas2
, mas7_3
),
490 __field( __u32
, mas0
)
491 __field( __u32
, mas1
)
492 __field( __u64
, mas2
)
493 __field( __u64
, mas7_3
)
497 __entry
->mas0
= mas0
;
498 __entry
->mas1
= mas1
;
499 __entry
->mas2
= mas2
;
500 __entry
->mas7_3
= mas7_3
;
503 TP_printk("mas0=%x mas1=%x mas2=%llx mas7_3=%llx",
504 __entry
->mas0
, __entry
->mas1
,
505 __entry
->mas2
, __entry
->mas7_3
)
508 TRACE_EVENT(kvm_booke206_ref_release
,
509 TP_PROTO(__u64 pfn
, __u32 flags
),
513 __field( __u64
, pfn
)
514 __field( __u32
, flags
)
519 __entry
->flags
= flags
;
522 TP_printk("pfn=%llx flags=%x",
523 __entry
->pfn
, __entry
->flags
)
526 TRACE_EVENT(kvm_booke_queue_irqprio
,
527 TP_PROTO(struct kvm_vcpu
*vcpu
, unsigned int priority
),
528 TP_ARGS(vcpu
, priority
),
531 __field( __u32
, cpu_nr
)
532 __field( __u32
, priority
)
533 __field( unsigned long, pending
)
537 __entry
->cpu_nr
= vcpu
->vcpu_id
;
538 __entry
->priority
= priority
;
539 __entry
->pending
= vcpu
->arch
.pending_exceptions
;
542 TP_printk("vcpu=%x prio=%x pending=%lx",
543 __entry
->cpu_nr
, __entry
->priority
, __entry
->pending
)
548 #endif /* _TRACE_KVM_H */
550 /* This part must be outside protection */
551 #include <trace/define_trace.h>