Re: [PATCH 1/2] x86/tdx: Add helper to query maximum TD Quote size

From: Peter Fang

Date: Tue Jul 14 2026 - 01:55:03 EST


On Fri, Jul 10, 2026 at 10:38:40AM +0800, Binbin Wu wrote:
> On 6/12/2026 8:36 PM, Kiryl Shutsemau wrote:
> >>
> >> +/**
> >> + * tdx_get_max_quote_size() - Get the maximum TD Quote size
> >> + *
> >> + * Read the maximum size of a TD Quote from a 4-byte TD metadata field. The TDX
> >> + * guest driver uses it to size the buffer for Quote retrieval. Older TDX
> >> + * modules do not support this field and return an error.
> >> + *
> >> + * Return: Maximum Quote size in bytes on success, or 0 on failure.
> >> + */
> >> +u32 tdx_get_max_quote_size(void)
> >> +{
> >> + u64 val, ret;
> >> +
> >> + ret = tdg_vm_rd(TDCS_QUOTE_MAX_SIZE, &val);
> >> +
> >> + return ret ? 0 : (u32)val;
> >
> > Cast is redundant.
>
> I thought in Linux kernel, the explicit cast is often preferred?
> E.g. as documentation of the metadata field’s width here?

Hm... I asked AI to find some patterns in arch/x86, and looks
like the explicit cast is more common... Kiryl are you okay with me
keeping the cast?

>