Re: [PATCH v7 00/42] guest_memfd: In-place conversion support

From: Ackerley Tng

Date: Thu Jun 04 2026 - 17:19:31 EST


Sean Christopherson <seanjc@xxxxxxxxxx> writes:

> On Wed, Jun 03, 2026, Ackerley Tng wrote:
>> Ackerley Tng via B4 Relay <devnull+ackerleytng.google.com@xxxxxxxxxx>
>> writes:
>>
>> > This is v7 of guest_memfd in-place conversion support.
>> >
>>
>> Here's the outstanding items after going over everyone's comments
>> including Sashiko's:
>>
>> + KVM: TDX: Make source page optional for KVM_TDX_INIT_MEM_REGION
>> + Need to move page clearing into __kvm_gmem_get_pfn to resolve
>> leak where populate can put initialized kernel memory into TDX
>> guest
>> + See suggested fix at [1]
>
> That fix works for me. The initial guest image will typically be a tiny subset
> of guest memory, so unnecessarily zeroing a few pages isn't a performance concern.
>

In regular usage moving the zeroing in [1] doesn't change anything,
since the same zeroing would have first happened when the host faults
the pages to put the initial image. When populating, there's no more
zeroing since it was zeroed.

[1] covers the case where the host doesn't write anything to the pages
and directly tries to populate the pages to the guest.

>> + KVM: guest_memfd: Only prepare folios for private pages,
>> + s/non-CoCo/CoCo in commit message "INIT_SHARED is about to be
>> supported for non-CoCo VMs in a later patch in this series
>> + Use Suggested-by: Michael Roth <michael.roth@xxxxxxx>
>> + KVM: selftests: Test that shared/private status is consistent across
>> processes
>> + Improve test reliability using pthread_mutex
>> + I have a fixup patch offline.
>>
>> I would like feedback on these:
>>
>> + KVM: selftests: Test conversion with elevated page refcount
>> + Askar pointed out that soon vmsplice may not pin pages. Should I
>> pin pages through CONFIG_GUP_TEST like in [2]? I prefer not to
>> take a dependency on CONFIG_GUP_TEST.
>
> I'm not exactly excited about taking a dependency on CONFIG_GUP_TEST either, but
> it probably is the least awful choice. E.g. KVM also pins pages is certain flows,
> but we're _also_ actively working to remove the need to pin.
>
> Hmm, maybe IORING_REGISTER_PBUF_RING? AFAICT, it's almost literally a "pin user
> memory" syscall.
>

Hmm that takes a dependency on io_uring, which isn't always compiled
in. Between CONFIG_IO_URING and CONFIG_GUP_TEST, I'd rather
CONFIG_GUP_TEST.

>> + KVM: selftests: Add script to exercise private_mem_conversions_test
>> + Would like to know what people think of a wrapper script before
>> I address Sashiko's comments.
>
> NAK to a wrapper script. This sounds like a perfect fit for Vipin's selftest
> runner (which I'm like 4 months overdue for reviewing, testing, and merging).
> If the runner _can't_ do what you want, then I'd rather improve the runner.
>
> [*] https://lore.kernel.org/all/20260331194202.1722082-1-vipinsh@xxxxxxxxxx
>

Good to know we have this!

Thanks, I'll work on a v8 to clean up the above.

>>
>> [1] https://lore.kernel.org/all/CAEvNRgEVC=fFuKVgZYvWyZD7t_zvUZihFG8hrACjvtkD5cwugw@xxxxxxxxxxxxxx/
>> [2] https://lore.kernel.org/all/baa8838f623102931e755cf34c86314b305af49c.1747264138.git.ackerleytng@xxxxxxxxxx/
>>
>> >
>> > [...snip...]
>> >