All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix SSBD not being exposed to guests. (v1)
@ 2018-05-21 21:54 Konrad Rzeszutek Wilk
  2018-05-21 21:54 ` [PATCH] KVM: VMX: Expose SSBD properly to guests Konrad Rzeszutek Wilk
  0 siblings, 1 reply; 5+ messages in thread
From: Konrad Rzeszutek Wilk @ 2018-05-21 21:54 UTC (permalink / raw)
  To: x86, kvm, linux-kernel

Hi,

Without this patch, when launching QEMU with -cpu +ssbd I ended up
with a warning seeing that the CPU does not support - which in fact it does.

The issue was the X86_FEATURE_ -  the kvm_cpuid_7_0_edx_x86_features
had bit 17 set (X86_FEATURE_SSBD), while the right bit should have been
bit 31 ( X86_FEATURE_SPEC_CTRL_SSBD). That meant the masking:

	entry->edx &= kvm_cpuid_7_0_edx_x86_features;

would nicely clear the SSBD bit.

This fixes:
Fixes: 52817587e706 ("x86/cpufeatures: Disentangle SSBD enumeration")

 arch/x86/kvm/cpuid.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Konrad Rzeszutek Wilk (1):
      KVM: VMX: Expose SSBD properly to guests.

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

* [PATCH] KVM: VMX: Expose SSBD properly to guests.
  2018-05-21 21:54 [PATCH] Fix SSBD not being exposed to guests. (v1) Konrad Rzeszutek Wilk
@ 2018-05-21 21:54 ` Konrad Rzeszutek Wilk
  2018-05-22 23:50   ` Ben Hutchings
  2018-05-23  9:00   ` [tip:x86/pti] KVM/VMX: " tip-bot for Konrad Rzeszutek Wilk
  0 siblings, 2 replies; 5+ messages in thread
From: Konrad Rzeszutek Wilk @ 2018-05-21 21:54 UTC (permalink / raw)
  To: x86, kvm, linux-kernel
  Cc: Konrad Rzeszutek Wilk, Paolo Bonzini, Radim Krčmář,
	Thomas Gleixner, Ingo Molnar, H. Peter Anvin, stable

The X86_FEATURE_SSBD is an synthetic CPU feature - that is
it bit location has no relevance to the real CPUID 0x7.EBX[31]
bit position. For that we need the new CPU feature name.

Fixes: 52817587e706 ("x86/cpufeatures: Disentangle SSBD enumeration")

CC: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Radim Krčmář" <rkrcmar@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: stable@vger.kernel.org
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
 arch/x86/kvm/cpuid.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index ced851169730..598461e24be3 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -407,8 +407,8 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
 
 	/* cpuid 7.0.edx*/
 	const u32 kvm_cpuid_7_0_edx_x86_features =
-		F(AVX512_4VNNIW) | F(AVX512_4FMAPS) | F(SPEC_CTRL) | F(SSBD) |
-		F(ARCH_CAPABILITIES);
+		F(AVX512_4VNNIW) | F(AVX512_4FMAPS) | F(SPEC_CTRL) |
+		F(SPEC_CTRL_SSBD) | F(ARCH_CAPABILITIES);
 
 	/* all calls to cpuid_count() should be made on the same cpu */
 	get_cpu();
-- 
2.13.4

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

* Re: [PATCH] KVM: VMX: Expose SSBD properly to guests.
  2018-05-21 21:54 ` [PATCH] KVM: VMX: Expose SSBD properly to guests Konrad Rzeszutek Wilk
@ 2018-05-22 23:50   ` Ben Hutchings
  2018-06-07 13:14     ` Thomas Voegtle
  2018-05-23  9:00   ` [tip:x86/pti] KVM/VMX: " tip-bot for Konrad Rzeszutek Wilk
  1 sibling, 1 reply; 5+ messages in thread
From: Ben Hutchings @ 2018-05-22 23:50 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk, x86, kvm, linux-kernel
  Cc: Paolo Bonzini, Radim Krčmář,
	Thomas Gleixner, Ingo Molnar, H. Peter Anvin, stable

[-- Attachment #1: Type: text/plain, Size: 1550 bytes --]

On Mon, 2018-05-21 at 17:54 -0400, Konrad Rzeszutek Wilk wrote:
> The X86_FEATURE_SSBD is an synthetic CPU feature - that is
> it bit location has no relevance to the real CPUID 0x7.EBX[31]
> bit position. For that we need the new CPU feature name.
> 
> Fixes: 52817587e706 ("x86/cpufeatures: Disentangle SSBD enumeration")
> 
> CC: Paolo Bonzini <pbonzini@redhat.com>
> Cc: "Radim Krčmář" <rkrcmar@redhat.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: "H. Peter Anvin" <hpa@zytor.com>
> Cc: stable@vger.kernel.org
> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> ---
>  arch/x86/kvm/cpuid.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
> index ced851169730..598461e24be3 100644
> --- a/arch/x86/kvm/cpuid.c
> +++ b/arch/x86/kvm/cpuid.c
> @@ -407,8 +407,8 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
>  
>  	/* cpuid 7.0.edx*/
>  	const u32 kvm_cpuid_7_0_edx_x86_features =
> -		F(AVX512_4VNNIW) | F(AVX512_4FMAPS) | F(SPEC_CTRL) | F(SSBD) |
> -		F(ARCH_CAPABILITIES);
> +		F(AVX512_4VNNIW) | F(AVX512_4FMAPS) | F(SPEC_CTRL) |
> +		F(SPEC_CTRL_SSBD) | F(ARCH_CAPABILITIES);
>  
>  	/* all calls to cpuid_count() should be made on the same cpu */
>  	get_cpu();

For 4.9-stable, guest_cpuid_has_spec_ctrl() needs a similar fix.

Ben.

-- 
Ben Hutchings
It is easier to change the specification to fit the program
than vice versa.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* [tip:x86/pti] KVM/VMX: Expose SSBD properly to guests
  2018-05-21 21:54 ` [PATCH] KVM: VMX: Expose SSBD properly to guests Konrad Rzeszutek Wilk
  2018-05-22 23:50   ` Ben Hutchings
@ 2018-05-23  9:00   ` tip-bot for Konrad Rzeszutek Wilk
  1 sibling, 0 replies; 5+ messages in thread
From: tip-bot for Konrad Rzeszutek Wilk @ 2018-05-23  9:00 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, rkrcmar, konrad.wilk, linux-kernel, tglx, mingo, pbonzini

Commit-ID:  0aa48468d00959c8a37cd3ac727284f4f7359151
Gitweb:     https://git.kernel.org/tip/0aa48468d00959c8a37cd3ac727284f4f7359151
Author:     Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
AuthorDate: Mon, 21 May 2018 17:54:49 -0400
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Wed, 23 May 2018 10:55:52 +0200

KVM/VMX: Expose SSBD properly to guests

The X86_FEATURE_SSBD is an synthetic CPU feature - that is
it bit location has no relevance to the real CPUID 0x7.EBX[31]
bit position. For that we need the new CPU feature name.

Fixes: 52817587e706 ("x86/cpufeatures: Disentangle SSBD enumeration")
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: kvm@vger.kernel.org
Cc: "Radim Krčmář" <rkrcmar@redhat.com>
Cc: stable@vger.kernel.org
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Link: https://lkml.kernel.org/r/20180521215449.26423-2-konrad.wilk@oracle.com

---
 arch/x86/kvm/cpuid.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index ced851169730..598461e24be3 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -407,8 +407,8 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
 
 	/* cpuid 7.0.edx*/
 	const u32 kvm_cpuid_7_0_edx_x86_features =
-		F(AVX512_4VNNIW) | F(AVX512_4FMAPS) | F(SPEC_CTRL) | F(SSBD) |
-		F(ARCH_CAPABILITIES);
+		F(AVX512_4VNNIW) | F(AVX512_4FMAPS) | F(SPEC_CTRL) |
+		F(SPEC_CTRL_SSBD) | F(ARCH_CAPABILITIES);
 
 	/* all calls to cpuid_count() should be made on the same cpu */
 	get_cpu();

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

* Re: [PATCH] KVM: VMX: Expose SSBD properly to guests.
  2018-05-22 23:50   ` Ben Hutchings
@ 2018-06-07 13:14     ` Thomas Voegtle
  0 siblings, 0 replies; 5+ messages in thread
From: Thomas Voegtle @ 2018-06-07 13:14 UTC (permalink / raw)
  To: Ben Hutchings
  Cc: Konrad Rzeszutek Wilk, x86, kvm, linux-kernel, Paolo Bonzini,
	Radim Krčmář,
	Thomas Gleixner, Ingo Molnar, H. Peter Anvin, stable

[-- Attachment #1: Type: text/plain, Size: 2086 bytes --]

On Wed, 23 May 2018, Ben Hutchings wrote:

> On Mon, 2018-05-21 at 17:54 -0400, Konrad Rzeszutek Wilk wrote:
>> The X86_FEATURE_SSBD is an synthetic CPU feature - that is
>> it bit location has no relevance to the real CPUID 0x7.EBX[31]
>> bit position. For that we need the new CPU feature name.
>>
>> Fixes: 52817587e706 ("x86/cpufeatures: Disentangle SSBD enumeration")
>>
>> CC: Paolo Bonzini <pbonzini@redhat.com>
>> Cc: "Radim Krčmář" <rkrcmar@redhat.com>
>> Cc: Thomas Gleixner <tglx@linutronix.de>
>> Cc: Ingo Molnar <mingo@redhat.com>
>> Cc: "H. Peter Anvin" <hpa@zytor.com>
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
>> ---
>>  arch/x86/kvm/cpuid.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
>> index ced851169730..598461e24be3 100644
>> --- a/arch/x86/kvm/cpuid.c
>> +++ b/arch/x86/kvm/cpuid.c
>> @@ -407,8 +407,8 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
>>
>>  	/* cpuid 7.0.edx*/
>>  	const u32 kvm_cpuid_7_0_edx_x86_features =
>> -		F(AVX512_4VNNIW) | F(AVX512_4FMAPS) | F(SPEC_CTRL) | F(SSBD) |
>> -		F(ARCH_CAPABILITIES);
>> +		F(AVX512_4VNNIW) | F(AVX512_4FMAPS) | F(SPEC_CTRL) |
>> +		F(SPEC_CTRL_SSBD) | F(ARCH_CAPABILITIES);
>>
>>  	/* all calls to cpuid_count() should be made on the same cpu */
>>  	get_cpu();
>
> For 4.9-stable, guest_cpuid_has_spec_ctrl() needs a similar fix.
>
> Ben.

Do you mean something like this?

--- a/arch/x86/kvm/cpuid.h
+++ b/arch/x86/kvm/cpuid.h
@@ -179,7 +179,7 @@ static inline bool guest_cpuid_has_spec_ctrl(struct 
kvm_vcpu *vcpu)
         if (best && (best->ebx & bit(X86_FEATURE_AMD_IBRS)))
                 return true;
         best = kvm_find_cpuid_entry(vcpu, 7, 0);
-       return best && (best->edx & (bit(X86_FEATURE_SPEC_CTRL) | 
bit(X86_FEATURE_SSBD)));
+       return best && (best->edx & (bit(X86_FEATURE_SPEC_CTRL) | 
bit(X86_FEATURE_SPEC_CTRL_SSBD)));
  }

  static inline bool guest_cpuid_has_arch_capabilities(struct kvm_vcpu 
*vcpu)

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

end of thread, other threads:[~2018-06-07 13:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-21 21:54 [PATCH] Fix SSBD not being exposed to guests. (v1) Konrad Rzeszutek Wilk
2018-05-21 21:54 ` [PATCH] KVM: VMX: Expose SSBD properly to guests Konrad Rzeszutek Wilk
2018-05-22 23:50   ` Ben Hutchings
2018-06-07 13:14     ` Thomas Voegtle
2018-05-23  9:00   ` [tip:x86/pti] KVM/VMX: " tip-bot for Konrad Rzeszutek Wilk

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.