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