1 #if !defined(_TRACE_KVM_H) || defined(TRACE_HEADER_MULTI_READ) 2 #define _TRACE_KVM_H 3 4 #include <linux/tracepoint.h> 5 6 #undef TRACE_SYSTEM 7 #define TRACE_SYSTEM kvm 8 #define TRACE_INCLUDE_PATH arch/x86/kvm 9 #define TRACE_INCLUDE_FILE trace 10 11 /* 12 * Tracepoint for guest mode entry. 13 */ 14 TRACE_EVENT(kvm_entry, 15 TP_PROTO(unsigned int vcpu_id), 16 TP_ARGS(vcpu_id), 17 18 TP_STRUCT__entry( 19 __field( unsigned int, vcpu_id ) 20 ), 21 22 TP_fast_assign( 23 __entry->vcpu_id = vcpu_id; 24 ), 25 26 TP_printk("vcpu %u", __entry->vcpu_id) 27 ); 28 29 /* 30 * Tracepoint for hypercall. 31 */ 32 TRACE_EVENT(kvm_hypercall, 33 TP_PROTO(unsigned long nr, unsigned long a0, unsigned long a1, 34 unsigned long a2, unsigned long a3), 35 TP_ARGS(nr, a0, a1, a2, a3), 36 37 TP_STRUCT__entry( 38 __field( unsigned long, nr ) 39 __field( unsigned long, a0 ) 40 __field( unsigned long, a1 ) 41 __field( unsigned long, a2 ) 42 __field( unsigned long, a3 ) 43 ), 44 45 TP_fast_assign( 46 __entry->nr = nr; 47 __entry->a0 = a0; 48 __entry->a1 = a1; 49 __entry->a2 = a2; 50 __entry->a3 = a3; 51 ), 52 53 TP_printk("nr 0x%lx a0 0x%lx a1 0x%lx a2 0x%lx a3 0x%lx", 54 __entry->nr, __entry->a0, __entry->a1, __entry->a2, 55 __entry->a3) 56 ); 57 58 /* 59 * Tracepoint for PIO. 60 */ 61 TRACE_EVENT(kvm_pio, 62 TP_PROTO(unsigned int rw, unsigned int port, unsigned int size, 63 unsigned int count), 64 TP_ARGS(rw, port, size, count), 65 66 TP_STRUCT__entry( 67 __field( unsigned int, rw ) 68 __field( unsigned int, port ) 69 __field( unsigned int, size ) 70 __field( unsigned int, count ) 71 ), 72 73 TP_fast_assign( 74 __entry->rw = rw; 75 __entry->port = port; 76 __entry->size = size; 77 __entry->count = count; 78 ), 79 80 TP_printk("pio_%s at 0x%x size %d count %d", 81 __entry->rw ? "write" : "read", 82 __entry->port, __entry->size, __entry->count) 83 ); 84 85 /* 86 * Tracepoint for cpuid. 87 */ 88 TRACE_EVENT(kvm_cpuid, 89 TP_PROTO(unsigned int function, unsigned long rax, unsigned long rbx, 90 unsigned long rcx, unsigned long rdx), 91 TP_ARGS(function, rax, rbx, rcx, rdx), 92 93 TP_STRUCT__entry( 94 __field( unsigned int, function ) 95 __field( unsigned long, rax ) 96 __field( unsigned long, rbx ) 97 __field( unsigned long, rcx ) 98 __field( unsigned long, rdx ) 99 ), 100 101 TP_fast_assign( 102 __entry->function = function; 103 __entry->rax = rax; 104 __entry->rbx = rbx; 105 __entry->rcx = rcx; 106 __entry->rdx = rdx; 107 ), 108 109 TP_printk("func %x rax %lx rbx %lx rcx %lx rdx %lx", 110 __entry->function, __entry->rax, 111 __entry->rbx, __entry->rcx, __entry->rdx) 112 ); 113 114 #define AREG(x) { APIC_##x, "APIC_" #x } 115 116 #define kvm_trace_symbol_apic \ 117 AREG(ID), AREG(LVR), AREG(TASKPRI), AREG(ARBPRI), AREG(PROCPRI), \ 118 AREG(EOI), AREG(RRR), AREG(LDR), AREG(DFR), AREG(SPIV), AREG(ISR), \ 119 AREG(TMR), AREG(IRR), AREG(ESR), AREG(ICR), AREG(ICR2), AREG(LVTT), \ 120 AREG(LVTTHMR), AREG(LVTPC), AREG(LVT0), AREG(LVT1), AREG(LVTERR), \ 121 AREG(TMICT), AREG(TMCCT), AREG(TDCR), AREG(SELF_IPI), AREG(EFEAT), \ 122 AREG(ECTRL) 123 /* 124 * Tracepoint for apic access. 125 */ 126 TRACE_EVENT(kvm_apic, 127 TP_PROTO(unsigned int rw, unsigned int reg, unsigned int val), 128 TP_ARGS(rw, reg, val), 129 130 TP_STRUCT__entry( 131 __field( unsigned int, rw ) 132 __field( unsigned int, reg ) 133 __field( unsigned int, val ) 134 ), 135 136 TP_fast_assign( 137 __entry->rw = rw; 138 __entry->reg = reg; 139 __entry->val = val; 140 ), 141 142 TP_printk("apic_%s %s = 0x%x", 143 __entry->rw ? "write" : "read", 144 __print_symbolic(__entry->reg, kvm_trace_symbol_apic), 145 __entry->val) 146 ); 147 148 #define trace_kvm_apic_read(reg, val) trace_kvm_apic(0, reg, val) 149 #define trace_kvm_apic_write(reg, val) trace_kvm_apic(1, reg, val) 150 151 /* 152 * Tracepoint for kvm guest exit: 153 */ 154 TRACE_EVENT(kvm_exit, 155 TP_PROTO(unsigned int exit_reason, unsigned long guest_rip), 156 TP_ARGS(exit_reason, guest_rip), 157 158 TP_STRUCT__entry( 159 __field( unsigned int, exit_reason ) 160 __field( unsigned long, guest_rip ) 161 ), 162 163 TP_fast_assign( 164 __entry->exit_reason = exit_reason; 165 __entry->guest_rip = guest_rip; 166 ), 167 168 TP_printk("reason %s rip 0x%lx", 169 ftrace_print_symbols_seq(p, __entry->exit_reason, 170 kvm_x86_ops->exit_reasons_str), 171 __entry->guest_rip) 172 ); 173 174 /* 175 * Tracepoint for kvm interrupt injection: 176 */ 177 TRACE_EVENT(kvm_inj_virq, 178 TP_PROTO(unsigned int irq), 179 TP_ARGS(irq), 180 181 TP_STRUCT__entry( 182 __field( unsigned int, irq ) 183 ), 184 185 TP_fast_assign( 186 __entry->irq = irq; 187 ), 188 189 TP_printk("irq %u", __entry->irq) 190 ); 191 192 /* 193 * Tracepoint for page fault. 194 */ 195 TRACE_EVENT(kvm_page_fault, 196 TP_PROTO(unsigned long fault_address, unsigned int error_code), 197 TP_ARGS(fault_address, error_code), 198 199 TP_STRUCT__entry( 200 __field( unsigned long, fault_address ) 201 __field( unsigned int, error_code ) 202 ), 203 204 TP_fast_assign( 205 __entry->fault_address = fault_address; 206 __entry->error_code = error_code; 207 ), 208 209 TP_printk("address %lx error_code %x", 210 __entry->fault_address, __entry->error_code) 211 ); 212 213 /* 214 * Tracepoint for guest MSR access. 215 */ 216 TRACE_EVENT(kvm_msr, 217 TP_PROTO(unsigned int rw, unsigned int ecx, unsigned long data), 218 TP_ARGS(rw, ecx, data), 219 220 TP_STRUCT__entry( 221 __field( unsigned int, rw ) 222 __field( unsigned int, ecx ) 223 __field( unsigned long, data ) 224 ), 225 226 TP_fast_assign( 227 __entry->rw = rw; 228 __entry->ecx = ecx; 229 __entry->data = data; 230 ), 231 232 TP_printk("msr_%s %x = 0x%lx", 233 __entry->rw ? "write" : "read", 234 __entry->ecx, __entry->data) 235 ); 236 237 #define trace_kvm_msr_read(ecx, data) trace_kvm_msr(0, ecx, data) 238 #define trace_kvm_msr_write(ecx, data) trace_kvm_msr(1, ecx, data) 239 240 /* 241 * Tracepoint for guest CR access. 242 */ 243 TRACE_EVENT(kvm_cr, 244 TP_PROTO(unsigned int rw, unsigned int cr, unsigned long val), 245 TP_ARGS(rw, cr, val), 246 247 TP_STRUCT__entry( 248 __field( unsigned int, rw ) 249 __field( unsigned int, cr ) 250 __field( unsigned long, val ) 251 ), 252 253 TP_fast_assign( 254 __entry->rw = rw; 255 __entry->cr = cr; 256 __entry->val = val; 257 ), 258 259 TP_printk("cr_%s %x = 0x%lx", 260 __entry->rw ? "write" : "read", 261 __entry->cr, __entry->val) 262 ); 263 264 #define trace_kvm_cr_read(cr, val) trace_kvm_cr(0, cr, val) 265 #define trace_kvm_cr_write(cr, val) trace_kvm_cr(1, cr, val) 266 267 #endif /* _TRACE_KVM_H */ 268 269 /* This part must be outside protection */ 270 #include <trace/define_trace.h> 271