[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d55cb607566e43ea6522f0aeb6fe7c10628dd950.camel@intel.com>
Date: Fri, 2 Dec 2022 21:56:49 +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 09/20] x86/virt/tdx: Get information about TDX module
and TDX-capable memory
On Fri, 2022-12-02 at 09:06 -0800, Dave Hansen wrote:
> On 12/2/22 03:11, Huang, Kai wrote:
> > And also to address you concern that not all 892 bytes are reserved, how about
> > below:
> >
> > union {
> > - struct cpuid_config cpuid_configs[0];
> > - u8 reserved5[892];
> > + DECLARE_FLEX_ARRAY(struct cpuid_config, cpuid_configs);
> > + u8 padding[892];
> > };
> > } __packed __aligned(TDSYSINFO_STRUCT_ALIGNMENT);
> >
> > The goal is to make the size of 'struct tdsysinfo_struct' to be 1024B so we can
> > use a static variable for it, and at the meantime, it can still have 1024B
> > (enough space) for the TDH.SYS.INFO to write to.
>
> I just don't like the open-coded sizes.
>
> For instance, wouldn't it be great if you didn't have to know the size
> of *ANYTHING* else to properly size the '892'?
>
> Maybe we just need some helpers to hide the gunk:
>
> #define DECLARE_PADDED_STRUCT(type, name, alignment) \
> struct type##_padded { \
> union { \
> struct type name; \
> u8 padding[alignment]; \
> } \
> } name##_padded;
>
> #define PADDED_STRUCT(name) (name##_padded.name)
>
> That can get used like this:
>
> DECLARE_PADDED_STRUCT(struct tdsysinfo_struct, tdsysinfo,
> TDSYSINFO_STRUCT_ALIGNMENT);
>
>
> struct tdsysinfo_struct sysinfo = PADDED_STRUCT(tdsysinfo)
Thanks. Will try out this way.
Powered by blists - more mailing lists