Skip to content

Commit 164cea3

Browse files
committed
KVM: selftests: Mask off OSPKE and OSXSAVE when comparing CPUID entries
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). Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com> Link: https://lore.kernel.org/r/20241003234337.273364-4-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent f2c5aa3 commit 164cea3

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tools/testing/selftests/kvm/x86_64/cpuid_test.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ static struct cpuid_mask get_const_cpuid_mask(const struct kvm_cpuid_entry2 *ent
6262
memset(&mask, 0xff, sizeof(mask));
6363

6464
switch (entry->function) {
65+
case 0x1:
66+
mask.regs[X86_FEATURE_OSXSAVE.reg] &= ~BIT(X86_FEATURE_OSXSAVE.bit);
67+
break;
68+
case 0x7:
69+
mask.regs[X86_FEATURE_OSPKE.reg] &= ~BIT(X86_FEATURE_OSPKE.bit);
70+
break;
6571
case 0xd:
6672
/*
6773
* CPUID.0xD.{0,1}.EBX enumerate XSAVE size based on the current

0 commit comments

Comments
 (0)