xref: /openbmc/linux/arch/s390/kvm/trace.h (revision bc5aa3a0)
1 #if !defined(_TRACE_KVM_H) || defined(TRACE_HEADER_MULTI_READ)
2 #define _TRACE_KVM_H
3 
4 #include <linux/tracepoint.h>
5 #include <asm/sie.h>
6 #include <asm/debug.h>
7 #include <asm/dis.h>
8 
9 #undef TRACE_SYSTEM
10 #define TRACE_SYSTEM kvm
11 #define TRACE_INCLUDE_PATH .
12 #undef TRACE_INCLUDE_FILE
13 #define TRACE_INCLUDE_FILE trace
14 
15 /*
16  * Helpers for vcpu-specific tracepoints containing the same information
17  * as s390dbf VCPU_EVENTs.
18  */
19 #define VCPU_PROTO_COMMON struct kvm_vcpu *vcpu
20 #define VCPU_ARGS_COMMON vcpu
21 #define VCPU_FIELD_COMMON __field(int, id)			\
22 	__field(unsigned long, pswmask)				\
23 	__field(unsigned long, pswaddr)
24 #define VCPU_ASSIGN_COMMON do {						\
25 	__entry->id = vcpu->vcpu_id;					\
26 	__entry->pswmask = vcpu->arch.sie_block->gpsw.mask;		\
27 	__entry->pswaddr = vcpu->arch.sie_block->gpsw.addr;		\
28 	} while (0);
29 #define VCPU_TP_PRINTK(p_str, p_args...)				\
30 	TP_printk("%02d[%016lx-%016lx]: " p_str, __entry->id,		\
31 		  __entry->pswmask, __entry->pswaddr, p_args)
32 
33 TRACE_EVENT(kvm_s390_skey_related_inst,
34 	    TP_PROTO(VCPU_PROTO_COMMON),
35 	    TP_ARGS(VCPU_ARGS_COMMON),
36 
37 	    TP_STRUCT__entry(
38 		    VCPU_FIELD_COMMON
39 		    ),
40 
41 	    TP_fast_assign(
42 		    VCPU_ASSIGN_COMMON
43 		    ),
44 	    VCPU_TP_PRINTK("%s", "storage key related instruction")
45 	);
46 
47 TRACE_EVENT(kvm_s390_major_guest_pfault,
48 	    TP_PROTO(VCPU_PROTO_COMMON),
49 	    TP_ARGS(VCPU_ARGS_COMMON),
50 
51 	    TP_STRUCT__entry(
52 		    VCPU_FIELD_COMMON
53 		    ),
54 
55 	    TP_fast_assign(
56 		    VCPU_ASSIGN_COMMON
57 		    ),
58 	    VCPU_TP_PRINTK("%s", "major fault, maybe applicable for pfault")
59 	);
60 
61 TRACE_EVENT(kvm_s390_pfault_init,
62 	    TP_PROTO(VCPU_PROTO_COMMON, long pfault_token),
63 	    TP_ARGS(VCPU_ARGS_COMMON, pfault_token),
64 
65 	    TP_STRUCT__entry(
66 		    VCPU_FIELD_COMMON
67 		    __field(long, pfault_token)
68 		    ),
69 
70 	    TP_fast_assign(
71 		    VCPU_ASSIGN_COMMON
72 		    __entry->pfault_token = pfault_token;
73 		    ),
74 	    VCPU_TP_PRINTK("init pfault token %ld", __entry->pfault_token)
75 	);
76 
77 TRACE_EVENT(kvm_s390_pfault_done,
78 	    TP_PROTO(VCPU_PROTO_COMMON, long pfault_token),
79 	    TP_ARGS(VCPU_ARGS_COMMON, pfault_token),
80 
81 	    TP_STRUCT__entry(
82 		    VCPU_FIELD_COMMON
83 		    __field(long, pfault_token)
84 		    ),
85 
86 	    TP_fast_assign(
87 		    VCPU_ASSIGN_COMMON
88 		    __entry->pfault_token = pfault_token;
89 		    ),
90 	    VCPU_TP_PRINTK("done pfault token %ld", __entry->pfault_token)
91 	);
92 
93 /*
94  * Tracepoints for SIE entry and exit.
95  */
96 TRACE_EVENT(kvm_s390_sie_enter,
97 	    TP_PROTO(VCPU_PROTO_COMMON, int cpuflags),
98 	    TP_ARGS(VCPU_ARGS_COMMON, cpuflags),
99 
100 	    TP_STRUCT__entry(
101 		    VCPU_FIELD_COMMON
102 		    __field(int, cpuflags)
103 		    ),
104 
105 	    TP_fast_assign(
106 		    VCPU_ASSIGN_COMMON
107 		    __entry->cpuflags = cpuflags;
108 		    ),
109 
110 	    VCPU_TP_PRINTK("entering sie flags %x", __entry->cpuflags)
111 	);
112 
113 TRACE_EVENT(kvm_s390_sie_fault,
114 	    TP_PROTO(VCPU_PROTO_COMMON),
115 	    TP_ARGS(VCPU_ARGS_COMMON),
116 
117 	    TP_STRUCT__entry(
118 		    VCPU_FIELD_COMMON
119 		    ),
120 
121 	    TP_fast_assign(
122 		    VCPU_ASSIGN_COMMON
123 		    ),
124 
125 	    VCPU_TP_PRINTK("%s", "fault in sie instruction")
126 	);
127 
128 TRACE_EVENT(kvm_s390_sie_exit,
129 	    TP_PROTO(VCPU_PROTO_COMMON, u8 icptcode),
130 	    TP_ARGS(VCPU_ARGS_COMMON, icptcode),
131 
132 	    TP_STRUCT__entry(
133 		    VCPU_FIELD_COMMON
134 		    __field(u8, icptcode)
135 		    ),
136 
137 	    TP_fast_assign(
138 		    VCPU_ASSIGN_COMMON
139 		    __entry->icptcode = icptcode;
140 		    ),
141 
142 	    VCPU_TP_PRINTK("exit sie icptcode %d (%s)", __entry->icptcode,
143 			   __print_symbolic(__entry->icptcode,
144 					    sie_intercept_code))
145 	);
146 
147 /*
148  * Trace point for intercepted instructions.
149  */
150 TRACE_EVENT(kvm_s390_intercept_instruction,
151 	    TP_PROTO(VCPU_PROTO_COMMON, __u16 ipa, __u32 ipb),
152 	    TP_ARGS(VCPU_ARGS_COMMON, ipa, ipb),
153 
154 	    TP_STRUCT__entry(
155 		    VCPU_FIELD_COMMON
156 		    __field(__u64, instruction)
157 		    ),
158 
159 	    TP_fast_assign(
160 		    VCPU_ASSIGN_COMMON
161 		    __entry->instruction = ((__u64)ipa << 48) |
162 		    ((__u64)ipb << 16);
163 		    ),
164 
165 	    VCPU_TP_PRINTK("intercepted instruction %016llx (%s)",
166 			   __entry->instruction,
167 			   __print_symbolic(icpt_insn_decoder(__entry->instruction),
168 					    icpt_insn_codes))
169 	);
170 
171 /*
172  * Trace point for intercepted program interruptions.
173  */
174 TRACE_EVENT(kvm_s390_intercept_prog,
175 	    TP_PROTO(VCPU_PROTO_COMMON, __u16 code),
176 	    TP_ARGS(VCPU_ARGS_COMMON, code),
177 
178 	    TP_STRUCT__entry(
179 		    VCPU_FIELD_COMMON
180 		    __field(__u16, code)
181 		    ),
182 
183 	    TP_fast_assign(
184 		    VCPU_ASSIGN_COMMON
185 		    __entry->code = code;
186 		    ),
187 
188 	    VCPU_TP_PRINTK("intercepted program interruption %04x (%s)",
189 			   __entry->code,
190 			   __print_symbolic(__entry->code,
191 					    icpt_prog_codes))
192 	);
193 
194 /*
195  * Trace point for validity intercepts.
196  */
197 TRACE_EVENT(kvm_s390_intercept_validity,
198 	    TP_PROTO(VCPU_PROTO_COMMON, __u16 viwhy),
199 	    TP_ARGS(VCPU_ARGS_COMMON, viwhy),
200 
201 	    TP_STRUCT__entry(
202 		    VCPU_FIELD_COMMON
203 		    __field(__u16, viwhy)
204 		    ),
205 
206 	    TP_fast_assign(
207 		    VCPU_ASSIGN_COMMON
208 		    __entry->viwhy = viwhy;
209 		    ),
210 
211 	    VCPU_TP_PRINTK("got validity intercept %04x", __entry->viwhy)
212 	);
213 
214 /*
215  * Trace points for instructions that are of special interest.
216  */
217 
218 TRACE_EVENT(kvm_s390_handle_sigp,
219 	    TP_PROTO(VCPU_PROTO_COMMON, __u8 order_code, __u16 cpu_addr, \
220 		     __u32 parameter),
221 	    TP_ARGS(VCPU_ARGS_COMMON, order_code, cpu_addr, parameter),
222 
223 	    TP_STRUCT__entry(
224 		    VCPU_FIELD_COMMON
225 		    __field(__u8, order_code)
226 		    __field(__u16, cpu_addr)
227 		    __field(__u32, parameter)
228 		    ),
229 
230 	    TP_fast_assign(
231 		    VCPU_ASSIGN_COMMON
232 		    __entry->order_code = order_code;
233 		    __entry->cpu_addr = cpu_addr;
234 		    __entry->parameter = parameter;
235 		    ),
236 
237 	    VCPU_TP_PRINTK("handle sigp order %02x (%s), cpu address %04x, " \
238 			   "parameter %08x", __entry->order_code,
239 			   __print_symbolic(__entry->order_code,
240 					    sigp_order_codes),
241 			   __entry->cpu_addr, __entry->parameter)
242 	);
243 
244 TRACE_EVENT(kvm_s390_handle_sigp_pei,
245 	    TP_PROTO(VCPU_PROTO_COMMON, __u8 order_code, __u16 cpu_addr),
246 	    TP_ARGS(VCPU_ARGS_COMMON, order_code, cpu_addr),
247 
248 	    TP_STRUCT__entry(
249 		    VCPU_FIELD_COMMON
250 		    __field(__u8, order_code)
251 		    __field(__u16, cpu_addr)
252 		    ),
253 
254 	    TP_fast_assign(
255 		    VCPU_ASSIGN_COMMON
256 		    __entry->order_code = order_code;
257 		    __entry->cpu_addr = cpu_addr;
258 		    ),
259 
260 	    VCPU_TP_PRINTK("handle sigp pei order %02x (%s), cpu address %04x",
261 			   __entry->order_code,
262 			   __print_symbolic(__entry->order_code,
263 					    sigp_order_codes),
264 			   __entry->cpu_addr)
265 	);
266 
267 TRACE_EVENT(kvm_s390_handle_diag,
268 	    TP_PROTO(VCPU_PROTO_COMMON, __u16 code),
269 	    TP_ARGS(VCPU_ARGS_COMMON, code),
270 
271 	    TP_STRUCT__entry(
272 		    VCPU_FIELD_COMMON
273 		    __field(__u16, code)
274 		    ),
275 
276 	    TP_fast_assign(
277 		    VCPU_ASSIGN_COMMON
278 		    __entry->code = code;
279 		    ),
280 
281 	    VCPU_TP_PRINTK("handle diagnose call %04x (%s)", __entry->code,
282 			   __print_symbolic(__entry->code, diagnose_codes))
283 	);
284 
285 TRACE_EVENT(kvm_s390_handle_lctl,
286 	    TP_PROTO(VCPU_PROTO_COMMON, int g, int reg1, int reg3, u64 addr),
287 	    TP_ARGS(VCPU_ARGS_COMMON, g, reg1, reg3, addr),
288 
289 	    TP_STRUCT__entry(
290 		    VCPU_FIELD_COMMON
291 		    __field(int, g)
292 		    __field(int, reg1)
293 		    __field(int, reg3)
294 		    __field(u64, addr)
295 		    ),
296 
297 	    TP_fast_assign(
298 		    VCPU_ASSIGN_COMMON
299 		    __entry->g = g;
300 		    __entry->reg1 = reg1;
301 		    __entry->reg3 = reg3;
302 		    __entry->addr = addr;
303 		    ),
304 
305 	    VCPU_TP_PRINTK("%s: loading cr %x-%x from %016llx",
306 			   __entry->g ? "lctlg" : "lctl",
307 			   __entry->reg1, __entry->reg3, __entry->addr)
308 	);
309 
310 TRACE_EVENT(kvm_s390_handle_stctl,
311 	    TP_PROTO(VCPU_PROTO_COMMON, int g, int reg1, int reg3, u64 addr),
312 	    TP_ARGS(VCPU_ARGS_COMMON, g, reg1, reg3, addr),
313 
314 	    TP_STRUCT__entry(
315 		    VCPU_FIELD_COMMON
316 		    __field(int, g)
317 		    __field(int, reg1)
318 		    __field(int, reg3)
319 		    __field(u64, addr)
320 		    ),
321 
322 	    TP_fast_assign(
323 		    VCPU_ASSIGN_COMMON
324 		    __entry->g = g;
325 		    __entry->reg1 = reg1;
326 		    __entry->reg3 = reg3;
327 		    __entry->addr = addr;
328 		    ),
329 
330 	    VCPU_TP_PRINTK("%s: storing cr %x-%x to %016llx",
331 			   __entry->g ? "stctg" : "stctl",
332 			   __entry->reg1, __entry->reg3, __entry->addr)
333 	);
334 
335 TRACE_EVENT(kvm_s390_handle_prefix,
336 	    TP_PROTO(VCPU_PROTO_COMMON, int set, u32 address),
337 	    TP_ARGS(VCPU_ARGS_COMMON, set, address),
338 
339 	    TP_STRUCT__entry(
340 		    VCPU_FIELD_COMMON
341 		    __field(int, set)
342 		    __field(u32, address)
343 		    ),
344 
345 	    TP_fast_assign(
346 		    VCPU_ASSIGN_COMMON
347 		    __entry->set = set;
348 		    __entry->address = address;
349 		    ),
350 
351 	    VCPU_TP_PRINTK("%s prefix to %08x",
352 			   __entry->set ? "setting" : "storing",
353 			   __entry->address)
354 	);
355 
356 TRACE_EVENT(kvm_s390_handle_stap,
357 	    TP_PROTO(VCPU_PROTO_COMMON, u64 address),
358 	    TP_ARGS(VCPU_ARGS_COMMON, address),
359 
360 	    TP_STRUCT__entry(
361 		    VCPU_FIELD_COMMON
362 		    __field(u64, address)
363 		    ),
364 
365 	    TP_fast_assign(
366 		    VCPU_ASSIGN_COMMON
367 		    __entry->address = address;
368 		    ),
369 
370 	    VCPU_TP_PRINTK("storing cpu address to %016llx",
371 			   __entry->address)
372 	);
373 
374 TRACE_EVENT(kvm_s390_handle_stfl,
375 	    TP_PROTO(VCPU_PROTO_COMMON, unsigned int facility_list),
376 	    TP_ARGS(VCPU_ARGS_COMMON, facility_list),
377 
378 	    TP_STRUCT__entry(
379 		    VCPU_FIELD_COMMON
380 		    __field(unsigned int, facility_list)
381 		    ),
382 
383 	    TP_fast_assign(
384 		    VCPU_ASSIGN_COMMON
385 		    __entry->facility_list = facility_list;
386 		    ),
387 
388 	    VCPU_TP_PRINTK("store facility list value %08x",
389 			   __entry->facility_list)
390 	);
391 
392 TRACE_EVENT(kvm_s390_handle_stsi,
393 	    TP_PROTO(VCPU_PROTO_COMMON, int fc, int sel1, int sel2, u64 addr),
394 	    TP_ARGS(VCPU_ARGS_COMMON, fc, sel1, sel2, addr),
395 
396 	    TP_STRUCT__entry(
397 		    VCPU_FIELD_COMMON
398 		    __field(int, fc)
399 		    __field(int, sel1)
400 		    __field(int, sel2)
401 		    __field(u64, addr)
402 		    ),
403 
404 	    TP_fast_assign(
405 		    VCPU_ASSIGN_COMMON
406 		    __entry->fc = fc;
407 		    __entry->sel1 = sel1;
408 		    __entry->sel2 = sel2;
409 		    __entry->addr = addr;
410 		    ),
411 
412 	    VCPU_TP_PRINTK("STSI %d.%d.%d information stored to %016llx",
413 			   __entry->fc, __entry->sel1, __entry->sel2,
414 			   __entry->addr)
415 	);
416 
417 TRACE_EVENT(kvm_s390_handle_operexc,
418 	    TP_PROTO(VCPU_PROTO_COMMON, __u16 ipa, __u32 ipb),
419 	    TP_ARGS(VCPU_ARGS_COMMON, ipa, ipb),
420 
421 	    TP_STRUCT__entry(
422 		    VCPU_FIELD_COMMON
423 		    __field(__u64, instruction)
424 		    ),
425 
426 	    TP_fast_assign(
427 		    VCPU_ASSIGN_COMMON
428 		    __entry->instruction = ((__u64)ipa << 48) |
429 		    ((__u64)ipb << 16);
430 		    ),
431 
432 	    VCPU_TP_PRINTK("operation exception on instruction %016llx (%s)",
433 			   __entry->instruction,
434 			   __print_symbolic(icpt_insn_decoder(__entry->instruction),
435 					    icpt_insn_codes))
436 	);
437 
438 TRACE_EVENT(kvm_s390_handle_sthyi,
439 	    TP_PROTO(VCPU_PROTO_COMMON, u64 code, u64 addr),
440 	    TP_ARGS(VCPU_ARGS_COMMON, code, addr),
441 
442 	    TP_STRUCT__entry(
443 		    VCPU_FIELD_COMMON
444 		    __field(u64, code)
445 		    __field(u64, addr)
446 		    ),
447 
448 	    TP_fast_assign(
449 		    VCPU_ASSIGN_COMMON
450 		    __entry->code = code;
451 		    __entry->addr = addr;
452 		    ),
453 
454 	    VCPU_TP_PRINTK("STHYI fc: %llu addr: %016llx",
455 			   __entry->code, __entry->addr)
456 	);
457 
458 #endif /* _TRACE_KVM_H */
459 
460 /* This part must be outside protection */
461 #include <trace/define_trace.h>
462