Re: [PATCH 2/2] virt: tdx-guest: Allocate Quote buffer dynamically

From: Peter Fang

Date: Tue Jun 23 2026 - 01:12:14 EST


On Fri, Jun 12, 2026 at 01:37:38PM +0100, Kiryl Shutsemau wrote:
> On Fri, Jun 12, 2026 at 04:08:49AM -0700, Peter Fang wrote:
> > @@ -171,7 +171,7 @@ static void tdx_mr_deinit(const struct attribute_group *mr_grp)
> > #define GET_QUOTE_SUCCESS 0
> > #define GET_QUOTE_IN_FLIGHT 0xffffffffffffffff
> >
> > -#define TDX_QUOTE_MAX_LEN (GET_QUOTE_BUF_SIZE - sizeof(struct tdx_quote_buf))
> > +#define TDX_QUOTE_BUF_LEN(n) (offsetof(struct tdx_quote_buf, data) + (n))
>
> I've got confused by this offsetof(). It is valid, but why not plain
> sizeof()?

I recently noticed that using sizeof() on a struct with a trailing
flexible array may not be the cleanest coding style [1], so I took the
chance and improved it. Looking at it again, I see that I can just use
struct_size_t() and not reinvent the wheel... I'll improve this in the
next revision.

>
> Otherwise looks okay to me:
>
> Reviewed-by: Kiryl Shutsemau (Meta) <kas@xxxxxxxxxx>

Thanks Kiryl!

>
> --
> Kiryl Shutsemau / Kirill A. Shutemov

[1] https://lore.kernel.org/linux-coco/a52c4701-c99d-48d5-9b63-8eb1c0e589f0@xxxxxxxxx/