cryptospore / rpms / qemu-kvm

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