kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 0/4] KVM: SEV: Limit cache flush operations in sev guest memory reclaim events
@ 2023-11-10  0:37 Jacky Li
  2023-11-10  0:37 ` [RFC PATCH 1/4] KVM: SEV: Drop wbinvd_on_all_cpus() as kvm mmu notifier would flush the cache Jacky Li
                   ` (4 more replies)
  0 siblings, 5 replies; 17+ messages in thread
From: Jacky Li @ 2023-11-10  0:37 UTC (permalink / raw)
  To: Sean Christpherson, Paolo Bonzini
  Cc: Ovidiu Panait, Liam Merwick, Ashish Kalra, David Rientjes,
	David Kaplan, Peter Gonda, Mingwei Zhang, kvm, Jacky Li

The cache flush operation in sev guest memory reclaim events was
originally introduced to prevent security issues due to cache
incoherence and untrusted VMM. However when this operation gets
triggered, it causes performance degradation to the whole machine.

This cache flush operation is performed in mmu_notifiers, in particular,
in the mmu_notifier_invalidate_range_start() function, unconditionally
on all guest memory regions. Although the intention was to flush
cache lines only when guest memory was deallocated, the excessive
invocations include many other cases where this flush is unnecessary.

This RFC proposes using the mmu notifier event to determine whether a
cache flush is needed. Specifically, only do the cache flush when the
address range is unmapped, cleared, released or migrated. A bitmap
module param is also introduced to provide flexibility when flush is
needed in more events or no flush is needed depending on the hardware
platform.

Note that the cache flush operation in memory reclamation only targets
SEV/SEV-ES platforms and no cache flush is needed in SEV-SNP VMs.
Therefore the patch series does not apply to the SEV-SNP context.

Jacky Li (4):
  KVM: SEV: Drop wbinvd_on_all_cpus() as kvm mmu notifier would flush
    the cache
  KVM: SEV: Plumb mmu_notifier_event into sev function
  KVM: SEV: Limit the call of WBINVDs based on the event type of mmu
    notifier
  KVM: SEV: Use a bitmap module param to decide whether a cache flush is
    needed during the guest memory reclaim

 arch/x86/include/asm/kvm_host.h |  3 +-
 arch/x86/kvm/svm/sev.c          | 62 ++++++++++++++++++++++++---------
 arch/x86/kvm/svm/svm.h          |  3 +-
 arch/x86/kvm/x86.c              |  5 +--
 include/linux/kvm_host.h        |  3 +-
 include/linux/mmu_notifier.h    |  4 +++
 virt/kvm/kvm_main.c             | 14 +++++---
 7 files changed, 68 insertions(+), 26 deletions(-)

-- 
2.43.0.rc0.421.g78406f8d94-goog


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

end of thread, other threads:[~2023-12-02  6:21 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-10  0:37 [RFC PATCH 0/4] KVM: SEV: Limit cache flush operations in sev guest memory reclaim events Jacky Li
2023-11-10  0:37 ` [RFC PATCH 1/4] KVM: SEV: Drop wbinvd_on_all_cpus() as kvm mmu notifier would flush the cache Jacky Li
2023-12-01 17:53   ` Sean Christopherson
2023-11-10  0:37 ` [RFC PATCH 2/4] KVM: SEV: Plumb mmu_notifier_event into sev function Jacky Li
2023-11-10  0:37 ` [RFC PATCH 3/4] KVM: SEV: Limit the call of WBINVDs based on the event type of mmu notifier Jacky Li
2023-11-10 18:52   ` Kalra, Ashish
2023-11-10  0:37 ` [RFC PATCH 4/4] KVM: SEV: Use a bitmap module param to decide whether a cache flush is needed during the guest memory reclaim Jacky Li
2023-12-01 18:00   ` Sean Christopherson
2023-12-01 18:05 ` [RFC PATCH 0/4] KVM: SEV: Limit cache flush operations in sev guest memory reclaim events Sean Christopherson
2023-12-01 19:02   ` Mingwei Zhang
2023-12-01 21:30     ` Kalra, Ashish
2023-12-01 21:58       ` Mingwei Zhang
2023-12-01 22:13         ` Kalra, Ashish
2023-12-01 22:13         ` Sean Christopherson
2023-12-01 22:22           ` Mingwei Zhang
2023-12-01 22:30             ` Sean Christopherson
2023-12-02  6:21               ` Mingwei Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).