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 #if defined(CONFIG_HAVE_KVM_IRQFD) 41 TRACE_EVENT(kvm_set_irq, 42 TP_PROTO(unsigned int gsi, int level, int irq_source_id), 43 TP_ARGS(gsi, level, irq_source_id), 44 45 TP_STRUCT__entry( 46 __field( unsigned int, gsi ) 47 __field( int, level ) 48 __field( int, irq_source_id ) 49 ), 50 51 TP_fast_assign( 52 __entry->gsi = gsi; 53 __entry->level = level; 54 __entry->irq_source_id = irq_source_id; 55 ), 56 57 TP_printk("gsi %u level %d source %d", 58 __entry->gsi, __entry->level, __entry->irq_source_id) 59 ); 60 #endif /* defined(CONFIG_HAVE_KVM_IRQFD) */ 61 62 #if defined(__KVM_HAVE_IOAPIC) 63 #define kvm_deliver_mode \ 64 {0x0, "Fixed"}, \ 65 {0x1, "LowPrio"}, \ 66 {0x2, "SMI"}, \ 67 {0x3, "Res3"}, \ 68 {0x4, "NMI"}, \ 69 {0x5, "INIT"}, \ 70 {0x6, "SIPI"}, \ 71 {0x7, "ExtINT"} 72 73 TRACE_EVENT(kvm_ioapic_set_irq, 74 TP_PROTO(__u64 e, int pin, bool coalesced), 75 TP_ARGS(e, pin, coalesced), 76 77 TP_STRUCT__entry( 78 __field( __u64, e ) 79 __field( int, pin ) 80 __field( bool, coalesced ) 81 ), 82 83 TP_fast_assign( 84 __entry->e = e; 85 __entry->pin = pin; 86 __entry->coalesced = coalesced; 87 ), 88 89 TP_printk("pin %u dst %x vec=%u (%s|%s|%s%s)%s", 90 __entry->pin, (u8)(__entry->e >> 56), (u8)__entry->e, 91 __print_symbolic((__entry->e >> 8 & 0x7), kvm_deliver_mode), 92 (__entry->e & (1<<11)) ? "logical" : "physical", 93 (__entry->e & (1<<15)) ? "level" : "edge", 94 (__entry->e & (1<<16)) ? "|masked" : "", 95 __entry->coalesced ? " (coalesced)" : "") 96 ); 97 98 TRACE_EVENT(kvm_ioapic_delayed_eoi_inj, 99 TP_PROTO(__u64 e), 100 TP_ARGS(e), 101 102 TP_STRUCT__entry( 103 __field( __u64, e ) 104 ), 105 106 TP_fast_assign( 107 __entry->e = e; 108 ), 109 110 TP_printk("dst %x vec=%u (%s|%s|%s%s)", 111 (u8)(__entry->e >> 56), (u8)__entry->e, 112 __print_symbolic((__entry->e >> 8 & 0x7), kvm_deliver_mode), 113 (__entry->e & (1<<11)) ? "logical" : "physical", 114 (__entry->e & (1<<15)) ? "level" : "edge", 115 (__entry->e & (1<<16)) ? "|masked" : "") 116 ); 117 118 TRACE_EVENT(kvm_msi_set_irq, 119 TP_PROTO(__u64 address, __u64 data), 120 TP_ARGS(address, data), 121 122 TP_STRUCT__entry( 123 __field( __u64, address ) 124 __field( __u64, data ) 125 ), 126 127 TP_fast_assign( 128 __entry->address = address; 129 __entry->data = data; 130 ), 131 132 TP_printk("dst %u vec %x (%s|%s|%s%s)", 133 (u8)(__entry->address >> 12), (u8)__entry->data, 134 __print_symbolic((__entry->data >> 8 & 0x7), kvm_deliver_mode), 135 (__entry->address & (1<<2)) ? "logical" : "physical", 136 (__entry->data & (1<<15)) ? "level" : "edge", 137 (__entry->address & (1<<3)) ? "|rh" : "") 138 ); 139 140 #define kvm_irqchips \ 141 {KVM_IRQCHIP_PIC_MASTER, "PIC master"}, \ 142 {KVM_IRQCHIP_PIC_SLAVE, "PIC slave"}, \ 143 {KVM_IRQCHIP_IOAPIC, "IOAPIC"} 144 145 #endif /* defined(__KVM_HAVE_IOAPIC) */ 146 147 #if defined(CONFIG_HAVE_KVM_IRQFD) 148 149 #ifdef kvm_irqchips 150 #define kvm_ack_irq_string "irqchip %s pin %u" 151 #define kvm_ack_irq_parm __print_symbolic(__entry->irqchip, kvm_irqchips), __entry->pin 152 #else 153 #define kvm_ack_irq_string "irqchip %d pin %u" 154 #define kvm_ack_irq_parm __entry->irqchip, __entry->pin 155 #endif 156 157 TRACE_EVENT(kvm_ack_irq, 158 TP_PROTO(unsigned int irqchip, unsigned int pin), 159 TP_ARGS(irqchip, pin), 160 161 TP_STRUCT__entry( 162 __field( unsigned int, irqchip ) 163 __field( unsigned int, pin ) 164 ), 165 166 TP_fast_assign( 167 __entry->irqchip = irqchip; 168 __entry->pin = pin; 169 ), 170 171 TP_printk(kvm_ack_irq_string, kvm_ack_irq_parm) 172 ); 173 174 #endif /* defined(CONFIG_HAVE_KVM_IRQFD) */ 175 176 177 178 #define KVM_TRACE_MMIO_READ_UNSATISFIED 0 179 #define KVM_TRACE_MMIO_READ 1 180 #define KVM_TRACE_MMIO_WRITE 2 181 182 #define kvm_trace_symbol_mmio \ 183 { KVM_TRACE_MMIO_READ_UNSATISFIED, "unsatisfied-read" }, \ 184 { KVM_TRACE_MMIO_READ, "read" }, \ 185 { KVM_TRACE_MMIO_WRITE, "write" } 186 187 TRACE_EVENT(kvm_mmio, 188 TP_PROTO(int type, int len, u64 gpa, u64 val), 189 TP_ARGS(type, len, gpa, val), 190 191 TP_STRUCT__entry( 192 __field( u32, type ) 193 __field( u32, len ) 194 __field( u64, gpa ) 195 __field( u64, val ) 196 ), 197 198 TP_fast_assign( 199 __entry->type = type; 200 __entry->len = len; 201 __entry->gpa = gpa; 202 __entry->val = val; 203 ), 204 205 TP_printk("mmio %s len %u gpa 0x%llx val 0x%llx", 206 __print_symbolic(__entry->type, kvm_trace_symbol_mmio), 207 __entry->len, __entry->gpa, __entry->val) 208 ); 209 210 #define kvm_fpu_load_symbol \ 211 {0, "unload"}, \ 212 {1, "load"} 213 214 TRACE_EVENT(kvm_fpu, 215 TP_PROTO(int load), 216 TP_ARGS(load), 217 218 TP_STRUCT__entry( 219 __field( u32, load ) 220 ), 221 222 TP_fast_assign( 223 __entry->load = load; 224 ), 225 226 TP_printk("%s", __print_symbolic(__entry->load, kvm_fpu_load_symbol)) 227 ); 228 229 TRACE_EVENT(kvm_age_page, 230 TP_PROTO(ulong gfn, int level, struct kvm_memory_slot *slot, int ref), 231 TP_ARGS(gfn, level, slot, ref), 232 233 TP_STRUCT__entry( 234 __field( u64, hva ) 235 __field( u64, gfn ) 236 __field( u8, level ) 237 __field( u8, referenced ) 238 ), 239 240 TP_fast_assign( 241 __entry->gfn = gfn; 242 __entry->level = level; 243 __entry->hva = ((gfn - slot->base_gfn) << 244 PAGE_SHIFT) + slot->userspace_addr; 245 __entry->referenced = ref; 246 ), 247 248 TP_printk("hva %llx gfn %llx level %u %s", 249 __entry->hva, __entry->gfn, __entry->level, 250 __entry->referenced ? "YOUNG" : "OLD") 251 ); 252 253 #ifdef CONFIG_KVM_ASYNC_PF 254 DECLARE_EVENT_CLASS(kvm_async_get_page_class, 255 256 TP_PROTO(u64 gva, u64 gfn), 257 258 TP_ARGS(gva, gfn), 259 260 TP_STRUCT__entry( 261 __field(__u64, gva) 262 __field(u64, gfn) 263 ), 264 265 TP_fast_assign( 266 __entry->gva = gva; 267 __entry->gfn = gfn; 268 ), 269 270 TP_printk("gva = %#llx, gfn = %#llx", __entry->gva, __entry->gfn) 271 ); 272 273 DEFINE_EVENT(kvm_async_get_page_class, kvm_try_async_get_page, 274 275 TP_PROTO(u64 gva, u64 gfn), 276 277 TP_ARGS(gva, gfn) 278 ); 279 280 DEFINE_EVENT(kvm_async_get_page_class, kvm_async_pf_doublefault, 281 282 TP_PROTO(u64 gva, u64 gfn), 283 284 TP_ARGS(gva, gfn) 285 ); 286 287 DECLARE_EVENT_CLASS(kvm_async_pf_nopresent_ready, 288 289 TP_PROTO(u64 token, u64 gva), 290 291 TP_ARGS(token, gva), 292 293 TP_STRUCT__entry( 294 __field(__u64, token) 295 __field(__u64, gva) 296 ), 297 298 TP_fast_assign( 299 __entry->token = token; 300 __entry->gva = gva; 301 ), 302 303 TP_printk("token %#llx gva %#llx", __entry->token, __entry->gva) 304 305 ); 306 307 DEFINE_EVENT(kvm_async_pf_nopresent_ready, kvm_async_pf_not_present, 308 309 TP_PROTO(u64 token, u64 gva), 310 311 TP_ARGS(token, gva) 312 ); 313 314 DEFINE_EVENT(kvm_async_pf_nopresent_ready, kvm_async_pf_ready, 315 316 TP_PROTO(u64 token, u64 gva), 317 318 TP_ARGS(token, gva) 319 ); 320 321 TRACE_EVENT( 322 kvm_async_pf_completed, 323 TP_PROTO(unsigned long address, u64 gva), 324 TP_ARGS(address, gva), 325 326 TP_STRUCT__entry( 327 __field(unsigned long, address) 328 __field(u64, gva) 329 ), 330 331 TP_fast_assign( 332 __entry->address = address; 333 __entry->gva = gva; 334 ), 335 336 TP_printk("gva %#llx address %#lx", __entry->gva, 337 __entry->address) 338 ); 339 340 #endif 341 342 #endif /* _TRACE_KVM_MAIN_H */ 343 344 /* This part must be outside protection */ 345 #include <trace/define_trace.h> 346