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