lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1b1a2fe7-d225-414c-9055-8ad06938a0bf@intel.com>
Date: Fri, 30 Jan 2026 08:35:09 -0800
From: Dave Hansen <dave.hansen@...el.com>
To: Xu Yilun <yilun.xu@...ux.intel.com>
Cc: Chao Gao <chao.gao@...el.com>, linux-coco@...ts.linux.dev,
 linux-kernel@...r.kernel.org, kvm@...r.kernel.org, x86@...nel.org,
 reinette.chatre@...el.com, ira.weiny@...el.com, kai.huang@...el.com,
 dan.j.williams@...el.com, sagis@...gle.com, vannapurve@...gle.com,
 paulmck@...nel.org, nik.borisov@...e.com, zhenzhong.duan@...el.com,
 seanjc@...gle.com, rick.p.edgecombe@...el.com, kas@...nel.org,
 dave.hansen@...ux.intel.com, vishal.l.verma@...el.com,
 Farrah Chen <farrah.chen@...el.com>, Thomas Gleixner <tglx@...utronix.de>,
 Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
 "H. Peter Anvin" <hpa@...or.com>
Subject: Re: [PATCH v3 08/26] x86/virt/seamldr: Retrieve P-SEAMLDR information

On 1/29/26 20:01, Xu Yilun wrote:
>> I'd also prefer a
>>
>> 	BUILD_BUG_ON(sizeof(struct seamldr_info) != 2048);
>                                                     ^
> BUILD_BUG_ON(sizeof(struct seamldr_info) != 256);   is it?
Whatever the documentation says. I might have been looking at the
seamldr_seaminfo.

>> just as a sanity check. It doesn't cost anything and it makes sure that
>> as you muck around with reserved fields and padding that there's at
>> least one check making sure it's OK.
> 
> And I recently received a comments that "never __packed for naturally
> aligned structures cause it leads to bad generated code and hurts
> performance", but I really want to highlight nearby it is for a
> formatted binary blob, so:
> 
>   struct seamldr_info {
> 	u32     version;
> 	u32     attributes;
> 	u32     vendor_id;
> 	u32     build_date;
> 	u16     build_num;
> 	u16     minor_version;
> 	u16     major_version;
> 	u16     update_version;
> 	u8      reserved0[4];
> 	u32     num_remaining_updates;
> 	u8      reserved1[224];
>   };   //delete __packed here
> 
>  static_assert(sizeof(struct seamldr_info) == 256);
> 
> Is it better?

I'm pretty sure __packed is used all over the place.

I'd be shocked if access to a __packed structure generated different
code than a non-packed one for the same layout. But it wouldn't be the
first time I was shocked by a compiler.

I think you might be confusing the fact that access to unaligned data
can really stink on some architectures. The code generation for *that*
can be garbage. But not on x86 really and not for data that's already
naturally aligned.

Plus, *this* data structure is far, far from being performance sensitive
anyway. So it doubly or triply doesn't matter here.

If nothing else, __packed is a good indicator that WYSIWYG for structure
layout because it's an ABI. I honestly don't see a lot of downsides.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ