2024-04-11 14:45:10

by Zheyun Shen

[permalink] [raw]
Subject: [PATCH v4 0/2] KVM: SVM: Flush cache only on CPUs running SEV guest

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