Re: [PATCH v4 3/4] virt: tdx-guest: Use a variable to store the Quote buffer size
From: Peter Fang
Date: Tue Sep 22 2026 - 12:34:24 EST
On Tue, Sep 22, 2026 at 07:59:55AM -0700, Dave Hansen wrote:
> On 9/22/26 03:05, Xiaoyao Li wrote:
> >> @@ -417,7 +416,8 @@ static int __init tdx_guest_init(void)
> >> if (ret)
> >> goto deinit_mr;
> >>
> >> - quote_data = alloc_quote_buf();
> >> + quote_data_len = PAGE_ALIGN(GET_QUOTE_BUF_SIZE);
> >> + quote_data = alloc_quote_buf(quote_data_len);
> > since quote_data_len is a global variable, it looks no need to pass it around.
> >
> > Same for free_quote_buf()
>
> It's not the end of the world, but... global variable == bad. Plus,
> handing global variables around can actually make the code flow more clear.
>
> I'd much rather have a quote_data_len() with a static function variable.
> Oh, and, btw... "quote_data_len" is the wrong name. It's literally *not*
> "the length of the quote data" itself because it has the header metadata
> included in there.
Thanks. I'll apply the static function variable pattern suggested in
patch 4, and think of a better name.
The pointer to this buffer is "void *quote_data" which probably needs a
better name too.