Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: x86: Add requested index to the CPUID tracepoint

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>

authored by

Sean Christopherson and committed by
Paolo Bonzini
e7adda28 d55c9d40

+9 -6
+1 -1
arch/x86/kvm/cpuid.c
··· 1026 1026 } 1027 1027 } 1028 1028 } 1029 - trace_kvm_cpuid(orig_function, *eax, *ebx, *ecx, *edx, exact); 1029 + trace_kvm_cpuid(orig_function, index, *eax, *ebx, *ecx, *edx, exact); 1030 1030 return exact; 1031 1031 } 1032 1032 EXPORT_SYMBOL_GPL(kvm_cpuid);
+8 -5
arch/x86/kvm/trace.h
··· 151 151 * Tracepoint for cpuid. 152 152 */ 153 153 TRACE_EVENT(kvm_cpuid, 154 - TP_PROTO(unsigned int function, unsigned long rax, unsigned long rbx, 155 - unsigned long rcx, unsigned long rdx, bool found), 156 - TP_ARGS(function, rax, rbx, rcx, rdx, found), 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), 157 + TP_ARGS(function, index, rax, rbx, rcx, rdx, found), 157 158 158 159 TP_STRUCT__entry( 159 160 __field( unsigned int, function ) 161 + __field( unsigned int, index ) 160 162 __field( unsigned long, rax ) 161 163 __field( unsigned long, rbx ) 162 164 __field( unsigned long, rcx ) ··· 168 166 169 167 TP_fast_assign( 170 168 __entry->function = function; 169 + __entry->index = index; 171 170 __entry->rax = rax; 172 171 __entry->rbx = rbx; 173 172 __entry->rcx = rcx; ··· 176 173 __entry->found = found; 177 174 ), 178 175 179 - TP_printk("func %x rax %lx rbx %lx rcx %lx rdx %lx, cpuid entry %s", 180 - __entry->function, __entry->rax, 176 + TP_printk("func %x idx %x rax %lx rbx %lx rcx %lx rdx %lx, cpuid entry %s", 177 + __entry->function, __entry->index, __entry->rax, 181 178 __entry->rbx, __entry->rcx, __entry->rdx, 182 179 __entry->found ? "found" : "not found") 183 180 );