1 #if !defined(_TRACE_KVM_MAIN_H) || defined(TRACE_HEADER_MULTI_READ) 2 #define _TRACE_KVM_MAIN_H 3 4 #include <linux/tracepoint.h> 5 6 #undef TRACE_SYSTEM 7 #define TRACE_SYSTEM kvm 8 9 #define ERSN(x) { KVM_EXIT_##x, "KVM_EXIT_" #x } 10 11 #define kvm_trace_exit_reason \ 12 ERSN(UNKNOWN), ERSN(EXCEPTION), ERSN(IO), ERSN(HYPERCALL), \ 13 ERSN(DEBUG), ERSN(HLT), ERSN(MMIO), ERSN(IRQ_WINDOW_OPEN), \ 14 ERSN(SHUTDOWN), ERSN(FAIL_ENTRY), ERSN(INTR), ERSN(SET_TPR), \ 15 ERSN(TPR_ACCESS), ERSN(S390_SIEIC), ERSN(S390_RESET), ERSN(DCR),\ 16 ERSN(NMI), ERSN(INTERNAL_ERROR), ERSN(OSI), ERSN(PAPR_HCALL), \ 17 ERSN(S390_UCONTROL), ERSN(WATCHDOG), ERSN(S390_TSCH) 18 19 TRACE_EVENT(kvm_userspace_exit, 20 TP_PROTO(__u32 reason, int errno), 21 TP_ARGS(reason, errno), 22 23 TP_STRUCT__entry( 24 __field( __u32, reason ) 25 __field( int, errno ) 26 ), 27 28 TP_fast_assign( 29 __entry->reason = reason; 30 __entry->errno = errno; 31 ), 32 33 TP_printk("reason %s (%d)", 34 __entry->errno < 0 ? 35 (__entry->errno == -EINTR ? "restart" : "error") : 36 __print_symbolic(__entry->reason, kvm_trace_exit_reason), 37 __entry->errno < 0 ? -__entry->errno : __entry->reason) 38 ); 39 40 TRACE_EVENT(kvm_vcpu_wakeup, 41 TP_PROTO(__u64 ns, bool waited, bool valid), 42 TP_ARGS(ns, waited, valid), 43 44 TP_STRUCT__entry( 45 __field( __u64, ns ) 46 __field( bool, waited ) 47 __field( bool, valid ) 48 ), 49 50 TP_fast_assign( 51 __entry->ns = ns; 52 __entry->waited = waited; 53 __entry->valid = valid; 54 ), 55 56 TP_printk("%s time %lld ns, polling %s", 57 __entry->waited ? "wait" : "poll", 58 __entry->ns, 59 __entry->valid ? "valid" : "invalid") 60 ); 61 62 #if defined(CONFIG_HAVE_KVM_IRQFD) 63 TRACE_EVENT(kvm_set_irq, 64 TP_PROTO(unsigned int gsi, int level, int irq_source_id), 65 TP_ARGS(gsi, level, irq_source_id), 66 67 TP_STRUCT__entry( 68 __field( unsigned int, gsi ) 69 __field( int, level ) 70 __field( int, irq_source_id ) 71 ), 72 73 TP_fast_assign( 74 __entry->gsi = gsi; 75 __entry->level = level; 76 __entry->irq_source_id = irq_source_id; 77 ), 78 79 TP_printk("gsi %u level %d source %d", 80 __entry->gsi, __entry->level, __entry->irq_source_id) 81 ); 82 #endif /* defined(CONFIG_HAVE_KVM_IRQFD) */ 83 84 #if defined(__KVM_HAVE_IOAPIC) 85 #define kvm_deliver_mode \ 86 {0x0, "Fixed"}, \ 87 {0x1, "LowPrio"}, \ 88 {0x2, "SMI"}, \ 89 {0x3, "Res3"}, \ 90 {0x4, "NMI"}, \ 91 {0x5, "INIT"}, \ 92 {0x6, "SIPI"}, \ 93 {0x7, "ExtINT"} 94 95 TRACE_EVENT(kvm_ioapic_set_irq, 96 TP_PROTO(__u64 e, int pin, bool coalesced), 97 TP_ARGS(e, pin, coalesced), 98 99 TP_STRUCT__entry( 100 __field( __u64, e ) 101 __field( int, pin ) 102 __field( bool, coalesced ) 103 ), 104 105 TP_fast_assign( 106 __entry->e = e; 107 __entry->pin = pin; 108 __entry->coalesced = coalesced; 109 ), 110 111 TP_printk("pin %u dst %x vec %u (%s|%s|%s%s)%s", 112 __entry->pin, (u8)(__entry->e >> 56), (u8)__entry->e, 113 __print_symbolic((__entry->e >> 8 & 0x7), kvm_deliver_mode), 114 (__entry->e & (1<<11)) ? "logical" : "physical", 115 (__entry->e & (1<<15)) ? "level" : "edge", 116 (__entry->e & (1<<16)) ? "|masked" : "", 117 __entry->coalesced ? " (coalesced)" : "") 118 ); 119 120 TRACE_EVENT(kvm_ioapic_delayed_eoi_inj, 121 TP_PROTO(__u64 e), 122 TP_ARGS(e), 123 124 TP_STRUCT__entry( 125 __field( __u64, e ) 126 ), 127 128 TP_fast_assign( 129 __entry->e = e; 130 ), 131 132 TP_printk("dst %x vec %u (%s|%s|%s%s)", 133 (u8)(__entry->e >> 56), (u8)__entry->e, 134 __print_symbolic((__entry->e >> 8 & 0x7), kvm_deliver_mode), 135 (__entry->e & (1<<11)) ? "logical" : "physical", 136 (__entry->e & (1<<15)) ? "level" : "edge", 137 (__entry->e & (1<<16)) ? "|masked" : "") 138 ); 139 140 TRACE_EVENT(kvm_msi_set_irq, 141 TP_PROTO(__u64 address, __u64 data), 142 TP_ARGS(address, data), 143 144 TP_STRUCT__entry( 145 __field( __u64, address ) 146 __field( __u64, data ) 147 ), 148 149 TP_fast_assign( 150 __entry->address = address; 151 __entry->data = data; 152 ), 153 154 TP_printk("dst %u vec %u (%s|%s|%s%s)", 155 (u8)(__entry->address >> 12), (u8)__entry->data, 156 __print_symbolic((__entry->data >> 8 & 0x7), kvm_deliver_mode), 157 (__entry->address & (1<<2)) ? "logical" : "physical", 158 (__entry->data & (1<<15)) ? "level" : "edge", 159 (__entry->address & (1<<3)) ? "|rh" : "") 160 ); 161 162 #define kvm_irqchips \ 163 {KVM_IRQCHIP_PIC_MASTER, "PIC master"}, \ 164 {KVM_IRQCHIP_PIC_SLAVE, "PIC slave"}, \ 165 {KVM_IRQCHIP_IOAPIC, "IOAPIC"} 166 167 #endif /* defined(__KVM_HAVE_IOAPIC) */ 168 169 #if defined(CONFIG_HAVE_KVM_IRQFD) 170 171 #ifdef kvm_irqchips 172 #define kvm_ack_irq_string "irqchip %s pin %u" 173 #define kvm_ack_irq_parm __print_symbolic(__entry->irqchip, kvm_irqchips), __entry->pin 174 #else 175 #define kvm_ack_irq_string "irqchip %d pin %u" 176 #define kvm_ack_irq_parm __entry->irqchip, __entry->pin 177 #endif 178 179 TRACE_EVENT(kvm_ack_irq, 180 TP_PROTO(unsigned int irqchip, unsigned int pin), 181 TP_ARGS(irqchip, pin), 182 183 TP_STRUCT__entry( 184 __field( unsigned int, irqchip ) 185 __field( unsigned int, pin ) 186 ), 187 188 TP_fast_assign( 189 __entry->irqchip = irqchip; 190 __entry->pin = pin; 191 ), 192 193 TP_printk(kvm_ack_irq_string, kvm_ack_irq_parm) 194 ); 195 196 #endif /* defined(CONFIG_HAVE_KVM_IRQFD) */ 197 198 199 200 #define KVM_TRACE_MMIO_READ_UNSATISFIED 0 201 #define KVM_TRACE_MMIO_READ 1 202 #define KVM_TRACE_MMIO_WRITE 2 203 204 #define kvm_trace_symbol_mmio \ 205 { KVM_TRACE_MMIO_READ_UNSATISFIED, "unsatisfied-read" }, \ 206 { KVM_TRACE_MMIO_READ, "read" }, \ 207 { KVM_TRACE_MMIO_WRITE, "write" } 208 209 TRACE_EVENT(kvm_mmio, 210 TP_PROTO(int type, int len, u64 gpa, u64 val), 211 TP_ARGS(type, len, gpa, val), 212 213 TP_STRUCT__entry( 214 __field( u32, type ) 215 __field( u32, len ) 216 __field( u64, gpa ) 217 __field( u64, val ) 218 ), 219 220 TP_fast_assign( 221 __entry->type = type; 222 __entry->len = len; 223 __entry->gpa = gpa; 224 __entry->val = val; 225 ), 226 227 TP_printk("mmio %s len %u gpa 0x%llx val 0x%llx", 228 __print_symbolic(__entry->type, kvm_trace_symbol_mmio), 229 __entry->len, __entry->gpa, __entry->val) 230 ); 231 232 #define kvm_fpu_load_symbol \ 233 {0, "unload"}, \ 234 {1, "load"} 235 236 TRACE_EVENT(kvm_fpu, 237 TP_PROTO(int load), 238 TP_ARGS(load), 239 240 TP_STRUCT__entry( 241 __field( u32, load ) 242 ), 243 244 TP_fast_assign( 245 __entry->load = load; 246 ), 247 248 TP_printk("%s", __print_symbolic(__entry->load, kvm_fpu_load_symbol)) 249 ); 250 251 TRACE_EVENT(kvm_age_page, 252 TP_PROTO(ulong gfn, int level, struct kvm_memory_slot *slot, int ref), 253 TP_ARGS(gfn, level, slot, ref), 254 255 TP_STRUCT__entry( 256 __field( u64, hva ) 257 __field( u64, gfn ) 258 __field( u8, level ) 259 __field( u8, referenced ) 260 ), 261 262 TP_fast_assign( 263 __entry->gfn = gfn; 264 __entry->level = level; 265 __entry->hva = ((gfn - slot->base_gfn) << 266 PAGE_SHIFT) + slot->userspace_addr; 267 __entry->referenced = ref; 268 ), 269 270 TP_printk("hva %llx gfn %llx level %u %s", 271 __entry->hva, __entry->gfn, __entry->level, 272 __entry->referenced ? "YOUNG" : "OLD") 273 ); 274 275 #ifdef CONFIG_KVM_ASYNC_PF 276 DECLARE_EVENT_CLASS(kvm_async_get_page_class, 277 278 TP_PROTO(u64 gva, u64 gfn), 279 280 TP_ARGS(gva, gfn), 281 282 TP_STRUCT__entry( 283 __field(__u64, gva) 284 __field(u64, gfn) 285 ), 286 287 TP_fast_assign( 288 __entry->gva = gva; 289 __entry->gfn = gfn; 290 ), 291 292 TP_printk("gva = %#llx, gfn = %#llx", __entry->gva, __entry->gfn) 293 ); 294 295 DEFINE_EVENT(kvm_async_get_page_class, kvm_try_async_get_page, 296 297 TP_PROTO(u64 gva, u64 gfn), 298 299 TP_ARGS(gva, gfn) 300 ); 301 302 DEFINE_EVENT(kvm_async_get_page_class, kvm_async_pf_doublefault, 303 304 TP_PROTO(u64 gva, u64 gfn), 305 306 TP_ARGS(gva, gfn) 307 ); 308 309 DECLARE_EVENT_CLASS(kvm_async_pf_nopresent_ready, 310 311 TP_PROTO(u64 token, u64 gva), 312 313 TP_ARGS(token, gva), 314 315 TP_STRUCT__entry( 316 __field(__u64, token) 317 __field(__u64, gva) 318 ), 319 320 TP_fast_assign( 321 __entry->token = token; 322 __entry->gva = gva; 323 ), 324 325 TP_printk("token %#llx gva %#llx", __entry->token, __entry->gva) 326 327 ); 328 329 DEFINE_EVENT(kvm_async_pf_nopresent_ready, kvm_async_pf_not_present, 330 331 TP_PROTO(u64 token, u64 gva), 332 333 TP_ARGS(token, gva) 334 ); 335 336 DEFINE_EVENT(kvm_async_pf_nopresent_ready, kvm_async_pf_ready, 337 338 TP_PROTO(u64 token, u64 gva), 339 340 TP_ARGS(token, gva) 341 ); 342 343 TRACE_EVENT( 344 kvm_async_pf_completed, 345 TP_PROTO(unsigned long address, u64 gva), 346 TP_ARGS(address, gva), 347 348 TP_STRUCT__entry( 349 __field(unsigned long, address) 350 __field(u64, gva) 351 ), 352 353 TP_fast_assign( 354 __entry->address = address; 355 __entry->gva = gva; 356 ), 357 358 TP_printk("gva %#llx address %#lx", __entry->gva, 359 __entry->address) 360 ); 361 362 #endif 363 364 TRACE_EVENT(kvm_halt_poll_ns, 365 TP_PROTO(bool grow, unsigned int vcpu_id, unsigned int new, 366 unsigned int old), 367 TP_ARGS(grow, vcpu_id, new, old), 368 369 TP_STRUCT__entry( 370 __field(bool, grow) 371 __field(unsigned int, vcpu_id) 372 __field(unsigned int, new) 373 __field(unsigned int, old) 374 ), 375 376 TP_fast_assign( 377 __entry->grow = grow; 378 __entry->vcpu_id = vcpu_id; 379 __entry->new = new; 380 __entry->old = old; 381 ), 382 383 TP_printk("vcpu %u: halt_poll_ns %u (%s %u)", 384 __entry->vcpu_id, 385 __entry->new, 386 __entry->grow ? "grow" : "shrink", 387 __entry->old) 388 ); 389 390 #define trace_kvm_halt_poll_ns_grow(vcpu_id, new, old) \ 391 trace_kvm_halt_poll_ns(true, vcpu_id, new, old) 392 #define trace_kvm_halt_poll_ns_shrink(vcpu_id, new, old) \ 393 trace_kvm_halt_poll_ns(false, vcpu_id, new, old) 394 395 #endif /* _TRACE_KVM_MAIN_H */ 396 397 /* This part must be outside protection */ 398 #include <trace/define_trace.h> 399