Skip to contentSkip to conversation

KVM: x86: Advertise that the SMM_CTL MSR is not supported

PATCH Applied Jim Mattson 3 participants 6 messages Oct 7, 2022 – Dec 2, 2022

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

PATCH 1/1 KVM: x86: Advertise that the SMM_CTL MSR is not supported

CPUID.80000021H:EAX[bit 9] indicates that the SMM_CTL MSR (0xc0010116) is not supported. This defeature can be advertised by KVM_GET_SUPPORTED_CPUID regardless of whether or not the host enumerates it.

---
 arch/x86/kvm/cpuid.c | 4 ++++
 1 file changed, 4 insertions(+)
arch/x86/kvm/cpuid.c +4 -0
index 2796dde06302..b748fac2ae37 100644
@@ -1199,8 +1199,12 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
 		 * Other defined bits are for MSRs that KVM does not expose:
 		 *   EAX      3      SPCL, SMM page configuration lock
 		 *   EAX      13     PCMSR, Prefetch control MSR
+		 *
+		 * KVM doesn't support SMM_CTL.
+		 *   EAX       9     SMM_CTL MSR is not supported
 		 */
 		entry->eax &= BIT(0) | BIT(2) | BIT(6);
+		entry->eax |= BIT(9);
 		if (static_cpu_has(X86_FEATURE_LFENCE_RDTSC))
 			entry->eax |= BIT(2);
 		if (!static_cpu_has_bug(X86_BUG_NULL_SEG))
Signature · 1 line
2.38.0.rc1.362.ged0d419d3c-goog
#1 lore raw
Quoted 4 lines · Jim Mattson

CPUID.80000021H:EAX[bit 9] indicates that the SMM_CTL MSR (0xc0010116) is not supported. This defeature can be advertised by KVM_GET_SUPPORTED_CPUID regardless of whether or not the host enumerates it.

Might be worth noting that KVM will only enumerate the bit if the host happens to have a max extend leaf > 80000021.

Quoted 11 lines
---
 arch/x86/kvm/cpuid.c | 4 ++++
 1 file changed, 4 insertions(+)
arch/x86/kvm/cpuid.c +0 -0
index 2796dde06302..b748fac2ae37 100644

arch/x86/kvm/cpuid.c static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function) · line 1206

Quoted 8 lines
arch/x86/kvm/cpuid.c +3 -0
@@ -1199,8 +1199,12 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
 		 * Other defined bits are for MSRs that KVM does not expose:
 		 *   EAX      3      SPCL, SMM page configuration lock
 		 *   EAX      13     PCMSR, Prefetch control MSR
+		 *
+		 * KVM doesn't support SMM_CTL.
+		 *   EAX       9     SMM_CTL MSR is not supported
 		 */
 		entry->eax &= BIT(0) | BIT(2) | BIT(6);

I don't suppose I can bribe you to add a kvm_only_cpuid_leafs entry for these? :-)

Quoted 7 lines
arch/x86/kvm/cpuid.c +1 -0
+		entry->eax |= BIT(9);
 		if (static_cpu_has(X86_FEATURE_LFENCE_RDTSC))
 			entry->eax |= BIT(2);
 		if (!static_cpu_has_bug(X86_BUG_NULL_SEG))
Signature · 1 line
2.38.0.rc1.362.ged0d419d3c-goog
#2 lore raw
Quoted 14 lines · Sean Christopherson
Quoted 4 lines · Jim Mattson

CPUID.80000021H:EAX[bit 9] indicates that the SMM_CTL MSR (0xc0010116) is not supported. This defeature can be advertised by KVM_GET_SUPPORTED_CPUID regardless of whether or not the host enumerates it.

Might be worth noting that KVM will only enumerate the bit if the host happens to have a max extend leaf > 80000021.

Quoted 6 lines
---
 arch/x86/kvm/cpuid.c | 4 ++++
 1 file changed, 4 insertions(+)
Quoted 15 lines

arch/x86/kvm/cpuid.c static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function) · line 1206

Quoted 13 lines
arch/x86/kvm/cpuid.c +3 -0
index 2796dde06302..b748fac2ae37 100644
@@ -1199,8 +1199,12 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
 		 * Other defined bits are for MSRs that KVM does not expose:
 		 *   EAX      3      SPCL, SMM page configuration lock
 		 *   EAX      13     PCMSR, Prefetch control MSR
+		 *
+		 * KVM doesn't support SMM_CTL.
+		 *   EAX       9     SMM_CTL MSR is not supported
 		 */
 		entry->eax &= BIT(0) | BIT(2) | BIT(6);

I don't suppose I can bribe you to add a kvm_only_cpuid_leafs entry for these? :-)

Ha! Someone else must have heard me whining :-)

https://lore.kernel.org/all/[email protected]

maintainer
#3 lore raw
In reply to Sean Christopherson
Quoted 6 lines · Sean Christopherson
Quoted 4 lines

CPUID.80000021H:EAX[bit 9] indicates that the SMM_CTL MSR (0xc0010116) is not supported. This defeature can be advertised by KVM_GET_SUPPORTED_CPUID regardless of whether or not the host enumerates it.

Might be worth noting that KVM will only enumerate the bit if the host happens to have a max extend leaf > 80000021.

Actually 0x8000001d, because 0x80000021 is a synthetic leaf (the only one of its kind). Unfortunately we cannot synthesize 0x80000021 unconditionally due to a preexisting bug in QEMU. :(

Paolo

maintainer Applied
#4 lore raw
In reply to Jim Mattson
Quoted 17 lines · Jim Mattson

CPUID.80000021H:EAX[bit 9] indicates that the SMM_CTL MSR (0xc0010116) is not supported. This defeature can be advertised by KVM_GET_SUPPORTED_CPUID regardless of whether or not the host enumerates it.

---
  arch/x86/kvm/cpuid.c | 4 ++++
  1 file changed, 4 insertions(+)
arch/x86/kvm/cpuid.c +0 -0
index 2796dde06302..b748fac2ae37 100644
@@ -1199,8 +1199,12 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
  		 * Other defined bits are for MSRs that KVM does not expose:
  		 *   EAX      3      SPCL, SMM page configuration lock

arch/x86/kvm/cpuid.c static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function) · line 1210

Quoted 10 lines
arch/x86/kvm/cpuid.c +4 -0
  		 *   EAX      13     PCMSR, Prefetch control MSR
+		 *
+		 * KVM doesn't support SMM_CTL.
+		 *   EAX       9     SMM_CTL MSR is not supported
  		 */
  		entry->eax &= BIT(0) | BIT(2) | BIT(6);
+		entry->eax |= BIT(9);
  		if (static_cpu_has(X86_FEATURE_LFENCE_RDTSC))
  			entry->eax |= BIT(2);
  		if (!static_cpu_has_bug(X86_BUG_NULL_SEG))

Queued, thanks. Negative features suck, though.

Paolo

#5 lore raw
Quoted 22 lines · Paolo Bonzini
Quoted 21 lines · Jim Mattson

CPUID.80000021H:EAX[bit 9] indicates that the SMM_CTL MSR (0xc0010116) is not supported. This defeature can be advertised by KVM_GET_SUPPORTED_CPUID regardless of whether or not the host enumerates it.

---
  arch/x86/kvm/cpuid.c | 4 ++++
  1 file changed, 4 insertions(+)
arch/x86/kvm/cpuid.c +3 -0
index 2796dde06302..b748fac2ae37 100644
@@ -1199,8 +1199,12 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
  		 * Other defined bits are for MSRs that KVM does not expose:
  		 *   EAX      3      SPCL, SMM page configuration lock
  		 *   EAX      13     PCMSR, Prefetch control MSR
+		 *
+		 * KVM doesn't support SMM_CTL.
+		 *   EAX       9     SMM_CTL MSR is not supported
Quoted 8 lines

arch/x86/kvm/cpuid.c static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function) · line 1210

Quoted 6 lines
arch/x86/kvm/cpuid.c +1 -0
  		 */
  		entry->eax &= BIT(0) | BIT(2) | BIT(6);
+		entry->eax |= BIT(9);
  		if (static_cpu_has(X86_FEATURE_LFENCE_RDTSC))
  			entry->eax |= BIT(2);
  		if (!static_cpu_has_bug(X86_BUG_NULL_SEG))

Queued, thanks. Negative features suck, though.

LOL, you and Jim should start a club, Jim's had a few good rants on negative features :-)