[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <3e09b8fb-a24c-4c50-9203-30dce333c4fc@linux.intel.com>
Date: Tue, 25 Nov 2025 17:14:01 +0800
From: Binbin Wu <binbin.wu@...ux.intel.com>
To: Rick Edgecombe <rick.p.edgecombe@...el.com>
Cc: bp@...en8.de, chao.gao@...el.com, dave.hansen@...el.com,
isaku.yamahata@...el.com, kai.huang@...el.com, kas@...nel.org,
kvm@...r.kernel.org, linux-coco@...ts.linux.dev,
linux-kernel@...r.kernel.org, mingo@...hat.com, pbonzini@...hat.com,
seanjc@...gle.com, tglx@...utronix.de, vannapurve@...gle.com,
x86@...nel.org, yan.y.zhao@...el.com, xiaoyao.li@...el.com,
binbin.wu@...el.com
Subject: Re: [PATCH v4 10/16] KVM: TDX: Allocate PAMT memory for vCPU control
structures
On 11/21/2025 8:51 AM, Rick Edgecombe wrote:
> From: "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>
>
> TDX vCPU control structures are provided to the TDX module at 4KB page
> size and require PAMT backing. This means for Dynamic PAMT they need to
> also have 4KB backings installed.
>
> Previous changes introduced tdx_alloc_page()/tdx_free_page() that can
> allocate a page and automatically handle the DPAMT maintenance. Use them
> for vCPU control structures instead of alloc_page()/__free_page().
>
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@...ux.intel.com>
> [update log]
> Signed-off-by: Rick Edgecombe <rick.p.edgecombe@...el.com>
Reviewed-by: Binbin Wu <binbin.wu@...ux.intel.com>
> ---
> v3:
> - Write log. Reame from “Allocate PAMT memory for TDH.VP.CREATE and
> TDH.VP.ADDCX”.
> - Remove new line damage
> ---
> arch/x86/kvm/vmx/tdx.c | 12 +++++-------
> 1 file changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c
> index 8c4c1221e311..b6d7f4b5f40f 100644
> --- a/arch/x86/kvm/vmx/tdx.c
> +++ b/arch/x86/kvm/vmx/tdx.c
> @@ -2882,7 +2882,7 @@ static int tdx_td_vcpu_init(struct kvm_vcpu *vcpu, u64 vcpu_rcx)
> int ret, i;
> u64 err;
>
> - page = alloc_page(GFP_KERNEL);
> + page = tdx_alloc_page();
> if (!page)
> return -ENOMEM;
> tdx->vp.tdvpr_page = page;
> @@ -2902,7 +2902,7 @@ static int tdx_td_vcpu_init(struct kvm_vcpu *vcpu, u64 vcpu_rcx)
> }
>
> for (i = 0; i < kvm_tdx->td.tdcx_nr_pages; i++) {
> - page = alloc_page(GFP_KERNEL);
> + page = tdx_alloc_page();
> if (!page) {
> ret = -ENOMEM;
> goto free_tdcx;
> @@ -2924,7 +2924,7 @@ static int tdx_td_vcpu_init(struct kvm_vcpu *vcpu, u64 vcpu_rcx)
> * method, but the rest are freed here.
> */
> for (; i < kvm_tdx->td.tdcx_nr_pages; i++) {
> - __free_page(tdx->vp.tdcx_pages[i]);
> + tdx_free_page(tdx->vp.tdcx_pages[i]);
> tdx->vp.tdcx_pages[i] = NULL;
> }
> return -EIO;
> @@ -2952,16 +2952,14 @@ static int tdx_td_vcpu_init(struct kvm_vcpu *vcpu, u64 vcpu_rcx)
>
> free_tdcx:
> for (i = 0; i < kvm_tdx->td.tdcx_nr_pages; i++) {
> - if (tdx->vp.tdcx_pages[i])
> - __free_page(tdx->vp.tdcx_pages[i]);
> + tdx_free_page(tdx->vp.tdcx_pages[i]);
> tdx->vp.tdcx_pages[i] = NULL;
> }
> kfree(tdx->vp.tdcx_pages);
> tdx->vp.tdcx_pages = NULL;
>
> free_tdvpr:
> - if (tdx->vp.tdvpr_page)
> - __free_page(tdx->vp.tdvpr_page);
> + tdx_free_page(tdx->vp.tdvpr_page);
> tdx->vp.tdvpr_page = NULL;
> tdx->vp.tdvpr_pa = 0;
>
Powered by blists - more mailing lists