xref: /linux/arch/powerpc/kvm/trace_pr.h (revision ba049e93aef7e8c571567088b1b73f4f5b99272a)
172c12535SAneesh Kumar K.V 
272c12535SAneesh Kumar K.V #if !defined(_TRACE_KVM_PR_H) || defined(TRACE_HEADER_MULTI_READ)
372c12535SAneesh Kumar K.V #define _TRACE_KVM_PR_H
472c12535SAneesh Kumar K.V 
572c12535SAneesh Kumar K.V #include <linux/tracepoint.h>
63c78f78aSSuresh E. Warrier #include "trace_book3s.h"
772c12535SAneesh Kumar K.V 
872c12535SAneesh Kumar K.V #undef TRACE_SYSTEM
972c12535SAneesh Kumar K.V #define TRACE_SYSTEM kvm_pr
1072c12535SAneesh Kumar K.V #define TRACE_INCLUDE_PATH .
1172c12535SAneesh Kumar K.V #define TRACE_INCLUDE_FILE trace_pr
1272c12535SAneesh Kumar K.V 
1372c12535SAneesh Kumar K.V TRACE_EVENT(kvm_book3s_reenter,
1472c12535SAneesh Kumar K.V 	TP_PROTO(int r, struct kvm_vcpu *vcpu),
1572c12535SAneesh Kumar K.V 	TP_ARGS(r, vcpu),
1672c12535SAneesh Kumar K.V 
1772c12535SAneesh Kumar K.V 	TP_STRUCT__entry(
1872c12535SAneesh Kumar K.V 		__field(	unsigned int,	r		)
1972c12535SAneesh Kumar K.V 		__field(	unsigned long,	pc		)
2072c12535SAneesh Kumar K.V 	),
2172c12535SAneesh Kumar K.V 
2272c12535SAneesh Kumar K.V 	TP_fast_assign(
2372c12535SAneesh Kumar K.V 		__entry->r		= r;
2472c12535SAneesh Kumar K.V 		__entry->pc		= kvmppc_get_pc(vcpu);
2572c12535SAneesh Kumar K.V 	),
2672c12535SAneesh Kumar K.V 
2772c12535SAneesh Kumar K.V 	TP_printk("reentry r=%d | pc=0x%lx", __entry->r, __entry->pc)
2872c12535SAneesh Kumar K.V );
2972c12535SAneesh Kumar K.V 
3072c12535SAneesh Kumar K.V #ifdef CONFIG_PPC_BOOK3S_64
3172c12535SAneesh Kumar K.V 
3272c12535SAneesh Kumar K.V TRACE_EVENT(kvm_book3s_64_mmu_map,
33*ba049e93SDan Williams 	TP_PROTO(int rflags, ulong hpteg, ulong va, kvm_pfn_t hpaddr,
3472c12535SAneesh Kumar K.V 		 struct kvmppc_pte *orig_pte),
3572c12535SAneesh Kumar K.V 	TP_ARGS(rflags, hpteg, va, hpaddr, orig_pte),
3672c12535SAneesh Kumar K.V 
3772c12535SAneesh Kumar K.V 	TP_STRUCT__entry(
3872c12535SAneesh Kumar K.V 		__field(	unsigned char,		flag_w		)
3972c12535SAneesh Kumar K.V 		__field(	unsigned char,		flag_x		)
4072c12535SAneesh Kumar K.V 		__field(	unsigned long,		eaddr		)
4172c12535SAneesh Kumar K.V 		__field(	unsigned long,		hpteg		)
4272c12535SAneesh Kumar K.V 		__field(	unsigned long,		va		)
4372c12535SAneesh Kumar K.V 		__field(	unsigned long long,	vpage		)
4472c12535SAneesh Kumar K.V 		__field(	unsigned long,		hpaddr		)
4572c12535SAneesh Kumar K.V 	),
4672c12535SAneesh Kumar K.V 
4772c12535SAneesh Kumar K.V 	TP_fast_assign(
4872c12535SAneesh Kumar K.V 		__entry->flag_w	= ((rflags & HPTE_R_PP) == 3) ? '-' : 'w';
4972c12535SAneesh Kumar K.V 		__entry->flag_x	= (rflags & HPTE_R_N) ? '-' : 'x';
5072c12535SAneesh Kumar K.V 		__entry->eaddr	= orig_pte->eaddr;
5172c12535SAneesh Kumar K.V 		__entry->hpteg	= hpteg;
5272c12535SAneesh Kumar K.V 		__entry->va	= va;
5372c12535SAneesh Kumar K.V 		__entry->vpage	= orig_pte->vpage;
5472c12535SAneesh Kumar K.V 		__entry->hpaddr	= hpaddr;
5572c12535SAneesh Kumar K.V 	),
5672c12535SAneesh Kumar K.V 
5772c12535SAneesh Kumar K.V 	TP_printk("KVM: %c%c Map 0x%lx: [%lx] 0x%lx (0x%llx) -> %lx",
5872c12535SAneesh Kumar K.V 		  __entry->flag_w, __entry->flag_x, __entry->eaddr,
5972c12535SAneesh Kumar K.V 		  __entry->hpteg, __entry->va, __entry->vpage, __entry->hpaddr)
6072c12535SAneesh Kumar K.V );
6172c12535SAneesh Kumar K.V 
6272c12535SAneesh Kumar K.V #endif /* CONFIG_PPC_BOOK3S_64 */
6372c12535SAneesh Kumar K.V 
6472c12535SAneesh Kumar K.V TRACE_EVENT(kvm_book3s_mmu_map,
6572c12535SAneesh Kumar K.V 	TP_PROTO(struct hpte_cache *pte),
6672c12535SAneesh Kumar K.V 	TP_ARGS(pte),
6772c12535SAneesh Kumar K.V 
6872c12535SAneesh Kumar K.V 	TP_STRUCT__entry(
6972c12535SAneesh Kumar K.V 		__field(	u64,		host_vpn	)
7072c12535SAneesh Kumar K.V 		__field(	u64,		pfn		)
7172c12535SAneesh Kumar K.V 		__field(	ulong,		eaddr		)
7272c12535SAneesh Kumar K.V 		__field(	u64,		vpage		)
7372c12535SAneesh Kumar K.V 		__field(	ulong,		raddr		)
7472c12535SAneesh Kumar K.V 		__field(	int,		flags		)
7572c12535SAneesh Kumar K.V 	),
7672c12535SAneesh Kumar K.V 
7772c12535SAneesh Kumar K.V 	TP_fast_assign(
7872c12535SAneesh Kumar K.V 		__entry->host_vpn	= pte->host_vpn;
7972c12535SAneesh Kumar K.V 		__entry->pfn		= pte->pfn;
8072c12535SAneesh Kumar K.V 		__entry->eaddr		= pte->pte.eaddr;
8172c12535SAneesh Kumar K.V 		__entry->vpage		= pte->pte.vpage;
8272c12535SAneesh Kumar K.V 		__entry->raddr		= pte->pte.raddr;
8372c12535SAneesh Kumar K.V 		__entry->flags		= (pte->pte.may_read ? 0x4 : 0) |
8472c12535SAneesh Kumar K.V 					  (pte->pte.may_write ? 0x2 : 0) |
8572c12535SAneesh Kumar K.V 					  (pte->pte.may_execute ? 0x1 : 0);
8672c12535SAneesh Kumar K.V 	),
8772c12535SAneesh Kumar K.V 
8872c12535SAneesh Kumar K.V 	TP_printk("Map: hvpn=%llx pfn=%llx ea=%lx vp=%llx ra=%lx [%x]",
8972c12535SAneesh Kumar K.V 		  __entry->host_vpn, __entry->pfn, __entry->eaddr,
9072c12535SAneesh Kumar K.V 		  __entry->vpage, __entry->raddr, __entry->flags)
9172c12535SAneesh Kumar K.V );
9272c12535SAneesh Kumar K.V 
9372c12535SAneesh Kumar K.V TRACE_EVENT(kvm_book3s_mmu_invalidate,
9472c12535SAneesh Kumar K.V 	TP_PROTO(struct hpte_cache *pte),
9572c12535SAneesh Kumar K.V 	TP_ARGS(pte),
9672c12535SAneesh Kumar K.V 
9772c12535SAneesh Kumar K.V 	TP_STRUCT__entry(
9872c12535SAneesh Kumar K.V 		__field(	u64,		host_vpn	)
9972c12535SAneesh Kumar K.V 		__field(	u64,		pfn		)
10072c12535SAneesh Kumar K.V 		__field(	ulong,		eaddr		)
10172c12535SAneesh Kumar K.V 		__field(	u64,		vpage		)
10272c12535SAneesh Kumar K.V 		__field(	ulong,		raddr		)
10372c12535SAneesh Kumar K.V 		__field(	int,		flags		)
10472c12535SAneesh Kumar K.V 	),
10572c12535SAneesh Kumar K.V 
10672c12535SAneesh Kumar K.V 	TP_fast_assign(
10772c12535SAneesh Kumar K.V 		__entry->host_vpn	= pte->host_vpn;
10872c12535SAneesh Kumar K.V 		__entry->pfn		= pte->pfn;
10972c12535SAneesh Kumar K.V 		__entry->eaddr		= pte->pte.eaddr;
11072c12535SAneesh Kumar K.V 		__entry->vpage		= pte->pte.vpage;
11172c12535SAneesh Kumar K.V 		__entry->raddr		= pte->pte.raddr;
11272c12535SAneesh Kumar K.V 		__entry->flags		= (pte->pte.may_read ? 0x4 : 0) |
11372c12535SAneesh Kumar K.V 					  (pte->pte.may_write ? 0x2 : 0) |
11472c12535SAneesh Kumar K.V 					  (pte->pte.may_execute ? 0x1 : 0);
11572c12535SAneesh Kumar K.V 	),
11672c12535SAneesh Kumar K.V 
11772c12535SAneesh Kumar K.V 	TP_printk("Flush: hva=%llx pfn=%llx ea=%lx vp=%llx ra=%lx [%x]",
11872c12535SAneesh Kumar K.V 		  __entry->host_vpn, __entry->pfn, __entry->eaddr,
11972c12535SAneesh Kumar K.V 		  __entry->vpage, __entry->raddr, __entry->flags)
12072c12535SAneesh Kumar K.V );
12172c12535SAneesh Kumar K.V 
12272c12535SAneesh Kumar K.V TRACE_EVENT(kvm_book3s_mmu_flush,
12372c12535SAneesh Kumar K.V 	TP_PROTO(const char *type, struct kvm_vcpu *vcpu, unsigned long long p1,
12472c12535SAneesh Kumar K.V 		 unsigned long long p2),
12572c12535SAneesh Kumar K.V 	TP_ARGS(type, vcpu, p1, p2),
12672c12535SAneesh Kumar K.V 
12772c12535SAneesh Kumar K.V 	TP_STRUCT__entry(
12872c12535SAneesh Kumar K.V 		__field(	int,			count		)
12972c12535SAneesh Kumar K.V 		__field(	unsigned long long,	p1		)
13072c12535SAneesh Kumar K.V 		__field(	unsigned long long,	p2		)
13172c12535SAneesh Kumar K.V 		__field(	const char *,		type		)
13272c12535SAneesh Kumar K.V 	),
13372c12535SAneesh Kumar K.V 
13472c12535SAneesh Kumar K.V 	TP_fast_assign(
13572c12535SAneesh Kumar K.V 		__entry->count		= to_book3s(vcpu)->hpte_cache_count;
13672c12535SAneesh Kumar K.V 		__entry->p1		= p1;
13772c12535SAneesh Kumar K.V 		__entry->p2		= p2;
13872c12535SAneesh Kumar K.V 		__entry->type		= type;
13972c12535SAneesh Kumar K.V 	),
14072c12535SAneesh Kumar K.V 
14172c12535SAneesh Kumar K.V 	TP_printk("Flush %d %sPTEs: %llx - %llx",
14272c12535SAneesh Kumar K.V 		  __entry->count, __entry->type, __entry->p1, __entry->p2)
14372c12535SAneesh Kumar K.V );
14472c12535SAneesh Kumar K.V 
14572c12535SAneesh Kumar K.V TRACE_EVENT(kvm_book3s_slb_found,
14672c12535SAneesh Kumar K.V 	TP_PROTO(unsigned long long gvsid, unsigned long long hvsid),
14772c12535SAneesh Kumar K.V 	TP_ARGS(gvsid, hvsid),
14872c12535SAneesh Kumar K.V 
14972c12535SAneesh Kumar K.V 	TP_STRUCT__entry(
15072c12535SAneesh Kumar K.V 		__field(	unsigned long long,	gvsid		)
15172c12535SAneesh Kumar K.V 		__field(	unsigned long long,	hvsid		)
15272c12535SAneesh Kumar K.V 	),
15372c12535SAneesh Kumar K.V 
15472c12535SAneesh Kumar K.V 	TP_fast_assign(
15572c12535SAneesh Kumar K.V 		__entry->gvsid		= gvsid;
15672c12535SAneesh Kumar K.V 		__entry->hvsid		= hvsid;
15772c12535SAneesh Kumar K.V 	),
15872c12535SAneesh Kumar K.V 
15972c12535SAneesh Kumar K.V 	TP_printk("%llx -> %llx", __entry->gvsid, __entry->hvsid)
16072c12535SAneesh Kumar K.V );
16172c12535SAneesh Kumar K.V 
16272c12535SAneesh Kumar K.V TRACE_EVENT(kvm_book3s_slb_fail,
16372c12535SAneesh Kumar K.V 	TP_PROTO(u16 sid_map_mask, unsigned long long gvsid),
16472c12535SAneesh Kumar K.V 	TP_ARGS(sid_map_mask, gvsid),
16572c12535SAneesh Kumar K.V 
16672c12535SAneesh Kumar K.V 	TP_STRUCT__entry(
16772c12535SAneesh Kumar K.V 		__field(	unsigned short,		sid_map_mask	)
16872c12535SAneesh Kumar K.V 		__field(	unsigned long long,	gvsid		)
16972c12535SAneesh Kumar K.V 	),
17072c12535SAneesh Kumar K.V 
17172c12535SAneesh Kumar K.V 	TP_fast_assign(
17272c12535SAneesh Kumar K.V 		__entry->sid_map_mask	= sid_map_mask;
17372c12535SAneesh Kumar K.V 		__entry->gvsid		= gvsid;
17472c12535SAneesh Kumar K.V 	),
17572c12535SAneesh Kumar K.V 
17672c12535SAneesh Kumar K.V 	TP_printk("%x/%x: %llx", __entry->sid_map_mask,
17772c12535SAneesh Kumar K.V 		  SID_MAP_MASK - __entry->sid_map_mask, __entry->gvsid)
17872c12535SAneesh Kumar K.V );
17972c12535SAneesh Kumar K.V 
18072c12535SAneesh Kumar K.V TRACE_EVENT(kvm_book3s_slb_map,
18172c12535SAneesh Kumar K.V 	TP_PROTO(u16 sid_map_mask, unsigned long long gvsid,
18272c12535SAneesh Kumar K.V 		 unsigned long long hvsid),
18372c12535SAneesh Kumar K.V 	TP_ARGS(sid_map_mask, gvsid, hvsid),
18472c12535SAneesh Kumar K.V 
18572c12535SAneesh Kumar K.V 	TP_STRUCT__entry(
18672c12535SAneesh Kumar K.V 		__field(	unsigned short,		sid_map_mask	)
18772c12535SAneesh Kumar K.V 		__field(	unsigned long long,	guest_vsid	)
18872c12535SAneesh Kumar K.V 		__field(	unsigned long long,	host_vsid	)
18972c12535SAneesh Kumar K.V 	),
19072c12535SAneesh Kumar K.V 
19172c12535SAneesh Kumar K.V 	TP_fast_assign(
19272c12535SAneesh Kumar K.V 		__entry->sid_map_mask	= sid_map_mask;
19372c12535SAneesh Kumar K.V 		__entry->guest_vsid	= gvsid;
19472c12535SAneesh Kumar K.V 		__entry->host_vsid	= hvsid;
19572c12535SAneesh Kumar K.V 	),
19672c12535SAneesh Kumar K.V 
19772c12535SAneesh Kumar K.V 	TP_printk("%x: %llx -> %llx", __entry->sid_map_mask,
19872c12535SAneesh Kumar K.V 		  __entry->guest_vsid, __entry->host_vsid)
19972c12535SAneesh Kumar K.V );
20072c12535SAneesh Kumar K.V 
20172c12535SAneesh Kumar K.V TRACE_EVENT(kvm_book3s_slbmte,
20272c12535SAneesh Kumar K.V 	TP_PROTO(u64 slb_vsid, u64 slb_esid),
20372c12535SAneesh Kumar K.V 	TP_ARGS(slb_vsid, slb_esid),
20472c12535SAneesh Kumar K.V 
20572c12535SAneesh Kumar K.V 	TP_STRUCT__entry(
20672c12535SAneesh Kumar K.V 		__field(	u64,	slb_vsid	)
20772c12535SAneesh Kumar K.V 		__field(	u64,	slb_esid	)
20872c12535SAneesh Kumar K.V 	),
20972c12535SAneesh Kumar K.V 
21072c12535SAneesh Kumar K.V 	TP_fast_assign(
21172c12535SAneesh Kumar K.V 		__entry->slb_vsid	= slb_vsid;
21272c12535SAneesh Kumar K.V 		__entry->slb_esid	= slb_esid;
21372c12535SAneesh Kumar K.V 	),
21472c12535SAneesh Kumar K.V 
21572c12535SAneesh Kumar K.V 	TP_printk("%llx, %llx", __entry->slb_vsid, __entry->slb_esid)
21672c12535SAneesh Kumar K.V );
21772c12535SAneesh Kumar K.V 
21872c12535SAneesh Kumar K.V TRACE_EVENT(kvm_exit,
21972c12535SAneesh Kumar K.V 	TP_PROTO(unsigned int exit_nr, struct kvm_vcpu *vcpu),
22072c12535SAneesh Kumar K.V 	TP_ARGS(exit_nr, vcpu),
22172c12535SAneesh Kumar K.V 
22272c12535SAneesh Kumar K.V 	TP_STRUCT__entry(
22372c12535SAneesh Kumar K.V 		__field(	unsigned int,	exit_nr		)
22472c12535SAneesh Kumar K.V 		__field(	unsigned long,	pc		)
22572c12535SAneesh Kumar K.V 		__field(	unsigned long,	msr		)
22672c12535SAneesh Kumar K.V 		__field(	unsigned long,	dar		)
22772c12535SAneesh Kumar K.V 		__field(	unsigned long,	srr1		)
22872c12535SAneesh Kumar K.V 		__field(	unsigned long,	last_inst	)
22972c12535SAneesh Kumar K.V 	),
23072c12535SAneesh Kumar K.V 
23172c12535SAneesh Kumar K.V 	TP_fast_assign(
23272c12535SAneesh Kumar K.V 		__entry->exit_nr	= exit_nr;
23372c12535SAneesh Kumar K.V 		__entry->pc		= kvmppc_get_pc(vcpu);
23472c12535SAneesh Kumar K.V 		__entry->dar		= kvmppc_get_fault_dar(vcpu);
2355deb8e7aSAlexander Graf 		__entry->msr		= kvmppc_get_msr(vcpu);
23672c12535SAneesh Kumar K.V 		__entry->srr1		= vcpu->arch.shadow_srr1;
23772c12535SAneesh Kumar K.V 		__entry->last_inst	= vcpu->arch.last_inst;
23872c12535SAneesh Kumar K.V 	),
23972c12535SAneesh Kumar K.V 
24072c12535SAneesh Kumar K.V 	TP_printk("exit=%s"
24172c12535SAneesh Kumar K.V 		" | pc=0x%lx"
24272c12535SAneesh Kumar K.V 		" | msr=0x%lx"
24372c12535SAneesh Kumar K.V 		" | dar=0x%lx"
24472c12535SAneesh Kumar K.V 		" | srr1=0x%lx"
24572c12535SAneesh Kumar K.V 		" | last_inst=0x%lx"
24672c12535SAneesh Kumar K.V 		,
24772c12535SAneesh Kumar K.V 		__print_symbolic(__entry->exit_nr, kvm_trace_symbol_exit),
24872c12535SAneesh Kumar K.V 		__entry->pc,
24972c12535SAneesh Kumar K.V 		__entry->msr,
25072c12535SAneesh Kumar K.V 		__entry->dar,
25172c12535SAneesh Kumar K.V 		__entry->srr1,
25272c12535SAneesh Kumar K.V 		__entry->last_inst
25372c12535SAneesh Kumar K.V 		)
25472c12535SAneesh Kumar K.V );
25572c12535SAneesh Kumar K.V 
25672c12535SAneesh Kumar K.V TRACE_EVENT(kvm_unmap_hva,
25772c12535SAneesh Kumar K.V 	TP_PROTO(unsigned long hva),
25872c12535SAneesh Kumar K.V 	TP_ARGS(hva),
25972c12535SAneesh Kumar K.V 
26072c12535SAneesh Kumar K.V 	TP_STRUCT__entry(
26172c12535SAneesh Kumar K.V 		__field(	unsigned long,	hva		)
26272c12535SAneesh Kumar K.V 	),
26372c12535SAneesh Kumar K.V 
26472c12535SAneesh Kumar K.V 	TP_fast_assign(
26572c12535SAneesh Kumar K.V 		__entry->hva		= hva;
26672c12535SAneesh Kumar K.V 	),
26772c12535SAneesh Kumar K.V 
26872c12535SAneesh Kumar K.V 	TP_printk("unmap hva 0x%lx\n", __entry->hva)
26972c12535SAneesh Kumar K.V );
27072c12535SAneesh Kumar K.V 
27172c12535SAneesh Kumar K.V #endif /* _TRACE_KVM_H */
27272c12535SAneesh Kumar K.V 
27372c12535SAneesh Kumar K.V /* This part must be outside protection */
27472c12535SAneesh Kumar K.V #include <trace/define_trace.h>
275