d65131
From: Brijesh Singh <brijesh.singh@amd.com>
d65131
Date: Tue, 15 Aug 2017 12:00:51 -0500
a056f3
Subject: [PATCH] target-i386/cpu: Add new EPYC CPU model
d65131
d65131
Add a new base CPU model called 'EPYC' to model processors from AMD EPYC
d65131
family (which includes EPYC 76xx,75xx,74xx, 73xx and 72xx).
d65131
d65131
The following features bits have been added/removed compare to Opteron_G5
d65131
d65131
Added: monitor, movbe, rdrand, mmxext, ffxsr, rdtscp, cr8legacy, osvw,
d65131
       fsgsbase, bmi1, avx2, smep, bmi2, rdseed, adx, smap, clfshopt, sha
d65131
       xsaveopt, xsavec, xgetbv1, arat
d65131
d65131
Removed: xop, fma4, tbm
d65131
d65131
Cc: Paolo Bonzini <pbonzini@redhat.com>
d65131
Cc: Richard Henderson <rth@twiddle.net>
d65131
Cc: Eduardo Habkost <ehabkost@redhat.com>
d65131
Cc: Tom Lendacky <thomas.lendacky@amd.com>
d65131
Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
d65131
Message-Id: <20170815170051.127257-1-brijesh.singh@amd.com>
d65131
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
d65131
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
d65131
(cherry picked from commit 2e2efc7dbe2b0adc1200b5aa286cdbed729f6751)
d65131
---
d65131
 target/i386/cpu.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
d65131
 1 file changed, 44 insertions(+)
d65131
d65131
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
d65131
index dbe3393b1c..0862877973 100644
d65131
--- a/target/i386/cpu.c
d65131
+++ b/target/i386/cpu.c
d65131
@@ -1919,6 +1919,50 @@ static X86CPUDefinition builtin_x86_defs[] = {
d65131
         .xlevel = 0x8000001A,
d65131
         .model_id = "AMD Opteron 63xx class CPU",
d65131
     },
d65131
+    {
d65131
+        .name = "EPYC",
d65131
+        .level = 0xd,
d65131
+        .vendor = CPUID_VENDOR_AMD,
d65131
+        .family = 23,
d65131
+        .model = 1,
d65131
+        .stepping = 2,
d65131
+        .features[FEAT_1_EDX] =
d65131
+            CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX | CPUID_CLFLUSH |
d65131
+            CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_MCA | CPUID_PGE |
d65131
+            CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 | CPUID_MCE |
d65131
+            CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE | CPUID_DE |
d65131
+            CPUID_VME | CPUID_FP87,
d65131
+        .features[FEAT_1_ECX] =
d65131
+            CPUID_EXT_RDRAND | CPUID_EXT_F16C | CPUID_EXT_AVX |
d65131
+            CPUID_EXT_XSAVE | CPUID_EXT_AES |  CPUID_EXT_POPCNT |
d65131
+            CPUID_EXT_MOVBE | CPUID_EXT_SSE42 | CPUID_EXT_SSE41 |
d65131
+            CPUID_EXT_CX16 | CPUID_EXT_FMA | CPUID_EXT_SSSE3 |
d65131
+            CPUID_EXT_MONITOR | CPUID_EXT_PCLMULQDQ | CPUID_EXT_SSE3,
d65131
+        .features[FEAT_8000_0001_EDX] =
d65131
+            CPUID_EXT2_LM | CPUID_EXT2_RDTSCP | CPUID_EXT2_PDPE1GB |
d65131
+            CPUID_EXT2_FFXSR | CPUID_EXT2_MMXEXT | CPUID_EXT2_NX |
d65131
+            CPUID_EXT2_SYSCALL,
d65131
+        .features[FEAT_8000_0001_ECX] =
d65131
+            CPUID_EXT3_OSVW | CPUID_EXT3_3DNOWPREFETCH |
d65131
+            CPUID_EXT3_MISALIGNSSE | CPUID_EXT3_SSE4A | CPUID_EXT3_ABM |
d65131
+            CPUID_EXT3_CR8LEG | CPUID_EXT3_SVM | CPUID_EXT3_LAHF_LM,
d65131
+        .features[FEAT_7_0_EBX] =
d65131
+            CPUID_7_0_EBX_FSGSBASE | CPUID_7_0_EBX_BMI1 | CPUID_7_0_EBX_AVX2 |
d65131
+            CPUID_7_0_EBX_SMEP | CPUID_7_0_EBX_BMI2 | CPUID_7_0_EBX_RDSEED |
d65131
+            CPUID_7_0_EBX_ADX | CPUID_7_0_EBX_SMAP | CPUID_7_0_EBX_CLFLUSHOPT |
d65131
+            CPUID_7_0_EBX_SHA_NI,
d65131
+        /* Missing: XSAVES (not supported by some Linux versions,
d65131
+         * including v4.1 to v4.12).
d65131
+         * KVM doesn't yet expose any XSAVES state save component.
d65131
+         */
d65131
+        .features[FEAT_XSAVE] =
d65131
+            CPUID_XSAVE_XSAVEOPT | CPUID_XSAVE_XSAVEC |
d65131
+            CPUID_XSAVE_XGETBV1,
d65131
+        .features[FEAT_6_EAX] =
d65131
+            CPUID_6_EAX_ARAT,
d65131
+        .xlevel = 0x8000000A,
d65131
+        .model_id = "AMD EPYC Processor",
d65131
+    },
d65131
 };
d65131
 
d65131
 typedef struct PropValue {