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

From: Dave Hansen

Date: Mon Sep 28 2026 - 12:13:37 EST


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.

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?