Re: [PATCH v5 4/6] virt: tdx-guest: Add a helper for the Quote buffer size

From: Peter Fang

Date: Tue Sep 29 2026 - 06:14:26 EST


On Mon, Sep 28, 2026 at 09:13:11AM -0700, Dave Hansen wrote:
> On 9/28/26 03:08, Peter Fang wrote:
> > +static size_t get_quote_buf_size(void)
> > +{
> > + static size_t quote_buf_size;
> > +
> > + if (quote_buf_size)
> > + return quote_buf_size;
> > +
> > + quote_buf_size = PAGE_ALIGN(TDX_DEFAULT_QUOTE_SIZE);
> > +
> > + return quote_buf_size;
> > +}
>
> <sarcasm>
> This is gloriously unencumbered by unwieldy comments!
> </sarcasm>
>
> Please explain the goal of this function. Why is it doing what it is
> doing? This should also explain why it is page-aligning and caching things.

Ugh sorry, this is a miss on my part. I will add comments to explain
this, especially the caching part.

>
> Which also reminds me, it really isn't calculating the size of the quote
> "buf". It's calculating the size of the allocation required to transport
> it around, no?
>
> Because, there are three sizes here:
>
> 1. The actual data of the quote
> 2. The size of #1 with the metadata added in
> 3. The size of #2 with page padding
>
> Which one of those three is "buf_size", eh?

I think what Rick said makes sense. A more limited change would be to
choose 2 and let alloc/free deal with the page alignment. None of this
is explained until patch 6. I'll add a comment for this. Thanks.