Re: [RFC PATCH v2 03/23] x86/tdx: Enhance tdh_phymem_page_wbinvd_hkid() to invalidate huge pages

From: Yan Zhao

Date: Thu Nov 13 2025 - 20:23:20 EST


On Thu, Nov 13, 2025 at 07:26:43AM -0800, Dave Hansen wrote:
> On 11/12/25 23:37, Huang, Kai wrote:
> > Sure. But it seems you will need to wait all patches that you mentioned to
> > be merged to safely use 'page++' for pages in a folio?
> >
> > And if you do:
> >
> > for (i = 0; i < npages; i++)
> > {
> > struct page *p = folio_page(folio, start_idx + i);
> > struct tdx_module_args args = {};
> >
> > args.rcx = mk_keyed_paddr(hkid, p);
> > ...
> > }
> >
> > It should work w/o any dependency?
> >
> > Anyway, I don't have any strong opinion, as long as it works. You may
> > choose what you want. 🙂
>
> Folks, I'll make it easy: Do what Kai suggested above. It works
> universally and it's obvious. Saving an "i" variable only makes the code
> harder to read.
>
> If anyone thinks that:
>
> while (npages--)
>
> Is easier to understand than the most common C idiom on the planet:
>
> for (i = 0; i < npages; i++)
>
> ... then I don't know what to tell them.
Got it. That's very helpful. Thanks for the instruction!