Message ID | 20220826210019.1211302-2-jmattson@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/3] KVM: x86: Insert "AMD" in KVM_X86_FEATURE_PSFD | expand |
On Fri, Aug 26, 2022, Jim Mattson wrote: > Previously, KVM reported support for CPUID.(EAX=7,ECX=1) only if the > maximum leaf 7 index on the host was exactly 1. A recent microcode > patch for Ice Lake raised the maximum leaf 7 index from 0 to 2, > skipping right over 1. Though that patch left CPUID.(EAX=7,ECX=1) > filled with zeros on Ice Lake, it nonetheless exposed this bug. > > Report CPUID.(EAX=7,ECX=1) support if the maximum leaf 7 index on the > host is at least 1. > > Cc: Sean Christopherson <seanjc@google.com> > Fixes: bcf600ca8d21 ("KVM: x86: Remove the unnecessary loop on CPUID 0x7 sub-leafs") > Signed-off-by: Jim Mattson <jmattson@google.com> > --- > arch/x86/kvm/cpuid.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c > index 07be45c5bb93..64cdabb3cb2c 100644 > --- a/arch/x86/kvm/cpuid.c > +++ b/arch/x86/kvm/cpuid.c > @@ -886,7 +886,7 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function) > cpuid_entry_override(entry, CPUID_7_EDX); > > /* KVM only supports 0x7.0 and 0x7.1, capped above via min(). */ > - if (entry->eax == 1) { > + if (entry->eax >= 1) { But as the comment says, above this is: entry->eax = min(entry->eax, 1u); ... /* KVM only supports 0x7.0 and 0x7.1, capped above via min(). */ if (entry->eax == 1) { What am I missing?
On Fri, Aug 26, 2022 at 4:54 PM Sean Christopherson <seanjc@google.com> wrote: > > On Fri, Aug 26, 2022, Jim Mattson wrote: > > Previously, KVM reported support for CPUID.(EAX=7,ECX=1) only if the > > maximum leaf 7 index on the host was exactly 1. A recent microcode > > patch for Ice Lake raised the maximum leaf 7 index from 0 to 2, > > skipping right over 1. Though that patch left CPUID.(EAX=7,ECX=1) > > filled with zeros on Ice Lake, it nonetheless exposed this bug. > > > > Report CPUID.(EAX=7,ECX=1) support if the maximum leaf 7 index on the > > host is at least 1. > > > > Cc: Sean Christopherson <seanjc@google.com> > > Fixes: bcf600ca8d21 ("KVM: x86: Remove the unnecessary loop on CPUID 0x7 sub-leafs") > > Signed-off-by: Jim Mattson <jmattson@google.com> > > --- > > arch/x86/kvm/cpuid.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c > > index 07be45c5bb93..64cdabb3cb2c 100644 > > --- a/arch/x86/kvm/cpuid.c > > +++ b/arch/x86/kvm/cpuid.c > > @@ -886,7 +886,7 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function) > > cpuid_entry_override(entry, CPUID_7_EDX); > > > > /* KVM only supports 0x7.0 and 0x7.1, capped above via min(). */ > > - if (entry->eax == 1) { > > + if (entry->eax >= 1) { > > But as the comment says, above this is: > > entry->eax = min(entry->eax, 1u); > > ... > > /* KVM only supports 0x7.0 and 0x7.1, capped above via min(). */ > if (entry->eax == 1) { > > What am I missing? It's not you; it's me. There's no bug here.
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index 07be45c5bb93..64cdabb3cb2c 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -886,7 +886,7 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function) cpuid_entry_override(entry, CPUID_7_EDX); /* KVM only supports 0x7.0 and 0x7.1, capped above via min(). */ - if (entry->eax == 1) { + if (entry->eax >= 1) { entry = do_host_cpuid(array, function, 1); if (!entry) goto out;
Previously, KVM reported support for CPUID.(EAX=7,ECX=1) only if the maximum leaf 7 index on the host was exactly 1. A recent microcode patch for Ice Lake raised the maximum leaf 7 index from 0 to 2, skipping right over 1. Though that patch left CPUID.(EAX=7,ECX=1) filled with zeros on Ice Lake, it nonetheless exposed this bug. Report CPUID.(EAX=7,ECX=1) support if the maximum leaf 7 index on the host is at least 1. Cc: Sean Christopherson <seanjc@google.com> Fixes: bcf600ca8d21 ("KVM: x86: Remove the unnecessary loop on CPUID 0x7 sub-leafs") Signed-off-by: Jim Mattson <jmattson@google.com> --- arch/x86/kvm/cpuid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)