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