xref: /openbmc/linux/arch/arm64/kvm/trace.h (revision b830f94f)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #if !defined(_TRACE_ARM64_KVM_H) || defined(TRACE_HEADER_MULTI_READ)
3 #define _TRACE_ARM64_KVM_H
4 
5 #include <linux/tracepoint.h>
6 #include "sys_regs.h"
7 
8 #undef TRACE_SYSTEM
9 #define TRACE_SYSTEM kvm
10 
11 TRACE_EVENT(kvm_wfx_arm64,
12 	TP_PROTO(unsigned long vcpu_pc, bool is_wfe),
13 	TP_ARGS(vcpu_pc, is_wfe),
14 
15 	TP_STRUCT__entry(
16 		__field(unsigned long,	vcpu_pc)
17 		__field(bool,		is_wfe)
18 	),
19 
20 	TP_fast_assign(
21 		__entry->vcpu_pc = vcpu_pc;
22 		__entry->is_wfe  = is_wfe;
23 	),
24 
25 	TP_printk("guest executed wf%c at: 0x%08lx",
26 		  __entry->is_wfe ? 'e' : 'i', __entry->vcpu_pc)
27 );
28 
29 TRACE_EVENT(kvm_hvc_arm64,
30 	TP_PROTO(unsigned long vcpu_pc, unsigned long r0, unsigned long imm),
31 	TP_ARGS(vcpu_pc, r0, imm),
32 
33 	TP_STRUCT__entry(
34 		__field(unsigned long, vcpu_pc)
35 		__field(unsigned long, r0)
36 		__field(unsigned long, imm)
37 	),
38 
39 	TP_fast_assign(
40 		__entry->vcpu_pc = vcpu_pc;
41 		__entry->r0 = r0;
42 		__entry->imm = imm;
43 	),
44 
45 	TP_printk("HVC at 0x%08lx (r0: 0x%08lx, imm: 0x%lx)",
46 		  __entry->vcpu_pc, __entry->r0, __entry->imm)
47 );
48 
49 TRACE_EVENT(kvm_arm_setup_debug,
50 	TP_PROTO(struct kvm_vcpu *vcpu, __u32 guest_debug),
51 	TP_ARGS(vcpu, guest_debug),
52 
53 	TP_STRUCT__entry(
54 		__field(struct kvm_vcpu *, vcpu)
55 		__field(__u32, guest_debug)
56 	),
57 
58 	TP_fast_assign(
59 		__entry->vcpu = vcpu;
60 		__entry->guest_debug = guest_debug;
61 	),
62 
63 	TP_printk("vcpu: %p, flags: 0x%08x", __entry->vcpu, __entry->guest_debug)
64 );
65 
66 TRACE_EVENT(kvm_arm_clear_debug,
67 	TP_PROTO(__u32 guest_debug),
68 	TP_ARGS(guest_debug),
69 
70 	TP_STRUCT__entry(
71 		__field(__u32, guest_debug)
72 	),
73 
74 	TP_fast_assign(
75 		__entry->guest_debug = guest_debug;
76 	),
77 
78 	TP_printk("flags: 0x%08x", __entry->guest_debug)
79 );
80 
81 TRACE_EVENT(kvm_arm_set_dreg32,
82 	TP_PROTO(const char *name, __u32 value),
83 	TP_ARGS(name, value),
84 
85 	TP_STRUCT__entry(
86 		__field(const char *, name)
87 		__field(__u32, value)
88 	),
89 
90 	TP_fast_assign(
91 		__entry->name = name;
92 		__entry->value = value;
93 	),
94 
95 	TP_printk("%s: 0x%08x", __entry->name, __entry->value)
96 );
97 
98 TRACE_DEFINE_SIZEOF(__u64);
99 
100 TRACE_EVENT(kvm_arm_set_regset,
101 	TP_PROTO(const char *type, int len, __u64 *control, __u64 *value),
102 	TP_ARGS(type, len, control, value),
103 	TP_STRUCT__entry(
104 		__field(const char *, name)
105 		__field(int, len)
106 		__array(u64, ctrls, 16)
107 		__array(u64, values, 16)
108 	),
109 	TP_fast_assign(
110 		__entry->name = type;
111 		__entry->len = len;
112 		memcpy(__entry->ctrls, control, len << 3);
113 		memcpy(__entry->values, value, len << 3);
114 	),
115 	TP_printk("%d %s CTRL:%s VALUE:%s", __entry->len, __entry->name,
116 		__print_array(__entry->ctrls, __entry->len, sizeof(__u64)),
117 		__print_array(__entry->values, __entry->len, sizeof(__u64)))
118 );
119 
120 TRACE_EVENT(trap_reg,
121 	TP_PROTO(const char *fn, int reg, bool is_write, u64 write_value),
122 	TP_ARGS(fn, reg, is_write, write_value),
123 
124 	TP_STRUCT__entry(
125 		__field(const char *, fn)
126 		__field(int, reg)
127 		__field(bool, is_write)
128 		__field(u64, write_value)
129 	),
130 
131 	TP_fast_assign(
132 		__entry->fn = fn;
133 		__entry->reg = reg;
134 		__entry->is_write = is_write;
135 		__entry->write_value = write_value;
136 	),
137 
138 	TP_printk("%s %s reg %d (0x%08llx)", __entry->fn,  __entry->is_write?"write to":"read from", __entry->reg, __entry->write_value)
139 );
140 
141 TRACE_EVENT(kvm_handle_sys_reg,
142 	TP_PROTO(unsigned long hsr),
143 	TP_ARGS(hsr),
144 
145 	TP_STRUCT__entry(
146 		__field(unsigned long,	hsr)
147 	),
148 
149 	TP_fast_assign(
150 		__entry->hsr = hsr;
151 	),
152 
153 	TP_printk("HSR 0x%08lx", __entry->hsr)
154 );
155 
156 TRACE_EVENT(kvm_sys_access,
157 	TP_PROTO(unsigned long vcpu_pc, struct sys_reg_params *params, const struct sys_reg_desc *reg),
158 	TP_ARGS(vcpu_pc, params, reg),
159 
160 	TP_STRUCT__entry(
161 		__field(unsigned long,			vcpu_pc)
162 		__field(bool,				is_write)
163 		__field(const char *,			name)
164 		__field(u8,				Op0)
165 		__field(u8,				Op1)
166 		__field(u8,				CRn)
167 		__field(u8,				CRm)
168 		__field(u8,				Op2)
169 	),
170 
171 	TP_fast_assign(
172 		__entry->vcpu_pc = vcpu_pc;
173 		__entry->is_write = params->is_write;
174 		__entry->name = reg->name;
175 		__entry->Op0 = reg->Op0;
176 		__entry->Op0 = reg->Op0;
177 		__entry->Op1 = reg->Op1;
178 		__entry->CRn = reg->CRn;
179 		__entry->CRm = reg->CRm;
180 		__entry->Op2 = reg->Op2;
181 	),
182 
183 	TP_printk("PC: %lx %s (%d,%d,%d,%d,%d) %s",
184 		  __entry->vcpu_pc, __entry->name ?: "UNKN",
185 		  __entry->Op0, __entry->Op1, __entry->CRn,
186 		  __entry->CRm, __entry->Op2,
187 		  __entry->is_write ? "write" : "read")
188 );
189 
190 TRACE_EVENT(kvm_set_guest_debug,
191 	TP_PROTO(struct kvm_vcpu *vcpu, __u32 guest_debug),
192 	TP_ARGS(vcpu, guest_debug),
193 
194 	TP_STRUCT__entry(
195 		__field(struct kvm_vcpu *, vcpu)
196 		__field(__u32, guest_debug)
197 	),
198 
199 	TP_fast_assign(
200 		__entry->vcpu = vcpu;
201 		__entry->guest_debug = guest_debug;
202 	),
203 
204 	TP_printk("vcpu: %p, flags: 0x%08x", __entry->vcpu, __entry->guest_debug)
205 );
206 
207 
208 #endif /* _TRACE_ARM64_KVM_H */
209 
210 #undef TRACE_INCLUDE_PATH
211 #define TRACE_INCLUDE_PATH .
212 #undef TRACE_INCLUDE_FILE
213 #define TRACE_INCLUDE_FILE trace
214 
215 /* This part must be outside protection */
216 #include <trace/define_trace.h>
217