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 */ 14 TRACE_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%08lx", __entry->vcpu_pc) 27 ); 28 29 TRACE_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%08lx", 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 52 TRACE_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 %#08lx", 73 __entry->ipa, __entry->hsr, 74 __entry->hxfar, __entry->vcpu_pc) 75 ); 76 77 TRACE_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 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), 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 117 TRACE_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%08lx (instr: %08lx, cpsr: %08lx)", 135 __entry->vcpu_pc, __entry->instr, __entry->cpsr) 136 ); 137 138 TRACE_EVENT(kvm_unmap_hva_range, 139 TP_PROTO(unsigned long start, unsigned long end), 140 TP_ARGS(start, end), 141 142 TP_STRUCT__entry( 143 __field( unsigned long, start ) 144 __field( unsigned long, end ) 145 ), 146 147 TP_fast_assign( 148 __entry->start = start; 149 __entry->end = end; 150 ), 151 152 TP_printk("mmu notifier unmap range: %#08lx -- %#08lx", 153 __entry->start, __entry->end) 154 ); 155 156 TRACE_EVENT(kvm_set_spte_hva, 157 TP_PROTO(unsigned long hva), 158 TP_ARGS(hva), 159 160 TP_STRUCT__entry( 161 __field( unsigned long, hva ) 162 ), 163 164 TP_fast_assign( 165 __entry->hva = hva; 166 ), 167 168 TP_printk("mmu notifier set pte hva: %#08lx", __entry->hva) 169 ); 170 171 TRACE_EVENT(kvm_age_hva, 172 TP_PROTO(unsigned long start, unsigned long end), 173 TP_ARGS(start, end), 174 175 TP_STRUCT__entry( 176 __field( unsigned long, start ) 177 __field( unsigned long, end ) 178 ), 179 180 TP_fast_assign( 181 __entry->start = start; 182 __entry->end = end; 183 ), 184 185 TP_printk("mmu notifier age hva: %#08lx -- %#08lx", 186 __entry->start, __entry->end) 187 ); 188 189 TRACE_EVENT(kvm_test_age_hva, 190 TP_PROTO(unsigned long hva), 191 TP_ARGS(hva), 192 193 TP_STRUCT__entry( 194 __field( unsigned long, hva ) 195 ), 196 197 TP_fast_assign( 198 __entry->hva = hva; 199 ), 200 201 TP_printk("mmu notifier test age hva: %#08lx", __entry->hva) 202 ); 203 204 TRACE_EVENT(kvm_set_way_flush, 205 TP_PROTO(unsigned long vcpu_pc, bool cache), 206 TP_ARGS(vcpu_pc, cache), 207 208 TP_STRUCT__entry( 209 __field( unsigned long, vcpu_pc ) 210 __field( bool, cache ) 211 ), 212 213 TP_fast_assign( 214 __entry->vcpu_pc = vcpu_pc; 215 __entry->cache = cache; 216 ), 217 218 TP_printk("S/W flush at 0x%016lx (cache %s)", 219 __entry->vcpu_pc, __entry->cache ? "on" : "off") 220 ); 221 222 TRACE_EVENT(kvm_toggle_cache, 223 TP_PROTO(unsigned long vcpu_pc, bool was, bool now), 224 TP_ARGS(vcpu_pc, was, now), 225 226 TP_STRUCT__entry( 227 __field( unsigned long, vcpu_pc ) 228 __field( bool, was ) 229 __field( bool, now ) 230 ), 231 232 TP_fast_assign( 233 __entry->vcpu_pc = vcpu_pc; 234 __entry->was = was; 235 __entry->now = now; 236 ), 237 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") 241 ); 242 243 /* 244 * Tracepoints for arch_timer 245 */ 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), 249 250 TP_STRUCT__entry( 251 __field( unsigned long, vcpu_id ) 252 __field( __u32, irq ) 253 __field( int, level ) 254 ), 255 256 TP_fast_assign( 257 __entry->vcpu_id = vcpu_id; 258 __entry->irq = irq; 259 __entry->level = level; 260 ), 261 262 TP_printk("VCPU: %ld, IRQ %d, level %d", 263 __entry->vcpu_id, __entry->irq, __entry->level) 264 ); 265 266 TRACE_EVENT(kvm_get_timer_map, 267 TP_PROTO(unsigned long vcpu_id, struct timer_map *map), 268 TP_ARGS(vcpu_id, map), 269 270 TP_STRUCT__entry( 271 __field( unsigned long, vcpu_id ) 272 __field( int, direct_vtimer ) 273 __field( int, direct_ptimer ) 274 __field( int, emul_ptimer ) 275 ), 276 277 TP_fast_assign( 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; 284 ), 285 286 TP_printk("VCPU: %ld, dv: %d, dp: %d, ep: %d", 287 __entry->vcpu_id, 288 __entry->direct_vtimer, 289 __entry->direct_ptimer, 290 __entry->emul_ptimer) 291 ); 292 293 TRACE_EVENT(kvm_timer_save_state, 294 TP_PROTO(struct arch_timer_context *ctx), 295 TP_ARGS(ctx), 296 297 TP_STRUCT__entry( 298 __field( unsigned long, ctl ) 299 __field( unsigned long long, cval ) 300 __field( int, timer_idx ) 301 ), 302 303 TP_fast_assign( 304 __entry->ctl = timer_get_ctl(ctx); 305 __entry->cval = timer_get_cval(ctx); 306 __entry->timer_idx = arch_timer_ctx_index(ctx); 307 ), 308 309 TP_printk(" CTL: %#08lx CVAL: %#16llx arch_timer_ctx_index: %d", 310 __entry->ctl, 311 __entry->cval, 312 __entry->timer_idx) 313 ); 314 315 TRACE_EVENT(kvm_timer_restore_state, 316 TP_PROTO(struct arch_timer_context *ctx), 317 TP_ARGS(ctx), 318 319 TP_STRUCT__entry( 320 __field( unsigned long, ctl ) 321 __field( unsigned long long, cval ) 322 __field( int, timer_idx ) 323 ), 324 325 TP_fast_assign( 326 __entry->ctl = timer_get_ctl(ctx); 327 __entry->cval = timer_get_cval(ctx); 328 __entry->timer_idx = arch_timer_ctx_index(ctx); 329 ), 330 331 TP_printk("CTL: %#08lx CVAL: %#16llx arch_timer_ctx_index: %d", 332 __entry->ctl, 333 __entry->cval, 334 __entry->timer_idx) 335 ); 336 337 TRACE_EVENT(kvm_timer_hrtimer_expire, 338 TP_PROTO(struct arch_timer_context *ctx), 339 TP_ARGS(ctx), 340 341 TP_STRUCT__entry( 342 __field( int, timer_idx ) 343 ), 344 345 TP_fast_assign( 346 __entry->timer_idx = arch_timer_ctx_index(ctx); 347 ), 348 349 TP_printk("arch_timer_ctx_index: %d", __entry->timer_idx) 350 ); 351 352 TRACE_EVENT(kvm_timer_emulate, 353 TP_PROTO(struct arch_timer_context *ctx, bool should_fire), 354 TP_ARGS(ctx, should_fire), 355 356 TP_STRUCT__entry( 357 __field( int, timer_idx ) 358 __field( bool, should_fire ) 359 ), 360 361 TP_fast_assign( 362 __entry->timer_idx = arch_timer_ctx_index(ctx); 363 __entry->should_fire = should_fire; 364 ), 365 366 TP_printk("arch_timer_ctx_index: %d (should_fire: %d)", 367 __entry->timer_idx, __entry->should_fire) 368 ); 369 370 #endif /* _TRACE_ARM_ARM64_KVM_H */ 371 372 #undef TRACE_INCLUDE_PATH 373 #define TRACE_INCLUDE_PATH . 374 #undef TRACE_INCLUDE_FILE 375 #define TRACE_INCLUDE_FILE trace_arm 376 377 /* This part must be outside protection */ 378 #include <trace/define_trace.h> 379