[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aRqfAlt1sxn7yZJ1@yzhao56-desk.sh.intel.com>
Date: Mon, 17 Nov 2025 12:05:22 +0800
From: Yan Zhao <yan.y.zhao@...el.com>
To: Binbin Wu <binbin.wu@...ux.intel.com>
CC: <seanjc@...gle.com>, <pbonzini@...hat.com>,
<linux-kernel@...r.kernel.org>, <kvm@...r.kernel.org>, <x86@...nel.org>,
<rick.p.edgecombe@...el.com>, <dave.hansen@...el.com>, <kas@...nel.org>,
<tabba@...gle.com>, <ackerleytng@...gle.com>, <michael.roth@....com>,
<david@...hat.com>, <vannapurve@...gle.com>, <vbabka@...e.cz>,
<thomas.lendacky@....com>, <pgonda@...gle.com>, <fan.du@...el.com>,
<jun.miao@...el.com>, <ira.weiny@...el.com>, <isaku.yamahata@...el.com>,
<xiaoyao.li@...el.com>, <chao.p.peng@...el.com>
Subject: Re: [RFC PATCH v2 05/23] x86/tdx: Enhance tdh_phymem_page_reclaim()
to support huge pages
On Mon, Nov 17, 2025 at 10:09:42AM +0800, Binbin Wu wrote:
>
>
> On 8/7/2025 5:42 PM, Yan Zhao wrote:
> [...]
> > diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c
> > index 64219c659844..9ed585bde062 100644
> > --- a/arch/x86/virt/vmx/tdx/tdx.c
> > +++ b/arch/x86/virt/vmx/tdx/tdx.c
> > @@ -1966,19 +1966,27 @@ EXPORT_SYMBOL_GPL(tdh_vp_init);
> > * So despite the names, they must be interpted specially as described by the spec. Return
> > * them only for error reporting purposes.
> > */
> > -u64 tdh_phymem_page_reclaim(struct page *page, u64 *tdx_pt, u64 *tdx_owner, u64 *tdx_size)
> > +u64 tdh_phymem_page_reclaim(struct folio *folio, unsigned long start_idx, unsigned long npages,
> > + u64 *tdx_pt, u64 *tdx_owner, u64 *tdx_size)
> > {
> > + struct page *start = folio_page(folio, start_idx);
> > struct tdx_module_args args = {
> > - .rcx = page_to_phys(page),
> > + .rcx = page_to_phys(start),
> > };
> > u64 ret;
> > + if (start_idx + npages > folio_nr_pages(folio))
> > + return TDX_OPERAND_INVALID;
> > +
> > ret = seamcall_ret(TDH_PHYMEM_PAGE_RECLAIM, &args);
> > *tdx_pt = args.rcx;
> > *tdx_owner = args.rdx;
> > *tdx_size = args.r8;
> > + if (npages != (1 << (*tdx_size) * PTE_SHIFT))
> > + return TDX_SW_ERROR;
>
> Nit:
>
> The size check here is to make sure the reclamation on the correct level,
> however, tdx_size may not be updated if some other error occurs first.
> Do you think it's better to check 'ret' first before returning TDX_SW_ERROR?
> Otherwise, the error code provided by the TDX module, which may be helpful for
> debugging, will be buried under TDX_SW_ERROR.
Makes sense. Thanks!
I'll change it to:
if (!ret && npages != (1 << (*tdx_size) * PTE_SHIFT))
return TDX_SW_ERROR;
> > return ret;
> > }
> > EXPORT_SYMBOL_GPL(tdh_phymem_page_reclaim);
>
Powered by blists - more mailing lists