Re: [PATCH V4 1/1] KVM: TDX: Add sub-ioctl KVM_TDX_TERMINATE_VM

From: Edgecombe, Rick P
Date: Fri Jun 20 2025 - 14:59:37 EST


On Fri, 2025-06-20 at 07:24 -0700, Sean Christopherson wrote:
> > The patch was tested with QEMU which AFAICT does not touch  memslots when
> > shutting down.  Is there a reason to?
>
> In this case, the VMM process is not shutting down.  To emulate a reboot, the
> VMM destroys the VM, but reuses the guest_memfd files for the "new" VM. 
> Because guest_memfd takes a reference to "struct kvm", through memslot
> bindings, memslots need to be manually destroyed so that all references are
> put and the VM is freed by the kernel.

Sorry if I'm being dumb, but why does it do this? It saves freeing/allocating
the guestmemfd pages? Or the in-place data gets reused somehow?

The series Vishal linked has some kind of SEV state transfer thing. How is it
intended to work for TDX?

>   E.g. otherwise multiple reboots would manifest as memory leakds and
> eventually OOM the host.

This is in the case of future guestmemfd functionality? Or today?