[U-Boot] [RESEND PATCH v2 2/6] efi_loader: Initial HII database protocols

Laszlo Ersek lersek at redhat.com
Tue Jan 8 00:28:00 UTC 2019


On 01/07/19 20:22, Leif Lindholm wrote:
> On Mon, Jan 07, 2019 at 07:29:47PM +0100, Laszlo Ersek wrote:

>> The UEFI spec (v2.7) explicitly requires EFI_GUID to be 64-bit aligned,
>> unless specified otherwise. See in "Table 5. Common UEFI Data Types":
>>
>>   EFI_GUID -- 128-bit buffer containing a unique identifier value.
>>               Unless otherwise specified, aligned on a 64-bit
>>               boundary.
> 
> Indeed.
> 
>> Whether edk2 satisfies that, and if so, how (by chance / by general
>> build flags), I don't know. The code says,
>>
>> ///
>> /// 128 bit buffer containing a unique identifier value.
>> /// Unless otherwise specified, aligned on a 64 bit boundary.
>> ///
>> typedef struct {
>>   UINT32  Data1;
>>   UINT16  Data2;
>>   UINT16  Data3;
>>   UINT8   Data4[8];
>> } GUID;
>>
>> I think there may have been an expectation in "MdePkg/Include/Base.h"
>> that the supported compilers would automatically ensure the specified
>> alignment, given the structure definition.
> 
> But that would be expecting things not only not guaranteed by C, but
> something there is no semantic information suggesting would be useful
> for the compiler to do above. [...]

Agreed. I'm not saying the edk2 code is right, just guessing why the
code might look like it does. This would not be the first silent
assumption, I think.

Anyhow, I think it would be better to change the code than the spec.

Thanks,
Laszlo


More information about the U-Boot mailing list