From patchwork Wed Jul 3 11:37:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Vincent_Stehl=C3=A9?= X-Patchwork-Id: 1956208 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WDd7x40hkz1xqb for ; Wed, 3 Jul 2024 21:38:21 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D7A0288811; Wed, 3 Jul 2024 13:38:10 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 15C0C882DB; Wed, 3 Jul 2024 13:38:09 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 1CFB2887E3 for ; Wed, 3 Jul 2024 13:38:07 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=vincent.stehle@arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8E4A71007; Wed, 3 Jul 2024 04:38:31 -0700 (PDT) Received: from localhost.localdomain (X72Y076X74.nice.arm.com [10.34.125.15]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id A7AA43F762; Wed, 3 Jul 2024 04:38:05 -0700 (PDT) From: =?utf-8?q?Vincent_Stehl=C3=A9?= To: u-boot@lists.denx.de Cc: =?utf-8?q?Vincent_Stehl=C3=A9?= , Simon Glass , Tom Rini , Heinrich Schuchardt , Ilias Apalodimas Subject: [PATCH v2 1/2] efi: move guid helper functions to efi.h Date: Wed, 3 Jul 2024 13:37:55 +0200 Message-ID: <20240703113756.1293218-2-vincent.stehle@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240703113756.1293218-1-vincent.stehle@arm.com> References: <20240627170629.2696427-1-vincent.stehle@arm.com> <20240703113756.1293218-1-vincent.stehle@arm.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Move the guidcmp() and guidcpy() functions to efi.h, near the definition of the efi_guid_t type those functions deal with. Signed-off-by: Vincent Stehlé Cc: Heinrich Schuchardt Cc: Ilias Apalodimas Cc: Tom Rini --- include/efi.h | 10 ++++++++++ include/efi_loader.h | 10 ---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/efi.h b/include/efi.h index c3c4b93f860..d5af2139946 100644 --- a/include/efi.h +++ b/include/efi.h @@ -78,6 +78,16 @@ typedef struct { u8 b[16]; } efi_guid_t __attribute__((aligned(4))); +static inline int guidcmp(const void *g1, const void *g2) +{ + return memcmp(g1, g2, sizeof(efi_guid_t)); +} + +static inline void *guidcpy(void *dst, const void *src) +{ + return memcpy(dst, src, sizeof(efi_guid_t)); +} + #define EFI_BITS_PER_LONG (sizeof(long) * 8) /* Bit mask for EFI status code with error */ diff --git a/include/efi_loader.h b/include/efi_loader.h index 6c993e1a694..ca8fc0820f6 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -21,16 +21,6 @@ struct blk_desc; struct jmp_buf_data; -static inline int guidcmp(const void *g1, const void *g2) -{ - return memcmp(g1, g2, sizeof(efi_guid_t)); -} - -static inline void *guidcpy(void *dst, const void *src) -{ - return memcpy(dst, src, sizeof(efi_guid_t)); -} - #if CONFIG_IS_ENABLED(EFI_LOADER) /** From patchwork Wed Jul 3 11:37:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Vincent_Stehl=C3=A9?= X-Patchwork-Id: 1956209 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WDd880mgXz1xqb for ; Wed, 3 Jul 2024 21:38:32 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4BF1188826; Wed, 3 Jul 2024 13:38:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 7000D8881C; Wed, 3 Jul 2024 13:38:10 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 405298880F for ; Wed, 3 Jul 2024 13:38:08 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=vincent.stehle@arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B41A81688; Wed, 3 Jul 2024 04:38:32 -0700 (PDT) Received: from localhost.localdomain (X72Y076X74.nice.arm.com [10.34.125.15]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id CD80E3F762; Wed, 3 Jul 2024 04:38:06 -0700 (PDT) From: =?utf-8?q?Vincent_Stehl=C3=A9?= To: u-boot@lists.denx.de Cc: =?utf-8?q?Vincent_Stehl=C3=A9?= , Simon Glass , Tom Rini , Heinrich Schuchardt , Ilias Apalodimas Subject: [PATCH v2 2/2] bootstd: cros: store partition type in an efi_guid_t Date: Wed, 3 Jul 2024 13:37:56 +0200 Message-ID: <20240703113756.1293218-3-vincent.stehle@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240703113756.1293218-1-vincent.stehle@arm.com> References: <20240627170629.2696427-1-vincent.stehle@arm.com> <20240703113756.1293218-1-vincent.stehle@arm.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean The scan_part() function uses a struct uuid to store the little-endian partition type GUID, but this structure should be used only to contain a big-endian UUID. Use an efi_guid_t instead and use guidcmp() for the comparison. Suggested-by: Heinrich Schuchardt Signed-off-by: Vincent Stehlé Cc: Simon Glass Cc: Tom Rini --- Changes for v2: - Use guidcmp() for the comparison, as suggested by Heinrich. boot/bootmeth_cros.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/boot/bootmeth_cros.c b/boot/bootmeth_cros.c index 645b8bed102..676f550ca25 100644 --- a/boot/bootmeth_cros.c +++ b/boot/bootmeth_cros.c @@ -147,7 +147,7 @@ static int scan_part(struct udevice *blk, int partnum, { struct blk_desc *desc = dev_get_uclass_plat(blk); struct vb2_keyblock *hdr; - struct uuid type; + efi_guid_t type; ulong num_blks; int ret; @@ -160,10 +160,10 @@ static int scan_part(struct udevice *blk, int partnum, /* Check for kernel partition type */ log_debug("part %x: type=%s\n", partnum, info->type_guid); - if (uuid_str_to_bin(info->type_guid, (u8 *)&type, UUID_STR_FORMAT_GUID)) + if (uuid_str_to_bin(info->type_guid, type.b, UUID_STR_FORMAT_GUID)) return log_msg_ret("typ", -EINVAL); - if (memcmp(&cros_kern_type, &type, sizeof(type))) + if (guidcmp(&cros_kern_type, &type)) return log_msg_ret("typ", -ENOEXEC); /* Make a buffer for the header information */