Re: [PATCH v3 08/26] x86/virt/seamldr: Retrieve P-SEAMLDR information
From: Dave Hansen
Date: Fri Jan 30 2026 - 11:35:28 EST
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.