public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/2] KVM: SVM: Flush cache only on CPUs running SEV guest
@ 2024-04-11 14:04 Zheyun Shen
  2024-04-11 14:04 ` [PATCH v4 1/2] KVM: x86: Add a wbinvd helper Zheyun Shen
  2024-04-11 14:04 ` [PATCH v4 2/2] KVM: SVM: Flush cache only on CPUs running SEV guest Zheyun Shen
  0 siblings, 2 replies; 8+ messages in thread
From: Zheyun Shen @ 2024-04-11 14:04 UTC (permalink / raw)
  To: thomas.lendacky, seanjc, pbonzini, tglx; +Cc: kvm, linux-kernel, Zheyun Shen

Previous versions pointed out the problem of wbinvd_on_all_cpus() in SEV
and tried to maintain a cpumask to solve it. However, recording the CPU
to mask before VMRUN and clearing the mask after reclamation is not
correct. If the next reclamation happens before VMEXIT and VMRUN, lack 
of record may lead to miss one wbinvd on this CPU.

---
v3 -> v4:
- Added a wbinvd helper and export it to SEV.
- Changed the struct cpumask in kvm_sev_info into cpumask*, which should
be dynamically allocated and freed.
- Changed the time of recording the CPUs from pre_sev_run() to vcpu_load().
- Removed code of clearing the mask.

v2 -> v3:
- Replaced get_cpu() with parameter cpu in pre_sev_run().

v1 -> v2:
- Added sev_do_wbinvd() to wrap two operations.
- Used cpumask_test_and_clear_cpu() to avoid concurrent problems.
---

Zheyun Shen (2):
  KVM: x86: Add a wbinvd helper
  KVM: SVM: Flush cache only on CPUs running SEV guest

 arch/x86/kvm/svm/sev.c | 48 ++++++++++++++++++++++++++++++++++++++----
 arch/x86/kvm/svm/svm.c |  2 ++
 arch/x86/kvm/svm/svm.h |  4 ++++
 arch/x86/kvm/x86.c     |  9 ++++++--
 arch/x86/kvm/x86.h     |  1 +
 5 files changed, 58 insertions(+), 6 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-01-17 22:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-11 14:04 [PATCH v4 0/2] KVM: SVM: Flush cache only on CPUs running SEV guest Zheyun Shen
2024-04-11 14:04 ` [PATCH v4 1/2] KVM: x86: Add a wbinvd helper Zheyun Shen
2024-04-11 14:04 ` [PATCH v4 2/2] KVM: SVM: Flush cache only on CPUs running SEV guest Zheyun Shen
2024-12-04  0:27   ` Sean Christopherson
2024-12-04 19:33     ` Kevin Loughlin
2024-12-04 22:06       ` Sean Christopherson
2024-12-10 23:56         ` Kevin Loughlin
2025-01-17 22:33           ` Kevin Loughlin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox