xref: /linux/arch/arm64/kvm/trace_arm.h (revision 0ea5c948cb64bab5bc7a5516774eb8536f05aa0d)
19ed24f4bSMarc Zyngier /* SPDX-License-Identifier: GPL-2.0 */
29ed24f4bSMarc Zyngier #if !defined(_TRACE_ARM_ARM64_KVM_H) || defined(TRACE_HEADER_MULTI_READ)
39ed24f4bSMarc Zyngier #define _TRACE_ARM_ARM64_KVM_H
49ed24f4bSMarc Zyngier 
547f3a2fcSJintack Lim #include <asm/kvm_emulate.h>
69ed24f4bSMarc Zyngier #include <kvm/arm_arch_timer.h>
79ed24f4bSMarc Zyngier #include <linux/tracepoint.h>
89ed24f4bSMarc Zyngier 
99ed24f4bSMarc Zyngier #undef TRACE_SYSTEM
109ed24f4bSMarc Zyngier #define TRACE_SYSTEM kvm
119ed24f4bSMarc Zyngier 
129ed24f4bSMarc Zyngier /*
139ed24f4bSMarc Zyngier  * Tracepoints for entry/exit to guest
149ed24f4bSMarc Zyngier  */
159ed24f4bSMarc Zyngier TRACE_EVENT(kvm_entry,
169ed24f4bSMarc Zyngier 	TP_PROTO(unsigned long vcpu_pc),
179ed24f4bSMarc Zyngier 	TP_ARGS(vcpu_pc),
189ed24f4bSMarc Zyngier 
199ed24f4bSMarc Zyngier 	TP_STRUCT__entry(
209ed24f4bSMarc Zyngier 		__field(	unsigned long,	vcpu_pc		)
219ed24f4bSMarc Zyngier 	),
229ed24f4bSMarc Zyngier 
239ed24f4bSMarc Zyngier 	TP_fast_assign(
249ed24f4bSMarc Zyngier 		__entry->vcpu_pc		= vcpu_pc;
259ed24f4bSMarc Zyngier 	),
269ed24f4bSMarc Zyngier 
27376426b1SMarc Zyngier 	TP_printk("PC: 0x%016lx", __entry->vcpu_pc)
289ed24f4bSMarc Zyngier );
299ed24f4bSMarc Zyngier 
309ed24f4bSMarc Zyngier TRACE_EVENT(kvm_exit,
319ed24f4bSMarc Zyngier 	TP_PROTO(int ret, unsigned int esr_ec, unsigned long vcpu_pc),
329ed24f4bSMarc Zyngier 	TP_ARGS(ret, esr_ec, vcpu_pc),
339ed24f4bSMarc Zyngier 
349ed24f4bSMarc Zyngier 	TP_STRUCT__entry(
359ed24f4bSMarc Zyngier 		__field(	int,		ret		)
369ed24f4bSMarc Zyngier 		__field(	unsigned int,	esr_ec		)
379ed24f4bSMarc Zyngier 		__field(	unsigned long,	vcpu_pc		)
389ed24f4bSMarc Zyngier 	),
399ed24f4bSMarc Zyngier 
409ed24f4bSMarc Zyngier 	TP_fast_assign(
419ed24f4bSMarc Zyngier 		__entry->ret			= ARM_EXCEPTION_CODE(ret);
429ed24f4bSMarc Zyngier 		__entry->esr_ec = ARM_EXCEPTION_IS_TRAP(ret) ? esr_ec : 0;
439ed24f4bSMarc Zyngier 		__entry->vcpu_pc		= vcpu_pc;
449ed24f4bSMarc Zyngier 	),
459ed24f4bSMarc Zyngier 
46376426b1SMarc Zyngier 	TP_printk("%s: HSR_EC: 0x%04x (%s), PC: 0x%016lx",
479ed24f4bSMarc Zyngier 		  __print_symbolic(__entry->ret, kvm_arm_exception_type),
489ed24f4bSMarc Zyngier 		  __entry->esr_ec,
499ed24f4bSMarc Zyngier 		  __print_symbolic(__entry->esr_ec, kvm_arm_exception_class),
509ed24f4bSMarc Zyngier 		  __entry->vcpu_pc)
519ed24f4bSMarc Zyngier );
529ed24f4bSMarc Zyngier 
539ed24f4bSMarc Zyngier TRACE_EVENT(kvm_guest_fault,
549ed24f4bSMarc Zyngier 	TP_PROTO(unsigned long vcpu_pc, unsigned long hsr,
559ed24f4bSMarc Zyngier 		 unsigned long hxfar,
569ed24f4bSMarc Zyngier 		 unsigned long long ipa),
579ed24f4bSMarc Zyngier 	TP_ARGS(vcpu_pc, hsr, hxfar, ipa),
589ed24f4bSMarc Zyngier 
599ed24f4bSMarc Zyngier 	TP_STRUCT__entry(
609ed24f4bSMarc Zyngier 		__field(	unsigned long,	vcpu_pc		)
619ed24f4bSMarc Zyngier 		__field(	unsigned long,	hsr		)
629ed24f4bSMarc Zyngier 		__field(	unsigned long,	hxfar		)
639ed24f4bSMarc Zyngier 		__field(   unsigned long long,	ipa		)
649ed24f4bSMarc Zyngier 	),
659ed24f4bSMarc Zyngier 
669ed24f4bSMarc Zyngier 	TP_fast_assign(
679ed24f4bSMarc Zyngier 		__entry->vcpu_pc		= vcpu_pc;
689ed24f4bSMarc Zyngier 		__entry->hsr			= hsr;
699ed24f4bSMarc Zyngier 		__entry->hxfar			= hxfar;
709ed24f4bSMarc Zyngier 		__entry->ipa			= ipa;
719ed24f4bSMarc Zyngier 	),
729ed24f4bSMarc Zyngier 
73376426b1SMarc Zyngier 	TP_printk("ipa %#llx, hsr %#08lx, hxfar %#08lx, pc %#016lx",
749ed24f4bSMarc Zyngier 		  __entry->ipa, __entry->hsr,
759ed24f4bSMarc Zyngier 		  __entry->hxfar, __entry->vcpu_pc)
769ed24f4bSMarc Zyngier );
779ed24f4bSMarc Zyngier 
789ed24f4bSMarc Zyngier TRACE_EVENT(kvm_access_fault,
799ed24f4bSMarc Zyngier 	TP_PROTO(unsigned long ipa),
809ed24f4bSMarc Zyngier 	TP_ARGS(ipa),
819ed24f4bSMarc Zyngier 
829ed24f4bSMarc Zyngier 	TP_STRUCT__entry(
839ed24f4bSMarc Zyngier 		__field(	unsigned long,	ipa		)
849ed24f4bSMarc Zyngier 	),
859ed24f4bSMarc Zyngier 
869ed24f4bSMarc Zyngier 	TP_fast_assign(
879ed24f4bSMarc Zyngier 		__entry->ipa		= ipa;
889ed24f4bSMarc Zyngier 	),
899ed24f4bSMarc Zyngier 
909ed24f4bSMarc Zyngier 	TP_printk("IPA: %lx", __entry->ipa)
919ed24f4bSMarc Zyngier );
929ed24f4bSMarc Zyngier 
939ed24f4bSMarc Zyngier TRACE_EVENT(kvm_irq_line,
949ed24f4bSMarc Zyngier 	TP_PROTO(unsigned int type, int vcpu_idx, int irq_num, int level),
959ed24f4bSMarc Zyngier 	TP_ARGS(type, vcpu_idx, irq_num, level),
969ed24f4bSMarc Zyngier 
979ed24f4bSMarc Zyngier 	TP_STRUCT__entry(
989ed24f4bSMarc Zyngier 		__field(	unsigned int,	type		)
999ed24f4bSMarc Zyngier 		__field(	int,		vcpu_idx	)
1009ed24f4bSMarc Zyngier 		__field(	int,		irq_num		)
1019ed24f4bSMarc Zyngier 		__field(	int,		level		)
1029ed24f4bSMarc Zyngier 	),
1039ed24f4bSMarc Zyngier 
1049ed24f4bSMarc Zyngier 	TP_fast_assign(
1059ed24f4bSMarc Zyngier 		__entry->type		= type;
1069ed24f4bSMarc Zyngier 		__entry->vcpu_idx	= vcpu_idx;
1079ed24f4bSMarc Zyngier 		__entry->irq_num	= irq_num;
1089ed24f4bSMarc Zyngier 		__entry->level		= level;
1099ed24f4bSMarc Zyngier 	),
1109ed24f4bSMarc Zyngier 
1119ed24f4bSMarc Zyngier 	TP_printk("Inject %s interrupt (%d), vcpu->idx: %d, num: %d, level: %d",
1129ed24f4bSMarc Zyngier 		  (__entry->type == KVM_ARM_IRQ_TYPE_CPU) ? "CPU" :
1139ed24f4bSMarc Zyngier 		  (__entry->type == KVM_ARM_IRQ_TYPE_PPI) ? "VGIC PPI" :
1149ed24f4bSMarc Zyngier 		  (__entry->type == KVM_ARM_IRQ_TYPE_SPI) ? "VGIC SPI" : "UNKNOWN",
1159ed24f4bSMarc Zyngier 		  __entry->type, __entry->vcpu_idx, __entry->irq_num, __entry->level)
1169ed24f4bSMarc Zyngier );
1179ed24f4bSMarc Zyngier 
1189ed24f4bSMarc Zyngier TRACE_EVENT(kvm_mmio_emulate,
1199ed24f4bSMarc Zyngier 	TP_PROTO(unsigned long vcpu_pc, unsigned long instr,
1209ed24f4bSMarc Zyngier 		 unsigned long cpsr),
1219ed24f4bSMarc Zyngier 	TP_ARGS(vcpu_pc, instr, cpsr),
1229ed24f4bSMarc Zyngier 
1239ed24f4bSMarc Zyngier 	TP_STRUCT__entry(
1249ed24f4bSMarc Zyngier 		__field(	unsigned long,	vcpu_pc		)
1259ed24f4bSMarc Zyngier 		__field(	unsigned long,	instr		)
1269ed24f4bSMarc Zyngier 		__field(	unsigned long,	cpsr		)
1279ed24f4bSMarc Zyngier 	),
1289ed24f4bSMarc Zyngier 
1299ed24f4bSMarc Zyngier 	TP_fast_assign(
1309ed24f4bSMarc Zyngier 		__entry->vcpu_pc		= vcpu_pc;
1319ed24f4bSMarc Zyngier 		__entry->instr			= instr;
1329ed24f4bSMarc Zyngier 		__entry->cpsr			= cpsr;
1339ed24f4bSMarc Zyngier 	),
1349ed24f4bSMarc Zyngier 
135376426b1SMarc Zyngier 	TP_printk("Emulate MMIO at: 0x%016lx (instr: %08lx, cpsr: %08lx)",
1369ed24f4bSMarc Zyngier 		  __entry->vcpu_pc, __entry->instr, __entry->cpsr)
1379ed24f4bSMarc Zyngier );
1389ed24f4bSMarc Zyngier 
139*d11974dcSOliver Upton TRACE_EVENT(kvm_mmio_nisv,
140*d11974dcSOliver Upton 	TP_PROTO(unsigned long vcpu_pc, unsigned long esr,
141*d11974dcSOliver Upton 		 unsigned long far, unsigned long ipa),
142*d11974dcSOliver Upton 	TP_ARGS(vcpu_pc, esr, far, ipa),
143*d11974dcSOliver Upton 
144*d11974dcSOliver Upton 	TP_STRUCT__entry(
145*d11974dcSOliver Upton 		__field(	unsigned long,	vcpu_pc		)
146*d11974dcSOliver Upton 		__field(	unsigned long,	esr		)
147*d11974dcSOliver Upton 		__field(	unsigned long,	far		)
148*d11974dcSOliver Upton 		__field(	unsigned long,	ipa		)
149*d11974dcSOliver Upton 	),
150*d11974dcSOliver Upton 
151*d11974dcSOliver Upton 	TP_fast_assign(
152*d11974dcSOliver Upton 		__entry->vcpu_pc		= vcpu_pc;
153*d11974dcSOliver Upton 		__entry->esr			= esr;
154*d11974dcSOliver Upton 		__entry->far			= far;
155*d11974dcSOliver Upton 		__entry->ipa			= ipa;
156*d11974dcSOliver Upton 	),
157*d11974dcSOliver Upton 
158*d11974dcSOliver Upton 	TP_printk("ipa %#016lx, esr %#016lx, far %#016lx, pc %#016lx",
159*d11974dcSOliver Upton 		  __entry->ipa, __entry->esr,
160*d11974dcSOliver Upton 		  __entry->far, __entry->vcpu_pc)
161*d11974dcSOliver Upton );
162*d11974dcSOliver Upton 
163*d11974dcSOliver Upton 
1649ed24f4bSMarc Zyngier TRACE_EVENT(kvm_set_way_flush,
1659ed24f4bSMarc Zyngier 	    TP_PROTO(unsigned long vcpu_pc, bool cache),
1669ed24f4bSMarc Zyngier 	    TP_ARGS(vcpu_pc, cache),
1679ed24f4bSMarc Zyngier 
1689ed24f4bSMarc Zyngier 	    TP_STRUCT__entry(
1699ed24f4bSMarc Zyngier 		    __field(	unsigned long,	vcpu_pc		)
1709ed24f4bSMarc Zyngier 		    __field(	bool,		cache		)
1719ed24f4bSMarc Zyngier 	    ),
1729ed24f4bSMarc Zyngier 
1739ed24f4bSMarc Zyngier 	    TP_fast_assign(
1749ed24f4bSMarc Zyngier 		    __entry->vcpu_pc		= vcpu_pc;
1759ed24f4bSMarc Zyngier 		    __entry->cache		= cache;
1769ed24f4bSMarc Zyngier 	    ),
1779ed24f4bSMarc Zyngier 
1789ed24f4bSMarc Zyngier 	    TP_printk("S/W flush at 0x%016lx (cache %s)",
1799ed24f4bSMarc Zyngier 		      __entry->vcpu_pc, __entry->cache ? "on" : "off")
1809ed24f4bSMarc Zyngier );
1819ed24f4bSMarc Zyngier 
1829ed24f4bSMarc Zyngier TRACE_EVENT(kvm_toggle_cache,
1839ed24f4bSMarc Zyngier 	    TP_PROTO(unsigned long vcpu_pc, bool was, bool now),
1849ed24f4bSMarc Zyngier 	    TP_ARGS(vcpu_pc, was, now),
1859ed24f4bSMarc Zyngier 
1869ed24f4bSMarc Zyngier 	    TP_STRUCT__entry(
1879ed24f4bSMarc Zyngier 		    __field(	unsigned long,	vcpu_pc		)
1889ed24f4bSMarc Zyngier 		    __field(	bool,		was		)
1899ed24f4bSMarc Zyngier 		    __field(	bool,		now		)
1909ed24f4bSMarc Zyngier 	    ),
1919ed24f4bSMarc Zyngier 
1929ed24f4bSMarc Zyngier 	    TP_fast_assign(
1939ed24f4bSMarc Zyngier 		    __entry->vcpu_pc		= vcpu_pc;
1949ed24f4bSMarc Zyngier 		    __entry->was		= was;
1959ed24f4bSMarc Zyngier 		    __entry->now		= now;
1969ed24f4bSMarc Zyngier 	    ),
1979ed24f4bSMarc Zyngier 
1989ed24f4bSMarc Zyngier 	    TP_printk("VM op at 0x%016lx (cache was %s, now %s)",
1999ed24f4bSMarc Zyngier 		      __entry->vcpu_pc, __entry->was ? "on" : "off",
2009ed24f4bSMarc Zyngier 		      __entry->now ? "on" : "off")
2019ed24f4bSMarc Zyngier );
2029ed24f4bSMarc Zyngier 
2039ed24f4bSMarc Zyngier /*
2049ed24f4bSMarc Zyngier  * Tracepoints for arch_timer
2059ed24f4bSMarc Zyngier  */
2069ed24f4bSMarc Zyngier TRACE_EVENT(kvm_timer_update_irq,
2079ed24f4bSMarc Zyngier 	TP_PROTO(unsigned long vcpu_id, __u32 irq, int level),
2089ed24f4bSMarc Zyngier 	TP_ARGS(vcpu_id, irq, level),
2099ed24f4bSMarc Zyngier 
2109ed24f4bSMarc Zyngier 	TP_STRUCT__entry(
2119ed24f4bSMarc Zyngier 		__field(	unsigned long,	vcpu_id	)
2129ed24f4bSMarc Zyngier 		__field(	__u32,		irq	)
2139ed24f4bSMarc Zyngier 		__field(	int,		level	)
2149ed24f4bSMarc Zyngier 	),
2159ed24f4bSMarc Zyngier 
2169ed24f4bSMarc Zyngier 	TP_fast_assign(
2179ed24f4bSMarc Zyngier 		__entry->vcpu_id	= vcpu_id;
2189ed24f4bSMarc Zyngier 		__entry->irq		= irq;
2199ed24f4bSMarc Zyngier 		__entry->level		= level;
2209ed24f4bSMarc Zyngier 	),
2219ed24f4bSMarc Zyngier 
2229ed24f4bSMarc Zyngier 	TP_printk("VCPU: %ld, IRQ %d, level %d",
2239ed24f4bSMarc Zyngier 		  __entry->vcpu_id, __entry->irq, __entry->level)
2249ed24f4bSMarc Zyngier );
2259ed24f4bSMarc Zyngier 
2269ed24f4bSMarc Zyngier TRACE_EVENT(kvm_get_timer_map,
2279ed24f4bSMarc Zyngier 	TP_PROTO(unsigned long vcpu_id, struct timer_map *map),
2289ed24f4bSMarc Zyngier 	TP_ARGS(vcpu_id, map),
2299ed24f4bSMarc Zyngier 
2309ed24f4bSMarc Zyngier 	TP_STRUCT__entry(
2319ed24f4bSMarc Zyngier 		__field(	unsigned long,		vcpu_id	)
2329ed24f4bSMarc Zyngier 		__field(	int,			direct_vtimer	)
2339ed24f4bSMarc Zyngier 		__field(	int,			direct_ptimer	)
23481dc9504SMarc Zyngier 		__field(	int,			emul_vtimer	)
2359ed24f4bSMarc Zyngier 		__field(	int,			emul_ptimer	)
2369ed24f4bSMarc Zyngier 	),
2379ed24f4bSMarc Zyngier 
2389ed24f4bSMarc Zyngier 	TP_fast_assign(
2399ed24f4bSMarc Zyngier 		__entry->vcpu_id		= vcpu_id;
2409ed24f4bSMarc Zyngier 		__entry->direct_vtimer		= arch_timer_ctx_index(map->direct_vtimer);
2419ed24f4bSMarc Zyngier 		__entry->direct_ptimer =
2429ed24f4bSMarc Zyngier 			(map->direct_ptimer) ? arch_timer_ctx_index(map->direct_ptimer) : -1;
24381dc9504SMarc Zyngier 		__entry->emul_vtimer =
24481dc9504SMarc Zyngier 			(map->emul_vtimer) ? arch_timer_ctx_index(map->emul_vtimer) : -1;
2459ed24f4bSMarc Zyngier 		__entry->emul_ptimer =
2469ed24f4bSMarc Zyngier 			(map->emul_ptimer) ? arch_timer_ctx_index(map->emul_ptimer) : -1;
2479ed24f4bSMarc Zyngier 	),
2489ed24f4bSMarc Zyngier 
24981dc9504SMarc Zyngier 	TP_printk("VCPU: %ld, dv: %d, dp: %d, ev: %d, ep: %d",
2509ed24f4bSMarc Zyngier 		  __entry->vcpu_id,
2519ed24f4bSMarc Zyngier 		  __entry->direct_vtimer,
2529ed24f4bSMarc Zyngier 		  __entry->direct_ptimer,
25381dc9504SMarc Zyngier 		  __entry->emul_vtimer,
2549ed24f4bSMarc Zyngier 		  __entry->emul_ptimer)
2559ed24f4bSMarc Zyngier );
2569ed24f4bSMarc Zyngier 
2579ed24f4bSMarc Zyngier TRACE_EVENT(kvm_timer_save_state,
2589ed24f4bSMarc Zyngier 	TP_PROTO(struct arch_timer_context *ctx),
2599ed24f4bSMarc Zyngier 	TP_ARGS(ctx),
2609ed24f4bSMarc Zyngier 
2619ed24f4bSMarc Zyngier 	TP_STRUCT__entry(
2629ed24f4bSMarc Zyngier 		__field(	unsigned long,		ctl		)
2639ed24f4bSMarc Zyngier 		__field(	unsigned long long,	cval		)
2649ed24f4bSMarc Zyngier 		__field(	int,			timer_idx	)
2659ed24f4bSMarc Zyngier 	),
2669ed24f4bSMarc Zyngier 
2679ed24f4bSMarc Zyngier 	TP_fast_assign(
26841ce82f6SMarc Zyngier 		__entry->ctl			= timer_get_ctl(ctx);
26941ce82f6SMarc Zyngier 		__entry->cval			= timer_get_cval(ctx);
2709ed24f4bSMarc Zyngier 		__entry->timer_idx		= arch_timer_ctx_index(ctx);
2719ed24f4bSMarc Zyngier 	),
2729ed24f4bSMarc Zyngier 
2739ed24f4bSMarc Zyngier 	TP_printk("   CTL: %#08lx CVAL: %#16llx arch_timer_ctx_index: %d",
2749ed24f4bSMarc Zyngier 		  __entry->ctl,
2759ed24f4bSMarc Zyngier 		  __entry->cval,
2769ed24f4bSMarc Zyngier 		  __entry->timer_idx)
2779ed24f4bSMarc Zyngier );
2789ed24f4bSMarc Zyngier 
2799ed24f4bSMarc Zyngier TRACE_EVENT(kvm_timer_restore_state,
2809ed24f4bSMarc Zyngier 	TP_PROTO(struct arch_timer_context *ctx),
2819ed24f4bSMarc Zyngier 	TP_ARGS(ctx),
2829ed24f4bSMarc Zyngier 
2839ed24f4bSMarc Zyngier 	TP_STRUCT__entry(
2849ed24f4bSMarc Zyngier 		__field(	unsigned long,		ctl		)
2859ed24f4bSMarc Zyngier 		__field(	unsigned long long,	cval		)
2869ed24f4bSMarc Zyngier 		__field(	int,			timer_idx	)
2879ed24f4bSMarc Zyngier 	),
2889ed24f4bSMarc Zyngier 
2899ed24f4bSMarc Zyngier 	TP_fast_assign(
29041ce82f6SMarc Zyngier 		__entry->ctl			= timer_get_ctl(ctx);
29141ce82f6SMarc Zyngier 		__entry->cval			= timer_get_cval(ctx);
2929ed24f4bSMarc Zyngier 		__entry->timer_idx		= arch_timer_ctx_index(ctx);
2939ed24f4bSMarc Zyngier 	),
2949ed24f4bSMarc Zyngier 
2959ed24f4bSMarc Zyngier 	TP_printk("CTL: %#08lx CVAL: %#16llx arch_timer_ctx_index: %d",
2969ed24f4bSMarc Zyngier 		  __entry->ctl,
2979ed24f4bSMarc Zyngier 		  __entry->cval,
2989ed24f4bSMarc Zyngier 		  __entry->timer_idx)
2999ed24f4bSMarc Zyngier );
3009ed24f4bSMarc Zyngier 
3019ed24f4bSMarc Zyngier TRACE_EVENT(kvm_timer_hrtimer_expire,
3029ed24f4bSMarc Zyngier 	TP_PROTO(struct arch_timer_context *ctx),
3039ed24f4bSMarc Zyngier 	TP_ARGS(ctx),
3049ed24f4bSMarc Zyngier 
3059ed24f4bSMarc Zyngier 	TP_STRUCT__entry(
3069ed24f4bSMarc Zyngier 		__field(	int,			timer_idx	)
3079ed24f4bSMarc Zyngier 	),
3089ed24f4bSMarc Zyngier 
3099ed24f4bSMarc Zyngier 	TP_fast_assign(
3109ed24f4bSMarc Zyngier 		__entry->timer_idx		= arch_timer_ctx_index(ctx);
3119ed24f4bSMarc Zyngier 	),
3129ed24f4bSMarc Zyngier 
3139ed24f4bSMarc Zyngier 	TP_printk("arch_timer_ctx_index: %d", __entry->timer_idx)
3149ed24f4bSMarc Zyngier );
3159ed24f4bSMarc Zyngier 
3169ed24f4bSMarc Zyngier TRACE_EVENT(kvm_timer_emulate,
3179ed24f4bSMarc Zyngier 	TP_PROTO(struct arch_timer_context *ctx, bool should_fire),
3189ed24f4bSMarc Zyngier 	TP_ARGS(ctx, should_fire),
3199ed24f4bSMarc Zyngier 
3209ed24f4bSMarc Zyngier 	TP_STRUCT__entry(
3219ed24f4bSMarc Zyngier 		__field(	int,			timer_idx	)
3229ed24f4bSMarc Zyngier 		__field(	bool,			should_fire	)
3239ed24f4bSMarc Zyngier 	),
3249ed24f4bSMarc Zyngier 
3259ed24f4bSMarc Zyngier 	TP_fast_assign(
3269ed24f4bSMarc Zyngier 		__entry->timer_idx		= arch_timer_ctx_index(ctx);
3279ed24f4bSMarc Zyngier 		__entry->should_fire		= should_fire;
3289ed24f4bSMarc Zyngier 	),
3299ed24f4bSMarc Zyngier 
3309ed24f4bSMarc Zyngier 	TP_printk("arch_timer_ctx_index: %d (should_fire: %d)",
3319ed24f4bSMarc Zyngier 		  __entry->timer_idx, __entry->should_fire)
3329ed24f4bSMarc Zyngier );
3339ed24f4bSMarc Zyngier 
33447f3a2fcSJintack Lim TRACE_EVENT(kvm_nested_eret,
33547f3a2fcSJintack Lim 	TP_PROTO(struct kvm_vcpu *vcpu, unsigned long elr_el2,
33647f3a2fcSJintack Lim 		 unsigned long spsr_el2),
33747f3a2fcSJintack Lim 	TP_ARGS(vcpu, elr_el2, spsr_el2),
33847f3a2fcSJintack Lim 
33947f3a2fcSJintack Lim 	TP_STRUCT__entry(
34047f3a2fcSJintack Lim 		__field(struct kvm_vcpu *,	vcpu)
34147f3a2fcSJintack Lim 		__field(unsigned long,		elr_el2)
34247f3a2fcSJintack Lim 		__field(unsigned long,		spsr_el2)
34347f3a2fcSJintack Lim 		__field(unsigned long,		target_mode)
34447f3a2fcSJintack Lim 		__field(unsigned long,		hcr_el2)
34547f3a2fcSJintack Lim 	),
34647f3a2fcSJintack Lim 
34747f3a2fcSJintack Lim 	TP_fast_assign(
34847f3a2fcSJintack Lim 		__entry->vcpu = vcpu;
34947f3a2fcSJintack Lim 		__entry->elr_el2 = elr_el2;
35047f3a2fcSJintack Lim 		__entry->spsr_el2 = spsr_el2;
35147f3a2fcSJintack Lim 		__entry->target_mode = spsr_el2 & (PSR_MODE_MASK | PSR_MODE32_BIT);
35247f3a2fcSJintack Lim 		__entry->hcr_el2 = __vcpu_sys_reg(vcpu, HCR_EL2);
35347f3a2fcSJintack Lim 	),
35447f3a2fcSJintack Lim 
35547f3a2fcSJintack Lim 	TP_printk("elr_el2: 0x%lx spsr_el2: 0x%08lx (M: %s) hcr_el2: %lx",
35647f3a2fcSJintack Lim 		  __entry->elr_el2, __entry->spsr_el2,
35747f3a2fcSJintack Lim 		  __print_symbolic(__entry->target_mode, kvm_mode_names),
35847f3a2fcSJintack Lim 		  __entry->hcr_el2)
35947f3a2fcSJintack Lim );
36047f3a2fcSJintack Lim 
36147f3a2fcSJintack Lim TRACE_EVENT(kvm_inject_nested_exception,
36247f3a2fcSJintack Lim 	TP_PROTO(struct kvm_vcpu *vcpu, u64 esr_el2, int type),
36347f3a2fcSJintack Lim 	TP_ARGS(vcpu, esr_el2, type),
36447f3a2fcSJintack Lim 
36547f3a2fcSJintack Lim 	TP_STRUCT__entry(
36647f3a2fcSJintack Lim 		__field(struct kvm_vcpu *,		vcpu)
36747f3a2fcSJintack Lim 		__field(unsigned long,			esr_el2)
36847f3a2fcSJintack Lim 		__field(int,				type)
36947f3a2fcSJintack Lim 		__field(unsigned long,			spsr_el2)
37047f3a2fcSJintack Lim 		__field(unsigned long,			pc)
37147f3a2fcSJintack Lim 		__field(unsigned long,			source_mode)
37247f3a2fcSJintack Lim 		__field(unsigned long,			hcr_el2)
37347f3a2fcSJintack Lim 	),
37447f3a2fcSJintack Lim 
37547f3a2fcSJintack Lim 	TP_fast_assign(
37647f3a2fcSJintack Lim 		__entry->vcpu = vcpu;
37747f3a2fcSJintack Lim 		__entry->esr_el2 = esr_el2;
37847f3a2fcSJintack Lim 		__entry->type = type;
37947f3a2fcSJintack Lim 		__entry->spsr_el2 = *vcpu_cpsr(vcpu);
38047f3a2fcSJintack Lim 		__entry->pc = *vcpu_pc(vcpu);
38147f3a2fcSJintack Lim 		__entry->source_mode = *vcpu_cpsr(vcpu) & (PSR_MODE_MASK | PSR_MODE32_BIT);
38247f3a2fcSJintack Lim 		__entry->hcr_el2 = __vcpu_sys_reg(vcpu, HCR_EL2);
38347f3a2fcSJintack Lim 	),
38447f3a2fcSJintack Lim 
38547f3a2fcSJintack Lim 	TP_printk("%s: esr_el2 0x%lx elr_el2: 0x%lx spsr_el2: 0x%08lx (M: %s) hcr_el2: %lx",
38647f3a2fcSJintack Lim 		  __print_symbolic(__entry->type, kvm_exception_type_names),
38747f3a2fcSJintack Lim 		  __entry->esr_el2, __entry->pc, __entry->spsr_el2,
38847f3a2fcSJintack Lim 		  __print_symbolic(__entry->source_mode, kvm_mode_names),
38947f3a2fcSJintack Lim 		  __entry->hcr_el2)
39047f3a2fcSJintack Lim );
39147f3a2fcSJintack Lim 
392e58ec47bSMarc Zyngier TRACE_EVENT(kvm_forward_sysreg_trap,
393e58ec47bSMarc Zyngier 	    TP_PROTO(struct kvm_vcpu *vcpu, u32 sysreg, bool is_read),
394e58ec47bSMarc Zyngier 	    TP_ARGS(vcpu, sysreg, is_read),
395e58ec47bSMarc Zyngier 
396e58ec47bSMarc Zyngier 	    TP_STRUCT__entry(
397e58ec47bSMarc Zyngier 		__field(u64,	pc)
398e58ec47bSMarc Zyngier 		__field(u32,	sysreg)
399e58ec47bSMarc Zyngier 		__field(bool,	is_read)
400e58ec47bSMarc Zyngier 	    ),
401e58ec47bSMarc Zyngier 
402e58ec47bSMarc Zyngier 	    TP_fast_assign(
403e58ec47bSMarc Zyngier 		__entry->pc = *vcpu_pc(vcpu);
404e58ec47bSMarc Zyngier 		__entry->sysreg = sysreg;
405e58ec47bSMarc Zyngier 		__entry->is_read = is_read;
406e58ec47bSMarc Zyngier 	    ),
407e58ec47bSMarc Zyngier 
408e58ec47bSMarc Zyngier 	    TP_printk("%llx %c (%d,%d,%d,%d,%d)",
409e58ec47bSMarc Zyngier 		      __entry->pc,
410e58ec47bSMarc Zyngier 		      __entry->is_read ? 'R' : 'W',
411e58ec47bSMarc Zyngier 		      sys_reg_Op0(__entry->sysreg),
412e58ec47bSMarc Zyngier 		      sys_reg_Op1(__entry->sysreg),
413e58ec47bSMarc Zyngier 		      sys_reg_CRn(__entry->sysreg),
414e58ec47bSMarc Zyngier 		      sys_reg_CRm(__entry->sysreg),
415e58ec47bSMarc Zyngier 		      sys_reg_Op2(__entry->sysreg))
416e58ec47bSMarc Zyngier );
417e58ec47bSMarc Zyngier 
4189ed24f4bSMarc Zyngier #endif /* _TRACE_ARM_ARM64_KVM_H */
4199ed24f4bSMarc Zyngier 
4209ed24f4bSMarc Zyngier #undef TRACE_INCLUDE_PATH
4219ed24f4bSMarc Zyngier #define TRACE_INCLUDE_PATH .
4229ed24f4bSMarc Zyngier #undef TRACE_INCLUDE_FILE
4239ed24f4bSMarc Zyngier #define TRACE_INCLUDE_FILE trace_arm
4249ed24f4bSMarc Zyngier 
4259ed24f4bSMarc Zyngier /* This part must be outside protection */
4269ed24f4bSMarc Zyngier #include <trace/define_trace.h>
427