xref: /linux/arch/mips/kvm/trace.h (revision 93258604ab6d3f2bdc6cb02f61961af56712f144)
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 
20*93258604SJames Hogan /*
21*93258604SJames Hogan  * Tracepoints for VM enters
22*93258604SJames Hogan  */
23*93258604SJames Hogan TRACE_EVENT(kvm_enter,
24*93258604SJames Hogan 	    TP_PROTO(struct kvm_vcpu *vcpu),
25*93258604SJames Hogan 	    TP_ARGS(vcpu),
26*93258604SJames Hogan 	    TP_STRUCT__entry(
27*93258604SJames Hogan 			__field(unsigned long, pc)
28*93258604SJames Hogan 	    ),
29*93258604SJames Hogan 
30*93258604SJames Hogan 	    TP_fast_assign(
31*93258604SJames Hogan 			__entry->pc = vcpu->arch.pc;
32*93258604SJames Hogan 	    ),
33*93258604SJames Hogan 
34*93258604SJames Hogan 	    TP_printk("PC: 0x%08lx",
35*93258604SJames Hogan 		      __entry->pc)
36*93258604SJames Hogan );
37*93258604SJames Hogan 
38*93258604SJames Hogan TRACE_EVENT(kvm_reenter,
39*93258604SJames Hogan 	    TP_PROTO(struct kvm_vcpu *vcpu),
40*93258604SJames Hogan 	    TP_ARGS(vcpu),
41*93258604SJames Hogan 	    TP_STRUCT__entry(
42*93258604SJames Hogan 			__field(unsigned long, pc)
43*93258604SJames Hogan 	    ),
44*93258604SJames Hogan 
45*93258604SJames Hogan 	    TP_fast_assign(
46*93258604SJames Hogan 			__entry->pc = vcpu->arch.pc;
47*93258604SJames Hogan 	    ),
48*93258604SJames Hogan 
49*93258604SJames Hogan 	    TP_printk("PC: 0x%08lx",
50*93258604SJames Hogan 		      __entry->pc)
51*93258604SJames Hogan );
52*93258604SJames Hogan 
53*93258604SJames Hogan TRACE_EVENT(kvm_out,
54*93258604SJames Hogan 	    TP_PROTO(struct kvm_vcpu *vcpu),
55*93258604SJames Hogan 	    TP_ARGS(vcpu),
56*93258604SJames Hogan 	    TP_STRUCT__entry(
57*93258604SJames Hogan 			__field(unsigned long, pc)
58*93258604SJames Hogan 	    ),
59*93258604SJames Hogan 
60*93258604SJames Hogan 	    TP_fast_assign(
61*93258604SJames Hogan 			__entry->pc = vcpu->arch.pc;
62*93258604SJames Hogan 	    ),
63*93258604SJames Hogan 
64*93258604SJames Hogan 	    TP_printk("PC: 0x%08lx",
65*93258604SJames Hogan 		      __entry->pc)
66*93258604SJames Hogan );
67*93258604SJames Hogan 
681e09e86aSJames Hogan /* The first 32 exit reasons correspond to Cause.ExcCode */
691e09e86aSJames Hogan #define KVM_TRACE_EXIT_INT		 0
701e09e86aSJames Hogan #define KVM_TRACE_EXIT_TLBMOD		 1
711e09e86aSJames Hogan #define KVM_TRACE_EXIT_TLBMISS_LD	 2
721e09e86aSJames Hogan #define KVM_TRACE_EXIT_TLBMISS_ST	 3
731e09e86aSJames Hogan #define KVM_TRACE_EXIT_ADDRERR_LD	 4
741e09e86aSJames Hogan #define KVM_TRACE_EXIT_ADDRERR_ST	 5
751e09e86aSJames Hogan #define KVM_TRACE_EXIT_SYSCALL		 8
761e09e86aSJames Hogan #define KVM_TRACE_EXIT_BREAK_INST	 9
771e09e86aSJames Hogan #define KVM_TRACE_EXIT_RESVD_INST	10
781e09e86aSJames Hogan #define KVM_TRACE_EXIT_COP_UNUSABLE	11
791e09e86aSJames Hogan #define KVM_TRACE_EXIT_TRAP_INST	13
801e09e86aSJames Hogan #define KVM_TRACE_EXIT_MSA_FPE		14
811e09e86aSJames Hogan #define KVM_TRACE_EXIT_FPE		15
821e09e86aSJames Hogan #define KVM_TRACE_EXIT_MSA_DISABLED	21
831e09e86aSJames Hogan /* Further exit reasons */
841e09e86aSJames Hogan #define KVM_TRACE_EXIT_WAIT		32
851e09e86aSJames Hogan #define KVM_TRACE_EXIT_CACHE		33
861e09e86aSJames Hogan #define KVM_TRACE_EXIT_SIGNAL		34
871e09e86aSJames Hogan 
881e09e86aSJames Hogan /* Tracepoints for VM exits */
891e09e86aSJames Hogan #define kvm_trace_symbol_exit_types				\
901e09e86aSJames Hogan 	{ KVM_TRACE_EXIT_INT,		"Interrupt" },		\
911e09e86aSJames Hogan 	{ KVM_TRACE_EXIT_TLBMOD,	"TLB Mod" },		\
921e09e86aSJames Hogan 	{ KVM_TRACE_EXIT_TLBMISS_LD,	"TLB Miss (LD)" },	\
931e09e86aSJames Hogan 	{ KVM_TRACE_EXIT_TLBMISS_ST,	"TLB Miss (ST)" },	\
941e09e86aSJames Hogan 	{ KVM_TRACE_EXIT_ADDRERR_LD,	"Address Error (LD)" },	\
951e09e86aSJames Hogan 	{ KVM_TRACE_EXIT_ADDRERR_ST,	"Address Err (ST)" },	\
961e09e86aSJames Hogan 	{ KVM_TRACE_EXIT_SYSCALL,	"System Call" },	\
971e09e86aSJames Hogan 	{ KVM_TRACE_EXIT_BREAK_INST,	"Break Inst" },		\
981e09e86aSJames Hogan 	{ KVM_TRACE_EXIT_RESVD_INST,	"Reserved Inst" },	\
991e09e86aSJames Hogan 	{ KVM_TRACE_EXIT_COP_UNUSABLE,	"COP0/1 Unusable" },	\
1001e09e86aSJames Hogan 	{ KVM_TRACE_EXIT_TRAP_INST,	"Trap Inst" },		\
1011e09e86aSJames Hogan 	{ KVM_TRACE_EXIT_MSA_FPE,	"MSA FPE" },		\
1021e09e86aSJames Hogan 	{ KVM_TRACE_EXIT_FPE,		"FPE" },		\
1031e09e86aSJames Hogan 	{ KVM_TRACE_EXIT_MSA_DISABLED,	"MSA Disabled" },	\
1041e09e86aSJames Hogan 	{ KVM_TRACE_EXIT_WAIT,		"WAIT" },		\
1051e09e86aSJames Hogan 	{ KVM_TRACE_EXIT_CACHE,		"CACHE" },		\
1061e09e86aSJames Hogan 	{ KVM_TRACE_EXIT_SIGNAL,	"Signal" }
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 
12704ebebf4SJames Hogan #define KVM_TRACE_AUX_RESTORE		0
12804ebebf4SJames Hogan #define KVM_TRACE_AUX_SAVE		1
12904ebebf4SJames Hogan #define KVM_TRACE_AUX_ENABLE		2
13004ebebf4SJames Hogan #define KVM_TRACE_AUX_DISABLE		3
13104ebebf4SJames Hogan #define KVM_TRACE_AUX_DISCARD		4
13204ebebf4SJames Hogan 
13304ebebf4SJames Hogan #define KVM_TRACE_AUX_FPU		1
13404ebebf4SJames Hogan #define KVM_TRACE_AUX_MSA		2
13504ebebf4SJames Hogan #define KVM_TRACE_AUX_FPU_MSA		3
13604ebebf4SJames Hogan 
13704ebebf4SJames Hogan #define kvm_trace_symbol_aux_op		\
13804ebebf4SJames Hogan 	{ KVM_TRACE_AUX_RESTORE, "restore" },	\
13904ebebf4SJames Hogan 	{ KVM_TRACE_AUX_SAVE,    "save" },	\
14004ebebf4SJames Hogan 	{ KVM_TRACE_AUX_ENABLE,  "enable" },	\
14104ebebf4SJames Hogan 	{ KVM_TRACE_AUX_DISABLE, "disable" },	\
14204ebebf4SJames Hogan 	{ KVM_TRACE_AUX_DISCARD, "discard" }
14304ebebf4SJames Hogan 
14404ebebf4SJames Hogan #define kvm_trace_symbol_aux_state		\
14504ebebf4SJames Hogan 	{ KVM_TRACE_AUX_FPU,     "FPU" },	\
14604ebebf4SJames Hogan 	{ KVM_TRACE_AUX_MSA,     "MSA" },	\
14704ebebf4SJames Hogan 	{ KVM_TRACE_AUX_FPU_MSA, "FPU & MSA" }
14804ebebf4SJames Hogan 
14904ebebf4SJames Hogan TRACE_EVENT(kvm_aux,
15004ebebf4SJames Hogan 	    TP_PROTO(struct kvm_vcpu *vcpu, unsigned int op,
15104ebebf4SJames Hogan 		     unsigned int state),
15204ebebf4SJames Hogan 	    TP_ARGS(vcpu, op, state),
15304ebebf4SJames Hogan 	    TP_STRUCT__entry(
15404ebebf4SJames Hogan 			__field(unsigned long, pc)
15504ebebf4SJames Hogan 			__field(u8, op)
15604ebebf4SJames Hogan 			__field(u8, state)
15704ebebf4SJames Hogan 	    ),
15804ebebf4SJames Hogan 
15904ebebf4SJames Hogan 	    TP_fast_assign(
16004ebebf4SJames Hogan 			__entry->pc = vcpu->arch.pc;
16104ebebf4SJames Hogan 			__entry->op = op;
16204ebebf4SJames Hogan 			__entry->state = state;
16304ebebf4SJames Hogan 	    ),
16404ebebf4SJames Hogan 
16504ebebf4SJames Hogan 	    TP_printk("%s %s PC: 0x%08lx",
16604ebebf4SJames Hogan 		      __print_symbolic(__entry->op,
16704ebebf4SJames Hogan 				       kvm_trace_symbol_aux_op),
16804ebebf4SJames Hogan 		      __print_symbolic(__entry->state,
16904ebebf4SJames Hogan 				       kvm_trace_symbol_aux_state),
17004ebebf4SJames Hogan 		      __entry->pc)
17104ebebf4SJames Hogan );
17204ebebf4SJames Hogan 
1739887d1c7SJames Hogan TRACE_EVENT(kvm_asid_change,
1749887d1c7SJames Hogan 	    TP_PROTO(struct kvm_vcpu *vcpu, unsigned int old_asid,
1759887d1c7SJames Hogan 		     unsigned int new_asid),
1769887d1c7SJames Hogan 	    TP_ARGS(vcpu, old_asid, new_asid),
1779887d1c7SJames Hogan 	    TP_STRUCT__entry(
1789887d1c7SJames Hogan 			__field(unsigned long, pc)
1799887d1c7SJames Hogan 			__field(u8, old_asid)
1809887d1c7SJames Hogan 			__field(u8, new_asid)
1819887d1c7SJames Hogan 	    ),
1829887d1c7SJames Hogan 
1839887d1c7SJames Hogan 	    TP_fast_assign(
1849887d1c7SJames Hogan 			__entry->pc = vcpu->arch.pc;
1859887d1c7SJames Hogan 			__entry->old_asid = old_asid;
1869887d1c7SJames Hogan 			__entry->new_asid = new_asid;
1879887d1c7SJames Hogan 	    ),
1889887d1c7SJames Hogan 
1899887d1c7SJames Hogan 	    TP_printk("PC: 0x%08lx old: 0x%02x new: 0x%02x",
1909887d1c7SJames Hogan 		      __entry->pc,
1919887d1c7SJames Hogan 		      __entry->old_asid,
1929887d1c7SJames Hogan 		      __entry->new_asid)
1939887d1c7SJames Hogan );
1949887d1c7SJames Hogan 
195669e846eSSanjay Lal #endif /* _TRACE_KVM_H */
196669e846eSSanjay Lal 
197669e846eSSanjay Lal /* This part must be outside protection */
198669e846eSSanjay Lal #include <trace/define_trace.h>
199