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

From: Binbin Wu

Date: Thu Jul 09 2026 - 22:39:04 EST


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?

>
>> +}
>> +EXPORT_SYMBOL_GPL(tdx_get_max_quote_size);
>> +
>> static void __noreturn tdx_panic(const char *msg)
>> {
>> struct tdx_module_args args = {
>