diff mbox series

[PULL,09/12] i386: Allow TOPOEXT to be enabled on older kernels

Message ID 20180625222524.382-10-ehabkost@redhat.com
State New
Headers show
Series [PULL,01/12] i386: Add support for CPUID_8000_001E for AMD | expand

Commit Message

Eduardo Habkost June 25, 2018, 10:25 p.m. UTC
From: Babu Moger <babu.moger@amd.com>

Enabling TOPOEXT feature might cause compatibility issues if
older kernels does not set this feature. Lets set this feature
unconditionally.

Signed-off-by: Babu Moger <babu.moger@amd.com>
Message-Id: <1528939107-17193-2-git-send-email-babu.moger@amd.com>
[ehabkost: rewrite comment and commit message]
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 target/i386/kvm.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Richard W.M. Jones Aug. 9, 2018, 8:29 p.m. UTC | #1
On Mon, Jun 25, 2018 at 07:25:21PM -0300, Eduardo Habkost wrote:
> From: Babu Moger <babu.moger@amd.com>
> 
> Enabling TOPOEXT feature might cause compatibility issues if
> older kernels does not set this feature. Lets set this feature
> unconditionally.
> 
> Signed-off-by: Babu Moger <babu.moger@amd.com>
> Message-Id: <1528939107-17193-2-git-send-email-babu.moger@amd.com>
> [ehabkost: rewrite comment and commit message]
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
>  target/i386/kvm.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/target/i386/kvm.c b/target/i386/kvm.c
> index 445e0e0b11..2d174f3a91 100644
> --- a/target/i386/kvm.c
> +++ b/target/i386/kvm.c
> @@ -372,6 +372,13 @@ uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function,
>          if (host_tsx_blacklisted()) {
>              ret &= ~(CPUID_7_0_EBX_RTM | CPUID_7_0_EBX_HLE);
>          }
> +    } else if (function == 0x80000001 && reg == R_ECX) {
> +        /*
> +         * It's safe to enable TOPOEXT even if it's not returned by
> +         * GET_SUPPORTED_CPUID.  Unconditionally enabling TOPOEXT here allows
> +         * us to keep CPU models including TOPOEXT runnable on older kernels.
> +         */
> +        ret |= CPUID_EXT3_TOPOEXT;
>      } else if (function == 0x80000001 && reg == R_EDX) {
>          /* On Intel, kvm returns cpuid according to the Intel spec,
>           * so add missing bits according to the AMD spec:

This commit breaks KVM (not TCG) with -cpu host on:

  AMD Phenom(tm) 9600B Quad-Core Processor

More details including full qemu command line etc in this bug:

  https://bugzilla.redhat.com/show_bug.cgi?id=1613277

Rich.
diff mbox series

Patch

diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index 445e0e0b11..2d174f3a91 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -372,6 +372,13 @@  uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function,
         if (host_tsx_blacklisted()) {
             ret &= ~(CPUID_7_0_EBX_RTM | CPUID_7_0_EBX_HLE);
         }
+    } else if (function == 0x80000001 && reg == R_ECX) {
+        /*
+         * It's safe to enable TOPOEXT even if it's not returned by
+         * GET_SUPPORTED_CPUID.  Unconditionally enabling TOPOEXT here allows
+         * us to keep CPU models including TOPOEXT runnable on older kernels.
+         */
+        ret |= CPUID_EXT3_TOPOEXT;
     } else if (function == 0x80000001 && reg == R_EDX) {
         /* On Intel, kvm returns cpuid according to the Intel spec,
          * so add missing bits according to the AMD spec: