Skip to content

Commit

Permalink
KVM: x86: Add requested index to the CPUID tracepoint
Browse files Browse the repository at this point in the history
Output the requested index when tracing CPUID emulation; it's basically
mandatory for leafs where the index is meaningful, and is helpful for
verifying KVM correctness even when the index isn't meaningful, e.g. the
trace for a Linux guest's hypervisor_cpuid_base() probing appears to
be broken (returns all zeroes) at first glance, but is correct because
the index is non-zero, i.e. the output values correspond to a random
index in the maximum basic leaf.

Suggested-by: Xiaoyao Li <xiaoyao.li@intel.com>
Cc: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
Sean Christopherson authored and bonzini committed Mar 18, 2020
1 parent d55c9d4 commit e7adda2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion arch/x86/kvm/cpuid.c
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,7 @@ bool kvm_cpuid(struct kvm_vcpu *vcpu, u32 *eax, u32 *ebx,
}
}
}
trace_kvm_cpuid(orig_function, *eax, *ebx, *ecx, *edx, exact);
trace_kvm_cpuid(orig_function, index, *eax, *ebx, *ecx, *edx, exact);
return exact;
}
EXPORT_SYMBOL_GPL(kvm_cpuid);
Expand Down
13 changes: 8 additions & 5 deletions arch/x86/kvm/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,14 @@ TRACE_EVENT(kvm_fast_mmio,
* Tracepoint for cpuid.
*/
TRACE_EVENT(kvm_cpuid,
TP_PROTO(unsigned int function, unsigned long rax, unsigned long rbx,
unsigned long rcx, unsigned long rdx, bool found),
TP_ARGS(function, rax, rbx, rcx, rdx, found),
TP_PROTO(unsigned int function, unsigned int index, unsigned long rax,
unsigned long rbx, unsigned long rcx, unsigned long rdx,
bool found),
TP_ARGS(function, index, rax, rbx, rcx, rdx, found),

TP_STRUCT__entry(
__field( unsigned int, function )
__field( unsigned int, index )
__field( unsigned long, rax )
__field( unsigned long, rbx )
__field( unsigned long, rcx )
Expand All @@ -166,15 +168,16 @@ TRACE_EVENT(kvm_cpuid,

TP_fast_assign(
__entry->function = function;
__entry->index = index;
__entry->rax = rax;
__entry->rbx = rbx;
__entry->rcx = rcx;
__entry->rdx = rdx;
__entry->found = found;
),

TP_printk("func %x rax %lx rbx %lx rcx %lx rdx %lx, cpuid entry %s",
__entry->function, __entry->rax,
TP_printk("func %x idx %x rax %lx rbx %lx rcx %lx rdx %lx, cpuid entry %s",
__entry->function, __entry->index, __entry->rax,
__entry->rbx, __entry->rcx, __entry->rdx,
__entry->found ? "found" : "not found")
);
Expand Down

0 comments on commit e7adda2

Please sign in to comment.