[PATCH 03/11] KVM: selftests: Mask off OSPKE and OSXSAVE when comparing CPUID entries

Sean Christopherson posted 11 patches 1 month, 3 weeks ago
[PATCH 03/11] KVM: selftests: Mask off OSPKE and OSXSAVE when comparing CPUID entries
Posted by Sean Christopherson 1 month, 3 weeks ago
Mask off OSPKE and OSXSAVE, which are toggled based on corresponding CR4
enabling bits, when comparing vCPU CPUID against KVM's supported CPUID.
This will allow setting OSXSAVE by default when creating vCPUs, without
causing test failures (KVM doesn't enumerate OSXSAVE=1).

Signed-off-by: Sean Christopherson <seanjc@google.com>
---
 tools/testing/selftests/kvm/x86_64/cpuid_test.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tools/testing/selftests/kvm/x86_64/cpuid_test.c b/tools/testing/selftests/kvm/x86_64/cpuid_test.c
index f7fdcef5fa59..7b3fda6842bc 100644
--- a/tools/testing/selftests/kvm/x86_64/cpuid_test.c
+++ b/tools/testing/selftests/kvm/x86_64/cpuid_test.c
@@ -62,6 +62,12 @@ static struct cpuid_mask get_const_cpuid_mask(const struct kvm_cpuid_entry2 *ent
 	memset(&mask, 0xff, sizeof(mask));
 
 	switch (entry->function) {
+	case 0x1:
+		mask.regs[X86_FEATURE_OSXSAVE.reg] &= ~BIT(X86_FEATURE_OSXSAVE.bit);
+		break;
+	case 0x7:
+		mask.regs[X86_FEATURE_OSPKE.reg] &= ~BIT(X86_FEATURE_OSPKE.bit);
+		break;
 	case 0xd:
 		/*
 		 * CPUID.0xD.{0,1}.EBX enumerate XSAVE size based on the current
-- 
2.47.0.rc0.187.ge670bccf7e-goog
Re: [PATCH 03/11] KVM: selftests: Mask off OSPKE and OSXSAVE when comparing CPUID entries
Posted by Vitaly Kuznetsov 1 month, 3 weeks ago
Sean Christopherson <seanjc@google.com> writes:

> Mask off OSPKE and OSXSAVE, which are toggled based on corresponding CR4
> enabling bits, when comparing vCPU CPUID against KVM's supported CPUID.
> This will allow setting OSXSAVE by default when creating vCPUs, without
> causing test failures (KVM doesn't enumerate OSXSAVE=1).
>
> Signed-off-by: Sean Christopherson <seanjc@google.com>
> ---
>  tools/testing/selftests/kvm/x86_64/cpuid_test.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/tools/testing/selftests/kvm/x86_64/cpuid_test.c b/tools/testing/selftests/kvm/x86_64/cpuid_test.c
> index f7fdcef5fa59..7b3fda6842bc 100644
> --- a/tools/testing/selftests/kvm/x86_64/cpuid_test.c
> +++ b/tools/testing/selftests/kvm/x86_64/cpuid_test.c
> @@ -62,6 +62,12 @@ static struct cpuid_mask get_const_cpuid_mask(const struct kvm_cpuid_entry2 *ent
>  	memset(&mask, 0xff, sizeof(mask));
>  
>  	switch (entry->function) {
> +	case 0x1:
> +		mask.regs[X86_FEATURE_OSXSAVE.reg] &= ~BIT(X86_FEATURE_OSXSAVE.bit);
> +		break;
> +	case 0x7:
> +		mask.regs[X86_FEATURE_OSPKE.reg] &= ~BIT(X86_FEATURE_OSPKE.bit);
> +		break;
>  	case 0xd:
>  		/*
>  		 * CPUID.0xD.{0,1}.EBX enumerate XSAVE size based on the current

Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>

-- 
Vitaly