From 6d4a3cd42781babed7d29b061e220ebff24dd43e Mon Sep 17 00:00:00 2001
From: Jiri Denemark <jdenemar@redhat.com>
Date: Mon, 8 Jan 2018 20:53:25 +0100
Subject: [PATCH] cpu: Add EPYC-IBPB CPU model

This is a variant of EPYC with indirect branch prediction protection.
The only difference between EPYC and EPYC-IBPB is the added "ibpb"
feature.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
---
 src/cpu/cpu_map.xml                                | 72 ++++++++++++++++++++++
 .../x86_64-cpuid-EPYC-7601-32-Core-ibpb-guest.xml  |  3 +-
 .../x86_64-cpuid-EPYC-7601-32-Core-ibpb-host.xml   |  3 +-
 .../x86_64-cpuid-EPYC-7601-32-Core-ibpb-json.xml   |  3 +-
 4 files changed, 75 insertions(+), 6 deletions(-)

diff --git a/src/cpu/cpu_map.xml b/src/cpu/cpu_map.xml
index 25289d94e..85c728227 100644
--- a/src/cpu/cpu_map.xml
+++ b/src/cpu/cpu_map.xml
@@ -2250,6 +2250,78 @@
       <feature name='xsavec'/>
       <feature name='xsaveopt'/>
     </model>
+
+    <model name='EPYC-IBPB'>
+      <signature family='23' model='1'/>
+      <vendor name='AMD'/>
+      <feature name='3dnowprefetch'/>
+      <feature name='abm'/>
+      <feature name='adx'/>
+      <feature name='aes'/>
+      <feature name='apic'/>
+      <feature name='arat'/>
+      <feature name='avx'/>
+      <feature name='avx2'/>
+      <feature name='bmi1'/>
+      <feature name='bmi2'/>
+      <feature name='clflush'/>
+      <feature name='clflushopt'/>
+      <feature name='cmov'/>
+      <feature name='cr8legacy'/>
+      <feature name='cx16'/>
+      <feature name='cx8'/>
+      <feature name='de'/>
+      <feature name='f16c'/>
+      <feature name='fma'/>
+      <feature name='fpu'/>
+      <feature name='fsgsbase'/>
+      <feature name='fxsr'/>
+      <feature name='fxsr_opt'/>
+      <feature name='ibpb'/>
+      <feature name='lahf_lm'/>
+      <feature name='lm'/>
+      <feature name='mca'/>
+      <feature name='mce'/>
+      <feature name='misalignsse'/>
+      <feature name='mmx'/>
+      <feature name='mmxext'/>
+      <feature name='monitor'/>
+      <feature name='movbe'/>
+      <feature name='msr'/>
+      <feature name='mtrr'/>
+      <feature name='nx'/>
+      <feature name='osvw'/>
+      <feature name='pae'/>
+      <feature name='pat'/>
+      <feature name='pclmuldq'/>
+      <feature name='pdpe1gb'/>
+      <feature name='pge'/>
+      <feature name='pni'/>
+      <feature name='popcnt'/>
+      <feature name='pse'/>
+      <feature name='pse36'/>
+      <feature name='rdrand'/>
+      <feature name='rdseed'/>
+      <feature name='rdtscp'/>
+      <feature name='sep'/>
+      <feature name='sha-ni'/>
+      <feature name='smap'/>
+      <feature name='smep'/>
+      <feature name='sse'/>
+      <feature name='sse2'/>
+      <feature name='sse4.1'/>
+      <feature name='sse4.2'/>
+      <feature name='sse4a'/>
+      <feature name='ssse3'/>
+      <feature name='svm'/>
+      <feature name='syscall'/>
+      <feature name='tsc'/>
+      <feature name='vme'/>
+      <feature name='xgetbv1'/>
+      <feature name='xsave'/>
+      <feature name='xsavec'/>
+      <feature name='xsaveopt'/>
+    </model>
   </arch>
 
   <arch name='ppc64'>
diff --git a/tests/cputestdata/x86_64-cpuid-EPYC-7601-32-Core-ibpb-guest.xml b/tests/cputestdata/x86_64-cpuid-EPYC-7601-32-Core-ibpb-guest.xml
index 33eb8bd1f..1d772977a 100644
--- a/tests/cputestdata/x86_64-cpuid-EPYC-7601-32-Core-ibpb-guest.xml
+++ b/tests/cputestdata/x86_64-cpuid-EPYC-7601-32-Core-ibpb-guest.xml
@@ -1,5 +1,5 @@
 <cpu mode='custom' match='exact'>
-  <model fallback='forbid'>EPYC</model>
+  <model fallback='forbid'>EPYC-IBPB</model>
   <vendor>AMD</vendor>
   <feature policy='require' name='ht'/>
   <feature policy='require' name='osxsave'/>
@@ -13,6 +13,5 @@
   <feature policy='require' name='perfctr_core'/>
   <feature policy='require' name='perfctr_nb'/>
   <feature policy='require' name='invtsc'/>
-  <feature policy='require' name='ibpb'/>
   <feature policy='disable' name='rdtscp'/>
 </cpu>
diff --git a/tests/cputestdata/x86_64-cpuid-EPYC-7601-32-Core-ibpb-host.xml b/tests/cputestdata/x86_64-cpuid-EPYC-7601-32-Core-ibpb-host.xml
index fa66113c6..c14e25433 100644
--- a/tests/cputestdata/x86_64-cpuid-EPYC-7601-32-Core-ibpb-host.xml
+++ b/tests/cputestdata/x86_64-cpuid-EPYC-7601-32-Core-ibpb-host.xml
@@ -1,6 +1,6 @@
 <cpu>
   <arch>x86_64</arch>
-  <model>EPYC</model>
+  <model>EPYC-IBPB</model>
   <vendor>AMD</vendor>
   <feature name='ht'/>
   <feature name='osxsave'/>
@@ -14,5 +14,4 @@
   <feature name='perfctr_core'/>
   <feature name='perfctr_nb'/>
   <feature name='invtsc'/>
-  <feature name='ibpb'/>
 </cpu>
diff --git a/tests/cputestdata/x86_64-cpuid-EPYC-7601-32-Core-ibpb-json.xml b/tests/cputestdata/x86_64-cpuid-EPYC-7601-32-Core-ibpb-json.xml
index 81c09c32a..c4e34a0fa 100644
--- a/tests/cputestdata/x86_64-cpuid-EPYC-7601-32-Core-ibpb-json.xml
+++ b/tests/cputestdata/x86_64-cpuid-EPYC-7601-32-Core-ibpb-json.xml
@@ -1,12 +1,11 @@
 <cpu mode='custom' match='exact'>
-  <model fallback='forbid'>EPYC</model>
+  <model fallback='forbid'>EPYC-IBPB</model>
   <vendor>AMD</vendor>
   <feature policy='require' name='x2apic'/>
   <feature policy='require' name='tsc-deadline'/>
   <feature policy='require' name='hypervisor'/>
   <feature policy='require' name='tsc_adjust'/>
   <feature policy='require' name='cmp_legacy'/>
-  <feature policy='require' name='ibpb'/>
   <feature policy='disable' name='monitor'/>
   <feature policy='disable' name='rdtscp'/>
   <feature policy='disable' name='svm'/>
-- 
2.15.1

