From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: Sean Christopherson <sean.j.christopherson@intel.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Wanpeng Li <wanpengli@tencent.com>,
Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] KVM: x86: Print symbolic names of VMX VM-Exit flags in traces
Date: Fri, 13 Mar 2020 11:20:43 +0100 [thread overview]
Message-ID: <87sgicpnd0.fsf@vitty.brq.redhat.com> (raw)
In-Reply-To: <20200312181535.23797-1-sean.j.christopherson@intel.com>
Sean Christopherson <sean.j.christopherson@intel.com> writes:
> 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.
>
> Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
> ---
> arch/x86/include/uapi/asm/vmx.h | 3 +++
> arch/x86/kvm/trace.h | 32 +++++++++++++++++---------------
> 2 files changed, 20 insertions(+), 15 deletions(-)
>
> diff --git a/arch/x86/include/uapi/asm/vmx.h b/arch/x86/include/uapi/asm/vmx.h
> index e95b72ec19bc..b8ff9e8ac0d5 100644
> --- a/arch/x86/include/uapi/asm/vmx.h
> +++ b/arch/x86/include/uapi/asm/vmx.h
> @@ -150,6 +150,9 @@
> { EXIT_REASON_UMWAIT, "UMWAIT" }, \
> { EXIT_REASON_TPAUSE, "TPAUSE" }
>
> +#define VMX_EXIT_REASON_FLAGS \
> + { VMX_EXIT_REASONS_FAILED_VMENTRY, "FAILED_VMENTRY" }
> +
> #define VMX_ABORT_SAVE_GUEST_MSR_FAIL 1
> #define VMX_ABORT_LOAD_HOST_PDPTE_FAIL 2
> #define VMX_ABORT_LOAD_HOST_MSR_FAIL 4
> diff --git a/arch/x86/kvm/trace.h b/arch/x86/kvm/trace.h
> index f5b8814d9f83..3cfc8d97b158 100644
> --- a/arch/x86/kvm/trace.h
> +++ b/arch/x86/kvm/trace.h
> @@ -219,6 +219,14 @@ TRACE_EVENT(kvm_apic,
> #define KVM_ISA_VMX 1
> #define KVM_ISA_SVM 2
>
> +#define kvm_print_exit_reason(exit_reason, isa) \
> + (isa == KVM_ISA_VMX) ? \
> + __print_symbolic(exit_reason & 0xffff, VMX_EXIT_REASONS) : \
> + __print_symbolic(exit_reason, SVM_EXIT_REASONS), \
> + (isa == KVM_ISA_VMX && exit_reason & ~0xffff) ? " " : "", \
> + (isa == KVM_ISA_VMX) ? \
> + __print_flags(exit_reason & ~0xffff, " ", VMX_EXIT_REASON_FLAGS) : ""
> +
> /*
> * Tracepoint for kvm guest exit:
> */
> @@ -244,12 +252,10 @@ TRACE_EVENT(kvm_exit,
> &__entry->info2);
> ),
>
> - TP_printk("vcpu %u reason %s rip 0x%lx info %llx %llx",
> + TP_printk("vcpu %u reason %s%s%s rip 0x%lx info %llx %llx",
> __entry->vcpu_id,
> - (__entry->isa == KVM_ISA_VMX) ?
> - __print_symbolic(__entry->exit_reason, VMX_EXIT_REASONS) :
> - __print_symbolic(__entry->exit_reason, SVM_EXIT_REASONS),
> - __entry->guest_rip, __entry->info1, __entry->info2)
> + kvm_print_exit_reason(__entry->exit_reason, __entry->isa),
> + __entry->guest_rip, __entry->info1, __entry->info2)
> );
>
> /*
> @@ -582,12 +588,10 @@ TRACE_EVENT(kvm_nested_vmexit,
> __entry->exit_int_info_err = exit_int_info_err;
> __entry->isa = isa;
Unrelated to your patch, just a random thought: I *think* it would be
possible to avoid passing 'isa' to these tracepoints and figure out
which module is embedding them instead (THIS_MODULE/KBUILD_MODNAME/...
magic or something like that) but it may not worth the effort.
> ),
> - TP_printk("rip: 0x%016llx reason: %s ext_inf1: 0x%016llx "
> + TP_printk("rip: 0x%016llx reason: %s%s%s ext_inf1: 0x%016llx "
> "ext_inf2: 0x%016llx ext_int: 0x%08x ext_int_err: 0x%08x",
> __entry->rip,
> - (__entry->isa == KVM_ISA_VMX) ?
> - __print_symbolic(__entry->exit_code, VMX_EXIT_REASONS) :
> - __print_symbolic(__entry->exit_code, SVM_EXIT_REASONS),
> + kvm_print_exit_reason(__entry->exit_code, __entry->isa),
> __entry->exit_info1, __entry->exit_info2,
> __entry->exit_int_info, __entry->exit_int_info_err)
> );
> @@ -620,13 +624,11 @@ TRACE_EVENT(kvm_nested_vmexit_inject,
> __entry->isa = isa;
> ),
>
> - TP_printk("reason: %s ext_inf1: 0x%016llx "
> + TP_printk("reason: %s%s%s ext_inf1: 0x%016llx "
> "ext_inf2: 0x%016llx ext_int: 0x%08x ext_int_err: 0x%08x",
> - (__entry->isa == KVM_ISA_VMX) ?
> - __print_symbolic(__entry->exit_code, VMX_EXIT_REASONS) :
> - __print_symbolic(__entry->exit_code, SVM_EXIT_REASONS),
> - __entry->exit_info1, __entry->exit_info2,
> - __entry->exit_int_info, __entry->exit_int_info_err)
> + kvm_print_exit_reason(__entry->exit_code, __entry->isa),
> + __entry->exit_info1, __entry->exit_info2,
> + __entry->exit_int_info, __entry->exit_int_info_err)
> );
>
> /*
Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
--
Vitaly
prev parent reply other threads:[~2020-03-13 10:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-12 18:15 Sean Christopherson
2020-03-13 10:20 ` Vitaly Kuznetsov [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87sgicpnd0.fsf@vitty.brq.redhat.com \
--to=vkuznets@redhat.com \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=sean.j.christopherson@intel.com \
--cc=wanpengli@tencent.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome