Skip to content

Commit 2b110b6

Browse files
Sean Christophersonbonzini
authored andcommitted
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>
1 parent e7adda2 commit 2b110b6

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

‎arch/x86/kvm/cpuid.c‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -990,13 +990,15 @@ bool kvm_cpuid(struct kvm_vcpu *vcpu, u32 *eax, u32 *ebx,
990990
{
991991
u32 orig_function = *eax, function = *eax, index = *ecx;
992992
struct kvm_cpuid_entry2 *entry;
993-
bool exact;
993+
bool exact, used_max_basic = false;
994994

995995
entry = kvm_find_cpuid_entry(vcpu, function, index);
996996
exact = !!entry;
997997

998-
if (!entry && !exact_only)
998+
if (!entry && !exact_only) {
999999
entry = get_out_of_range_cpuid_entry(vcpu, &function, index);
1000+
used_max_basic = !!entry;
1001+
}
10001002

10011003
if (entry) {
10021004
*eax = entry->eax;
@@ -1026,7 +1028,8 @@ bool kvm_cpuid(struct kvm_vcpu *vcpu, u32 *eax, u32 *ebx,
10261028
}
10271029
}
10281030
}
1029-
trace_kvm_cpuid(orig_function, index, *eax, *ebx, *ecx, *edx, exact);
1031+
trace_kvm_cpuid(orig_function, index, *eax, *ebx, *ecx, *edx, exact,
1032+
used_max_basic);
10301033
return exact;
10311034
}
10321035
EXPORT_SYMBOL_GPL(kvm_cpuid);

‎arch/x86/kvm/trace.h‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ TRACE_EVENT(kvm_fast_mmio,
153153
TRACE_EVENT(kvm_cpuid,
154154
TP_PROTO(unsigned int function, unsigned int index, unsigned long rax,
155155
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),
158158

159159
TP_STRUCT__entry(
160160
__field( unsigned int, function )
@@ -164,6 +164,7 @@ TRACE_EVENT(kvm_cpuid,
164164
__field( unsigned long, rcx )
165165
__field( unsigned long, rdx )
166166
__field( bool, found )
167+
__field( bool, used_max_basic )
167168
),
168169

169170
TP_fast_assign(
@@ -174,12 +175,14 @@ TRACE_EVENT(kvm_cpuid,
174175
__entry->rcx = rcx;
175176
__entry->rdx = rdx;
176177
__entry->found = found;
178+
__entry->used_max_basic = used_max_basic;
177179
),
178180

179-
TP_printk("func %x idx %x rax %lx rbx %lx rcx %lx rdx %lx, cpuid entry %s",
181+
TP_printk("func %x idx %x rax %lx rbx %lx rcx %lx rdx %lx, cpuid entry %s%s",
180182
__entry->function, __entry->index, __entry->rax,
181183
__entry->rbx, __entry->rcx, __entry->rdx,
182-
__entry->found ? "found" : "not found")
184+
__entry->found ? "found" : "not found",
185+
__entry->used_max_basic ? ", used max basic" : "")
183186
);
184187

185188
#define AREG(x) { APIC_##x, "APIC_" #x }

0 commit comments

Comments
 (0)