]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
KVM: selftests: Refresh vCPU CPUID cache in __vcpu_get_cpuid_entry()
authorSean Christopherson <seanjc@google.com>
Thu, 28 Nov 2024 01:33:35 +0000 (17:33 -0800)
committerSean Christopherson <seanjc@google.com>
Wed, 18 Dec 2024 22:19:29 +0000 (14:19 -0800)
commita2a791e8208623b1575f21c7ec559df095c0a96e
tree99340378928ab30be9a5d27640a4817477c6779c
parent08833719e77041e331f6193878f1b944744b9068
KVM: selftests: Refresh vCPU CPUID cache in __vcpu_get_cpuid_entry()

Refresh selftests' CPUID cache in the vCPU structure when querying a CPUID
entry so that tests don't consume stale data when KVM modifies CPUID as a
side effect to a completely unrelated change.  E.g. KVM adjusts OSXSAVE in
response to CR4.OSXSAVE changes.

Unnecessarily invoking KVM_GET_CPUID is suboptimal, but vcpu->cpuid exists
to simplify selftests development, not for performance reasons.  And,
unfortunately, trying to handle the side effects in tests or other flows
is unpleasant, e.g. selftests could manually refresh if KVM_SET_SREGS is
successful, but that would still leave a gap with respect to guest CR4
changes.

Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
Link: https://lore.kernel.org/r/20241128013424.4096668-9-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
tools/testing/selftests/kvm/include/x86/processor.h