From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Wed, 07 Jun 2023 14:08:51 +0200 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by lore.white.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q6ry8-00EJRz-IX for lore@lore.pengutronix.de; Wed, 07 Jun 2023 14:08:51 +0200 Received: from bombadil.infradead.org ([2607:7c80:54:3::133]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q6ry6-0003wn-4x for lore@pengutronix.de; Wed, 07 Jun 2023 14:08:50 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=17MlegKP/vnSeQT6q4tkA3Dn/FXnG1xceha1x0heII0=; b=Clenx/1O1dB2C15FUissZPG4KV 21SU1Lgbr20O1dGQAPhnQPgE2ItawkR1JaH9TuQH0axDPST7TKZw9zMQ46rHRsjTzI88LrEUYF1Tw StOjuCdaTwzVjy3XGQU6mp1N1vcmJ5/RoUpBckRs0Up+zyKOKjKvK6Psrr27dkdA0TeBS2sZ7Lu0q mkjL/8LGP9KccjQT8QYNLOx5/PIkVTadQUxY6YLrE/n+IzqQyCYV/qUeU1TRvS3S4GE6wClWr1XP+ yMjUl8mZdzMWUgpYfwR2i74sI4tO55BqwSXZsclQyUz2yixfr8/achE6A693XJYfUFZgtyK/RSDFU PKdYYO1w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6rwy-005kwr-1F; Wed, 07 Jun 2023 12:07:40 +0000 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6rwl-005knd-0k for barebox@lists.infradead.org; Wed, 07 Jun 2023 12:07:33 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q6rwi-000339-Hs; Wed, 07 Jun 2023 14:07:24 +0200 Received: from [2a0a:edc0:0:1101:1d::54] (helo=dude05.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1q6rwh-005jkK-QS; Wed, 07 Jun 2023 14:07:23 +0200 Received: from afa by dude05.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1q6rwe-00CyMN-UP; Wed, 07 Jun 2023 14:07:20 +0200 From: Ahmad Fatoum To: barebox@lists.infradead.org Cc: Ahmad Fatoum Date: Wed, 7 Jun 2023 14:06:57 +0200 Message-Id: <20230607120714.3083182-3-a.fatoum@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230607120714.3083182-1-a.fatoum@pengutronix.de> References: <20230607120714.3083182-1-a.fatoum@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230607_050727_266063_D2517900 X-CRM114-Status: GOOD ( 14.34 ) X-BeenThere: barebox@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "barebox" X-SA-Exim-Connect-IP: 2607:7c80:54:3::133 X-SA-Exim-Mail-From: barebox-bounces+lore=pengutronix.de@lists.infradead.org X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on metis.ext.pengutronix.de X-Spam-Level: X-Spam-Status: No, score=-4.9 required=4.0 tests=AWL,BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Subject: [PATCH v2 02/19] efi: define efi_guid_t as 32-bit aligned guid_t X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on metis.ext.pengutronix.de) Let's sync definition with Linux, so we are able to pass efi_guid_t types to function accepting guid_t. This has the added benefit of us starting to observe alignment, which may become relevant with barebox EFI on non-x86. Signed-off-by: Ahmad Fatoum --- v1 -> v2: - no change --- include/efi.h | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/include/efi.h b/include/efi.h index 3595cf05ccb7..1904caf3a4b6 100644 --- a/include/efi.h +++ b/include/efi.h @@ -14,6 +14,7 @@ */ #include #include +#include #ifdef CONFIG_EFI_BOOTUP #define EFIAPI __attribute__((ms_abi)) @@ -66,10 +67,20 @@ typedef u16 efi_char16_t; /* UNICODE character */ typedef u64 efi_physical_addr_t; typedef void *efi_handle_t; - -typedef struct { - u8 b[16]; -} efi_guid_t; +/* + * The UEFI spec 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 bits not 8 bits like our guid_t. In some cases (i.e., on 32-bit ARM), + * this means that firmware services invoked by the kernel may assume that + * efi_guid_t* arguments are 32-bit aligned, and use memory accessors that + * do not tolerate misalignment. So let's set the minimum alignment to 32 bits. + * + * Note that the UEFI spec as well as some comments in the EDK2 code base + * suggest that EFI_GUID should be 64-bit aligned, but this appears to be + * a mistake, given that no code seems to exist that actually enforces that + * or relies on it. + */ +typedef guid_t efi_guid_t __aligned(__alignof__(u32)); #define EFI_GUID(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \ ((efi_guid_t) \ -- 2.39.2