Commit | Line | Data |
---|---|---|
9f36eaed | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
3bc29f0a MD |
2 | #if !defined(LTTNG_TRACE_KVM_H) || defined(TRACE_HEADER_MULTI_READ) |
3 | #define LTTNG_TRACE_KVM_H | |
b3c40230 | 4 | |
6ec43db8 | 5 | #include <probes/lttng-tracepoint-event.h> |
b3c40230 MG |
6 | #include <asm/vmx.h> |
7 | #include <asm/svm.h> | |
8170580a | 8 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) |
b3c40230 | 9 | #include <asm/clocksource.h> |
8170580a | 10 | #endif |
b3c40230 MG |
11 | #include <linux/version.h> |
12 | #include <../arch/x86/kvm/lapic.h> | |
13 | #include <../arch/x86/kvm/kvm_cache_regs.h> | |
14 | ||
15 | #undef TRACE_SYSTEM | |
b36bb1a8 | 16 | #define TRACE_SYSTEM kvm_x86 |
b3c40230 MG |
17 | |
18 | /* | |
19 | * Tracepoint for guest mode entry. | |
20 | */ | |
b36bb1a8 | 21 | LTTNG_TRACEPOINT_EVENT_MAP(kvm_entry, kvm_x86_entry, |
b3c40230 MG |
22 | TP_PROTO(unsigned int vcpu_id), |
23 | TP_ARGS(vcpu_id), | |
24 | ||
f127e61e MD |
25 | TP_FIELDS( |
26 | ctf_integer(unsigned int, vcpu_id, vcpu_id) | |
27 | ) | |
b3c40230 MG |
28 | ) |
29 | ||
30 | /* | |
31 | * Tracepoint for hypercall. | |
32 | */ | |
b36bb1a8 | 33 | LTTNG_TRACEPOINT_EVENT_MAP(kvm_hypercall, kvm_x86_hypercall, |
b3c40230 MG |
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 | ||
f127e61e MD |
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 | ) | |
b3c40230 MG |
45 | ) |
46 | ||
47 | /* | |
48 | * Tracepoint for hypercall. | |
49 | */ | |
b36bb1a8 | 50 | LTTNG_TRACEPOINT_EVENT_MAP(kvm_hv_hypercall, kvm_x86_hv_hypercall, |
b3c40230 MG |
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 | ||
f127e61e MD |
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 | ) | |
b3c40230 MG |
63 | ) |
64 | ||
65 | /* | |
66 | * Tracepoint for PIO. | |
67 | */ | |
b36bb1a8 | 68 | LTTNG_TRACEPOINT_EVENT_MAP(kvm_pio, kvm_x86_pio, |
b3c40230 MG |
69 | TP_PROTO(unsigned int rw, unsigned int port, unsigned int size, |
70 | unsigned int count), | |
71 | TP_ARGS(rw, port, size, count), | |
72 | ||
f127e61e MD |
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 | ) | |
b3c40230 MG |
79 | ) |
80 | ||
81 | /* | |
82 | * Tracepoint for cpuid. | |
83 | */ | |
b36bb1a8 | 84 | LTTNG_TRACEPOINT_EVENT_MAP(kvm_cpuid, kvm_x86_cpuid, |
b3c40230 MG |
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 | ||
f127e61e MD |
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 | ) | |
b3c40230 MG |
96 | ) |
97 | ||
b3c40230 MG |
98 | /* |
99 | * Tracepoint for apic access. | |
100 | */ | |
b36bb1a8 | 101 | LTTNG_TRACEPOINT_EVENT_MAP(kvm_apic, kvm_x86_apic, |
b3c40230 MG |
102 | TP_PROTO(unsigned int rw, unsigned int reg, unsigned int val), |
103 | TP_ARGS(rw, reg, val), | |
104 | ||
f127e61e MD |
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 | ) | |
b3c40230 MG |
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 | ||
b3c40230 MG |
115 | /* |
116 | * Tracepoint for kvm guest exit: | |
117 | */ | |
b36bb1a8 | 118 | LTTNG_TRACEPOINT_EVENT_CODE_MAP(kvm_exit, kvm_x86_exit, |
f127e61e MD |
119 | TP_PROTO(unsigned int exit_reason, struct kvm_vcpu *vcpu, u32 isa), |
120 | TP_ARGS(exit_reason, vcpu, isa), | |
121 | ||
122 | TP_locvar( | |
123 | u64 info1, info2; | |
b3c40230 MG |
124 | ), |
125 | ||
265822ae | 126 | TP_code_pre( |
f127e61e MD |
127 | kvm_x86_ops->get_exit_info(vcpu, &tp_locvar->info1, |
128 | &tp_locvar->info2); | |
b3c40230 MG |
129 | ), |
130 | ||
f127e61e MD |
131 | TP_FIELDS( |
132 | ctf_integer(unsigned int, exit_reason, exit_reason) | |
133 | ctf_integer(unsigned long, guest_rip, kvm_rip_read(vcpu)) | |
134 | ctf_integer(u32, isa, isa) | |
135 | ctf_integer(u64, info1, tp_locvar->info1) | |
136 | ctf_integer(u64, info2, tp_locvar->info2) | |
265822ae MD |
137 | ), |
138 | ||
139 | TP_code_post() | |
b3c40230 MG |
140 | ) |
141 | ||
142 | /* | |
143 | * Tracepoint for kvm interrupt injection: | |
144 | */ | |
b36bb1a8 | 145 | LTTNG_TRACEPOINT_EVENT_MAP(kvm_inj_virq, kvm_x86_inj_virq, |
b3c40230 MG |
146 | TP_PROTO(unsigned int irq), |
147 | TP_ARGS(irq), | |
148 | ||
f127e61e MD |
149 | TP_FIELDS( |
150 | ctf_integer(unsigned int, irq, irq) | |
151 | ) | |
b3c40230 MG |
152 | ) |
153 | ||
b3c40230 MG |
154 | /* |
155 | * Tracepoint for kvm interrupt injection: | |
156 | */ | |
b36bb1a8 | 157 | LTTNG_TRACEPOINT_EVENT_MAP(kvm_inj_exception, kvm_x86_inj_exception, |
b3c40230 MG |
158 | TP_PROTO(unsigned exception, bool has_error, unsigned error_code), |
159 | TP_ARGS(exception, has_error, error_code), | |
160 | ||
f127e61e MD |
161 | TP_FIELDS( |
162 | ctf_integer(u8, exception, exception) | |
163 | ctf_integer(u8, has_error, has_error) | |
164 | ctf_integer(u32, error_code, error_code) | |
165 | ) | |
b3c40230 MG |
166 | ) |
167 | ||
168 | /* | |
169 | * Tracepoint for page fault. | |
170 | */ | |
b36bb1a8 | 171 | LTTNG_TRACEPOINT_EVENT_MAP(kvm_page_fault, kvm_x86_page_fault, |
b3c40230 MG |
172 | TP_PROTO(unsigned long fault_address, unsigned int error_code), |
173 | TP_ARGS(fault_address, error_code), | |
174 | ||
f127e61e MD |
175 | TP_FIELDS( |
176 | ctf_integer(unsigned long, fault_address, fault_address) | |
177 | ctf_integer(unsigned int, error_code, error_code) | |
178 | ) | |
b3c40230 MG |
179 | ) |
180 | ||
181 | /* | |
182 | * Tracepoint for guest MSR access. | |
183 | */ | |
b36bb1a8 | 184 | LTTNG_TRACEPOINT_EVENT_MAP(kvm_msr, kvm_x86_msr, |
b3c40230 MG |
185 | TP_PROTO(unsigned write, u32 ecx, u64 data, bool exception), |
186 | TP_ARGS(write, ecx, data, exception), | |
187 | ||
f127e61e MD |
188 | TP_FIELDS( |
189 | ctf_integer(unsigned, write, write) | |
190 | ctf_integer(u32, ecx, ecx) | |
191 | ctf_integer(u64, data, data) | |
192 | ctf_integer(u8, exception, exception) | |
193 | ) | |
b3c40230 MG |
194 | ) |
195 | ||
196 | #define trace_kvm_msr_read(ecx, data) trace_kvm_msr(0, ecx, data, false) | |
197 | #define trace_kvm_msr_write(ecx, data) trace_kvm_msr(1, ecx, data, false) | |
198 | #define trace_kvm_msr_read_ex(ecx) trace_kvm_msr(0, ecx, 0, true) | |
199 | #define trace_kvm_msr_write_ex(ecx, data) trace_kvm_msr(1, ecx, data, true) | |
200 | ||
201 | /* | |
202 | * Tracepoint for guest CR access. | |
203 | */ | |
b36bb1a8 | 204 | LTTNG_TRACEPOINT_EVENT_MAP(kvm_cr, kvm_x86_cr, |
b3c40230 MG |
205 | TP_PROTO(unsigned int rw, unsigned int cr, unsigned long val), |
206 | TP_ARGS(rw, cr, val), | |
207 | ||
f127e61e MD |
208 | TP_FIELDS( |
209 | ctf_integer(unsigned int, rw, rw) | |
210 | ctf_integer(unsigned int, cr, cr) | |
211 | ctf_integer(unsigned long, val, val) | |
212 | ) | |
b3c40230 MG |
213 | ) |
214 | ||
215 | #define trace_kvm_cr_read(cr, val) trace_kvm_cr(0, cr, val) | |
216 | #define trace_kvm_cr_write(cr, val) trace_kvm_cr(1, cr, val) | |
217 | ||
b36bb1a8 | 218 | LTTNG_TRACEPOINT_EVENT_MAP(kvm_pic_set_irq, kvm_x86_pic_set_irq, |
b3c40230 MG |
219 | TP_PROTO(__u8 chip, __u8 pin, __u8 elcr, __u8 imr, bool coalesced), |
220 | TP_ARGS(chip, pin, elcr, imr, coalesced), | |
221 | ||
f127e61e MD |
222 | TP_FIELDS( |
223 | ctf_integer(__u8, chip, chip) | |
224 | ctf_integer(__u8, pin, pin) | |
225 | ctf_integer(__u8, elcr, elcr) | |
226 | ctf_integer(__u8, imr, imr) | |
227 | ctf_integer(bool, coalesced, coalesced) | |
228 | ) | |
b3c40230 MG |
229 | ) |
230 | ||
b36bb1a8 | 231 | LTTNG_TRACEPOINT_EVENT_MAP(kvm_apic_ipi, kvm_x86_apic_ipi, |
b3c40230 MG |
232 | TP_PROTO(__u32 icr_low, __u32 dest_id), |
233 | TP_ARGS(icr_low, dest_id), | |
234 | ||
f127e61e MD |
235 | TP_FIELDS( |
236 | ctf_integer(__u32, icr_low, icr_low) | |
237 | ctf_integer(__u32, dest_id, dest_id) | |
238 | ) | |
b3c40230 MG |
239 | ) |
240 | ||
b36bb1a8 | 241 | LTTNG_TRACEPOINT_EVENT_MAP(kvm_apic_accept_irq, kvm_x86_apic_accept_irq, |
b3c40230 MG |
242 | TP_PROTO(__u32 apicid, __u16 dm, __u8 tm, __u8 vec, bool coalesced), |
243 | TP_ARGS(apicid, dm, tm, vec, coalesced), | |
244 | ||
f127e61e MD |
245 | TP_FIELDS( |
246 | ctf_integer(__u32, apicid, apicid) | |
247 | ctf_integer(__u16, dm, dm) | |
248 | ctf_integer(__u8, tm, tm) | |
249 | ctf_integer(__u8, vec, vec) | |
250 | ctf_integer(bool, coalesced, coalesced) | |
251 | ) | |
b3c40230 MG |
252 | ) |
253 | ||
b36bb1a8 | 254 | LTTNG_TRACEPOINT_EVENT_MAP(kvm_eoi, kvm_x86_eoi, |
b3c40230 MG |
255 | TP_PROTO(struct kvm_lapic *apic, int vector), |
256 | TP_ARGS(apic, vector), | |
257 | ||
f127e61e MD |
258 | TP_FIELDS( |
259 | ctf_integer(__u32, apicid, apic->vcpu->vcpu_id) | |
260 | ctf_integer(int, vector, vector) | |
261 | ) | |
b3c40230 MG |
262 | ) |
263 | ||
b36bb1a8 | 264 | LTTNG_TRACEPOINT_EVENT_MAP(kvm_pv_eoi, kvm_x86_pv_eoi, |
b3c40230 MG |
265 | TP_PROTO(struct kvm_lapic *apic, int vector), |
266 | TP_ARGS(apic, vector), | |
267 | ||
f127e61e MD |
268 | TP_FIELDS( |
269 | ctf_integer(__u32, apicid, apic->vcpu->vcpu_id) | |
270 | ctf_integer(int, vector, vector) | |
271 | ) | |
b3c40230 MG |
272 | ) |
273 | ||
274 | /* | |
275 | * Tracepoint for nested VMRUN | |
276 | */ | |
b36bb1a8 | 277 | LTTNG_TRACEPOINT_EVENT_MAP(kvm_nested_vmrun, kvm_x86_nested_vmrun, |
b3c40230 MG |
278 | TP_PROTO(__u64 rip, __u64 vmcb, __u64 nested_rip, __u32 int_ctl, |
279 | __u32 event_inj, bool npt), | |
280 | TP_ARGS(rip, vmcb, nested_rip, int_ctl, event_inj, npt), | |
281 | ||
f127e61e MD |
282 | TP_FIELDS( |
283 | ctf_integer(__u64, rip, rip) | |
284 | ctf_integer(__u64, vmcb, vmcb) | |
285 | ctf_integer(__u64, nested_rip, nested_rip) | |
286 | ctf_integer(__u32, int_ctl, int_ctl) | |
287 | ctf_integer(__u32, event_inj, event_inj) | |
288 | ctf_integer(bool, npt, npt) | |
289 | ) | |
b3c40230 MG |
290 | ) |
291 | ||
b36bb1a8 | 292 | LTTNG_TRACEPOINT_EVENT_MAP(kvm_nested_intercepts, kvm_x86_nested_intercepts, |
b3c40230 MG |
293 | TP_PROTO(__u16 cr_read, __u16 cr_write, __u32 exceptions, __u64 intercept), |
294 | TP_ARGS(cr_read, cr_write, exceptions, intercept), | |
295 | ||
f127e61e MD |
296 | TP_FIELDS( |
297 | ctf_integer(__u16, cr_read, cr_read) | |
298 | ctf_integer(__u16, cr_write, cr_write) | |
299 | ctf_integer(__u32, exceptions, exceptions) | |
300 | ctf_integer(__u64, intercept, intercept) | |
301 | ) | |
b3c40230 MG |
302 | ) |
303 | /* | |
304 | * Tracepoint for #VMEXIT while nested | |
305 | */ | |
b36bb1a8 | 306 | LTTNG_TRACEPOINT_EVENT_MAP(kvm_nested_vmexit, kvm_x86_nested_vmexit, |
b3c40230 MG |
307 | TP_PROTO(__u64 rip, __u32 exit_code, |
308 | __u64 exit_info1, __u64 exit_info2, | |
309 | __u32 exit_int_info, __u32 exit_int_info_err, __u32 isa), | |
310 | TP_ARGS(rip, exit_code, exit_info1, exit_info2, | |
311 | exit_int_info, exit_int_info_err, isa), | |
312 | ||
f127e61e MD |
313 | TP_FIELDS( |
314 | ctf_integer(__u64, rip, rip) | |
315 | ctf_integer(__u32, exit_code, exit_code) | |
316 | ctf_integer(__u64, exit_info1, exit_info1) | |
317 | ctf_integer(__u64, exit_info2, exit_info2) | |
318 | ctf_integer(__u32, exit_int_info, exit_int_info) | |
319 | ctf_integer(__u32, exit_int_info_err, exit_int_info_err) | |
320 | ctf_integer(__u32, isa, isa) | |
321 | ) | |
b3c40230 MG |
322 | ) |
323 | ||
324 | /* | |
325 | * Tracepoint for #VMEXIT reinjected to the guest | |
326 | */ | |
b36bb1a8 | 327 | LTTNG_TRACEPOINT_EVENT_MAP(kvm_nested_vmexit_inject, kvm_x86_nested_vmexit_inject, |
b3c40230 MG |
328 | TP_PROTO(__u32 exit_code, |
329 | __u64 exit_info1, __u64 exit_info2, | |
330 | __u32 exit_int_info, __u32 exit_int_info_err, __u32 isa), | |
331 | TP_ARGS(exit_code, exit_info1, exit_info2, | |
332 | exit_int_info, exit_int_info_err, isa), | |
333 | ||
f127e61e MD |
334 | TP_FIELDS( |
335 | ctf_integer(__u32, exit_code, exit_code) | |
336 | ctf_integer(__u64, exit_info1, exit_info1) | |
337 | ctf_integer(__u64, exit_info2, exit_info2) | |
338 | ctf_integer(__u32, exit_int_info, exit_int_info) | |
339 | ctf_integer(__u32, exit_int_info_err, exit_int_info_err) | |
340 | ctf_integer(__u32, isa, isa) | |
341 | ) | |
b3c40230 MG |
342 | ) |
343 | ||
344 | /* | |
345 | * Tracepoint for nested #vmexit because of interrupt pending | |
346 | */ | |
b36bb1a8 | 347 | LTTNG_TRACEPOINT_EVENT_MAP(kvm_nested_intr_vmexit, kvm_x86_nested_intr_vmexit, |
b3c40230 MG |
348 | TP_PROTO(__u64 rip), |
349 | TP_ARGS(rip), | |
350 | ||
f127e61e MD |
351 | TP_FIELDS( |
352 | ctf_integer(__u64, rip, rip) | |
353 | ) | |
b3c40230 MG |
354 | ) |
355 | ||
356 | /* | |
357 | * Tracepoint for nested #vmexit because of interrupt pending | |
358 | */ | |
b36bb1a8 | 359 | LTTNG_TRACEPOINT_EVENT_MAP(kvm_invlpga, kvm_x86_invlpga, |
b3c40230 MG |
360 | TP_PROTO(__u64 rip, int asid, u64 address), |
361 | TP_ARGS(rip, asid, address), | |
362 | ||
f127e61e MD |
363 | TP_FIELDS( |
364 | ctf_integer(__u64, rip, rip) | |
365 | ctf_integer(int, asid, asid) | |
366 | ctf_integer(__u64, address, address) | |
367 | ) | |
b3c40230 MG |
368 | ) |
369 | ||
370 | /* | |
371 | * Tracepoint for nested #vmexit because of interrupt pending | |
372 | */ | |
b36bb1a8 | 373 | LTTNG_TRACEPOINT_EVENT_MAP(kvm_skinit, kvm_x86_skinit, |
b3c40230 MG |
374 | TP_PROTO(__u64 rip, __u32 slb), |
375 | TP_ARGS(rip, slb), | |
376 | ||
f127e61e MD |
377 | TP_FIELDS( |
378 | ctf_integer(__u64, rip, rip) | |
379 | ctf_integer(__u32, slb, slb) | |
380 | ) | |
b3c40230 MG |
381 | ) |
382 | ||
383 | #define KVM_EMUL_INSN_F_CR0_PE (1 << 0) | |
384 | #define KVM_EMUL_INSN_F_EFL_VM (1 << 1) | |
385 | #define KVM_EMUL_INSN_F_CS_D (1 << 2) | |
386 | #define KVM_EMUL_INSN_F_CS_L (1 << 3) | |
387 | ||
388 | #define kvm_trace_symbol_emul_flags \ | |
389 | { 0, "real" }, \ | |
390 | { KVM_EMUL_INSN_F_CR0_PE \ | |
391 | | KVM_EMUL_INSN_F_EFL_VM, "vm16" }, \ | |
392 | { KVM_EMUL_INSN_F_CR0_PE, "prot16" }, \ | |
393 | { KVM_EMUL_INSN_F_CR0_PE \ | |
394 | | KVM_EMUL_INSN_F_CS_D, "prot32" }, \ | |
395 | { KVM_EMUL_INSN_F_CR0_PE \ | |
396 | | KVM_EMUL_INSN_F_CS_L, "prot64" } | |
397 | ||
398 | #define kei_decode_mode(mode) ({ \ | |
399 | u8 flags = 0xff; \ | |
400 | switch (mode) { \ | |
401 | case X86EMUL_MODE_REAL: \ | |
402 | flags = 0; \ | |
403 | break; \ | |
404 | case X86EMUL_MODE_VM86: \ | |
405 | flags = KVM_EMUL_INSN_F_EFL_VM; \ | |
406 | break; \ | |
407 | case X86EMUL_MODE_PROT16: \ | |
408 | flags = KVM_EMUL_INSN_F_CR0_PE; \ | |
409 | break; \ | |
410 | case X86EMUL_MODE_PROT32: \ | |
411 | flags = KVM_EMUL_INSN_F_CR0_PE \ | |
412 | | KVM_EMUL_INSN_F_CS_D; \ | |
413 | break; \ | |
414 | case X86EMUL_MODE_PROT64: \ | |
415 | flags = KVM_EMUL_INSN_F_CR0_PE \ | |
416 | | KVM_EMUL_INSN_F_CS_L; \ | |
417 | break; \ | |
418 | } \ | |
419 | flags; \ | |
420 | }) | |
421 | ||
b36bb1a8 | 422 | LTTNG_TRACEPOINT_EVENT_MAP(kvm_emulate_insn, kvm_x86_emulate_insn, |
b3c40230 MG |
423 | TP_PROTO(struct kvm_vcpu *vcpu, __u8 failed), |
424 | TP_ARGS(vcpu, failed), | |
425 | ||
f127e61e | 426 | TP_FIELDS( |
8170580a | 427 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)) |
f127e61e MD |
428 | ctf_integer(__u64, rip, vcpu->arch.emulate_ctxt.decode.fetch.start) |
429 | ctf_integer(__u32, csbase, kvm_x86_ops->get_segment_base(vcpu, VCPU_SREG_CS)) | |
430 | ctf_integer(__u8, len, vcpu->arch.emulate_ctxt.decode.eip | |
431 | - vcpu->arch.emulate_ctxt.decode.fetch.start) | |
432 | ctf_array(__u8, insn, vcpu->arch.emulate_ctxt.decode.fetch.data, 15) | |
458c2022 | 433 | #elif (LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0)) |
f127e61e MD |
434 | ctf_integer(__u64, rip, vcpu->arch.emulate_ctxt.fetch.start) |
435 | ctf_integer(__u32, csbase, kvm_x86_ops->get_segment_base(vcpu, VCPU_SREG_CS)) | |
436 | ctf_integer(__u8, len, vcpu->arch.emulate_ctxt._eip | |
437 | - vcpu->arch.emulate_ctxt.fetch.start) | |
438 | ctf_array(__u8, insn, vcpu->arch.emulate_ctxt.fetch.data, 15) | |
458c2022 | 439 | #else |
f127e61e MD |
440 | ctf_integer(__u64, rip, vcpu->arch.emulate_ctxt._eip - |
441 | (vcpu->arch.emulate_ctxt.fetch.ptr - | |
442 | vcpu->arch.emulate_ctxt.fetch.data)) | |
443 | ctf_integer(__u32, csbase, kvm_x86_ops->get_segment_base(vcpu, VCPU_SREG_CS)) | |
444 | ctf_integer(__u8, len, vcpu->arch.emulate_ctxt.fetch.ptr - | |
445 | vcpu->arch.emulate_ctxt.fetch.data) | |
446 | ctf_array(__u8, insn, vcpu->arch.emulate_ctxt.fetch.data, 15) | |
8170580a | 447 | #endif |
f127e61e MD |
448 | ctf_integer(__u8, flags, kei_decode_mode(vcpu->arch.emulate_ctxt.mode)) |
449 | ctf_integer(__u8, failed, failed) | |
b3c40230 | 450 | ) |
f127e61e | 451 | ) |
b3c40230 MG |
452 | |
453 | #define trace_kvm_emulate_insn_start(vcpu) trace_kvm_emulate_insn(vcpu, 0) | |
454 | #define trace_kvm_emulate_insn_failed(vcpu) trace_kvm_emulate_insn(vcpu, 1) | |
455 | ||
b36bb1a8 MD |
456 | LTTNG_TRACEPOINT_EVENT_MAP( |
457 | vcpu_match_mmio, kvm_x86_vcpu_match_mmio, | |
b3c40230 MG |
458 | TP_PROTO(gva_t gva, gpa_t gpa, bool write, bool gpa_match), |
459 | TP_ARGS(gva, gpa, write, gpa_match), | |
460 | ||
f127e61e MD |
461 | TP_FIELDS( |
462 | ctf_integer(gva_t, gva, gva) | |
463 | ctf_integer(gpa_t, gpa, gpa) | |
464 | ctf_integer(bool, write, write) | |
465 | ctf_integer(bool, gpa_match, gpa_match) | |
466 | ) | |
b3c40230 MG |
467 | ) |
468 | ||
026e6902 | 469 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)) |
b36bb1a8 | 470 | LTTNG_TRACEPOINT_EVENT_MAP(kvm_write_tsc_offset, kvm_x86_write_tsc_offset, |
026e6902 MG |
471 | TP_PROTO(unsigned int vcpu_id, __u64 previous_tsc_offset, |
472 | __u64 next_tsc_offset), | |
473 | TP_ARGS(vcpu_id, previous_tsc_offset, next_tsc_offset), | |
474 | ||
f127e61e MD |
475 | TP_FIELDS( |
476 | ctf_integer(unsigned int, vcpu_id, vcpu_id) | |
477 | ctf_integer(__u64, previous_tsc_offset, previous_tsc_offset) | |
478 | ctf_integer(__u64, next_tsc_offset, next_tsc_offset) | |
479 | ) | |
026e6902 MG |
480 | ) |
481 | #endif | |
482 | ||
8170580a | 483 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) |
b3c40230 MG |
484 | #ifdef CONFIG_X86_64 |
485 | ||
b36bb1a8 | 486 | LTTNG_TRACEPOINT_EVENT_MAP(kvm_update_master_clock, kvm_x86_update_master_clock, |
b3c40230 MG |
487 | TP_PROTO(bool use_master_clock, unsigned int host_clock, bool offset_matched), |
488 | TP_ARGS(use_master_clock, host_clock, offset_matched), | |
489 | ||
f127e61e MD |
490 | TP_FIELDS( |
491 | ctf_integer(bool, use_master_clock, use_master_clock) | |
492 | ctf_integer(unsigned int, host_clock, host_clock) | |
493 | ctf_integer(bool, offset_matched, offset_matched) | |
494 | ) | |
b3c40230 MG |
495 | ) |
496 | ||
b36bb1a8 | 497 | LTTNG_TRACEPOINT_EVENT_MAP(kvm_track_tsc, kvm_x86_track_tsc, |
b3c40230 MG |
498 | TP_PROTO(unsigned int vcpu_id, unsigned int nr_matched, |
499 | unsigned int online_vcpus, bool use_master_clock, | |
500 | unsigned int host_clock), | |
501 | TP_ARGS(vcpu_id, nr_matched, online_vcpus, use_master_clock, | |
502 | host_clock), | |
503 | ||
f127e61e MD |
504 | TP_FIELDS( |
505 | ctf_integer(unsigned int, vcpu_id, vcpu_id) | |
506 | ctf_integer(unsigned int, nr_vcpus_matched_tsc, nr_matched) | |
507 | ctf_integer(unsigned int, online_vcpus, online_vcpus) | |
508 | ctf_integer(bool, use_master_clock, use_master_clock) | |
509 | ctf_integer(unsigned int, host_clock, host_clock) | |
510 | ) | |
b3c40230 MG |
511 | ) |
512 | ||
513 | #endif /* CONFIG_X86_64 */ | |
8170580a | 514 | #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0) */ |
b3c40230 | 515 | |
3bc29f0a | 516 | #endif /* LTTNG_TRACE_KVM_H */ |
b3c40230 MG |
517 | |
518 | #undef TRACE_INCLUDE_PATH | |
c075712b | 519 | #define TRACE_INCLUDE_PATH instrumentation/events/lttng-module/arch/x86/kvm |
b3c40230 MG |
520 | #undef TRACE_INCLUDE_FILE |
521 | #define TRACE_INCLUDE_FILE trace | |
522 | ||
523 | /* This part must be outside protection */ | |
6ec43db8 | 524 | #include <probes/define_trace.h> |