Update the SEV-SNP launch update flow to utilize guest_memfd in-place conversion.
Include the KVM_SET_MEMORY_ATTRIBUTES2_PRESERVE flag when setting memory attributes to private. This is permitted before the SNP VM is finalized. In snp_launch_update_data, pass 0 as the host virtual address. This instructs the kernel to perform the launch update using the guest_memfd backing the guest physical address rather than a userspace-provided buffer. Signed-off-by: Ackerley Tng <[email protected]> --- tools/testing/selftests/kvm/lib/x86/sev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/testing/selftests/kvm/lib/x86/sev.c b/tools/testing/selftests/kvm/lib/x86/sev.c index 93f9169034617..074ab0eff1e27 100644 --- a/tools/testing/selftests/kvm/lib/x86/sev.c +++ b/tools/testing/selftests/kvm/lib/x86/sev.c @@ -37,8 +37,7 @@ static void encrypt_region(struct kvm_vm *vm, struct userspace_mem_region *regio if (is_sev_snp_vm(vm)) snp_launch_update_data(vm, gpa_base + offset, - (u64)addr_gpa2hva(vm, gpa_base + offset), - size, page_type); + 0, size, page_type); else sev_launch_update_data(vm, gpa_base + offset, size); -- 2.54.0.563.g4f69b47b94-goog
