1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #if !defined(_TRACE_KVM_H) || defined(TRACE_HEADER_MULTI_READ) 3 #define _TRACE_KVM_H 4 5 #include <linux/tracepoint.h> 6 #include <asm/vmx.h> 7 #include <asm/svm.h> 8 #include <asm/clocksource.h> 9 #include <asm/pvclock-abi.h> 10 11 #undef TRACE_SYSTEM 12 #define TRACE_SYSTEM kvm 13 14 /* 15 * Tracepoint for guest mode entry. 16 */ 17 TRACE_EVENT(kvm_entry, 18 TP_PROTO(struct kvm_vcpu *vcpu), 19 TP_ARGS(vcpu), 20 21 TP_STRUCT__entry( 22 __field( unsigned int, vcpu_id ) 23 __field( unsigned long, rip ) 24 ), 25 26 TP_fast_assign( 27 __entry->vcpu_id = vcpu->vcpu_id; 28 __entry->rip = kvm_rip_read(vcpu); 29 ), 30 31 TP_printk("vcpu %u, rip 0x%lx", __entry->vcpu_id, __entry->rip) 32 ); 33 34 /* 35 * Tracepoint for hypercall. 36 */ 37 TRACE_EVENT(kvm_hypercall, 38 TP_PROTO(unsigned long nr, unsigned long a0, unsigned long a1, 39 unsigned long a2, unsigned long a3), 40 TP_ARGS(nr, a0, a1, a2, a3), 41 42 TP_STRUCT__entry( 43 __field( unsigned long, nr ) 44 __field( unsigned long, a0 ) 45 __field( unsigned long, a1 ) 46 __field( unsigned long, a2 ) 47 __field( unsigned long, a3 ) 48 ), 49 50 TP_fast_assign( 51 __entry->nr = nr; 52 __entry->a0 = a0; 53 __entry->a1 = a1; 54 __entry->a2 = a2; 55 __entry->a3 = a3; 56 ), 57 58 TP_printk("nr 0x%lx a0 0x%lx a1 0x%lx a2 0x%lx a3 0x%lx", 59 __entry->nr, __entry->a0, __entry->a1, __entry->a2, 60 __entry->a3) 61 ); 62 63 /* 64 * Tracepoint for hypercall. 65 */ 66 TRACE_EVENT(kvm_hv_hypercall, 67 TP_PROTO(__u16 code, bool fast, __u16 rep_cnt, __u16 rep_idx, 68 __u64 ingpa, __u64 outgpa), 69 TP_ARGS(code, fast, rep_cnt, rep_idx, ingpa, outgpa), 70 71 TP_STRUCT__entry( 72 __field( __u16, rep_cnt ) 73 __field( __u16, rep_idx ) 74 __field( __u64, ingpa ) 75 __field( __u64, outgpa ) 76 __field( __u16, code ) 77 __field( bool, fast ) 78 ), 79 80 TP_fast_assign( 81 __entry->rep_cnt = rep_cnt; 82 __entry->rep_idx = rep_idx; 83 __entry->ingpa = ingpa; 84 __entry->outgpa = outgpa; 85 __entry->code = code; 86 __entry->fast = fast; 87 ), 88 89 TP_printk("code 0x%x %s cnt 0x%x idx 0x%x in 0x%llx out 0x%llx", 90 __entry->code, __entry->fast ? "fast" : "slow", 91 __entry->rep_cnt, __entry->rep_idx, __entry->ingpa, 92 __entry->outgpa) 93 ); 94 95 /* 96 * Tracepoint for PIO. 97 */ 98 99 #define KVM_PIO_IN 0 100 #define KVM_PIO_OUT 1 101 102 TRACE_EVENT(kvm_pio, 103 TP_PROTO(unsigned int rw, unsigned int port, unsigned int size, 104 unsigned int count, void *data), 105 TP_ARGS(rw, port, size, count, data), 106 107 TP_STRUCT__entry( 108 __field( unsigned int, rw ) 109 __field( unsigned int, port ) 110 __field( unsigned int, size ) 111 __field( unsigned int, count ) 112 __field( unsigned int, val ) 113 ), 114 115 TP_fast_assign( 116 __entry->rw = rw; 117 __entry->port = port; 118 __entry->size = size; 119 __entry->count = count; 120 if (size == 1) 121 __entry->val = *(unsigned char *)data; 122 else if (size == 2) 123 __entry->val = *(unsigned short *)data; 124 else 125 __entry->val = *(unsigned int *)data; 126 ), 127 128 TP_printk("pio_%s at 0x%x size %d count %d val 0x%x %s", 129 __entry->rw ? "write" : "read", 130 __entry->port, __entry->size, __entry->count, __entry->val, 131 __entry->count > 1 ? "(...)" : "") 132 ); 133 134 /* 135 * Tracepoint for fast mmio. 136 */ 137 TRACE_EVENT(kvm_fast_mmio, 138 TP_PROTO(u64 gpa), 139 TP_ARGS(gpa), 140 141 TP_STRUCT__entry( 142 __field(u64, gpa) 143 ), 144 145 TP_fast_assign( 146 __entry->gpa = gpa; 147 ), 148 149 TP_printk("fast mmio at gpa 0x%llx", __entry->gpa) 150 ); 151 152 /* 153 * Tracepoint for cpuid. 154 */ 155 TRACE_EVENT(kvm_cpuid, 156 TP_PROTO(unsigned int function, unsigned int index, unsigned long rax, 157 unsigned long rbx, unsigned long rcx, unsigned long rdx, 158 bool found, bool used_max_basic), 159 TP_ARGS(function, index, rax, rbx, rcx, rdx, found, used_max_basic), 160 161 TP_STRUCT__entry( 162 __field( unsigned int, function ) 163 __field( unsigned int, index ) 164 __field( unsigned long, rax ) 165 __field( unsigned long, rbx ) 166 __field( unsigned long, rcx ) 167 __field( unsigned long, rdx ) 168 __field( bool, found ) 169 __field( bool, used_max_basic ) 170 ), 171 172 TP_fast_assign( 173 __entry->function = function; 174 __entry->index = index; 175 __entry->rax = rax; 176 __entry->rbx = rbx; 177 __entry->rcx = rcx; 178 __entry->rdx = rdx; 179 __entry->found = found; 180 __entry->used_max_basic = used_max_basic; 181 ), 182 183 TP_printk("func %x idx %x rax %lx rbx %lx rcx %lx rdx %lx, cpuid entry %s%s", 184 __entry->function, __entry->index, __entry->rax, 185 __entry->rbx, __entry->rcx, __entry->rdx, 186 __entry->found ? "found" : "not found", 187 __entry->used_max_basic ? ", used max basic" : "") 188 ); 189 190 #define AREG(x) { APIC_##x, "APIC_" #x } 191 192 #define kvm_trace_symbol_apic \ 193 AREG(ID), AREG(LVR), AREG(TASKPRI), AREG(ARBPRI), AREG(PROCPRI), \ 194 AREG(EOI), AREG(RRR), AREG(LDR), AREG(DFR), AREG(SPIV), AREG(ISR), \ 195 AREG(TMR), AREG(IRR), AREG(ESR), AREG(ICR), AREG(ICR2), AREG(LVTT), \ 196 AREG(LVTTHMR), AREG(LVTPC), AREG(LVT0), AREG(LVT1), AREG(LVTERR), \ 197 AREG(TMICT), AREG(TMCCT), AREG(TDCR), AREG(SELF_IPI), AREG(EFEAT), \ 198 AREG(ECTRL) 199 /* 200 * Tracepoint for apic access. 201 */ 202 TRACE_EVENT(kvm_apic, 203 TP_PROTO(unsigned int rw, unsigned int reg, unsigned int val), 204 TP_ARGS(rw, reg, val), 205 206 TP_STRUCT__entry( 207 __field( unsigned int, rw ) 208 __field( unsigned int, reg ) 209 __field( unsigned int, val ) 210 ), 211 212 TP_fast_assign( 213 __entry->rw = rw; 214 __entry->reg = reg; 215 __entry->val = val; 216 ), 217 218 TP_printk("apic_%s %s = 0x%x", 219 __entry->rw ? "write" : "read", 220 __print_symbolic(__entry->reg, kvm_trace_symbol_apic), 221 __entry->val) 222 ); 223 224 #define trace_kvm_apic_read(reg, val) trace_kvm_apic(0, reg, val) 225 #define trace_kvm_apic_write(reg, val) trace_kvm_apic(1, reg, val) 226 227 #define KVM_ISA_VMX 1 228 #define KVM_ISA_SVM 2 229 230 #define kvm_print_exit_reason(exit_reason, isa) \ 231 (isa == KVM_ISA_VMX) ? \ 232 __print_symbolic(exit_reason & 0xffff, VMX_EXIT_REASONS) : \ 233 __print_symbolic(exit_reason, SVM_EXIT_REASONS), \ 234 (isa == KVM_ISA_VMX && exit_reason & ~0xffff) ? " " : "", \ 235 (isa == KVM_ISA_VMX) ? \ 236 __print_flags(exit_reason & ~0xffff, " ", VMX_EXIT_REASON_FLAGS) : "" 237 238 #define TRACE_EVENT_KVM_EXIT(name) \ 239 TRACE_EVENT(name, \ 240 TP_PROTO(unsigned int exit_reason, struct kvm_vcpu *vcpu, u32 isa), \ 241 TP_ARGS(exit_reason, vcpu, isa), \ 242 \ 243 TP_STRUCT__entry( \ 244 __field( unsigned int, exit_reason ) \ 245 __field( unsigned long, guest_rip ) \ 246 __field( u32, isa ) \ 247 __field( u64, info1 ) \ 248 __field( u64, info2 ) \ 249 __field( u32, intr_info ) \ 250 __field( u32, error_code ) \ 251 __field( unsigned int, vcpu_id ) \ 252 ), \ 253 \ 254 TP_fast_assign( \ 255 __entry->exit_reason = exit_reason; \ 256 __entry->guest_rip = kvm_rip_read(vcpu); \ 257 __entry->isa = isa; \ 258 __entry->vcpu_id = vcpu->vcpu_id; \ 259 kvm_x86_ops.get_exit_info(vcpu, &__entry->info1, \ 260 &__entry->info2, \ 261 &__entry->intr_info, \ 262 &__entry->error_code); \ 263 ), \ 264 \ 265 TP_printk("vcpu %u reason %s%s%s rip 0x%lx info1 0x%016llx " \ 266 "info2 0x%016llx intr_info 0x%08x error_code 0x%08x", \ 267 __entry->vcpu_id, \ 268 kvm_print_exit_reason(__entry->exit_reason, __entry->isa), \ 269 __entry->guest_rip, __entry->info1, __entry->info2, \ 270 __entry->intr_info, __entry->error_code) \ 271 ) 272 273 /* 274 * Tracepoint for kvm guest exit: 275 */ 276 TRACE_EVENT_KVM_EXIT(kvm_exit); 277 278 /* 279 * Tracepoint for kvm interrupt injection: 280 */ 281 TRACE_EVENT(kvm_inj_virq, 282 TP_PROTO(unsigned int irq), 283 TP_ARGS(irq), 284 285 TP_STRUCT__entry( 286 __field( unsigned int, irq ) 287 ), 288 289 TP_fast_assign( 290 __entry->irq = irq; 291 ), 292 293 TP_printk("irq %u", __entry->irq) 294 ); 295 296 #define EXS(x) { x##_VECTOR, "#" #x } 297 298 #define kvm_trace_sym_exc \ 299 EXS(DE), EXS(DB), EXS(BP), EXS(OF), EXS(BR), EXS(UD), EXS(NM), \ 300 EXS(DF), EXS(TS), EXS(NP), EXS(SS), EXS(GP), EXS(PF), \ 301 EXS(MF), EXS(AC), EXS(MC) 302 303 /* 304 * Tracepoint for kvm interrupt injection: 305 */ 306 TRACE_EVENT(kvm_inj_exception, 307 TP_PROTO(unsigned exception, bool has_error, unsigned error_code), 308 TP_ARGS(exception, has_error, error_code), 309 310 TP_STRUCT__entry( 311 __field( u8, exception ) 312 __field( u8, has_error ) 313 __field( u32, error_code ) 314 ), 315 316 TP_fast_assign( 317 __entry->exception = exception; 318 __entry->has_error = has_error; 319 __entry->error_code = error_code; 320 ), 321 322 TP_printk("%s (0x%x)", 323 __print_symbolic(__entry->exception, kvm_trace_sym_exc), 324 /* FIXME: don't print error_code if not present */ 325 __entry->has_error ? __entry->error_code : 0) 326 ); 327 328 /* 329 * Tracepoint for page fault. 330 */ 331 TRACE_EVENT(kvm_page_fault, 332 TP_PROTO(unsigned long fault_address, unsigned int error_code), 333 TP_ARGS(fault_address, error_code), 334 335 TP_STRUCT__entry( 336 __field( unsigned long, fault_address ) 337 __field( unsigned int, error_code ) 338 ), 339 340 TP_fast_assign( 341 __entry->fault_address = fault_address; 342 __entry->error_code = error_code; 343 ), 344 345 TP_printk("address %lx error_code %x", 346 __entry->fault_address, __entry->error_code) 347 ); 348 349 /* 350 * Tracepoint for guest MSR access. 351 */ 352 TRACE_EVENT(kvm_msr, 353 TP_PROTO(unsigned write, u32 ecx, u64 data, bool exception), 354 TP_ARGS(write, ecx, data, exception), 355 356 TP_STRUCT__entry( 357 __field( unsigned, write ) 358 __field( u32, ecx ) 359 __field( u64, data ) 360 __field( u8, exception ) 361 ), 362 363 TP_fast_assign( 364 __entry->write = write; 365 __entry->ecx = ecx; 366 __entry->data = data; 367 __entry->exception = exception; 368 ), 369 370 TP_printk("msr_%s %x = 0x%llx%s", 371 __entry->write ? "write" : "read", 372 __entry->ecx, __entry->data, 373 __entry->exception ? " (#GP)" : "") 374 ); 375 376 #define trace_kvm_msr_read(ecx, data) trace_kvm_msr(0, ecx, data, false) 377 #define trace_kvm_msr_write(ecx, data) trace_kvm_msr(1, ecx, data, false) 378 #define trace_kvm_msr_read_ex(ecx) trace_kvm_msr(0, ecx, 0, true) 379 #define trace_kvm_msr_write_ex(ecx, data) trace_kvm_msr(1, ecx, data, true) 380 381 /* 382 * Tracepoint for guest CR access. 383 */ 384 TRACE_EVENT(kvm_cr, 385 TP_PROTO(unsigned int rw, unsigned int cr, unsigned long val), 386 TP_ARGS(rw, cr, val), 387 388 TP_STRUCT__entry( 389 __field( unsigned int, rw ) 390 __field( unsigned int, cr ) 391 __field( unsigned long, val ) 392 ), 393 394 TP_fast_assign( 395 __entry->rw = rw; 396 __entry->cr = cr; 397 __entry->val = val; 398 ), 399 400 TP_printk("cr_%s %x = 0x%lx", 401 __entry->rw ? "write" : "read", 402 __entry->cr, __entry->val) 403 ); 404 405 #define trace_kvm_cr_read(cr, val) trace_kvm_cr(0, cr, val) 406 #define trace_kvm_cr_write(cr, val) trace_kvm_cr(1, cr, val) 407 408 TRACE_EVENT(kvm_pic_set_irq, 409 TP_PROTO(__u8 chip, __u8 pin, __u8 elcr, __u8 imr, bool coalesced), 410 TP_ARGS(chip, pin, elcr, imr, coalesced), 411 412 TP_STRUCT__entry( 413 __field( __u8, chip ) 414 __field( __u8, pin ) 415 __field( __u8, elcr ) 416 __field( __u8, imr ) 417 __field( bool, coalesced ) 418 ), 419 420 TP_fast_assign( 421 __entry->chip = chip; 422 __entry->pin = pin; 423 __entry->elcr = elcr; 424 __entry->imr = imr; 425 __entry->coalesced = coalesced; 426 ), 427 428 TP_printk("chip %u pin %u (%s%s)%s", 429 __entry->chip, __entry->pin, 430 (__entry->elcr & (1 << __entry->pin)) ? "level":"edge", 431 (__entry->imr & (1 << __entry->pin)) ? "|masked":"", 432 __entry->coalesced ? " (coalesced)" : "") 433 ); 434 435 #define kvm_apic_dst_shorthand \ 436 {0x0, "dst"}, \ 437 {0x1, "self"}, \ 438 {0x2, "all"}, \ 439 {0x3, "all-but-self"} 440 441 TRACE_EVENT(kvm_apic_ipi, 442 TP_PROTO(__u32 icr_low, __u32 dest_id), 443 TP_ARGS(icr_low, dest_id), 444 445 TP_STRUCT__entry( 446 __field( __u32, icr_low ) 447 __field( __u32, dest_id ) 448 ), 449 450 TP_fast_assign( 451 __entry->icr_low = icr_low; 452 __entry->dest_id = dest_id; 453 ), 454 455 TP_printk("dst %x vec %u (%s|%s|%s|%s|%s)", 456 __entry->dest_id, (u8)__entry->icr_low, 457 __print_symbolic((__entry->icr_low >> 8 & 0x7), 458 kvm_deliver_mode), 459 (__entry->icr_low & (1<<11)) ? "logical" : "physical", 460 (__entry->icr_low & (1<<14)) ? "assert" : "de-assert", 461 (__entry->icr_low & (1<<15)) ? "level" : "edge", 462 __print_symbolic((__entry->icr_low >> 18 & 0x3), 463 kvm_apic_dst_shorthand)) 464 ); 465 466 TRACE_EVENT(kvm_apic_accept_irq, 467 TP_PROTO(__u32 apicid, __u16 dm, __u16 tm, __u8 vec), 468 TP_ARGS(apicid, dm, tm, vec), 469 470 TP_STRUCT__entry( 471 __field( __u32, apicid ) 472 __field( __u16, dm ) 473 __field( __u16, tm ) 474 __field( __u8, vec ) 475 ), 476 477 TP_fast_assign( 478 __entry->apicid = apicid; 479 __entry->dm = dm; 480 __entry->tm = tm; 481 __entry->vec = vec; 482 ), 483 484 TP_printk("apicid %x vec %u (%s|%s)", 485 __entry->apicid, __entry->vec, 486 __print_symbolic((__entry->dm >> 8 & 0x7), kvm_deliver_mode), 487 __entry->tm ? "level" : "edge") 488 ); 489 490 TRACE_EVENT(kvm_eoi, 491 TP_PROTO(struct kvm_lapic *apic, int vector), 492 TP_ARGS(apic, vector), 493 494 TP_STRUCT__entry( 495 __field( __u32, apicid ) 496 __field( int, vector ) 497 ), 498 499 TP_fast_assign( 500 __entry->apicid = apic->vcpu->vcpu_id; 501 __entry->vector = vector; 502 ), 503 504 TP_printk("apicid %x vector %d", __entry->apicid, __entry->vector) 505 ); 506 507 TRACE_EVENT(kvm_pv_eoi, 508 TP_PROTO(struct kvm_lapic *apic, int vector), 509 TP_ARGS(apic, vector), 510 511 TP_STRUCT__entry( 512 __field( __u32, apicid ) 513 __field( int, vector ) 514 ), 515 516 TP_fast_assign( 517 __entry->apicid = apic->vcpu->vcpu_id; 518 __entry->vector = vector; 519 ), 520 521 TP_printk("apicid %x vector %d", __entry->apicid, __entry->vector) 522 ); 523 524 /* 525 * Tracepoint for nested VMRUN 526 */ 527 TRACE_EVENT(kvm_nested_vmrun, 528 TP_PROTO(__u64 rip, __u64 vmcb, __u64 nested_rip, __u32 int_ctl, 529 __u32 event_inj, bool npt), 530 TP_ARGS(rip, vmcb, nested_rip, int_ctl, event_inj, npt), 531 532 TP_STRUCT__entry( 533 __field( __u64, rip ) 534 __field( __u64, vmcb ) 535 __field( __u64, nested_rip ) 536 __field( __u32, int_ctl ) 537 __field( __u32, event_inj ) 538 __field( bool, npt ) 539 ), 540 541 TP_fast_assign( 542 __entry->rip = rip; 543 __entry->vmcb = vmcb; 544 __entry->nested_rip = nested_rip; 545 __entry->int_ctl = int_ctl; 546 __entry->event_inj = event_inj; 547 __entry->npt = npt; 548 ), 549 550 TP_printk("rip: 0x%016llx vmcb: 0x%016llx nrip: 0x%016llx int_ctl: 0x%08x " 551 "event_inj: 0x%08x npt: %s", 552 __entry->rip, __entry->vmcb, __entry->nested_rip, 553 __entry->int_ctl, __entry->event_inj, 554 __entry->npt ? "on" : "off") 555 ); 556 557 TRACE_EVENT(kvm_nested_intercepts, 558 TP_PROTO(__u16 cr_read, __u16 cr_write, __u32 exceptions, 559 __u32 intercept1, __u32 intercept2, __u32 intercept3), 560 TP_ARGS(cr_read, cr_write, exceptions, intercept1, 561 intercept2, intercept3), 562 563 TP_STRUCT__entry( 564 __field( __u16, cr_read ) 565 __field( __u16, cr_write ) 566 __field( __u32, exceptions ) 567 __field( __u32, intercept1 ) 568 __field( __u32, intercept2 ) 569 __field( __u32, intercept3 ) 570 ), 571 572 TP_fast_assign( 573 __entry->cr_read = cr_read; 574 __entry->cr_write = cr_write; 575 __entry->exceptions = exceptions; 576 __entry->intercept1 = intercept1; 577 __entry->intercept2 = intercept2; 578 __entry->intercept3 = intercept3; 579 ), 580 581 TP_printk("cr_read: %04x cr_write: %04x excp: %08x " 582 "intercepts: %08x %08x %08x", 583 __entry->cr_read, __entry->cr_write, __entry->exceptions, 584 __entry->intercept1, __entry->intercept2, __entry->intercept3) 585 ); 586 /* 587 * Tracepoint for #VMEXIT while nested 588 */ 589 TRACE_EVENT_KVM_EXIT(kvm_nested_vmexit); 590 591 /* 592 * Tracepoint for #VMEXIT reinjected to the guest 593 */ 594 TRACE_EVENT(kvm_nested_vmexit_inject, 595 TP_PROTO(__u32 exit_code, 596 __u64 exit_info1, __u64 exit_info2, 597 __u32 exit_int_info, __u32 exit_int_info_err, __u32 isa), 598 TP_ARGS(exit_code, exit_info1, exit_info2, 599 exit_int_info, exit_int_info_err, isa), 600 601 TP_STRUCT__entry( 602 __field( __u32, exit_code ) 603 __field( __u64, exit_info1 ) 604 __field( __u64, exit_info2 ) 605 __field( __u32, exit_int_info ) 606 __field( __u32, exit_int_info_err ) 607 __field( __u32, isa ) 608 ), 609 610 TP_fast_assign( 611 __entry->exit_code = exit_code; 612 __entry->exit_info1 = exit_info1; 613 __entry->exit_info2 = exit_info2; 614 __entry->exit_int_info = exit_int_info; 615 __entry->exit_int_info_err = exit_int_info_err; 616 __entry->isa = isa; 617 ), 618 619 TP_printk("reason: %s%s%s ext_inf1: 0x%016llx " 620 "ext_inf2: 0x%016llx ext_int: 0x%08x ext_int_err: 0x%08x", 621 kvm_print_exit_reason(__entry->exit_code, __entry->isa), 622 __entry->exit_info1, __entry->exit_info2, 623 __entry->exit_int_info, __entry->exit_int_info_err) 624 ); 625 626 /* 627 * Tracepoint for nested #vmexit because of interrupt pending 628 */ 629 TRACE_EVENT(kvm_nested_intr_vmexit, 630 TP_PROTO(__u64 rip), 631 TP_ARGS(rip), 632 633 TP_STRUCT__entry( 634 __field( __u64, rip ) 635 ), 636 637 TP_fast_assign( 638 __entry->rip = rip 639 ), 640 641 TP_printk("rip: 0x%016llx", __entry->rip) 642 ); 643 644 /* 645 * Tracepoint for nested #vmexit because of interrupt pending 646 */ 647 TRACE_EVENT(kvm_invlpga, 648 TP_PROTO(__u64 rip, int asid, u64 address), 649 TP_ARGS(rip, asid, address), 650 651 TP_STRUCT__entry( 652 __field( __u64, rip ) 653 __field( int, asid ) 654 __field( __u64, address ) 655 ), 656 657 TP_fast_assign( 658 __entry->rip = rip; 659 __entry->asid = asid; 660 __entry->address = address; 661 ), 662 663 TP_printk("rip: 0x%016llx asid: %d address: 0x%016llx", 664 __entry->rip, __entry->asid, __entry->address) 665 ); 666 667 /* 668 * Tracepoint for nested #vmexit because of interrupt pending 669 */ 670 TRACE_EVENT(kvm_skinit, 671 TP_PROTO(__u64 rip, __u32 slb), 672 TP_ARGS(rip, slb), 673 674 TP_STRUCT__entry( 675 __field( __u64, rip ) 676 __field( __u32, slb ) 677 ), 678 679 TP_fast_assign( 680 __entry->rip = rip; 681 __entry->slb = slb; 682 ), 683 684 TP_printk("rip: 0x%016llx slb: 0x%08x", 685 __entry->rip, __entry->slb) 686 ); 687 688 #define KVM_EMUL_INSN_F_CR0_PE (1 << 0) 689 #define KVM_EMUL_INSN_F_EFL_VM (1 << 1) 690 #define KVM_EMUL_INSN_F_CS_D (1 << 2) 691 #define KVM_EMUL_INSN_F_CS_L (1 << 3) 692 693 #define kvm_trace_symbol_emul_flags \ 694 { 0, "real" }, \ 695 { KVM_EMUL_INSN_F_CR0_PE \ 696 | KVM_EMUL_INSN_F_EFL_VM, "vm16" }, \ 697 { KVM_EMUL_INSN_F_CR0_PE, "prot16" }, \ 698 { KVM_EMUL_INSN_F_CR0_PE \ 699 | KVM_EMUL_INSN_F_CS_D, "prot32" }, \ 700 { KVM_EMUL_INSN_F_CR0_PE \ 701 | KVM_EMUL_INSN_F_CS_L, "prot64" } 702 703 #define kei_decode_mode(mode) ({ \ 704 u8 flags = 0xff; \ 705 switch (mode) { \ 706 case X86EMUL_MODE_REAL: \ 707 flags = 0; \ 708 break; \ 709 case X86EMUL_MODE_VM86: \ 710 flags = KVM_EMUL_INSN_F_EFL_VM; \ 711 break; \ 712 case X86EMUL_MODE_PROT16: \ 713 flags = KVM_EMUL_INSN_F_CR0_PE; \ 714 break; \ 715 case X86EMUL_MODE_PROT32: \ 716 flags = KVM_EMUL_INSN_F_CR0_PE \ 717 | KVM_EMUL_INSN_F_CS_D; \ 718 break; \ 719 case X86EMUL_MODE_PROT64: \ 720 flags = KVM_EMUL_INSN_F_CR0_PE \ 721 | KVM_EMUL_INSN_F_CS_L; \ 722 break; \ 723 } \ 724 flags; \ 725 }) 726 727 TRACE_EVENT(kvm_emulate_insn, 728 TP_PROTO(struct kvm_vcpu *vcpu, __u8 failed), 729 TP_ARGS(vcpu, failed), 730 731 TP_STRUCT__entry( 732 __field( __u64, rip ) 733 __field( __u32, csbase ) 734 __field( __u8, len ) 735 __array( __u8, insn, 15 ) 736 __field( __u8, flags ) 737 __field( __u8, failed ) 738 ), 739 740 TP_fast_assign( 741 __entry->csbase = kvm_x86_ops.get_segment_base(vcpu, VCPU_SREG_CS); 742 __entry->len = vcpu->arch.emulate_ctxt->fetch.ptr 743 - vcpu->arch.emulate_ctxt->fetch.data; 744 __entry->rip = vcpu->arch.emulate_ctxt->_eip - __entry->len; 745 memcpy(__entry->insn, 746 vcpu->arch.emulate_ctxt->fetch.data, 747 15); 748 __entry->flags = kei_decode_mode(vcpu->arch.emulate_ctxt->mode); 749 __entry->failed = failed; 750 ), 751 752 TP_printk("%x:%llx:%s (%s)%s", 753 __entry->csbase, __entry->rip, 754 __print_hex(__entry->insn, __entry->len), 755 __print_symbolic(__entry->flags, 756 kvm_trace_symbol_emul_flags), 757 __entry->failed ? " failed" : "" 758 ) 759 ); 760 761 #define trace_kvm_emulate_insn_start(vcpu) trace_kvm_emulate_insn(vcpu, 0) 762 #define trace_kvm_emulate_insn_failed(vcpu) trace_kvm_emulate_insn(vcpu, 1) 763 764 TRACE_EVENT( 765 vcpu_match_mmio, 766 TP_PROTO(gva_t gva, gpa_t gpa, bool write, bool gpa_match), 767 TP_ARGS(gva, gpa, write, gpa_match), 768 769 TP_STRUCT__entry( 770 __field(gva_t, gva) 771 __field(gpa_t, gpa) 772 __field(bool, write) 773 __field(bool, gpa_match) 774 ), 775 776 TP_fast_assign( 777 __entry->gva = gva; 778 __entry->gpa = gpa; 779 __entry->write = write; 780 __entry->gpa_match = gpa_match 781 ), 782 783 TP_printk("gva %#lx gpa %#llx %s %s", __entry->gva, __entry->gpa, 784 __entry->write ? "Write" : "Read", 785 __entry->gpa_match ? "GPA" : "GVA") 786 ); 787 788 TRACE_EVENT(kvm_write_tsc_offset, 789 TP_PROTO(unsigned int vcpu_id, __u64 previous_tsc_offset, 790 __u64 next_tsc_offset), 791 TP_ARGS(vcpu_id, previous_tsc_offset, next_tsc_offset), 792 793 TP_STRUCT__entry( 794 __field( unsigned int, vcpu_id ) 795 __field( __u64, previous_tsc_offset ) 796 __field( __u64, next_tsc_offset ) 797 ), 798 799 TP_fast_assign( 800 __entry->vcpu_id = vcpu_id; 801 __entry->previous_tsc_offset = previous_tsc_offset; 802 __entry->next_tsc_offset = next_tsc_offset; 803 ), 804 805 TP_printk("vcpu=%u prev=%llu next=%llu", __entry->vcpu_id, 806 __entry->previous_tsc_offset, __entry->next_tsc_offset) 807 ); 808 809 #ifdef CONFIG_X86_64 810 811 #define host_clocks \ 812 {VDSO_CLOCKMODE_NONE, "none"}, \ 813 {VDSO_CLOCKMODE_TSC, "tsc"} \ 814 815 TRACE_EVENT(kvm_update_master_clock, 816 TP_PROTO(bool use_master_clock, unsigned int host_clock, bool offset_matched), 817 TP_ARGS(use_master_clock, host_clock, offset_matched), 818 819 TP_STRUCT__entry( 820 __field( bool, use_master_clock ) 821 __field( unsigned int, host_clock ) 822 __field( bool, offset_matched ) 823 ), 824 825 TP_fast_assign( 826 __entry->use_master_clock = use_master_clock; 827 __entry->host_clock = host_clock; 828 __entry->offset_matched = offset_matched; 829 ), 830 831 TP_printk("masterclock %d hostclock %s offsetmatched %u", 832 __entry->use_master_clock, 833 __print_symbolic(__entry->host_clock, host_clocks), 834 __entry->offset_matched) 835 ); 836 837 TRACE_EVENT(kvm_track_tsc, 838 TP_PROTO(unsigned int vcpu_id, unsigned int nr_matched, 839 unsigned int online_vcpus, bool use_master_clock, 840 unsigned int host_clock), 841 TP_ARGS(vcpu_id, nr_matched, online_vcpus, use_master_clock, 842 host_clock), 843 844 TP_STRUCT__entry( 845 __field( unsigned int, vcpu_id ) 846 __field( unsigned int, nr_vcpus_matched_tsc ) 847 __field( unsigned int, online_vcpus ) 848 __field( bool, use_master_clock ) 849 __field( unsigned int, host_clock ) 850 ), 851 852 TP_fast_assign( 853 __entry->vcpu_id = vcpu_id; 854 __entry->nr_vcpus_matched_tsc = nr_matched; 855 __entry->online_vcpus = online_vcpus; 856 __entry->use_master_clock = use_master_clock; 857 __entry->host_clock = host_clock; 858 ), 859 860 TP_printk("vcpu_id %u masterclock %u offsetmatched %u nr_online %u" 861 " hostclock %s", 862 __entry->vcpu_id, __entry->use_master_clock, 863 __entry->nr_vcpus_matched_tsc, __entry->online_vcpus, 864 __print_symbolic(__entry->host_clock, host_clocks)) 865 ); 866 867 #endif /* CONFIG_X86_64 */ 868 869 /* 870 * Tracepoint for PML full VMEXIT. 871 */ 872 TRACE_EVENT(kvm_pml_full, 873 TP_PROTO(unsigned int vcpu_id), 874 TP_ARGS(vcpu_id), 875 876 TP_STRUCT__entry( 877 __field( unsigned int, vcpu_id ) 878 ), 879 880 TP_fast_assign( 881 __entry->vcpu_id = vcpu_id; 882 ), 883 884 TP_printk("vcpu %d: PML full", __entry->vcpu_id) 885 ); 886 887 TRACE_EVENT(kvm_ple_window_update, 888 TP_PROTO(unsigned int vcpu_id, unsigned int new, unsigned int old), 889 TP_ARGS(vcpu_id, new, old), 890 891 TP_STRUCT__entry( 892 __field( unsigned int, vcpu_id ) 893 __field( unsigned int, new ) 894 __field( unsigned int, old ) 895 ), 896 897 TP_fast_assign( 898 __entry->vcpu_id = vcpu_id; 899 __entry->new = new; 900 __entry->old = old; 901 ), 902 903 TP_printk("vcpu %u old %u new %u (%s)", 904 __entry->vcpu_id, __entry->old, __entry->new, 905 __entry->old < __entry->new ? "growed" : "shrinked") 906 ); 907 908 TRACE_EVENT(kvm_pvclock_update, 909 TP_PROTO(unsigned int vcpu_id, struct pvclock_vcpu_time_info *pvclock), 910 TP_ARGS(vcpu_id, pvclock), 911 912 TP_STRUCT__entry( 913 __field( unsigned int, vcpu_id ) 914 __field( __u32, version ) 915 __field( __u64, tsc_timestamp ) 916 __field( __u64, system_time ) 917 __field( __u32, tsc_to_system_mul ) 918 __field( __s8, tsc_shift ) 919 __field( __u8, flags ) 920 ), 921 922 TP_fast_assign( 923 __entry->vcpu_id = vcpu_id; 924 __entry->version = pvclock->version; 925 __entry->tsc_timestamp = pvclock->tsc_timestamp; 926 __entry->system_time = pvclock->system_time; 927 __entry->tsc_to_system_mul = pvclock->tsc_to_system_mul; 928 __entry->tsc_shift = pvclock->tsc_shift; 929 __entry->flags = pvclock->flags; 930 ), 931 932 TP_printk("vcpu_id %u, pvclock { version %u, tsc_timestamp 0x%llx, " 933 "system_time 0x%llx, tsc_to_system_mul 0x%x, tsc_shift %d, " 934 "flags 0x%x }", 935 __entry->vcpu_id, 936 __entry->version, 937 __entry->tsc_timestamp, 938 __entry->system_time, 939 __entry->tsc_to_system_mul, 940 __entry->tsc_shift, 941 __entry->flags) 942 ); 943 944 TRACE_EVENT(kvm_wait_lapic_expire, 945 TP_PROTO(unsigned int vcpu_id, s64 delta), 946 TP_ARGS(vcpu_id, delta), 947 948 TP_STRUCT__entry( 949 __field( unsigned int, vcpu_id ) 950 __field( s64, delta ) 951 ), 952 953 TP_fast_assign( 954 __entry->vcpu_id = vcpu_id; 955 __entry->delta = delta; 956 ), 957 958 TP_printk("vcpu %u: delta %lld (%s)", 959 __entry->vcpu_id, 960 __entry->delta, 961 __entry->delta < 0 ? "early" : "late") 962 ); 963 964 TRACE_EVENT(kvm_enter_smm, 965 TP_PROTO(unsigned int vcpu_id, u64 smbase, bool entering), 966 TP_ARGS(vcpu_id, smbase, entering), 967 968 TP_STRUCT__entry( 969 __field( unsigned int, vcpu_id ) 970 __field( u64, smbase ) 971 __field( bool, entering ) 972 ), 973 974 TP_fast_assign( 975 __entry->vcpu_id = vcpu_id; 976 __entry->smbase = smbase; 977 __entry->entering = entering; 978 ), 979 980 TP_printk("vcpu %u: %s SMM, smbase 0x%llx", 981 __entry->vcpu_id, 982 __entry->entering ? "entering" : "leaving", 983 __entry->smbase) 984 ); 985 986 /* 987 * Tracepoint for VT-d posted-interrupts. 988 */ 989 TRACE_EVENT(kvm_pi_irte_update, 990 TP_PROTO(unsigned int host_irq, unsigned int vcpu_id, 991 unsigned int gsi, unsigned int gvec, 992 u64 pi_desc_addr, bool set), 993 TP_ARGS(host_irq, vcpu_id, gsi, gvec, pi_desc_addr, set), 994 995 TP_STRUCT__entry( 996 __field( unsigned int, host_irq ) 997 __field( unsigned int, vcpu_id ) 998 __field( unsigned int, gsi ) 999 __field( unsigned int, gvec ) 1000 __field( u64, pi_desc_addr ) 1001 __field( bool, set ) 1002 ), 1003 1004 TP_fast_assign( 1005 __entry->host_irq = host_irq; 1006 __entry->vcpu_id = vcpu_id; 1007 __entry->gsi = gsi; 1008 __entry->gvec = gvec; 1009 __entry->pi_desc_addr = pi_desc_addr; 1010 __entry->set = set; 1011 ), 1012 1013 TP_printk("VT-d PI is %s for irq %u, vcpu %u, gsi: 0x%x, " 1014 "gvec: 0x%x, pi_desc_addr: 0x%llx", 1015 __entry->set ? "enabled and being updated" : "disabled", 1016 __entry->host_irq, 1017 __entry->vcpu_id, 1018 __entry->gsi, 1019 __entry->gvec, 1020 __entry->pi_desc_addr) 1021 ); 1022 1023 /* 1024 * Tracepoint for kvm_hv_notify_acked_sint. 1025 */ 1026 TRACE_EVENT(kvm_hv_notify_acked_sint, 1027 TP_PROTO(int vcpu_id, u32 sint), 1028 TP_ARGS(vcpu_id, sint), 1029 1030 TP_STRUCT__entry( 1031 __field(int, vcpu_id) 1032 __field(u32, sint) 1033 ), 1034 1035 TP_fast_assign( 1036 __entry->vcpu_id = vcpu_id; 1037 __entry->sint = sint; 1038 ), 1039 1040 TP_printk("vcpu_id %d sint %u", __entry->vcpu_id, __entry->sint) 1041 ); 1042 1043 /* 1044 * Tracepoint for synic_set_irq. 1045 */ 1046 TRACE_EVENT(kvm_hv_synic_set_irq, 1047 TP_PROTO(int vcpu_id, u32 sint, int vector, int ret), 1048 TP_ARGS(vcpu_id, sint, vector, ret), 1049 1050 TP_STRUCT__entry( 1051 __field(int, vcpu_id) 1052 __field(u32, sint) 1053 __field(int, vector) 1054 __field(int, ret) 1055 ), 1056 1057 TP_fast_assign( 1058 __entry->vcpu_id = vcpu_id; 1059 __entry->sint = sint; 1060 __entry->vector = vector; 1061 __entry->ret = ret; 1062 ), 1063 1064 TP_printk("vcpu_id %d sint %u vector %d ret %d", 1065 __entry->vcpu_id, __entry->sint, __entry->vector, 1066 __entry->ret) 1067 ); 1068 1069 /* 1070 * Tracepoint for kvm_hv_synic_send_eoi. 1071 */ 1072 TRACE_EVENT(kvm_hv_synic_send_eoi, 1073 TP_PROTO(int vcpu_id, int vector), 1074 TP_ARGS(vcpu_id, vector), 1075 1076 TP_STRUCT__entry( 1077 __field(int, vcpu_id) 1078 __field(u32, sint) 1079 __field(int, vector) 1080 __field(int, ret) 1081 ), 1082 1083 TP_fast_assign( 1084 __entry->vcpu_id = vcpu_id; 1085 __entry->vector = vector; 1086 ), 1087 1088 TP_printk("vcpu_id %d vector %d", __entry->vcpu_id, __entry->vector) 1089 ); 1090 1091 /* 1092 * Tracepoint for synic_set_msr. 1093 */ 1094 TRACE_EVENT(kvm_hv_synic_set_msr, 1095 TP_PROTO(int vcpu_id, u32 msr, u64 data, bool host), 1096 TP_ARGS(vcpu_id, msr, data, host), 1097 1098 TP_STRUCT__entry( 1099 __field(int, vcpu_id) 1100 __field(u32, msr) 1101 __field(u64, data) 1102 __field(bool, host) 1103 ), 1104 1105 TP_fast_assign( 1106 __entry->vcpu_id = vcpu_id; 1107 __entry->msr = msr; 1108 __entry->data = data; 1109 __entry->host = host 1110 ), 1111 1112 TP_printk("vcpu_id %d msr 0x%x data 0x%llx host %d", 1113 __entry->vcpu_id, __entry->msr, __entry->data, __entry->host) 1114 ); 1115 1116 /* 1117 * Tracepoint for stimer_set_config. 1118 */ 1119 TRACE_EVENT(kvm_hv_stimer_set_config, 1120 TP_PROTO(int vcpu_id, int timer_index, u64 config, bool host), 1121 TP_ARGS(vcpu_id, timer_index, config, host), 1122 1123 TP_STRUCT__entry( 1124 __field(int, vcpu_id) 1125 __field(int, timer_index) 1126 __field(u64, config) 1127 __field(bool, host) 1128 ), 1129 1130 TP_fast_assign( 1131 __entry->vcpu_id = vcpu_id; 1132 __entry->timer_index = timer_index; 1133 __entry->config = config; 1134 __entry->host = host; 1135 ), 1136 1137 TP_printk("vcpu_id %d timer %d config 0x%llx host %d", 1138 __entry->vcpu_id, __entry->timer_index, __entry->config, 1139 __entry->host) 1140 ); 1141 1142 /* 1143 * Tracepoint for stimer_set_count. 1144 */ 1145 TRACE_EVENT(kvm_hv_stimer_set_count, 1146 TP_PROTO(int vcpu_id, int timer_index, u64 count, bool host), 1147 TP_ARGS(vcpu_id, timer_index, count, host), 1148 1149 TP_STRUCT__entry( 1150 __field(int, vcpu_id) 1151 __field(int, timer_index) 1152 __field(u64, count) 1153 __field(bool, host) 1154 ), 1155 1156 TP_fast_assign( 1157 __entry->vcpu_id = vcpu_id; 1158 __entry->timer_index = timer_index; 1159 __entry->count = count; 1160 __entry->host = host; 1161 ), 1162 1163 TP_printk("vcpu_id %d timer %d count %llu host %d", 1164 __entry->vcpu_id, __entry->timer_index, __entry->count, 1165 __entry->host) 1166 ); 1167 1168 /* 1169 * Tracepoint for stimer_start(periodic timer case). 1170 */ 1171 TRACE_EVENT(kvm_hv_stimer_start_periodic, 1172 TP_PROTO(int vcpu_id, int timer_index, u64 time_now, u64 exp_time), 1173 TP_ARGS(vcpu_id, timer_index, time_now, exp_time), 1174 1175 TP_STRUCT__entry( 1176 __field(int, vcpu_id) 1177 __field(int, timer_index) 1178 __field(u64, time_now) 1179 __field(u64, exp_time) 1180 ), 1181 1182 TP_fast_assign( 1183 __entry->vcpu_id = vcpu_id; 1184 __entry->timer_index = timer_index; 1185 __entry->time_now = time_now; 1186 __entry->exp_time = exp_time; 1187 ), 1188 1189 TP_printk("vcpu_id %d timer %d time_now %llu exp_time %llu", 1190 __entry->vcpu_id, __entry->timer_index, __entry->time_now, 1191 __entry->exp_time) 1192 ); 1193 1194 /* 1195 * Tracepoint for stimer_start(one-shot timer case). 1196 */ 1197 TRACE_EVENT(kvm_hv_stimer_start_one_shot, 1198 TP_PROTO(int vcpu_id, int timer_index, u64 time_now, u64 count), 1199 TP_ARGS(vcpu_id, timer_index, time_now, count), 1200 1201 TP_STRUCT__entry( 1202 __field(int, vcpu_id) 1203 __field(int, timer_index) 1204 __field(u64, time_now) 1205 __field(u64, count) 1206 ), 1207 1208 TP_fast_assign( 1209 __entry->vcpu_id = vcpu_id; 1210 __entry->timer_index = timer_index; 1211 __entry->time_now = time_now; 1212 __entry->count = count; 1213 ), 1214 1215 TP_printk("vcpu_id %d timer %d time_now %llu count %llu", 1216 __entry->vcpu_id, __entry->timer_index, __entry->time_now, 1217 __entry->count) 1218 ); 1219 1220 /* 1221 * Tracepoint for stimer_timer_callback. 1222 */ 1223 TRACE_EVENT(kvm_hv_stimer_callback, 1224 TP_PROTO(int vcpu_id, int timer_index), 1225 TP_ARGS(vcpu_id, timer_index), 1226 1227 TP_STRUCT__entry( 1228 __field(int, vcpu_id) 1229 __field(int, timer_index) 1230 ), 1231 1232 TP_fast_assign( 1233 __entry->vcpu_id = vcpu_id; 1234 __entry->timer_index = timer_index; 1235 ), 1236 1237 TP_printk("vcpu_id %d timer %d", 1238 __entry->vcpu_id, __entry->timer_index) 1239 ); 1240 1241 /* 1242 * Tracepoint for stimer_expiration. 1243 */ 1244 TRACE_EVENT(kvm_hv_stimer_expiration, 1245 TP_PROTO(int vcpu_id, int timer_index, int direct, int msg_send_result), 1246 TP_ARGS(vcpu_id, timer_index, direct, msg_send_result), 1247 1248 TP_STRUCT__entry( 1249 __field(int, vcpu_id) 1250 __field(int, timer_index) 1251 __field(int, direct) 1252 __field(int, msg_send_result) 1253 ), 1254 1255 TP_fast_assign( 1256 __entry->vcpu_id = vcpu_id; 1257 __entry->timer_index = timer_index; 1258 __entry->direct = direct; 1259 __entry->msg_send_result = msg_send_result; 1260 ), 1261 1262 TP_printk("vcpu_id %d timer %d direct %d send result %d", 1263 __entry->vcpu_id, __entry->timer_index, 1264 __entry->direct, __entry->msg_send_result) 1265 ); 1266 1267 /* 1268 * Tracepoint for stimer_cleanup. 1269 */ 1270 TRACE_EVENT(kvm_hv_stimer_cleanup, 1271 TP_PROTO(int vcpu_id, int timer_index), 1272 TP_ARGS(vcpu_id, timer_index), 1273 1274 TP_STRUCT__entry( 1275 __field(int, vcpu_id) 1276 __field(int, timer_index) 1277 ), 1278 1279 TP_fast_assign( 1280 __entry->vcpu_id = vcpu_id; 1281 __entry->timer_index = timer_index; 1282 ), 1283 1284 TP_printk("vcpu_id %d timer %d", 1285 __entry->vcpu_id, __entry->timer_index) 1286 ); 1287 1288 TRACE_EVENT(kvm_apicv_update_request, 1289 TP_PROTO(bool activate, unsigned long bit), 1290 TP_ARGS(activate, bit), 1291 1292 TP_STRUCT__entry( 1293 __field(bool, activate) 1294 __field(unsigned long, bit) 1295 ), 1296 1297 TP_fast_assign( 1298 __entry->activate = activate; 1299 __entry->bit = bit; 1300 ), 1301 1302 TP_printk("%s bit=%lu", 1303 __entry->activate ? "activate" : "deactivate", 1304 __entry->bit) 1305 ); 1306 1307 /* 1308 * Tracepoint for AMD AVIC 1309 */ 1310 TRACE_EVENT(kvm_avic_incomplete_ipi, 1311 TP_PROTO(u32 vcpu, u32 icrh, u32 icrl, u32 id, u32 index), 1312 TP_ARGS(vcpu, icrh, icrl, id, index), 1313 1314 TP_STRUCT__entry( 1315 __field(u32, vcpu) 1316 __field(u32, icrh) 1317 __field(u32, icrl) 1318 __field(u32, id) 1319 __field(u32, index) 1320 ), 1321 1322 TP_fast_assign( 1323 __entry->vcpu = vcpu; 1324 __entry->icrh = icrh; 1325 __entry->icrl = icrl; 1326 __entry->id = id; 1327 __entry->index = index; 1328 ), 1329 1330 TP_printk("vcpu=%u, icrh:icrl=%#010x:%08x, id=%u, index=%u", 1331 __entry->vcpu, __entry->icrh, __entry->icrl, 1332 __entry->id, __entry->index) 1333 ); 1334 1335 TRACE_EVENT(kvm_avic_unaccelerated_access, 1336 TP_PROTO(u32 vcpu, u32 offset, bool ft, bool rw, u32 vec), 1337 TP_ARGS(vcpu, offset, ft, rw, vec), 1338 1339 TP_STRUCT__entry( 1340 __field(u32, vcpu) 1341 __field(u32, offset) 1342 __field(bool, ft) 1343 __field(bool, rw) 1344 __field(u32, vec) 1345 ), 1346 1347 TP_fast_assign( 1348 __entry->vcpu = vcpu; 1349 __entry->offset = offset; 1350 __entry->ft = ft; 1351 __entry->rw = rw; 1352 __entry->vec = vec; 1353 ), 1354 1355 TP_printk("vcpu=%u, offset=%#x(%s), %s, %s, vec=%#x", 1356 __entry->vcpu, 1357 __entry->offset, 1358 __print_symbolic(__entry->offset, kvm_trace_symbol_apic), 1359 __entry->ft ? "trap" : "fault", 1360 __entry->rw ? "write" : "read", 1361 __entry->vec) 1362 ); 1363 1364 TRACE_EVENT(kvm_avic_ga_log, 1365 TP_PROTO(u32 vmid, u32 vcpuid), 1366 TP_ARGS(vmid, vcpuid), 1367 1368 TP_STRUCT__entry( 1369 __field(u32, vmid) 1370 __field(u32, vcpuid) 1371 ), 1372 1373 TP_fast_assign( 1374 __entry->vmid = vmid; 1375 __entry->vcpuid = vcpuid; 1376 ), 1377 1378 TP_printk("vmid=%u, vcpuid=%u", 1379 __entry->vmid, __entry->vcpuid) 1380 ); 1381 1382 TRACE_EVENT(kvm_hv_timer_state, 1383 TP_PROTO(unsigned int vcpu_id, unsigned int hv_timer_in_use), 1384 TP_ARGS(vcpu_id, hv_timer_in_use), 1385 TP_STRUCT__entry( 1386 __field(unsigned int, vcpu_id) 1387 __field(unsigned int, hv_timer_in_use) 1388 ), 1389 TP_fast_assign( 1390 __entry->vcpu_id = vcpu_id; 1391 __entry->hv_timer_in_use = hv_timer_in_use; 1392 ), 1393 TP_printk("vcpu_id %x hv_timer %x", 1394 __entry->vcpu_id, 1395 __entry->hv_timer_in_use) 1396 ); 1397 1398 /* 1399 * Tracepoint for kvm_hv_flush_tlb. 1400 */ 1401 TRACE_EVENT(kvm_hv_flush_tlb, 1402 TP_PROTO(u64 processor_mask, u64 address_space, u64 flags), 1403 TP_ARGS(processor_mask, address_space, flags), 1404 1405 TP_STRUCT__entry( 1406 __field(u64, processor_mask) 1407 __field(u64, address_space) 1408 __field(u64, flags) 1409 ), 1410 1411 TP_fast_assign( 1412 __entry->processor_mask = processor_mask; 1413 __entry->address_space = address_space; 1414 __entry->flags = flags; 1415 ), 1416 1417 TP_printk("processor_mask 0x%llx address_space 0x%llx flags 0x%llx", 1418 __entry->processor_mask, __entry->address_space, 1419 __entry->flags) 1420 ); 1421 1422 /* 1423 * Tracepoint for kvm_hv_flush_tlb_ex. 1424 */ 1425 TRACE_EVENT(kvm_hv_flush_tlb_ex, 1426 TP_PROTO(u64 valid_bank_mask, u64 format, u64 address_space, u64 flags), 1427 TP_ARGS(valid_bank_mask, format, address_space, flags), 1428 1429 TP_STRUCT__entry( 1430 __field(u64, valid_bank_mask) 1431 __field(u64, format) 1432 __field(u64, address_space) 1433 __field(u64, flags) 1434 ), 1435 1436 TP_fast_assign( 1437 __entry->valid_bank_mask = valid_bank_mask; 1438 __entry->format = format; 1439 __entry->address_space = address_space; 1440 __entry->flags = flags; 1441 ), 1442 1443 TP_printk("valid_bank_mask 0x%llx format 0x%llx " 1444 "address_space 0x%llx flags 0x%llx", 1445 __entry->valid_bank_mask, __entry->format, 1446 __entry->address_space, __entry->flags) 1447 ); 1448 1449 /* 1450 * Tracepoints for kvm_hv_send_ipi. 1451 */ 1452 TRACE_EVENT(kvm_hv_send_ipi, 1453 TP_PROTO(u32 vector, u64 processor_mask), 1454 TP_ARGS(vector, processor_mask), 1455 1456 TP_STRUCT__entry( 1457 __field(u32, vector) 1458 __field(u64, processor_mask) 1459 ), 1460 1461 TP_fast_assign( 1462 __entry->vector = vector; 1463 __entry->processor_mask = processor_mask; 1464 ), 1465 1466 TP_printk("vector %x processor_mask 0x%llx", 1467 __entry->vector, __entry->processor_mask) 1468 ); 1469 1470 TRACE_EVENT(kvm_hv_send_ipi_ex, 1471 TP_PROTO(u32 vector, u64 format, u64 valid_bank_mask), 1472 TP_ARGS(vector, format, valid_bank_mask), 1473 1474 TP_STRUCT__entry( 1475 __field(u32, vector) 1476 __field(u64, format) 1477 __field(u64, valid_bank_mask) 1478 ), 1479 1480 TP_fast_assign( 1481 __entry->vector = vector; 1482 __entry->format = format; 1483 __entry->valid_bank_mask = valid_bank_mask; 1484 ), 1485 1486 TP_printk("vector %x format %llx valid_bank_mask 0x%llx", 1487 __entry->vector, __entry->format, 1488 __entry->valid_bank_mask) 1489 ); 1490 1491 TRACE_EVENT(kvm_pv_tlb_flush, 1492 TP_PROTO(unsigned int vcpu_id, bool need_flush_tlb), 1493 TP_ARGS(vcpu_id, need_flush_tlb), 1494 1495 TP_STRUCT__entry( 1496 __field( unsigned int, vcpu_id ) 1497 __field( bool, need_flush_tlb ) 1498 ), 1499 1500 TP_fast_assign( 1501 __entry->vcpu_id = vcpu_id; 1502 __entry->need_flush_tlb = need_flush_tlb; 1503 ), 1504 1505 TP_printk("vcpu %u need_flush_tlb %s", __entry->vcpu_id, 1506 __entry->need_flush_tlb ? "true" : "false") 1507 ); 1508 1509 /* 1510 * Tracepoint for failed nested VMX VM-Enter. 1511 */ 1512 TRACE_EVENT(kvm_nested_vmenter_failed, 1513 TP_PROTO(const char *msg, u32 err), 1514 TP_ARGS(msg, err), 1515 1516 TP_STRUCT__entry( 1517 __field(const char *, msg) 1518 __field(u32, err) 1519 ), 1520 1521 TP_fast_assign( 1522 __entry->msg = msg; 1523 __entry->err = err; 1524 ), 1525 1526 TP_printk("%s%s", __entry->msg, !__entry->err ? "" : 1527 __print_symbolic(__entry->err, VMX_VMENTER_INSTRUCTION_ERRORS)) 1528 ); 1529 1530 /* 1531 * Tracepoint for syndbg_set_msr. 1532 */ 1533 TRACE_EVENT(kvm_hv_syndbg_set_msr, 1534 TP_PROTO(int vcpu_id, u32 vp_index, u32 msr, u64 data), 1535 TP_ARGS(vcpu_id, vp_index, msr, data), 1536 1537 TP_STRUCT__entry( 1538 __field(int, vcpu_id) 1539 __field(u32, vp_index) 1540 __field(u32, msr) 1541 __field(u64, data) 1542 ), 1543 1544 TP_fast_assign( 1545 __entry->vcpu_id = vcpu_id; 1546 __entry->vp_index = vp_index; 1547 __entry->msr = msr; 1548 __entry->data = data; 1549 ), 1550 1551 TP_printk("vcpu_id %d vp_index %u msr 0x%x data 0x%llx", 1552 __entry->vcpu_id, __entry->vp_index, __entry->msr, 1553 __entry->data) 1554 ); 1555 1556 /* 1557 * Tracepoint for syndbg_get_msr. 1558 */ 1559 TRACE_EVENT(kvm_hv_syndbg_get_msr, 1560 TP_PROTO(int vcpu_id, u32 vp_index, u32 msr, u64 data), 1561 TP_ARGS(vcpu_id, vp_index, msr, data), 1562 1563 TP_STRUCT__entry( 1564 __field(int, vcpu_id) 1565 __field(u32, vp_index) 1566 __field(u32, msr) 1567 __field(u64, data) 1568 ), 1569 1570 TP_fast_assign( 1571 __entry->vcpu_id = vcpu_id; 1572 __entry->vp_index = vp_index; 1573 __entry->msr = msr; 1574 __entry->data = data; 1575 ), 1576 1577 TP_printk("vcpu_id %d vp_index %u msr 0x%x data 0x%llx", 1578 __entry->vcpu_id, __entry->vp_index, __entry->msr, 1579 __entry->data) 1580 ); 1581 #endif /* _TRACE_KVM_H */ 1582 1583 #undef TRACE_INCLUDE_PATH 1584 #define TRACE_INCLUDE_PATH ../../arch/x86/kvm 1585 #undef TRACE_INCLUDE_FILE 1586 #define TRACE_INCLUDE_FILE trace 1587 1588 /* This part must be outside protection */ 1589 #include <trace/define_trace.h> 1590