From 0a1bf35f5f0750ae281aaaa6305c4fedbeb6e47e Mon Sep 17 00:00:00 2001 From: Vincent Stehlé Date: Wed, 3 Jul 2024 13:37:55 +0200 Subject: efi: move guid helper functions to efi.h 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) /** -- cgit v1.2.3 From 1b1b1e7f6038047d425a75756333cadd037b3f64 Mon Sep 17 00:00:00 2001 From: Vincent Stehlé Date: Wed, 3 Jul 2024 13:37:56 +0200 Subject: bootstd: cros: store partition type in an efi_guid_t 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 --- 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 */ -- cgit v1.2.3