[1/2] kvm: x86: Include multiple indices with CPUID leaf 0x8000001d
diff mbox series

Message ID 20190327201537.77350-1-jmattson@google.com
State New
Headers show
Series
  • [1/2] kvm: x86: Include multiple indices with CPUID leaf 0x8000001d
Related show

Commit Message

Jim Mattson March 27, 2019, 8:15 p.m. UTC
Per the APM, "CPUID Fn8000_001D_E[D,C,B,A]X reports cache topology
information for the cache enumerated by the value passed to the
instruction in ECX, referred to as Cache n in the following
description. To gather information for all cache levels, software must
repeatedly execute CPUID with 8000_001Dh in EAX and ECX set to
increasing values beginning with 0 until a value of 00h is returned in
the field CacheType (EAX[4:0]) indicating no more cache descriptions
are available for this processor."

The termination condition is the same as leaf 4, so we can reuse that
code block for leaf 0x8000001d.

Fixes: 8765d75329a38 ("KVM: X86: Extend CPUID range to include new leaf")
Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Borislav Petkov <bp@suse.de>
Signed-off-by: Jim Mattson <jmattson@google.com>
Reviewed-by: Marc Orr <marcorr@google.com>
---
 arch/x86/kvm/cpuid.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Comments

Borislav Petkov April 1, 2019, 5:06 p.m. UTC | #1
On Wed, Mar 27, 2019 at 01:15:36PM -0700, Jim Mattson wrote:
> Per the APM, "CPUID Fn8000_001D_E[D,C,B,A]X reports cache topology
> information for the cache enumerated by the value passed to the
> instruction in ECX, referred to as Cache n in the following
> description. To gather information for all cache levels, software must
> repeatedly execute CPUID with 8000_001Dh in EAX and ECX set to
> increasing values beginning with 0 until a value of 00h is returned in
> the field CacheType (EAX[4:0]) indicating no more cache descriptions
> are available for this processor."
> 
> The termination condition is the same as leaf 4, so we can reuse that
> code block for leaf 0x8000001d.
> 
> Fixes: 8765d75329a38 ("KVM: X86: Extend CPUID range to include new leaf")
> Cc: Brijesh Singh <brijesh.singh@amd.com>
> Cc: Borislav Petkov <bp@suse.de>
> Signed-off-by: Jim Mattson <jmattson@google.com>
> Reviewed-by: Marc Orr <marcorr@google.com>
> ---
>  arch/x86/kvm/cpuid.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)

Reviewed-by: Borislav Petkov <bp@suse.de>
Jim Mattson May 17, 2019, 5:47 p.m. UTC | #2
On Mon, Apr 1, 2019 at 10:06 AM Borislav Petkov <bp@suse.de> wrote:
>
> On Wed, Mar 27, 2019 at 01:15:36PM -0700, Jim Mattson wrote:
> > Per the APM, "CPUID Fn8000_001D_E[D,C,B,A]X reports cache topology
> > information for the cache enumerated by the value passed to the
> > instruction in ECX, referred to as Cache n in the following
> > description. To gather information for all cache levels, software must
> > repeatedly execute CPUID with 8000_001Dh in EAX and ECX set to
> > increasing values beginning with 0 until a value of 00h is returned in
> > the field CacheType (EAX[4:0]) indicating no more cache descriptions
> > are available for this processor."
> >
> > The termination condition is the same as leaf 4, so we can reuse that
> > code block for leaf 0x8000001d.
> >
> > Fixes: 8765d75329a38 ("KVM: X86: Extend CPUID range to include new leaf")
> > Cc: Brijesh Singh <brijesh.singh@amd.com>
> > Cc: Borislav Petkov <bp@suse.de>
> > Signed-off-by: Jim Mattson <jmattson@google.com>
> > Reviewed-by: Marc Orr <marcorr@google.com>
> > ---
> >  arch/x86/kvm/cpuid.c | 7 +++----
> >  1 file changed, 3 insertions(+), 4 deletions(-)
>
> Reviewed-by: Borislav Petkov <bp@suse.de>

Paolo?

Patch
diff mbox series

diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index fd3951638ae4..d22bba0b2ecc 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -455,8 +455,9 @@  static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
 		}
 		break;
 	}
-	/* function 4 has additional index. */
-	case 4: {
+	/* functions 4 and 0x8000001d have additional index. */
+	case 4:
+	case 0x8000001d: {
 		int i, cache_type;
 
 		entry->flags |= KVM_CPUID_FLAG_SIGNIFCANT_INDEX;
@@ -701,8 +702,6 @@  static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
 		break;
 	case 0x8000001a:
 		break;
-	case 0x8000001d:
-		break;
 	/*Add support for Centaur's CPUID instruction*/
 	case 0xC0000000:
 		/*Just support up to 0xC0000004 now*/