On Fri, Jun 09, 2023 at 02:54:41AM +0300, "kirill.shutemov@xxxxxxxxxxxxxxx" <kirill.shutemov@xxxxxxxxxxxxxxx> wrote: > On Thu, Jun 08, 2023 at 04:29:19PM -0700, Isaku Yamahata wrote: > > On Thu, Jun 08, 2023 at 02:41:28PM +0300, > > "kirill.shutemov@xxxxxxxxxxxxxxx" <kirill.shutemov@xxxxxxxxxxxxxxx> wrote: > > > > > On Thu, Jun 08, 2023 at 02:40:27AM +0000, Huang, Kai wrote: > > > > On Thu, 2023-06-08 at 03:27 +0300, kirill.shutemov@xxxxxxxxxxxxxxx wrote: > > > > > 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. > > > > > > > > > > > > I do need to keep tdsysinfo_struct as it will be used by KVM too. > > > > > > Will you pass it down to KVM from this function? Will KVM use the struct > > > after the function returns? > > > > KVM needs tdsysinfo_struct to create guest TD. It doesn't require > > 1024-alignment. > > How KVM gets it from here? For now, TDX KVM patch series moves the tdsysinfo out of the function, and add a getter function of it. As long as KVM can access the info, it doesn't care how its memory is allocated. static or dynamic. -- Isaku Yamahata <isaku.yamahata@xxxxxxxxx>