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

From: Edgecombe, Rick P

Date: Tue Sep 30 2025 - 14:11:28 EST


On Tue, 2025-09-30 at 09:09 +0800, Yan Zhao wrote:
> 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().

Oh, nice catch. Thanks!