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