From patchwork Wed May 29 14:48:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 799845 Delivered-To: patch@linaro.org Received: by 2002:adf:e110:0:b0:35b:5a80:51b4 with SMTP id t16csp771261wrz; Wed, 29 May 2024 07:49:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUJS6rsdTADFVv9t9w52+6o5lIUCDWQGCqod6JWDuuHiFyvR8sLaiUA0+eXt1VBQ3QqGe5UPg5UhLgjgd8ELPsn X-Google-Smtp-Source: AGHT+IEgliPGlMeLb18fgfA3yWpiTaSpeDgeAX2wsmArO8qJtGrFagouPTLEPagEBVTkWVUurXW9 X-Received: by 2002:a05:6512:3142:b0:529:b55f:620f with SMTP id 2adb3069b0e04-529b55f6431mr4461737e87.32.1716994157013; Wed, 29 May 2024 07:49:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716994156; cv=none; d=google.com; s=arc-20160816; b=omOkh9jXFQWhICCcMAvAVKHZOZ4nyA1ZXwHWNgFizIsFPS/lGADvPU59RdlJz1aKvJ +HH2TH6LCaWypMnCiCiMIBNYJy6sKZCADKXHjo7WbzFI8FecwzHU5n/2oEY1L8M1x+cq 4xiGIc1YNlksKxJd7nrZGBrlk5MGMah2mDj87Frp+0GszmpGEvxfoAyQVZFDeU/PaB+c t+bZmc5FbPTEm9pzxGBwbzLgh7NOxJGSwYuRGxBqgAH2WqfqSWjo0lrK7dRM+Kpk7i4H YpetmArMawhb2sbg0bBNK00/Ivs/s5M52LtsyYdKOW5iZpPT+U2Sq8khcPW9crBJhAOb pzEw== 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=aIIdk8QLdQK/+nMS97Tn+QiBS+LkUYzHnlaYIE+5lNU=; fh=ZzUnhiL7JdiQlr/NUoK2DePPTAeOLINnpf37ou0hY1M=; b=ayjAxUBeZ0ixdxJtmlsIXSeBqTlYppWeQsTKpIvUdkUEyx+wehjpqDtPiCkuUeEsSS uZRad+g2Dqz/7JhAiWpzF+a/kYuduOXfuGRzYdF3pnLw2hrOIKfwbJtEcumFaOunUYRl QupRngfWyjVH03NNXYX48TWv0+AmjsAFIhWfHb9i0o2vxc+WMIxcM/yT2JUzilMTiKGS 57J+6VmXb/akm5oPJCfaSzLuMvWkt5Qfi3nfaTfOBDJekJLGu6aurxaz77h08uDJu1dl meM06046m95UlID1qtd4mYMcXxOhfzctvl/Yw4cyw4coGlCaobdZQ4x9KJsYGnBCy19D I+hQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RCgOfIeG; 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-a626c7ff0ffsi640927066b.76.2024.05.29.07.49.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 07:49:16 -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=RCgOfIeG; 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 5534288633; Wed, 29 May 2024 16:49:06 +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="RCgOfIeG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8668B88602; Wed, 29 May 2024 16:49:03 +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-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) (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 7B7C088615 for ; Wed, 29 May 2024 16:49:01 +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-x531.google.com with SMTP id 4fb4d7f45d1cf-5788eaf5320so2540053a12.0 for ; Wed, 29 May 2024 07:49:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1716994141; x=1717598941; 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=aIIdk8QLdQK/+nMS97Tn+QiBS+LkUYzHnlaYIE+5lNU=; b=RCgOfIeGnC2aY5iq+WvIpvg0GDV4lbvg6dSoHBqplEa5z5A1zDiyem2oJIL/ZwXIcp PnU9x4Hcq2YQoPehFro6OPJP1LAlYCbQW/xNlL0+OgNx9uE1vYXzPEz9VHXTDBeYraPA n5V2jiGgeiJ7ZnfYW3KxSJRhAvLRqm9T4LX6WCp4TEQwblII9cLHYUKpgnNH3StIvbze XtX2nEIoDmQVThjGPg9h9QjYrkbrwKxrw1otdAMtaJgBoEmZoMtmRyD/N1wE5WQyJ257 oDa7FVCKC88SMGQ5Fp0CTsWQE9vp/kYEeB55XEOUgZ5n/MvHLdmHFkAbww1oyI22rgRs J6TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716994141; x=1717598941; 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=aIIdk8QLdQK/+nMS97Tn+QiBS+LkUYzHnlaYIE+5lNU=; b=eoIZfxG8+15EYsQLFYD7FFytBHWBX4UehnoqwBrReJmkCFJ/O75oRPvyvzSO4XZWsj yirIHtwpL3Eiam+HOQGSLEmJ4szR4TYcClU68YRhNbs26FzBfTJZh/GLByOkr3woMdBc /mhJyaCrgU9J2p2wST1UhxjeWnMvgGc3SGolaCIBs3P91ZX5bzelzOzlkq2i4lpj0LYh XhQfJZvWJEnjBbxbz0AMJqZyr6cxGAcchumH8QfSZkT5YBwnczod0Ib3hKYf2Tu8g4nO 7YkF/muACw1qCweYKDxmoGbzyRGFKLnLISBz1yd3FjHAAyYB7ycVBNKcyayiZnBE+HeO LoUw== X-Forwarded-Encrypted: i=1; AJvYcCVr5sDYwLDZKHH7pOHAwUgDxbdTZA18YNLDh+taRC7+/ui8fYqO0IEnjsgnJXXJcEoMMToNbqHyEpucazzHAGt3aLlIsw== X-Gm-Message-State: AOJu0Yy2znWK9Z1RPG0AqE4sJ2bZoEpaqkwkrs+YWSlXswx2afF5aXzP enuG7AWFQvQWF1Rr4ljKfKesknDve5N0dg0Alvq0StOJBK01zqWTJ661n9IO62o= X-Received: by 2002:a50:d510:0:b0:572:78df:c606 with SMTP id 4fb4d7f45d1cf-578519a21cbmr11801327a12.26.1716994141013; Wed, 29 May 2024 07:49:01 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::8bb3]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-578638009b1sm6922029a12.17.2024.05.29.07.49.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 07:49:00 -0700 (PDT) From: Caleb Connolly Date: Wed, 29 May 2024 16:48:50 +0200 Subject: [PATCH v2 1/7] lib: uuid: add UUID v5 support MIME-Version: 1.0 Message-Id: <20240529-b4-dynamic-uuid-v2-1-c26f31057bbe@linaro.org> References: <20240529-b4-dynamic-uuid-v2-0-c26f31057bbe@linaro.org> In-Reply-To: <20240529-b4-dynamic-uuid-v2-0-c26f31057bbe@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=4051; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=9RwhiMRkxrdJFgF+8gB+nMRGmyBqr6tIjuyyWZp3K0I=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmV0BZPBk9BhuBAUn5iM0Rg4ymPu5u6Vf5ypt+2 jI6VjWr8oSJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZldAWQAKCRAFgzErGV9k ti7zD/4gm9hBUha5E17XOjmHmcur+SbNnOg5h+lq3KzMTIw7Jrwvkq8+Ga1z96MZ8G6fUWmtNxu ga1tc27vrz+afUVMR8AnpJkbSyIwBkqWSatEkrT3dAIfUV71d1ohjk0Nz77OxDyvei8hvsroMss ffCsumg5v4X2CtEN4WuUw6QDGDLrJmP5gnnMTc9dZVVvxs9H+5QlnnvfqlciMaanIS+mOoR7h2r lKAjTFzojJiq3Y72hpfwlw1MJTuvGw/wnXteZ8pIMDDJPzcNTsNAxQtmYQU4s7qyVvE4a3M8XRG JBarHBQKrDZeUlr6V6QKVEAYwd5yYS2Mlm3noZ8ArUALI1CmHvUQ/BGNkTXRJCWRjcaY4HUnls4 BNfchUp0Df3zANonqA0k2b8rVDaYNDCFyJyN0b5wr3csJnZiJjzjMmy6ZZhS3v90DWqr03phfzb xBJMatQ81olK/XwVNa93wSPcFZozlZI0a9VOYDIckEM/B1PzqvIaa1lnv9QnmxWZQp4tFaSQo3D OzbGbgv62QbQwa9mm6HcasgE2Vmf6XR+ZcrFBW9m0UUmR3aOwYNlzwlqxQsn43LQsfbmeck1k6w oSh6DcNylJJIx+kV3xTGjOAUdzjCXyUxx7tY8qYpPiToKP6nRqjgTMsoO3PJVS8x9FdVqU356rv 5zHwa1W6EWOXuMQ== 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 generate 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. 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..6ef006cca1da 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 *))) { + size_t 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 Wed May 29 14:48:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 799846 Delivered-To: patch@linaro.org Received: by 2002:adf:e110:0:b0:35b:5a80:51b4 with SMTP id t16csp771351wrz; Wed, 29 May 2024 07:49:28 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUCVDAzXL3LlTEp2xjohWe4bcy3xyVSyWTlymFeGfEyNLYLwnlACwzcsxW/FyWq5NnW5ONjiU4TiBYpja8eCZJv X-Google-Smtp-Source: AGHT+IH5TP0ua3pQdshnaiN1qgTVc8/dweExxBqkrcjIhHtGqiOl+rSajdVyNlASzh/MgFGscWuk X-Received: by 2002:a50:d78b:0:b0:575:c1a:494b with SMTP id 4fb4d7f45d1cf-578518e9aa6mr10121616a12.9.1716994168553; Wed, 29 May 2024 07:49:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716994168; cv=none; d=google.com; s=arc-20160816; b=jIoAcWFPd4AKiOzZ0U02/Ndi0vxuVzqgaAAcHAITm55UvJsyO+plmEH54vG7ORo8a1 y37H2Q29GEgAtYKGb2tzMgCNcT62f4yB9ZV0291OroDAwHOb4h8C+IbWy4JZnZWYEPqV UNTNQa0ZgvfoJb4hqm2M/9Noruhpo55Mj8l1YOZbFJQKvvEQph3Zsz/R83V1fXINq8yt f+EnhY8l/9dnMAb5XSSirZO6YdQ5Yr8IeTXECjIrVYtdxd/VkzPdQKvuXjOJ+Bp3fEI8 Z+0NARiF05q4RDCITgcqQA8eXzTbCp7Ny/qkmQZ26jkHp3Vo4xjoB4kQI5Na3GZS7+a9 UTZA== 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=t+JaXRNM+oGWCFOTJkIarqdO6Gg4cC9VJm+VLICQBKk=; b=m2t/7t/5NSwvPQXF74dZCL5EtTb3rUW/ysugMIi7j7xypw/vTRpqbCHwxhUFTInN1d 26AVHUIyCvCkUy/xf+n//7Sq+9ow+NNQgJZOP2bhWpMzG+KjTJJ3/G9gzl4toROaHZC+ J23oXbfQtU69e4HmWz99L7Ppbpn2NN2GcXI2FqHLuyvGAEcf2BJrOAJ9yN+9PqHUxdnG 4AAjtZ5LJbMzmKthdwQdE42gMwYjiCcK+BJQ3O1l/uOOaF2kwwM1DWgcF8zFmY3uiZe0 RcFPae7IzbZh7po1n/0sOUpH6jXCiIiSKiWYLQFHSX2pvUX28bURTN4wDdm8RX5Y8OA6 f2+Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MR7TplxA; 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 4fb4d7f45d1cf-578687be692si5250936a12.155.2024.05.29.07.49.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 07:49:28 -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=MR7TplxA; 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 B0F0688625; Wed, 29 May 2024 16:49:07 +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="MR7TplxA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EE48B88629; Wed, 29 May 2024 16:49:04 +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-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) (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 8FE2D88623 for ; Wed, 29 May 2024 16:49:02 +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-x536.google.com with SMTP id 4fb4d7f45d1cf-57a034697fbso1258489a12.0 for ; Wed, 29 May 2024 07:49:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1716994142; x=1717598942; 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=MR7TplxAbktkWbXfWSpf8iM7XTBThJJ16Vy4KdFonTF3gsxLdJl9Vn3am9BbL7CIqn znyAexI/spduom28TJOLrAUTQ2K4vZvM+shZVwc5+oUnk4XpbbAumouyADSVa/mFU6RI Zj142r7mHVJD9cNXkMDRibQ7Z25NB9KT/FiPS1AW9CsKLPl5dLYROzTiIArAEzIg9bi/ GIDkL6b4QJVZFuJSLngy3Jc/C0jWioqwmhbzAujNRCwEp1P+CNWj0/mx8O1kHN9kAzrt YjLRO58ZZhdOmDCjd+2rge4oYYqPrmzSzZoliMjA/gdNasnNIDeqWaqhgggfUzlAsy11 +MDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716994142; x=1717598942; 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=cAAOLQlrg78bCXj6rs4qBF/F/D5SK7mXQbtc2WKyTbNa54/WnQliIw5muEPwJJXVUx DHNXEhFDBQxnkdhv14YF5fwuqzQZsVIY+9eOqRX20gpmIQtztGnpqxC2FVQOljhj9Vfx GcP2s6VtQs7jAEZ1Cju9ITUyRe+MNNkCh0GANj4VPNFYtNvqYQwCkavUTo03AxJpoB7Z 2u5BsFhdTBQqc45B6JaZ4zU54TDF9wRdkr+7yewkntgxHXyl8blubXuJi9PUr/J4Mf2z lbsX56K+qA0KWDYM1EONRRfxsmWYzR3mZYGAaFZnoGUKQFJGM6Bl+mO8CRkxzfNF6yeJ F08g== X-Forwarded-Encrypted: i=1; AJvYcCX2RJkj936TqtP3xb/FUH3h+7qDomuyNUzFspNkOr55z1UOr0zCXONKrQpnwyaYSF3RTVbUqsUnBgcjYxiMBjXuM6eTJA== X-Gm-Message-State: AOJu0YwINeGCaSRz2vciLUBOJ+oVwOGn7aaYyzNfz7qhd79IFYTRCsLi Bj/gSiYEEZgifLRrCO8j7PIIMd4LMG1r2DaekTdLg8FVsPqRzGVIzDbz4JVwnm8= X-Received: by 2002:a50:8d53:0:b0:578:6536:481e with SMTP id 4fb4d7f45d1cf-578653648d6mr8319422a12.30.1716994142012; Wed, 29 May 2024 07:49:02 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::8bb3]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-578638009b1sm6922029a12.17.2024.05.29.07.49.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 07:49:01 -0700 (PDT) From: Caleb Connolly Date: Wed, 29 May 2024 16:48:51 +0200 Subject: [PATCH v2 2/7] efi: add a helper to generate dynamic UUIDs MIME-Version: 1.0 Message-Id: <20240529-b4-dynamic-uuid-v2-2-c26f31057bbe@linaro.org> References: <20240529-b4-dynamic-uuid-v2-0-c26f31057bbe@linaro.org> In-Reply-To: <20240529-b4-dynamic-uuid-v2-0-c26f31057bbe@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/ZANAwAIAQWDMSsZX2S2AcsmYgBmV0Ba6BUNi7Rzilov7q5UMY2a5pq0ADtzlK4Bb ktF+D7Kc2WJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZldAWgAKCRAFgzErGV9k tgbRD/0WCwNjwEYcpD6BzXRY0G14NO3gPrZ9DvuYj647kctRWqKMB6SvpsyQbhr7Bt2c2vx3Z9d j2QP6ysxAksVlkw4YUY0Vbha51eE0zp4gAIVxo0B5yFBSFX780YNGKnwCkcM8GsAIt3M/08Xu6O uJ5eDJ+FZVZewSLnNMAiSZF+SvIgW+J4FGv5h1kayYrmOPYQZ/PPXYJ3PjnMOLmElUCLCCRVr6i cvnMcGpuyVzs+2ztMT3VTtH/tCfUz/8bIJNxZdgRgmEzZvaeIqtNydd4P11MX/5dyxg1+GOfvhZ lojYGqSGeWVytUUGruV4xYi+Q6L/5wOEO8STykLhX6XZTQVNgumx8VOtVt61983yh8OBD5GkOet WAbJpbVaXQEdM+Q7G1uIIG4KvwHdonPco9gG9rI/u/b68aHYn6HSwKIqgNswqD4UOIExiRSPASX yhPuUil+ylJs5vriArk6MwmgftfB8IR7sQ3Yrvx8Xlt8+v0ihv8GjCvd9LuqoZli8HxFAMQZzIB X1sx47rou7xl9kWz2G7Vq2cMcL2X/S2xF4O71uFqW90z41n9AQ18yOZkoDqCJFInMEw2IehrBXd hfGUDRWht5jsj2z7LTDII0Vafhr4nKQNsN3vWR6PHn2EprtVnCyTZoar78kfTRoKySovSXEt1vG lskda3n0WdlHC9w== 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 Wed May 29 14:48:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 799847 Delivered-To: patch@linaro.org Received: by 2002:adf:e110:0:b0:35b:5a80:51b4 with SMTP id t16csp771423wrz; Wed, 29 May 2024 07:49:40 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWWHLJPkGomndQXuo9gonW77GJxzcM1ZdBKlIhlhGQSyVqE5yIjyt08bux9rrTFvELLrV4nWEtKrkKjBgX9HNug X-Google-Smtp-Source: AGHT+IHvWkciYHdEd1XNp/ICOMjTCQ4/Om5qfK8OICnUgHin+bvFHWaFgr+GlZG9KKBAuybr7gLA X-Received: by 2002:a17:906:a08a:b0:a5c:de6f:87e7 with SMTP id a640c23a62f3a-a6264f0ecd7mr1119841166b.61.1716994179989; Wed, 29 May 2024 07:49:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716994179; cv=none; d=google.com; s=arc-20160816; b=CJ4MtZpuc6IZsp/pRquHdAHIUqtKaoJRG9FR39CZok29OClD/vtPABYTSqnn5lWxJp bHWYPIj8s92q5OmA9tRQTOLf8JE7/jXgVcCVMYfpZ+oz0zgFptJ1FacllkadS0GvoWIl U7psgdoDZkhM7kQ5VnAJ1Zicn4F2FWSIg2BBW5shjB5dOSUQxHI/mQW/rVsGMgs+bAHz MtbxyGgyuUBrDTKSqaXHepmf9rw4BEXeF2OSLl6THE/4bLkPk2Hj98Wp0jOVU0BBft4X aFQtLLeNj2QxCtn4o/D2qLswVnNuTW5ObDI5TRzZ6wl3JSCVWDxl3RJEqw8f7pJu8cLb cXLQ== 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=FMAW1dpN0sJGqp4IpwIC0EpaM2WaZQwQFd9eCKE47xE=; fh=tAKHAgHn2us0Jr26iSJlU0xrtmjw6YwEBoG8SpVzM6w=; b=dGSklR9pZMtSvQFJiG65i7tzeDV325qvCCv2E3Hyicoxei7MGHWnyNxjJ1xkLSWvlq YNH0Hp0Pes//Qui3WkRgvWa5dOW4UlWazyARaQM8SymLJfaqYizpofitJXtegu0oaYuF rbTPE5tphtG5mKUleG2NMXD2nV5imf1B0Hx5BvVG1qcNgTPe/lq6AC0FyjlTAOgxZjEU qCWnl+YiYkppFaTBTBLe0pJ44ZBmugNuA5hNlYOxDCvVpv4h90xtz5ccjQUwzT9RIJ3O yVs0/i8ZdhSIiKc3alL3bCLAwY0NX1zB1cnqYLKuvsaV+I2iczIyCOt4d3ir6jGAh8db 47BQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IvhNLjfg; 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-a62bee59ca7si471989866b.871.2024.05.29.07.49.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 07:49:39 -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=IvhNLjfg; 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 152388863F; Wed, 29 May 2024 16:49:08 +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="IvhNLjfg"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CCFDD88629; Wed, 29 May 2024 16:49:05 +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-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) (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 C8E4A88602 for ; Wed, 29 May 2024 16:49:03 +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-x52f.google.com with SMTP id 4fb4d7f45d1cf-5785d466c82so2594620a12.3 for ; Wed, 29 May 2024 07:49:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1716994143; x=1717598943; 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=FMAW1dpN0sJGqp4IpwIC0EpaM2WaZQwQFd9eCKE47xE=; b=IvhNLjfgkOGvGgPAtXz9dMwGWDLansM4tlkA0xlYn9vGrwO85lAcUuq4cMkmn+4wi5 G1Wq4mChLldFsCZFoBOrHyUsDP+t3FcVzys/abgRezBY9rM1ZybqpkVPyTWJpsdQ4oG1 rNuvDS8jQgdXz0/HJJHN6i32l925UQJxuyeY6B1PLiwdcZjtWCak3NNrWtDTe+t0Xvkb exewB7chU3TjcWfhICLlBWsIB5Td+yx2GbJYc78vnq5WzpxXviPz8rAbVXGbaffqAX25 io6NIgtmmMrBp3NIQjAPblWLiNP5HlGlu0RSp3hfqoVWFGclzaLfdrwYRVCuynkfaBmN F0og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716994143; x=1717598943; 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=FMAW1dpN0sJGqp4IpwIC0EpaM2WaZQwQFd9eCKE47xE=; b=m/wMajtAZa96GU+IDqVG/IT4CXym91Hb2gpakUmS1HYDqtGWP7RNNyHrPTQT72XYxE QmjvP338xW7eSQRNccrGDTEmULO5FLhdAiQMTr9gCZ3knD/ctfNpuj81jVi0k0aydk8R qSwc9yCWT6Es1g35ZtnqRRIPvVLZPDPskBR108+lIKs/h1b6oG6srQ/j5hpuC9RQB8cI +8Drdu6pHH9WUbv1+CEwGVsCc/pXWbUyySlrPKD8IsuqSAZE5TpCgEfZw+CUeNEFVfxE 8ohHjkYP/xUvOUKkJTrcfjB/ekoRmBu42FmZDVsVnPnFSFXpEgvX7x7eZWiMkZHD4IUX PHZg== X-Forwarded-Encrypted: i=1; AJvYcCWWp8J8OnPmbEZfVYWCSxeEBsVtXTsN/e/mNHtfUP48NP3mshAhOfepOrN8ciLRe3Pvx/sOSrpLwTSLhtfhc4iW/UJG8Q== X-Gm-Message-State: AOJu0YyQ/52OvDDXQ7CxQPFGFIT/bA9U900vTRCWZboxykN+KxF9EN83 HlU9Aef1lcEIX1oHwL4OuO+RY189XicP8QEmRwzg/5F83PEnkqgWzujWbnd0vLQ= X-Received: by 2002:a50:a45d:0:b0:578:63e0:e4f1 with SMTP id 4fb4d7f45d1cf-57863e0e555mr9562088a12.17.1716994143135; Wed, 29 May 2024 07:49:03 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::8bb3]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-578638009b1sm6922029a12.17.2024.05.29.07.49.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 07:49:02 -0700 (PDT) From: Caleb Connolly Date: Wed, 29 May 2024 16:48:52 +0200 Subject: [PATCH v2 3/7] doc: uefi: document dynamic UUID generation MIME-Version: 1.0 Message-Id: <20240529-b4-dynamic-uuid-v2-3-c26f31057bbe@linaro.org> References: <20240529-b4-dynamic-uuid-v2-0-c26f31057bbe@linaro.org> In-Reply-To: <20240529-b4-dynamic-uuid-v2-0-c26f31057bbe@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=2297; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=EdslQZF10Tz/XBvoasteUepMjZO5dSDrB6Bbsr2kI1w=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmV0BatxyLQukAj5Dqnl+xStlnQCKCwrB0fbuyB w4B56lgPPGJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZldAWgAKCRAFgzErGV9k ticCD/9x/f5jkH7UFVfM6eqOBTbKYRSQTYKqhMfagwIB0HhU114r4p7qJdIxiC7r3VpS83Pf9pC hEILG0mjxNJx0+/7LmZA6nCVLJnP/X2LjrpbZxgnG7oroXkmxiZ3Tkj0HvpxCCvm19bh24t/GNJ UgMINpDhnZu5HOoyiYQ34xVLKOL6rtqlESLst2PRX5q3jJ0gX4o0vH59zNWdehb1bYdbIoR7v7A gXM55veKJ3BAwUnesc+OxzVh7YrCWh4Xtbl7DjVLgucUjwczIWYjzj5lhbkKpS5T993RsOyg8H0 4ixX26gY0KJei6PppJGtKfZgTrDgEqdA132/TsO/OSz3Fjjsj0iL7za/rY8lhHiXRiRzMAReNmD Go5eEvdvHlgEXnncuEsaVEKOdgjFLLn6Uhn6brsZTMTGwX3wVNKt0TwvpPzfu7bMg+lgXRjPep9 wReK9OPJTlr8Ok/hX0O/LTQ6BlvaASSgo9OjM210MQ8qrd3n8SB3GkbsG5k314MQ5Qm/bJsY5NG mN5XS4g0bvyQ2BcfCbbw2ihTWgO1Ihss0L1TalxqoJB+dcStmHxloP3fE0ff63cCm945572mYet +q1qg7lNOLoZzREet2/hZJmiTQPYXegZa3aotTYZULq2r3aouz7CazxJzawMwml4lp1aic/u7gT bXOO51Qlzq/D9ow== 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. 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 Wed May 29 14:48:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 799848 Delivered-To: patch@linaro.org Received: by 2002:adf:e110:0:b0:35b:5a80:51b4 with SMTP id t16csp771524wrz; Wed, 29 May 2024 07:49:52 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWCmYL0O+ly1cqiAfKnmtye7XpBiovpxnziCZaUpLJ6PH4O8Za0njHUify1PvufyiCb/Hf6NQxgZkkd/N9QhCcU X-Google-Smtp-Source: AGHT+IFXW1ctg7zYvLgC7XCRvlzAxlxnSbXCJtyAWRj5pxn0wX0TgyFT7vDMKA3Re/KHrzwJl/fH X-Received: by 2002:a50:a687:0:b0:578:61c7:2806 with SMTP id 4fb4d7f45d1cf-57861c72831mr9846935a12.14.1716994191774; Wed, 29 May 2024 07:49:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716994191; cv=none; d=google.com; s=arc-20160816; b=ZGf3iiNSDUAiqVEFb597UdXa1G0JL3NceitypljIjT7cUSo+xu1s8mmD99Ec+ZK+VT oaiPN4sZ/JGAoz84EuZgJT9lnspo9ZoAYpm+LyMlWSKqM7/7+Vpyxt/V2j6C0PMPpKLU 2/mF0GXW5sQ+F9NLJHxQLldNJgSFT4AmfCWLliM0X/1GquQXHjtKq+3FKdgXzP9oeggI 2E7rvLmvOWm8ZJtWhmjqwbw9Uu+qujJ0mzbC1aT1Md1inI7+v25jtXODkqCr33iju51c Vqz2VePBo82oSl9aAX5d50C52YSU2J7YvRUSSu9lL2rsI/P3d2PihEhc5SEE+E7vruVm EVKQ== 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=gJyadcP59baj2bBGo1FFuTK+Cdt7CMKhzMzfggkQHz4=; b=VNI5ArKhdieWABJvqSzzhTZdzlAmceF7mQ76gTZncMDfmlyLre6edjtG+wlr8o+17u Wmm3E1qT0b7ziuRRQKjBXElS5KfvkCrRPdRaQSO5nHQmaWMRNSJmn7h5+wHBiHB3nXWp 2/5MQzwBRyO0oolmGPtedmS9QFiSxAlN0b2SyNEegB9DC0utKUWdk00KHUjFXRl4fFAD YYdqphFt6pTK/sXN88N5E4YsvPINJHwh5dq43cRrJLBqWvXP0xZiCt1Ls7hWltYNCkQm t8TRfB6L2PXlO9BZlcd7O5EFblLvhiy4M0rLyB4HDFltehj3FVNRWw3ZLkbCpkl4h9r+ Byew==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Yr3qypCd; 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 4fb4d7f45d1cf-57a01c8057dsi1146947a12.511.2024.05.29.07.49.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 07:49:51 -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=Yr3qypCd; 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 73FBF88619; Wed, 29 May 2024 16:49:11 +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="Yr3qypCd"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6346D88619; Wed, 29 May 2024 16:49:07 +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-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) (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 064EF88623 for ; Wed, 29 May 2024 16:49:05 +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-x12b.google.com with SMTP id 2adb3069b0e04-529b4011070so2624744e87.1 for ; Wed, 29 May 2024 07:49:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1716994144; x=1717598944; 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=Yr3qypCdIUPd1m/IuAGiSzgtllOri1iZ9ELBLVFzc0E3/K8IBJ71Qhh+gCDCcRP1Oj LCUGc00XooSTUvWboHi9z/IvKG8eShlNvE6SqZL9ta3f1TWPZ0wC+UTDFuNQ3H/meBkn MvzaPv3RxESJHd8rSZ57rk7KZtLAZ0/YM2jzZkm3FkxSAwhban1xCz+gNwyTMv0Hv/bf CDRUAmhhFZjORFlimIYIjMEHI8WOsT/y86uJwT1VjaQYPErHMegKAaYDCyaYaJ0QOGWo w7jJkMI+2BYWJgqOyxNy3Q5tM74jTMChG7jVpIjYkYLT5Dg3I1U82esQSimsRvf/aPsd dVcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716994144; x=1717598944; 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=YT7pasMDI+E6QW3X2jxYjSqeuTsJP7311sKuR6mwf+MS34jr6szPUXCe6SQPpbQ9RI 7dqEg5Aj0n6UYYioX3uHTJplQqV4VCG6AL8HlDeA6JfekCg93njsnh3pR6Mg2fs0Gpga 75t4WCvGIH3EMgUJIy7t2e9FTEKn1Ubfvj4GSzLRehvAzhXFy0COJZx8Ko3sGKES/W3U gmMYB2V8uAagshcEUGeqVsQ6SzGo0aUUVxuyVpmMWL4zR3kzNdYng1kRselC+0NBzemf DbxsVPemdshNQ9dtSSw/e2fbuHV+vZPL3b4GfbyWx0L0T9LrMge0/zC6f/XZCNCThbJN 5HwA== X-Forwarded-Encrypted: i=1; AJvYcCVSZf/0ZrwchJ5bpj5hi6VAv8F6BFDYPbqY9VTxu1wGWjRWMkbXDvpg95uOosJlD9I8D8rx258zjYINmYKHzfHXShbWWQ== X-Gm-Message-State: AOJu0YzaaqaOU1c356guIO22ifoySaNeRzVo5jNHbqcX9dsU2zUSo9Z0 oxnzDZZLFmp8XeLTIT9Kt7ZuR28UEnyov22cbR4vZXpFY5BN9tln+WwPiP/Ggvw= X-Received: by 2002:a05:6512:3994:b0:522:2a2c:759e with SMTP id 2adb3069b0e04-5296420479emr11207888e87.6.1716994144203; Wed, 29 May 2024 07:49:04 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::8bb3]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-578638009b1sm6922029a12.17.2024.05.29.07.49.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 07:49:03 -0700 (PDT) From: Caleb Connolly Date: Wed, 29 May 2024 16:48:53 +0200 Subject: [PATCH v2 4/7] sandbox: switch to dynamic UUIDs MIME-Version: 1.0 Message-Id: <20240529-b4-dynamic-uuid-v2-4-c26f31057bbe@linaro.org> References: <20240529-b4-dynamic-uuid-v2-0-c26f31057bbe@linaro.org> In-Reply-To: <20240529-b4-dynamic-uuid-v2-0-c26f31057bbe@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/ZANAwAIAQWDMSsZX2S2AcsmYgBmV0BaOF9IPnBV4Zghz/JzLJoa3zp5Kw8U0BC1u xOd4tr+fhGJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZldAWgAKCRAFgzErGV9k ttDBD/9Do821MEwW/qOvK6R0YvMnMH/LBqUGIhSjJUa3mANBvl76d4fS/13WXUAH/b/s6dtDoY0 AY4m8TjYgDuC43Q9cYAhakT1jiBW1SwAhPgydYFNq225ptN5lL+46t0TDbdZ6ma5j4mGOq8Jedq ZX5bFWTHWC6XOwBDzHY4l58FkpY2gJwBx8kcj+d2RqqwAH/m9WRGOjZtHchs9cF1+YchOU9fRbE 1XXx8bTr6wpA3zbEojjZTe1SWwwm6vLLEaYCj8P4Wi22wGNaGYuxA2KfiSFVKmpbBrRpOoQCwXD xpNcuEF9AAqunBpAT7RdfeRqDCJ34VTEt8u4HMK9mdbZVvgeKZk8FJo/r8qNGkj8laobnEYkfG7 mw6ovECNYgSUat+jGtka4twJYcfyAgnHWkJ8n2jBf9ULxEFLt12LoqKNhi8JWeWVCBjrQAvmLc2 vNzL8QF1HliYvtsjHpmA5YrUwwgjMFL5ZGn6AY2Z3ckWM5LoGmZC1m6SV8XK3RE3zW9T0YjstcU gHzFTqOxe8AQSnXgm0vS8M4IYQZ+b1BKEMSp0DiTqJdnXLJaFXa+6Ny7fK/hTJ3gabIWDI1LR8v a05MW+URh1MhPHPTnOVG/o8EuZDVhAWsh5eQrzRQctHzyE27Laqf2Bw90s27IYHe0umLfs7VdL3 XHFxgMj2Ldy6L9A== 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 --- 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 Wed May 29 14:48:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 799849 Delivered-To: patch@linaro.org Received: by 2002:adf:e110:0:b0:35b:5a80:51b4 with SMTP id t16csp771612wrz; Wed, 29 May 2024 07:50:04 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVmVa4zZO4XWmIfOo6k2o/B08fWSI0QG1yhJrQ76KVcK3hrE1fd580plVTqCopFxzbH5Hn6QAx66NpEBayHFp1P X-Google-Smtp-Source: AGHT+IHq2ifmv8nCQH0VORhTctTpw+COY8cKDLanS1/bo74Bq/Y0O3wJPWgaAabe8XQBWitaT7G1 X-Received: by 2002:a17:906:30d1:b0:a65:a623:54ce with SMTP id a640c23a62f3a-a65a6235609mr75456966b.29.1716994204331; Wed, 29 May 2024 07:50:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716994204; cv=none; d=google.com; s=arc-20160816; b=ad9AASVeHdDip7joxluJxLFTq+Qi1GLJY/1l3NsrbPA6HYq39fKS6m0aqYHeU/W0+t ehkyMyVpQJoRYWqeHkIii3CLNjecTNGFIfLwl8aCD32Sdf+VUl8jSM55G7pDMsRaODBN 2xDhsv7ZeSeL2Q8dryDT3/uI6/1CDfj3GJjtV/VNJYYn6BAE76fLsfXztfap77eyy1fS L2enXrU81wp4+Xn173TiG0Fyo8CHycz8gBYcJNrZVGUuO3Ef44vnAqdVSd/HFYL8njim CA5vTEHn3jSsKH+SglcPHFaLIbBq/N1daReZo7t1wya8gZvI01ASNhqUDzZR20QGGPix Y9ow== 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=5TqztJQmgbCIjWAIrDa+3qg6yWYJjKnXV3xAvJ7iRaw=; fh=o+KpHsK+J3tuou0rbki/jkGx2cYgEv16R3mrkG2AJSQ=; b=YP1hH9LN/wej0hAIyaOzMqgh3JcUFeOnsrMAg4PQBhaNPrdkfxvPbTyLX0VIW+Tbov FpgrQr4YYjnDTtFnPY/4S5eEFZfWRjHrDzwegV6gUzyIZ7BF8YIBYA2oC4PUj9IGJlAT Hr0KLNODen3H/8vDJ4ozDzCUQEQlmoONkbTmTp39sQfUxv6/7XwxEJSi64B6VbAMbXDW s9w1vhKU1o4/CDVV603QFTjyu4SiywJt4r7ctjIcbF0wEy5BDoINcxyZUZ7Agx2QCQrD NKknjrHKhW4hTDVREfpQ5ZcmwUgMdVvj51TfQQw29BSzxg5tUCdHsu5bQzcLFuLYi76J F7ww==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=D95VpD3l; 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-a642d2851easi104863666b.121.2024.05.29.07.50.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 07:50:04 -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=D95VpD3l; 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 D59AB88649; Wed, 29 May 2024 16:49:11 +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="D95VpD3l"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 51FFB88641; Wed, 29 May 2024 16:49:08 +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-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) (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 01BAD88602 for ; Wed, 29 May 2024 16:49:06 +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-x533.google.com with SMTP id 4fb4d7f45d1cf-57883b25b50so2500895a12.2 for ; Wed, 29 May 2024 07:49:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1716994145; x=1717598945; 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=5TqztJQmgbCIjWAIrDa+3qg6yWYJjKnXV3xAvJ7iRaw=; b=D95VpD3lml69K5QIVka6kzUXgG20nnAfGs3mtA0jAk9gCxA0TmQpQqW4UWUx8hp+LR +tUfGQ7NF09t06pa221BMGA3FzdYAOJsV2WS4oMJP/yu1HmnKeP7R2tterI8JywoKWqI J/2afZEXq51URr+8sPjL0UApvsCnWxG+AsAKs9BNr7DF9vuIcJGQ6bM0OtN1LM91D5vX 8yjbhNRcaFZq6zdvJNrQzWQ3r3eww+sHPAFbDvicEVcxF1nkdmxTdEf/cFjazT9wB4su XWShtArqXUn7cVrX0r2sOGpZL7kGWpL+2fxk5627v8JJcu+xGjfst5FWadrnJEr1jZrc qQOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716994145; x=1717598945; 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=5TqztJQmgbCIjWAIrDa+3qg6yWYJjKnXV3xAvJ7iRaw=; b=FkBtMgqN2X9aJ6SGflg9OAjyhHgU5GrDRolJ0w/Wofcn1yXI7hvgzjm+lIgoaoGZN/ z48M5n/AIvyQJe88zF9QUr5Ceg8O6zhkE9Wbrt5baXgyDmDZMdgYTa5LkcNUoJX1Fog6 DGivMuMhbs7j0IQ4SbdyBFGL0FEnFpD4w/2pOduqYB5YVi9wa55Orb94NRnag9d9wR+E QxFhQIbLyCngsivmnRJEGzlmlfnazW3DnidvLgxSPS2cXmyuFuJaYNUeR4OH8J7KBOGL IQLdz5iVNs8thyczgOn3HHJK/1Nh5Cg3hKPJ0hEoAGEmvo8+BboGl7xFhs2j4MNzIKXC or0A== X-Forwarded-Encrypted: i=1; AJvYcCWjuSDQM/c7SAeW4486bd/0yc/dJEXf2F/BK+FC+VxQeDDSErdaKTaStDHuSLtda4nbNGueunKd8Y+7Mxb/SyyF8uGzEg== X-Gm-Message-State: AOJu0YydDY9UIzohBrmPjma1q4ZPBck/Pd+e0HaWskplt7BazyKVAYkz XFKGyRbiCYwRIPvtWU9aK0pnUoqPIGnhpgssOwxj/U5A1HW/kYjZTqVwOM5yg9k= X-Received: by 2002:a50:c048:0:b0:570:3b8:a990 with SMTP id 4fb4d7f45d1cf-57851a5156fmr9925777a12.39.1716994145442; Wed, 29 May 2024 07:49:05 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::8bb3]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-578638009b1sm6922029a12.17.2024.05.29.07.49.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 07:49:04 -0700 (PDT) From: Caleb Connolly Date: Wed, 29 May 2024 16:48:54 +0200 Subject: [PATCH v2 5/7] lib: uuid: supporting building as part of host tools MIME-Version: 1.0 Message-Id: <20240529-b4-dynamic-uuid-v2-5-c26f31057bbe@linaro.org> References: <20240529-b4-dynamic-uuid-v2-0-c26f31057bbe@linaro.org> In-Reply-To: <20240529-b4-dynamic-uuid-v2-0-c26f31057bbe@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=QHdfRbm/u+JL8Udsf5R9COkCKzsesq/AtWafMSX79IM=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmV0BaS6NQFBRWNqgou2Ldd6s3SOv7GHmQTgLvi 9Fk898gOq6JAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZldAWgAKCRAFgzErGV9k tsquD/0cP6cm0JP19dbFrWmpcL3XdRVPIkaEYwG+kZuYhizg3d7hNP1sA13GE53h3SkGgzH0B59 JYnfaHXhqP86N2Ylc2ziJc0cspaexjype+FMHtOOmT6EmHSNqcEvc0BS9qeSb4bmcjN9vhqIrtK iI7z4J6qK6L8vSGcmEzvI7ILYIzu+5P2MmB/AOuqsjUmoF1avrHCElI4B701JbV4P+HGMGRAKoZ zFJid8+s69EOf9+9/lUujkmwLIT0KCnxQNJvqArGtGZW1vNEz3/WPQf5tgP8tHrp4gwKG2DcT1O kin5XG3/unBimu3o27RJwNAql0FyLDSAu5wuXS3LIYtatNYmcwFhZEHpmpZoX147cHndYWyo65t Ek/IDICa3kjmzZUCd3zocDAYT2Gt6tZv/W4IUkLjWiXGXLmNqbdtg33gT58tER5MAt1JXqx8ihm zZv973GzTuU3aKRqRFPJwAmMCNfLUT7x4LzJtlifAqOvk1eRq15S8AZTDUmJsJIq50nP1RVZJdi kvf0aiG1kbeehpB+zg89qgXalje97sRKsZBwwHZxJDSVehTLUtuvPArfHyTsIsTBiFHvPs3hF+O diXCcfASQgoxpJUp+XflgNIlMdDNbF1Vl0sd0p6iZ9cCz7NHAB+7geRIufPBPb632tzqtQXZCSq BjolrEsV0uOqAdQ== 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 6ef006cca1da..b6ad3dd06f6f 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 Wed May 29 14:48:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 799850 Delivered-To: patch@linaro.org Received: by 2002:adf:e110:0:b0:35b:5a80:51b4 with SMTP id t16csp771697wrz; Wed, 29 May 2024 07:50:16 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWsajX/1B9tK7rHeB7USWzVGIG7tQBQ++rtKxM7mq0TW47Ypdcm5xhe2bH/JqrRbxd1yD8xmmTxYY3uff40zOwV X-Google-Smtp-Source: AGHT+IGMhSKG6aPuE4WK2HBiBZ1tn86Ft4bmtQsgAwq8WRDHCPv28PCGxET4SghzTMY/R4cZcuEZ X-Received: by 2002:a50:bae3:0:b0:578:68f7:4371 with SMTP id 4fb4d7f45d1cf-57868f744f8mr14506099a12.3.1716994215901; Wed, 29 May 2024 07:50:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716994215; cv=none; d=google.com; s=arc-20160816; b=GKefgEVYyUHSi8GDDCqWn0Q6FC1MGtMqFyibcUxSIIGg0+WkNzLKsyTZ0lNrXLLvdB xxz/STPqvj3jkzUWvpon16O2FG71hk240I0vsegoem5/iSHVyo3vYCfBd8PsyZTa3gd9 uDawS8HuD6jriwv/H+86ug9ZXH0Te5jYT+L/1HvYz824cK5r3dqbcbDiQ74e9NGDV5VD L+Uihjn9iH5ypJvPIM1gW9uZh5dQb7eEBs8/9kvoEeWoF//1RdVQVsInfAjp2lkoACeb 4mut97QQ0u2MgMQYfBmtb/x32hOXDVQSQkam8TSlfBo1wLwKPnoVADRZ1UunL1R9ahl7 GgGw== 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=jT+QFXiAPflgYbqk5QzqNQ+b1J4NncefbGAThlZmb7Q=; fh=6KdXSMOqVddd6R8H8/41AzRvGP87B6r7SElyRXFOjEE=; b=NDxEUFZfg3ZSLHROQ1W2Jfitt6zkJICilSMGWtVnNpl29aRxoKxAjrK5zufChV+MC9 sycrore+aKe4jcWgYlenirBryUtMF/AXcAEWbDXt+pSLsaiBk2Nwg1LDCe8YT7FmBBGs rPIrRArfW4RWA79xSJQN03fAwyO7QDZiVO44oWxmYFMPpSWbq2kzMGo7GWO8ktxqQAJT dxnlLv1ezcrpWawbXBPx9tYrVNiooUFw43lURVzxJ3weeztX5Z/8cRz95NCQcXw91HFV wSmG1U+38LvFrM7iUDRchmZvgVO29cDyNixuOs7AiNeMJA7hhqQxBmN1eZ15Fu3cGasJ F8EA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yKohH2U0; 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-578676ec1b9si5110458a12.580.2024.05.29.07.50.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 07:50:15 -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=yKohH2U0; 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 4A8588864F; Wed, 29 May 2024 16:49:12 +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="yKohH2U0"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 634FB8864A; Wed, 29 May 2024 16:49:09 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-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 4AA1B88615 for ; Wed, 29 May 2024 16:49:07 +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-52b78c65cadso573338e87.0 for ; Wed, 29 May 2024 07:49:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1716994146; x=1717598946; 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=jT+QFXiAPflgYbqk5QzqNQ+b1J4NncefbGAThlZmb7Q=; b=yKohH2U0vDgkvoa8EFahYwUxCb/cP1P+a0ecf38cEr+BSH7CIPVSuyQX0Vg0Gyl8uT 7V8xooPiYvyLITfKnOHE7+6XmEuCiVjwy1/caFkpkAVNkItf5CGdBlmNfe4ljH2entm1 BnRquBSVWzYpcn9RyJcRvRpeLoS0x1QyIxdhba/WMvo4u0+pHMfMjK/UDY2Ljgfw4IGl 712mzoXFZMCEtMZlNmRzNG+SLq0PaBclcbVl5pwzC4zAcbGpWX0BCL0kt24SMSeAVCfk 23xb6TKp2/Kn+lpALnFIXWmMDTWITABa7J08QJkWwJ9L3WiT192JQSbMlTKCSFL3mAzp yUDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716994146; x=1717598946; 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=jT+QFXiAPflgYbqk5QzqNQ+b1J4NncefbGAThlZmb7Q=; b=i0ZQHsTYfa/6a2lN6Jn7IWb8vAyu80JjMRjc/4Od1mxcTyCSxsbCSG50k4bvGJP5sK E23ekV2S3Kgu+g2cfQGhoY2bpZKvZaFme2DKIJNtcsbzArGl90od1guGtBkPcr+bLljh QKkN2ih/L1MvbN+c7aKSk7CcrD/G3OPU0vVbkrnn+0M9MMxZzAEIi36bmiTm5FeLpAwg w6r0ETh/++qpLhUtd19IDVnb55XEjje5BHN0jAyi39UKW42NB/x/5PBS7zVsU+QGgwyI C+qc4oAmq8nrbCwfwPgifnPwJ0ikimMvMhmgZykAkA9GkEAihApug4cGqelkVMNkrqxz lCfg== X-Forwarded-Encrypted: i=1; AJvYcCVoMSZNMO8k/pPzYVbDN20SEwKFCdFfKIy6LzNSNYwsIp/NbySMGGw9XE3VC/4pykz4xDm6sR+4eoi7oORIV4pyp6IydQ== X-Gm-Message-State: AOJu0YxbA72S3D2kiC2WOHXKZmEWWqiRgvzCFSvXEMPNC4JggtCiwgOh R0BrMQEQbvyLt46GeF5NJk/JRpvtYZS6H8F7JJs3D5754LU3shS4pd4ioDonbiE= X-Received: by 2002:a05:6512:110a:b0:529:a6f6:1b03 with SMTP id 2adb3069b0e04-529a6f61b4dmr12311826e87.14.1716994146530; Wed, 29 May 2024 07:49:06 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::8bb3]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-578638009b1sm6922029a12.17.2024.05.29.07.49.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 07:49:06 -0700 (PDT) From: Caleb Connolly Date: Wed, 29 May 2024 16:48:55 +0200 Subject: [PATCH v2 6/7] tools: add genguid tool MIME-Version: 1.0 Message-Id: <20240529-b4-dynamic-uuid-v2-6-c26f31057bbe@linaro.org> References: <20240529-b4-dynamic-uuid-v2-0-c26f31057bbe@linaro.org> In-Reply-To: <20240529-b4-dynamic-uuid-v2-0-c26f31057bbe@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=5650; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=SeMzuQyQPTJuNY/VxRIKXgLIczQuxO4g2VA6NP7Bjj0=; b=kA0DAAgBBYMxKxlfZLYByyZiAGZXQFrIzfNFcSKldRAIpTECd3r9/8MAa08bETG7XfGfDLTIf 4kCMwQAAQgAHRYhBLZRoUY8ar7QaQxVzQWDMSsZX2S2BQJmV0BaAAoJEAWDMSsZX2S2fG4P/AuQ OrfYfKn05YErIMPMkyMlwajzV7QE3WZUL3yPf5u+4HORS5Vu4tlYeUW/84zcI7q22YJKC84o6Sr HwFDEC3tZzlyyLqaFO/9SOckhIr9nZj0eS3vdAH4xYHaRTneiuzvgtRkYjzArtkhP2AP0rnkpgM XLm8El1CD4otCxi1GbfITT6aqJHda0c98Y5Rb0WZSri39JRIXiBQrBQj1yLnBGLEycmckt4wv8C 5coG61VqfQS49uK5K/7ITrAhy9VN1NrSScjyR13hDxskJRTRjUP/t7IFad12w+bSYpE69wCvnRf eU3SEhabu0C4vLd5mfdSOUvb55EUa7Cyztt6FcLPK6Ep6JsEnrUI5X3hX77trOvc+hcYf/7IbRQ OZMmBv0zaEoH/bS86CEVULc1FoC04OD7ZFdc80+c60kBXgwAq+LDo/4RQHtcjSh22DtpNEg2ike 7XbZ8GgXAs71vWLPBZYCTTw/cSyLFwW/faN48x16FK4ltQ6KKFBMNwp6yWnSIZcmuUDG1AlMRh1 yR3oBtUmnPx96hZWr4nOi++fUdb7mIvG+wtzr7YNct6ErHR5df7pT5/6ZMib2EUbS22hrIjsdIb BHsi6Yn9yB3UpP3/GoNPBHn4fBrWEQxAYUVceEhYD20JtcocHvSBCNtgrRUOqgmKP2TCi9jflZp weY0s 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 --- tools/Makefile | 3 ++ tools/genguid.c | 154 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 157 insertions(+) diff --git a/tools/Makefile b/tools/Makefile index 6a4280e3668f..7db7723793d5 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_MKEFICAPSULE) += 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..dbac65d42623 --- /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); +} + +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 Wed May 29 14:48:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 799851 Delivered-To: patch@linaro.org Received: by 2002:adf:e110:0:b0:35b:5a80:51b4 with SMTP id t16csp771799wrz; Wed, 29 May 2024 07:50:31 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVctZduWFILno3nMlh0ayQEUvkryj3sJ8Iv3TYJls+mA+6JMAnAgRvpr52vTD6O4lx5QbNQV2QV9Jx4EMU9nP4q X-Google-Smtp-Source: AGHT+IHP32o4w50rs96gIJ9u218W82agkxSstvU3gd6xOQ9T5xC6qe/otLayDJnmsII8uN0YPd9X X-Received: by 2002:a17:906:1547:b0:a65:c143:b3d6 with SMTP id a640c23a62f3a-a65c143cab5mr64821666b.1.1716994231432; Wed, 29 May 2024 07:50:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716994231; cv=none; d=google.com; s=arc-20160816; b=JBAGU4foemtOUx3ZrNkHgC0Xopu0hFgVn3/vwuHZXhMDqwFUQa4GFYUVjhD2PlxaLw q0i1w9L7jOrZ20f5shswUAOsgW2aLGHLw6t5WMaog0zSG1l/hOeXEnWZWbnI1p/bUAzP wX3I3iuzhdNPWPzgOPWEEJs0c5NIu8OEdjMZ4vVUa9RbmoMnM47ceQUYy6V15VpJ+CtQ OaYldqohvTeAbJlsno9VmWE5FNDVFHiR9RrWzMvF71rTBP2W7QHXdARyCWSiWURdg5DB DMAaRisfH7G643KjurJkpYu9PRXcRtZHK45TjXb4eO57xuziCC3tVmWQKBER6mG+MzN0 2kGQ== 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=CNfufS4BdB1Uy7nUc8cXgrmVcwQ6WnWEs/A/AegjVh4=; fh=W2MaVgqGBCgTk9VrqAoNMPAxKCHpP8g6d4ou9vmVoXE=; b=Xtddtpm3hxyaTULe2elxYE19VygCSpUTdWqlfttObj8r8V6kVMZLub6pLzD/3ZCKQB Z2dTJpoq8wyjWv0DXfj3IHF1E6/cglzHQN6VXm0NG+48xp3rMTfTcjYfR0VoKkQFIXa+ HvyVvK3AFRdvpxAsozM7khmf/sfk+prgXT0/h7hyY7/edbHe7BFnmrzVsOVJWpdyKtS1 X6yydcUlQL34WsiLNrzYlbEGjmnje5go1bwCa/9s8PrvRswDx5oJZogebPxCd1S1Xros Cc2GEUebxJadcdWxmkqH3XBZAeF6fYSC4/asGJuhtqA0kaSLBbTnriM44R0jJjF5qDcd 3U+w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZYquy6Qh; 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-a626cc644basi628614966b.598.2024.05.29.07.50.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 07:50:31 -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=ZYquy6Qh; 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 AB24388657; Wed, 29 May 2024 16:49:12 +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="ZYquy6Qh"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 535D988619; Wed, 29 May 2024 16:49:10 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-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-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) (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 5D3598860B for ; Wed, 29 May 2024 16:49:08 +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-x531.google.com with SMTP id 4fb4d7f45d1cf-57857e0f462so2477754a12.0 for ; Wed, 29 May 2024 07:49:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1716994148; x=1717598948; 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=CNfufS4BdB1Uy7nUc8cXgrmVcwQ6WnWEs/A/AegjVh4=; b=ZYquy6QhQJlRTIcR8JRdoNSfppKsEyi+eGBR13lBc+KlDtNnuocxLwQuhNZ4tT6CMl vgQyaI0rc33lzf1nVNENcLhyOfWhBIVZ0z2BBh2Gbp2vihlMfLyZXP0zfnf5d/ycS6Mx z2L2a4HEU7nc5WgmbWjQWvoGBcaNnKwqMtcnNEuoHSYlIExMiB0GTlQ9DfQVe4Bgj6ja 5hVLDGNXE7lg79JTGTbUSf8aIX9j8Ttt/8Ug0Nn9sWPvWnDSm8a4JyE//hduAonLN5G2 I075YZebviXD6ajKXGHxedmpSGVozAOOhQecKtxgeE+Jfg47KM4rYI/YnQSNmjBQyzWN Azew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716994148; x=1717598948; 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=CNfufS4BdB1Uy7nUc8cXgrmVcwQ6WnWEs/A/AegjVh4=; b=WYA7st98wiqPAciaLnTmxPA9emzHGpR56P8atGedlRd8OVqR9iuOScv/kr/XkQ0zp0 pmzP4bu2Xgm9VXrviRa/xtqu97kB9atYyqzSNCquCul3OeMpK5QpkWkHbbL4HbtG2TaC gVbSet0D9Sk4ZBkBsLglBTPS/a15hRlvQF2gmcbsqHYpxkZjliNF8TY3/+zs9+GVDksK lUkV9E5g7FQpJX049wn1EhbHm06LCty6NkVo5H79qL5B92NA5ejrtGA+EaxwKKCBlo5R 2bE8FHnWrZWmGjZiVGsd1epnWeXjm3XFvObbILx7O4y//e86cqf54T2HjAXsqBuXlhqS MuQg== X-Forwarded-Encrypted: i=1; AJvYcCWwkxjQfHalXnC381iiN/7iMX2n8mzyyYG0aP7OhQfWhm9lptoSUIEug36AUrXiKhPYkSedeNWnQLENYSqMomKcHsEyQg== X-Gm-Message-State: AOJu0YwegUh5iV1nM652/0XdsWOzShfHXKE/Jaembj5Osp5QpG4Hel0N rmb7xVBC2f7+OxCYqWn90oKTsA0u67p5UTAVZiQkHVaImELCE92YRf+u5jgbQX4= X-Received: by 2002:a50:8a9c:0:b0:579:fb7e:210d with SMTP id 4fb4d7f45d1cf-579fb7e2991mr3181562a12.1.1716994147807; Wed, 29 May 2024 07:49:07 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::8bb3]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-578638009b1sm6922029a12.17.2024.05.29.07.49.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 07:49:07 -0700 (PDT) From: Caleb Connolly Date: Wed, 29 May 2024 16:48:56 +0200 Subject: [PATCH v2 7/7] test: lib/uuid: add unit tests for dynamic UUIDs MIME-Version: 1.0 Message-Id: <20240529-b4-dynamic-uuid-v2-7-c26f31057bbe@linaro.org> References: <20240529-b4-dynamic-uuid-v2-0-c26f31057bbe@linaro.org> In-Reply-To: <20240529-b4-dynamic-uuid-v2-0-c26f31057bbe@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=3313; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=higGEcp3P/+9pD9qAWm97NBYRZ+vVffi7vKUe5vsaIU=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmV0BaPROmRqn6St2d+faa3GKt7E2vy+AolHq8m gZzNm9JqaWJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZldAWgAKCRAFgzErGV9k tuIFD/9eUKZQCwfWKeit5eWx8YW1EOfNAbJahem9H809oBBK75My994g2nbRhBzQIswevWxU7xq SqRRblsrBOkNUNRVitHcIcCPsLO8FoChVVL+2CSHf2oeTi7o0LVdaDA7TvzNGZK+t5KMtNlZCQw H8Im8mNRMWK+Gp5adF5CCyYKlnes9o0oX35jM7+3GFebio7pMNLarnj0UARIot5iwyRO1XVFtvN Px9UuxB/U7fDfeRIArAUhdG+O+/gYype1mZUh5WqQ0R4v+NY/0HX2p29NtGf2mNxlYJZ3zrQrcY 8ntTgbZdNCSgu2jAlY0kj5XyuNEU6I4xyrFe35uQyoUPw2MKVLoFB0yWszqjSYFv/gMufdLACp9 1eoUmJZsPI9PitesJT8k3oqNTTMOJFr0sMR/Y7CLpucjIGKqV6qbZVBEPYij6qP3Z9Fq7IZxzLJ SGz+uyoP8IK+8NCOWBF32zqoTgsvps2a+V5x3qRgj0YWHHkO4fAtX+SrwZ5xNhYpY6A41nSUhM9 8bVmSbs4pWGqk5bIqQTBFRC7crBMJzMiZmIK8u8LkaAThQAjyLICUDIjy7Z8Y+1UCbGl9/01j8i miABUl90/f70RcpBcFo9uQCFxRBhx0afOIrjdRSLXgKZv9Sm+T9n0hLW8m5nsYhtl8yB6uTKYBR DdX42T+BZ0/6zWw== 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 | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/test/lib/uuid.c b/test/lib/uuid.c index 0914f2c47e77..843678ec7f00 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,89 @@ 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; + + ut_unsilence_console(uts); + static 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) */ +