On 10/2/2026 3:37 AM, Lisa Wang wrote: > From: Sagi Shahar <[email protected]> > > Finalize TDX VM after VM and VCPU creation and memory initialization. > > To integrate TDX VM finalization seamlessly, the finalization is hooked > into kvm_arch_vm_finalize_vcpus(). This approach avoids the need for > every TDX selftest to manually finalize the VM. While it does prevent > TDX selftests from customizing memory before it is locked, no current > selftests require this. > > In TDX, finalization is a mandatory step to make the TD runnable. It > also finalizes the MRTD of the VM's initial memory and state, locking > them in for future attestation and preventing any further modifications. > > Signed-off-by: Sagi Shahar <[email protected]> > Signed-off-by: Lisa Wang <[email protected]> > Reviewed-by: Ira Weiny <[email protected]>
tdx_vm_finalize() does more than finalization. It also calls tdx_load_private_memory() to populates the initial private memory. otherwise, Reviewed-by: Binbin Wu <[email protected]> > --- > tools/testing/selftests/kvm/lib/x86/processor.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/tools/testing/selftests/kvm/lib/x86/processor.c > b/tools/testing/selftests/kvm/lib/x86/processor.c > index b4b76dc505ae..e1d0fd5ed1f6 100644 > --- a/tools/testing/selftests/kvm/lib/x86/processor.c > +++ b/tools/testing/selftests/kvm/lib/x86/processor.c > @@ -1536,6 +1536,12 @@ bool kvm_arch_has_default_irqchip(void) > return true; > } > > +void kvm_arch_vm_finalize_vcpus(struct kvm_vm *vm) > +{ > + if (is_tdx_vm(vm)) > + tdx_vm_finalize(vm); > +} > + > void setup_smram(struct kvm_vm *vm, struct kvm_vcpu *vcpu, u64 smram_gpa, > const void *smi_handler, size_t handler_size) > { >

