[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <60deb2ffe15e71bc91727aa04298c79f21a58c83.camel@intel.com>
Date: Mon, 28 Nov 2022 22:13:18 +0000
From: "Huang, Kai" <kai.huang@...el.com>
To: "kvm@...r.kernel.org" <kvm@...r.kernel.org>,
"Hansen, Dave" <dave.hansen@...el.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
CC: "Luck, Tony" <tony.luck@...el.com>,
"bagasdotme@...il.com" <bagasdotme@...il.com>,
"ak@...ux.intel.com" <ak@...ux.intel.com>,
"Wysocki, Rafael J" <rafael.j.wysocki@...el.com>,
"kirill.shutemov@...ux.intel.com" <kirill.shutemov@...ux.intel.com>,
"Christopherson,, Sean" <seanjc@...gle.com>,
"Chatre, Reinette" <reinette.chatre@...el.com>,
"pbonzini@...hat.com" <pbonzini@...hat.com>,
"linux-mm@...ck.org" <linux-mm@...ck.org>,
"Yamahata, Isaku" <isaku.yamahata@...el.com>,
"Shahar, Sagi" <sagis@...gle.com>,
"imammedo@...hat.com" <imammedo@...hat.com>,
"Gao, Chao" <chao.gao@...el.com>,
"Brown, Len" <len.brown@...el.com>,
"peterz@...radead.org" <peterz@...radead.org>,
"sathyanarayanan.kuppuswamy@...ux.intel.com"
<sathyanarayanan.kuppuswamy@...ux.intel.com>,
"Huang, Ying" <ying.huang@...el.com>,
"Williams, Dan J" <dan.j.williams@...el.com>
Subject: Re: [PATCH v7 11/20] x86/virt/tdx: Add placeholder to construct TDMRs
to cover all TDX memory regions
On Mon, 2022-11-28 at 07:59 -0800, Dave Hansen wrote:
> On 11/24/22 04:02, Huang, Kai wrote:
> > On Wed, 2022-11-23 at 14:17 -0800, Dave Hansen wrote:
> > > First, I think 'tdx_sysinfo' should probably be a local variable in
> > > init_tdx_module() and have its address passed in here. Having global
> > > variables always makes it more opaque about who is initializing it.
> > Sorry I missed to respond this.
> >
> > Using local variable for 'tdx_sysinfo' will cause a build warning:
> >
> > https://lore.kernel.org/lkml/a6694c81b4e96a22557fd0af70a81bd2c2e4e3e7.camel@intel.com/
>
> Having it be local scope is a lot more important than having it be on
> stack. Just declare it local to the function but keep it off the stack.
> No need to dynamically allocate it, even.
Apologize I am not entirely sure whether I fully got your point. Do you mean
something like below?
static struct tdsysinfo_struct tdx_sysinfo;
static int tdmr_size_single(int max_reserved_per_tdmr)
{
...
}
static int tdmr_array_size(struct tdsysinfo_struct *sysinfo)
{
return tdmr_size_single(sysinfo->max_reserved_per_tdmr) *
sysinfo->max_tdmrs;
}
static int init_tdx_module(void)
{
...
tdx_get_sysinfo(&tdx_sysinfo, ...);
...
tdmr_array = alloc_pages_exact(tdmr_array_size(&tdx_sysinfo),
GFP_KERNEL | __GFP_ZERO);
...
construct_tdmrs(tdmr_array, &nr_tdmrs, &tdx_sysinfo);
...
}
Powered by blists - more mailing lists