[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <21b43adc-37aa-bac3-0615-4703438ea4a1@intel.com>
Date: Fri, 2 Dec 2022 09:06:04 -0800
From: Dave Hansen <dave.hansen@...el.com>
To: "Huang, Kai" <kai.huang@...el.com>,
"kvm@...r.kernel.org" <kvm@...r.kernel.org>,
"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>,
"peterz@...radead.org" <peterz@...radead.org>,
"Shahar, Sagi" <sagis@...gle.com>,
"imammedo@...hat.com" <imammedo@...hat.com>,
"Gao, Chao" <chao.gao@...el.com>,
"Brown, Len" <len.brown@...el.com>,
"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 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)
Powered by blists - more mailing lists