kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: x86: Advertise that the SMM_CTL MSR is not supported
@ 2022-10-07 22:16 Jim Mattson
  2022-10-07 22:27 ` Sean Christopherson
  2022-12-02 18:50 ` Paolo Bonzini
  0 siblings, 2 replies; 6+ messages in thread
From: Jim Mattson @ 2022-10-07 22:16 UTC (permalink / raw)
  To: kvm, pbonzini, seanjc; +Cc: 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.

Signed-off-by: Jim Mattson <jmattson@google.com>
---
 arch/x86/kvm/cpuid.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 2796dde06302..b748fac2ae37 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -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))
-- 
2.38.0.rc1.362.ged0d419d3c-goog


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] KVM: x86: Advertise that the SMM_CTL MSR is not supported
  2022-10-07 22:16 [PATCH] KVM: x86: Advertise that the SMM_CTL MSR is not supported Jim Mattson
@ 2022-10-07 22:27 ` Sean Christopherson
  2022-12-01  0:08   ` Sean Christopherson
  2022-12-02 18:45   ` Paolo Bonzini
  2022-12-02 18:50 ` Paolo Bonzini
  1 sibling, 2 replies; 6+ messages in thread
From: Sean Christopherson @ 2022-10-07 22:27 UTC (permalink / raw)
  To: Jim Mattson; +Cc: kvm, pbonzini

On Fri, Oct 07, 2022, Jim Mattson wrote:
> 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.
> 
> Signed-off-by: Jim Mattson <jmattson@google.com>
> ---
>  arch/x86/kvm/cpuid.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
> index 2796dde06302..b748fac2ae37 100644
> --- a/arch/x86/kvm/cpuid.c
> +++ b/arch/x86/kvm/cpuid.c
> @@ -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? :-)

> +		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))
> -- 
> 2.38.0.rc1.362.ged0d419d3c-goog
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] KVM: x86: Advertise that the SMM_CTL MSR is not supported
  2022-10-07 22:27 ` Sean Christopherson
@ 2022-12-01  0:08   ` Sean Christopherson
  2022-12-02 18:45   ` Paolo Bonzini
  1 sibling, 0 replies; 6+ messages in thread
From: Sean Christopherson @ 2022-12-01  0:08 UTC (permalink / raw)
  To: Jim Mattson; +Cc: kvm, pbonzini

On Fri, Oct 07, 2022, Sean Christopherson wrote:
> On Fri, Oct 07, 2022, Jim Mattson wrote:
> > 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.
> > 
> > Signed-off-by: Jim Mattson <jmattson@google.com>
> > ---
> >  arch/x86/kvm/cpuid.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
> > index 2796dde06302..b748fac2ae37 100644
> > --- a/arch/x86/kvm/cpuid.c
> > +++ b/arch/x86/kvm/cpuid.c
> > @@ -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/20221129235816.188737-5-kim.phillips@amd.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] KVM: x86: Advertise that the SMM_CTL MSR is not supported
  2022-10-07 22:27 ` Sean Christopherson
  2022-12-01  0:08   ` Sean Christopherson
@ 2022-12-02 18:45   ` Paolo Bonzini
  1 sibling, 0 replies; 6+ messages in thread
From: Paolo Bonzini @ 2022-12-02 18:45 UTC (permalink / raw)
  To: Sean Christopherson, Jim Mattson; +Cc: kvm

On 10/8/22 00:27, Sean Christopherson wrote:
>> 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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] KVM: x86: Advertise that the SMM_CTL MSR is not supported
  2022-10-07 22:16 [PATCH] KVM: x86: Advertise that the SMM_CTL MSR is not supported Jim Mattson
  2022-10-07 22:27 ` Sean Christopherson
@ 2022-12-02 18:50 ` Paolo Bonzini
  2022-12-02 18:58   ` Sean Christopherson
  1 sibling, 1 reply; 6+ messages in thread
From: Paolo Bonzini @ 2022-12-02 18:50 UTC (permalink / raw)
  To: Jim Mattson, kvm, seanjc

On 10/8/22 00:16, Jim Mattson wrote:
> 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.
> 
> Signed-off-by: Jim Mattson <jmattson@google.com>
> ---
>   arch/x86/kvm/cpuid.c | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
> index 2796dde06302..b748fac2ae37 100644
> --- a/arch/x86/kvm/cpuid.c
> +++ b/arch/x86/kvm/cpuid.c
> @@ -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))

Queued, thanks.  Negative features suck, though.

Paolo


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] KVM: x86: Advertise that the SMM_CTL MSR is not supported
  2022-12-02 18:50 ` Paolo Bonzini
@ 2022-12-02 18:58   ` Sean Christopherson
  0 siblings, 0 replies; 6+ messages in thread
From: Sean Christopherson @ 2022-12-02 18:58 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: Jim Mattson, kvm

On Fri, Dec 02, 2022, Paolo Bonzini wrote:
> On 10/8/22 00:16, Jim Mattson wrote:
> > 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.
> > 
> > Signed-off-by: Jim Mattson <jmattson@google.com>
> > ---
> >   arch/x86/kvm/cpuid.c | 4 ++++
> >   1 file changed, 4 insertions(+)
> > 
> > diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
> > index 2796dde06302..b748fac2ae37 100644
> > --- a/arch/x86/kvm/cpuid.c
> > +++ b/arch/x86/kvm/cpuid.c
> > @@ -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))
> 
> Queued, thanks.  Negative features suck, though.

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-12-02 18:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-07 22:16 [PATCH] KVM: x86: Advertise that the SMM_CTL MSR is not supported Jim Mattson
2022-10-07 22:27 ` Sean Christopherson
2022-12-01  0:08   ` Sean Christopherson
2022-12-02 18:45   ` Paolo Bonzini
2022-12-02 18:50 ` Paolo Bonzini
2022-12-02 18:58   ` Sean Christopherson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).