Re: [PATCH v11 08/20] x86/virt/tdx: Get information about TDX module and TDX-capable memory
From: kirill . shutemov
Date: Wed Jun 07 2023 - 20:27:42 EST
On Mon, Jun 05, 2023 at 02:27:21AM +1200, Kai Huang wrote:
> For now both 'tdsysinfo_struct' and CMRs are only used during the module
> initialization. But because they are both relatively big, declare them
> inside the module initialization function but as static variables.
This justification does not make sense to me. static variables will not be
freed after function returned. They will still consume memory.
I think you need to allocate/free memory dynamically, if they are too big
for stack.
...
> static int init_tdx_module(void)
> {
> + static DECLARE_PADDED_STRUCT(tdsysinfo_struct, tdsysinfo,
> + TDSYSINFO_STRUCT_SIZE, TDSYSINFO_STRUCT_ALIGNMENT);
> + static struct cmr_info cmr_array[MAX_CMRS]
> + __aligned(CMR_INFO_ARRAY_ALIGNMENT);
--
Kiryl Shutsemau / Kirill A. Shutemov