fix: KVM: x86: Get exit_reason as part of kvm_x86_ops.get_exit_info (v5.16)
[lttng-modules.git] / include / instrumentation / events / arch / x86 / kvm / trace.h
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 #if !defined(LTTNG_TRACE_KVM_H) || defined(TRACE_HEADER_MULTI_READ)
3 #define LTTNG_TRACE_KVM_H
4
5 #include <lttng/tracepoint-event.h>
6 #include <asm/vmx.h>
7 #include <asm/svm.h>
8 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
9 #include <asm/clocksource.h>
10 #endif
11 #include <lttng/kernel-version.h>
12 #include <../arch/x86/kvm/lapic.h>
13 #include <../arch/x86/kvm/kvm_cache_regs.h>
14
15 #undef TRACE_SYSTEM
16 #define TRACE_SYSTEM kvm_x86
17
18 /*
19 * Tracepoint for guest mode entry.
20 */
21 LTTNG_TRACEPOINT_EVENT_MAP(kvm_entry, kvm_x86_entry,
22 TP_PROTO(unsigned int vcpu_id),
23 TP_ARGS(vcpu_id),
24
25 TP_FIELDS(
26 ctf_integer(unsigned int, vcpu_id, vcpu_id)
27 )
28 )
29
30 /*
31 * Tracepoint for hypercall.
32 */
33 LTTNG_TRACEPOINT_EVENT_MAP(kvm_hypercall, kvm_x86_hypercall,
34 TP_PROTO(unsigned long nr, unsigned long a0, unsigned long a1,
35 unsigned long a2, unsigned long a3),
36 TP_ARGS(nr, a0, a1, a2, a3),
37
38 TP_FIELDS(
39 ctf_integer(unsigned long, nr, nr)
40 ctf_integer(unsigned long, a0, a0)
41 ctf_integer(unsigned long, a1, a1)
42 ctf_integer(unsigned long, a2, a2)
43 ctf_integer(unsigned long, a3, a3)
44 )
45 )
46
47 /*
48 * Tracepoint for hypercall.
49 */
50 LTTNG_TRACEPOINT_EVENT_MAP(kvm_hv_hypercall, kvm_x86_hv_hypercall,
51 TP_PROTO(__u16 code, bool fast, __u16 rep_cnt, __u16 rep_idx,
52 __u64 ingpa, __u64 outgpa),
53 TP_ARGS(code, fast, rep_cnt, rep_idx, ingpa, outgpa),
54
55 TP_FIELDS(
56 ctf_integer(__u16, rep_cnt, rep_cnt)
57 ctf_integer(__u16, rep_idx, rep_idx)
58 ctf_integer(__u64, ingpa, ingpa)
59 ctf_integer(__u64, outgpa, outgpa)
60 ctf_integer(__u16, code, code)
61 ctf_integer(bool, fast, fast)
62 )
63 )
64
65 /*
66 * Tracepoint for PIO.
67 */
68 LTTNG_TRACEPOINT_EVENT_MAP(kvm_pio, kvm_x86_pio,
69 TP_PROTO(unsigned int rw, unsigned int port, unsigned int size,
70 unsigned int count),
71 TP_ARGS(rw, port, size, count),
72
73 TP_FIELDS(
74 ctf_integer(unsigned int, rw, rw)
75 ctf_integer(unsigned int, port, port)
76 ctf_integer(unsigned int, size, size)
77 ctf_integer(unsigned int, count, count)
78 )
79 )
80
81 /*
82 * Tracepoint for cpuid.
83 */
84 LTTNG_TRACEPOINT_EVENT_MAP(kvm_cpuid, kvm_x86_cpuid,
85 TP_PROTO(unsigned int function, unsigned long rax, unsigned long rbx,
86 unsigned long rcx, unsigned long rdx),
87 TP_ARGS(function, rax, rbx, rcx, rdx),
88
89 TP_FIELDS(
90 ctf_integer(unsigned int, function, function)
91 ctf_integer(unsigned long, rax, rax)
92 ctf_integer(unsigned long, rbx, rbx)
93 ctf_integer(unsigned long, rcx, rcx)
94 ctf_integer(unsigned long, rdx, rdx)
95 )
96 )
97
98 /*
99 * Tracepoint for apic access.
100 */
101 LTTNG_TRACEPOINT_EVENT_MAP(kvm_apic, kvm_x86_apic,
102 TP_PROTO(unsigned int rw, unsigned int reg, unsigned int val),
103 TP_ARGS(rw, reg, val),
104
105 TP_FIELDS(
106 ctf_integer(unsigned int, rw, rw)
107 ctf_integer(unsigned int, reg, reg)
108 ctf_integer(unsigned int, val, val)
109 )
110 )
111
112 #define trace_kvm_apic_read(reg, val) trace_kvm_apic(0, reg, val)
113 #define trace_kvm_apic_write(reg, val) trace_kvm_apic(1, reg, val)
114
115 /*
116 * Tracepoint for kvm guest exit:
117 */
118 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,16,0))
119 LTTNG_TRACEPOINT_EVENT_CODE_MAP(kvm_exit, kvm_x86_exit,
120 TP_PROTO(struct kvm_vcpu *vcpu, u32 isa),
121 TP_ARGS(vcpu, isa),
122
123 TP_locvar(
124 u32 reason;
125 u64 info1, info2;
126 u32 intr_info, error_code;
127 ),
128
129 TP_code_pre(
130 kvm_x86_ops.get_exit_info(vcpu, &tp_locvar->reason,
131 &tp_locvar->info1,
132 &tp_locvar->info2,
133 &tp_locvar->intr_info,
134 &tp_locvar->error_code);
135 ),
136
137 TP_FIELDS(
138 ctf_integer(u32, exit_reason, tp_locvar->reason)
139 ctf_integer(unsigned long, guest_rip, kvm_rip_read(vcpu))
140 ctf_integer(u32, isa, isa)
141 ctf_integer(u64, info1, tp_locvar->info1)
142 ctf_integer(u64, info2, tp_locvar->info2)
143 ctf_integer(u32, intr_info, tp_locvar->intr_info)
144 ctf_integer(u32, error_code, tp_locvar->error_code)
145 ctf_integer(unsigned int, vcpu_id, vcpu->vcpu_id)
146 ),
147
148 TP_code_post()
149 )
150 #elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,10,0))
151 LTTNG_TRACEPOINT_EVENT_CODE_MAP(kvm_exit, kvm_x86_exit,
152 TP_PROTO(unsigned int exit_reason, struct kvm_vcpu *vcpu, u32 isa),
153 TP_ARGS(exit_reason, vcpu, isa),
154
155 TP_locvar(
156 u64 info1, info2;
157 u32 intr_info, error_code;
158 ),
159
160 TP_code_pre(
161 kvm_x86_ops.get_exit_info(vcpu, &tp_locvar->info1,
162 &tp_locvar->info2,
163 &tp_locvar->intr_info,
164 &tp_locvar->error_code);
165 ),
166
167 TP_FIELDS(
168 ctf_integer(unsigned int, exit_reason, exit_reason)
169 ctf_integer(unsigned long, guest_rip, kvm_rip_read(vcpu))
170 ctf_integer(u32, isa, isa)
171 ctf_integer(u64, info1, tp_locvar->info1)
172 ctf_integer(u64, info2, tp_locvar->info2)
173 ctf_integer(u32, intr_info, tp_locvar->intr_info)
174 ctf_integer(u32, error_code, tp_locvar->error_code)
175 ctf_integer(unsigned int, vcpu_id, vcpu->vcpu_id)
176 ),
177
178 TP_code_post()
179 )
180 #elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,7,0))
181 LTTNG_TRACEPOINT_EVENT_CODE_MAP(kvm_exit, kvm_x86_exit,
182 TP_PROTO(unsigned int exit_reason, struct kvm_vcpu *vcpu, u32 isa),
183 TP_ARGS(exit_reason, vcpu, isa),
184
185 TP_locvar(
186 u64 info1, info2;
187 ),
188
189 TP_code_pre(
190 kvm_x86_ops.get_exit_info(vcpu, &tp_locvar->info1,
191 &tp_locvar->info2);
192 ),
193
194 TP_FIELDS(
195 ctf_integer(unsigned int, exit_reason, exit_reason)
196 ctf_integer(unsigned long, guest_rip, kvm_rip_read(vcpu))
197 ctf_integer(u32, isa, isa)
198 ctf_integer(u64, info1, tp_locvar->info1)
199 ctf_integer(u64, info2, tp_locvar->info2)
200 ),
201
202 TP_code_post()
203 )
204 #else
205 LTTNG_TRACEPOINT_EVENT_CODE_MAP(kvm_exit, kvm_x86_exit,
206 TP_PROTO(unsigned int exit_reason, struct kvm_vcpu *vcpu, u32 isa),
207 TP_ARGS(exit_reason, vcpu, isa),
208
209 TP_locvar(
210 u64 info1, info2;
211 ),
212
213 TP_code_pre(
214 kvm_x86_ops->get_exit_info(vcpu, &tp_locvar->info1,
215 &tp_locvar->info2);
216 ),
217
218 TP_FIELDS(
219 ctf_integer(unsigned int, exit_reason, exit_reason)
220 ctf_integer(unsigned long, guest_rip, kvm_rip_read(vcpu))
221 ctf_integer(u32, isa, isa)
222 ctf_integer(u64, info1, tp_locvar->info1)
223 ctf_integer(u64, info2, tp_locvar->info2)
224 ),
225
226 TP_code_post()
227 )
228 #endif
229
230 /*
231 * Tracepoint for kvm interrupt injection:
232 */
233 LTTNG_TRACEPOINT_EVENT_MAP(kvm_inj_virq, kvm_x86_inj_virq,
234 TP_PROTO(unsigned int irq),
235 TP_ARGS(irq),
236
237 TP_FIELDS(
238 ctf_integer(unsigned int, irq, irq)
239 )
240 )
241
242 /*
243 * Tracepoint for kvm interrupt injection:
244 */
245 LTTNG_TRACEPOINT_EVENT_MAP(kvm_inj_exception, kvm_x86_inj_exception,
246 TP_PROTO(unsigned exception, bool has_error, unsigned error_code),
247 TP_ARGS(exception, has_error, error_code),
248
249 TP_FIELDS(
250 ctf_integer(u8, exception, exception)
251 ctf_integer(u8, has_error, has_error)
252 ctf_integer(u32, error_code, error_code)
253 )
254 )
255
256 /*
257 * Tracepoint for page fault.
258 */
259 LTTNG_TRACEPOINT_EVENT_MAP(kvm_page_fault, kvm_x86_page_fault,
260 TP_PROTO(unsigned long fault_address, unsigned int error_code),
261 TP_ARGS(fault_address, error_code),
262
263 TP_FIELDS(
264 ctf_integer_hex(unsigned long, fault_address, fault_address)
265 ctf_integer(unsigned int, error_code, error_code)
266 )
267 )
268
269 /*
270 * Tracepoint for guest MSR access.
271 */
272 LTTNG_TRACEPOINT_EVENT_MAP(kvm_msr, kvm_x86_msr,
273 TP_PROTO(unsigned write, u32 ecx, u64 data, bool exception),
274 TP_ARGS(write, ecx, data, exception),
275
276 TP_FIELDS(
277 ctf_integer(unsigned, write, write)
278 ctf_integer(u32, ecx, ecx)
279 ctf_integer(u64, data, data)
280 ctf_integer(u8, exception, exception)
281 )
282 )
283
284 #define trace_kvm_msr_read(ecx, data) trace_kvm_msr(0, ecx, data, false)
285 #define trace_kvm_msr_write(ecx, data) trace_kvm_msr(1, ecx, data, false)
286 #define trace_kvm_msr_read_ex(ecx) trace_kvm_msr(0, ecx, 0, true)
287 #define trace_kvm_msr_write_ex(ecx, data) trace_kvm_msr(1, ecx, data, true)
288
289 /*
290 * Tracepoint for guest CR access.
291 */
292 LTTNG_TRACEPOINT_EVENT_MAP(kvm_cr, kvm_x86_cr,
293 TP_PROTO(unsigned int rw, unsigned int cr, unsigned long val),
294 TP_ARGS(rw, cr, val),
295
296 TP_FIELDS(
297 ctf_integer(unsigned int, rw, rw)
298 ctf_integer(unsigned int, cr, cr)
299 ctf_integer(unsigned long, val, val)
300 )
301 )
302
303 #define trace_kvm_cr_read(cr, val) trace_kvm_cr(0, cr, val)
304 #define trace_kvm_cr_write(cr, val) trace_kvm_cr(1, cr, val)
305
306 LTTNG_TRACEPOINT_EVENT_MAP(kvm_pic_set_irq, kvm_x86_pic_set_irq,
307 TP_PROTO(__u8 chip, __u8 pin, __u8 elcr, __u8 imr, bool coalesced),
308 TP_ARGS(chip, pin, elcr, imr, coalesced),
309
310 TP_FIELDS(
311 ctf_integer(__u8, chip, chip)
312 ctf_integer(__u8, pin, pin)
313 ctf_integer(__u8, elcr, elcr)
314 ctf_integer(__u8, imr, imr)
315 ctf_integer(bool, coalesced, coalesced)
316 )
317 )
318
319 LTTNG_TRACEPOINT_EVENT_MAP(kvm_apic_ipi, kvm_x86_apic_ipi,
320 TP_PROTO(__u32 icr_low, __u32 dest_id),
321 TP_ARGS(icr_low, dest_id),
322
323 TP_FIELDS(
324 ctf_integer(__u32, icr_low, icr_low)
325 ctf_integer(__u32, dest_id, dest_id)
326 )
327 )
328
329 LTTNG_TRACEPOINT_EVENT_MAP(kvm_apic_accept_irq, kvm_x86_apic_accept_irq,
330 TP_PROTO(__u32 apicid, __u16 dm, __u8 tm, __u8 vec, bool coalesced),
331 TP_ARGS(apicid, dm, tm, vec, coalesced),
332
333 TP_FIELDS(
334 ctf_integer(__u32, apicid, apicid)
335 ctf_integer(__u16, dm, dm)
336 ctf_integer(__u8, tm, tm)
337 ctf_integer(__u8, vec, vec)
338 ctf_integer(bool, coalesced, coalesced)
339 )
340 )
341
342 LTTNG_TRACEPOINT_EVENT_MAP(kvm_eoi, kvm_x86_eoi,
343 TP_PROTO(struct kvm_lapic *apic, int vector),
344 TP_ARGS(apic, vector),
345
346 TP_FIELDS(
347 ctf_integer(__u32, apicid, apic->vcpu->vcpu_id)
348 ctf_integer(int, vector, vector)
349 )
350 )
351
352 LTTNG_TRACEPOINT_EVENT_MAP(kvm_pv_eoi, kvm_x86_pv_eoi,
353 TP_PROTO(struct kvm_lapic *apic, int vector),
354 TP_ARGS(apic, vector),
355
356 TP_FIELDS(
357 ctf_integer(__u32, apicid, apic->vcpu->vcpu_id)
358 ctf_integer(int, vector, vector)
359 )
360 )
361
362 /*
363 * Tracepoint for nested VMRUN
364 */
365 LTTNG_TRACEPOINT_EVENT_MAP(kvm_nested_vmrun, kvm_x86_nested_vmrun,
366 TP_PROTO(__u64 rip, __u64 vmcb, __u64 nested_rip, __u32 int_ctl,
367 __u32 event_inj, bool npt),
368 TP_ARGS(rip, vmcb, nested_rip, int_ctl, event_inj, npt),
369
370 TP_FIELDS(
371 ctf_integer(__u64, rip, rip)
372 ctf_integer(__u64, vmcb, vmcb)
373 ctf_integer(__u64, nested_rip, nested_rip)
374 ctf_integer(__u32, int_ctl, int_ctl)
375 ctf_integer(__u32, event_inj, event_inj)
376 ctf_integer(bool, npt, npt)
377 )
378 )
379
380 LTTNG_TRACEPOINT_EVENT_MAP(kvm_nested_intercepts, kvm_x86_nested_intercepts,
381 TP_PROTO(__u16 cr_read, __u16 cr_write, __u32 exceptions, __u64 intercept),
382 TP_ARGS(cr_read, cr_write, exceptions, intercept),
383
384 TP_FIELDS(
385 ctf_integer(__u16, cr_read, cr_read)
386 ctf_integer(__u16, cr_write, cr_write)
387 ctf_integer(__u32, exceptions, exceptions)
388 ctf_integer(__u64, intercept, intercept)
389 )
390 )
391 /*
392 * Tracepoint for #VMEXIT while nested
393 */
394 LTTNG_TRACEPOINT_EVENT_MAP(kvm_nested_vmexit, kvm_x86_nested_vmexit,
395 TP_PROTO(__u64 rip, __u32 exit_code,
396 __u64 exit_info1, __u64 exit_info2,
397 __u32 exit_int_info, __u32 exit_int_info_err, __u32 isa),
398 TP_ARGS(rip, exit_code, exit_info1, exit_info2,
399 exit_int_info, exit_int_info_err, isa),
400
401 TP_FIELDS(
402 ctf_integer(__u64, rip, rip)
403 ctf_integer(__u32, exit_code, exit_code)
404 ctf_integer(__u64, exit_info1, exit_info1)
405 ctf_integer(__u64, exit_info2, exit_info2)
406 ctf_integer(__u32, exit_int_info, exit_int_info)
407 ctf_integer(__u32, exit_int_info_err, exit_int_info_err)
408 ctf_integer(__u32, isa, isa)
409 )
410 )
411
412 /*
413 * Tracepoint for #VMEXIT reinjected to the guest
414 */
415 LTTNG_TRACEPOINT_EVENT_MAP(kvm_nested_vmexit_inject, kvm_x86_nested_vmexit_inject,
416 TP_PROTO(__u32 exit_code,
417 __u64 exit_info1, __u64 exit_info2,
418 __u32 exit_int_info, __u32 exit_int_info_err, __u32 isa),
419 TP_ARGS(exit_code, exit_info1, exit_info2,
420 exit_int_info, exit_int_info_err, isa),
421
422 TP_FIELDS(
423 ctf_integer(__u32, exit_code, exit_code)
424 ctf_integer(__u64, exit_info1, exit_info1)
425 ctf_integer(__u64, exit_info2, exit_info2)
426 ctf_integer(__u32, exit_int_info, exit_int_info)
427 ctf_integer(__u32, exit_int_info_err, exit_int_info_err)
428 ctf_integer(__u32, isa, isa)
429 )
430 )
431
432 /*
433 * Tracepoint for nested #vmexit because of interrupt pending
434 */
435 LTTNG_TRACEPOINT_EVENT_MAP(kvm_nested_intr_vmexit, kvm_x86_nested_intr_vmexit,
436 TP_PROTO(__u64 rip),
437 TP_ARGS(rip),
438
439 TP_FIELDS(
440 ctf_integer(__u64, rip, rip)
441 )
442 )
443
444 /*
445 * Tracepoint for nested #vmexit because of interrupt pending
446 */
447 LTTNG_TRACEPOINT_EVENT_MAP(kvm_invlpga, kvm_x86_invlpga,
448 TP_PROTO(__u64 rip, int asid, u64 address),
449 TP_ARGS(rip, asid, address),
450
451 TP_FIELDS(
452 ctf_integer(__u64, rip, rip)
453 ctf_integer(int, asid, asid)
454 ctf_integer_hex(__u64, address, address)
455 )
456 )
457
458 /*
459 * Tracepoint for nested #vmexit because of interrupt pending
460 */
461 LTTNG_TRACEPOINT_EVENT_MAP(kvm_skinit, kvm_x86_skinit,
462 TP_PROTO(__u64 rip, __u32 slb),
463 TP_ARGS(rip, slb),
464
465 TP_FIELDS(
466 ctf_integer(__u64, rip, rip)
467 ctf_integer(__u32, slb, slb)
468 )
469 )
470
471 #define KVM_EMUL_INSN_F_CR0_PE (1 << 0)
472 #define KVM_EMUL_INSN_F_EFL_VM (1 << 1)
473 #define KVM_EMUL_INSN_F_CS_D (1 << 2)
474 #define KVM_EMUL_INSN_F_CS_L (1 << 3)
475
476 #define kvm_trace_symbol_emul_flags \
477 { 0, "real" }, \
478 { KVM_EMUL_INSN_F_CR0_PE \
479 | KVM_EMUL_INSN_F_EFL_VM, "vm16" }, \
480 { KVM_EMUL_INSN_F_CR0_PE, "prot16" }, \
481 { KVM_EMUL_INSN_F_CR0_PE \
482 | KVM_EMUL_INSN_F_CS_D, "prot32" }, \
483 { KVM_EMUL_INSN_F_CR0_PE \
484 | KVM_EMUL_INSN_F_CS_L, "prot64" }
485
486 #define kei_decode_mode(mode) ({ \
487 u8 flags = 0xff; \
488 switch (mode) { \
489 case X86EMUL_MODE_REAL: \
490 flags = 0; \
491 break; \
492 case X86EMUL_MODE_VM86: \
493 flags = KVM_EMUL_INSN_F_EFL_VM; \
494 break; \
495 case X86EMUL_MODE_PROT16: \
496 flags = KVM_EMUL_INSN_F_CR0_PE; \
497 break; \
498 case X86EMUL_MODE_PROT32: \
499 flags = KVM_EMUL_INSN_F_CR0_PE \
500 | KVM_EMUL_INSN_F_CS_D; \
501 break; \
502 case X86EMUL_MODE_PROT64: \
503 flags = KVM_EMUL_INSN_F_CR0_PE \
504 | KVM_EMUL_INSN_F_CS_L; \
505 break; \
506 } \
507 flags; \
508 })
509
510 LTTNG_TRACEPOINT_EVENT_MAP(kvm_emulate_insn, kvm_x86_emulate_insn,
511 TP_PROTO(struct kvm_vcpu *vcpu, __u8 failed),
512 TP_ARGS(vcpu, failed),
513
514 TP_FIELDS(
515 #if (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(3,1,0))
516 ctf_integer(__u64, rip, vcpu->arch.emulate_ctxt.decode.fetch.start)
517 ctf_integer(__u32, csbase, kvm_x86_ops->get_segment_base(vcpu, VCPU_SREG_CS))
518 ctf_integer(__u8, len, vcpu->arch.emulate_ctxt.decode.eip
519 - vcpu->arch.emulate_ctxt.decode.fetch.start)
520 ctf_array(__u8, insn, vcpu->arch.emulate_ctxt.decode.fetch.data, 15)
521 ctf_integer(__u8, flags, kei_decode_mode(vcpu->arch.emulate_ctxt.mode))
522 #elif (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(3,17,0))
523 ctf_integer(__u64, rip, vcpu->arch.emulate_ctxt.fetch.start)
524 ctf_integer(__u32, csbase, kvm_x86_ops->get_segment_base(vcpu, VCPU_SREG_CS))
525 ctf_integer(__u8, len, vcpu->arch.emulate_ctxt._eip
526 - vcpu->arch.emulate_ctxt.fetch.start)
527 ctf_array(__u8, insn, vcpu->arch.emulate_ctxt.fetch.data, 15)
528 ctf_integer(__u8, flags, kei_decode_mode(vcpu->arch.emulate_ctxt.mode))
529 #elif (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(5,7,0))
530 ctf_integer(__u64, rip, vcpu->arch.emulate_ctxt._eip -
531 (vcpu->arch.emulate_ctxt.fetch.ptr -
532 vcpu->arch.emulate_ctxt.fetch.data))
533 ctf_integer(__u32, csbase, kvm_x86_ops->get_segment_base(vcpu, VCPU_SREG_CS))
534 ctf_integer(__u8, len, vcpu->arch.emulate_ctxt.fetch.ptr -
535 vcpu->arch.emulate_ctxt.fetch.data)
536 ctf_array(__u8, insn, vcpu->arch.emulate_ctxt.fetch.data, 15)
537 ctf_integer(__u8, flags, kei_decode_mode(vcpu->arch.emulate_ctxt.mode))
538 #else
539 ctf_integer(__u64, rip, vcpu->arch.emulate_ctxt->_eip -
540 (vcpu->arch.emulate_ctxt->fetch.ptr -
541 vcpu->arch.emulate_ctxt->fetch.data))
542 ctf_integer(__u32, csbase, kvm_x86_ops.get_segment_base(vcpu, VCPU_SREG_CS))
543 ctf_integer(__u8, len, vcpu->arch.emulate_ctxt->fetch.ptr -
544 vcpu->arch.emulate_ctxt->fetch.data)
545 ctf_array(__u8, insn, vcpu->arch.emulate_ctxt->fetch.data, 15)
546 ctf_integer(__u8, flags, kei_decode_mode(vcpu->arch.emulate_ctxt->mode))
547 #endif
548 ctf_integer(__u8, failed, failed)
549 )
550 )
551
552 #define trace_kvm_emulate_insn_start(vcpu) trace_kvm_emulate_insn(vcpu, 0)
553 #define trace_kvm_emulate_insn_failed(vcpu) trace_kvm_emulate_insn(vcpu, 1)
554
555 LTTNG_TRACEPOINT_EVENT_MAP(
556 vcpu_match_mmio, kvm_x86_vcpu_match_mmio,
557 TP_PROTO(gva_t gva, gpa_t gpa, bool write, bool gpa_match),
558 TP_ARGS(gva, gpa, write, gpa_match),
559
560 TP_FIELDS(
561 ctf_integer(gva_t, gva, gva)
562 ctf_integer(gpa_t, gpa, gpa)
563 ctf_integer(bool, write, write)
564 ctf_integer(bool, gpa_match, gpa_match)
565 )
566 )
567
568 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,11,0))
569 LTTNG_TRACEPOINT_EVENT_MAP(kvm_write_tsc_offset, kvm_x86_write_tsc_offset,
570 TP_PROTO(unsigned int vcpu_id, __u64 previous_tsc_offset,
571 __u64 next_tsc_offset),
572 TP_ARGS(vcpu_id, previous_tsc_offset, next_tsc_offset),
573
574 TP_FIELDS(
575 ctf_integer(unsigned int, vcpu_id, vcpu_id)
576 ctf_integer(__u64, previous_tsc_offset, previous_tsc_offset)
577 ctf_integer(__u64, next_tsc_offset, next_tsc_offset)
578 )
579 )
580 #endif
581
582 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
583 #ifdef CONFIG_X86_64
584
585 LTTNG_TRACEPOINT_EVENT_MAP(kvm_update_master_clock, kvm_x86_update_master_clock,
586 TP_PROTO(bool use_master_clock, unsigned int host_clock, bool offset_matched),
587 TP_ARGS(use_master_clock, host_clock, offset_matched),
588
589 TP_FIELDS(
590 ctf_integer(bool, use_master_clock, use_master_clock)
591 ctf_integer(unsigned int, host_clock, host_clock)
592 ctf_integer(bool, offset_matched, offset_matched)
593 )
594 )
595
596 LTTNG_TRACEPOINT_EVENT_MAP(kvm_track_tsc, kvm_x86_track_tsc,
597 TP_PROTO(unsigned int vcpu_id, unsigned int nr_matched,
598 unsigned int online_vcpus, bool use_master_clock,
599 unsigned int host_clock),
600 TP_ARGS(vcpu_id, nr_matched, online_vcpus, use_master_clock,
601 host_clock),
602
603 TP_FIELDS(
604 ctf_integer(unsigned int, vcpu_id, vcpu_id)
605 ctf_integer(unsigned int, nr_vcpus_matched_tsc, nr_matched)
606 ctf_integer(unsigned int, online_vcpus, online_vcpus)
607 ctf_integer(bool, use_master_clock, use_master_clock)
608 ctf_integer(unsigned int, host_clock, host_clock)
609 )
610 )
611
612 #endif /* CONFIG_X86_64 */
613 #endif /* LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0) */
614
615 #endif /* LTTNG_TRACE_KVM_H */
616
617 #undef TRACE_INCLUDE_PATH
618 #define TRACE_INCLUDE_PATH instrumentation/events/arch/x86/kvm
619 #undef TRACE_INCLUDE_FILE
620 #define TRACE_INCLUDE_FILE trace
621
622 /* This part must be outside protection */
623 #include <lttng/define_trace.h>
This page took 0.041606 seconds and 4 git commands to generate.