From: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
To: Masahisa Kojima <masahisa.kojima@linaro.org>
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>, u-boot@lists.denx.de
Subject: Re: [PATCH] efi: use 32-bit alignment for efi_guid_t
Date: Fri, 27 Jan 2023 20:26:02 +0100 [thread overview]
Message-ID: <da233aee-2ea5-e03d-dc05-d859a654ae9a@canonical.com> (raw)
In-Reply-To: <20230127115128.5916-1-masahisa.kojima@linaro.org>
On 1/27/23 12:51, Masahisa Kojima wrote:
> Current U-Boot implements 64-bit boundary for efi_guid_t structure.
> It follows the UEFI specification, page 21 of the UEFI Specification v2.10
> says about EFI_GUID:
> 128-bit buffer containing a unique identifier value. Unless
> otherwise specified, aligned on a 64-bit boundary.
>
> On the other hand, page 163 of the UEFI specification v2.10 and
> EDK2 reference implementation both define EFI_GUID as
> struct { u32 a; u16; b; u16 c; u8 d[8]; }; and so the implied
> alignment is 32-bit not 64-bit like U-Boot efi_guid_t.
>
> Due to this alignment difference, EDK2 application "CapsuleApp.efi -P"
> does not work as expected.
> This calls EFI_FIRMWARE_MANAGEMENT_PROTOCOL.GetImageInfo()
> and dump the EFI_FIRMWARE_IMAGE_DESCRIPTOR structure,
> offsetof(EFI_FIRMWARE_IMAGE_DESCRIPTOR, ImageTypeId) is different,
> 8 in U-Boot and 4 in EDK2(CapsuleApp.efi).
> Here is the wrong EFI_GUID dump.
> wrong dump : ImageTypeId - 00000000-7D83-058B-D550-474CA19560D8
> expected : ImageTypeId - 058B7D83-50D5-4C47-A195-60D86AD341C4
>
> EFI_FIRMWARE_IMAGE_DESCRIPTOR structure is defined in UEFI specification:
> typedef struct {
> UINT8 ImageIndex;
> EFI_GUID ImageTypeId;
> UINT64 ImageId
> <snip>
>
> } EFI_FIRMWARE_IMAGE_DESCRIPTOR;
>
> There was the relevant patch for linux kernel to use 32-bit alignment
> for efi_guid_t [1].
> U-Boot should get aligned to EDK2 reference implementation and
> linux kernel.
>
> Due to this alignment change, efi_hii_ref structure in include/efi_api.h
> is affected, but it is not used in the current U-Boot code.
>
> [1] https://lore.kernel.org/all/20190202094119.13230-5-ard.biesheuvel@linaro.org/
>
> Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> ---
> include/efi.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/efi.h b/include/efi.h
> index 42f4e58a91..914a12967f 100644
> --- a/include/efi.h
> +++ b/include/efi.h
> @@ -56,7 +56,7 @@ struct efi_device_path;
>
> typedef struct {
> u8 b[16];
> -} efi_guid_t __attribute__((aligned(8)));
> +} efi_guid_t __attribute__((aligned(4)));
>
> #define EFI_BITS_PER_LONG (sizeof(long) * 8)
>
next prev parent reply other threads:[~2023-01-27 19:26 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-27 11:51 [PATCH] efi: use 32-bit alignment for efi_guid_t Masahisa Kojima
2023-01-27 14:18 ` Ilias Apalodimas
2023-01-28 4:47 ` Masahisa Kojima
2023-01-27 19:26 ` Heinrich Schuchardt [this message]
-- strict thread matches above, loose matches on Subject: below --
2019-01-08 15:28 Ard Biesheuvel
2019-01-08 15:28 ` Ard Biesheuvel
2019-01-08 15:53 ` Leif Lindholm
2019-01-08 15:53 ` Leif Lindholm
2019-01-08 16:22 ` Ard Biesheuvel
2019-01-08 16:22 ` Ard Biesheuvel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=da233aee-2ea5-e03d-dc05-d859a654ae9a@canonical.com \
--to=heinrich.schuchardt@canonical.com \
--cc=ilias.apalodimas@linaro.org \
--cc=masahisa.kojima@linaro.org \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.