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