Skip to contentSkip to conversation

i386: Add new Hygon 'Dhyana' and 'Dhyana-IBPB' CPU models

RFC PATCH Superseded Pu Wen 3 participants 5 messages Apr 12, 2019

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Pu Wen

author
#0 lore raw

RFC PATCH 1/1 i386: Add new Hygon 'Dhyana' and 'Dhyana-IBPB' CPU models

Add two new base CPU models called 'Dhyana' and 'Dhyana-IBPB' to model processors from Hygon Dhyana (family 18h), which derived from AMD EPYC (family 17h). 'Dhyana-IBPB' is a copy of the 'Dhyana' CPU model with just CPUID_8000_0008_EBX_IBPB added.

The following features bits have been removed compare to AMD EPYC:
aes, pclmulqdq, sha_ni

The Hygon Dhyana support to KVM in Linux is already accepted upstream[1]. So add Hygon Dhyana support to Qemu is necessary to create Hygon's own CPU models.

Reference:
[1] https://git.kernel.org/tip/fec98069fb72fb656304a3e52265e0c2fc9adf87

---
 hw/i386/pc.c      |  6 ++++
 target/i386/cpu.c | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 target/i386/cpu.h |  2 ++
 3 files changed, 106 insertions(+)
hw/i386/pc.c +6 -0
index f2c15bf..7e59f50 100644
@@ -128,6 +128,10 @@ GlobalProperty pc_compat_3_1[] = {
     { "EPYC" "-" TYPE_X86_CPU, "nrip-save", "off" },
     { "EPYC-IBPB" "-" TYPE_X86_CPU, "npt", "off" },
     { "EPYC-IBPB" "-" TYPE_X86_CPU, "nrip-save", "off" },
+    { "Dhyana" "-" TYPE_X86_CPU, "npt", "off" },
+    { "Dhyana" "-" TYPE_X86_CPU, "nrip-save", "off" },
+    { "Dhyana-IBPB" "-" TYPE_X86_CPU, "npt", "off" },
+    { "Dhyana-IBPB" "-" TYPE_X86_CPU, "nrip-save", "off" },
     { "Skylake-Client" "-" TYPE_X86_CPU,      "mpx", "on" },
     { "Skylake-Client-IBRS" "-" TYPE_X86_CPU, "mpx", "on" },
     { "Skylake-Server" "-" TYPE_X86_CPU,      "mpx", "on" },
@@ -152,6 +156,8 @@ GlobalProperty pc_compat_2_12[] = {
     { TYPE_X86_CPU, "topoext", "off" },
     { "EPYC-" TYPE_X86_CPU, "xlevel", "0x8000000a" },
     { "EPYC-IBPB-" TYPE_X86_CPU, "xlevel", "0x8000000a" },
+    { "Dhyana-" TYPE_X86_CPU, "xlevel", "0x8000000a" },
+    { "Dhyana-IBPB-" TYPE_X86_CPU, "xlevel", "0x8000000a" },
 };
 const size_t pc_compat_2_12_len = G_N_ELEMENTS(pc_compat_2_12);
 
target/i386/cpu.c +98 -0

104 lines not on this page · raw message

target/i386/cpu.h +2 -0
index 83fb522..553dbe7 100644
@@ -726,6 +726,8 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS];
 
 #define CPUID_VENDOR_VIA   "CentaurHauls"
 
+#define CPUID_VENDOR_HYGON    "HygonGenuine"
+
 #define CPUID_MWAIT_IBE     (1U << 1) /* Interrupts can exit capability */
 #define CPUID_MWAIT_EMX     (1U << 0) /* enumeration supported */
 
Signature · 1 line
2.7.4
#1 lore raw
Quoted 4 lines · Pu Wen

Add two new base CPU models called 'Dhyana' and 'Dhyana-IBPB' to model processors from Hygon Dhyana (family 18h), which derived from AMD EPYC (family 17h). 'Dhyana-IBPB' is a copy of the 'Dhyana' CPU model with just CPUID_8000_0008_EBX_IBPB added.

Do we really need to support both CPU variants ?

The IBPB feature is the Spectre fix which dates from January 2018. Having both made (limited) sense for EPYC as EPYC CPUs existed already, so there would be a mix of EPYC CPUs with and without the microcode that adds IBPB.

The Google results I see suggest that Dhyana CPUs started to become available in July 2018, so surely they would come with microcode that has the IBPB right from day 1 ?

Am I missing anything that means there will be a compelling need to support Dhyana /without/ IBPB ?

If not, then we only need 1 CPU model and that would include IBPB.

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#2 lore raw
Quoted 6 lines · Daniel P. Berrangé
Quoted 4 lines

Add two new base CPU models called 'Dhyana' and 'Dhyana-IBPB' to model processors from Hygon Dhyana (family 18h), which derived from AMD EPYC (family 17h). 'Dhyana-IBPB' is a copy of the 'Dhyana' CPU model with just CPUID_8000_0008_EBX_IBPB added.

Do we really need to support both CPU variants ?

Also, I think the compatibility properties are not needed for Dhyana chips.

Paolo

author
#3 lore raw
Quoted 9 lines · Paolo Bonzini
Quoted 6 lines · Daniel P. Berrangé
Quoted 4 lines

Add two new base CPU models called 'Dhyana' and 'Dhyana-IBPB' to model processors from Hygon Dhyana (family 18h), which derived from AMD EPYC (family 17h). 'Dhyana-IBPB' is a copy of the 'Dhyana' CPU model with just CPUID_8000_0008_EBX_IBPB added.

Do we really need to support both CPU variants ?

Also, I think the compatibility properties are not needed for Dhyana chips.

Will only keep one CPU model with IBPB feature by using the name 'Dhyana'.

Thx.

Signature · 2 lines
Regards,
Pu Wen
author
#4 lore raw
In reply to Daniel P. Berrangé
Quoted 5 lines · Daniel P. Berrangé
Quoted 4 lines · Pu Wen

Add two new base CPU models called 'Dhyana' and 'Dhyana-IBPB' to model processors from Hygon Dhyana (family 18h), which derived from AMD EPYC (family 17h). 'Dhyana-IBPB' is a copy of the 'Dhyana' CPU model with just CPUID_8000_0008_EBX_IBPB added.

...

Quoted 3 lines

The Google results I see suggest that Dhyana CPUs started to become available in July 2018, so surely they would come with microcode that has the IBPB right from day 1 ?

Yes, you are right. Dhyana CPUs already have the IBPB feature.

Quoted 4 lines

Am I missing anything that means there will be a compelling need to support Dhyana /without/ IBPB ?

If not, then we only need 1 CPU model and that would include IBPB.

Okay, will only keep one CPU model which include IBPB by using the name 'Dhyana'.

Thx.

Signature · 2 lines
Regards,
Pu Wen