Skip to content

RFC KVM: SEV: Limit cache flush operations in sev guest memory reclaim events

Jacky Li kvm 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest4 patches 12 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4KVM: SEV: Drop wbinvd_on_all_cpus() as kvm mmu notifier would flush the cachearch/x86/kvm/svm/sev.c+0 -141 reply
2/4KVM: SEV: Plumb mmu_notifier_event into sev functionarch/x86/include/asm/kvm_host.h arch/x86/kvm/svm/sev.c arch/x86/kvm/svm/svm.h +3 more+20 -110 replies
3/4KVM: SEV: Limit the call of WBINVDs based on the event type of mmu notifierarch/x86/kvm/svm/sev.c+5 -11 reply
4/4KVM: SEV: Use a bitmap module param to decide whether a cache flush is needed during the guest memory reclaimarch/x86/kvm/svm/sev.c include/linux/mmu_notifier.h+47 -41 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 0/4] KVM: SEV: Limit cache flush operations in sev guest memory reclaim events

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(-)
Signature · 1 line
2.43.0.rc0.421.g78406f8d94-goog