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

From: Vitaly Kuznetsov
Date: Fri Oct 04 2024 - 05:02:37 EST


Sean Christopherson <seanjc@xxxxxxxxxx> 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@xxxxxxxxxx>
> ---
> 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@xxxxxxxxxx>

--
Vitaly