Skip to contentSkip to conversation

KVM: CPUID: Add new features to the guest's CPUID

PATCH In review Aaron Lewis 2 participants 4 messages Jul 15, 2019 – Aug 21, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: CPUID: Add new features to the guest's CPUID

Add features X86_FEATURE_FDP_EXCPTN_ONLY and X86_FEATURE_ZERO_FCS_FDS to the mask for CPUID.(EAX=07H,ECX=0H):EBX. Doing this will ensure the guest's CPUID for these bits match the host, rather than the guest being blindly set to 0.

This is important as these are actually defeature bits, which means that a 0 indicates the presence of a feature and a 1 indicates the absence of a feature. since these features cannot be emulated, kvm should not claim the existence of a feature that isn't present on the host.

---
 arch/x86/kvm/cpuid.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kvm/cpuid.c +2 -1
index ead681210306..64c3fad068e1 100644
@@ -353,7 +353,8 @@ static inline void do_cpuid_7_mask(struct kvm_cpuid_entry2 *entry, int index)
 		F(BMI2) | F(ERMS) | f_invpcid | F(RTM) | f_mpx | F(RDSEED) |
 		F(ADX) | F(SMAP) | F(AVX512IFMA) | F(AVX512F) | F(AVX512PF) |
 		F(AVX512ER) | F(AVX512CD) | F(CLFLUSHOPT) | F(CLWB) | F(AVX512DQ) |
-		F(SHA_NI) | F(AVX512BW) | F(AVX512VL) | f_intel_pt;
+		F(SHA_NI) | F(AVX512BW) | F(AVX512VL) | f_intel_pt |
+		F(FDP_EXCPTN_ONLY) | F(ZERO_FCS_FDS);
 
 	/* cpuid 7.0.ecx*/
 	const u32 kvm_cpuid_7_0_ecx_x86_features =
Signature · 1 line
2.22.0.510.g264f2c817a-goog
#1 lore raw
Quoted 30 lines · Aaron Lewis

Add features X86_FEATURE_FDP_EXCPTN_ONLY and X86_FEATURE_ZERO_FCS_FDS to the mask for CPUID.(EAX=07H,ECX=0H):EBX. Doing this will ensure the guest's CPUID for these bits match the host, rather than the guest being blindly set to 0.

This is important as these are actually defeature bits, which means that a 0 indicates the presence of a feature and a 1 indicates the absence of a feature. since these features cannot be emulated, kvm should not claim the existence of a feature that isn't present on the host.

---
 arch/x86/kvm/cpuid.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kvm/cpuid.c +2 -2
index ead681210306..64c3fad068e1 100644
@@ -353,7 +353,8 @@ static inline void do_cpuid_7_mask(struct kvm_cpuid_entry2 *entry, int index)
                F(BMI2) | F(ERMS) | f_invpcid | F(RTM) | f_mpx | F(RDSEED) |
                F(ADX) | F(SMAP) | F(AVX512IFMA) | F(AVX512F) | F(AVX512PF) |
                F(AVX512ER) | F(AVX512CD) | F(CLFLUSHOPT) | F(CLWB) | F(AVX512DQ) |
-               F(SHA_NI) | F(AVX512BW) | F(AVX512VL) | f_intel_pt;
+               F(SHA_NI) | F(AVX512BW) | F(AVX512VL) | f_intel_pt |
+               F(FDP_EXCPTN_ONLY) | F(ZERO_FCS_FDS);
 
        /* cpuid 7.0.ecx*/
        const u32 kvm_cpuid_7_0_ecx_x86_features =
--
Quoted 2 lines

2.22.0.510.g264f2c817a-goog

ping

Reviewed-by on v1 1/1
#2 lore raw
In reply to Aaron Lewis
Quoted 19 lines · Aaron Lewis

Add features X86_FEATURE_FDP_EXCPTN_ONLY and X86_FEATURE_ZERO_FCS_FDS to the mask for CPUID.(EAX=07H,ECX=0H):EBX. Doing this will ensure the guest's CPUID for these bits match the host, rather than the guest being blindly set to 0.

This is important as these are actually defeature bits, which means that a 0 indicates the presence of a feature and a 1 indicates the absence of a feature. since these features cannot be emulated, kvm should not claim the existence of a feature that isn't present on the host.

---
  arch/x86/kvm/cpuid.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kvm/cpuid.c +0 -0
index ead681210306..64c3fad068e1 100644

arch/x86/kvm/cpuid.c static inline void do_cpuid_7_mask(struct kvm_cpuid_entry2 *entry, int index) · line 360

Quoted 9 lines
arch/x86/kvm/cpuid.c +2 -1
@@ -353,7 +353,8 @@ static inline void do_cpuid_7_mask(struct kvm_cpuid_entry2 *entry, int index)
  		F(BMI2) | F(ERMS) | f_invpcid | F(RTM) | f_mpx | F(RDSEED) |
  		F(ADX) | F(SMAP) | F(AVX512IFMA) | F(AVX512F) | F(AVX512PF) |
  		F(AVX512ER) | F(AVX512CD) | F(CLFLUSHOPT) | F(CLWB) | F(AVX512DQ) |
-		F(SHA_NI) | F(AVX512BW) | F(AVX512VL) | f_intel_pt;
+		F(SHA_NI) | F(AVX512BW) | F(AVX512VL) | f_intel_pt |
+		F(FDP_EXCPTN_ONLY) | F(ZERO_FCS_FDS);
 
  	/* cpuid 7.0.ecx*/
  	const u32 kvm_cpuid_7_0_ecx_x86_features =
#3 lore raw
Quoted 31 lines · Krish Sadhukhan
Quoted 27 lines · Aaron Lewis

Add features X86_FEATURE_FDP_EXCPTN_ONLY and X86_FEATURE_ZERO_FCS_FDS to the mask for CPUID.(EAX=07H,ECX=0H):EBX. Doing this will ensure the guest's CPUID for these bits match the host, rather than the guest being blindly set to 0.

This is important as these are actually defeature bits, which means that a 0 indicates the presence of a feature and a 1 indicates the absence of a feature. since these features cannot be emulated, kvm should not claim the existence of a feature that isn't present on the host.

---
  arch/x86/kvm/cpuid.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kvm/cpuid.c +2 -1
index ead681210306..64c3fad068e1 100644
@@ -353,7 +353,8 @@ static inline void do_cpuid_7_mask(struct kvm_cpuid_entry2 *entry, int index)
              F(BMI2) | F(ERMS) | f_invpcid | F(RTM) | f_mpx | F(RDSEED) |
              F(ADX) | F(SMAP) | F(AVX512IFMA) | F(AVX512F) | F(AVX512PF) |
              F(AVX512ER) | F(AVX512CD) | F(CLFLUSHOPT) | F(CLWB) | F(AVX512DQ) |
-             F(SHA_NI) | F(AVX512BW) | F(AVX512VL) | f_intel_pt;
+             F(SHA_NI) | F(AVX512BW) | F(AVX512VL) | f_intel_pt |
+             F(FDP_EXCPTN_ONLY) | F(ZERO_FCS_FDS);
 
Quoted 4 lines

arch/x86/kvm/cpuid.c static inline void do_cpuid_7_mask(struct kvm_cpuid_entry2 *entry, int index) · line 360

Quoted 2 lines
arch/x86/kvm/cpuid.c +0 -0
      /* cpuid 7.0.ecx*/
      const u32 kvm_cpuid_7_0_ecx_x86_features =

ping