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