yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-i386-Add-2nd-Generation-AMD-EPYC-processors.patch

8fced6
From 1bee5a77b3f999d2933a440021737d0720b32269 Mon Sep 17 00:00:00 2001
8fced6
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
8fced6
Date: Wed, 29 Jul 2020 18:56:21 -0400
8fced6
Subject: [PATCH 1/4] i386: Add 2nd Generation AMD EPYC processors
8fced6
8fced6
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
8fced6
Message-id: <20200729185621.152427-2-dgilbert@redhat.com>
8fced6
Patchwork-id: 98078
8fced6
O-Subject: [RHEL-8.3.0 qemu-kvm PATCH 1/1] i386: Add 2nd Generation AMD EPYC processors
8fced6
Bugzilla: 1780385
8fced6
RH-Acked-by: Danilo de Paula <ddepaula@redhat.com>
8fced6
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
8fced6
RH-Acked-by: Maxim Levitsky <mlevitsk@redhat.com>
8fced6
8fced6
From: "Moger, Babu" <Babu.Moger@amd.com>
8fced6
8fced6
Adds the support for 2nd Gen AMD EPYC Processors. The model display
8fced6
name will be EPYC-Rome.
8fced6
8fced6
Adds the following new feature bits on top of the feature bits from the
8fced6
first generation EPYC models.
8fced6
perfctr-core : core performance counter extensions support. Enables the VM to
8fced6
               use extended performance counter support. It enables six
8fced6
               programmable counters instead of four counters.
8fced6
clzero       : instruction zeroes out the 64 byte cache line specified in RAX.
8fced6
xsaveerptr   : XSAVE, XSAVE, FXSAVEOPT, XSAVEC, XSAVES always save error
8fced6
               pointers and FXRSTOR, XRSTOR, XRSTORS always restore error
8fced6
               pointers.
8fced6
wbnoinvd     : Write back and do not invalidate cache
8fced6
ibpb         : Indirect Branch Prediction Barrier
8fced6
amd-stibp    : Single Thread Indirect Branch Predictor
8fced6
clwb         : Cache Line Write Back and Retain
8fced6
xsaves       : XSAVES, XRSTORS and IA32_XSS support
8fced6
rdpid        : Read Processor ID instruction support
8fced6
umip         : User-Mode Instruction Prevention support
8fced6
8fced6
The  Reference documents are available at
8fced6
https://developer.amd.com/wp-content/resources/55803_0.54-PUB.pdf
8fced6
https://www.amd.com/system/files/TechDocs/24594.pdf
8fced6
8fced6
Depends on following kernel commits:
8fced6
40bc47b08b6e ("kvm: x86: Enumerate support for CLZERO instruction")
8fced6
504ce1954fba ("KVM: x86: Expose XSAVEERPTR to the guest")
8fced6
6d61e3c32248 ("kvm: x86: Expose RDPID in KVM_GET_SUPPORTED_CPUID")
8fced6
52297436199d ("kvm: svm: Update svm_xsaves_supported")
8fced6
8fced6
Signed-off-by: Babu Moger <babu.moger@amd.com>
8fced6
Message-Id: <157314966312.23828.17684821666338093910.stgit@naples-babu.amd.com>
8fced6
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
8fced6
(cherry picked from commit 143c30d4d346831a09e59e9af45afdca0331e819)
8fced6
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
8fced6
---
8fced6
 target/i386/cpu.c | 102 +++++++++++++++++++++++++++++++++++++++++++++-
8fced6
 target/i386/cpu.h |   2 +
8fced6
 2 files changed, 103 insertions(+), 1 deletion(-)
8fced6
8fced6
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
8fced6
index a343de0c9d..ff39fc9905 100644
8fced6
--- a/target/i386/cpu.c
8fced6
+++ b/target/i386/cpu.c
8fced6
@@ -1133,7 +1133,7 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
8fced6
             "clzero", NULL, "xsaveerptr", NULL,
8fced6
             NULL, NULL, NULL, NULL,
8fced6
             NULL, "wbnoinvd", NULL, NULL,
8fced6
-            "ibpb", NULL, NULL, NULL,
8fced6
+            "ibpb", NULL, NULL, "amd-stibp",
8fced6
             NULL, NULL, NULL, NULL,
8fced6
             NULL, NULL, NULL, NULL,
8fced6
             "amd-ssbd", "virt-ssbd", "amd-no-ssb", NULL,
8fced6
@@ -1803,6 +1803,56 @@ static CPUCaches epyc_cache_info = {
8fced6
     },
8fced6
 };
8fced6
 
8fced6
+static CPUCaches epyc_rome_cache_info = {
8fced6
+    .l1d_cache = &(CPUCacheInfo) {
8fced6
+        .type = DATA_CACHE,
8fced6
+        .level = 1,
8fced6
+        .size = 32 * KiB,
8fced6
+        .line_size = 64,
8fced6
+        .associativity = 8,
8fced6
+        .partitions = 1,
8fced6
+        .sets = 64,
8fced6
+        .lines_per_tag = 1,
8fced6
+        .self_init = 1,
8fced6
+        .no_invd_sharing = true,
8fced6
+    },
8fced6
+    .l1i_cache = &(CPUCacheInfo) {
8fced6
+        .type = INSTRUCTION_CACHE,
8fced6
+        .level = 1,
8fced6
+        .size = 32 * KiB,
8fced6
+        .line_size = 64,
8fced6
+        .associativity = 8,
8fced6
+        .partitions = 1,
8fced6
+        .sets = 64,
8fced6
+        .lines_per_tag = 1,
8fced6
+        .self_init = 1,
8fced6
+        .no_invd_sharing = true,
8fced6
+    },
8fced6
+    .l2_cache = &(CPUCacheInfo) {
8fced6
+        .type = UNIFIED_CACHE,
8fced6
+        .level = 2,
8fced6
+        .size = 512 * KiB,
8fced6
+        .line_size = 64,
8fced6
+        .associativity = 8,
8fced6
+        .partitions = 1,
8fced6
+        .sets = 1024,
8fced6
+        .lines_per_tag = 1,
8fced6
+    },
8fced6
+    .l3_cache = &(CPUCacheInfo) {
8fced6
+        .type = UNIFIED_CACHE,
8fced6
+        .level = 3,
8fced6
+        .size = 16 * MiB,
8fced6
+        .line_size = 64,
8fced6
+        .associativity = 16,
8fced6
+        .partitions = 1,
8fced6
+        .sets = 16384,
8fced6
+        .lines_per_tag = 1,
8fced6
+        .self_init = true,
8fced6
+        .inclusive = true,
8fced6
+        .complex_indexing = true,
8fced6
+    },
8fced6
+};
8fced6
+
8fced6
 /* The following VMX features are not supported by KVM and are left out in the
8fced6
  * CPU definitions:
8fced6
  *
8fced6
@@ -4024,6 +4074,56 @@ static X86CPUDefinition builtin_x86_defs[] = {
8fced6
         .model_id = "Hygon Dhyana Processor",
8fced6
         .cache_info = &epyc_cache_info,
8fced6
     },
8fced6
+    {
8fced6
+        .name = "EPYC-Rome",
8fced6
+        .level = 0xd,
8fced6
+        .vendor = CPUID_VENDOR_AMD,
8fced6
+        .family = 23,
8fced6
+        .model = 49,
8fced6
+        .stepping = 0,
8fced6
+        .features[FEAT_1_EDX] =
8fced6
+            CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX | CPUID_CLFLUSH |
8fced6
+            CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_MCA | CPUID_PGE |
8fced6
+            CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 | CPUID_MCE |
8fced6
+            CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE | CPUID_DE |
8fced6
+            CPUID_VME | CPUID_FP87,
8fced6
+        .features[FEAT_1_ECX] =
8fced6
+            CPUID_EXT_RDRAND | CPUID_EXT_F16C | CPUID_EXT_AVX |
8fced6
+            CPUID_EXT_XSAVE | CPUID_EXT_AES |  CPUID_EXT_POPCNT |
8fced6
+            CPUID_EXT_MOVBE | CPUID_EXT_SSE42 | CPUID_EXT_SSE41 |
8fced6
+            CPUID_EXT_CX16 | CPUID_EXT_FMA | CPUID_EXT_SSSE3 |
8fced6
+            CPUID_EXT_MONITOR | CPUID_EXT_PCLMULQDQ | CPUID_EXT_SSE3,
8fced6
+        .features[FEAT_8000_0001_EDX] =
8fced6
+            CPUID_EXT2_LM | CPUID_EXT2_RDTSCP | CPUID_EXT2_PDPE1GB |
8fced6
+            CPUID_EXT2_FFXSR | CPUID_EXT2_MMXEXT | CPUID_EXT2_NX |
8fced6
+            CPUID_EXT2_SYSCALL,
8fced6
+        .features[FEAT_8000_0001_ECX] =
8fced6
+            CPUID_EXT3_OSVW | CPUID_EXT3_3DNOWPREFETCH |
8fced6
+            CPUID_EXT3_MISALIGNSSE | CPUID_EXT3_SSE4A | CPUID_EXT3_ABM |
8fced6
+            CPUID_EXT3_CR8LEG | CPUID_EXT3_SVM | CPUID_EXT3_LAHF_LM |
8fced6
+            CPUID_EXT3_TOPOEXT | CPUID_EXT3_PERFCORE,
8fced6
+        .features[FEAT_8000_0008_EBX] =
8fced6
+            CPUID_8000_0008_EBX_CLZERO | CPUID_8000_0008_EBX_XSAVEERPTR |
8fced6
+            CPUID_8000_0008_EBX_WBNOINVD | CPUID_8000_0008_EBX_IBPB |
8fced6
+            CPUID_8000_0008_EBX_STIBP,
8fced6
+        .features[FEAT_7_0_EBX] =
8fced6
+            CPUID_7_0_EBX_FSGSBASE | CPUID_7_0_EBX_BMI1 | CPUID_7_0_EBX_AVX2 |
8fced6
+            CPUID_7_0_EBX_SMEP | CPUID_7_0_EBX_BMI2 | CPUID_7_0_EBX_RDSEED |
8fced6
+            CPUID_7_0_EBX_ADX | CPUID_7_0_EBX_SMAP | CPUID_7_0_EBX_CLFLUSHOPT |
8fced6
+            CPUID_7_0_EBX_SHA_NI | CPUID_7_0_EBX_CLWB,
8fced6
+        .features[FEAT_7_0_ECX] =
8fced6
+            CPUID_7_0_ECX_UMIP | CPUID_7_0_ECX_RDPID,
8fced6
+        .features[FEAT_XSAVE] =
8fced6
+            CPUID_XSAVE_XSAVEOPT | CPUID_XSAVE_XSAVEC |
8fced6
+            CPUID_XSAVE_XGETBV1 | CPUID_XSAVE_XSAVES,
8fced6
+        .features[FEAT_6_EAX] =
8fced6
+            CPUID_6_EAX_ARAT,
8fced6
+        .features[FEAT_SVM] =
8fced6
+            CPUID_SVM_NPT | CPUID_SVM_NRIPSAVE,
8fced6
+        .xlevel = 0x8000001E,
8fced6
+        .model_id = "AMD EPYC-Rome Processor",
8fced6
+        .cache_info = &epyc_rome_cache_info,
8fced6
+    },
8fced6
 };
8fced6
 
8fced6
 /* KVM-specific features that are automatically added/removed
8fced6
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
8fced6
index 7bfbf2a5e5..f3da25cb8a 100644
8fced6
--- a/target/i386/cpu.h
8fced6
+++ b/target/i386/cpu.h
8fced6
@@ -792,6 +792,8 @@ typedef uint64_t FeatureWordArray[FEATURE_WORDS];
8fced6
 #define CPUID_8000_0008_EBX_WBNOINVD    (1U << 9)
8fced6
 /* Indirect Branch Prediction Barrier */
8fced6
 #define CPUID_8000_0008_EBX_IBPB        (1U << 12)
8fced6
+/* Single Thread Indirect Branch Predictors */
8fced6
+#define CPUID_8000_0008_EBX_STIBP       (1U << 15)
8fced6
 
8fced6
 #define CPUID_XSAVE_XSAVEOPT   (1U << 0)
8fced6
 #define CPUID_XSAVE_XSAVEC     (1U << 1)
8fced6
-- 
8fced6
2.27.0
8fced6