Re: [RFC PATCH v2 03/23] x86/tdx: Enhance tdh_phymem_page_wbinvd_hkid() to invalidate huge pages
From: Dave Hansen
Date: Thu Nov 13 2025 - 10:26:45 EST
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.