Skip to content

Commit 01d1059

Browse files
committed
KVM: x86: Zero out PV features cache when the CPUID leaf is not present
Clear KVM's PV feature cache prior when processing a new guest CPUID so that KVM doesn't keep a stale cache entry if userspace does KVM_SET_CPUID2 multiple times, once with a PV features entry, and a second time without. Fixes: 66570e9 ("kvm: x86: only provide PV features if enabled in guest's CPUID") Cc: Oliver Upton <oliver.upton@linux.dev> Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> Reviewed-by: Binbin Wu <binbin.wu@linux.intel.com> Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com> Link: https://lore.kernel.org/r/20241128013424.4096668-19-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 59cb3ac commit 01d1059

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

arch/x86/kvm/cpuid.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,8 @@ void kvm_update_pv_runtime(struct kvm_vcpu *vcpu)
272272
{
273273
struct kvm_cpuid_entry2 *best = kvm_find_kvm_cpuid_features(vcpu);
274274

275+
vcpu->arch.pv_cpuid.features = 0;
276+
275277
/*
276278
* save the feature bitmap to avoid cpuid lookup for every PV
277279
* operation

0 commit comments

Comments
 (0)