kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: CPUID: Add new features to the guest's CPUID
@ 2019-07-15 21:03 Aaron Lewis
  2019-07-22 14:51 ` Aaron Lewis
  2019-07-23 21:42 ` Krish Sadhukhan
  0 siblings, 2 replies; 4+ messages in thread
From: Aaron Lewis @ 2019-07-15 21:03 UTC (permalink / raw)
  To: jmattson, kvm; +Cc: 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.

Signed-off-by: Aaron Lewis <aaronlewis@google.com>
---
 arch/x86/kvm/cpuid.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index ead681210306..64c3fad068e1 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -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 =
-- 
2.22.0.510.g264f2c817a-goog


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

* Re: [PATCH] KVM: CPUID: Add new features to the guest's CPUID
  2019-07-15 21:03 [PATCH] KVM: CPUID: Add new features to the guest's CPUID Aaron Lewis
@ 2019-07-22 14:51 ` Aaron Lewis
  2019-07-23 21:42 ` Krish Sadhukhan
  1 sibling, 0 replies; 4+ messages in thread
From: Aaron Lewis @ 2019-07-22 14:51 UTC (permalink / raw)
  To: Jim Mattson, kvm

On Mon, Jul 15, 2019 at 2:03 PM Aaron Lewis <aaronlewis@google.com> wrote:
>
> 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.
>
> Signed-off-by: Aaron Lewis <aaronlewis@google.com>
> ---
>  arch/x86/kvm/cpuid.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
> index ead681210306..64c3fad068e1 100644
> --- a/arch/x86/kvm/cpuid.c
> +++ b/arch/x86/kvm/cpuid.c
> @@ -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 =
> --
> 2.22.0.510.g264f2c817a-goog
>

ping

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

* Re: [PATCH] KVM: CPUID: Add new features to the guest's CPUID
  2019-07-15 21:03 [PATCH] KVM: CPUID: Add new features to the guest's CPUID Aaron Lewis
  2019-07-22 14:51 ` Aaron Lewis
@ 2019-07-23 21:42 ` Krish Sadhukhan
  2019-08-21 16:17   ` Aaron Lewis
  1 sibling, 1 reply; 4+ messages in thread
From: Krish Sadhukhan @ 2019-07-23 21:42 UTC (permalink / raw)
  To: Aaron Lewis, jmattson, kvm



On 07/15/2019 02:03 PM, Aaron Lewis wrote:
> 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.
>
> Signed-off-by: Aaron Lewis <aaronlewis@google.com>
> ---
>   arch/x86/kvm/cpuid.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
> index ead681210306..64c3fad068e1 100644
> --- a/arch/x86/kvm/cpuid.c
> +++ b/arch/x86/kvm/cpuid.c
> @@ -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 =

Reviewed-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>

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

* Re: [PATCH] KVM: CPUID: Add new features to the guest's CPUID
  2019-07-23 21:42 ` Krish Sadhukhan
@ 2019-08-21 16:17   ` Aaron Lewis
  0 siblings, 0 replies; 4+ messages in thread
From: Aaron Lewis @ 2019-08-21 16:17 UTC (permalink / raw)
  To: Krish Sadhukhan; +Cc: Jim Mattson, kvm

On Tue, Jul 23, 2019 at 2:42 PM Krish Sadhukhan
<krish.sadhukhan@oracle.com> wrote:
>
>
>
> On 07/15/2019 02:03 PM, Aaron Lewis wrote:
> > 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.
> >
> > Signed-off-by: Aaron Lewis <aaronlewis@google.com>
> > Reviewed-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>
> > ---
> >   arch/x86/kvm/cpuid.c | 3 ++-
> >   1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
> > index ead681210306..64c3fad068e1 100644
> > --- a/arch/x86/kvm/cpuid.c
> > +++ b/arch/x86/kvm/cpuid.c
> > @@ -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 =
>
> Reviewed-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>

ping

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

end of thread, other threads:[~2019-08-21 16:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-15 21:03 [PATCH] KVM: CPUID: Add new features to the guest's CPUID Aaron Lewis
2019-07-22 14:51 ` Aaron Lewis
2019-07-23 21:42 ` Krish Sadhukhan
2019-08-21 16:17   ` Aaron Lewis

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).