Re: [PATCH 02/15] x86/virt/tdx: Add extra memory to TDX Module for Extensions

From: Xu Yilun

Date: Wed May 27 2026 - 04:01:19 EST


On Wed, May 27, 2026 at 02:38:27PM +0800, Xiaoyao Li wrote:
> On 5/27/2026 11:47 AM, Xu Yilun wrote:
> > > > +static void tdx_clflush_hpa_list(struct page *root, unsigned int nr_pages)
> > > > +{
> > > > + u64 *entries = page_to_virt(root);
> > > > + int i;
> > > > +
> > > > + for (i = 0; i < nr_pages; i++)
> > > > + clflush_cache_range(__va(entries[i]), PAGE_SIZE);
> > >
> > > Is the page flush only needed when CLFLUSH_BEFORE_ALLOC is true?
> > >
> > > If so, it inherits the same decision to always flush as what
> >
> > Yes it is basically the same as tdx_clflush_page().
> >
> > > tdx_clflush_page() did. Then, any chance we can use tdx_clflush_page() here
> >
> > But I don't think we should convert hpa/page/va back and forth just for
> > re-using one line of code.
>
> Because we want/need to flush page as late as possible so that the page
> flush needs to happen right before SEAMCALL?

I think so. Let the flushing be part of the tdh call semantic.

>
> How about we pass in the struct page * and number into tdx_ext_mem_add() and
> construct the root page inside it?

I assume you don't suggest allocate root page inside the call, then we
need 3 parameters for the HPA_LIST_INFO:

struct page *, unsigned int nr_pages, struct page *root

which I think too much.

I think your concern is to try not to introduce another tdx_clflush_
variant, but I believe this will happen, pfn based memory description is
on the way:

https://lore.kernel.org/all/20260430014929.24210-1-yan.y.zhao@xxxxxxxxx/