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