Re: [RFC PATCH 09/15] x86/virt/tdx: Add interface to generate a Quote

From: Peter Fang

Date: Fri Jun 26 2026 - 05:59:11 EST


On Sun, Jun 14, 2026 at 04:29:48AM -0700, Peter Fang wrote:
> >
> > > + goto out;
> > > +
> > > + /*
> > > + * The quote buffer is a shared resource, so use it only for the
> > > + * SEAMCALL and copy the data out as soon as possible.
> > > + */
> > > + quote_dup = kvmemdup(quote_data.buf, out_len, GFP_KERNEL);
> >
> > So at init time we allocate a vmalloc for the quote and pre-populate the
> > hpa_list. Then we use it every time and copy the contents to a new vmalloc.
> > Would it really be that hard to keep the hpa list allocation around, do a
> > vmalloc here and update the pfn list. Then do get quote on that and pass back
> > the vmalloc we just allocated? Just feels like global reuse way has extra pieces
> > in it. Compared to the whole quoting operation, this vmalloc_to_pfn() loop is
> > probably not very expensive.
>
> Hm interesting idea. But a Quote buffer could be close to 4MB in the worst
> case. Let's say max_quote_size is 3MB, that's 768 vmalloc_to_pfn() calls
> each time... That sounds a bit excessive right?
>
> The extra bits mainly come from using kvmemdup() I think. Having to use
> kvfree() on it does feel a bit annoying but that was the tradeoff I
> made...
>

I didn't change the design in the v2 series, but after some discussion
with Yilun, I now realize this is actually a really good idea. Having a
static buffer does complicate the code a bit. I'll probably try doing
the allocation on the KVM side and just do vmalloc_to_pfn() calls each
time. Thanks.

> >
>