xref: /linux/arch/mips/kvm/trace.h (revision 28c1e762b01eee56ada8148c88c4f1e99beb5584)
1669e846eSSanjay Lal /*
2669e846eSSanjay Lal  * This file is subject to the terms and conditions of the GNU General Public
3669e846eSSanjay Lal  * License.  See the file "COPYING" in the main directory of this archive
4669e846eSSanjay Lal  * for more details.
5669e846eSSanjay Lal  *
6669e846eSSanjay Lal  * Copyright (C) 2012  MIPS Technologies, Inc.  All rights reserved.
7669e846eSSanjay Lal  * Authors: Sanjay Lal <sanjayl@kymasys.com>
8669e846eSSanjay Lal  */
9669e846eSSanjay Lal 
10669e846eSSanjay Lal #if !defined(_TRACE_KVM_H) || defined(TRACE_HEADER_MULTI_READ)
11669e846eSSanjay Lal #define _TRACE_KVM_H
12669e846eSSanjay Lal 
13669e846eSSanjay Lal #include <linux/tracepoint.h>
14669e846eSSanjay Lal 
15669e846eSSanjay Lal #undef TRACE_SYSTEM
16669e846eSSanjay Lal #define TRACE_SYSTEM kvm
17669e846eSSanjay Lal #define TRACE_INCLUDE_PATH .
18669e846eSSanjay Lal #define TRACE_INCLUDE_FILE trace
19669e846eSSanjay Lal 
2093258604SJames Hogan /*
2193258604SJames Hogan  * Tracepoints for VM enters
2293258604SJames Hogan  */
23fb6cec14SJames Hogan DECLARE_EVENT_CLASS(kvm_transition,
2493258604SJames Hogan 	TP_PROTO(struct kvm_vcpu *vcpu),
2593258604SJames Hogan 	TP_ARGS(vcpu),
2693258604SJames Hogan 	TP_STRUCT__entry(
2793258604SJames Hogan 		__field(unsigned long, pc)
2893258604SJames Hogan 	),
2993258604SJames Hogan 
3093258604SJames Hogan 	TP_fast_assign(
3193258604SJames Hogan 		__entry->pc = vcpu->arch.pc;
3293258604SJames Hogan 	),
3393258604SJames Hogan 
3493258604SJames Hogan 	TP_printk("PC: 0x%08lx",
3593258604SJames Hogan 		  __entry->pc)
3693258604SJames Hogan );
3793258604SJames Hogan 
38fb6cec14SJames Hogan DEFINE_EVENT(kvm_transition, kvm_enter,
3993258604SJames Hogan 	     TP_PROTO(struct kvm_vcpu *vcpu),
40fb6cec14SJames Hogan 	     TP_ARGS(vcpu));
4193258604SJames Hogan 
42fb6cec14SJames Hogan DEFINE_EVENT(kvm_transition, kvm_reenter,
4393258604SJames Hogan 	     TP_PROTO(struct kvm_vcpu *vcpu),
44fb6cec14SJames Hogan 	     TP_ARGS(vcpu));
4593258604SJames Hogan 
46fb6cec14SJames Hogan DEFINE_EVENT(kvm_transition, kvm_out,
47fb6cec14SJames Hogan 	     TP_PROTO(struct kvm_vcpu *vcpu),
48fb6cec14SJames Hogan 	     TP_ARGS(vcpu));
4993258604SJames Hogan 
501e09e86aSJames Hogan /* The first 32 exit reasons correspond to Cause.ExcCode */
511e09e86aSJames Hogan #define KVM_TRACE_EXIT_INT		 0
521e09e86aSJames Hogan #define KVM_TRACE_EXIT_TLBMOD		 1
531e09e86aSJames Hogan #define KVM_TRACE_EXIT_TLBMISS_LD	 2
541e09e86aSJames Hogan #define KVM_TRACE_EXIT_TLBMISS_ST	 3
551e09e86aSJames Hogan #define KVM_TRACE_EXIT_ADDRERR_LD	 4
561e09e86aSJames Hogan #define KVM_TRACE_EXIT_ADDRERR_ST	 5
571e09e86aSJames Hogan #define KVM_TRACE_EXIT_SYSCALL		 8
581e09e86aSJames Hogan #define KVM_TRACE_EXIT_BREAK_INST	 9
591e09e86aSJames Hogan #define KVM_TRACE_EXIT_RESVD_INST	10
601e09e86aSJames Hogan #define KVM_TRACE_EXIT_COP_UNUSABLE	11
611e09e86aSJames Hogan #define KVM_TRACE_EXIT_TRAP_INST	13
621e09e86aSJames Hogan #define KVM_TRACE_EXIT_MSA_FPE		14
631e09e86aSJames Hogan #define KVM_TRACE_EXIT_FPE		15
641e09e86aSJames Hogan #define KVM_TRACE_EXIT_MSA_DISABLED	21
65*28c1e762SJames Hogan #define KVM_TRACE_EXIT_GUEST_EXIT	27
661e09e86aSJames Hogan /* Further exit reasons */
671e09e86aSJames Hogan #define KVM_TRACE_EXIT_WAIT		32
681e09e86aSJames Hogan #define KVM_TRACE_EXIT_CACHE		33
691e09e86aSJames Hogan #define KVM_TRACE_EXIT_SIGNAL		34
70a7244920SJames Hogan /* 32 exit reasons correspond to GuestCtl0.GExcCode (VZ) */
71a7244920SJames Hogan #define KVM_TRACE_EXIT_GEXCCODE_BASE	64
72a7244920SJames Hogan #define KVM_TRACE_EXIT_GPSI		64	/*  0 */
73a7244920SJames Hogan #define KVM_TRACE_EXIT_GSFC		65	/*  1 */
74a7244920SJames Hogan #define KVM_TRACE_EXIT_HC		66	/*  2 */
75a7244920SJames Hogan #define KVM_TRACE_EXIT_GRR		67	/*  3 */
76a7244920SJames Hogan #define KVM_TRACE_EXIT_GVA		72	/*  8 */
77a7244920SJames Hogan #define KVM_TRACE_EXIT_GHFC		73	/*  9 */
78a7244920SJames Hogan #define KVM_TRACE_EXIT_GPA		74	/* 10 */
791e09e86aSJames Hogan 
801e09e86aSJames Hogan /* Tracepoints for VM exits */
811e09e86aSJames Hogan #define kvm_trace_symbol_exit_types				\
821e09e86aSJames Hogan 	{ KVM_TRACE_EXIT_INT,		"Interrupt" },		\
831e09e86aSJames Hogan 	{ KVM_TRACE_EXIT_TLBMOD,	"TLB Mod" },		\
841e09e86aSJames Hogan 	{ KVM_TRACE_EXIT_TLBMISS_LD,	"TLB Miss (LD)" },	\
851e09e86aSJames Hogan 	{ KVM_TRACE_EXIT_TLBMISS_ST,	"TLB Miss (ST)" },	\
861e09e86aSJames Hogan 	{ KVM_TRACE_EXIT_ADDRERR_LD,	"Address Error (LD)" },	\
871e09e86aSJames Hogan 	{ KVM_TRACE_EXIT_ADDRERR_ST,	"Address Err (ST)" },	\
881e09e86aSJames Hogan 	{ KVM_TRACE_EXIT_SYSCALL,	"System Call" },	\
891e09e86aSJames Hogan 	{ KVM_TRACE_EXIT_BREAK_INST,	"Break Inst" },		\
901e09e86aSJames Hogan 	{ KVM_TRACE_EXIT_RESVD_INST,	"Reserved Inst" },	\
911e09e86aSJames Hogan 	{ KVM_TRACE_EXIT_COP_UNUSABLE,	"COP0/1 Unusable" },	\
921e09e86aSJames Hogan 	{ KVM_TRACE_EXIT_TRAP_INST,	"Trap Inst" },		\
931e09e86aSJames Hogan 	{ KVM_TRACE_EXIT_MSA_FPE,	"MSA FPE" },		\
941e09e86aSJames Hogan 	{ KVM_TRACE_EXIT_FPE,		"FPE" },		\
951e09e86aSJames Hogan 	{ KVM_TRACE_EXIT_MSA_DISABLED,	"MSA Disabled" },	\
96*28c1e762SJames Hogan 	{ KVM_TRACE_EXIT_GUEST_EXIT,	"Guest Exit" },		\
971e09e86aSJames Hogan 	{ KVM_TRACE_EXIT_WAIT,		"WAIT" },		\
981e09e86aSJames Hogan 	{ KVM_TRACE_EXIT_CACHE,		"CACHE" },		\
99a7244920SJames Hogan 	{ KVM_TRACE_EXIT_SIGNAL,	"Signal" },		\
100a7244920SJames Hogan 	{ KVM_TRACE_EXIT_GPSI,		"GPSI" },		\
101a7244920SJames Hogan 	{ KVM_TRACE_EXIT_GSFC,		"GSFC" },		\
102a7244920SJames Hogan 	{ KVM_TRACE_EXIT_HC,		"HC" },			\
103a7244920SJames Hogan 	{ KVM_TRACE_EXIT_GRR,		"GRR" },		\
104a7244920SJames Hogan 	{ KVM_TRACE_EXIT_GVA,		"GVA" },		\
105a7244920SJames Hogan 	{ KVM_TRACE_EXIT_GHFC,		"GHFC" },		\
106a7244920SJames Hogan 	{ KVM_TRACE_EXIT_GPA,		"GPA" }
107669e846eSSanjay Lal 
108669e846eSSanjay Lal TRACE_EVENT(kvm_exit,
109669e846eSSanjay Lal 	    TP_PROTO(struct kvm_vcpu *vcpu, unsigned int reason),
110669e846eSSanjay Lal 	    TP_ARGS(vcpu, reason),
111669e846eSSanjay Lal 	    TP_STRUCT__entry(
112b3cffac0SJames Hogan 			__field(unsigned long, pc)
113669e846eSSanjay Lal 			__field(unsigned int, reason)
114669e846eSSanjay Lal 	    ),
115669e846eSSanjay Lal 
116669e846eSSanjay Lal 	    TP_fast_assign(
117b3cffac0SJames Hogan 			__entry->pc = vcpu->arch.pc;
118669e846eSSanjay Lal 			__entry->reason = reason;
119669e846eSSanjay Lal 	    ),
120669e846eSSanjay Lal 
121669e846eSSanjay Lal 	    TP_printk("[%s]PC: 0x%08lx",
1221e09e86aSJames Hogan 		      __print_symbolic(__entry->reason,
1231e09e86aSJames Hogan 				       kvm_trace_symbol_exit_types),
124b3cffac0SJames Hogan 		      __entry->pc)
125669e846eSSanjay Lal );
126669e846eSSanjay Lal 
1276398da13SJames Hogan #define KVM_TRACE_MFC0		0
1286398da13SJames Hogan #define KVM_TRACE_MTC0		1
1296398da13SJames Hogan #define KVM_TRACE_DMFC0		2
1306398da13SJames Hogan #define KVM_TRACE_DMTC0		3
1316398da13SJames Hogan #define KVM_TRACE_RDHWR		4
1326398da13SJames Hogan 
1336398da13SJames Hogan #define KVM_TRACE_HWR_COP0	0
1346398da13SJames Hogan #define KVM_TRACE_HWR_HWR	1
1356398da13SJames Hogan 
1366398da13SJames Hogan #define KVM_TRACE_COP0(REG, SEL)	((KVM_TRACE_HWR_COP0 << 8) |	\
1376398da13SJames Hogan 					 ((REG) << 3) | (SEL))
1386398da13SJames Hogan #define KVM_TRACE_HWR(REG, SEL)		((KVM_TRACE_HWR_HWR  << 8) |	\
1396398da13SJames Hogan 					 ((REG) << 3) | (SEL))
1406398da13SJames Hogan 
1416398da13SJames Hogan #define kvm_trace_symbol_hwr_ops				\
1426398da13SJames Hogan 	{ KVM_TRACE_MFC0,		"MFC0" },		\
1436398da13SJames Hogan 	{ KVM_TRACE_MTC0,		"MTC0" },		\
1446398da13SJames Hogan 	{ KVM_TRACE_DMFC0,		"DMFC0" },		\
1456398da13SJames Hogan 	{ KVM_TRACE_DMTC0,		"DMTC0" },		\
1466398da13SJames Hogan 	{ KVM_TRACE_RDHWR,		"RDHWR" }
1476398da13SJames Hogan 
1486398da13SJames Hogan #define kvm_trace_symbol_hwr_cop				\
1496398da13SJames Hogan 	{ KVM_TRACE_HWR_COP0,		"COP0" },		\
1506398da13SJames Hogan 	{ KVM_TRACE_HWR_HWR,		"HWR" }
1516398da13SJames Hogan 
1526398da13SJames Hogan #define kvm_trace_symbol_hwr_regs				\
1536398da13SJames Hogan 	{ KVM_TRACE_COP0( 0, 0),	"Index" },		\
1546398da13SJames Hogan 	{ KVM_TRACE_COP0( 2, 0),	"EntryLo0" },		\
1556398da13SJames Hogan 	{ KVM_TRACE_COP0( 3, 0),	"EntryLo1" },		\
1566398da13SJames Hogan 	{ KVM_TRACE_COP0( 4, 0),	"Context" },		\
1576398da13SJames Hogan 	{ KVM_TRACE_COP0( 4, 2),	"UserLocal" },		\
1586398da13SJames Hogan 	{ KVM_TRACE_COP0( 5, 0),	"PageMask" },		\
1596398da13SJames Hogan 	{ KVM_TRACE_COP0( 6, 0),	"Wired" },		\
1606398da13SJames Hogan 	{ KVM_TRACE_COP0( 7, 0),	"HWREna" },		\
1616398da13SJames Hogan 	{ KVM_TRACE_COP0( 8, 0),	"BadVAddr" },		\
1626398da13SJames Hogan 	{ KVM_TRACE_COP0( 9, 0),	"Count" },		\
1636398da13SJames Hogan 	{ KVM_TRACE_COP0(10, 0),	"EntryHi" },		\
1646398da13SJames Hogan 	{ KVM_TRACE_COP0(11, 0),	"Compare" },		\
1656398da13SJames Hogan 	{ KVM_TRACE_COP0(12, 0),	"Status" },		\
1666398da13SJames Hogan 	{ KVM_TRACE_COP0(12, 1),	"IntCtl" },		\
1676398da13SJames Hogan 	{ KVM_TRACE_COP0(12, 2),	"SRSCtl" },		\
1686398da13SJames Hogan 	{ KVM_TRACE_COP0(13, 0),	"Cause" },		\
1696398da13SJames Hogan 	{ KVM_TRACE_COP0(14, 0),	"EPC" },		\
1706398da13SJames Hogan 	{ KVM_TRACE_COP0(15, 0),	"PRId" },		\
1716398da13SJames Hogan 	{ KVM_TRACE_COP0(15, 1),	"EBase" },		\
1726398da13SJames Hogan 	{ KVM_TRACE_COP0(16, 0),	"Config" },		\
1736398da13SJames Hogan 	{ KVM_TRACE_COP0(16, 1),	"Config1" },		\
1746398da13SJames Hogan 	{ KVM_TRACE_COP0(16, 2),	"Config2" },		\
1756398da13SJames Hogan 	{ KVM_TRACE_COP0(16, 3),	"Config3" },		\
1766398da13SJames Hogan 	{ KVM_TRACE_COP0(16, 4),	"Config4" },		\
1776398da13SJames Hogan 	{ KVM_TRACE_COP0(16, 5),	"Config5" },		\
1786398da13SJames Hogan 	{ KVM_TRACE_COP0(16, 7),	"Config7" },		\
1796398da13SJames Hogan 	{ KVM_TRACE_COP0(26, 0),	"ECC" },		\
1806398da13SJames Hogan 	{ KVM_TRACE_COP0(30, 0),	"ErrorEPC" },		\
18105108709SJames Hogan 	{ KVM_TRACE_COP0(31, 2),	"KScratch1" },		\
18205108709SJames Hogan 	{ KVM_TRACE_COP0(31, 3),	"KScratch2" },		\
18305108709SJames Hogan 	{ KVM_TRACE_COP0(31, 4),	"KScratch3" },		\
18405108709SJames Hogan 	{ KVM_TRACE_COP0(31, 5),	"KScratch4" },		\
18505108709SJames Hogan 	{ KVM_TRACE_COP0(31, 6),	"KScratch5" },		\
18605108709SJames Hogan 	{ KVM_TRACE_COP0(31, 7),	"KScratch6" },		\
1876398da13SJames Hogan 	{ KVM_TRACE_HWR( 0, 0),		"CPUNum" },		\
1886398da13SJames Hogan 	{ KVM_TRACE_HWR( 1, 0),		"SYNCI_Step" },		\
1896398da13SJames Hogan 	{ KVM_TRACE_HWR( 2, 0),		"CC" },			\
1906398da13SJames Hogan 	{ KVM_TRACE_HWR( 3, 0),		"CCRes" },		\
1916398da13SJames Hogan 	{ KVM_TRACE_HWR(29, 0),		"ULR" }
1926398da13SJames Hogan 
1936398da13SJames Hogan TRACE_EVENT(kvm_hwr,
1946398da13SJames Hogan 	    TP_PROTO(struct kvm_vcpu *vcpu, unsigned int op, unsigned int reg,
1956398da13SJames Hogan 		     unsigned long val),
1966398da13SJames Hogan 	    TP_ARGS(vcpu, op, reg, val),
1976398da13SJames Hogan 	    TP_STRUCT__entry(
1986398da13SJames Hogan 			__field(unsigned long, val)
1996398da13SJames Hogan 			__field(u16, reg)
2006398da13SJames Hogan 			__field(u8, op)
2016398da13SJames Hogan 	    ),
2026398da13SJames Hogan 
2036398da13SJames Hogan 	    TP_fast_assign(
2046398da13SJames Hogan 			__entry->val = val;
2056398da13SJames Hogan 			__entry->reg = reg;
2066398da13SJames Hogan 			__entry->op = op;
2076398da13SJames Hogan 	    ),
2086398da13SJames Hogan 
2096398da13SJames Hogan 	    TP_printk("%s %s (%s:%u:%u) 0x%08lx",
2106398da13SJames Hogan 		      __print_symbolic(__entry->op,
2116398da13SJames Hogan 				       kvm_trace_symbol_hwr_ops),
2126398da13SJames Hogan 		      __print_symbolic(__entry->reg,
2136398da13SJames Hogan 				       kvm_trace_symbol_hwr_regs),
2146398da13SJames Hogan 		      __print_symbolic(__entry->reg >> 8,
2156398da13SJames Hogan 				       kvm_trace_symbol_hwr_cop),
2166398da13SJames Hogan 		      (__entry->reg >> 3) & 0x1f,
2176398da13SJames Hogan 		      __entry->reg & 0x7,
2186398da13SJames Hogan 		      __entry->val)
2196398da13SJames Hogan );
2206398da13SJames Hogan 
22104ebebf4SJames Hogan #define KVM_TRACE_AUX_RESTORE		0
22204ebebf4SJames Hogan #define KVM_TRACE_AUX_SAVE		1
22304ebebf4SJames Hogan #define KVM_TRACE_AUX_ENABLE		2
22404ebebf4SJames Hogan #define KVM_TRACE_AUX_DISABLE		3
22504ebebf4SJames Hogan #define KVM_TRACE_AUX_DISCARD		4
22604ebebf4SJames Hogan 
22704ebebf4SJames Hogan #define KVM_TRACE_AUX_FPU		1
22804ebebf4SJames Hogan #define KVM_TRACE_AUX_MSA		2
22904ebebf4SJames Hogan #define KVM_TRACE_AUX_FPU_MSA		3
23004ebebf4SJames Hogan 
23104ebebf4SJames Hogan #define kvm_trace_symbol_aux_op		\
23204ebebf4SJames Hogan 	{ KVM_TRACE_AUX_RESTORE, "restore" },	\
23304ebebf4SJames Hogan 	{ KVM_TRACE_AUX_SAVE,    "save" },	\
23404ebebf4SJames Hogan 	{ KVM_TRACE_AUX_ENABLE,  "enable" },	\
23504ebebf4SJames Hogan 	{ KVM_TRACE_AUX_DISABLE, "disable" },	\
23604ebebf4SJames Hogan 	{ KVM_TRACE_AUX_DISCARD, "discard" }
23704ebebf4SJames Hogan 
23804ebebf4SJames Hogan #define kvm_trace_symbol_aux_state		\
23904ebebf4SJames Hogan 	{ KVM_TRACE_AUX_FPU,     "FPU" },	\
24004ebebf4SJames Hogan 	{ KVM_TRACE_AUX_MSA,     "MSA" },	\
24104ebebf4SJames Hogan 	{ KVM_TRACE_AUX_FPU_MSA, "FPU & MSA" }
24204ebebf4SJames Hogan 
24304ebebf4SJames Hogan TRACE_EVENT(kvm_aux,
24404ebebf4SJames Hogan 	    TP_PROTO(struct kvm_vcpu *vcpu, unsigned int op,
24504ebebf4SJames Hogan 		     unsigned int state),
24604ebebf4SJames Hogan 	    TP_ARGS(vcpu, op, state),
24704ebebf4SJames Hogan 	    TP_STRUCT__entry(
24804ebebf4SJames Hogan 			__field(unsigned long, pc)
24904ebebf4SJames Hogan 			__field(u8, op)
25004ebebf4SJames Hogan 			__field(u8, state)
25104ebebf4SJames Hogan 	    ),
25204ebebf4SJames Hogan 
25304ebebf4SJames Hogan 	    TP_fast_assign(
25404ebebf4SJames Hogan 			__entry->pc = vcpu->arch.pc;
25504ebebf4SJames Hogan 			__entry->op = op;
25604ebebf4SJames Hogan 			__entry->state = state;
25704ebebf4SJames Hogan 	    ),
25804ebebf4SJames Hogan 
25904ebebf4SJames Hogan 	    TP_printk("%s %s PC: 0x%08lx",
26004ebebf4SJames Hogan 		      __print_symbolic(__entry->op,
26104ebebf4SJames Hogan 				       kvm_trace_symbol_aux_op),
26204ebebf4SJames Hogan 		      __print_symbolic(__entry->state,
26304ebebf4SJames Hogan 				       kvm_trace_symbol_aux_state),
26404ebebf4SJames Hogan 		      __entry->pc)
26504ebebf4SJames Hogan );
26604ebebf4SJames Hogan 
2679887d1c7SJames Hogan TRACE_EVENT(kvm_asid_change,
2689887d1c7SJames Hogan 	    TP_PROTO(struct kvm_vcpu *vcpu, unsigned int old_asid,
2699887d1c7SJames Hogan 		     unsigned int new_asid),
2709887d1c7SJames Hogan 	    TP_ARGS(vcpu, old_asid, new_asid),
2719887d1c7SJames Hogan 	    TP_STRUCT__entry(
2729887d1c7SJames Hogan 			__field(unsigned long, pc)
2739887d1c7SJames Hogan 			__field(u8, old_asid)
2749887d1c7SJames Hogan 			__field(u8, new_asid)
2759887d1c7SJames Hogan 	    ),
2769887d1c7SJames Hogan 
2779887d1c7SJames Hogan 	    TP_fast_assign(
2789887d1c7SJames Hogan 			__entry->pc = vcpu->arch.pc;
2799887d1c7SJames Hogan 			__entry->old_asid = old_asid;
2809887d1c7SJames Hogan 			__entry->new_asid = new_asid;
2819887d1c7SJames Hogan 	    ),
2829887d1c7SJames Hogan 
2839887d1c7SJames Hogan 	    TP_printk("PC: 0x%08lx old: 0x%02x new: 0x%02x",
2849887d1c7SJames Hogan 		      __entry->pc,
2859887d1c7SJames Hogan 		      __entry->old_asid,
2869887d1c7SJames Hogan 		      __entry->new_asid)
2879887d1c7SJames Hogan );
2889887d1c7SJames Hogan 
289669e846eSSanjay Lal #endif /* _TRACE_KVM_H */
290669e846eSSanjay Lal 
291669e846eSSanjay Lal /* This part must be outside protection */
292669e846eSSanjay Lal #include <trace/define_trace.h>
293