Skip to content

Commit 2c4c413

Browse files
Sean Christophersonbonzini
authored andcommitted
KVM: x86: Print symbolic names of VMX VM-Exit flags in traces
Use __print_flags() to display the names of VMX flags in VM-Exit traces and strip the flags when printing the basic exit reason, e.g. so that a failed VM-Entry due to invalid guest state gets recorded as "INVALID_STATE FAILED_VMENTRY" instead of "0x80000021". Opportunstically fix misaligned variables in the kvm_exit and kvm_nested_vmexit_inject tracepoints. Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com> Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com> Message-Id: <20200508235348.19427-3-sean.j.christopherson@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent dcf068d commit 2c4c413

2 files changed

Lines changed: 20 additions & 15 deletions

File tree

‎arch/x86/include/uapi/asm/vmx.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@
150150
{ EXIT_REASON_UMWAIT, "UMWAIT" }, \
151151
{ EXIT_REASON_TPAUSE, "TPAUSE" }
152152

153+
#define VMX_EXIT_REASON_FLAGS \
154+
{ VMX_EXIT_REASONS_FAILED_VMENTRY, "FAILED_VMENTRY" }
155+
153156
#define VMX_ABORT_SAVE_GUEST_MSR_FAIL 1
154157
#define VMX_ABORT_LOAD_HOST_PDPTE_FAIL 2
155158
#define VMX_ABORT_LOAD_HOST_MSR_FAIL 4

‎arch/x86/kvm/trace.h‎

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,14 @@ TRACE_EVENT(kvm_apic,
225225
#define KVM_ISA_VMX 1
226226
#define KVM_ISA_SVM 2
227227

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+
228236
/*
229237
* Tracepoint for kvm guest exit:
230238
*/
@@ -250,12 +258,10 @@ TRACE_EVENT(kvm_exit,
250258
&__entry->info2);
251259
),
252260

253-
TP_printk("vcpu %u reason %s rip 0x%lx info %llx %llx",
261+
TP_printk("vcpu %u reason %s%s%s rip 0x%lx info %llx %llx",
254262
__entry->vcpu_id,
255-
(__entry->isa == KVM_ISA_VMX) ?
256-
__print_symbolic(__entry->exit_reason, VMX_EXIT_REASONS) :
257-
__print_symbolic(__entry->exit_reason, SVM_EXIT_REASONS),
258-
__entry->guest_rip, __entry->info1, __entry->info2)
263+
kvm_print_exit_reason(__entry->exit_reason, __entry->isa),
264+
__entry->guest_rip, __entry->info1, __entry->info2)
259265
);
260266

261267
/*
@@ -588,12 +594,10 @@ TRACE_EVENT(kvm_nested_vmexit,
588594
__entry->exit_int_info_err = exit_int_info_err;
589595
__entry->isa = isa;
590596
),
591-
TP_printk("rip: 0x%016llx reason: %s ext_inf1: 0x%016llx "
597+
TP_printk("rip: 0x%016llx reason: %s%s%s ext_inf1: 0x%016llx "
592598
"ext_inf2: 0x%016llx ext_int: 0x%08x ext_int_err: 0x%08x",
593599
__entry->rip,
594-
(__entry->isa == KVM_ISA_VMX) ?
595-
__print_symbolic(__entry->exit_code, VMX_EXIT_REASONS) :
596-
__print_symbolic(__entry->exit_code, SVM_EXIT_REASONS),
600+
kvm_print_exit_reason(__entry->exit_code, __entry->isa),
597601
__entry->exit_info1, __entry->exit_info2,
598602
__entry->exit_int_info, __entry->exit_int_info_err)
599603
);
@@ -626,13 +630,11 @@ TRACE_EVENT(kvm_nested_vmexit_inject,
626630
__entry->isa = isa;
627631
),
628632

629-
TP_printk("reason: %s ext_inf1: 0x%016llx "
633+
TP_printk("reason: %s%s%s ext_inf1: 0x%016llx "
630634
"ext_inf2: 0x%016llx ext_int: 0x%08x ext_int_err: 0x%08x",
631-
(__entry->isa == KVM_ISA_VMX) ?
632-
__print_symbolic(__entry->exit_code, VMX_EXIT_REASONS) :
633-
__print_symbolic(__entry->exit_code, SVM_EXIT_REASONS),
634-
__entry->exit_info1, __entry->exit_info2,
635-
__entry->exit_int_info, __entry->exit_int_info_err)
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)
636638
);
637639

638640
/*

0 commit comments

Comments
 (0)