From patchwork Fri May 31 13:50:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 800536 Delivered-To: patch@linaro.org Received: by 2002:a5d:65c4:0:b0:35b:5a80:51b4 with SMTP id e4csp742118wrw; Fri, 31 May 2024 06:51:01 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV9H7Qq2+uew4d2cuCnoKnjuHRo5ofnOB1buxCjrk540Vy+iFLQOe7mNaYP7rc954xlPnRq/sf4p7TCJeXD06GB X-Google-Smtp-Source: AGHT+IFpI6o0t6aKW6nRwiDIyWm+HzodBM238792Pt5FuKI1Uz9ztyFyiL+k8heUJ2H7zHJuS4El X-Received: by 2002:a05:6512:46c:b0:523:8e07:5603 with SMTP id 2adb3069b0e04-52b895a0a73mr1211353e87.41.1717163461546; Fri, 31 May 2024 06:51:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717163461; cv=none; d=google.com; s=arc-20160816; b=v55eguTxkBsx9zliPOm7EqDHXtnIsbPwEZhwKIR7jYj8iT74B88gYl8RSiwkYIme5q yi+wUJvpj39f4r6WGG7LcKgdWoLQORdO49tsnX5abnkKggRoATpWpJrzpR77Sv4e0Fht kfPmAzAv5C3SfOsud3ldHTOoVEaOSVgztvh8U3su1KHGA1L6jlpyN9XHNubVsD5LXxh0 q+HThd4dKvgzDjJfW6Lb1OiEG9xBRco02QogD+GP2p6YGlfhkB6ZBjpNMn5+H2a8MPJF R/q8OGcf75ItC3jjHBBd6gitfczJYB1xv72VLEoNsX63OeRgY5oDyb3qfK81R6utVWlu PBOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=E0SxjaHgoia6tB2dELcQ+S5gH84D9tF+3xpd0qdBlFw=; fh=ECq9wuO88LH4ZVS/Lhaukn07OiSQ4TQYRRuVpZ/Oux8=; b=kDlNT9WrMuK4BG991tcHXVZT8QfdiaUgZLfwJQ+CRYvTJQRO2LFgdyo8CPOLij7emt 51HbMZUi0S9y5LA/sTtQb3fWxSJmURtkAXfJqvqgNCzLmF48hmAThLjBJYezvCiZd/l0 Jb893qqzlThDiM0kZ6JuPuSFFhuGhNsyY1H2ODellmukXMlCaIAUdke+iGETA+oKBN42 rbGB5Wk8nvJvCWfVyBVSkmpZ80nAURYDW7GikkHVZtaGOb2IZgcqDMa2jaeFMg9WZF2D pzYfxPXfFIsjIuIr4JwHNdAPkdVOfNlGmn5niC3phVdiLNmREzeN3fX3/6RGIr9Xq5AT D1sw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UYf4xNxW; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57a31cc9b25si958763a12.657.2024.05.31.06.51.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 06:51:01 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UYf4xNxW; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EF9478878B; Fri, 31 May 2024 15:50:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="UYf4xNxW"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F0A66882B8; Fri, 31 May 2024 15:50:49 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id DC9808831F for ; Fri, 31 May 2024 15:50:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-52b7dc424acso2138758e87.0 for ; Fri, 31 May 2024 06:50:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717163447; x=1717768247; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=E0SxjaHgoia6tB2dELcQ+S5gH84D9tF+3xpd0qdBlFw=; b=UYf4xNxWbaOMGYWYvqO/iQD9lUMpwvc+iOEjmKXP3/YIz2gq+rtjLgslXY+8vRyLya VxUJzyYc33WrTLvjHyS+AyVX/d2Vda8jimN0slsZHNjuv4UjQMToAL0swIWXbjeqmDYJ Qij3ZxnolaQ3J6ZhyGAn1i8L6y3QpEIKXHutRq+mTNFQhYzNWGQLaxEzUV9vNxyrpMJi hUVfxtOADOKp2HL1XxcbVt8mNCpUomCXYWebZZDxSee6act2AiJL6iU7IlEKiJ2Wqqo7 7ZDLwgdVovlqYERqLN1RVqWMY73q8MqZnxLlwc4oF3jB/XIcOMWzCqyPLu2AMeF7zdww hmig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717163447; x=1717768247; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=E0SxjaHgoia6tB2dELcQ+S5gH84D9tF+3xpd0qdBlFw=; b=LiXrs7vMRMcm4qf/MvbqiJQfrrFyyDUomH897E6zAdftogTYZuVAN7IQA91svqlFbe 06U43pI2bGgzq7G+P3aUZJm1F1mwGttmusBBogePtHGtB0Uwtw5w21NlWrlamE5Dwk0c CPuh8XH806cubprOdlDx9aOszqXr6u4Wba+K3br5RCfKdPlytK4L3lHeVJw40ylaLy/j B6Vgfq6FUlvggEiynNDyDR+hxyNLuhLTtnm89dSCHFy4uFgG4/EHrMPFYnIY7N2/XsbM 02EhpOKas5wSv3Uyw4esnedkcmTeMvWoPM1xh1GTcA0RX8onfQJdmoOyryU4oYbeq6ky rhag== X-Forwarded-Encrypted: i=1; AJvYcCVatC5qmZ/0/e1kx0iHdatjqp0YwFaUB3qoXawYdBmoACH8en0QAkKazSWQq6oWBzElmT3+8M0VjJh/h8ZqapXSlTGAZw== X-Gm-Message-State: AOJu0YxBMklkU4Z93pvJTtP6BW4RlsdB2RU6iPHyXiJrzC2OVNWFytCg 8H+CVdnHIH6lfmdP7jFmMCW6/Nl7uwGzxnM/fV+V7g3vySsaCg99D3Ups4WbGi4= X-Received: by 2002:a05:6512:4898:b0:516:d692:5e0b with SMTP id 2adb3069b0e04-52b896cbe90mr1124628e87.54.1717163447039; Fri, 31 May 2024 06:50:47 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::8090]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a67eab84a99sm89442866b.143.2024.05.31.06.50.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 06:50:46 -0700 (PDT) From: Caleb Connolly Date: Fri, 31 May 2024 15:50:35 +0200 Subject: [PATCH v3 1/7] lib: uuid: add UUID v5 support MIME-Version: 1.0 Message-Id: <20240531-b4-dynamic-uuid-v3-1-ca4a4865db00@linaro.org> References: <20240531-b4-dynamic-uuid-v3-0-ca4a4865db00@linaro.org> In-Reply-To: <20240531-b4-dynamic-uuid-v3-0-ca4a4865db00@linaro.org> To: Tom Rini , Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Mario Six , Alper Nebi Yasak , Abdellatif El Khlifi Cc: Richard Hughes , u-boot@lists.denx.de, Caleb Connolly X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=4109; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=gsSuV5MW3EKgQQRwAD6xb2/96AMgilhrIVh4AHK7v+A=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmWdWzrTH1Dkf0AlhCZCpXTKQia66NhuWrLFR5Z 1C8ytWa0Y+JAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZlnVswAKCRAFgzErGV9k tt5xD/0Ri9PSCIxdzdMy0IzAVUAzZ0eJLbFjYb6oyyOIgCJFDflrveF0HgVyVjz4muWPAcmop1r Pa0jrzP9fBLG+7R4C326yKM5HXO5bOLENqpQXOPFXXdw9IuERZgKs1gO/hwGTmgmmGp21Z9OSvQ q5o1HqZXG8Yegu2hG+g79F7TGqULEsaSWr/lD0T5dRmkWEEVtLuKi5k+FitSZYrJdH3IVzxLqzw UAdi06hT79aBJnFG3FjSp9mBNrxdgKrMEyhWu5xRH3o52+irrWj+hlSSx1jYgbzqt4etjCkYGlY QvT5ltT9/0QI6S906UITRlmm9F+vSZHgGJ+xQw406nvlleBAQOKcZN9XyasOeETUFDTBd9lreDU 4WBQ8UwP8MUXPjjIRnis3e/WVZqhP9dGNHfOXmbXWkMmVhTMzDErzn/oHyJnk1GSzObuRxxvvTD 5lbRfqZkjzbR0h9LHRcpvp6m8Q0udSyGa+53ajphGaYGJRsJ2f6E0y8kNSfFZIsXq3Do8/UzC9D p6CZB47JTbvOlA/kmCDpIQtvpBgxla0QOdS0JD80JmJ1QdR/YH3lOY+XuVhcO9v0GPE2zBhoI4m 9OYSsqRBJ9qDzUAbKzF6KoEsCXK2hF6JxNOG1uG4K9ymNL7D0af+ImfzSUvqom0RCCglaC6yRua NCMacR8dTl5U+zw== X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 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 Add support for generating version 5 UUIDs, these are determistic and work by hashing a "namespace" UUID together with some unique data. One intended usecase is to allow for dynamically generate payload UUIDs for UEFI capsule updates, so that supported boards can have their own UUIDs without needing to hardcode them. Tests for this are added in an upcoming patch. Signed-off-by: Caleb Connolly --- include/uuid.h | 17 +++++++++++++++++ lib/Kconfig | 8 ++++++++ lib/uuid.c | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) diff --git a/include/uuid.h b/include/uuid.h index f5a941250f48..539affaa47b9 100644 --- a/include/uuid.h +++ b/include/uuid.h @@ -10,8 +10,9 @@ #ifndef __UUID_H__ #define __UUID_H__ #include +#include /* * UUID - Universally Unique IDentifier - 128 bits unique number. * There are 5 versions and one variant of UUID defined by RFC4122 @@ -142,8 +143,24 @@ void gen_rand_uuid(unsigned char *uuid_bin); * @param - uuid output type: UUID - 0, GUID - 1 */ void gen_rand_uuid_str(char *uuid_str, int str_format); +#if IS_ENABLED(CONFIG_UUID_GEN_V5) +/** + * gen_uuid_v5() - generate UUID v5 from namespace and other seed data. + * + * @namespace: pointer to UUID namespace salt + * @uuid: pointer to allocated UUID output + * @...: NULL terminated list of seed data as pairs of pointers + * to data and their lengths + */ +void gen_uuid_v5(const struct uuid *namespace, struct uuid *uuid, ...); +#else +static inline void gen_uuid_v5(const struct uuid *namespace, struct uuid *uuid, ...) +{ +} +#endif + /** * uuid_str_to_le_bin() - Convert string UUID to little endian binary data. * @uuid_str: pointer to UUID string * @uuid_bin: pointer to allocated array for little endian output [16B] diff --git a/lib/Kconfig b/lib/Kconfig index 189e6eb31aa1..2941532f25cf 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -80,8 +80,16 @@ config RANDOM_UUID help Enable the generation of partitions with random UUIDs if none are provided. +config UUID_GEN_V5 + bool "Enable UUID version 5 generation" + select LIB_UUID + depends on SHA1 + help + Enable the generation of version 5 UUIDs, these are determistic and + generated from a namespace UUID, and a string (such as a board name). + config SPL_LIB_UUID depends on SPL bool diff --git a/lib/uuid.c b/lib/uuid.c index dfa2320ba267..2df0523e717f 100644 --- a/lib/uuid.c +++ b/lib/uuid.c @@ -21,8 +21,9 @@ #include #include #include #include +#include int uuid_str_valid(const char *uuid) { int i, valid; @@ -368,8 +369,44 @@ void uuid_bin_to_str(const unsigned char *uuid_bin, char *uuid_str, } } } +#if IS_ENABLED(CONFIG_UUID_GEN_V5) +void gen_uuid_v5(const struct uuid *namespace, struct uuid *uuid, ...) +{ + sha1_context ctx; + va_list args; + const uint8_t *data; + uint8_t hash[SHA1_SUM_LEN]; + uint32_t tmp; + + sha1_starts(&ctx); + /* Hash the namespace UUID as salt */ + sha1_update(&ctx, (unsigned char *)namespace, UUID_BIN_LEN); + va_start(args, uuid); + + while ((data = va_arg(args, const uint8_t *))) { + unsigned int len = va_arg(args, size_t); + + sha1_update(&ctx, data, len); + } + + va_end(args); + sha1_finish(&ctx, hash); + + /* Truncate the hash into output UUID, it is already big endian */ + memcpy(uuid, hash, sizeof(*uuid)); + + /* Configure variant/version bits */ + tmp = be32_to_cpu(uuid->time_hi_and_version); + tmp = (tmp & ~UUID_VERSION_MASK) | (5 << UUID_VERSION_SHIFT); + uuid->time_hi_and_version = cpu_to_be32(tmp); + + uuid->clock_seq_hi_and_reserved &= UUID_VARIANT_MASK; + uuid->clock_seq_hi_and_reserved |= UUID_VARIANT << UUID_VARIANT_SHIFT; +} +#endif + #if defined(CONFIG_RANDOM_UUID) || defined(CONFIG_CMD_UUID) void gen_rand_uuid(unsigned char *uuid_bin) { u32 ptr[4]; From patchwork Fri May 31 13:50:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 800537 Delivered-To: patch@linaro.org Received: by 2002:a5d:65c4:0:b0:35b:5a80:51b4 with SMTP id e4csp742205wrw; Fri, 31 May 2024 06:51:12 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUDdZhVKy9M+9Dh7eNLx3IpHN8hw+EKt9nP2J61k7Vj8x8++canU5CUGQ/Sd8ch9MMqfMShVk+yiAiDPNjEeH2I X-Google-Smtp-Source: AGHT+IES4Sc1cA5lSVB1zO4E77v9PZLdZIubTjUWaBvypDZWIQ7fjLLV8oyoLnexJcFhsned70ci X-Received: by 2002:a17:907:7241:b0:a62:415b:b5c with SMTP id a640c23a62f3a-a681fc5bffemr174649366b.5.1717163471875; Fri, 31 May 2024 06:51:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717163471; cv=none; d=google.com; s=arc-20160816; b=pYndhEWI1rdrONAwpYFf6Akae0iNvetCwCpQMCoplarIcCnykckNlyG76LVwLlAC77 E8dGcZPdY5KKkyDmB7Nmvzr3WBsmtdns7USzLlt8qGa0NtTHwI1gCLHbzB8B/7GiNLaL jllBvWI2rsiM225Cv0BKzSTq8+Ch4cZ7+H1eJy0wklfDU90toGVa48NtCtJac2FI7WQS hneBDlStghlYNjVJRhRCK70JdmrFT/D4b+pNKTE3inQqINRKFjkY1sb4X0eXhfj2il7V gkfO6zYzghbbX/B+Gd/Tk79ZW7nlwozLBZsxuyns47DZD3TGq3DXdzRPytcx/YYhrKSj SroQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=1Y28ZRmJZXP44Z5xd4CjT1ucROldm5l5ZmxQKzCTuTk=; fh=tYMancR2ghlwwItUOTnH01pPksPyW2F8u5piEgqVOKw=; b=bd4o+ekxNnDBlXOsi7dhX5MTt3n/tAZXK7c4D+LZ9faNDgOzXT0F7FS+JzxM0qKBHD VQdit3vc52get1BEng0r4tK27BYS/zQeW6+7oHNuEbpAdeNOAZ0ivKMJiSH34zdq0XBC gkh2/vhaE6odg1VvG/jt6ICW0kK6oi3MBH8pJEJbjSiUSfxhKHonip1CG32I4Dfqj9AJ V+prNU0OYDKmWk3lJ41K1/2PUfDvoS0seyNzzkLWrJBjs21jY3DMV7poSGdTyzSdsqJR jhRRXnXSiUruso7F3+sXOlMVDbkXQ6vasE8Jq3YagbOvrT3LIf8CPBkeokfXGFTW0Nxo RKbw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="a9rz9r/z"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id a640c23a62f3a-a67ea8861fcsi93306466b.500.2024.05.31.06.51.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 06:51:11 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="a9rz9r/z"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5AAEB887B5; Fri, 31 May 2024 15:50:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="a9rz9r/z"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3942E887B2; Fri, 31 May 2024 15:50:51 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D85488878B for ; Fri, 31 May 2024 15:50:48 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-a6265d3ba8fso190300666b.0 for ; Fri, 31 May 2024 06:50:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717163448; x=1717768248; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=1Y28ZRmJZXP44Z5xd4CjT1ucROldm5l5ZmxQKzCTuTk=; b=a9rz9r/zQnUJgUL9IWuruECM92cdP5pbmNr/Dlycy5/gwPkGRBFyOUypYId5kfTuw0 ZQTlgcxbj4a5ZnKFvbB7RQEsUG1xtq4M3Qfyb32+NpazB1jNW75yKsUc6BQC6tnXvKek 6Umvq1dxvjtxiYyX0JVf2aBHWl4FY7GGj3BuqJFnRKM9SwTkgzrnSaNKTltC8+inqxrl s8eC31vWocyhcEBwVou9oWpDhQ1AyeL4IORgfCF5PuZe3gz5fu/NbtanZt54r89own2u 59C7AanMQUbRNbrM+pmrWlKBf4C7PJDqcJboXb/TAyM8wbZ54jpaT0TPxD8a7Uf0Zy2o IFuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717163448; x=1717768248; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1Y28ZRmJZXP44Z5xd4CjT1ucROldm5l5ZmxQKzCTuTk=; b=jU7l9p43d2pkx3c18pQdzaKDeUUSuJaVybxnJeSt/cpZLxWaQZSE6rqtuN9qc2Mnxl 4CTGjMkZGsA88KJGWJ9tSvuMY1AJ3LwsmKbz6Lj9PcIWgaVDE82GAYhdE+HCtZkFn8cf fDplQE7aCWRoiBMut8T1SQEknpolpfnMpe2g5LE/dzGlJeOq44KAw+5wXK3MqZG2DVeB 24ccrXJum97Ho08l4bYg+pQWUEn4m5UORXARXOxdMy2jzPIwhg9uC28TM9KQ82gNDhTZ LGyjO+2MtkrJ83hoyEwrNdldM5Si8N0uVs2QedYWbqTpX4CEhqDJliORwTAOwoAVPzMS BCuQ== X-Forwarded-Encrypted: i=1; AJvYcCXIm61wNfqTYcwsTfSUFYQ8yFgQtqo/vKjYmmoP8+WeekDs0VuSgAJFUxD2IQd4dote7tINfhgnwqyPyKWGsLyW8v1pew== X-Gm-Message-State: AOJu0YzHAOX8grOHzpuFXd1vrueQOGd8gg6lVWJWXp7GGn7cPvYx3b5r gjtOWAJaTcw4vTEVsbe2WWACJdsYj/bnPdtAeHcrlfmeNWhN3thhzY5dlcg/Olw= X-Received: by 2002:a17:906:1911:b0:a68:9086:cbdf with SMTP id a640c23a62f3a-a689086cc6amr59200666b.40.1717163448216; Fri, 31 May 2024 06:50:48 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::8090]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a67eab84a99sm89442866b.143.2024.05.31.06.50.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 06:50:47 -0700 (PDT) From: Caleb Connolly Date: Fri, 31 May 2024 15:50:36 +0200 Subject: [PATCH v3 2/7] efi: add a helper to generate dynamic UUIDs MIME-Version: 1.0 Message-Id: <20240531-b4-dynamic-uuid-v3-2-ca4a4865db00@linaro.org> References: <20240531-b4-dynamic-uuid-v3-0-ca4a4865db00@linaro.org> In-Reply-To: <20240531-b4-dynamic-uuid-v3-0-ca4a4865db00@linaro.org> To: Tom Rini , Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Mario Six , Alper Nebi Yasak , Abdellatif El Khlifi Cc: Richard Hughes , u-boot@lists.denx.de, Caleb Connolly X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=5425; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=ihik6rOObYTcfAQqc+c7iPdePVxUCgEjrkSBDa9glj8=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmWdWzkkCxI0Kd7jKogoqhUuysy8Am5n0P9sTS7 0anfDect2+JAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZlnVswAKCRAFgzErGV9k tqESD/9xe0eZIfnRPO82r5jxBF62DTS4qHcFWypxkE7IUo2LqZXkeizpbc1m9zkv6Tm2SwK3qzT ssDVjXlk/lEqTNs7KXTwY0G/WddLlINqgNZBNdvg4nNb7mEAKVJNKrQxzarsPjneIdDbsCN0jV2 O5TCL5rxruB6IjqGNLovMVGo5j/mZEHNqQEFcKp5KR2cxhSia9nWPUt8UJo1cL5TLpUcB1gfh+G lnyBct/6QRVIu11NfX00gomr9EBtd+U9A92dtZS9anxq+ReKYlViMwxe++xNgfG1A5d0a7h2N6c C8CD+G/Xbj6FXSQY9DwjVAKsG8AkKG4hEZXVZRFTP7gBRnUw5IeAVhXo2bp1Yl+eVjCE4nR4eJe oPjBdNcMpHfAcDyce7JL9MePTmS0PSdV+TMdSycfb/gr5pBUc21ihc4zNwye87sgZ1I7YGdyACr nCKYVdlCzdN7rMe6nF8OJFl7LNxL+IBGNlT5wjmAgkLK0i178H+AfL28cEi+a69WeofsCVzEkcm L4A2lm5OjB1NLJeR9DVtXPHP1Zm4Kc3QSqtAHwurdJBdiLCJk3LxIQ/t3HPz5GtOsqajZt2GMqX zrBOWpcR2/xGFiylk2SNCguF7lc2jIbc4rkBE40I7IJO0KmQTpnZP8qTaAb8iZxEVl0zZ2HkJ+O CPLNocn+C8x0H7w== X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 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 Introduce a new helper efi_capsule_update_info_gen_ids() which populates the capsule update fw images image_type_id field. This allows for determinstic UUIDs to be used that can scale to a large number of different boards and board variants without the need to maintain a big list. We call this from efi_fill_image_desc_array() to populate the UUIDs lazily on-demand. This is behind an additional config option as it depends on V5 UUIDs and the SHA1 implementation. Signed-off-by: Caleb Connolly --- lib/efi_loader/Kconfig | 23 +++++++++++++++ lib/efi_loader/efi_capsule.c | 1 + lib/efi_loader/efi_firmware.c | 66 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+) diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index 430bb7f0f7dc..e90caf4f8e14 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -235,8 +235,31 @@ config EFI_CAPSULE_ON_DISK_EARLY If this option is enabled, capsules will be enforced to be executed as part of U-Boot initialisation so that they will surely take place whatever is set to distro_bootcmd. +config EFI_CAPSULE_DYNAMIC_UUIDS + bool "Dynamic UUIDs for capsules" + depends on EFI_HAVE_CAPSULE_SUPPORT + select UUID_GEN_V5 + help + Select this option if you want to use dynamically generated v5 + UUIDs for your board. To make use of this feature, your board + code should call efi_capsule_update_info_gen_ids() with a seed + UUID to generate the image_type_id field for each fw_image. + + The CapsuleUpdate payloads are expected to generate matching UUIDs + using the same scheme. + +config EFI_CAPSULE_NAMESPACE_UUID + string "Namespace UUID for dynamic UUIDs" + depends on EFI_CAPSULE_DYNAMIC_UUIDS + help + Define the namespace or "salt" UUID used to generate the per-image + UUIDs. This should be a UUID in the standard 8-4-4-4-12 format. + + Device vendors are expected to generate their own namespace UUID + to avoid conflicts with existing products. + config EFI_CAPSULE_FIRMWARE bool config EFI_CAPSULE_FIRMWARE_MANAGEMENT diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c index 0937800e588f..ac02e79ae7d8 100644 --- a/lib/efi_loader/efi_capsule.c +++ b/lib/efi_loader/efi_capsule.c @@ -19,8 +19,9 @@ #include #include #include #include +#include #include #include #include diff --git a/lib/efi_loader/efi_firmware.c b/lib/efi_loader/efi_firmware.c index ba5aba098c0f..a8dafe4f01a5 100644 --- a/lib/efi_loader/efi_firmware.c +++ b/lib/efi_loader/efi_firmware.c @@ -244,8 +244,71 @@ void efi_firmware_fill_version_info(struct efi_firmware_image_descriptor *image_ free(var_state); } +#if CONFIG_IS_ENABLED(EFI_CAPSULE_DYNAMIC_UUIDS) +/** + * efi_capsule_update_info_gen_ids - generate GUIDs for the images + * + * Generate the image_type_id for each image in the update_info.images array + * using the first compatible from the device tree and a salt + * UUID defined at build time. + * + * Returns: status code + */ +static efi_status_t efi_capsule_update_info_gen_ids(void) +{ + int ret, i; + struct uuid namespace; + const char *compatible; /* Full array including null bytes */ + struct efi_fw_image *fw_array; + + fw_array = update_info.images; + /* Check if we need to run (there are images and we didn't already generate their IDs) */ + if (!update_info.num_images || + memchr_inv(&fw_array[0].image_type_id, 0, sizeof(fw_array[0].image_type_id))) + return EFI_SUCCESS; + + ret = uuid_str_to_bin(CONFIG_EFI_CAPSULE_NAMESPACE_UUID, + (unsigned char *)&namespace, UUID_STR_FORMAT_GUID); + if (ret) { + log_debug("%s: CONFIG_EFI_CAPSULE_NAMESPACE_UUID is invalid: %d\n", __func__, ret); + return EFI_UNSUPPORTED; + } + + compatible = ofnode_read_string(ofnode_root(), "compatible"); + + if (!compatible) { + log_debug("%s: model or compatible not defined\n", __func__); + return EFI_UNSUPPORTED; + } + + if (!update_info.num_images) { + log_debug("%s: no fw_images, make sure update_info.num_images is set\n", __func__); + return -ENODATA; + } + + for (i = 0; i < update_info.num_images; i++) { + gen_uuid_v5(&namespace, + (struct uuid *)&fw_array[i].image_type_id, + compatible, strlen(compatible), + fw_array[i].fw_name, u16_strsize(fw_array[i].fw_name) + - sizeof(uint16_t), + NULL); + + log_debug("Image %ls UUID %pUs\n", fw_array[i].fw_name, + &fw_array[i].image_type_id); + } + + return EFI_SUCCESS; +} +#else +static efi_status_t efi_capsule_update_info_gen_ids(void) +{ + return EFI_SUCCESS; +} +#endif + /** * efi_fill_image_desc_array - populate image descriptor array * @image_info_size: Size of @image_info * @image_info: Image information @@ -282,8 +345,11 @@ static efi_status_t efi_fill_image_desc_array( return EFI_BUFFER_TOO_SMALL; } *image_info_size = total_size; + if (efi_capsule_update_info_gen_ids() != EFI_SUCCESS) + return EFI_UNSUPPORTED; + fw_array = update_info.images; *descriptor_count = update_info.num_images; *descriptor_version = EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION; *descriptor_size = sizeof(*image_info); From patchwork Fri May 31 13:50:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 800538 Delivered-To: patch@linaro.org Received: by 2002:a5d:65c4:0:b0:35b:5a80:51b4 with SMTP id e4csp742278wrw; Fri, 31 May 2024 06:51:23 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWgSu5IuXCY5Si3JOdbfvjREPy7q23Yu7QNwNSe38RhVQBnJinLrmnII0K9CZ407llY7VAp8nthLCuq+mKb8NS5 X-Google-Smtp-Source: AGHT+IFzFQpCJL2JsCNfhPRLb1o/TExcLE0P95HLxPAJHeRhA+5iGvc7B0FIuTE+kIpI1iurxzcN X-Received: by 2002:a50:9f61:0:b0:57a:33ff:ff1c with SMTP id 4fb4d7f45d1cf-57a3638f9dfmr1756477a12.21.1717163483608; Fri, 31 May 2024 06:51:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717163483; cv=none; d=google.com; s=arc-20160816; b=pFBViEiQdwWMglQwTekspY0H/dWCY/FmzwLA84gK0yq2j6x7VYyexGogK1T5Ojjj2S ZV9Uva1gEbd/z3+/xbjgAamdRsCKBW7OGKLd9riAA61hEwGxyG1rTl8taFE+cg3i9fde L8XmukbwocDdZrflWe4o76PdeObS6nJ2AE9RA/LUumA435Jiokhe7JLNqWXxgZ1dCwZI mmnyF9SgXOPiLbukWu/T+b2D5/qKPgavfcWrIaorTgN5nR952FYnBDBvp8K78oMu3Uq8 raUsxThCej+pOgjSj8NktLT9/coBZss2oyfbs/k02YamoAnlRbeq/mtl9UQqUWix8nlL P7dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=mTiLq4D9w02Ubiegl8WaAhqf5gqlLgN++TAyAUTr66s=; fh=PQjsF9r4CQvJobIQwG7/9ggtDl+HkY2CanHIcwxICL0=; b=Rlj03CDma5NTfdEweFv5rNgYpjmJTNA69rNnfe2D+5KbKMgnxb+MJBttKkZ8qIdXur nXMMHvs043H7oaViWCUGFrKgVnrcLn4Nfw3cIBqF1FW490MbhnaTBz15B3udpEyHFWau 3ptWdOLiyOv50uwIAcDg9p9/ri9ClYIzfS0iz+obdwUq5zVLP8QnEAv+Iv5sdEDDCUZg 0V+ivvLzuFHhUPk3d9PHmnTCEd365dWyX96hqPO6LgvGjLdk68KKQTiNYZsgVsTRrpH4 TVNRXUZRa1ccpS4hOJjykpormkUblBpXXwVW00cKW+Ck+F9e9I8ENROo8VcR/9LunFaa 15kw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=w0lWhrby; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id a640c23a62f3a-a67ea38d85dsi94598166b.421.2024.05.31.06.51.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 06:51:23 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=w0lWhrby; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BF22A887C2; Fri, 31 May 2024 15:50:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="w0lWhrby"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 272BC8878B; Fri, 31 May 2024 15:50:52 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 297FB882B8 for ; Fri, 31 May 2024 15:50:50 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-lj1-x229.google.com with SMTP id 38308e7fff4ca-2e95a1d5ee2so37445331fa.0 for ; Fri, 31 May 2024 06:50:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717163449; x=1717768249; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=mTiLq4D9w02Ubiegl8WaAhqf5gqlLgN++TAyAUTr66s=; b=w0lWhrbyKJgNG51zMZWfVmqIJ3QEMn5F5srVbQenNYTpvAmrROPDV79XcYFnPgrx3i Vi1pjorkL+4UScNrat4BwV56YHZ13ycEUlSjXonm+JEYhwwPHANlZAaKrgmpDk3OOim0 RQxEh8mdNFLTxU4fyvYo8gWVjQHXW3x/uyjqqnZoqLWzfhbbIWDieRIf1qkJZhM2F0vi mEUfkag965J7B+qOs28ie26HiY9YUKXgrHtX2XL4/X/Wz+zVarl+Kp3GBPGyPZry9tl+ NlyOlPt+k3I3ZwRopN7Ozu5t+WCkP/zElccqLx4mskWTj9ExW0yr/LKjnATmAsK5ekYm F5bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717163449; x=1717768249; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mTiLq4D9w02Ubiegl8WaAhqf5gqlLgN++TAyAUTr66s=; b=U2IjKnjsYgXXh6Cn0fgJwwyoor3bGkcY75KsoIFfgGjgInQvj6Llq4CM0JAoMNr0eO agA7rx7xvthXlijP9hcB/SJw6efI/Z5PrObBH2xEt/d/hNHofR8E1JB2pdRD5fMtUSxg sTWcR58biI7Zlw4X4vi9jT9y7Nq9Md1MfeNF2TNbiIOaMa0ASfyp43bflXYZAqqOyxxk QV0bHXDzCMX+v+WZH6LtozhNvI4FLERAKeqcNtO43BSd7Dk5n0Zs+k+DPPU+J3rIcqTM ycI4pQn5kfUCSQzcqbt8i2NM1wiHXxBx3sqHPGJdfY1JU0fb5Q8VTHL5oajmIA7FwwfF aKBw== X-Forwarded-Encrypted: i=1; AJvYcCVojPhQ5+yzfgslaNcZprim90uA0XiTephztDyJbN1/6aFgaUGErP/o10bXmoNJlvO+i16VRAJ2zxBA3ENipcgZaWFJ/w== X-Gm-Message-State: AOJu0YwulwNVc+EKeci3OYPGsOjmvAeK7X5N2OKlXCJQRtgbPQGHThOv TAPXIwC1n/qrFF1yqmp/+JDr+noqYtGu+uQjqnjc64yPwrGClzPVurVkwBAg1DY= X-Received: by 2002:a05:651c:2112:b0:2ea:7dc3:bdc with SMTP id 38308e7fff4ca-2ea951ddecfmr21055771fa.40.1717163449422; Fri, 31 May 2024 06:50:49 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::8090]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a67eab84a99sm89442866b.143.2024.05.31.06.50.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 06:50:48 -0700 (PDT) From: Caleb Connolly Date: Fri, 31 May 2024 15:50:37 +0200 Subject: [PATCH v3 3/7] doc: uefi: document dynamic UUID generation MIME-Version: 1.0 Message-Id: <20240531-b4-dynamic-uuid-v3-3-ca4a4865db00@linaro.org> References: <20240531-b4-dynamic-uuid-v3-0-ca4a4865db00@linaro.org> In-Reply-To: <20240531-b4-dynamic-uuid-v3-0-ca4a4865db00@linaro.org> To: Tom Rini , Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Mario Six , Alper Nebi Yasak , Abdellatif El Khlifi Cc: Richard Hughes , u-boot@lists.denx.de, Caleb Connolly X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2358; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=aM8qt0vJ1DRPyAhuqT6v0n4vqhUxMhwVttmyUp/d080=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmWdWzWd+yeJEcysyW0xUyGdDwZpXjrHXayC/MH tEOzjvGkOaJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZlnVswAKCRAFgzErGV9k tskhEACKevaI0X1GAwIrrkbxJMIlgT2B0UIdP6Ns27yPATNnJmmi79SNZOXjPFJLp3Rla0ZyYvK RvoM22UHLsS+Vomp72sYapg8tKa1gPlbRuFmz6HxN9581Zw4KRJmKAoi2GDIkHRmiOuzH7LZoUj ZMkX01r5K4rTzHUwBauB5XYqNnXcxFGh1PEgD+d4j3t5IrNlchx9UkOQLv7ybhow+U9g72glVqJ YjBeh3VQ62Nc0Q55NVEcO/3CoMEHCZcnKWhBSSfDA2Fbp7rvmyKsVU3Xf9UzLsMUF/WLB8EZI7E eJes58dDrusU/ENvcQzYHzFmsZ8ystYa8cN0EP5wtVz2UjGoIqz2mcH3Ag+NAijfBYhv//gRapU 0YzidWVmGcumBQ6SOicBRKmngvZ/NZ84XOZWb11azJ36NtgHBRf0eh4QhfxbELHAs4M5fyVKUv6 n4HyItaVPXbPTbiyTC+Z0l4qAxqXRouuqSbj/vpKh84hRqIbsbn6oYSM+4v/0DuVyMtZBM3RM48 sx5T2fISxF9X/cnOy8Uj7pSjo8IaebjmUjDsySPAZcHhGdfZfneO50mppz0iPJLci3VvNxLTtbg Rkh5UPoZiV6025+6p3rZSqEso/HpA76pn1oqX10V5iJIvEbFVIhmpPV+oAg1XZwQIcdIEN/zgCn euhuR3YHVWrwvag== X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 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 Document how platforms can generate GUIDs at runtime rather than maintaining a list of UUIDs per-board. Reviewed-by: Ilias Apalodimas Signed-off-by: Caleb Connolly --- doc/develop/uefi/uefi.rst | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/doc/develop/uefi/uefi.rst b/doc/develop/uefi/uefi.rst index 0389b269c01b..0b60702c052a 100644 --- a/doc/develop/uefi/uefi.rst +++ b/doc/develop/uefi/uefi.rst @@ -448,8 +448,39 @@ the location of the firmware updates is not a very secure practice. Getting this information from the firmware itself is more secure, assuming the firmware has been verified by a previous stage boot loader. +The image_type_id contains a GUID value which is specific to the image +and board being updated, that is to say it should uniquely identify the +board model (and revision if relevant) and image pair. Traditionally, +these GUIDs are generated manually and hardcoded on a per-board basis, +however this scheme makes it difficult to scale up to support many +boards. + +To address this, v5 GUIDs can be used to generate board-specific GUIDs +at runtime, based on a set of persistent identifiable information: + +.. code-block:: c + + /** + * efi_capsule_update_info_gen_ids - generate GUIDs for the images + * + * Generate the image_type_id for each image in the update_info.images array + * using the model and compatible strings from the device tree and a salt + * UUID defined at build time. + * + * Returns: status code + */ + static efi_status_t efi_capsule_update_info_gen_ids(void); + +These strings are combined with the fw_image name to generate GUIDs for +each image. Support for dynamic UUIDs can be enabled by turning on +CONFIG_EFI_CAPSULE_DYNAMIC_UUIDS, generating a new namespace UUID and +setting CONFIG_EFI_CAPSULE_NAMESPACE_UUID to it. + +The genguid tool can be used to determine the GUIDs for a particular board +and image. It can be found in the tools directory. + The firmware images structure defines the GUID values, image index values and the name of the images that are to be updated through the capsule update feature. These values are to be defined as part of an array. These GUID values would be used by the Firmware Management From patchwork Fri May 31 13:50:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 800539 Delivered-To: patch@linaro.org Received: by 2002:a5d:65c4:0:b0:35b:5a80:51b4 with SMTP id e4csp742395wrw; Fri, 31 May 2024 06:51:36 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW3/NlWr5nTP0CVJNcEpuwOuuNIE5Dy/PoIQ5BJT+Jnjfwm3yHvl/Up1aT6Mk1vmvOkf9Zh1gK+MRrslvIYz0UX X-Google-Smtp-Source: AGHT+IGH4CQLPiX4b22wilAlwy5c6ZpjU/OvaWz41OKWw9azcPHuZ4ll7IqbvaDSkgYaUx78znh5 X-Received: by 2002:a17:907:20b5:b0:a59:aae5:5837 with SMTP id a640c23a62f3a-a6820902273mr139547566b.44.1717163496409; Fri, 31 May 2024 06:51:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717163496; cv=none; d=google.com; s=arc-20160816; b=ZN66/101xI37Am+I8kX4x7coXNvWOzSc4jqjmy6JVxwfRg9dYMbDGXCd2lUHeRJ1Yn FB4zYvfZPFUvDSnGFHxh1jfXJO/nvO9bm8rjkWlJd3s6aFEVJ3U+PMK17TZyrHPm6HMD TrlhV4lJ/2hOXQabJL5KLHkPiwIw8CaommtFt6Ff5hcunWfweNxE/HaHT7iM2/BE7yNi DH7AgOr/mc7f9/u5hfHWc/6RQMYAJTi1SyMjqwEtuszH7CqblDzxvCyntEmbRZuCDtVo AqA03WG1k+fc/ArAP7t0vniIdBTPxKAbnUKJgPHvyX+a+EiG7o7+/dc0euOhcm3EiJpI 4fDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=DiS6tkUpaxndkmQtKOrLUpeZedTPdW0/QJrv/eROMxw=; fh=fD9lyVOPk9OFZgZvmhSc31Ct1H+o4yRCKj2in/9Xf44=; b=E0n6bioHg0a+EB0I6ldZ0EE19TEIfSqSPGGm7uqDzuHtRxzz5ZhOXEKuD3h1ST+RnB wqAJd9QoVNQpBYYB+7CGZBP+c9o7f5q08BDGRuZu0H7WgIAcmXrIprZ/FHhAGtbBYqe9 W3Z81WpFmC9Ro71WvmFI9UVfu53kAUhgOi7s68GLST3MQ3jhLTQJooj8pB+cEdapA0fP nTGPPXnFLX/N2UUYEilXda/AnKXxDlP+9wYoPUoUZqolahDbL2ca1H2GN6cCJEQmqTVy GSA9SttScty98UETEHvWdRQlAIwfOp0hQ7SdoAGGQo45DCNVB8k5UyMnHeKrHbFVkoYj cuFQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vakVDLLy; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id a640c23a62f3a-a67eae7079esi91268466b.730.2024.05.31.06.51.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 06:51:36 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vakVDLLy; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 39B50887CB; Fri, 31 May 2024 15:50:54 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="vakVDLLy"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 43305887B7; Fri, 31 May 2024 15:50:53 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 08D9A887B1 for ; Fri, 31 May 2024 15:50:51 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-a689b034b02so8750266b.2 for ; Fri, 31 May 2024 06:50:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717163450; x=1717768250; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=DiS6tkUpaxndkmQtKOrLUpeZedTPdW0/QJrv/eROMxw=; b=vakVDLLyroeSg+GL7VZNVk43YfscZ2fTO4q9KVaNdXvdEca1qVkmS0oCN6A2CbEXme 38mdTBdFpGMXw26nkZ4cGTCtNIZQTdvFBsFhjIKG9K1Pk85XLEoDmwhwJvQBazb/yBj8 pawA1AzA0FV09FSMTlIMv0H0IEMZkqPIRq+eNSOhauHYjZXUaoXAMJilS6pCwXdOhGkV lhou3oOLIeaEW8U36DsuxQgRviLWiLSzbQQmFzF6gQTl6CKeby9/CtzQvcXtJGzua/RN mQnUNPpju/DgFf+kpmiwlW+Fl2DBezUwL+Kvunhf1UqQN5iaSzcN/7zWMeOdYwjq8TEC 7mvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717163450; x=1717768250; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DiS6tkUpaxndkmQtKOrLUpeZedTPdW0/QJrv/eROMxw=; b=OiLFdb/WOwaJQM8eWAIu6OWkal4uzstM/gJoJ9rETETrd4AiZVJiVTSBdOUqMgk63x tz9bnbZXLVDZ7ICGZg8MAydXZ/Ga1ObL1MMSbZSfDO3iCyVuTDoaa54+YZR+v5Qldla6 91fXYMe3ZNV2luSe9/39MQ15RvBV/EwC+KbXXbGxhi/l4p0aY17mGlKS5aAimKEUFClc RvynAO+V4IyoQDBX4nqzWCyjtSjKjRZNk370x+TYW6rjGSn0tVym9vHFjyQ+DIGXDB8x fF+03ANoubNndVPiCtgdsqQY7wCAZx5lq+G2eazVAQKsFGwjU6pdYLrTUVKUYZmGvp2H tJmQ== X-Forwarded-Encrypted: i=1; AJvYcCXC+YUyD5NaDiqc3BslDOo1dUDrt036Kr8/ERE4lAyojd6zFNBhY7UuXFqMxctefKFjkHkyru6pqeU4y2xPWFJ2dygU3Q== X-Gm-Message-State: AOJu0YxeaVx3dUayIpav0qBjt+D4f2822MoYlthkio7/xo4FxQwzKH8q Fv//m3JHzQn1a9EA26x7dlR7ckuDbc3tjhCyUK9FBOQlnOw2N9YE39BLWOdY0gU= X-Received: by 2002:a17:906:a2da:b0:a68:44ed:613d with SMTP id a640c23a62f3a-a6844ed64dcmr134318366b.14.1717163450484; Fri, 31 May 2024 06:50:50 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::8090]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a67eab84a99sm89442866b.143.2024.05.31.06.50.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 06:50:50 -0700 (PDT) From: Caleb Connolly Date: Fri, 31 May 2024 15:50:38 +0200 Subject: [PATCH v3 4/7] sandbox: switch to dynamic UUIDs MIME-Version: 1.0 Message-Id: <20240531-b4-dynamic-uuid-v3-4-ca4a4865db00@linaro.org> References: <20240531-b4-dynamic-uuid-v3-0-ca4a4865db00@linaro.org> In-Reply-To: <20240531-b4-dynamic-uuid-v3-0-ca4a4865db00@linaro.org> To: Tom Rini , Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Mario Six , Alper Nebi Yasak , Abdellatif El Khlifi Cc: Richard Hughes , u-boot@lists.denx.de, Caleb Connolly X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=12323; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=ebvcIW8ENg3nKp4MgxtFbZceBlrQGRzQUXlv6yEpMtU=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmWdWzqUG/V/HAOFMFj4G5GmAy9TyruHb3iRHgO xDW6emU/P6JAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZlnVswAKCRAFgzErGV9k tjY4D/9VG0Jyh8Q6SVsNCgbO8x8a1i0z7fFaoujadFx+3iWxJWqYHvIRTEP7ON/9Tj0LABN/x4X R+0r5uFJUEYdlJJwiVSa7Z725q/R1++Ri6+UZMUyuY0yDZHJeuhTwDurKxIBwGfJGbtFtJ6ptKU +9QehTQvXwK/27YGNf2keTqHrqCXnzEW7fiGICDfmXLWzlgK+3gSZAN5bu3G8wwV1iwm1R4SK9z 1Zren6BsihEj98oxW1WmG9M1lcgvkChibqtaAHl5hXlFCTpOKPN3zaNwnr+q9nSa5NU4zvPfsdW 1S2ptIxFfMUY+3M/JBCTX68+8swy7cS83dIuIW34JRhe8FZn3FYIWNf4U2RWzQAuIVs+CC2URSm AHuEjIP3YWa8naMML1ufA9V8/DKmMifcItyHVycDDFA8mTtmpDlHnwl5z7V8HDZwKMfn51THnQ8 AEmqwpYW39KUyFD4/IaN6IU+sWbPyFfwEfGjIuYbu+/eIpu8G3vDTQl1hi2Qr4rwR46xegV8bA9 5bTm7HBnettgYi7oeblbO4wjdYjq4hT5uOurOm5Jsh4YIUI2WmMCAD05oSwJPVzumpkuESgWt3b wcsS41+6Tqrct4YDggN5IGUfk0WMRjrP5yPciIL6HkOoG/6GP2E42ETME/irRxDtogDpcqxt+Mm ZIk0SvIsh/RShAQ== X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 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 Migrate sandbox over to generating it's capsule update image GUIDs dynamically from the namespace and board/image info. Update the reference and tests to use the new GUIDs. Signed-off-by: Caleb Connolly Reviewed-by: Ilias Apalodimas --- arch/Kconfig | 1 + board/sandbox/sandbox.c | 16 ---------------- configs/sandbox_defconfig | 1 + configs/sandbox_flattree_defconfig | 1 + include/sandbox_efi_capsule.h | 6 +++--- .../tests/test_efi_capsule/test_capsule_firmware_fit.py | 2 +- .../tests/test_efi_capsule/test_capsule_firmware_raw.py | 8 ++++---- .../test_efi_capsule/test_capsule_firmware_signed_fit.py | 2 +- .../test_efi_capsule/test_capsule_firmware_signed_raw.py | 4 ++-- test/py/tests/test_efi_capsule/version.dts | 6 +++--- tools/binman/etype/efi_capsule.py | 2 +- tools/binman/ftest.py | 2 +- 12 files changed, 19 insertions(+), 32 deletions(-) diff --git a/arch/Kconfig b/arch/Kconfig index abd406d48841..0558c90540b6 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -164,8 +164,9 @@ config SANDBOX select SYS_CACHE_SHIFT_4 select IRQ select SUPPORT_EXTENSION_SCAN if CMDLINE select SUPPORT_ACPI + select EFI_CAPSULE_DYNAMIC_UUIDS if EFI_HAVE_CAPSULE_SUPPORT imply BITREVERSE select BLOBLIST imply LTO imply CMD_DM diff --git a/board/sandbox/sandbox.c b/board/sandbox/sandbox.c index 802596569c64..d97945e58fcf 100644 --- a/board/sandbox/sandbox.c +++ b/board/sandbox/sandbox.c @@ -31,36 +31,20 @@ */ gd_t *gd; #if IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) -/* GUIDs for capsule updatable firmware images */ -#define SANDBOX_UBOOT_IMAGE_GUID \ - EFI_GUID(0x09d7cf52, 0x0720, 0x4710, 0x91, 0xd1, \ - 0x08, 0x46, 0x9b, 0x7f, 0xe9, 0xc8) - -#define SANDBOX_UBOOT_ENV_IMAGE_GUID \ - EFI_GUID(0x5a7021f5, 0xfef2, 0x48b4, 0xaa, 0xba, \ - 0x83, 0x2e, 0x77, 0x74, 0x18, 0xc0) - -#define SANDBOX_FIT_IMAGE_GUID \ - EFI_GUID(0x3673b45d, 0x6a7c, 0x46f3, 0x9e, 0x60, \ - 0xad, 0xab, 0xb0, 0x3f, 0x79, 0x37) - struct efi_fw_image fw_images[] = { #if defined(CONFIG_EFI_CAPSULE_FIRMWARE_RAW) { - .image_type_id = SANDBOX_UBOOT_IMAGE_GUID, .fw_name = u"SANDBOX-UBOOT", .image_index = 1, }, { - .image_type_id = SANDBOX_UBOOT_ENV_IMAGE_GUID, .fw_name = u"SANDBOX-UBOOT-ENV", .image_index = 2, }, #elif defined(CONFIG_EFI_CAPSULE_FIRMWARE_FIT) { - .image_type_id = SANDBOX_FIT_IMAGE_GUID, .fw_name = u"SANDBOX-FIT", .image_index = 1, }, #endif diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index 93b52f2de5cf..58775b271600 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -349,8 +349,9 @@ CONFIG_TPM=y CONFIG_ERRNO_STR=y CONFIG_GETOPT=y CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y CONFIG_EFI_CAPSULE_ON_DISK=y +CONFIG_EFI_CAPSULE_NAMESPACE_UUID="09D7CF52-0720-4710-91D1-08469B7FE9C8" CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y CONFIG_EFI_CAPSULE_AUTHENTICATE=y CONFIG_EFI_CAPSULE_ESL_FILE="board/sandbox/capsule_pub_esl_good.esl" CONFIG_EFI_SECURE_BOOT=y diff --git a/configs/sandbox_flattree_defconfig b/configs/sandbox_flattree_defconfig index 6bf8874e722e..85ae63da8881 100644 --- a/configs/sandbox_flattree_defconfig +++ b/configs/sandbox_flattree_defconfig @@ -224,8 +224,9 @@ CONFIG_TPM=y CONFIG_ZSTD=y CONFIG_ERRNO_STR=y CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y CONFIG_EFI_CAPSULE_ON_DISK=y +CONFIG_EFI_CAPSULE_NAMESPACE_UUID="09d7cf52-0720-4710-91d1-08469b7fe9c8" CONFIG_EFI_CAPSULE_FIRMWARE_FIT=y CONFIG_EFI_CAPSULE_AUTHENTICATE=y CONFIG_EFI_CAPSULE_ESL_FILE="board/sandbox/capsule_pub_esl_good.esl" CONFIG_UNIT_TEST=y diff --git a/include/sandbox_efi_capsule.h b/include/sandbox_efi_capsule.h index 3e288e8a84a2..25ac496ea24f 100644 --- a/include/sandbox_efi_capsule.h +++ b/include/sandbox_efi_capsule.h @@ -5,11 +5,11 @@ #if !defined(_SANDBOX_EFI_CAPSULE_H_) #define _SANDBOX_EFI_CAPSULE_H_ -#define SANDBOX_UBOOT_IMAGE_GUID "09d7cf52-0720-4710-91d1-08469b7fe9c8" -#define SANDBOX_UBOOT_ENV_IMAGE_GUID "5a7021f5-fef2-48b4-aaba-832e777418c0" -#define SANDBOX_FIT_IMAGE_GUID "3673b45d-6a7c-46f3-9e60-adabb03f7937" +#define SANDBOX_UBOOT_IMAGE_GUID "fd5db83c-12f3-a46b-80a9-e3007c7ff56e" +#define SANDBOX_UBOOT_ENV_IMAGE_GUID "935fe837-fac8-4394-c008-737d8852c60d" +#define SANDBOX_FIT_IMAGE_GUID "ffd97379-0956-fa94-c003-8bfcf5cc097b" #define SANDBOX_INCORRECT_GUID "058b7d83-50d5-4c47-a195-60d86ad341c4" #define UBOOT_FIT_IMAGE "u-boot_bin_env.itb" diff --git a/test/py/tests/test_efi_capsule/test_capsule_firmware_fit.py b/test/py/tests/test_efi_capsule/test_capsule_firmware_fit.py index 11bcdc2bb293..746da4602085 100644 --- a/test/py/tests/test_efi_capsule/test_capsule_firmware_fit.py +++ b/test/py/tests/test_efi_capsule/test_capsule_firmware_fit.py @@ -146,9 +146,9 @@ class TestEfiCapsuleFirmwareFit(): verify_content(u_boot_console, '100000', 'u-boot:Old') verify_content(u_boot_console, '150000', 'u-boot-env:Old') else: # ensure that SANDBOX_UBOOT_IMAGE_GUID is in the ESRT. - assert '3673B45D-6A7C-46F3-9E60-ADABB03F7937' in ''.join(output) + assert '5AF91295-5A99-F62B-80D7-E9574DE87170' in ''.join(output) assert 'ESRT: fw_version=5' in ''.join(output) assert 'ESRT: lowest_supported_fw_version=3' in ''.join(output) verify_content(u_boot_console, '100000', 'u-boot:New') diff --git a/test/py/tests/test_efi_capsule/test_capsule_firmware_raw.py b/test/py/tests/test_efi_capsule/test_capsule_firmware_raw.py index a5b5c8a3853a..1866b8086573 100644 --- a/test/py/tests/test_efi_capsule/test_capsule_firmware_raw.py +++ b/test/py/tests/test_efi_capsule/test_capsule_firmware_raw.py @@ -133,12 +133,12 @@ class TestEfiCapsuleFirmwareRaw: 'env set dfu_alt_info "sf 0:0=u-boot-bin raw 0x100000 0x50000;u-boot-env raw 0x150000 0x200000"', 'efidebug capsule esrt']) # ensure that SANDBOX_UBOOT_ENV_IMAGE_GUID is in the ESRT. - assert '5A7021F5-FEF2-48B4-AABA-832E777418C0' in ''.join(output) + assert '935FE837-FAC8-4394-C008-737D8852C60D' in ''.join(output) # ensure that SANDBOX_UBOOT_IMAGE_GUID is in the ESRT. - assert '09D7CF52-0720-4710-91D1-08469B7FE9C8' in ''.join(output) + assert 'FD5DB83C-12F3-A46B-80A9-E3007C7FF56E' in ''.join(output) check_file_removed(u_boot_console, disk_img, capsule_files) expected = 'u-boot:Old' if capsule_auth else 'u-boot:New' @@ -187,14 +187,14 @@ class TestEfiCapsuleFirmwareRaw: verify_content(u_boot_console, '100000', 'u-boot:Old') verify_content(u_boot_console, '150000', 'u-boot-env:Old') else: # ensure that SANDBOX_UBOOT_IMAGE_GUID is in the ESRT. - assert '09D7CF52-0720-4710-91D1-08469B7FE9C8' in ''.join(output) + assert 'FD5DB83C-12F3-A46B-80A9-E3007C7FF56E' in ''.join(output) assert 'ESRT: fw_version=5' in ''.join(output) assert 'ESRT: lowest_supported_fw_version=3' in ''.join(output) # ensure that SANDBOX_UBOOT_ENV_IMAGE_GUID is in the ESRT. - assert '5A7021F5-FEF2-48B4-AABA-832E777418C0' in ''.join(output) + assert '935FE837-FAC8-4394-C008-737D8852C60D' in ''.join(output) assert 'ESRT: fw_version=10' in ''.join(output) assert 'ESRT: lowest_supported_fw_version=7' in ''.join(output) verify_content(u_boot_console, '100000', 'u-boot:New') diff --git a/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_fit.py b/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_fit.py index 44a58baa3106..a4e0a3bc73f5 100644 --- a/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_fit.py +++ b/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_fit.py @@ -156,9 +156,9 @@ class TestEfiCapsuleFirmwareSignedFit(): 'u-boot-env raw 0x150000 0x200000"', 'efidebug capsule esrt']) # ensure that SANDBOX_UBOOT_IMAGE_GUID is in the ESRT. - assert '3673B45D-6A7C-46F3-9E60-ADABB03F7937' in ''.join(output) + assert 'FD5DB83C-12F3-A46B-80A9-E3007C7FF56E' in ''.join(output) assert 'ESRT: fw_version=5' in ''.join(output) assert 'ESRT: lowest_supported_fw_version=3' in ''.join(output) verify_content(u_boot_console, '100000', 'u-boot:New') diff --git a/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_raw.py b/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_raw.py index 83a10e160b8c..260c71860632 100644 --- a/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_raw.py +++ b/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_raw.py @@ -150,14 +150,14 @@ class TestEfiCapsuleFirmwareSignedRaw(): 'u-boot-env raw 0x150000 0x200000"', 'efidebug capsule esrt']) # ensure that SANDBOX_UBOOT_IMAGE_GUID is in the ESRT. - assert '09D7CF52-0720-4710-91D1-08469B7FE9C8' in ''.join(output) + assert 'FD5DB83C-12F3-A46B-80A9-E3007C7FF56E' in ''.join(output) assert 'ESRT: fw_version=5' in ''.join(output) assert 'ESRT: lowest_supported_fw_version=3' in ''.join(output) # ensure that SANDBOX_UBOOT_ENV_IMAGE_GUID is in the ESRT. - assert '5A7021F5-FEF2-48B4-AABA-832E777418C0' in ''.join(output) + assert '935FE837-FAC8-4394-C008-737D8852C60D' in ''.join(output) assert 'ESRT: fw_version=10' in ''.join(output) assert 'ESRT: lowest_supported_fw_version=7' in ''.join(output) verify_content(u_boot_console, '100000', 'u-boot:New') diff --git a/test/py/tests/test_efi_capsule/version.dts b/test/py/tests/test_efi_capsule/version.dts index 07850cc6064c..3f0698bf7280 100644 --- a/test/py/tests/test_efi_capsule/version.dts +++ b/test/py/tests/test_efi_capsule/version.dts @@ -7,18 +7,18 @@ firmware-version { image1 { lowest-supported-version = <3>; image-index = <1>; - image-type-id = "09D7CF52-0720-4710-91D1-08469B7FE9C8"; + image-type-id = "FD5DB83C-12F3-A46B-80A9-E3007C7FF56E"; }; image2 { lowest-supported-version = <7>; image-index = <2>; - image-type-id = "5A7021F5-FEF2-48B4-AABA-832E777418C0"; + image-type-id = "935FE837-FAC8-4394-C008-737D8852C60D"; }; image3 { lowest-supported-version = <3>; image-index = <1>; - image-type-id = "3673B45D-6A7C-46F3-9E60-ADABB03F7937"; + image-type-id = "FFD97379-0956-FA94-C003-8BFCF5CC097B"; }; }; }; diff --git a/tools/binman/etype/efi_capsule.py b/tools/binman/etype/efi_capsule.py index e32037178221..da1f9b0a381a 100644 --- a/tools/binman/etype/efi_capsule.py +++ b/tools/binman/etype/efi_capsule.py @@ -23,9 +23,9 @@ def get_binman_test_guid(type_str): Returns: The actual GUID value (str) """ TYPE_TO_GUID = { - 'binman-test' : '09d7cf52-0720-4710-91d1-08469b7fe9c8' + 'binman-test' : 'fd5db83c-12f3-a46b-80a9-e3007c7ff56e' } return TYPE_TO_GUID[type_str] diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 8a44bc051b36..dc602b95ecd5 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -123,9 +123,9 @@ TEE_ADDR = 0x5678 # Firmware Management Protocol(FMP) GUID FW_MGMT_GUID = '6dcbd5ed-e82d-4c44-bda1-7194199ad92a' # Image GUID specified in the DTS -CAPSULE_IMAGE_GUID = '09d7cf52-0720-4710-91d1-08469b7fe9c8' +CAPSULE_IMAGE_GUID = 'fd5db83c-12f3-a46b-80a9-e3007c7ff56e' # Windows cert GUID WIN_CERT_TYPE_EFI_GUID = '4aafd29d-68df-49ee-8aa9-347d375665a7' # Empty capsule GUIDs EMPTY_CAPSULE_ACCEPT_GUID = '0c996046-bcc0-4d04-85ec-e1fcedf1c6f8' From patchwork Fri May 31 13:50:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 800540 Delivered-To: patch@linaro.org Received: by 2002:a5d:65c4:0:b0:35b:5a80:51b4 with SMTP id e4csp742505wrw; Fri, 31 May 2024 06:51:49 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU4/RPFafgBVH2jjv1lyo0l7mG+LJyomidTifHGniqVyOO6YQsHtGu3MHqHzTfvXpt+vutCLW80Esv/TrrWEzA9 X-Google-Smtp-Source: AGHT+IGXjIyH6IpGcCb/LGk+Xl1XgED3PLXETBFVd2mTQafA6SQ7zkhWsFM4u2nZmGPyXltyjrwW X-Received: by 2002:a17:906:158c:b0:a62:2ef9:13d with SMTP id a640c23a62f3a-a681c5f1057mr134667366b.0.1717163509222; Fri, 31 May 2024 06:51:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717163509; cv=none; d=google.com; s=arc-20160816; b=CzWXSCfW2c+nBKD3G/wYAL/SeEiWmcgTBugAQBCMFa1VScuzaKrGlMtfDwHLzNjjbl qJMetnZYKYi09126fV4KwZKT0gBCPbHyyfwgufvmWUSPWUknZsNybmWSYE/j8juz/dPW PoGozvQhY8mQ/E87iM847rEjprv1YzbPJVdY3BygXRtbldOlNE2PdU3xezU95H4twm7K KBXADiabsCMZwVkZ3006U2pSMCviglcmfOXQtvWldK8bsWToSpYpkRAIBu+0sdJq8WCk bwjM/3hAdjszFSWpmCTQN0JRTcM4qkxuQAXLRpSO+5sGxpLMnCiDWqONjVy2dSltZBcT 3oLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=9akAAz9hF/jdFLeFWjBJfV867XQPVmitXPU4glcZWNs=; fh=iv5h/0nHYJxFTshuIaBT3CTjG1TzvXf0Rbxwg0ex058=; b=zafltsylMtsfCc/D1VR0giuwPfZkNLbbgKJAcPkqP54SahNal1mMm50qpbMzRzuWgQ FQUJ3nQ5Rt3JoFxK1DD86kMLCO0FKf9A2IiM6G1voRAIiu/pTzGkPXqCJW54VW0iRQJV x2Mq5qGfufy7dp6/HzLKKDDhvOP+5Bk5VNLUPOjObd4JJ1fAis6PWW7tFFFVNod70Q8q oW5Pt70C7MBcmZsnHcWOjNPFwhhkI0Qvhp7KH+SQXJ2de4rWa8XnA+p+NwSwq1K2AeTv xppv2tUco3nLpZ1UVTrBzYe9HPs7XPpvYzdoUHp7hKt2fyJvZ4Pp+qtI5V45ZnEZu+CT lddg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H8pd6vB4; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id a640c23a62f3a-a67ea38ec2csi97307466b.318.2024.05.31.06.51.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 06:51:49 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H8pd6vB4; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CBFA3887B1; Fri, 31 May 2024 15:50:58 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="H8pd6vB4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B3E70887CE; Fri, 31 May 2024 15:50:54 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5A806882B8 for ; Fri, 31 May 2024 15:50:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-a6265d3ba8fso190308066b.0 for ; Fri, 31 May 2024 06:50:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717163452; x=1717768252; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=9akAAz9hF/jdFLeFWjBJfV867XQPVmitXPU4glcZWNs=; b=H8pd6vB4cGsmU80giHO5WtfA61T6TEyk9Er/Z4noIbfgAdt8AVJOkgdpAS88CIH4zS CCgW7biAp20fa9sv9qUYKYjjbWMfIcVvGZNfxzIqVDK1p/NdRSthVyucAwAFxKMwPP5a STC05ArGDl+T0bvPgrM30I1ydCFP+1ZGIUIhQi476UnlvwYEVLFtb+H3/6EHIYcRc6po BsL9oRj3A6DIhj84H8wnIdOCPfOuhRLocej0JNsspE+nRhmf0HcfpcmPFmZQxJokGcB6 9reREfX6y+ch/wdQ05zSie9ELqj9bm0IbdAy1sgwZYXFTp5VUApOO1bIFaCtmwcXFUse I+IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717163452; x=1717768252; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9akAAz9hF/jdFLeFWjBJfV867XQPVmitXPU4glcZWNs=; b=d0nT38vYFKqPaL1SpQKrXcSpndEDNVXwa181FOs3VSwqNsHZHSzUJEkeujHFDJjy+5 drjC6UA1yb/VYLSPBKmU+baLOhy5/iXTZUSEnq459NdWz8agl2J3/vsRrnRKOz/M654l kRA7emmLabWXxPTfwOTLSN0a9g4UjL+Q5M46JYf9o1tKVodo0uVdbrrMUyuE98x3ByFS zjh6uy5kJapb+KrBKRmrYDaUYJYAvQUjju4lU2Nq6PWsmcI2fqtoESWl9keuDtJDgILI yGnFCdyCHDeUTveMXOBNXmQsyDEcy5u6E9yodDMADrT3jbFIcqqWDkwL0CrqyqEk3i9y RiQw== X-Forwarded-Encrypted: i=1; AJvYcCVCy319kOxT2mL4t3uRhtdEh9sPcPzqImWAQUP65kc78tX/nZIPdeRtVLBjEJiplLEMWjKhhZ+oYrxGJYb1LscZQAIEww== X-Gm-Message-State: AOJu0YxiMKZN/vUSMd8VFeDYZVHynggYB5fjCwdSPiqZLcWQxk33jsxJ MXqlPNEXqEe5j0Rl62GEbBHEv+E2LGfkpuqRRLhn/V11ETGvi26lvwvuexm/1Jo= X-Received: by 2002:a17:906:3103:b0:a65:cea9:dd56 with SMTP id a640c23a62f3a-a68208fbc54mr128162666b.33.1717163451756; Fri, 31 May 2024 06:50:51 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::8090]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a67eab84a99sm89442866b.143.2024.05.31.06.50.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 06:50:51 -0700 (PDT) From: Caleb Connolly Date: Fri, 31 May 2024 15:50:39 +0200 Subject: [PATCH v3 5/7] lib: uuid: supporting building as part of host tools MIME-Version: 1.0 Message-Id: <20240531-b4-dynamic-uuid-v3-5-ca4a4865db00@linaro.org> References: <20240531-b4-dynamic-uuid-v3-0-ca4a4865db00@linaro.org> In-Reply-To: <20240531-b4-dynamic-uuid-v3-0-ca4a4865db00@linaro.org> To: Tom Rini , Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Mario Six , Alper Nebi Yasak , Abdellatif El Khlifi Cc: Richard Hughes , u-boot@lists.denx.de, Caleb Connolly X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=5253; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=GIKCAKL8Z6qLwSjriQMI2tPgimrtffN1dSTIvetofgk=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmWdW0y1Jnu2fICTePvOy2xxFnc29Cc0N4YrY+K 2+fy2Jtlj6JAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZlnVtAAKCRAFgzErGV9k tmCOD/9RI9KGI3ohzk20kokDx6sDbyzKChW5FaJuBN6rnMJbk2Pt2JXINNPVf+O6LesvNzGJjNE XqoIeY3C/vKgmM3YdmHsjbcKec3scPJr7GbrJIQ6f7zNZzGxwiYYlrbOoG4BGAt8N8qmo7DvYup 8FhzZgwKTkfQC+JQSs7bbBCX/uX9QF7dX41oyQQ7NpD+uImR02S2GVCabpOZ+za60sQ+/D6s7Mi 0mk30HJuU+qJAQqEvUah4p/NMzq+WvgUjxl8wvoE7ed8Ua+qGmuvm76uajsmx/bnu+xeDW7dzkL VxL6KzMkEmbNiWpAIPnhJYcfq9jNlzCJP2SNidYYvQ4WlMKJNDXvHA6LL3YLKMJRr44QVewZlr8 CQhX+PteTAusHlsK3IZR20sede/RaUwrb++Dd8s3jIlS2cOLhg1fsCevuptKT3rSd963MOWcrR7 HuO8o3HS6MiXkn+znncNsUAfnfmddMRoLCDrJ75OayEB4L2HFrCA/+eS7Ud4ZSJfx3jhXJd+Ved C4PYzYv7Y2WCmVg+BbNksRz7phAATvZHFPHWz3eGmwza2pQKKBNXlsFnsHMQQKiV0hremOrd7LQ 2HVLFpO8P2AFtk0fsEzHs5Lckb1FkOGd44Zt73oxaSo/bUijmEjwad0r4xiE888IxMVDA2OIQcw zFsCaGg6VZFN5hg== X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 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 Adjust the UUID library code so that it can be compiled as part of a host tool. This removes the one redundant log_debug() call, as well as the incorrectly defined LOG_CATEGORY. In general this is a fairly trivial change, just adjusting includes and disabling list_guid. This will be used by a new genguid tool to generate v5 GUIDs that match those generated by U-Boot at runtime. Signed-off-by: Caleb Connolly --- include/uuid.h | 4 ++-- lib/uuid.c | 44 ++++++++++++++++++++++++++++++-------------- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/include/uuid.h b/include/uuid.h index 539affaa47b9..b38b20d957ef 100644 --- a/include/uuid.h +++ b/include/uuid.h @@ -69,10 +69,10 @@ struct uuid { } __packed; /* Bits of a bitmask specifying the output format for GUIDs */ #define UUID_STR_FORMAT_STD 0 -#define UUID_STR_FORMAT_GUID BIT(0) -#define UUID_STR_UPPER_CASE BIT(1) +#define UUID_STR_FORMAT_GUID 0x1 +#define UUID_STR_UPPER_CASE 0x2 /* Use UUID_STR_LEN + 1 for string space */ #define UUID_STR_LEN 36 #define UUID_BIN_LEN sizeof(struct uuid) diff --git a/lib/uuid.c b/lib/uuid.c index 2df0523e717f..89911b06ccc0 100644 --- a/lib/uuid.c +++ b/lib/uuid.c @@ -6,25 +6,38 @@ * Authors: * Abdellatif El Khlifi */ -#define LOG_CATEGOT LOGC_CORE - +#ifndef USE_HOSTCC #include #include #include #include #include -#include -#include -#include #include #include #include #include #include +#include +#include +#else +#include +#include +#include +#include +#endif +#include +#include +#include +#include #include +#ifdef USE_HOSTCC +/* polyfill hextoul to avoid pulling in strto.c */ +#define hextoul(cp, endp) strtoul(cp, endp, 16) +#endif + int uuid_str_valid(const char *uuid) { int i, valid; @@ -51,8 +64,9 @@ int uuid_str_valid(const char *uuid) static const struct { const char *string; efi_guid_t guid; } list_guid[] = { +#ifndef USE_HOSTCC #ifdef CONFIG_PARTITION_TYPE_GUID {"system", PARTITION_SYSTEM_GUID}, {"mbr", LEGACY_MBR_PARTITION_GUID}, {"msft", PARTITION_MSFT_RESERVED_GUID}, @@ -231,8 +245,9 @@ static const struct { { "EFI_MEMORY_TYPE", EFI_MEMORY_TYPE }, { "EFI_MEM_STATUS_CODE_REC", EFI_MEM_STATUS_CODE_REC }, { "EFI_GUID_EFI_ACPI1", EFI_GUID_EFI_ACPI1 }, #endif +#endif /* !USE_HOSTCC */ }; int uuid_guid_get_bin(const char *guid_str, unsigned char *guid_bin) { @@ -266,9 +281,8 @@ int uuid_str_to_bin(const char *uuid_str, unsigned char *uuid_bin, uint32_t tmp32; uint64_t tmp64; if (!uuid_str_valid(uuid_str)) { - log_debug("not valid\n"); #ifdef CONFIG_PARTITION_TYPE_GUID if (!uuid_guid_get_bin(uuid_str, uuid_bin)) return 0; #endif @@ -297,19 +311,19 @@ int uuid_str_to_bin(const char *uuid_str, unsigned char *uuid_bin, tmp16 = cpu_to_be16(hextoul(uuid_str + 19, NULL)); memcpy(uuid_bin + 8, &tmp16, 2); - tmp64 = cpu_to_be64(simple_strtoull(uuid_str + 24, NULL, 16)); + tmp64 = cpu_to_be64(hextoul(uuid_str + 24, NULL)); memcpy(uuid_bin + 10, (char *)&tmp64 + 2, 6); return 0; } int uuid_str_to_le_bin(const char *uuid_str, unsigned char *uuid_bin) { - u16 tmp16; - u32 tmp32; - u64 tmp64; + uint16_t tmp16; + uint32_t tmp32; + uint64_t tmp64; if (!uuid_str_valid(uuid_str) || !uuid_bin) return -EINVAL; @@ -324,22 +338,22 @@ int uuid_str_to_le_bin(const char *uuid_str, unsigned char *uuid_bin) tmp16 = cpu_to_le16(hextoul(uuid_str + 19, NULL)); memcpy(uuid_bin + 8, &tmp16, 2); - tmp64 = cpu_to_le64(simple_strtoull(uuid_str + 24, NULL, 16)); + tmp64 = cpu_to_le64(hextoul(uuid_str + 24, NULL)); memcpy(uuid_bin + 10, &tmp64, 6); return 0; } void uuid_bin_to_str(const unsigned char *uuid_bin, char *uuid_str, int str_format) { - const u8 uuid_char_order[UUID_BIN_LEN] = {0, 1, 2, 3, 4, 5, 6, 7, 8, + const uint8_t uuid_char_order[UUID_BIN_LEN] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; - const u8 guid_char_order[UUID_BIN_LEN] = {3, 2, 1, 0, 5, 4, 7, 6, 8, + const uint8_t guid_char_order[UUID_BIN_LEN] = {3, 2, 1, 0, 5, 4, 7, 6, 8, 9, 10, 11, 12, 13, 14, 15}; - const u8 *char_order; + const uint8_t *char_order; const char *format; int i; /* @@ -405,8 +419,9 @@ void gen_uuid_v5(const struct uuid *namespace, struct uuid *uuid, ...) uuid->clock_seq_hi_and_reserved |= UUID_VARIANT << UUID_VARIANT_SHIFT; } #endif +#ifndef USE_HOSTCC #if defined(CONFIG_RANDOM_UUID) || defined(CONFIG_CMD_UUID) void gen_rand_uuid(unsigned char *uuid_bin) { u32 ptr[4]; @@ -494,4 +509,5 @@ U_BOOT_CMD(guid, CONFIG_SYS_MAXARGS, 1, do_uuid, "e.g. guid guid_env" ); #endif /* CONFIG_CMD_UUID */ #endif /* CONFIG_RANDOM_UUID || CONFIG_CMD_UUID */ +#endif /* !USE_HOSTCC */ From patchwork Fri May 31 13:50:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 800541 Delivered-To: patch@linaro.org Received: by 2002:a5d:65c4:0:b0:35b:5a80:51b4 with SMTP id e4csp742596wrw; Fri, 31 May 2024 06:52:01 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWdE0ocKVW/mCrFB3QmbbHlUwD9k1zlSe6nOrX8uTrsDjC3rjYerlNAJMrGhEhG4o/symxdZvTBc1/d13qFJkHl X-Google-Smtp-Source: AGHT+IGHEDThYmDehKbJZ3m+J3fKvfhpSXOzvJKKc61tGTUHfJtAvhJ5lJJxxAdJX/GRseDwknGH X-Received: by 2002:a17:906:2c1a:b0:a59:cbcb:1cca with SMTP id a640c23a62f3a-a65f094096dmr429583066b.13.1717163520689; Fri, 31 May 2024 06:52:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717163520; cv=none; d=google.com; s=arc-20160816; b=hf/d5dvHOUylbN4oBTXS9xNWWi+9aVdU94vMndg4Lq5sHLS/vmTxDbpdf0dalQXfJs MHaWI+UD79ok08HJPA7cE+/mKy0yHcUCyIad2EN++4EAMjY/X93nDETo1Oatg5Ciqbh8 pQ+zKLdt942cmCVcDnlk4NAaNlQRhz5Qru28pRFFvZo17f7V8GnpCjPoBf3hcw/A6//H NN2yM8wdYy1t9RRRgQtpkYwWqgTbeEx1g+s6hodtDVSbvdf6+MVY5TAwnkdi8FxUM1eg lLynDhGxWdDxk2JwJnxRVs7TH24D/WIfNTItFmcYfpp8RrcxJU71vgAkoRB80CJy/kGo 6eXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=Hw2RXhrZpIRC1LLz/VAb9tB7axGYbKL0pn4Md9US95g=; fh=muXz+ch3mpvLReMJ5b0emd4w5s4UQ+kJ/3nMXuVtl6o=; b=PB/6GVURKTBWe316g8G+MsI86QsGufV+IvD4ref/aOYB4d8aQ5geCAUjwdzWLBloBc TzWYk6BGmCHSrzu0MgDzDCdOylXldutx1t9+qYenrESxf3hh9QLf+d0oIfrCE6ajLJ6W 0MEnJbZGf86pj4FcYeY1tcJh4k3pYdP62JT9VyU3Ns9s+otPyzbfS7cGcYi5Cyxz6ii6 IXP78heJWt/dYghwiX09lMme8nXU/DU/tPYH66hlXt3cLYNyG3hYgQhxuKhulDkjXhn9 /AJkd9KlhCGNigBqmBYdsMth1HDgVJ+QRa8l2aC4FjJHQNFKP4u8u6zlErKLEBVuiJej 5Q+g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jsk2tDCX; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id a640c23a62f3a-a67eae702casi91620866b.737.2024.05.31.06.52.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 06:52:00 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jsk2tDCX; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 37466887CA; Fri, 31 May 2024 15:50:59 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="jsk2tDCX"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id ED8C1887DB; Fri, 31 May 2024 15:50:55 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 83F18887BC for ; Fri, 31 May 2024 15:50:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-ed1-x543.google.com with SMTP id 4fb4d7f45d1cf-5789733769dso3786701a12.1 for ; Fri, 31 May 2024 06:50:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717163453; x=1717768253; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Hw2RXhrZpIRC1LLz/VAb9tB7axGYbKL0pn4Md9US95g=; b=jsk2tDCXHLCHw/1yoChk5umHzQ8YV9Ej9CmD5gR6s/krzLZGpVrXcj2kxNjvWDmQ+3 RIvurs3QzNbL4JeUmSCYJKX7KWbNwewRVCTCltrXNxW0amKfh1ysZOOG0MmWiY0jmhWS 0Ypqp2FNMy4uTgMVSnKklmjT/QggsoQz1eiFTBPwePFNRIrliC9owvCECRQ55yoFLZYU 3z09HuBcFedRA2HCv1G5qNX3HmiejVH2KFA3HglwaY6Ho231851yXoOOakvC61oWnuZm B894lyru+hZhrmWvPq1OvDnxkQiNZ+aXSe/7lSaRDvaX+MW8BmpO74Wrzi1osHjBBt1y NPjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717163453; x=1717768253; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Hw2RXhrZpIRC1LLz/VAb9tB7axGYbKL0pn4Md9US95g=; b=nrvkPRRII/y4qr2QXdkpjrXqxHsOIIlxrKj68N2LMuyJWjESji7YzGt1a2q9uge/ps +pLmMhA502kWgqirlxc14AZaOVKY4RCL6IZI0nSixgdXdCVaWK4wqVm28X78GhbNsfM4 CEDsFr6QfM+eayBGlr4NO/uwSMbhKIwk3ZJTwqMfwCFp89wrQO3C2MCC3HUI9r+7nIft 6yVA0feJlwNs+vi/yxA3GWF462nYLozdpaDSLQy8foNSHhyi2S8sFjaxW14BxaSdBTp8 jsQtrsvS1XnRUi9WEmIvm3Q9TT0HY7RqiV10tfcgdTsxznLk+XYkM1iJeR1POkGKL6nJ ai5g== X-Forwarded-Encrypted: i=1; AJvYcCXM/iUL35jAx5yuz7liA6Rk0W2/1mIUnYGPXgtZxBRZGPpJCs5JyLkSxuDU+F6H5xif5dk7+VT/ncQNKQ5n4Ob2DMXP4Q== X-Gm-Message-State: AOJu0YwzTYiKCA5QvOR7zGU5n1RsX6wr5pmkTC30Lfk7kgC0y9MHHQ82 y6zbrsJdaHTpWwpjcFrYWyiElqvAdayGFao1zkUSKt9fDPIKqvzT8x6NOK+IMj4= X-Received: by 2002:a17:906:4815:b0:a65:19da:df5f with SMTP id a640c23a62f3a-a65f093eafemr380061466b.10.1717163452840; Fri, 31 May 2024 06:50:52 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::8090]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a67eab84a99sm89442866b.143.2024.05.31.06.50.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 06:50:52 -0700 (PDT) From: Caleb Connolly Date: Fri, 31 May 2024 15:50:40 +0200 Subject: [PATCH v3 6/7] tools: add genguid tool MIME-Version: 1.0 Message-Id: <20240531-b4-dynamic-uuid-v3-6-ca4a4865db00@linaro.org> References: <20240531-b4-dynamic-uuid-v3-0-ca4a4865db00@linaro.org> In-Reply-To: <20240531-b4-dynamic-uuid-v3-0-ca4a4865db00@linaro.org> To: Tom Rini , Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Mario Six , Alper Nebi Yasak , Abdellatif El Khlifi Cc: Richard Hughes , u-boot@lists.denx.de, Caleb Connolly X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=8102; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=T1+DS2/Ax+hg2h4lWpp9orQiYTuwChFRlmhAPl0CPzg=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmWdW0Jcn7nGPfkZoH1etfRyFNcW8EoQAUzxBFt /nbukbUYKiJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZlnVtAAKCRAFgzErGV9k tgFiD/9n8VW1ZMj97ox5D87w5kgx13jKh2WHUUDs5qjhbNUUsH5a41jvA9lhZJxjVky1BCX4PgY 1qC5vPvXNs7JoNBx5qowdZNTjMG9vh9o2cDcThQC/rSSjsxarqNz7/yyvxbC5oWME89vZ2TgAL0 oPJL6cLXO0SERHrGQyQXyzlt7Z4aLUDR4/ndpMZnL2KBCSbj3wMDwfjSpev4aM7X48FErpBCHWA TcBU6GNUOdwJ/JJXpDdb+8Q+FC0FWyyb7T27RT7eGwlbvoSZrwILVd8iRUbZusvR+AIcaq3NzA6 pCqZTzlidQzJjeB6rkYGq5FWJDLFsX53aDMOxT/5L70sg0CiM9axg9pR2ZCh6+EJWMNUczVwM/s TFOmkV43+rg8/BZalogV4qfaZNG7oijURCSnfhzB7++AmqGN3qeylkHNSOgv7Aukp/EnQU2QmkV 2DUWOT4f4KIAvlHFjUQ4QwnuarpOTCnP2dKLG697Y9lDcGIoFWYROifQ7WqhfGsCPEpq0M3yQMv t2FbljssflcC69bj4YkQyRLF8F3+ivkKBQ8CuO5iyPgBO+YlKe4ogwmTKlDBuXGXDAn2TZXfqB6 lfoCbCNeybdVGwlFuf4no9HAM/XePafswjfUGDdqJRNWwz8iOEu/6BqFYYpwD/alo1CYBD2DrgB Pn8qq07N/GF1wdw== X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 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 Add a tool that can generate GUIDs that match those generated internally by U-Boot for capsule update fw_images. Dynamic UUIDs in U-Boot work by taking a namespace UUID and hashing it with the board model, compatible, and fw_image name. This tool accepts the same inputs and will produce the same GUID as U-Boot would at runtime. Signed-off-by: Caleb Connolly Reviewed-by: Simon Glass --- doc/genguid.1 | 52 +++++++++++++++++++ tools/Kconfig | 7 +++ tools/Makefile | 3 ++ tools/genguid.c | 154 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 216 insertions(+) diff --git a/doc/genguid.1 b/doc/genguid.1 new file mode 100644 index 000000000000..4128055b3a9a --- /dev/null +++ b/doc/genguid.1 @@ -0,0 +1,52 @@ +.\" SPDX-License-Identifier: GPL-2.0+ +.\" Copyright (c) 2024, Linaro Limited +.TH GENGUID 1 "May 2024" + +.SH NAME +genguid \- Generate deterministic EFI capsule image GUIDs for a board + +.SH SYNOPSIS +.B genguid +.RI GUID " " [ -vj ] " " -c " " COMPAT " " NAME... + +.SH "DESCRIPTION" +The +.B genguid +command is used to determine the update image GUIDs for a board using +dynamic UUIDs. The command takes a namespace GUID (defined in the boards +defconfig), the boards first compatible string, and the names of the +firmware images. The command will output the GUIDs for each image. + +As the dynamic UUID mechanism generates GUIDs at runtime, it would be +necessary to actually boot U-Boot on the board and enable debug logs +to retrieve the generated GUIDs. This tools just simplifies that process. + +.SH "OPTIONS" + +.TP +.BI GUID +The namespace/salt GUID, same as CONFIG_EFI_CAPSULE_NAMESPACE_UUID. +The format is: + xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx + +.TP +.BI "-v\fR,\fB --verbose " +Print additional information to stderr. + +.TP +.BI "-j\fR,\fB --json " +Output the results in JSON format (array of object with name/uuid properties). + +.TP +.BI "-c\fR,\fB --compat " COMPAT +The first entry in the boards root compatible property. + +.TP +.BI NAME... +The names of the firmware images to generate GUIDs for (e.g. "SANDBOX-UBOOT-ENV"). + +.SH AUTHORS +Written by Caleb Connolly + +.SH HOMEPAGE +https://u-boot.org diff --git a/tools/Kconfig b/tools/Kconfig index 667807b33173..13201ff61fd4 100644 --- a/tools/Kconfig +++ b/tools/Kconfig @@ -103,8 +103,15 @@ config TOOLS_MKEFICAPSULE This command allows users to create a UEFI capsule file and, optionally sign that file. If you want to enable UEFI capsule update feature on your target, you certainly need this. +config TOOLS_GENGUID + bool "Build genguid command" + default y if EFI_CAPSULE_DYNAMIC_UUIDS + help + This command allows users to generate the GUIDs that a given + board would use for UEFI capsule update feature. + menuconfig FSPI_CONF_HEADER bool "FlexSPI Header Configuration" help FSPI Header Configuration diff --git a/tools/Makefile b/tools/Makefile index 6a4280e3668f..29e9a93b0f24 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -253,8 +253,11 @@ HOSTLDLIBS_mkeficapsule += \ HOSTLDLIBS_mkeficapsule += \ $(shell pkg-config --libs uuid 2> /dev/null || echo "-luuid") hostprogs-$(CONFIG_TOOLS_MKEFICAPSULE) += mkeficapsule +genguid-objs := generated/lib/uuid.o generated/lib/sha1.o genguid.o +hostprogs-$(CONFIG_TOOLS_GENGUID) += genguid + mkfwumdata-objs := mkfwumdata.o generated/lib/crc32.o HOSTLDLIBS_mkfwumdata += -luuid hostprogs-$(CONFIG_TOOLS_MKFWUMDATA) += mkfwumdata diff --git a/tools/genguid.c b/tools/genguid.c new file mode 100644 index 000000000000..e71bc1d48f95 --- /dev/null +++ b/tools/genguid.c @@ -0,0 +1,154 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright 2024 Linaro Ltd. + * Author: Caleb Connolly + */ + +#include +#include +#include +#include +#include +#include +#include + +#include + +static struct option options[] = { + {"dtb", required_argument, NULL, 'd'}, + {"compat", required_argument, NULL, 'c'}, + {"help", no_argument, NULL, 'h'}, + {"verbose", no_argument, NULL, 'v'}, + {"json", no_argument, NULL, 'j'}, + {NULL, 0, NULL, 0}, +}; + +static void usage(const char *progname) +{ + fprintf(stderr, "Usage: %s GUID [-v] -c COMPAT NAME...\n", progname); + fprintf(stderr, + "Generate a v5 GUID for one of more U-Boot fw_images the same way U-Boot does at runtime.\n"); + fprintf(stderr, + "\nOptions:\n" + " GUID namespace/salt GUID in 8-4-4-4-12 format\n" + " -h, --help display this help and exit\n" + " -c, --compat=COMPAT first compatible property in the board devicetree\n" + " -v, --verbose print debug messages\n" + " -j, --json output in JSON format\n" + " NAME... one or more names of fw_images to generate GUIDs for\n" + ); + fprintf(stderr, "\nExample:\n"); + fprintf(stderr, " %s 2a5aa852-b856-4d97-baa9-5c5f4421551f \\\n" + "\t-c \"qcom,qrb4210-rb2\" \\\n" + "\tQUALCOMM-UBOOT\n", progname); +} + +static size_t u16_strsize(const uint16_t *in) +{ + size_t i = 0, count = UINT16_MAX; + + while (count-- && in[i]) + i++; + + return (i + 1) * sizeof(uint16_t); +} + +int main(int argc, char **argv) +{ + struct uuid namespace; + char *namespace_str; + char uuid_str[37]; + char **image_uuids; + char *compatible = NULL; + uint16_t **images_u16; + char **images; + int c, n_images; + bool debug = false, json = false; + + if (argc < 2) { + usage(argv[0]); + return 1; + } + + namespace_str = argv[1]; + + /* The first arg is the GUID so skip it */ + while ((c = getopt_long(argc, argv, "c:hvj", options, NULL)) != -1) { + switch (c) { + case 'c': + compatible = strdup(optarg); + break; + case 'h': + usage(argv[0]); + return 0; + case 'v': + debug = true; + break; + case 'j': + json = true; + break; + default: + usage(argv[0]); + return 1; + } + } + + if (!compatible) { + fprintf(stderr, "ERROR: Please specify the compatible property.\n\n"); + usage(argv[0]); + return 1; + } + + if (uuid_str_to_bin(namespace_str, (unsigned char *)&namespace, UUID_STR_FORMAT_GUID)) { + fprintf(stderr, "ERROR: Check that your UUID is formatted correctly.\n"); + exit(EXIT_FAILURE); + } + + /* This is probably not the best way to convert a string to a "u16" string */ + n_images = argc - optind - 1; + images = argv + optind + 1; + images_u16 = calloc(n_images, sizeof(char *)); + for (int i = 0; i < n_images; i++) { + images_u16[i] = calloc(1, strlen(images[i]) * 2 + 2); + for (int j = 0; j < strlen(images[i]); j++) + images_u16[i][j] = (uint16_t)images[i][j]; + } + + if (debug) { + fprintf(stderr, "GUID: "); + uuid_bin_to_str((uint8_t *)&namespace, uuid_str, UUID_STR_FORMAT_GUID); + fprintf(stderr, "%s\n", uuid_str); + fprintf(stderr, "Compatible: \"%s\"\n", compatible); + fprintf(stderr, "Images: "); + for (int i = 0; i < n_images; i++) + fprintf(stderr, "\"%s\"%s", argv[optind + i + 1], + i == n_images - 1 ? "\n" : ", "); + } + + image_uuids = calloc(n_images, sizeof(char *)); + for (int i = 0; i < n_images; i++) { + struct uuid image_type_id; + + gen_uuid_v5(&namespace, &image_type_id, + compatible, strlen(compatible), + images_u16[i], u16_strsize(images_u16[i]) - sizeof(uint16_t), + NULL); + + uuid_bin_to_str((uint8_t *)&image_type_id, uuid_str, UUID_STR_FORMAT_GUID); + image_uuids[i] = strdup(uuid_str); + } + + if (json) { + printf("[\n"); + for (int i = 0; i < n_images; i++) + printf("\t{\"name\": \"%s\", \"uuid\": \"%s\"}%s\n", images[i], image_uuids[i], + i == n_images - 1 ? "" : ","); + printf("]\n"); + } else { + for (int i = 0; i < n_images; i++) + printf("%-24s| %s\n", images[i], image_uuids[i]); + } + + return 0; +} + From patchwork Fri May 31 13:50:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 800542 Delivered-To: patch@linaro.org Received: by 2002:a5d:65c4:0:b0:35b:5a80:51b4 with SMTP id e4csp742691wrw; Fri, 31 May 2024 06:52:12 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVJ3TQcSU/LjzMXRqFMadx0zF0NlX+HE30zwxA/4rD5qY0RxRSfXi4PIM15YH5hiSma3YURH7ZQrPb5pfUl3nzU X-Google-Smtp-Source: AGHT+IFp6G/M9h9I0IPUZ1YPyoB8PJkzTQvWxNUp7rm2NnPz0wfPSfzhZelKzit5Favnk5QIRitD X-Received: by 2002:a05:6512:214e:b0:51b:528e:ce7d with SMTP id 2adb3069b0e04-52b89563236mr1381719e87.34.1717163531769; Fri, 31 May 2024 06:52:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717163531; cv=none; d=google.com; s=arc-20160816; b=e8LcW2ojNp0Mxp0iN58UmIwqGP+ULt9QHEucJ6PzlYtodSQj2cMUzyleFzNz6WJR+h 1gQBzzjrVVt410LdUX4tOTOWc+CGLvBx7Rx7KBCP9LD5vvPta439PvUizFTjhrYOtmsE EKalOK2aW3EcaqUGQQY0y+2IQR6b1c4BDfTsyjUfFFhOSHDuSImwAiDDyMcPtSxMGCy3 mjPnVWyrfTW1qMe7dJAbEfG7LXv4O1Aeh3Q7wejd1ZXD4j7VbaZax+fhb/hVxQ9Jimq7 FKQkFW7cgL8pZQH2/DlV2iq0yXUlXh3gheKY9ptS7rDPnLTE7g/KedtkJxlyhunLRQ9U FUtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=7HsaSU/GVMju5xN/sg3znUxqC7KLIcXCPlkqzo9nf7Q=; fh=zX7U4vIu7oNTjjMAKTNKYyyHcAJ73i3J88TmmXEVpfw=; b=b0wxlBZBaafsoiXtm9WUEDjn3rmm/n6lP9TQ6rynOMw+0rsWaycE7zMdTo+7PhPAYv LTOnAVOVeDo2nVvDOGXRFkanMWiBX9DcuYrGQBtjR79yYeJja1Q3R03F4dGtVuIuU+fB 6mExnKFc/UJ5rhu7MLmYb8/5DgF05MID77A/9InYswndcEVvWi5UdNJ6juuYuPGEKTjH 1Uygm8zsG4E7XLB8MQTEyxt3kRyHyxyRYIFYXCCg61RIgO5ToK6++ljSXn1A9j/Xff6m R82rblbQFWHHJj1Mi2+g/pd1v3B5SV2dCSk6wF7/w10OAjh6YeguveAPrLDZOpmp9UYu +MKw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BqYgSCTh; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id a640c23a62f3a-a67e73f716csi93721666b.229.2024.05.31.06.52.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 06:52:11 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BqYgSCTh; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9E386887DB; Fri, 31 May 2024 15:50:59 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="BqYgSCTh"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AA810887BA; Fri, 31 May 2024 15:50:56 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A0EA3887D0 for ; Fri, 31 May 2024 15:50:54 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2e6f51f9de4so29106251fa.3 for ; Fri, 31 May 2024 06:50:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717163454; x=1717768254; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=7HsaSU/GVMju5xN/sg3znUxqC7KLIcXCPlkqzo9nf7Q=; b=BqYgSCThNvZZOPr1vudqPKPqh5C8PqLfByEf4LmOPBIruNcNwpjNH6YaZqXeFyg6E2 HUyNj/zzDmwfxwD9npeWL1BxYQHGhkNY1sFVbCneszugMfM10M0P3QlY5b8k+EFHF9KA IWj8Y5Wt0S+6/ZV/8jzkCHKWXLOJcTMpvsGoedspgjy68CkSxLlSlp32bkLWLWporZ6J 8kMfCh1nAAiHDwAkzBOWwcFp3idIcF6QO5lpTEXELL29cJdLzU/KA/3CDULsoGXSZVye 7FjjEzllXN/1Ei39MKhJTbv4ssQWIywtvEJxtIbq+hsoytBb+8iPJMiw/mRJqHDb90Qr tBMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717163454; x=1717768254; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7HsaSU/GVMju5xN/sg3znUxqC7KLIcXCPlkqzo9nf7Q=; b=MoZuBXBq/wScMxdD38eUq8vYAybIjiVwmq9m6PM7dyCK3Kc0Agd0l1neKltHpY1hBZ EaOYtSv0b5Y/i23VspYPPgh/JKAi0S1FfDAtjhLFR8ZcNLDSlCWdfoB0ZK4zZGfLpboJ h8gAVPUgD01vG0TxaO7iFmtRpgkHj/6+UtL0RAjOIBm6ynrHoyH7bhx/7sVgOoqwEvo1 hjhnPNOs9IoAZKEez+Kvfz2F7qJDAXWzE0GooLqhsOR7LVRRAR4N6nuoikXwU/2ZbYUo ckX4OW4FdNsWpZehZLyxASyvFMXYkkg+YoRBCXTcnHABEVaNCn8TfJIp2fMVEjtNZKY0 fKLg== X-Forwarded-Encrypted: i=1; AJvYcCXuM8V+a/lwYgoKAQXImp2Zf+VJx15Ob12RK6vByPmQ3ygKiMhm/UPUfJOtrSN3ghE1K+R1VCXFBrBIfYLPSe65w6ZmkQ== X-Gm-Message-State: AOJu0YxicvK5/To9CNENkZVeruK+0ShPZCn9CIaPnKeCpGhfBEa5oFur VKLhUtaNtLaVafZZwtCsoeSU/XA1kaWR4Bbh3URkYyIgEuHr1lxz7DGgWMZWbPs= X-Received: by 2002:a2e:b049:0:b0:2ea:9194:ab2d with SMTP id 38308e7fff4ca-2ea951147afmr15601601fa.18.1717163453955; Fri, 31 May 2024 06:50:53 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::8090]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a67eab84a99sm89442866b.143.2024.05.31.06.50.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 06:50:53 -0700 (PDT) From: Caleb Connolly Date: Fri, 31 May 2024 15:50:41 +0200 Subject: [PATCH v3 7/7] test: lib/uuid: add unit tests for dynamic UUIDs MIME-Version: 1.0 Message-Id: <20240531-b4-dynamic-uuid-v3-7-ca4a4865db00@linaro.org> References: <20240531-b4-dynamic-uuid-v3-0-ca4a4865db00@linaro.org> In-Reply-To: <20240531-b4-dynamic-uuid-v3-0-ca4a4865db00@linaro.org> To: Tom Rini , Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Mario Six , Alper Nebi Yasak , Abdellatif El Khlifi Cc: Richard Hughes , u-boot@lists.denx.de, Caleb Connolly X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3273; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=nUd+KMu0GfIDUzb8thPbkHD1IRE34vCpsyeDcvHSIBM=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmWdW0mg21Aq/DDFoTHnTl/kH1n9n/dH1kyh+va AUPmiJ3M7+JAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZlnVtAAKCRAFgzErGV9k trqhEACWA0ooZxLgDiEmaHGfAkOZYRJc26wbGa8cDsYhsSj3B/ass4bKqbzh8tyjb07Qhu2bytE QOGLy8ea7EIW4uXNm9PPI8WpN86BUQmmYIudDlyn61dkKOJp8Ymha6w9+qqT8PVDdUstlP1Habi Tjsw3ZxnujJUn93SdkPC8PdmVo+Cvxp99IuqPkEawxCwP4aD9aRHDGunCxkaTiAB7rwZ1DX7/ZB xz6mOM3gXcVyQpkVxbHom8LKeHajgAhAFwY4Lx+MgoiqlNpErL7giz57TDdvpi0hRlXWG1V3zsK IJd9YNR0mGr5RywadKcARSHy7GOiXdDuUKDxrugrNmPqhKGGg2AnbwRo23AlSi5NlnyawWnP1b1 P6gPUtlDz+NDu/8/UidpFGlvNSauCG5qTx9RsjxGkO9eq/OZSQwk9+9jUKKn5do9p4nxKje3ZKf TevZwf8T5VkYy406OAB+UibwSXYNeOeGJbbIh1JAEjGrp6+kftEIfwthmTjrPpbHnuMy1y49Eo0 0JlrJrKKAxuskBgc6DjyrUzLHLpmWFNHB8ImOlBi2vc8dzqpbidk2HyAFnOBM+M46tbHd1758Hp 9YdSX4pSsSqgRN7Ckrwrydb3b+GHLk+xWSLnv6ebI1YmCUJlTqGFdTo8IliLBugbZzIic5eX97I dxkE3hi0jPb+jjQ== X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 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 Add some basic unit tests to validate that the UUID generation behaves as expected. This matches the implementation in efi_loader for sandbox and a Qualcomm board and should catch any regressions. Signed-off-by: Caleb Connolly --- test/lib/uuid.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/test/lib/uuid.c b/test/lib/uuid.c index 0914f2c47e77..dc485189ae68 100644 --- a/test/lib/uuid.c +++ b/test/lib/uuid.c @@ -7,15 +7,20 @@ * Authors: * Abdellatif El Khlifi */ +#include #include #include #include #include /* test UUID */ #define TEST_SVC_UUID "ed32d533-4209-99e6-2d72-cdd998a79cc0" +/* Sandbox namespace UUID */ +#define SANDBOX_NAMESPACE_UUID "09d7cf52-0720-4710-91d1-08469b7fe9c8" +/* Qcom namespace UUID */ +#define QCOM_NAMESPACE_UUID "2a5aa852-b856-4d97-baa9-5c5f4421551f" #define UUID_SIZE 16 /* The UUID binary data (little-endian format) */ @@ -37,4 +42,87 @@ static int lib_test_uuid_to_le(struct unit_test_state *uts) return 0; } LIB_TEST(lib_test_uuid_to_le, 0); + +#if CONFIG_IS_ENABLED(EFI_CAPSULE_DYNAMIC_UUIDS) +struct dynamic_uuid_test_data { + const char *namespace; + const char *compatible; + const u16 *images[4]; + const char *expected_uuids[4]; +}; + +static int lib_test_dynamic_uuid_case(struct unit_test_state *uts, + const struct dynamic_uuid_test_data *data) +{ + struct uuid namespace; + int j; + + ut_assertok(uuid_str_to_bin(data->namespace, (unsigned char *)&namespace, + UUID_STR_FORMAT_GUID)); + + for (j = 0; data->images[j]; j++) { + const char *expected_uuid = data->expected_uuids[j]; + const u16 *image = data->images[j]; + struct uuid uuid; + char uuid_str[37]; + + gen_uuid_v5(&namespace, &uuid, + data->compatible, strlen(data->compatible), + image, u16_strsize(image) - sizeof(uint16_t), + NULL); + uuid_bin_to_str((unsigned char *)&uuid, uuid_str, UUID_STR_FORMAT_GUID); + + ut_asserteq_str(expected_uuid, uuid_str); + } + + return 0; +} + +static int lib_test_dynamic_uuid(struct unit_test_state *uts) +{ + int ret, i; + const struct dynamic_uuid_test_data test_data[] = { + { + .compatible = "sandbox", + .namespace = SANDBOX_NAMESPACE_UUID, + .images = { + u"SANDBOX-UBOOT", + u"SANDBOX-UBOOT-ENV", + u"SANDBOX-FIT", + NULL, + }, + .expected_uuids = { + "fd5db83c-12f3-a46b-80a9-e3007c7ff56e", + "935fe837-fac8-4394-c008-737d8852c60d", + "ffd97379-0956-fa94-c003-8bfcf5cc097b", + NULL, + } + }, + { + .compatible = "qcom,qrb4210-rb2", + .namespace = QCOM_NAMESPACE_UUID, + .images = { + u"QUALCOMM-UBOOT", + NULL, + }, + .expected_uuids = { + "8ee418dc-7e00-e156-80a7-274fbbc05ba8", + NULL, + } + }, + }; + + for (i = 0; i < ARRAY_SIZE(test_data); i++) { + ret = lib_test_dynamic_uuid_case(uts, &test_data[i]); + if (ret) + return ret; + } + + return 0; +} + +LIB_TEST(lib_test_dynamic_uuid, 0); + +#endif /* CONFIG_IS_ENABLED(EFI_CAPSULE_DYNAMIC_UUIDS) */ +