On 7/23/2026 7:13 AM, Lisa Wang wrote: > Force guest_memfd for TDX VMs. > > KVM supports guest_memfd for TDX private memory. Without in-place > conversion supports, all pages default attributes are private. Thus, > set page to "shared" for shared pages. > > Signed-off-by: Lisa Wang <[email protected]>
Reviewed-by: Binbin Wu <[email protected]> One nit below. > --- > tools/testing/selftests/kvm/lib/kvm_util.c | 2 +- > tools/testing/selftests/kvm/lib/ucall_common.c | 8 ++++++++ > 2 files changed, 9 insertions(+), 1 deletion(-) > > diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c > b/tools/testing/selftests/kvm/lib/kvm_util.c > index 0b9d2d383bfa..4a48c4b42095 100644 > --- a/tools/testing/selftests/kvm/lib/kvm_util.c > +++ b/tools/testing/selftests/kvm/lib/kvm_util.c > @@ -472,7 +472,7 @@ void kvm_set_files_rlimit(u32 nr_vcpus) > static bool is_guest_memfd_required(struct vm_shape shape) > { > #ifdef __x86_64__ > - return shape.type == KVM_X86_SNP_VM; > + return (shape.type == KVM_X86_SNP_VM || shape.type == KVM_X86_TDX_VM); Nit: The parentheses can be dropped. > #else > return false; > #endif > diff --git a/tools/testing/selftests/kvm/lib/ucall_common.c > b/tools/testing/selftests/kvm/lib/ucall_common.c > index 029ce21f9f2f..c03dfc763172 100644 > --- a/tools/testing/selftests/kvm/lib/ucall_common.c > +++ b/tools/testing/selftests/kvm/lib/ucall_common.c > @@ -27,6 +27,7 @@ static struct ucall_header *ucall_pool; > > void ucall_init(struct kvm_vm *vm, gpa_t mmio_gpa) > { > + struct userspace_mem_region *region; > struct ucall_header *hdr; > struct ucall *uc; > gva_t gva; > @@ -37,6 +38,13 @@ void ucall_init(struct kvm_vm *vm, gpa_t mmio_gpa) > hdr = (struct ucall_header *)addr_gva2hva(vm, gva); > memset(hdr, 0, sizeof(*hdr)); > > + region = vm_get_mem_region(vm, MEM_REGION_DATA); > + if (region->region.flags & KVM_MEM_GUEST_MEMFD) { > + size_t aligned_sz = align_up(sizeof(*hdr), vm->page_size); > + > + vm_mem_set_shared(vm, addr_gva2gpa(vm, gva), aligned_sz); > + } > + > for (i = 0; i < KVM_MAX_VCPUS; ++i) { > uc = &hdr->ucalls[i]; > uc->hva = uc; >

