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_set_way_flush,
139 TP_PROTO(unsigned long vcpu_pc, bool cache),
140 TP_ARGS(vcpu_pc, cache),
143 __field( unsigned long, vcpu_pc )
144 __field( bool, cache )
148 __entry->vcpu_pc = vcpu_pc;
149 __entry->cache = cache;
152 TP_printk("S/W flush at 0x%016lx (cache %s)",
153 __entry->vcpu_pc, __entry->cache ? "on" : "off")
156 TRACE_EVENT(kvm_toggle_cache,
157 TP_PROTO(unsigned long vcpu_pc, bool was, bool now),
158 TP_ARGS(vcpu_pc, was, now),
161 __field( unsigned long, vcpu_pc )
167 __entry->vcpu_pc = vcpu_pc;
172 TP_printk("VM op at 0x%016lx (cache was %s, now %s)",
173 __entry->vcpu_pc, __entry->was ? "on" : "off",
174 __entry->now ? "on" : "off")
178 * Tracepoints for arch_timer
180 TRACE_EVENT(kvm_timer_update_irq,
181 TP_PROTO(unsigned long vcpu_id, __u32 irq, int level),
182 TP_ARGS(vcpu_id, irq, level),
185 __field( unsigned long, vcpu_id )
186 __field( __u32, irq )
187 __field( int, level )
191 __entry->vcpu_id = vcpu_id;
193 __entry->level = level;
196 TP_printk("VCPU: %ld, IRQ %d, level %d",
197 __entry->vcpu_id, __entry->irq, __entry->level)
200 TRACE_EVENT(kvm_get_timer_map,
201 TP_PROTO(unsigned long vcpu_id, struct timer_map *map),
202 TP_ARGS(vcpu_id, map),
205 __field( unsigned long, vcpu_id )
206 __field( int, direct_vtimer )
207 __field( int, direct_ptimer )
208 __field( int, emul_ptimer )
212 __entry->vcpu_id = vcpu_id;
213 __entry->direct_vtimer = arch_timer_ctx_index(map->direct_vtimer);
214 __entry->direct_ptimer =
215 (map->direct_ptimer) ? arch_timer_ctx_index(map->direct_ptimer) : -1;
216 __entry->emul_ptimer =
217 (map->emul_ptimer) ? arch_timer_ctx_index(map->emul_ptimer) : -1;
220 TP_printk("VCPU: %ld, dv: %d, dp: %d, ep: %d",
222 __entry->direct_vtimer,
223 __entry->direct_ptimer,
224 __entry->emul_ptimer)
227 TRACE_EVENT(kvm_timer_save_state,
228 TP_PROTO(struct arch_timer_context *ctx),
232 __field( unsigned long, ctl )
233 __field( unsigned long long, cval )
234 __field( int, timer_idx )
238 __entry->ctl = timer_get_ctl(ctx);
239 __entry->cval = timer_get_cval(ctx);
240 __entry->timer_idx = arch_timer_ctx_index(ctx);
243 TP_printk(" CTL: %#08lx CVAL: %#16llx arch_timer_ctx_index: %d",
249 TRACE_EVENT(kvm_timer_restore_state,
250 TP_PROTO(struct arch_timer_context *ctx),
254 __field( unsigned long, ctl )
255 __field( unsigned long long, cval )
256 __field( int, timer_idx )
260 __entry->ctl = timer_get_ctl(ctx);
261 __entry->cval = timer_get_cval(ctx);
262 __entry->timer_idx = arch_timer_ctx_index(ctx);
265 TP_printk("CTL: %#08lx CVAL: %#16llx arch_timer_ctx_index: %d",
271 TRACE_EVENT(kvm_timer_hrtimer_expire,
272 TP_PROTO(struct arch_timer_context *ctx),
276 __field( int, timer_idx )
280 __entry->timer_idx = arch_timer_ctx_index(ctx);
283 TP_printk("arch_timer_ctx_index: %d", __entry->timer_idx)
286 TRACE_EVENT(kvm_timer_emulate,
287 TP_PROTO(struct arch_timer_context *ctx, bool should_fire),
288 TP_ARGS(ctx, should_fire),
291 __field( int, timer_idx )
292 __field( bool, should_fire )
296 __entry->timer_idx = arch_timer_ctx_index(ctx);
297 __entry->should_fire = should_fire;
300 TP_printk("arch_timer_ctx_index: %d (should_fire: %d)",
301 __entry->timer_idx, __entry->should_fire)
304 #endif /* _TRACE_ARM_ARM64_KVM_H */
306 #undef TRACE_INCLUDE_PATH
307 #define TRACE_INCLUDE_PATH .
308 #undef TRACE_INCLUDE_FILE
309 #define TRACE_INCLUDE_FILE trace_arm
311 /* This part must be outside protection */
312 #include <trace/define_trace.h>