1 /* SPDX-License-Identifier: GPL-2.0 */
2 #if !defined(_TRACE_ARM_ARM64_KVM_H) || defined(TRACE_HEADER_MULTI_READ)
3 #define _TRACE_ARM_ARM64_KVM_H
5 #include <kvm/arm_arch_timer.h>
6 #include <linux/tracepoint.h>
9 #define TRACE_SYSTEM kvm
12 * Tracepoints for entry/exit to guest
14 TRACE_EVENT(kvm_entry
,
15 TP_PROTO(unsigned long vcpu_pc
),
19 __field( unsigned long, vcpu_pc
)
23 __entry
->vcpu_pc
= vcpu_pc
;
26 TP_printk("PC: 0x%016lx", __entry
->vcpu_pc
)
30 TP_PROTO(int ret
, unsigned int esr_ec
, unsigned long vcpu_pc
),
31 TP_ARGS(ret
, esr_ec
, vcpu_pc
),
35 __field( unsigned int, esr_ec
)
36 __field( unsigned long, vcpu_pc
)
40 __entry
->ret
= ARM_EXCEPTION_CODE(ret
);
41 __entry
->esr_ec
= ARM_EXCEPTION_IS_TRAP(ret
) ? esr_ec
: 0;
42 __entry
->vcpu_pc
= vcpu_pc
;
45 TP_printk("%s: HSR_EC: 0x%04x (%s), PC: 0x%016lx",
46 __print_symbolic(__entry
->ret
, kvm_arm_exception_type
),
48 __print_symbolic(__entry
->esr_ec
, kvm_arm_exception_class
),
52 TRACE_EVENT(kvm_guest_fault
,
53 TP_PROTO(unsigned long vcpu_pc
, unsigned long hsr
,
55 unsigned long long ipa
),
56 TP_ARGS(vcpu_pc
, hsr
, hxfar
, ipa
),
59 __field( unsigned long, vcpu_pc
)
60 __field( unsigned long, hsr
)
61 __field( unsigned long, hxfar
)
62 __field( unsigned long long, ipa
)
66 __entry
->vcpu_pc
= vcpu_pc
;
68 __entry
->hxfar
= hxfar
;
72 TP_printk("ipa %#llx, hsr %#08lx, hxfar %#08lx, pc %#016lx",
73 __entry
->ipa
, __entry
->hsr
,
74 __entry
->hxfar
, __entry
->vcpu_pc
)
77 TRACE_EVENT(kvm_access_fault
,
78 TP_PROTO(unsigned long ipa
),
82 __field( unsigned long, ipa
)
89 TP_printk("IPA: %lx", __entry
->ipa
)
92 TRACE_EVENT(kvm_irq_line
,
93 TP_PROTO(unsigned int type
, int vcpu_idx
, int irq_num
, int level
),
94 TP_ARGS(type
, vcpu_idx
, irq_num
, level
),
97 __field( unsigned int, type
)
98 __field( int, vcpu_idx
)
99 __field( int, irq_num
)
100 __field( int, level
)
104 __entry
->type
= type
;
105 __entry
->vcpu_idx
= vcpu_idx
;
106 __entry
->irq_num
= irq_num
;
107 __entry
->level
= level
;
110 TP_printk("Inject %s interrupt (%d), vcpu->idx: %d, num: %d, level: %d",
111 (__entry
->type
== KVM_ARM_IRQ_TYPE_CPU
) ? "CPU" :
112 (__entry
->type
== KVM_ARM_IRQ_TYPE_PPI
) ? "VGIC PPI" :
113 (__entry
->type
== KVM_ARM_IRQ_TYPE_SPI
) ? "VGIC SPI" : "UNKNOWN",
114 __entry
->type
, __entry
->vcpu_idx
, __entry
->irq_num
, __entry
->level
)
117 TRACE_EVENT(kvm_mmio_emulate
,
118 TP_PROTO(unsigned long vcpu_pc
, unsigned long instr
,
120 TP_ARGS(vcpu_pc
, instr
, cpsr
),
123 __field( unsigned long, vcpu_pc
)
124 __field( unsigned long, instr
)
125 __field( unsigned long, cpsr
)
129 __entry
->vcpu_pc
= vcpu_pc
;
130 __entry
->instr
= instr
;
131 __entry
->cpsr
= cpsr
;
134 TP_printk("Emulate MMIO at: 0x%016lx (instr: %08lx, cpsr: %08lx)",
135 __entry
->vcpu_pc
, __entry
->instr
, __entry
->cpsr
)
138 TRACE_EVENT(kvm_unmap_hva_range
,
139 TP_PROTO(unsigned long start
, unsigned long end
),
143 __field( unsigned long, start
)
144 __field( unsigned long, end
)
148 __entry
->start
= start
;
152 TP_printk("mmu notifier unmap range: %#016lx -- %#016lx",
153 __entry
->start
, __entry
->end
)
156 TRACE_EVENT(kvm_set_spte_hva
,
157 TP_PROTO(unsigned long hva
),
161 __field( unsigned long, hva
)
168 TP_printk("mmu notifier set pte hva: %#016lx", __entry
->hva
)
171 TRACE_EVENT(kvm_age_hva
,
172 TP_PROTO(unsigned long start
, unsigned long end
),
176 __field( unsigned long, start
)
177 __field( unsigned long, end
)
181 __entry
->start
= start
;
185 TP_printk("mmu notifier age hva: %#016lx -- %#016lx",
186 __entry
->start
, __entry
->end
)
189 TRACE_EVENT(kvm_test_age_hva
,
190 TP_PROTO(unsigned long hva
),
194 __field( unsigned long, hva
)
201 TP_printk("mmu notifier test age hva: %#016lx", __entry
->hva
)
204 TRACE_EVENT(kvm_set_way_flush
,
205 TP_PROTO(unsigned long vcpu_pc
, bool cache
),
206 TP_ARGS(vcpu_pc
, cache
),
209 __field( unsigned long, vcpu_pc
)
210 __field( bool, cache
)
214 __entry
->vcpu_pc
= vcpu_pc
;
215 __entry
->cache
= cache
;
218 TP_printk("S/W flush at 0x%016lx (cache %s)",
219 __entry
->vcpu_pc
, __entry
->cache
? "on" : "off")
222 TRACE_EVENT(kvm_toggle_cache
,
223 TP_PROTO(unsigned long vcpu_pc
, bool was
, bool now
),
224 TP_ARGS(vcpu_pc
, was
, now
),
227 __field( unsigned long, vcpu_pc
)
233 __entry
->vcpu_pc
= vcpu_pc
;
238 TP_printk("VM op at 0x%016lx (cache was %s, now %s)",
239 __entry
->vcpu_pc
, __entry
->was
? "on" : "off",
240 __entry
->now
? "on" : "off")
244 * Tracepoints for arch_timer
246 TRACE_EVENT(kvm_timer_update_irq
,
247 TP_PROTO(unsigned long vcpu_id
, __u32 irq
, int level
),
248 TP_ARGS(vcpu_id
, irq
, level
),
251 __field( unsigned long, vcpu_id
)
252 __field( __u32
, irq
)
253 __field( int, level
)
257 __entry
->vcpu_id
= vcpu_id
;
259 __entry
->level
= level
;
262 TP_printk("VCPU: %ld, IRQ %d, level %d",
263 __entry
->vcpu_id
, __entry
->irq
, __entry
->level
)
266 TRACE_EVENT(kvm_get_timer_map
,
267 TP_PROTO(unsigned long vcpu_id
, struct timer_map
*map
),
268 TP_ARGS(vcpu_id
, map
),
271 __field( unsigned long, vcpu_id
)
272 __field( int, direct_vtimer
)
273 __field( int, direct_ptimer
)
274 __field( int, emul_ptimer
)
278 __entry
->vcpu_id
= vcpu_id
;
279 __entry
->direct_vtimer
= arch_timer_ctx_index(map
->direct_vtimer
);
280 __entry
->direct_ptimer
=
281 (map
->direct_ptimer
) ? arch_timer_ctx_index(map
->direct_ptimer
) : -1;
282 __entry
->emul_ptimer
=
283 (map
->emul_ptimer
) ? arch_timer_ctx_index(map
->emul_ptimer
) : -1;
286 TP_printk("VCPU: %ld, dv: %d, dp: %d, ep: %d",
288 __entry
->direct_vtimer
,
289 __entry
->direct_ptimer
,
290 __entry
->emul_ptimer
)
293 TRACE_EVENT(kvm_timer_save_state
,
294 TP_PROTO(struct arch_timer_context
*ctx
),
298 __field( unsigned long, ctl
)
299 __field( unsigned long long, cval
)
300 __field( int, timer_idx
)
304 __entry
->ctl
= timer_get_ctl(ctx
);
305 __entry
->cval
= timer_get_cval(ctx
);
306 __entry
->timer_idx
= arch_timer_ctx_index(ctx
);
309 TP_printk(" CTL: %#08lx CVAL: %#16llx arch_timer_ctx_index: %d",
315 TRACE_EVENT(kvm_timer_restore_state
,
316 TP_PROTO(struct arch_timer_context
*ctx
),
320 __field( unsigned long, ctl
)
321 __field( unsigned long long, cval
)
322 __field( int, timer_idx
)
326 __entry
->ctl
= timer_get_ctl(ctx
);
327 __entry
->cval
= timer_get_cval(ctx
);
328 __entry
->timer_idx
= arch_timer_ctx_index(ctx
);
331 TP_printk("CTL: %#08lx CVAL: %#16llx arch_timer_ctx_index: %d",
337 TRACE_EVENT(kvm_timer_hrtimer_expire
,
338 TP_PROTO(struct arch_timer_context
*ctx
),
342 __field( int, timer_idx
)
346 __entry
->timer_idx
= arch_timer_ctx_index(ctx
);
349 TP_printk("arch_timer_ctx_index: %d", __entry
->timer_idx
)
352 TRACE_EVENT(kvm_timer_emulate
,
353 TP_PROTO(struct arch_timer_context
*ctx
, bool should_fire
),
354 TP_ARGS(ctx
, should_fire
),
357 __field( int, timer_idx
)
358 __field( bool, should_fire
)
362 __entry
->timer_idx
= arch_timer_ctx_index(ctx
);
363 __entry
->should_fire
= should_fire
;
366 TP_printk("arch_timer_ctx_index: %d (should_fire: %d)",
367 __entry
->timer_idx
, __entry
->should_fire
)
370 #endif /* _TRACE_ARM_ARM64_KVM_H */
372 #undef TRACE_INCLUDE_PATH
373 #define TRACE_INCLUDE_PATH .
374 #undef TRACE_INCLUDE_FILE
375 #define TRACE_INCLUDE_FILE trace_arm
377 /* This part must be outside protection */
378 #include <trace/define_trace.h>