Re: [PATCH v2 00/14] KVM: guest_memfd: lazy preparation of pages + prefault support for SEV-SNP

From: Michael Roth
Date: Mon Jul 29 2024 - 18:09:54 EST


On Fri, Jul 26, 2024 at 02:51:43PM -0400, Paolo Bonzini wrote:
> Paolo Bonzini (14):
> KVM: x86: disallow pre-fault for SNP VMs before initialization
> KVM: guest_memfd: return folio from __kvm_gmem_get_pfn()
> KVM: guest_memfd: delay folio_mark_uptodate() until after successful
> preparation
> KVM: guest_memfd: do not go through struct page
> KVM: rename CONFIG_HAVE_KVM_GMEM_* to CONFIG_HAVE_KVM_ARCH_GMEM_*
> KVM: guest_memfd: return locked folio from __kvm_gmem_get_pfn
> KVM: guest_memfd: delay kvm_gmem_prepare_folio() until the memory is
> passed to the guest
> KVM: guest_memfd: make kvm_gmem_prepare_folio() operate on a single
> struct kvm
> KVM: remove kvm_arch_gmem_prepare_needed()
> KVM: guest_memfd: move check for already-populated page to common code
> KVM: cleanup and add shortcuts to kvm_range_has_memory_attributes()
> KVM: extend kvm_range_has_memory_attributes() to check subset of
> attributes
> KVM: guest_memfd: let kvm_gmem_populate() operate only on private gfns
> KVM: guest_memfd: abstract how prepared folios are recorded

Re-tested series with multiple SNP guests with/without experimental THP
patches on top.

Also re-tested using the following SNP self tests (I believe Pratik has
a newer version he'll be submitting soon):

https://github.com/mdroth/linux/commits/snp-uptodate2-kst4/
x86_64/coco_pre_fault_memory_test

Series:

Tested-by: Michael Roth <michael.roth@xxxxxxx>

>
> v1->v2:
> - patch 1: new
> - patch 7: point out benign race between page fault and hole-punch
> - patch 7: clean up comments
> - patch 10: clean up commit message
> - patch 11: remove ";;"
> - patch 13: fix length argument to kvm_range_has_memory_attributes()
> - patch 14: new
>
> Documentation/virt/kvm/api.rst | 6 +
> arch/x86/include/asm/kvm_host.h | 1 +
> arch/x86/kvm/Kconfig | 4 +-
> arch/x86/kvm/mmu/mmu.c | 5 +-
> arch/x86/kvm/svm/sev.c | 17 +--
> arch/x86/kvm/svm/svm.c | 1 +
> arch/x86/kvm/x86.c | 12 +-
> include/linux/kvm_host.h | 9 +-
> virt/kvm/Kconfig | 4 +-
> virt/kvm/guest_memfd.c | 226 +++++++++++++++++++-------------
> virt/kvm/kvm_main.c | 73 +++++------
> 11 files changed, 206 insertions(+), 152 deletions(-)
>
> --
> 2.43.0
>
>