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