26ba25
From 1fb1babff46264380702607ac92fc95d8adb90c1 Mon Sep 17 00:00:00 2001
26ba25
From: Eduardo Habkost <ehabkost@redhat.com>
26ba25
Date: Thu, 26 Jul 2018 17:19:02 +0100
26ba25
Subject: [PATCH 12/14] i386: Enable TOPOEXT feature on AMD EPYC CPU
26ba25
26ba25
RH-Author: Eduardo Habkost <ehabkost@redhat.com>
26ba25
Message-id: <20180726171904.27418-10-ehabkost@redhat.com>
26ba25
Patchwork-id: 81531
26ba25
O-Subject: [qemu-kvm RHEL8/virt212 PATCH v2 09/11] i386: Enable TOPOEXT feature on AMD EPYC CPU
26ba25
Bugzilla: 1597739
26ba25
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
26ba25
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
26ba25
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
26ba25
26ba25
From: Babu Moger <babu.moger@amd.com>
26ba25
26ba25
Enable TOPOEXT feature on EPYC CPU. This is required to support
26ba25
hyperthreading on VM guests. Also extend xlevel to 0x8000001E.
26ba25
26ba25
Disable topoext on PC_COMPAT_2_12 and keep xlevel 0x8000000a.
26ba25
26ba25
Signed-off-by: Babu Moger <babu.moger@amd.com>
26ba25
Message-Id: <1529443919-67509-3-git-send-email-babu.moger@amd.com>
26ba25
[ehabkost: Added EPYC-IBPB.xlevel to PC_COMPAT_2_12]
26ba25
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
26ba25
(cherry picked from commit e00516475c270dcb6705753da96063f95699abf2)
26ba25
[ehabkost: moved compat code to PC_RHEL75_COMPAT]
26ba25
[ehabkost: fixed typo on EPYC-IBPB compat entry]
26ba25
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
26ba25
---
26ba25
Changes v2 -> v3:
26ba25
* Removed duplicate TYPE_X86_CPU.legacy-cache=on entry from
26ba25
  PC_RHEL7_5_COMPAT (caught by Laurent Vivier)
26ba25
26ba25
Changes v1 -> v2:
26ba25
* Fixed typo on EPYC-IBPB compat entry
26ba25
26ba25
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
26ba25
---
26ba25
 include/hw/i386/pc.h | 12 ++++++++++++
26ba25
 target/i386/cpu.c    | 10 ++++++----
26ba25
 2 files changed, 18 insertions(+), 4 deletions(-)
26ba25
26ba25
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
26ba25
index 5aebf6e..c33ddbb 100644
26ba25
--- a/include/hw/i386/pc.h
26ba25
+++ b/include/hw/i386/pc.h
26ba25
@@ -983,6 +983,18 @@ extern void igd_passthrough_isa_bridge_create(PCIBus *bus, uint16_t gpu_dev_id);
26ba25
             .driver   = TYPE_X86_CPU,\
26ba25
             .property = "legacy-cache",\
26ba25
             .value    = "on",\
26ba25
+        },{ /* PC_RHEL7_5_COMPAT from PC_COMPAT_2_12 */ \
26ba25
+            .driver   = TYPE_X86_CPU,\
26ba25
+            .property = "topoext",\
26ba25
+            .value    = "off",\
26ba25
+        },{ /* PC_RHEL7_5_COMPAT from PC_COMPAT_2_12 */ \
26ba25
+            .driver   = "EPYC-" TYPE_X86_CPU,\
26ba25
+            .property = "xlevel",\
26ba25
+            .value    = stringify(0x8000000a),\
26ba25
+        },{ /* PC_RHEL7_5_COMPAT from PC_COMPAT_2_12 */ \
26ba25
+            .driver   = "EPYC-IBPB-" TYPE_X86_CPU,\
26ba25
+            .property = "xlevel",\
26ba25
+            .value    = stringify(0x8000000a),\
26ba25
         },
26ba25
 
26ba25
 
26ba25
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
26ba25
index cd0667f..fe2b2e8 100644
26ba25
--- a/target/i386/cpu.c
26ba25
+++ b/target/i386/cpu.c
26ba25
@@ -2562,7 +2562,8 @@ static X86CPUDefinition builtin_x86_defs[] = {
26ba25
         .features[FEAT_8000_0001_ECX] =
26ba25
             CPUID_EXT3_OSVW | CPUID_EXT3_3DNOWPREFETCH |
26ba25
             CPUID_EXT3_MISALIGNSSE | CPUID_EXT3_SSE4A | CPUID_EXT3_ABM |
26ba25
-            CPUID_EXT3_CR8LEG | CPUID_EXT3_SVM | CPUID_EXT3_LAHF_LM,
26ba25
+            CPUID_EXT3_CR8LEG | CPUID_EXT3_SVM | CPUID_EXT3_LAHF_LM |
26ba25
+            CPUID_EXT3_TOPOEXT,
26ba25
         .features[FEAT_7_0_EBX] =
26ba25
             CPUID_7_0_EBX_FSGSBASE | CPUID_7_0_EBX_BMI1 | CPUID_7_0_EBX_AVX2 |
26ba25
             CPUID_7_0_EBX_SMEP | CPUID_7_0_EBX_BMI2 | CPUID_7_0_EBX_RDSEED |
26ba25
@@ -2577,7 +2578,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
26ba25
             CPUID_XSAVE_XGETBV1,
26ba25
         .features[FEAT_6_EAX] =
26ba25
             CPUID_6_EAX_ARAT,
26ba25
-        .xlevel = 0x8000000A,
26ba25
+        .xlevel = 0x8000001E,
26ba25
         .model_id = "AMD EPYC Processor",
26ba25
         .cache_info = &epyc_cache_info,
26ba25
     },
26ba25
@@ -2607,7 +2608,8 @@ static X86CPUDefinition builtin_x86_defs[] = {
26ba25
         .features[FEAT_8000_0001_ECX] =
26ba25
             CPUID_EXT3_OSVW | CPUID_EXT3_3DNOWPREFETCH |
26ba25
             CPUID_EXT3_MISALIGNSSE | CPUID_EXT3_SSE4A | CPUID_EXT3_ABM |
26ba25
-            CPUID_EXT3_CR8LEG | CPUID_EXT3_SVM | CPUID_EXT3_LAHF_LM,
26ba25
+            CPUID_EXT3_CR8LEG | CPUID_EXT3_SVM | CPUID_EXT3_LAHF_LM |
26ba25
+            CPUID_EXT3_TOPOEXT,
26ba25
         .features[FEAT_8000_0008_EBX] =
26ba25
             CPUID_8000_0008_EBX_IBPB,
26ba25
         .features[FEAT_7_0_EBX] =
26ba25
@@ -2624,7 +2626,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
26ba25
             CPUID_XSAVE_XGETBV1,
26ba25
         .features[FEAT_6_EAX] =
26ba25
             CPUID_6_EAX_ARAT,
26ba25
-        .xlevel = 0x8000000A,
26ba25
+        .xlevel = 0x8000001E,
26ba25
         .model_id = "AMD EPYC Processor (with IBPB)",
26ba25
         .cache_info = &epyc_cache_info,
26ba25
     },
26ba25
-- 
26ba25
1.8.3.1
26ba25