]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: x86: Unconditionally set l1tf_flush_l1d during vCPU load
authorSean Christopherson <seanjc@google.com>
Wed, 22 May 2024 01:40:12 +0000 (18:40 -0700)
committerSean Christopherson <seanjc@google.com>
Tue, 11 Jun 2024 21:18:46 +0000 (14:18 -0700)
Always set l1tf_flush_l1d during kvm_arch_vcpu_load() instead of setting
it only when the vCPU is being scheduled back in.  The flag is processed
only when VM-Enter is imminent, and KVM obviously needs to load the vCPU
before VM-Enter, so attempting to precisely set l1tf_flush_l1d provides no
meaningful value.  I.e. the flag _will_ be set either way, it's simply a
matter of when.

Acked-by: Kai Huang <kai.huang@intel.com>
Link: https://lore.kernel.org/r/20240522014013.1672962-6-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/x86.c

index 6830cd389fc2cb56f28c2b6ea9c99c76c5aa595a..1f3b21fb4add2b71fb4f60fa53a2a1de32abbea0 100644 (file)
@@ -5006,12 +5006,11 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
 {
        struct kvm_pmu *pmu = vcpu_to_pmu(vcpu);
 
-       if (vcpu->scheduled_out) {
-               vcpu->arch.l1tf_flush_l1d = true;
-               if (pmu->version && unlikely(pmu->event_count)) {
-                       pmu->need_cleanup = true;
-                       kvm_make_request(KVM_REQ_PMU, vcpu);
-               }
+       vcpu->arch.l1tf_flush_l1d = true;
+
+       if (vcpu->scheduled_out && pmu->version && pmu->event_count) {
+               pmu->need_cleanup = true;
+               kvm_make_request(KVM_REQ_PMU, vcpu);
        }
 
        /* Address WBINVD may be executed by guest */