Re: [PATCH v3 13/16] KVM: TDX: Handle PAMT allocation in fault path

Yan Zhao
2025-09-30T01:10:32Z

On Thu, Sep 18, 2025 at 04:22:21PM -0700, Rick Edgecombe wrote:
> @@ -862,6 +863,9 @@ void tdx_vcpu_free(struct kvm_vcpu *vcpu)
> tdx->vp.tdvpr_page = 0;
> }
>
> + while ((page = get_tdx_prealloc_page(&tdx->prealloc)))
> + __free_page(page);
> +
> tdx->state = VCPU_TD_STATE_UNINITIALIZED;
> }
tdx_vcpu_free() may be invoked even if the vcpu ioctl KVM_TDX_INIT_VCPU was
never called.

> @@ -2966,6 +2999,8 @@ static int tdx_td_vcpu_init(struct kvm_vcpu *vcpu, u64 vcpu_rcx)
> int ret, i;
> u64 err;
>
> + INIT_LIST_HEAD(&tdx->prealloc.page_list);
So, need to move this list init to tdx_vcpu_create().

> page = tdx_alloc_page();
> if (!page)
> return -ENOMEM;
> --
> 2.51.0
>