summaryrefslogtreecommitdiff
path: root/arch/x86/kvm/trace.h
diff options
context:
space:
mode:
authorSean Christopherson <sean.j.christopherson@intel.com>2019-07-11 08:58:29 -0700
committerPaolo Bonzini <pbonzini@redhat.com>2019-09-11 17:34:10 +0200
commit5497b95567c1b7b264dbb80d3608119e18aa4c07 (patch)
tree4bc7a0460519e5ee246e43511b8fae9b3f3f1cff /arch/x86/kvm/trace.h
parenta061985b81a20248da60589d01375ebe9bec4dfc (diff)
KVM: nVMX: add tracepoint for failed nested VM-Enter
Debugging a failed VM-Enter is often like searching for a needle in a haystack, e.g. there are over 80 consistency checks that funnel into the "invalid control field" error code. One way to expedite debug is to run the buggy code as an L1 guest under KVM (and pray that the failing check is detected by KVM). However, extracting useful debug information out of L0 KVM requires attaching a debugger to KVM and/or modifying the source, e.g. to log which check is failing. Make life a little less painful for VMM developers and add a tracepoint for failed VM-Enter consistency checks. Ideally the tracepoint would capture both what check failed and precisely why it failed, but logging why a checked failed is difficult to do in a generic tracepoint without resorting to invasive techniques, e.g. generating a custom string on failure. That being said, for the vast majority of VM-Enter failures the most difficult step is figuring out exactly what to look at, e.g. figuring out which bit was incorrectly set in a control field is usually not too painful once the guilty field as been identified. To reach a happy medium between precision and ease of use, simply log the code that detected a failed check, using a macro to execute the check and log the trace event on failure. This approach enables tracing arbitrary code, e.g. it's not limited to function calls or specific formats of checks, and the changes to the existing code are minimally invasive. A macro with a two-character name is desirable as usage of the macro doesn't result in overly long lines or confusing alignment, while still retaining some amount of readability. I.e. a one-character name is a little too terse, and a three-character name results in the contents being passed to the macro aligning with an indented line when the macro is used an in if-statement, e.g.: if (VCC(nested_vmx_check_long_line_one(...) && nested_vmx_check_long_line_two(...))) return -EINVAL; And that is the story of how the CC(), a.k.a. Consistency Check, macro got its name. Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/kvm/trace.h')
-rw-r--r--arch/x86/kvm/trace.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/arch/x86/kvm/trace.h b/arch/x86/kvm/trace.h
index 0c8cc141cffb..25ea92873e49 100644
--- a/arch/x86/kvm/trace.h
+++ b/arch/x86/kvm/trace.h
@@ -1475,6 +1475,24 @@ TRACE_EVENT(kvm_pv_tlb_flush,
__entry->need_flush_tlb ? "true" : "false")
);
+/*
+ * Tracepoint for failed nested VMX VM-Enter.
+ */
+TRACE_EVENT(kvm_nested_vmenter_failed,
+ TP_PROTO(const char *msg),
+ TP_ARGS(msg),
+
+ TP_STRUCT__entry(
+ __field(const char *, msg)
+ ),
+
+ TP_fast_assign(
+ __entry->msg = msg;
+ ),
+
+ TP_printk("%s", __entry->msg)
+);
+
#endif /* _TRACE_KVM_H */
#undef TRACE_INCLUDE_PATH