cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

trace_arm.h (7354B)


      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
      4
      5#include <kvm/arm_arch_timer.h>
      6#include <linux/tracepoint.h>
      7
      8#undef TRACE_SYSTEM
      9#define TRACE_SYSTEM kvm
     10
     11/*
     12 * Tracepoints for entry/exit to guest
     13 */
     14TRACE_EVENT(kvm_entry,
     15	TP_PROTO(unsigned long vcpu_pc),
     16	TP_ARGS(vcpu_pc),
     17
     18	TP_STRUCT__entry(
     19		__field(	unsigned long,	vcpu_pc		)
     20	),
     21
     22	TP_fast_assign(
     23		__entry->vcpu_pc		= vcpu_pc;
     24	),
     25
     26	TP_printk("PC: 0x%016lx", __entry->vcpu_pc)
     27);
     28
     29TRACE_EVENT(kvm_exit,
     30	TP_PROTO(int ret, unsigned int esr_ec, unsigned long vcpu_pc),
     31	TP_ARGS(ret, esr_ec, vcpu_pc),
     32
     33	TP_STRUCT__entry(
     34		__field(	int,		ret		)
     35		__field(	unsigned int,	esr_ec		)
     36		__field(	unsigned long,	vcpu_pc		)
     37	),
     38
     39	TP_fast_assign(
     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;
     43	),
     44
     45	TP_printk("%s: HSR_EC: 0x%04x (%s), PC: 0x%016lx",
     46		  __print_symbolic(__entry->ret, kvm_arm_exception_type),
     47		  __entry->esr_ec,
     48		  __print_symbolic(__entry->esr_ec, kvm_arm_exception_class),
     49		  __entry->vcpu_pc)
     50);
     51
     52TRACE_EVENT(kvm_guest_fault,
     53	TP_PROTO(unsigned long vcpu_pc, unsigned long hsr,
     54		 unsigned long hxfar,
     55		 unsigned long long ipa),
     56	TP_ARGS(vcpu_pc, hsr, hxfar, ipa),
     57
     58	TP_STRUCT__entry(
     59		__field(	unsigned long,	vcpu_pc		)
     60		__field(	unsigned long,	hsr		)
     61		__field(	unsigned long,	hxfar		)
     62		__field(   unsigned long long,	ipa		)
     63	),
     64
     65	TP_fast_assign(
     66		__entry->vcpu_pc		= vcpu_pc;
     67		__entry->hsr			= hsr;
     68		__entry->hxfar			= hxfar;
     69		__entry->ipa			= ipa;
     70	),
     71
     72	TP_printk("ipa %#llx, hsr %#08lx, hxfar %#08lx, pc %#016lx",
     73		  __entry->ipa, __entry->hsr,
     74		  __entry->hxfar, __entry->vcpu_pc)
     75);
     76
     77TRACE_EVENT(kvm_access_fault,
     78	TP_PROTO(unsigned long ipa),
     79	TP_ARGS(ipa),
     80
     81	TP_STRUCT__entry(
     82		__field(	unsigned long,	ipa		)
     83	),
     84
     85	TP_fast_assign(
     86		__entry->ipa		= ipa;
     87	),
     88
     89	TP_printk("IPA: %lx", __entry->ipa)
     90);
     91
     92TRACE_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),
     95
     96	TP_STRUCT__entry(
     97		__field(	unsigned int,	type		)
     98		__field(	int,		vcpu_idx	)
     99		__field(	int,		irq_num		)
    100		__field(	int,		level		)
    101	),
    102
    103	TP_fast_assign(
    104		__entry->type		= type;
    105		__entry->vcpu_idx	= vcpu_idx;
    106		__entry->irq_num	= irq_num;
    107		__entry->level		= level;
    108	),
    109
    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)
    115);
    116
    117TRACE_EVENT(kvm_mmio_emulate,
    118	TP_PROTO(unsigned long vcpu_pc, unsigned long instr,
    119		 unsigned long cpsr),
    120	TP_ARGS(vcpu_pc, instr, cpsr),
    121
    122	TP_STRUCT__entry(
    123		__field(	unsigned long,	vcpu_pc		)
    124		__field(	unsigned long,	instr		)
    125		__field(	unsigned long,	cpsr		)
    126	),
    127
    128	TP_fast_assign(
    129		__entry->vcpu_pc		= vcpu_pc;
    130		__entry->instr			= instr;
    131		__entry->cpsr			= cpsr;
    132	),
    133
    134	TP_printk("Emulate MMIO at: 0x%016lx (instr: %08lx, cpsr: %08lx)",
    135		  __entry->vcpu_pc, __entry->instr, __entry->cpsr)
    136);
    137
    138TRACE_EVENT(kvm_set_way_flush,
    139	    TP_PROTO(unsigned long vcpu_pc, bool cache),
    140	    TP_ARGS(vcpu_pc, cache),
    141
    142	    TP_STRUCT__entry(
    143		    __field(	unsigned long,	vcpu_pc		)
    144		    __field(	bool,		cache		)
    145	    ),
    146
    147	    TP_fast_assign(
    148		    __entry->vcpu_pc		= vcpu_pc;
    149		    __entry->cache		= cache;
    150	    ),
    151
    152	    TP_printk("S/W flush at 0x%016lx (cache %s)",
    153		      __entry->vcpu_pc, __entry->cache ? "on" : "off")
    154);
    155
    156TRACE_EVENT(kvm_toggle_cache,
    157	    TP_PROTO(unsigned long vcpu_pc, bool was, bool now),
    158	    TP_ARGS(vcpu_pc, was, now),
    159
    160	    TP_STRUCT__entry(
    161		    __field(	unsigned long,	vcpu_pc		)
    162		    __field(	bool,		was		)
    163		    __field(	bool,		now		)
    164	    ),
    165
    166	    TP_fast_assign(
    167		    __entry->vcpu_pc		= vcpu_pc;
    168		    __entry->was		= was;
    169		    __entry->now		= now;
    170	    ),
    171
    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")
    175);
    176
    177/*
    178 * Tracepoints for arch_timer
    179 */
    180TRACE_EVENT(kvm_timer_update_irq,
    181	TP_PROTO(unsigned long vcpu_id, __u32 irq, int level),
    182	TP_ARGS(vcpu_id, irq, level),
    183
    184	TP_STRUCT__entry(
    185		__field(	unsigned long,	vcpu_id	)
    186		__field(	__u32,		irq	)
    187		__field(	int,		level	)
    188	),
    189
    190	TP_fast_assign(
    191		__entry->vcpu_id	= vcpu_id;
    192		__entry->irq		= irq;
    193		__entry->level		= level;
    194	),
    195
    196	TP_printk("VCPU: %ld, IRQ %d, level %d",
    197		  __entry->vcpu_id, __entry->irq, __entry->level)
    198);
    199
    200TRACE_EVENT(kvm_get_timer_map,
    201	TP_PROTO(unsigned long vcpu_id, struct timer_map *map),
    202	TP_ARGS(vcpu_id, map),
    203
    204	TP_STRUCT__entry(
    205		__field(	unsigned long,		vcpu_id	)
    206		__field(	int,			direct_vtimer	)
    207		__field(	int,			direct_ptimer	)
    208		__field(	int,			emul_ptimer	)
    209	),
    210
    211	TP_fast_assign(
    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;
    218	),
    219
    220	TP_printk("VCPU: %ld, dv: %d, dp: %d, ep: %d",
    221		  __entry->vcpu_id,
    222		  __entry->direct_vtimer,
    223		  __entry->direct_ptimer,
    224		  __entry->emul_ptimer)
    225);
    226
    227TRACE_EVENT(kvm_timer_save_state,
    228	TP_PROTO(struct arch_timer_context *ctx),
    229	TP_ARGS(ctx),
    230
    231	TP_STRUCT__entry(
    232		__field(	unsigned long,		ctl		)
    233		__field(	unsigned long long,	cval		)
    234		__field(	int,			timer_idx	)
    235	),
    236
    237	TP_fast_assign(
    238		__entry->ctl			= timer_get_ctl(ctx);
    239		__entry->cval			= timer_get_cval(ctx);
    240		__entry->timer_idx		= arch_timer_ctx_index(ctx);
    241	),
    242
    243	TP_printk("   CTL: %#08lx CVAL: %#16llx arch_timer_ctx_index: %d",
    244		  __entry->ctl,
    245		  __entry->cval,
    246		  __entry->timer_idx)
    247);
    248
    249TRACE_EVENT(kvm_timer_restore_state,
    250	TP_PROTO(struct arch_timer_context *ctx),
    251	TP_ARGS(ctx),
    252
    253	TP_STRUCT__entry(
    254		__field(	unsigned long,		ctl		)
    255		__field(	unsigned long long,	cval		)
    256		__field(	int,			timer_idx	)
    257	),
    258
    259	TP_fast_assign(
    260		__entry->ctl			= timer_get_ctl(ctx);
    261		__entry->cval			= timer_get_cval(ctx);
    262		__entry->timer_idx		= arch_timer_ctx_index(ctx);
    263	),
    264
    265	TP_printk("CTL: %#08lx CVAL: %#16llx arch_timer_ctx_index: %d",
    266		  __entry->ctl,
    267		  __entry->cval,
    268		  __entry->timer_idx)
    269);
    270
    271TRACE_EVENT(kvm_timer_hrtimer_expire,
    272	TP_PROTO(struct arch_timer_context *ctx),
    273	TP_ARGS(ctx),
    274
    275	TP_STRUCT__entry(
    276		__field(	int,			timer_idx	)
    277	),
    278
    279	TP_fast_assign(
    280		__entry->timer_idx		= arch_timer_ctx_index(ctx);
    281	),
    282
    283	TP_printk("arch_timer_ctx_index: %d", __entry->timer_idx)
    284);
    285
    286TRACE_EVENT(kvm_timer_emulate,
    287	TP_PROTO(struct arch_timer_context *ctx, bool should_fire),
    288	TP_ARGS(ctx, should_fire),
    289
    290	TP_STRUCT__entry(
    291		__field(	int,			timer_idx	)
    292		__field(	bool,			should_fire	)
    293	),
    294
    295	TP_fast_assign(
    296		__entry->timer_idx		= arch_timer_ctx_index(ctx);
    297		__entry->should_fire		= should_fire;
    298	),
    299
    300	TP_printk("arch_timer_ctx_index: %d (should_fire: %d)",
    301		  __entry->timer_idx, __entry->should_fire)
    302);
    303
    304#endif /* _TRACE_ARM_ARM64_KVM_H */
    305
    306#undef TRACE_INCLUDE_PATH
    307#define TRACE_INCLUDE_PATH .
    308#undef TRACE_INCLUDE_FILE
    309#define TRACE_INCLUDE_FILE trace_arm
    310
    311/* This part must be outside protection */
    312#include <trace/define_trace.h>