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

KVM: x86: Add blurb to CPUID tracepoint when using max basic leaf values

Tack on "used max basic" at the end of the CPUID tracepoint when the
output values correspond to the max basic leaf, i.e. when emulating
Intel's out-of-range CPUID behavior. Observing "cpuid entry not found"
in the tracepoint with non-zero output values is confusing for users
that aren't familiar with the out-of-range semantics, and qualifying the
"not found" case hopefully makes it clear that "found" means "found the
exact entry".

Suggested-by: 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
2b110b61 e7adda28

+13 -7
+6 -3
arch/x86/kvm/cpuid.c
··· 990 990 { 991 991 u32 orig_function = *eax, function = *eax, index = *ecx; 992 992 struct kvm_cpuid_entry2 *entry; 993 - bool exact; 993 + bool exact, used_max_basic = false; 994 994 995 995 entry = kvm_find_cpuid_entry(vcpu, function, index); 996 996 exact = !!entry; 997 997 998 - if (!entry && !exact_only) 998 + if (!entry && !exact_only) { 999 999 entry = get_out_of_range_cpuid_entry(vcpu, &function, index); 1000 + used_max_basic = !!entry; 1001 + } 1000 1002 1001 1003 if (entry) { 1002 1004 *eax = entry->eax; ··· 1028 1026 } 1029 1027 } 1030 1028 } 1031 - trace_kvm_cpuid(orig_function, index, *eax, *ebx, *ecx, *edx, exact); 1029 + trace_kvm_cpuid(orig_function, index, *eax, *ebx, *ecx, *edx, exact, 1030 + used_max_basic); 1032 1031 return exact; 1033 1032 } 1034 1033 EXPORT_SYMBOL_GPL(kvm_cpuid);
+7 -4
arch/x86/kvm/trace.h
··· 153 153 TRACE_EVENT(kvm_cpuid, 154 154 TP_PROTO(unsigned int function, unsigned int index, unsigned long rax, 155 155 unsigned long rbx, unsigned long rcx, unsigned long rdx, 156 - bool found), 157 - TP_ARGS(function, index, rax, rbx, rcx, rdx, found), 156 + bool found, bool used_max_basic), 157 + TP_ARGS(function, index, rax, rbx, rcx, rdx, found, used_max_basic), 158 158 159 159 TP_STRUCT__entry( 160 160 __field( unsigned int, function ) ··· 164 164 __field( unsigned long, rcx ) 165 165 __field( unsigned long, rdx ) 166 166 __field( bool, found ) 167 + __field( bool, used_max_basic ) 167 168 ), 168 169 169 170 TP_fast_assign( ··· 175 174 __entry->rcx = rcx; 176 175 __entry->rdx = rdx; 177 176 __entry->found = found; 177 + __entry->used_max_basic = used_max_basic; 178 178 ), 179 179 180 - TP_printk("func %x idx %x rax %lx rbx %lx rcx %lx rdx %lx, cpuid entry %s", 180 + TP_printk("func %x idx %x rax %lx rbx %lx rcx %lx rdx %lx, cpuid entry %s%s", 181 181 __entry->function, __entry->index, __entry->rax, 182 182 __entry->rbx, __entry->rcx, __entry->rdx, 183 - __entry->found ? "found" : "not found") 183 + __entry->found ? "found" : "not found", 184 + __entry->used_max_basic ? ", used max basic" : "") 184 185 ); 185 186 186 187 #define AREG(x) { APIC_##x, "APIC_" #x }