Marcelo Tosatti | 229456f | 2009-06-17 09:22:14 -0300 | [diff] [blame] | 1 | #if !defined(_TRACE_KVM_H) || defined(TRACE_HEADER_MULTI_READ) |
| 2 | #define _TRACE_KVM_H |
| 3 | |
| 4 | #include <linux/tracepoint.h> |
Stefan Hajnoczi | 0d460ff | 2011-07-22 12:46:53 +0100 | [diff] [blame] | 5 | #include <asm/vmx.h> |
| 6 | #include <asm/svm.h> |
Marcelo Tosatti | 229456f | 2009-06-17 09:22:14 -0300 | [diff] [blame] | 7 | |
| 8 | #undef TRACE_SYSTEM |
| 9 | #define TRACE_SYSTEM kvm |
Marcelo Tosatti | 229456f | 2009-06-17 09:22:14 -0300 | [diff] [blame] | 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 | /* |
Gleb Natapov | 55cd8e5 | 2010-01-17 15:51:22 +0200 | [diff] [blame] | 59 | * Tracepoint for hypercall. |
| 60 | */ |
| 61 | TRACE_EVENT(kvm_hv_hypercall, |
| 62 | TP_PROTO(__u16 code, bool fast, __u16 rep_cnt, __u16 rep_idx, |
| 63 | __u64 ingpa, __u64 outgpa), |
| 64 | TP_ARGS(code, fast, rep_cnt, rep_idx, ingpa, outgpa), |
| 65 | |
| 66 | TP_STRUCT__entry( |
Gleb Natapov | 55cd8e5 | 2010-01-17 15:51:22 +0200 | [diff] [blame] | 67 | __field( __u16, rep_cnt ) |
| 68 | __field( __u16, rep_idx ) |
| 69 | __field( __u64, ingpa ) |
| 70 | __field( __u64, outgpa ) |
David Sharp | d5bf2ff | 2010-12-03 16:13:21 -0800 | [diff] [blame] | 71 | __field( __u16, code ) |
| 72 | __field( bool, fast ) |
Gleb Natapov | 55cd8e5 | 2010-01-17 15:51:22 +0200 | [diff] [blame] | 73 | ), |
| 74 | |
| 75 | TP_fast_assign( |
Gleb Natapov | 55cd8e5 | 2010-01-17 15:51:22 +0200 | [diff] [blame] | 76 | __entry->rep_cnt = rep_cnt; |
| 77 | __entry->rep_idx = rep_idx; |
| 78 | __entry->ingpa = ingpa; |
| 79 | __entry->outgpa = outgpa; |
David Sharp | d5bf2ff | 2010-12-03 16:13:21 -0800 | [diff] [blame] | 80 | __entry->code = code; |
| 81 | __entry->fast = fast; |
Gleb Natapov | 55cd8e5 | 2010-01-17 15:51:22 +0200 | [diff] [blame] | 82 | ), |
| 83 | |
| 84 | TP_printk("code 0x%x %s cnt 0x%x idx 0x%x in 0x%llx out 0x%llx", |
| 85 | __entry->code, __entry->fast ? "fast" : "slow", |
| 86 | __entry->rep_cnt, __entry->rep_idx, __entry->ingpa, |
| 87 | __entry->outgpa) |
| 88 | ); |
| 89 | |
| 90 | /* |
Marcelo Tosatti | 229456f | 2009-06-17 09:22:14 -0300 | [diff] [blame] | 91 | * Tracepoint for PIO. |
| 92 | */ |
| 93 | TRACE_EVENT(kvm_pio, |
| 94 | TP_PROTO(unsigned int rw, unsigned int port, unsigned int size, |
| 95 | unsigned int count), |
| 96 | TP_ARGS(rw, port, size, count), |
| 97 | |
| 98 | TP_STRUCT__entry( |
| 99 | __field( unsigned int, rw ) |
| 100 | __field( unsigned int, port ) |
| 101 | __field( unsigned int, size ) |
| 102 | __field( unsigned int, count ) |
| 103 | ), |
| 104 | |
| 105 | TP_fast_assign( |
| 106 | __entry->rw = rw; |
| 107 | __entry->port = port; |
| 108 | __entry->size = size; |
| 109 | __entry->count = count; |
| 110 | ), |
| 111 | |
| 112 | TP_printk("pio_%s at 0x%x size %d count %d", |
| 113 | __entry->rw ? "write" : "read", |
| 114 | __entry->port, __entry->size, __entry->count) |
| 115 | ); |
| 116 | |
| 117 | /* |
| 118 | * Tracepoint for cpuid. |
| 119 | */ |
| 120 | TRACE_EVENT(kvm_cpuid, |
| 121 | TP_PROTO(unsigned int function, unsigned long rax, unsigned long rbx, |
| 122 | unsigned long rcx, unsigned long rdx), |
| 123 | TP_ARGS(function, rax, rbx, rcx, rdx), |
| 124 | |
| 125 | TP_STRUCT__entry( |
| 126 | __field( unsigned int, function ) |
| 127 | __field( unsigned long, rax ) |
| 128 | __field( unsigned long, rbx ) |
| 129 | __field( unsigned long, rcx ) |
| 130 | __field( unsigned long, rdx ) |
| 131 | ), |
| 132 | |
| 133 | TP_fast_assign( |
| 134 | __entry->function = function; |
| 135 | __entry->rax = rax; |
| 136 | __entry->rbx = rbx; |
| 137 | __entry->rcx = rcx; |
| 138 | __entry->rdx = rdx; |
| 139 | ), |
| 140 | |
| 141 | TP_printk("func %x rax %lx rbx %lx rcx %lx rdx %lx", |
| 142 | __entry->function, __entry->rax, |
| 143 | __entry->rbx, __entry->rcx, __entry->rdx) |
| 144 | ); |
| 145 | |
Avi Kivity | cb24772 | 2009-07-01 18:25:44 +0300 | [diff] [blame] | 146 | #define AREG(x) { APIC_##x, "APIC_" #x } |
| 147 | |
| 148 | #define kvm_trace_symbol_apic \ |
| 149 | AREG(ID), AREG(LVR), AREG(TASKPRI), AREG(ARBPRI), AREG(PROCPRI), \ |
| 150 | AREG(EOI), AREG(RRR), AREG(LDR), AREG(DFR), AREG(SPIV), AREG(ISR), \ |
| 151 | AREG(TMR), AREG(IRR), AREG(ESR), AREG(ICR), AREG(ICR2), AREG(LVTT), \ |
| 152 | AREG(LVTTHMR), AREG(LVTPC), AREG(LVT0), AREG(LVT1), AREG(LVTERR), \ |
| 153 | AREG(TMICT), AREG(TMCCT), AREG(TDCR), AREG(SELF_IPI), AREG(EFEAT), \ |
| 154 | AREG(ECTRL) |
Marcelo Tosatti | 229456f | 2009-06-17 09:22:14 -0300 | [diff] [blame] | 155 | /* |
| 156 | * Tracepoint for apic access. |
| 157 | */ |
| 158 | TRACE_EVENT(kvm_apic, |
| 159 | TP_PROTO(unsigned int rw, unsigned int reg, unsigned int val), |
| 160 | TP_ARGS(rw, reg, val), |
| 161 | |
| 162 | TP_STRUCT__entry( |
| 163 | __field( unsigned int, rw ) |
| 164 | __field( unsigned int, reg ) |
| 165 | __field( unsigned int, val ) |
| 166 | ), |
| 167 | |
| 168 | TP_fast_assign( |
| 169 | __entry->rw = rw; |
| 170 | __entry->reg = reg; |
| 171 | __entry->val = val; |
| 172 | ), |
| 173 | |
Avi Kivity | cb24772 | 2009-07-01 18:25:44 +0300 | [diff] [blame] | 174 | TP_printk("apic_%s %s = 0x%x", |
Marcelo Tosatti | 229456f | 2009-06-17 09:22:14 -0300 | [diff] [blame] | 175 | __entry->rw ? "write" : "read", |
Avi Kivity | cb24772 | 2009-07-01 18:25:44 +0300 | [diff] [blame] | 176 | __print_symbolic(__entry->reg, kvm_trace_symbol_apic), |
| 177 | __entry->val) |
Marcelo Tosatti | 229456f | 2009-06-17 09:22:14 -0300 | [diff] [blame] | 178 | ); |
| 179 | |
| 180 | #define trace_kvm_apic_read(reg, val) trace_kvm_apic(0, reg, val) |
| 181 | #define trace_kvm_apic_write(reg, val) trace_kvm_apic(1, reg, val) |
| 182 | |
Avi Kivity | aa17911 | 2010-11-17 18:44:19 +0200 | [diff] [blame] | 183 | #define KVM_ISA_VMX 1 |
| 184 | #define KVM_ISA_SVM 2 |
| 185 | |
Stefan Hajnoczi | 0d460ff | 2011-07-22 12:46:53 +0100 | [diff] [blame] | 186 | #define VMX_EXIT_REASONS \ |
| 187 | { EXIT_REASON_EXCEPTION_NMI, "EXCEPTION_NMI" }, \ |
| 188 | { EXIT_REASON_EXTERNAL_INTERRUPT, "EXTERNAL_INTERRUPT" }, \ |
| 189 | { EXIT_REASON_TRIPLE_FAULT, "TRIPLE_FAULT" }, \ |
| 190 | { EXIT_REASON_PENDING_INTERRUPT, "PENDING_INTERRUPT" }, \ |
| 191 | { EXIT_REASON_NMI_WINDOW, "NMI_WINDOW" }, \ |
| 192 | { EXIT_REASON_TASK_SWITCH, "TASK_SWITCH" }, \ |
| 193 | { EXIT_REASON_CPUID, "CPUID" }, \ |
| 194 | { EXIT_REASON_HLT, "HLT" }, \ |
| 195 | { EXIT_REASON_INVLPG, "INVLPG" }, \ |
| 196 | { EXIT_REASON_RDPMC, "RDPMC" }, \ |
| 197 | { EXIT_REASON_RDTSC, "RDTSC" }, \ |
| 198 | { EXIT_REASON_VMCALL, "VMCALL" }, \ |
| 199 | { EXIT_REASON_VMCLEAR, "VMCLEAR" }, \ |
| 200 | { EXIT_REASON_VMLAUNCH, "VMLAUNCH" }, \ |
| 201 | { EXIT_REASON_VMPTRLD, "VMPTRLD" }, \ |
| 202 | { EXIT_REASON_VMPTRST, "VMPTRST" }, \ |
| 203 | { EXIT_REASON_VMREAD, "VMREAD" }, \ |
| 204 | { EXIT_REASON_VMRESUME, "VMRESUME" }, \ |
| 205 | { EXIT_REASON_VMWRITE, "VMWRITE" }, \ |
| 206 | { EXIT_REASON_VMOFF, "VMOFF" }, \ |
| 207 | { EXIT_REASON_VMON, "VMON" }, \ |
| 208 | { EXIT_REASON_CR_ACCESS, "CR_ACCESS" }, \ |
| 209 | { EXIT_REASON_DR_ACCESS, "DR_ACCESS" }, \ |
| 210 | { EXIT_REASON_IO_INSTRUCTION, "IO_INSTRUCTION" }, \ |
| 211 | { EXIT_REASON_MSR_READ, "MSR_READ" }, \ |
| 212 | { EXIT_REASON_MSR_WRITE, "MSR_WRITE" }, \ |
| 213 | { EXIT_REASON_MWAIT_INSTRUCTION, "MWAIT_INSTRUCTION" }, \ |
| 214 | { EXIT_REASON_MONITOR_INSTRUCTION, "MONITOR_INSTRUCTION" }, \ |
| 215 | { EXIT_REASON_PAUSE_INSTRUCTION, "PAUSE_INSTRUCTION" }, \ |
| 216 | { EXIT_REASON_MCE_DURING_VMENTRY, "MCE_DURING_VMENTRY" }, \ |
| 217 | { EXIT_REASON_TPR_BELOW_THRESHOLD, "TPR_BELOW_THRESHOLD" }, \ |
| 218 | { EXIT_REASON_APIC_ACCESS, "APIC_ACCESS" }, \ |
| 219 | { EXIT_REASON_EPT_VIOLATION, "EPT_VIOLATION" }, \ |
| 220 | { EXIT_REASON_EPT_MISCONFIG, "EPT_MISCONFIG" }, \ |
| 221 | { EXIT_REASON_WBINVD, "WBINVD" } |
| 222 | |
| 223 | #define SVM_EXIT_REASONS \ |
| 224 | { SVM_EXIT_READ_CR0, "read_cr0" }, \ |
| 225 | { SVM_EXIT_READ_CR3, "read_cr3" }, \ |
| 226 | { SVM_EXIT_READ_CR4, "read_cr4" }, \ |
| 227 | { SVM_EXIT_READ_CR8, "read_cr8" }, \ |
| 228 | { SVM_EXIT_WRITE_CR0, "write_cr0" }, \ |
| 229 | { SVM_EXIT_WRITE_CR3, "write_cr3" }, \ |
| 230 | { SVM_EXIT_WRITE_CR4, "write_cr4" }, \ |
| 231 | { SVM_EXIT_WRITE_CR8, "write_cr8" }, \ |
| 232 | { SVM_EXIT_READ_DR0, "read_dr0" }, \ |
| 233 | { SVM_EXIT_READ_DR1, "read_dr1" }, \ |
| 234 | { SVM_EXIT_READ_DR2, "read_dr2" }, \ |
| 235 | { SVM_EXIT_READ_DR3, "read_dr3" }, \ |
| 236 | { SVM_EXIT_WRITE_DR0, "write_dr0" }, \ |
| 237 | { SVM_EXIT_WRITE_DR1, "write_dr1" }, \ |
| 238 | { SVM_EXIT_WRITE_DR2, "write_dr2" }, \ |
| 239 | { SVM_EXIT_WRITE_DR3, "write_dr3" }, \ |
| 240 | { SVM_EXIT_WRITE_DR5, "write_dr5" }, \ |
| 241 | { SVM_EXIT_WRITE_DR7, "write_dr7" }, \ |
| 242 | { SVM_EXIT_EXCP_BASE + DB_VECTOR, "DB excp" }, \ |
| 243 | { SVM_EXIT_EXCP_BASE + BP_VECTOR, "BP excp" }, \ |
| 244 | { SVM_EXIT_EXCP_BASE + UD_VECTOR, "UD excp" }, \ |
| 245 | { SVM_EXIT_EXCP_BASE + PF_VECTOR, "PF excp" }, \ |
| 246 | { SVM_EXIT_EXCP_BASE + NM_VECTOR, "NM excp" }, \ |
| 247 | { SVM_EXIT_EXCP_BASE + MC_VECTOR, "MC excp" }, \ |
| 248 | { SVM_EXIT_INTR, "interrupt" }, \ |
| 249 | { SVM_EXIT_NMI, "nmi" }, \ |
| 250 | { SVM_EXIT_SMI, "smi" }, \ |
| 251 | { SVM_EXIT_INIT, "init" }, \ |
| 252 | { SVM_EXIT_VINTR, "vintr" }, \ |
| 253 | { SVM_EXIT_CPUID, "cpuid" }, \ |
| 254 | { SVM_EXIT_INVD, "invd" }, \ |
| 255 | { SVM_EXIT_HLT, "hlt" }, \ |
| 256 | { SVM_EXIT_INVLPG, "invlpg" }, \ |
| 257 | { SVM_EXIT_INVLPGA, "invlpga" }, \ |
| 258 | { SVM_EXIT_IOIO, "io" }, \ |
| 259 | { SVM_EXIT_MSR, "msr" }, \ |
| 260 | { SVM_EXIT_TASK_SWITCH, "task_switch" }, \ |
| 261 | { SVM_EXIT_SHUTDOWN, "shutdown" }, \ |
| 262 | { SVM_EXIT_VMRUN, "vmrun" }, \ |
| 263 | { SVM_EXIT_VMMCALL, "hypercall" }, \ |
| 264 | { SVM_EXIT_VMLOAD, "vmload" }, \ |
| 265 | { SVM_EXIT_VMSAVE, "vmsave" }, \ |
| 266 | { SVM_EXIT_STGI, "stgi" }, \ |
| 267 | { SVM_EXIT_CLGI, "clgi" }, \ |
| 268 | { SVM_EXIT_SKINIT, "skinit" }, \ |
| 269 | { SVM_EXIT_WBINVD, "wbinvd" }, \ |
| 270 | { SVM_EXIT_MONITOR, "monitor" }, \ |
| 271 | { SVM_EXIT_MWAIT, "mwait" }, \ |
| 272 | { SVM_EXIT_XSETBV, "xsetbv" }, \ |
| 273 | { SVM_EXIT_NPF, "npf" } |
| 274 | |
Marcelo Tosatti | 229456f | 2009-06-17 09:22:14 -0300 | [diff] [blame] | 275 | /* |
| 276 | * Tracepoint for kvm guest exit: |
| 277 | */ |
| 278 | TRACE_EVENT(kvm_exit, |
Avi Kivity | aa17911 | 2010-11-17 18:44:19 +0200 | [diff] [blame] | 279 | TP_PROTO(unsigned int exit_reason, struct kvm_vcpu *vcpu, u32 isa), |
| 280 | TP_ARGS(exit_reason, vcpu, isa), |
Marcelo Tosatti | 229456f | 2009-06-17 09:22:14 -0300 | [diff] [blame] | 281 | |
| 282 | TP_STRUCT__entry( |
| 283 | __field( unsigned int, exit_reason ) |
| 284 | __field( unsigned long, guest_rip ) |
Avi Kivity | aa17911 | 2010-11-17 18:44:19 +0200 | [diff] [blame] | 285 | __field( u32, isa ) |
Avi Kivity | 586f960 | 2010-11-18 13:09:54 +0200 | [diff] [blame] | 286 | __field( u64, info1 ) |
| 287 | __field( u64, info2 ) |
Marcelo Tosatti | 229456f | 2009-06-17 09:22:14 -0300 | [diff] [blame] | 288 | ), |
| 289 | |
| 290 | TP_fast_assign( |
| 291 | __entry->exit_reason = exit_reason; |
Avi Kivity | 5bfd8b5 | 2010-03-11 10:50:44 +0200 | [diff] [blame] | 292 | __entry->guest_rip = kvm_rip_read(vcpu); |
Avi Kivity | aa17911 | 2010-11-17 18:44:19 +0200 | [diff] [blame] | 293 | __entry->isa = isa; |
Avi Kivity | 586f960 | 2010-11-18 13:09:54 +0200 | [diff] [blame] | 294 | kvm_x86_ops->get_exit_info(vcpu, &__entry->info1, |
| 295 | &__entry->info2); |
Marcelo Tosatti | 229456f | 2009-06-17 09:22:14 -0300 | [diff] [blame] | 296 | ), |
| 297 | |
Avi Kivity | 586f960 | 2010-11-18 13:09:54 +0200 | [diff] [blame] | 298 | TP_printk("reason %s rip 0x%lx info %llx %llx", |
Stefan Hajnoczi | 0d460ff | 2011-07-22 12:46:53 +0100 | [diff] [blame] | 299 | (__entry->isa == KVM_ISA_VMX) ? |
| 300 | __print_symbolic(__entry->exit_reason, VMX_EXIT_REASONS) : |
| 301 | __print_symbolic(__entry->exit_reason, SVM_EXIT_REASONS), |
Avi Kivity | 586f960 | 2010-11-18 13:09:54 +0200 | [diff] [blame] | 302 | __entry->guest_rip, __entry->info1, __entry->info2) |
Marcelo Tosatti | 229456f | 2009-06-17 09:22:14 -0300 | [diff] [blame] | 303 | ); |
| 304 | |
| 305 | /* |
| 306 | * Tracepoint for kvm interrupt injection: |
| 307 | */ |
| 308 | TRACE_EVENT(kvm_inj_virq, |
| 309 | TP_PROTO(unsigned int irq), |
| 310 | TP_ARGS(irq), |
| 311 | |
| 312 | TP_STRUCT__entry( |
| 313 | __field( unsigned int, irq ) |
| 314 | ), |
| 315 | |
| 316 | TP_fast_assign( |
| 317 | __entry->irq = irq; |
| 318 | ), |
| 319 | |
| 320 | TP_printk("irq %u", __entry->irq) |
| 321 | ); |
| 322 | |
Avi Kivity | 5c1c85d0 | 2010-03-11 13:01:59 +0200 | [diff] [blame] | 323 | #define EXS(x) { x##_VECTOR, "#" #x } |
| 324 | |
| 325 | #define kvm_trace_sym_exc \ |
| 326 | EXS(DE), EXS(DB), EXS(BP), EXS(OF), EXS(BR), EXS(UD), EXS(NM), \ |
| 327 | EXS(DF), EXS(TS), EXS(NP), EXS(SS), EXS(GP), EXS(PF), \ |
| 328 | EXS(MF), EXS(MC) |
| 329 | |
| 330 | /* |
| 331 | * Tracepoint for kvm interrupt injection: |
| 332 | */ |
| 333 | TRACE_EVENT(kvm_inj_exception, |
| 334 | TP_PROTO(unsigned exception, bool has_error, unsigned error_code), |
| 335 | TP_ARGS(exception, has_error, error_code), |
| 336 | |
| 337 | TP_STRUCT__entry( |
| 338 | __field( u8, exception ) |
| 339 | __field( u8, has_error ) |
| 340 | __field( u32, error_code ) |
| 341 | ), |
| 342 | |
| 343 | TP_fast_assign( |
| 344 | __entry->exception = exception; |
| 345 | __entry->has_error = has_error; |
| 346 | __entry->error_code = error_code; |
| 347 | ), |
| 348 | |
| 349 | TP_printk("%s (0x%x)", |
| 350 | __print_symbolic(__entry->exception, kvm_trace_sym_exc), |
| 351 | /* FIXME: don't print error_code if not present */ |
| 352 | __entry->has_error ? __entry->error_code : 0) |
| 353 | ); |
| 354 | |
Marcelo Tosatti | 229456f | 2009-06-17 09:22:14 -0300 | [diff] [blame] | 355 | /* |
| 356 | * Tracepoint for page fault. |
| 357 | */ |
| 358 | TRACE_EVENT(kvm_page_fault, |
| 359 | TP_PROTO(unsigned long fault_address, unsigned int error_code), |
| 360 | TP_ARGS(fault_address, error_code), |
| 361 | |
| 362 | TP_STRUCT__entry( |
| 363 | __field( unsigned long, fault_address ) |
| 364 | __field( unsigned int, error_code ) |
| 365 | ), |
| 366 | |
| 367 | TP_fast_assign( |
| 368 | __entry->fault_address = fault_address; |
| 369 | __entry->error_code = error_code; |
| 370 | ), |
| 371 | |
| 372 | TP_printk("address %lx error_code %x", |
| 373 | __entry->fault_address, __entry->error_code) |
| 374 | ); |
| 375 | |
| 376 | /* |
| 377 | * Tracepoint for guest MSR access. |
| 378 | */ |
| 379 | TRACE_EVENT(kvm_msr, |
Avi Kivity | 5920027 | 2010-01-25 19:47:02 +0200 | [diff] [blame] | 380 | TP_PROTO(unsigned write, u32 ecx, u64 data, bool exception), |
| 381 | TP_ARGS(write, ecx, data, exception), |
Marcelo Tosatti | 229456f | 2009-06-17 09:22:14 -0300 | [diff] [blame] | 382 | |
| 383 | TP_STRUCT__entry( |
Avi Kivity | 6e7d152 | 2010-01-25 19:36:03 +0200 | [diff] [blame] | 384 | __field( unsigned, write ) |
| 385 | __field( u32, ecx ) |
| 386 | __field( u64, data ) |
Avi Kivity | 5920027 | 2010-01-25 19:47:02 +0200 | [diff] [blame] | 387 | __field( u8, exception ) |
Marcelo Tosatti | 229456f | 2009-06-17 09:22:14 -0300 | [diff] [blame] | 388 | ), |
| 389 | |
| 390 | TP_fast_assign( |
Avi Kivity | 6e7d152 | 2010-01-25 19:36:03 +0200 | [diff] [blame] | 391 | __entry->write = write; |
Marcelo Tosatti | 229456f | 2009-06-17 09:22:14 -0300 | [diff] [blame] | 392 | __entry->ecx = ecx; |
| 393 | __entry->data = data; |
Avi Kivity | 5920027 | 2010-01-25 19:47:02 +0200 | [diff] [blame] | 394 | __entry->exception = exception; |
Marcelo Tosatti | 229456f | 2009-06-17 09:22:14 -0300 | [diff] [blame] | 395 | ), |
| 396 | |
Avi Kivity | 5920027 | 2010-01-25 19:47:02 +0200 | [diff] [blame] | 397 | TP_printk("msr_%s %x = 0x%llx%s", |
Avi Kivity | 6e7d152 | 2010-01-25 19:36:03 +0200 | [diff] [blame] | 398 | __entry->write ? "write" : "read", |
Avi Kivity | 5920027 | 2010-01-25 19:47:02 +0200 | [diff] [blame] | 399 | __entry->ecx, __entry->data, |
| 400 | __entry->exception ? " (#GP)" : "") |
Marcelo Tosatti | 229456f | 2009-06-17 09:22:14 -0300 | [diff] [blame] | 401 | ); |
| 402 | |
Avi Kivity | 5920027 | 2010-01-25 19:47:02 +0200 | [diff] [blame] | 403 | #define trace_kvm_msr_read(ecx, data) trace_kvm_msr(0, ecx, data, false) |
| 404 | #define trace_kvm_msr_write(ecx, data) trace_kvm_msr(1, ecx, data, false) |
| 405 | #define trace_kvm_msr_read_ex(ecx) trace_kvm_msr(0, ecx, 0, true) |
| 406 | #define trace_kvm_msr_write_ex(ecx, data) trace_kvm_msr(1, ecx, data, true) |
Marcelo Tosatti | 229456f | 2009-06-17 09:22:14 -0300 | [diff] [blame] | 407 | |
| 408 | /* |
| 409 | * Tracepoint for guest CR access. |
| 410 | */ |
| 411 | TRACE_EVENT(kvm_cr, |
| 412 | TP_PROTO(unsigned int rw, unsigned int cr, unsigned long val), |
| 413 | TP_ARGS(rw, cr, val), |
| 414 | |
| 415 | TP_STRUCT__entry( |
| 416 | __field( unsigned int, rw ) |
| 417 | __field( unsigned int, cr ) |
| 418 | __field( unsigned long, val ) |
| 419 | ), |
| 420 | |
| 421 | TP_fast_assign( |
| 422 | __entry->rw = rw; |
| 423 | __entry->cr = cr; |
| 424 | __entry->val = val; |
| 425 | ), |
| 426 | |
| 427 | TP_printk("cr_%s %x = 0x%lx", |
| 428 | __entry->rw ? "write" : "read", |
| 429 | __entry->cr, __entry->val) |
| 430 | ); |
| 431 | |
| 432 | #define trace_kvm_cr_read(cr, val) trace_kvm_cr(0, cr, val) |
| 433 | #define trace_kvm_cr_write(cr, val) trace_kvm_cr(1, cr, val) |
| 434 | |
Gleb Natapov | 1000ff8 | 2009-07-07 16:00:57 +0300 | [diff] [blame] | 435 | TRACE_EVENT(kvm_pic_set_irq, |
| 436 | TP_PROTO(__u8 chip, __u8 pin, __u8 elcr, __u8 imr, bool coalesced), |
| 437 | TP_ARGS(chip, pin, elcr, imr, coalesced), |
| 438 | |
| 439 | TP_STRUCT__entry( |
| 440 | __field( __u8, chip ) |
| 441 | __field( __u8, pin ) |
| 442 | __field( __u8, elcr ) |
| 443 | __field( __u8, imr ) |
| 444 | __field( bool, coalesced ) |
| 445 | ), |
| 446 | |
| 447 | TP_fast_assign( |
| 448 | __entry->chip = chip; |
| 449 | __entry->pin = pin; |
| 450 | __entry->elcr = elcr; |
| 451 | __entry->imr = imr; |
| 452 | __entry->coalesced = coalesced; |
| 453 | ), |
| 454 | |
| 455 | TP_printk("chip %u pin %u (%s%s)%s", |
| 456 | __entry->chip, __entry->pin, |
| 457 | (__entry->elcr & (1 << __entry->pin)) ? "level":"edge", |
| 458 | (__entry->imr & (1 << __entry->pin)) ? "|masked":"", |
| 459 | __entry->coalesced ? " (coalesced)" : "") |
| 460 | ); |
| 461 | |
| 462 | #define kvm_apic_dst_shorthand \ |
| 463 | {0x0, "dst"}, \ |
| 464 | {0x1, "self"}, \ |
| 465 | {0x2, "all"}, \ |
| 466 | {0x3, "all-but-self"} |
| 467 | |
| 468 | TRACE_EVENT(kvm_apic_ipi, |
| 469 | TP_PROTO(__u32 icr_low, __u32 dest_id), |
| 470 | TP_ARGS(icr_low, dest_id), |
| 471 | |
| 472 | TP_STRUCT__entry( |
| 473 | __field( __u32, icr_low ) |
| 474 | __field( __u32, dest_id ) |
| 475 | ), |
| 476 | |
| 477 | TP_fast_assign( |
| 478 | __entry->icr_low = icr_low; |
| 479 | __entry->dest_id = dest_id; |
| 480 | ), |
| 481 | |
| 482 | TP_printk("dst %x vec %u (%s|%s|%s|%s|%s)", |
| 483 | __entry->dest_id, (u8)__entry->icr_low, |
| 484 | __print_symbolic((__entry->icr_low >> 8 & 0x7), |
| 485 | kvm_deliver_mode), |
| 486 | (__entry->icr_low & (1<<11)) ? "logical" : "physical", |
| 487 | (__entry->icr_low & (1<<14)) ? "assert" : "de-assert", |
| 488 | (__entry->icr_low & (1<<15)) ? "level" : "edge", |
| 489 | __print_symbolic((__entry->icr_low >> 18 & 0x3), |
| 490 | kvm_apic_dst_shorthand)) |
| 491 | ); |
| 492 | |
| 493 | TRACE_EVENT(kvm_apic_accept_irq, |
| 494 | TP_PROTO(__u32 apicid, __u16 dm, __u8 tm, __u8 vec, bool coalesced), |
| 495 | TP_ARGS(apicid, dm, tm, vec, coalesced), |
| 496 | |
| 497 | TP_STRUCT__entry( |
| 498 | __field( __u32, apicid ) |
| 499 | __field( __u16, dm ) |
| 500 | __field( __u8, tm ) |
| 501 | __field( __u8, vec ) |
| 502 | __field( bool, coalesced ) |
| 503 | ), |
| 504 | |
| 505 | TP_fast_assign( |
| 506 | __entry->apicid = apicid; |
| 507 | __entry->dm = dm; |
| 508 | __entry->tm = tm; |
| 509 | __entry->vec = vec; |
| 510 | __entry->coalesced = coalesced; |
| 511 | ), |
| 512 | |
| 513 | TP_printk("apicid %x vec %u (%s|%s)%s", |
| 514 | __entry->apicid, __entry->vec, |
| 515 | __print_symbolic((__entry->dm >> 8 & 0x7), kvm_deliver_mode), |
| 516 | __entry->tm ? "level" : "edge", |
| 517 | __entry->coalesced ? " (coalesced)" : "") |
| 518 | ); |
| 519 | |
Michael S. Tsirkin | ae7a2a3 | 2012-06-24 19:25:07 +0300 | [diff] [blame^] | 520 | TRACE_EVENT(kvm_eoi, |
| 521 | TP_PROTO(struct kvm_lapic *apic, int vector), |
| 522 | TP_ARGS(apic, vector), |
| 523 | |
| 524 | TP_STRUCT__entry( |
| 525 | __field( __u32, apicid ) |
| 526 | __field( int, vector ) |
| 527 | ), |
| 528 | |
| 529 | TP_fast_assign( |
| 530 | __entry->apicid = apic->vcpu->vcpu_id; |
| 531 | __entry->vector = vector; |
| 532 | ), |
| 533 | |
| 534 | TP_printk("apicid %x vector %d", __entry->apicid, __entry->vector) |
| 535 | ); |
| 536 | |
| 537 | TRACE_EVENT(kvm_pv_eoi, |
| 538 | TP_PROTO(struct kvm_lapic *apic, int vector), |
| 539 | TP_ARGS(apic, vector), |
| 540 | |
| 541 | TP_STRUCT__entry( |
| 542 | __field( __u32, apicid ) |
| 543 | __field( int, vector ) |
| 544 | ), |
| 545 | |
| 546 | TP_fast_assign( |
| 547 | __entry->apicid = apic->vcpu->vcpu_id; |
| 548 | __entry->vector = vector; |
| 549 | ), |
| 550 | |
| 551 | TP_printk("apicid %x vector %d", __entry->apicid, __entry->vector) |
| 552 | ); |
| 553 | |
Joerg Roedel | 0ac406d | 2009-10-09 16:08:27 +0200 | [diff] [blame] | 554 | /* |
| 555 | * Tracepoint for nested VMRUN |
| 556 | */ |
| 557 | TRACE_EVENT(kvm_nested_vmrun, |
| 558 | TP_PROTO(__u64 rip, __u64 vmcb, __u64 nested_rip, __u32 int_ctl, |
| 559 | __u32 event_inj, bool npt), |
| 560 | TP_ARGS(rip, vmcb, nested_rip, int_ctl, event_inj, npt), |
| 561 | |
| 562 | TP_STRUCT__entry( |
| 563 | __field( __u64, rip ) |
| 564 | __field( __u64, vmcb ) |
| 565 | __field( __u64, nested_rip ) |
| 566 | __field( __u32, int_ctl ) |
| 567 | __field( __u32, event_inj ) |
| 568 | __field( bool, npt ) |
| 569 | ), |
| 570 | |
| 571 | TP_fast_assign( |
| 572 | __entry->rip = rip; |
| 573 | __entry->vmcb = vmcb; |
| 574 | __entry->nested_rip = nested_rip; |
| 575 | __entry->int_ctl = int_ctl; |
| 576 | __entry->event_inj = event_inj; |
| 577 | __entry->npt = npt; |
| 578 | ), |
| 579 | |
| 580 | TP_printk("rip: 0x%016llx vmcb: 0x%016llx nrip: 0x%016llx int_ctl: 0x%08x " |
Joerg Roedel | 052ce62 | 2010-02-19 16:23:09 +0100 | [diff] [blame] | 581 | "event_inj: 0x%08x npt: %s", |
Joerg Roedel | 0ac406d | 2009-10-09 16:08:27 +0200 | [diff] [blame] | 582 | __entry->rip, __entry->vmcb, __entry->nested_rip, |
| 583 | __entry->int_ctl, __entry->event_inj, |
| 584 | __entry->npt ? "on" : "off") |
| 585 | ); |
| 586 | |
Joerg Roedel | 2e554e8 | 2010-02-24 18:59:14 +0100 | [diff] [blame] | 587 | TRACE_EVENT(kvm_nested_intercepts, |
| 588 | TP_PROTO(__u16 cr_read, __u16 cr_write, __u32 exceptions, __u64 intercept), |
| 589 | TP_ARGS(cr_read, cr_write, exceptions, intercept), |
| 590 | |
| 591 | TP_STRUCT__entry( |
| 592 | __field( __u16, cr_read ) |
| 593 | __field( __u16, cr_write ) |
| 594 | __field( __u32, exceptions ) |
| 595 | __field( __u64, intercept ) |
| 596 | ), |
| 597 | |
| 598 | TP_fast_assign( |
| 599 | __entry->cr_read = cr_read; |
| 600 | __entry->cr_write = cr_write; |
| 601 | __entry->exceptions = exceptions; |
| 602 | __entry->intercept = intercept; |
| 603 | ), |
| 604 | |
| 605 | TP_printk("cr_read: %04x cr_write: %04x excp: %08x intercept: %016llx", |
| 606 | __entry->cr_read, __entry->cr_write, __entry->exceptions, |
| 607 | __entry->intercept) |
| 608 | ); |
Joerg Roedel | d8cabdd | 2009-10-09 16:08:28 +0200 | [diff] [blame] | 609 | /* |
| 610 | * Tracepoint for #VMEXIT while nested |
| 611 | */ |
| 612 | TRACE_EVENT(kvm_nested_vmexit, |
| 613 | TP_PROTO(__u64 rip, __u32 exit_code, |
| 614 | __u64 exit_info1, __u64 exit_info2, |
Stefan Hajnoczi | e097e5f | 2011-07-22 12:46:52 +0100 | [diff] [blame] | 615 | __u32 exit_int_info, __u32 exit_int_info_err, __u32 isa), |
Joerg Roedel | d8cabdd | 2009-10-09 16:08:28 +0200 | [diff] [blame] | 616 | TP_ARGS(rip, exit_code, exit_info1, exit_info2, |
Stefan Hajnoczi | e097e5f | 2011-07-22 12:46:52 +0100 | [diff] [blame] | 617 | exit_int_info, exit_int_info_err, isa), |
Joerg Roedel | d8cabdd | 2009-10-09 16:08:28 +0200 | [diff] [blame] | 618 | |
| 619 | TP_STRUCT__entry( |
| 620 | __field( __u64, rip ) |
| 621 | __field( __u32, exit_code ) |
| 622 | __field( __u64, exit_info1 ) |
| 623 | __field( __u64, exit_info2 ) |
| 624 | __field( __u32, exit_int_info ) |
| 625 | __field( __u32, exit_int_info_err ) |
Stefan Hajnoczi | e097e5f | 2011-07-22 12:46:52 +0100 | [diff] [blame] | 626 | __field( __u32, isa ) |
Joerg Roedel | d8cabdd | 2009-10-09 16:08:28 +0200 | [diff] [blame] | 627 | ), |
| 628 | |
| 629 | TP_fast_assign( |
| 630 | __entry->rip = rip; |
| 631 | __entry->exit_code = exit_code; |
| 632 | __entry->exit_info1 = exit_info1; |
| 633 | __entry->exit_info2 = exit_info2; |
| 634 | __entry->exit_int_info = exit_int_info; |
| 635 | __entry->exit_int_info_err = exit_int_info_err; |
Stefan Hajnoczi | e097e5f | 2011-07-22 12:46:52 +0100 | [diff] [blame] | 636 | __entry->isa = isa; |
Joerg Roedel | d8cabdd | 2009-10-09 16:08:28 +0200 | [diff] [blame] | 637 | ), |
| 638 | TP_printk("rip: 0x%016llx reason: %s ext_inf1: 0x%016llx " |
Joerg Roedel | 052ce62 | 2010-02-19 16:23:09 +0100 | [diff] [blame] | 639 | "ext_inf2: 0x%016llx ext_int: 0x%08x ext_int_err: 0x%08x", |
Joerg Roedel | d8cabdd | 2009-10-09 16:08:28 +0200 | [diff] [blame] | 640 | __entry->rip, |
Stefan Hajnoczi | 0d460ff | 2011-07-22 12:46:53 +0100 | [diff] [blame] | 641 | (__entry->isa == KVM_ISA_VMX) ? |
| 642 | __print_symbolic(__entry->exit_code, VMX_EXIT_REASONS) : |
| 643 | __print_symbolic(__entry->exit_code, SVM_EXIT_REASONS), |
Joerg Roedel | d8cabdd | 2009-10-09 16:08:28 +0200 | [diff] [blame] | 644 | __entry->exit_info1, __entry->exit_info2, |
| 645 | __entry->exit_int_info, __entry->exit_int_info_err) |
| 646 | ); |
| 647 | |
Joerg Roedel | 17897f3 | 2009-10-09 16:08:29 +0200 | [diff] [blame] | 648 | /* |
| 649 | * Tracepoint for #VMEXIT reinjected to the guest |
| 650 | */ |
| 651 | TRACE_EVENT(kvm_nested_vmexit_inject, |
| 652 | TP_PROTO(__u32 exit_code, |
| 653 | __u64 exit_info1, __u64 exit_info2, |
Stefan Hajnoczi | e097e5f | 2011-07-22 12:46:52 +0100 | [diff] [blame] | 654 | __u32 exit_int_info, __u32 exit_int_info_err, __u32 isa), |
Joerg Roedel | 17897f3 | 2009-10-09 16:08:29 +0200 | [diff] [blame] | 655 | TP_ARGS(exit_code, exit_info1, exit_info2, |
Stefan Hajnoczi | e097e5f | 2011-07-22 12:46:52 +0100 | [diff] [blame] | 656 | exit_int_info, exit_int_info_err, isa), |
Joerg Roedel | 17897f3 | 2009-10-09 16:08:29 +0200 | [diff] [blame] | 657 | |
| 658 | TP_STRUCT__entry( |
| 659 | __field( __u32, exit_code ) |
| 660 | __field( __u64, exit_info1 ) |
| 661 | __field( __u64, exit_info2 ) |
| 662 | __field( __u32, exit_int_info ) |
| 663 | __field( __u32, exit_int_info_err ) |
Stefan Hajnoczi | e097e5f | 2011-07-22 12:46:52 +0100 | [diff] [blame] | 664 | __field( __u32, isa ) |
Joerg Roedel | 17897f3 | 2009-10-09 16:08:29 +0200 | [diff] [blame] | 665 | ), |
| 666 | |
| 667 | TP_fast_assign( |
| 668 | __entry->exit_code = exit_code; |
| 669 | __entry->exit_info1 = exit_info1; |
| 670 | __entry->exit_info2 = exit_info2; |
| 671 | __entry->exit_int_info = exit_int_info; |
| 672 | __entry->exit_int_info_err = exit_int_info_err; |
Stefan Hajnoczi | e097e5f | 2011-07-22 12:46:52 +0100 | [diff] [blame] | 673 | __entry->isa = isa; |
Joerg Roedel | 17897f3 | 2009-10-09 16:08:29 +0200 | [diff] [blame] | 674 | ), |
| 675 | |
| 676 | TP_printk("reason: %s ext_inf1: 0x%016llx " |
Joerg Roedel | 052ce62 | 2010-02-19 16:23:09 +0100 | [diff] [blame] | 677 | "ext_inf2: 0x%016llx ext_int: 0x%08x ext_int_err: 0x%08x", |
Stefan Hajnoczi | 0d460ff | 2011-07-22 12:46:53 +0100 | [diff] [blame] | 678 | (__entry->isa == KVM_ISA_VMX) ? |
| 679 | __print_symbolic(__entry->exit_code, VMX_EXIT_REASONS) : |
| 680 | __print_symbolic(__entry->exit_code, SVM_EXIT_REASONS), |
Joerg Roedel | 17897f3 | 2009-10-09 16:08:29 +0200 | [diff] [blame] | 681 | __entry->exit_info1, __entry->exit_info2, |
| 682 | __entry->exit_int_info, __entry->exit_int_info_err) |
| 683 | ); |
Joerg Roedel | 236649d | 2009-10-09 16:08:30 +0200 | [diff] [blame] | 684 | |
| 685 | /* |
| 686 | * Tracepoint for nested #vmexit because of interrupt pending |
| 687 | */ |
| 688 | TRACE_EVENT(kvm_nested_intr_vmexit, |
| 689 | TP_PROTO(__u64 rip), |
| 690 | TP_ARGS(rip), |
| 691 | |
| 692 | TP_STRUCT__entry( |
| 693 | __field( __u64, rip ) |
| 694 | ), |
| 695 | |
| 696 | TP_fast_assign( |
| 697 | __entry->rip = rip |
| 698 | ), |
| 699 | |
Joerg Roedel | 052ce62 | 2010-02-19 16:23:09 +0100 | [diff] [blame] | 700 | TP_printk("rip: 0x%016llx", __entry->rip) |
Joerg Roedel | 236649d | 2009-10-09 16:08:30 +0200 | [diff] [blame] | 701 | ); |
Joerg Roedel | ec1ff79 | 2009-10-09 16:08:31 +0200 | [diff] [blame] | 702 | |
| 703 | /* |
| 704 | * Tracepoint for nested #vmexit because of interrupt pending |
| 705 | */ |
| 706 | TRACE_EVENT(kvm_invlpga, |
| 707 | TP_PROTO(__u64 rip, int asid, u64 address), |
| 708 | TP_ARGS(rip, asid, address), |
| 709 | |
| 710 | TP_STRUCT__entry( |
| 711 | __field( __u64, rip ) |
| 712 | __field( int, asid ) |
| 713 | __field( __u64, address ) |
| 714 | ), |
| 715 | |
| 716 | TP_fast_assign( |
| 717 | __entry->rip = rip; |
| 718 | __entry->asid = asid; |
| 719 | __entry->address = address; |
| 720 | ), |
| 721 | |
Joerg Roedel | 052ce62 | 2010-02-19 16:23:09 +0100 | [diff] [blame] | 722 | TP_printk("rip: 0x%016llx asid: %d address: 0x%016llx", |
Joerg Roedel | ec1ff79 | 2009-10-09 16:08:31 +0200 | [diff] [blame] | 723 | __entry->rip, __entry->asid, __entry->address) |
| 724 | ); |
Joerg Roedel | 532a46b | 2009-10-09 16:08:32 +0200 | [diff] [blame] | 725 | |
| 726 | /* |
| 727 | * Tracepoint for nested #vmexit because of interrupt pending |
| 728 | */ |
| 729 | TRACE_EVENT(kvm_skinit, |
| 730 | TP_PROTO(__u64 rip, __u32 slb), |
| 731 | TP_ARGS(rip, slb), |
| 732 | |
| 733 | TP_STRUCT__entry( |
| 734 | __field( __u64, rip ) |
| 735 | __field( __u32, slb ) |
| 736 | ), |
| 737 | |
| 738 | TP_fast_assign( |
| 739 | __entry->rip = rip; |
| 740 | __entry->slb = slb; |
| 741 | ), |
| 742 | |
Joerg Roedel | 052ce62 | 2010-02-19 16:23:09 +0100 | [diff] [blame] | 743 | TP_printk("rip: 0x%016llx slb: 0x%08x", |
Joerg Roedel | 532a46b | 2009-10-09 16:08:32 +0200 | [diff] [blame] | 744 | __entry->rip, __entry->slb) |
| 745 | ); |
| 746 | |
Avi Kivity | e46479f | 2010-04-11 13:05:16 +0300 | [diff] [blame] | 747 | #define __print_insn(insn, ilen) ({ \ |
| 748 | int i; \ |
| 749 | const char *ret = p->buffer + p->len; \ |
| 750 | \ |
| 751 | for (i = 0; i < ilen; ++i) \ |
| 752 | trace_seq_printf(p, " %02x", insn[i]); \ |
| 753 | trace_seq_printf(p, "%c", 0); \ |
| 754 | ret; \ |
| 755 | }) |
| 756 | |
| 757 | #define KVM_EMUL_INSN_F_CR0_PE (1 << 0) |
| 758 | #define KVM_EMUL_INSN_F_EFL_VM (1 << 1) |
| 759 | #define KVM_EMUL_INSN_F_CS_D (1 << 2) |
| 760 | #define KVM_EMUL_INSN_F_CS_L (1 << 3) |
| 761 | |
| 762 | #define kvm_trace_symbol_emul_flags \ |
| 763 | { 0, "real" }, \ |
| 764 | { KVM_EMUL_INSN_F_CR0_PE \ |
| 765 | | KVM_EMUL_INSN_F_EFL_VM, "vm16" }, \ |
| 766 | { KVM_EMUL_INSN_F_CR0_PE, "prot16" }, \ |
| 767 | { KVM_EMUL_INSN_F_CR0_PE \ |
| 768 | | KVM_EMUL_INSN_F_CS_D, "prot32" }, \ |
| 769 | { KVM_EMUL_INSN_F_CR0_PE \ |
| 770 | | KVM_EMUL_INSN_F_CS_L, "prot64" } |
| 771 | |
| 772 | #define kei_decode_mode(mode) ({ \ |
| 773 | u8 flags = 0xff; \ |
| 774 | switch (mode) { \ |
| 775 | case X86EMUL_MODE_REAL: \ |
| 776 | flags = 0; \ |
| 777 | break; \ |
| 778 | case X86EMUL_MODE_VM86: \ |
| 779 | flags = KVM_EMUL_INSN_F_EFL_VM; \ |
| 780 | break; \ |
| 781 | case X86EMUL_MODE_PROT16: \ |
| 782 | flags = KVM_EMUL_INSN_F_CR0_PE; \ |
| 783 | break; \ |
| 784 | case X86EMUL_MODE_PROT32: \ |
| 785 | flags = KVM_EMUL_INSN_F_CR0_PE \ |
| 786 | | KVM_EMUL_INSN_F_CS_D; \ |
| 787 | break; \ |
| 788 | case X86EMUL_MODE_PROT64: \ |
| 789 | flags = KVM_EMUL_INSN_F_CR0_PE \ |
| 790 | | KVM_EMUL_INSN_F_CS_L; \ |
| 791 | break; \ |
| 792 | } \ |
| 793 | flags; \ |
| 794 | }) |
| 795 | |
| 796 | TRACE_EVENT(kvm_emulate_insn, |
| 797 | TP_PROTO(struct kvm_vcpu *vcpu, __u8 failed), |
| 798 | TP_ARGS(vcpu, failed), |
| 799 | |
| 800 | TP_STRUCT__entry( |
| 801 | __field( __u64, rip ) |
| 802 | __field( __u32, csbase ) |
| 803 | __field( __u8, len ) |
| 804 | __array( __u8, insn, 15 ) |
| 805 | __field( __u8, flags ) |
| 806 | __field( __u8, failed ) |
| 807 | ), |
| 808 | |
| 809 | TP_fast_assign( |
Avi Kivity | 9dac77f | 2011-06-01 15:34:25 +0300 | [diff] [blame] | 810 | __entry->rip = vcpu->arch.emulate_ctxt.fetch.start; |
Avi Kivity | e46479f | 2010-04-11 13:05:16 +0300 | [diff] [blame] | 811 | __entry->csbase = kvm_x86_ops->get_segment_base(vcpu, VCPU_SREG_CS); |
Avi Kivity | 9dac77f | 2011-06-01 15:34:25 +0300 | [diff] [blame] | 812 | __entry->len = vcpu->arch.emulate_ctxt._eip |
| 813 | - vcpu->arch.emulate_ctxt.fetch.start; |
Avi Kivity | e46479f | 2010-04-11 13:05:16 +0300 | [diff] [blame] | 814 | memcpy(__entry->insn, |
Avi Kivity | 9dac77f | 2011-06-01 15:34:25 +0300 | [diff] [blame] | 815 | vcpu->arch.emulate_ctxt.fetch.data, |
Avi Kivity | e46479f | 2010-04-11 13:05:16 +0300 | [diff] [blame] | 816 | 15); |
| 817 | __entry->flags = kei_decode_mode(vcpu->arch.emulate_ctxt.mode); |
| 818 | __entry->failed = failed; |
| 819 | ), |
| 820 | |
| 821 | TP_printk("%x:%llx:%s (%s)%s", |
| 822 | __entry->csbase, __entry->rip, |
| 823 | __print_insn(__entry->insn, __entry->len), |
| 824 | __print_symbolic(__entry->flags, |
| 825 | kvm_trace_symbol_emul_flags), |
| 826 | __entry->failed ? " failed" : "" |
| 827 | ) |
| 828 | ); |
| 829 | |
| 830 | #define trace_kvm_emulate_insn_start(vcpu) trace_kvm_emulate_insn(vcpu, 0) |
| 831 | #define trace_kvm_emulate_insn_failed(vcpu) trace_kvm_emulate_insn(vcpu, 1) |
| 832 | |
Xiao Guangrong | 4f02264 | 2011-07-12 03:34:24 +0800 | [diff] [blame] | 833 | TRACE_EVENT( |
| 834 | vcpu_match_mmio, |
| 835 | TP_PROTO(gva_t gva, gpa_t gpa, bool write, bool gpa_match), |
| 836 | TP_ARGS(gva, gpa, write, gpa_match), |
| 837 | |
| 838 | TP_STRUCT__entry( |
| 839 | __field(gva_t, gva) |
| 840 | __field(gpa_t, gpa) |
| 841 | __field(bool, write) |
| 842 | __field(bool, gpa_match) |
| 843 | ), |
| 844 | |
| 845 | TP_fast_assign( |
| 846 | __entry->gva = gva; |
| 847 | __entry->gpa = gpa; |
| 848 | __entry->write = write; |
| 849 | __entry->gpa_match = gpa_match |
| 850 | ), |
| 851 | |
| 852 | TP_printk("gva %#lx gpa %#llx %s %s", __entry->gva, __entry->gpa, |
| 853 | __entry->write ? "Write" : "Read", |
| 854 | __entry->gpa_match ? "GPA" : "GVA") |
| 855 | ); |
Marcelo Tosatti | 229456f | 2009-06-17 09:22:14 -0300 | [diff] [blame] | 856 | #endif /* _TRACE_KVM_H */ |
| 857 | |
Xiao Guangrong | 2ed152a | 2010-03-10 19:00:43 +0800 | [diff] [blame] | 858 | #undef TRACE_INCLUDE_PATH |
| 859 | #define TRACE_INCLUDE_PATH arch/x86/kvm |
| 860 | #undef TRACE_INCLUDE_FILE |
| 861 | #define TRACE_INCLUDE_FILE trace |
| 862 | |
Marcelo Tosatti | 229456f | 2009-06-17 09:22:14 -0300 | [diff] [blame] | 863 | /* This part must be outside protection */ |
| 864 | #include <trace/define_trace.h> |