diff mbox

KVM:x86: AMD Processor Topology Information

Message ID 20171029215633.3102-1-pixo@polepetko.eu (mailing list archive)
State New, archived
Headers show

Commit Message

Stanislav Lanci Oct. 29, 2017, 9:56 p.m. UTC
This patch allow to enable x86 feature TOPOEXT and increase maximum extended function to 0x8000001E.
Both are needed to provide information about SMT on AMD Zen CPUs to the guest.

Signed-off-by: Stanislav Lanci <pixo@polepetko.eu>
---
 arch/x86/kvm/cpuid.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Nick Sarnie Oct. 29, 2017, 10:44 p.m. UTC | #1
On Sun, Oct 29, 2017 at 5:56 PM, Stanislav Lanci <pixo@polepetko.eu> wrote:
> This patch allow to enable x86 feature TOPOEXT and increase maximum extended function to 0x8000001E.
> Both are needed to provide information about SMT on AMD Zen CPUs to the guest.
>
> Signed-off-by: Stanislav Lanci <pixo@polepetko.eu>
> ---
>  arch/x86/kvm/cpuid.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
> index 0099e10eb045..374afdeaa6f5 100644
> --- a/arch/x86/kvm/cpuid.c
> +++ b/arch/x86/kvm/cpuid.c
> @@ -365,7 +365,8 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
>                 F(LAHF_LM) | F(CMP_LEGACY) | 0 /*SVM*/ | 0 /* ExtApicSpace */ |
>                 F(CR8_LEGACY) | F(ABM) | F(SSE4A) | F(MISALIGNSSE) |
>                 F(3DNOWPREFETCH) | F(OSVW) | 0 /* IBS */ | F(XOP) |
> -               0 /* SKINIT, WDT, LWP */ | F(FMA4) | F(TBM);
> +               0 /* SKINIT, WDT, LWP */ | F(FMA4) | F(TBM) |
> +               F(TOPOEXT);
>
>         /* cpuid 0xC0000001.edx */
>         const u32 kvm_cpuid_C000_0001_edx_x86_features =
> @@ -604,7 +605,7 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
>                 entry->edx = 0;
>                 break;
>         case 0x80000000:
> -               entry->eax = min(entry->eax, 0x8000001a);
> +               entry->eax = min(entry->eax, 0x8000001e);
>                 break;
>         case 0x80000001:
>                 entry->edx &= kvm_cpuid_8000_0001_edx_x86_features;
> --
> 2.14.2
>

No idea if it's correct, it seems to work in a Win10 guest:

Tested-by: Nick Sarnie <commendsarnex@gmail.com>
Moger, Babu Jan. 26, 2018, 9:04 p.m. UTC | #2
Looks  good to me. But needs rebase on top of linux-next tree.

One change is not required after the commit
8765d75329a3 KVM: X86: Extend CPUID range to include new leaf

Stanislav, Can you please rebase this patch. Let me know if you want
me to rebase it. Thanks
Paolo Bonzini Jan. 26, 2018, 10:53 p.m. UTC | #3
On 29/10/2017 22:56, Stanislav Lanci wrote:
> This patch allow to enable x86 feature TOPOEXT and increase maximum extended function to 0x8000001E.
> Both are needed to provide information about SMT on AMD Zen CPUs to the guest.
> 
> Signed-off-by: Stanislav Lanci <pixo@polepetko.eu>
> ---
>  arch/x86/kvm/cpuid.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
> index 0099e10eb045..374afdeaa6f5 100644
> --- a/arch/x86/kvm/cpuid.c
> +++ b/arch/x86/kvm/cpuid.c
> @@ -365,7 +365,8 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
>  		F(LAHF_LM) | F(CMP_LEGACY) | 0 /*SVM*/ | 0 /* ExtApicSpace */ |
>  		F(CR8_LEGACY) | F(ABM) | F(SSE4A) | F(MISALIGNSSE) |
>  		F(3DNOWPREFETCH) | F(OSVW) | 0 /* IBS */ | F(XOP) |
> -		0 /* SKINIT, WDT, LWP */ | F(FMA4) | F(TBM);
> +		0 /* SKINIT, WDT, LWP */ | F(FMA4) | F(TBM) |
> +		F(TOPOEXT);
>  
>  	/* cpuid 0xC0000001.edx */
>  	const u32 kvm_cpuid_C000_0001_edx_x86_features =
> @@ -604,7 +605,7 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
>  		entry->edx = 0;
>  		break;
>  	case 0x80000000:
> -		entry->eax = min(entry->eax, 0x8000001a);
> +		entry->eax = min(entry->eax, 0x8000001e);
>  		break;
>  	case 0x80000001:
>  		entry->edx &= kvm_cpuid_8000_0001_edx_x86_features;
> 

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
diff mbox

Patch

diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 0099e10eb045..374afdeaa6f5 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -365,7 +365,8 @@  static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
 		F(LAHF_LM) | F(CMP_LEGACY) | 0 /*SVM*/ | 0 /* ExtApicSpace */ |
 		F(CR8_LEGACY) | F(ABM) | F(SSE4A) | F(MISALIGNSSE) |
 		F(3DNOWPREFETCH) | F(OSVW) | 0 /* IBS */ | F(XOP) |
-		0 /* SKINIT, WDT, LWP */ | F(FMA4) | F(TBM);
+		0 /* SKINIT, WDT, LWP */ | F(FMA4) | F(TBM) |
+		F(TOPOEXT);
 
 	/* cpuid 0xC0000001.edx */
 	const u32 kvm_cpuid_C000_0001_edx_x86_features =
@@ -604,7 +605,7 @@  static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
 		entry->edx = 0;
 		break;
 	case 0x80000000:
-		entry->eax = min(entry->eax, 0x8000001a);
+		entry->eax = min(entry->eax, 0x8000001e);
 		break;
 	case 0x80000001:
 		entry->edx &= kvm_cpuid_8000_0001_edx_x86_features;