OpenCloudOS-Kernel/arch/x86/kvm/svm
Jeremi Piotrowski e5c972c1fa KVM: SVM: Flush Hyper-V TLB when required
The Hyper-V "EnlightenedNptTlb" enlightenment is always enabled when KVM
is running on top of Hyper-V and Hyper-V exposes support for it (which
is always). On AMD CPUs this enlightenment results in ASID invalidations
not flushing TLB entries derived from the NPT. To force the underlying
(L0) hypervisor to rebuild its shadow page tables, an explicit hypercall
is needed.

The original KVM implementation of Hyper-V's "EnlightenedNptTlb" on SVM
only added remote TLB flush hooks. This worked out fine for a while, as
sufficient remote TLB flushes where being issued in KVM to mask the
problem. Since v5.17, changes in the TDP code reduced the number of
flushes and the out-of-sync TLB prevents guests from booting
successfully.

Split svm_flush_tlb_current() into separate callbacks for the 3 cases
(guest/all/current), and issue the required Hyper-V hypercall when a
Hyper-V TLB flush is needed. The most important case where the TLB flush
was missing is when loading a new PGD, which is followed by what is now
svm_flush_tlb_current().

Cc: stable@vger.kernel.org # v5.17+
Fixes: 1e0c7d4075 ("KVM: SVM: hyper-v: Remote TLB flush for SVM")
Link: https://lore.kernel.org/lkml/43980946-7bbf-dcef-7e40-af904c456250@linux.microsoft.com/
Suggested-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Jeremi Piotrowski <jpiotrowski@linux.microsoft.com>
Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Message-Id: <20230324145233.4585-1-jpiotrowski@linux.microsoft.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2023-03-27 10:10:26 -04:00
..
avic.c KVM: SVM: WARN if GATag generation drops VM or vCPU ID information 2023-03-14 10:20:07 -04:00
hyperv.c KVM: nSVM: hyper-v: Enable L2 TLB flush 2022-11-18 12:59:18 -05:00
hyperv.h KVM: nSVM: hyper-v: Enable L2 TLB flush 2022-11-18 12:59:18 -05:00
nested.c KVM: nSVM: Don't sync tlb_ctl back to vmcb12 on nested VM-Exit 2023-01-31 12:56:26 -08:00
pmu.c KVM: x86/pmu: Cap kvm_pmu_cap.num_counters_gp at KVM's internal max 2023-01-26 18:03:42 -08:00
sev.c KVM: SVM: Fix potential overflow in SEV's send|receive_update_data() 2023-02-07 14:36:45 -08:00
svm.c KVM: SVM: Flush Hyper-V TLB when required 2023-03-27 10:10:26 -04:00
svm.h KVM: x86: Move HF_NMI_MASK and HF_IRET_MASK into "struct vcpu_svm" 2023-01-31 12:56:42 -08:00
svm_onhyperv.c KVM: x86: Unify pr_fmt to use module name for all KVM modules 2022-12-29 15:47:35 -05:00
svm_onhyperv.h KVM: SVM: Flush Hyper-V TLB when required 2023-03-27 10:10:26 -04:00
svm_ops.h KVM: SVM: restore host save area from assembly 2022-11-09 12:25:33 -05:00
vmenter.S Linux 6.1-rc6 2022-11-21 23:01:51 +01:00