From patchwork Fri Aug 30 12:34:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 1978975 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=p38RZgDq; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WwHfP53LSz1yfX for ; Fri, 30 Aug 2024 22:34:53 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 146FD88B55; Fri, 30 Aug 2024 14:34:41 +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="p38RZgDq"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D749C88B16; Fri, 30 Aug 2024 14:34:38 +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-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) (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 E8BD088BB8 for ; Fri, 30 Aug 2024 14:34:36 +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-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-42bb72a5e0bso14635425e9.1 for ; Fri, 30 Aug 2024 05:34:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725021276; x=1725626076; 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=+/T4cIWM0dAhnhIjw/m7a+fn4ePAgXVQbnkmBMx8NVQ=; b=p38RZgDqWuVlrKI9k0qDPw6IQlrZmFRRWZL6rfm0z+bFEbaivz5H2VY/NjMGeasP5r YArR31lEn04QAfOx2wjvxccyVgqyb8JNvZ8CW+CtYMOxAPqY29/AUY9CnJNWYBJz3aj4 g1y/h3YrphdMGqboLlNDimn0DC7F+Nr5V09mEWPAGhwIAE8lr8rs5s5SmTtKgpYDwI1q faS78e0eL5YZD5+koTdsusXnz4B7cglFSk1OgQ2KeLV2lAfgU3yZr6/vt6wxRYPa+mT6 bcszgQxuaWUfn3IuYnu1sW0KGfQkZb+uZag1YewCZOnGG68Tat+fbs3gK4ifbYrWkSaS wIqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725021276; x=1725626076; 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=+/T4cIWM0dAhnhIjw/m7a+fn4ePAgXVQbnkmBMx8NVQ=; b=wSyWF39GQlqiVyHqiCLhvzFk1EFFzOAsuZzm38MmBRQuucn1ivVMsz/tO4flQEWa6P LC1KT6pVx1MoXgGpt5mzKfELt8qM/6YdECU5YsARgbHEmMjMN+v5pCygL2C7lYNLKYfE msYSctVzaamDhAmx7kLSdDC6T0kx+sV3ayNnFlcK8ocGAaf5HXttfJuBesS3+OC0k4/R wiqpz8ANA2Y90zXFIM+Gclv8UfJo2RHbcJkACJ+olwVZHA2gdZsv4TTuhQqLe/5brqAP pwrFk2MNfdMtmzOQnf45oqcBVeC7x7ERrWi+lr7C4aFYdNZlo2vLSjr5srJ1nCYDF3SS 7efg== X-Forwarded-Encrypted: i=1; AJvYcCXqJbEe8rEUTvKHI96maGfNV68x1JD8BiIK+PhFr/Li+bY/hOx8dkbvJ1bGbk4SH6MoojYrdVA=@lists.denx.de X-Gm-Message-State: AOJu0Yz9OxqlVQx3oY7wCB4tWwnqVo2oKpqVH5JFI/mVe0toXYgvToyE /48JuPTjECY63huVKC7eNkH+mCntV6/RcmLsAfcaazyYrjFqxYLWRERewAUr9Ik= X-Google-Smtp-Source: AGHT+IHb/qJx2Ms+pBXmBzU2LwaL5d506Mmv5xMu6/ZPu8XLi81qECc7u9BRlmzDNa0w1VA5KEv5cw== X-Received: by 2002:a5d:4e50:0:b0:371:8bc4:49 with SMTP id ffacd0b85a97d-3749b4d8a38mr3904727f8f.0.1725021276296; Fri, 30 Aug 2024 05:34:36 -0700 (PDT) Received: from [192.168.1.17] (host-80-47-105-51.as13285.net. [80.47.105.51]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-374b960ef94sm648207f8f.103.2024.08.30.05.34.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Aug 2024 05:34:35 -0700 (PDT) From: Caleb Connolly Date: Fri, 30 Aug 2024 13:34:31 +0100 Subject: [PATCH v8 01/11] efi: define struct efi_guid MIME-Version: 1.0 Message-Id: <20240830-b4-dynamic-uuid-v8-1-79b31b199bee@linaro.org> References: <20240830-b4-dynamic-uuid-v8-0-79b31b199bee@linaro.org> In-Reply-To: <20240830-b4-dynamic-uuid-v8-0-79b31b199bee@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=1211; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=wX5DcO369Pdn7hiHbsWotgMj71dTc9VuhjXdEd8GBUk=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBm0bxZbY/hHtTnqSlDwM3FXS2nWRH+m0CRDgDWJ 2HCEaXf5yGJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZtG8WQAKCRAFgzErGV9k tm0LD/4jMuQlmB7Bxri2/c0wO2+7nRtIty5RRd+miDAqqNa+BObl0DiB0b9LD18elUApP7TsXLW xsvWzhKs3zfvdzQ3iCiI2vL0orHTTpD4zULYEI7K/ZIV4YZDqvLowIv+jBulJBTixBgz9FWVKL4 9IfR10PbmVVG4cxJKu5x93AD2sH5sqseOYeulzZYKuO2/W7M0PsLmCIw0yzUeO+LRTJqUKA0zwa c5n1MuwlKFr3hAq1iSzm0wqKTMMNpATAFFSLrCDEfrM/7rDf1zsKXWLz20jMiJC/kcbdhubRKEA nAd+lfjvbLUQLY6eQtuUpOg20CnKhSFtDyKEwicShijwErvWkRYpckELmQSl48FohXc+guBzWGV v3KjFjZRCyXl32nE/N/sdDMCyR7gIBVPyk0BaIFD06QJHQ/loAkJf64bzqkJS5zQuVQENN/o+jQ JxYtybQBoFulTvgUjy2nwdFqj7M31GaCYJPs9sgPV/Yw1YbjvfMg1musGiSxCxuOhqqtcbRk9F0 pcKvpK0L0udIUoXCSRhxev/J+Z5/2f/CV57q1Zis2EDREJUI5EOnLE8dEL1aP6FU8wbzhm0QtzI 9dA16gDUJHq3CH55TgCsSgKmZy9qHtBuRSUkfm27eawcTF4KeQTwGgplCV/Fu21luYRLkgAGDZ4 DQTt+0nNsMiQBUA== 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 This let's us forward declare efi_guid_t in the UUID code without pulling in efi.h Reviewed-by: Ilias Apalodimas Signed-off-by: Caleb Connolly --- include/efi.h | 2 +- tools/eficapsule.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/efi.h b/include/efi.h index d5af21399468..84640cf7b252 100644 --- a/include/efi.h +++ b/include/efi.h @@ -73,9 +73,9 @@ struct efi_device_path { * EDK2 reference implementation both define EFI_GUID as * struct { u32 a; u16; b; u16 c; u8 d[8]; }; which is 4-byte * aligned. */ -typedef struct { +typedef struct efi_guid { u8 b[16]; } efi_guid_t __attribute__((aligned(4))); static inline int guidcmp(const void *g1, const void *g2) diff --git a/tools/eficapsule.h b/tools/eficapsule.h index 6efd07d2eb6b..97d077536d5b 100644 --- a/tools/eficapsule.h +++ b/tools/eficapsule.h @@ -23,9 +23,9 @@ #endif #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) -typedef struct { +typedef struct efi_guid { uint8_t b[16]; } efi_guid_t __aligned(8); #define EFI_GUID(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \ From patchwork Fri Aug 30 12:34:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 1978976 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=rrBNaTAU; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WwHfc3pcwz1yfX for ; Fri, 30 Aug 2024 22:35:04 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 75C3588C20; Fri, 30 Aug 2024 14:34:42 +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="rrBNaTAU"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9AF7088BDE; Fri, 30 Aug 2024 14:34:40 +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-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) (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 1151E88BBC for ; Fri, 30 Aug 2024 14:34:38 +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-wr1-x432.google.com with SMTP id ffacd0b85a97d-371b2e95c34so1043765f8f.3 for ; Fri, 30 Aug 2024 05:34:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725021277; x=1725626077; 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=wWcgvpeFi5VpCZSZBuDE81Oi1RID+Jh+SdhJoMRzmwE=; b=rrBNaTAUbH3vwjC0PPrtp1GMbFor3z0bXse5smlGQpty4xGmLz0D+3opKXDjVIHZTz tUnocictD74Upo13M8ZC6iCDOqZjRrCf+uRGsQAfHNR7CkZkF1B0J/B1PPS3HOkxZOZt Ai602ejJHJQMM1BqszGDs6lomyvFTZfhmdV0eX/cpaT0YB6kXAl2IDitGWiAGbEO0iad GAFy3t/U9msYZ2+iyVbgtRRXnJ3RMB1WNcbXm1HuRuNbGjNIjOvrzmrDwhyNX8AmsXsk Vxre/iYpJw/bpCLowZuErAepGq6utVi0F7S5cIki8lxRPKwQivf6n+xpSSfXxVm2XAlC /L1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725021277; x=1725626077; 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=wWcgvpeFi5VpCZSZBuDE81Oi1RID+Jh+SdhJoMRzmwE=; b=kG1AjfxwFWCsk9HgbGqZHi3Q180usB/BDo9hof0UbKDt3RM9nO5Gkg+SK3MuNvFzSm rJbAWptAzyiZTDZqNde20/SkVGAYVTSGXVH3zpMHqQOsbsixdvqHOQvdw+ZYayBe2XN+ qagUpu/M2UVEoSQ2TLdB5u7MGsl7gByPZiNTi5DoNdOUSWQFxssXlwrO2m/JV8BNFusI 6RXoh40u2Wmzyr373sXmMnrOMtzbKv6WxDQSRw8tRSLhsrR1BMbEdAiANsJFuqF7A+8y znGdoqcg+YRJsZDUd8IXu3zz5W8xfl61mW/KjzoTHKXpGyLvaoRwIOglosuy/UqlNjPu YcFQ== X-Forwarded-Encrypted: i=1; AJvYcCWsw7H6/LATJ4r0eFO5XJDBAgCWGvpNFGmoO/rUo+M/lsXsWB3R9SOoPRzNsB0Hbb2kzBODIE0=@lists.denx.de X-Gm-Message-State: AOJu0YxAtICC2lX7L53bGq8cHUpvd0ml94x6mE8iXe3yxVfHnlDKfiOk YJxSFxP9GR6VSEtZoAoG0bNEbf98EcNZns0VVznsgG+SPTuWVqnszI4dOdnS3wo= X-Google-Smtp-Source: AGHT+IG5jNnAtowUl9WLamprEZ5+2S56Ai0zjKIJzSun4TnvOrKt2SVqD55CngjJ5invIPGnasZ8Gw== X-Received: by 2002:a05:6000:e44:b0:368:3789:1b6 with SMTP id ffacd0b85a97d-3749b589779mr4319696f8f.47.1725021277264; Fri, 30 Aug 2024 05:34:37 -0700 (PDT) Received: from [192.168.1.17] (host-80-47-105-51.as13285.net. [80.47.105.51]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-374b960ef94sm648207f8f.103.2024.08.30.05.34.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Aug 2024 05:34:36 -0700 (PDT) From: Caleb Connolly Date: Fri, 30 Aug 2024 13:34:32 +0100 Subject: [PATCH v8 02/11] lib: uuid: add UUID v5 support MIME-Version: 1.0 Message-Id: <20240830-b4-dynamic-uuid-v8-2-79b31b199bee@linaro.org> References: <20240830-b4-dynamic-uuid-v8-0-79b31b199bee@linaro.org> In-Reply-To: <20240830-b4-dynamic-uuid-v8-0-79b31b199bee@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=5505; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=UyWycvTmTLWqQjiIAg+pJ3mFYfmr6TmwDDOF4d8Bxlo=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBm0bxZhg78vWBx7WiInWPwNeJDREosCOaS2I3Ix 73vC29YJKCJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZtG8WQAKCRAFgzErGV9k trB0D/48XCGfYau39U+sJQTq9GywwfWIvWPP/bEPODIq0kDE192cTIfFFgNXAh1Ldv/EeM+Wx17 76srF4w5HwrkxkjyoMrnqB9IN6UcGNB2f+99q0bKkag3UX3ahxyf6tWpDKpafjij4eyMOyGxzCi 9yC87X8mdMMMc80GzatH5ZW4iMHfjt87QaaDD/LHnQAIb4vkn43bE60IS3yJl5z+cfcMVQywJIR kaJymzxA+QpPIfKb5mTMyg6IB2/zh257LIssJNBw7FRnjcdQmqclMmI7M2EruQBIVTA+47l2Ugq zyTqmjrn3z2HC2FUCCWksAAr2yRdGrpsiEGV3YQPx6JKsKvsVhUpl8Ze1Z76/HCrIj+OwQRtIRD CSlWXGTBOnECR4TxFeV79Lcj3ITOjcoGSmMu4BYCYu8Y4LRyB7tiCO5gKC1ZABE4eWoZJS0K6P8 xOWV7sDZra39IIgp9WcYI4goYgGSQCG6C44HuBL7VqmeRXUHNlnQFx5BansaI37OVZtA4VtT+TQ vLz3ZLK+TBEXF7F5sF89qCxMIAgynSpVHlxgHmPRgU3c83wNDwLnAFv+9A6UyKDnmUzd2shYN4w IIZ4Iv7RG6XDD1n0XONpKE3ymbohy5d8HJkZVzVG9Zlabas4+t1UDxWC8FOhKe5B3aQzoqYcCmf 6H4JOgdMA47U/Gg== X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Add support for generating version 5 UUIDs, these are determistic and work by hashing a "namespace" UUID together with some unique data. One intended usecase is to allow for dynamically generate payload UUIDs for UEFI capsule updates, so that supported boards can have their own UUIDs without needing to hardcode them. In addition, move the common bit twiddling code from gen_ran_uuid into a separate function and rewrite it not to use clrsetbits (which is not available when building as part of host tools). Tests for this are added in an upcoming patch. Reviewed-by: Ilias Apalodimas Signed-off-by: Caleb Connolly --- include/uuid.h | 17 +++++++++++++++-- lib/Kconfig | 1 + lib/uuid.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++------- 3 files changed, 68 insertions(+), 9 deletions(-) diff --git a/include/uuid.h b/include/uuid.h index f5a941250f48..1f4fa103b5e9 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 @@ -45,10 +46,10 @@ * where x is a hexadecimal character. Fields are separated by '-'s. * When converting to a binary UUID, le means the field should be converted * to little endian and be means it should be converted to big endian. * - * UUID is also used as GUID (Globally Unique Identifier) with the same binary - * format but it differs in string format like below. + * UUID is also used as GUID (Globally Unique Identifier) with the same format + * but with some fields stored in little endian. * * GUID: * 0 9 14 19 24 * xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx @@ -142,8 +143,20 @@ 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); +struct efi_guid; + +/** + * gen_v5_guid() - generate little endian v5 GUID from namespace and other seed data. + * + * @namespace: pointer to UUID namespace salt + * @guid: pointer to allocated GUID output + * @...: NULL terminated list of seed data as pairs of pointers + * to data and their lengths + */ +void gen_v5_guid(const struct uuid *namespace, struct efi_guid *guid, ...); + /** * 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 2059219a1207..5a48c016d2c5 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -72,8 +72,9 @@ config HAVE_PRIVATE_LIBGCC bool config LIB_UUID bool + select SHA1 config RANDOM_UUID bool "GPT Random UUID generation" select LIB_UUID diff --git a/lib/uuid.c b/lib/uuid.c index dfa2320ba267..c9dfdf007a18 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,58 @@ void uuid_bin_to_str(const unsigned char *uuid_bin, char *uuid_str, } } } +static void configure_uuid(struct uuid *uuid, unsigned char version) +{ + uint16_t tmp; + + /* Configure variant/version bits */ + tmp = be16_to_cpu(uuid->time_hi_and_version); + tmp = (tmp & ~UUID_VERSION_MASK) | (version << UUID_VERSION_SHIFT); + uuid->time_hi_and_version = cpu_to_be16(tmp); + + uuid->clock_seq_hi_and_reserved &= ~UUID_VARIANT_MASK; + uuid->clock_seq_hi_and_reserved |= (UUID_VARIANT << UUID_VARIANT_SHIFT); +} + +void gen_v5_guid(const struct uuid *namespace, struct efi_guid *guid, ...) +{ + sha1_context ctx; + va_list args; + const uint8_t *data; + uint32_t *tmp32; + uint16_t *tmp16; + uint8_t hash[SHA1_SUM_LEN]; + + sha1_starts(&ctx); + /* Hash the namespace UUID as salt */ + sha1_update(&ctx, (unsigned char *)namespace, UUID_BIN_LEN); + va_start(args, guid); + + while ((data = va_arg(args, const uint8_t *))) { + unsigned int len = va_arg(args, size_t); + + sha1_update(&ctx, data, len); + } + + va_end(args); + sha1_finish(&ctx, hash); + + /* Truncate the hash into output UUID, it is already big endian */ + memcpy(guid, hash, sizeof(*guid)); + + configure_uuid((struct uuid *)guid, 5); + + /* Make little endian */ + tmp32 = (uint32_t *)&guid->b[0]; + *tmp32 = cpu_to_le32(be32_to_cpu(*tmp32)); + tmp16 = (uint16_t *)&guid->b[4]; + *tmp16 = cpu_to_le16(be16_to_cpu(*tmp16)); + tmp16 = (uint16_t *)&guid->b[6]; + *tmp16 = cpu_to_le16(be16_to_cpu(*tmp16)); +} + #if defined(CONFIG_RANDOM_UUID) || defined(CONFIG_CMD_UUID) void gen_rand_uuid(unsigned char *uuid_bin) { u32 ptr[4]; @@ -394,15 +445,9 @@ void gen_rand_uuid(unsigned char *uuid_bin) /* Set all fields randomly */ for (i = 0; i < 4; i++) ptr[i] = rand(); - clrsetbits_be16(&uuid->time_hi_and_version, - UUID_VERSION_MASK, - UUID_VERSION << UUID_VERSION_SHIFT); - - clrsetbits_8(&uuid->clock_seq_hi_and_reserved, - UUID_VARIANT_MASK, - UUID_VARIANT << UUID_VARIANT_SHIFT); + configure_uuid(uuid, UUID_VERSION); memcpy(uuid_bin, uuid, 16); } From patchwork Fri Aug 30 12:34:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 1978977 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=nxFJroXw; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WwHfq3N7sz1ydy for ; Fri, 30 Aug 2024 22:35:15 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CE2DA88C36; Fri, 30 Aug 2024 14:34:42 +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="nxFJroXw"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0438E88B16; Fri, 30 Aug 2024 14:34:41 +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-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) (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 0474A88B16 for ; Fri, 30 Aug 2024 14:34:39 +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-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-4280b3a7efaso14990765e9.0 for ; Fri, 30 Aug 2024 05:34:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725021278; x=1725626078; 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=Zs4Gu8Qf2U45wSZmb1eyVaN9T3a2AvbsPdlCbYpA1zc=; b=nxFJroXwIGpDWJxOEVGE0IKyOi+H2mkVTVh1IxVzR3gWgCo62s58e0cLuSp5hkjW5k Z1FoSvKwqZ5L79jI0kULan50ksJpTGcPLmHOGWmUIbssRqZ/nvs9mTHBC/TyY4uynOlX OE/DTZTYpylkA3m50jX3UzpLphd24AarHtdol0anfR2H/HVl1S+HJHzu2zONUdno39Q+ 35OqMfIMTtQ6krc/jZzbfBBeCdyqbQhiLQZ5x434iX2hfkFWJIvP+8EjaxOPn2AqfSft ztp5MeEP6heBxWsb5Nj69/YohlDlA/dVhQaWrOUI4MYd3QQxRJZF445W3uMEYr8i85jX NR7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725021278; x=1725626078; 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=Zs4Gu8Qf2U45wSZmb1eyVaN9T3a2AvbsPdlCbYpA1zc=; b=xM23eO4MpBx6370wzW622mfAoxw5HSVCqXhJ1yCT7NYbk6uOZoyYTd0jqkJ2XWceHR /tlNpx8Q1QUxaKpU+Gv05IoQqdc6g7ug9T0rt1TLwrXxpj4Tl/Ohzlh6wmhrDyWTfo// z1shRQsXFMmgc3/oGclv82y5b0OK/p7H+JD3CrXvTBVlORnkKkQLyqH3FaG4R8chux4Y uezMEi2WwPQi4do4N6yGlkj75z6Yy/cl4pz5Z99sexeGklPHicjgEu08YdzZ9Oq+Q0Ed FGbqgZd7DgSukgvH6nKFM2cwx4omnRgFdcPk2Jd2F1muhIb3EwV0IpR7sVmb2Az+XklC K+Mw== X-Forwarded-Encrypted: i=1; AJvYcCVpvi/aP3HKy+VGzVsDQEb3s/aXAN4fsy6E4+3vNfHLoChI0g08nEAvIwTH8bnyLytonMONwSo=@lists.denx.de X-Gm-Message-State: AOJu0YzaqtIhNjF55auTnL1g7muOg07MDYs3PvjER3CtJN6Qluom0FG2 bAYPutxoCIKtmVcA2KOcY1vCdRRtnMcmZRbcttywwa3ANB5T01oYK8l+3GtQQtU= X-Google-Smtp-Source: AGHT+IEpYWzW9gRG4yQ/DuH9qL5f8bdE65oalkNXpYXuZsiu0HA3lEcEN+NIoolPnRiMWgZEQq3GGg== X-Received: by 2002:adf:a3ce:0:b0:371:879f:72e5 with SMTP id ffacd0b85a97d-374a956618bmr1315433f8f.20.1725021278400; Fri, 30 Aug 2024 05:34:38 -0700 (PDT) Received: from [192.168.1.17] (host-80-47-105-51.as13285.net. [80.47.105.51]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-374b960ef94sm648207f8f.103.2024.08.30.05.34.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Aug 2024 05:34:37 -0700 (PDT) From: Caleb Connolly Date: Fri, 30 Aug 2024 13:34:33 +0100 Subject: [PATCH v8 03/11] efi: add a helper to generate dynamic UUIDs MIME-Version: 1.0 Message-Id: <20240830-b4-dynamic-uuid-v8-3-79b31b199bee@linaro.org> References: <20240830-b4-dynamic-uuid-v8-0-79b31b199bee@linaro.org> In-Reply-To: <20240830-b4-dynamic-uuid-v8-0-79b31b199bee@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=4932; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=gMwk6mkD9Ufvv7gOE59jH5gnrG+CZ0zKKyfkCUdSwH8=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBm0bxZIXTUOUUw0elITJ9H8BStazsIGgU934TwE IVYDwLIYJiJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZtG8WQAKCRAFgzErGV9k toJ6D/91KC4Vq5XGgX/Nw0lX73XlIYM9+sMkb88GYUx8uWJtEFdY1yHRr0SrI17rCiliKlxaz1L ofKYe8JQUKDS1jzLYhaf1CuKqj7wZNfdxv4zltztaA/VOOzjmVQZ+Q7xGgU4Ze9tQGISSqeH6+r J9LfJcz6gMAeVEdIlaEhp9h1EN6kX+ooBcEjLlIphwUJVpuLazYclwMU6IGiB6QLzRiKcPgAQ6x e7h2APItRGqwKXErkkWzGpjViYtbU+d64LJ/s4Es5KKIWLcep5uWH8YiTI6lFE+2jtag2eQBVXD 7lR6MHqqTpbO9ewj/fOx8Yijjmgaz5gfpWSVPFOmlOnTBeVl+8UJuprMRiTfCKRce/kOpWlA8ve rC5kaPd0hBBZ3J2BVCpdh4wu1kdbRkAjBHZ4EUEr94mnq+geyuAgoqn4ESK529B/wS1Jkbs4dQl HAHy/HBD61lEyF77R0/ZkdIICaqKRMONDmZn77WpwwHNxkr6N+UPv4KP04JkMklMdd4VP1aPQMZ k54DIrWczGKmm5twtUnw2+5O8TFNElIrDRP1SOPSoK0zAj3DlZu4N4HHqcTG85RC1gcSV0fnYA9 8BfziwoPO5OW9kTD6tTahkOs6FFL+65CmCMmLbAdIwpH6RUAw/7r4/rr+6bn0IspqB6+S316/e7 uIQVzFhipu/e7Kw== 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. Reviewed-by: Ilias Apalodimas Signed-off-by: Caleb Connolly --- lib/efi_loader/Kconfig | 12 ++++++++++ lib/efi_loader/efi_capsule.c | 1 + lib/efi_loader/efi_firmware.c | 55 ++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 67 insertions(+), 1 deletion(-) diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index 1179c31bb136..85a31113fcf0 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -236,8 +236,20 @@ 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_NAMESPACE_GUID + string "Namespace for dynamic capsule GUIDs" + # v4 UUID as a default for upstream U-Boot boards + default "8c9f137e-91dc-427b-b2d6-b420faebaf2a" + depends on EFI_HAVE_CAPSULE_SUPPORT + help + Define the namespace or "salt" GUID used to generate the per-image + GUIDs. This should be a GUID in the standard 8-4-4-4-12 format. + + Device vendors are expected to generate their own namespace GUID + to avoid conflicts with upstream/community images. + 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 635088f25a13..f3a2388506cc 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..6650c2b8071d 100644 --- a/lib/efi_loader/efi_firmware.c +++ b/lib/efi_loader/efi_firmware.c @@ -244,8 +244,57 @@ void efi_firmware_fill_version_info(struct efi_firmware_image_descriptor *image_ free(var_state); } +/** + * efi_gen_capsule_guids - 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_gen_capsule_guids(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_GUID, + (unsigned char *)&namespace, UUID_STR_FORMAT_GUID); + if (ret) { + log_debug("%s: EFI_CAPSULE_NAMESPACE_GUID is invalid: %d\n", __func__, ret); + return EFI_INVALID_PARAMETER; + } + + compatible = ofnode_read_string(ofnode_root(), "compatible"); + if (!compatible) { + log_debug("%s: model or compatible not defined\n", __func__); + return EFI_INVALID_PARAMETER; + } + + for (i = 0; i < update_info.num_images; i++) { + gen_v5_guid(&namespace, + &fw_array[i].image_type_id, + compatible, strlen(compatible), + fw_array[i].fw_name, u16_strlen(fw_array[i].fw_name) * sizeof(uint16_t), + NULL); + + log_debug("Image %ls UUID %pUl\n", fw_array[i].fw_name, + &fw_array[i].image_type_id); + } + + return EFI_SUCCESS; +} + /** * efi_fill_image_desc_array - populate image descriptor array * @image_info_size: Size of @image_info * @image_info: Image information @@ -271,9 +320,9 @@ static efi_status_t efi_fill_image_desc_array( u16 **package_version_name) { size_t total_size; struct efi_fw_image *fw_array; - int i; + int i, ret; total_size = sizeof(*image_info) * update_info.num_images; if (*image_info_size < total_size) { @@ -282,8 +331,12 @@ static efi_status_t efi_fill_image_desc_array( return EFI_BUFFER_TOO_SMALL; } *image_info_size = total_size; + ret = efi_gen_capsule_guids(); + if (ret != EFI_SUCCESS) + return ret; + fw_array = update_info.images; *descriptor_count = update_info.num_images; *descriptor_version = EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION; *descriptor_size = sizeof(*image_info); From patchwork Fri Aug 30 12:34:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 1978978 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=k3naNV7h; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WwHg33JvTz1ydy for ; Fri, 30 Aug 2024 22:35:27 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 334F488C05; Fri, 30 Aug 2024 14:34:43 +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="k3naNV7h"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0061688C20; Fri, 30 Aug 2024 14:34:41 +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-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) (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 0729488BB8 for ; Fri, 30 Aug 2024 14:34:40 +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-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4280ca0791bso15891715e9.1 for ; Fri, 30 Aug 2024 05:34:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725021279; x=1725626079; 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=/b/8MiOtStSdfdpiDFC77Y/HYjbiXPx78MBnwUYXDa8=; b=k3naNV7hZ+0iax+GuVqCFx1gxKxMCZInjrTrezvSxS8X3b4ieUcOFt3OwJq2sOoCZw ezJv6HZhWvnmS5gn7rRfF8efYmtXVBJTa76lmlDUSHvTrs0lW1iyc/XDeDN2xolfZevI js06BIj47knt4IQKMaK3xZYquZoZlwdHG7uTCDXNiHsZId5uUpbEx5Ld/kva58lQO3By pqJeE4KLSdyKJsYS3Vseft8IDxhEgS5ugCAxeZEWx1RSzuiql6hrLqmh6zzK7OqC9ZEb AR1cAmsLtQBBvD3SxZ2fJ2+nhTFDnAvIUkbiDAYW+seAOaNeVB9HTSVx2HKPcfm+igVl LWpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725021279; x=1725626079; 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=/b/8MiOtStSdfdpiDFC77Y/HYjbiXPx78MBnwUYXDa8=; b=oNlFjPVo+T1S9nsOcsjVSJYE2xqpBV6EZM0MGtwvlkA1/s6GrhnZcSXtTIECCitHdP xkTvqD4dR0ntYKrcqO0IOfLo5Tojyg/Sy+lRzpwKwrTjbdcq6382kCW2qaBvXX3yMQNo a5CTPA3gbxHbDBM7W6NBwMeElvrn7O/KtIjrEObkOebHMqLc2aDBUwQ+KPUKr0IVxOqq +o3r/holaUDv3e9YXPxkw+2FIWDJYAb3Lfj8pI5n178xue7hfrfDVIqiYCfiMZLGFEAR 2tILGV6pICMkgzo92MkCruHprAVdTq41zkt2Gi4z5kmtk2HmmhKhH995xijV+5bAaBgS or+Q== X-Forwarded-Encrypted: i=1; AJvYcCVLCXbl0W9Wr67UrGPme/m4n3di3R+F0K1D5qOgSk8DJZQDIkviOjRVmMHOc13eNzT7RF+08uA=@lists.denx.de X-Gm-Message-State: AOJu0Yw2EER09IeQw7prst9n3KPCECnmxut2q7vTLadSxi8EeYq2fOCP xW5B2G0t6yiVuyKUiiOkECZPEEABkCyTASDz07b8Yo0FzGRYyUDtO0KtkMOkTtA= X-Google-Smtp-Source: AGHT+IFq6gHzSWvTD16xRTMCzPvdrwmMDMPpmPGxMrCXzgK4yJde4wnmpj7Xk+I9gumJBvwpMlvesA== X-Received: by 2002:a05:6000:1545:b0:371:7c83:12e5 with SMTP id ffacd0b85a97d-3749b544876mr5587324f8f.19.1725021279348; Fri, 30 Aug 2024 05:34:39 -0700 (PDT) Received: from [192.168.1.17] (host-80-47-105-51.as13285.net. [80.47.105.51]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-374b960ef94sm648207f8f.103.2024.08.30.05.34.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Aug 2024 05:34:38 -0700 (PDT) From: Caleb Connolly Date: Fri, 30 Aug 2024 13:34:34 +0100 Subject: [PATCH v8 04/11] doc: uefi: document dynamic UUID generation MIME-Version: 1.0 Message-Id: <20240830-b4-dynamic-uuid-v8-4-79b31b199bee@linaro.org> References: <20240830-b4-dynamic-uuid-v8-0-79b31b199bee@linaro.org> In-Reply-To: <20240830-b4-dynamic-uuid-v8-0-79b31b199bee@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=2227; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=z+k7ehN+E2cuyiSmyz++J33laIvhLNnuuBKXIQoKanw=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBm0bxZxlz0AgnBdY5bQR47aTgPBRhNkgg1LfFZq r0PWQVOLNmJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZtG8WQAKCRAFgzErGV9k to9bD/9AUtLnQI/fPWD6dlCbJ3gL7rgMKkYc+tKqWE3KcKHsfBStWBbXr2SmK8detMiZ1HdE3XN lhukt1Ww4/3scXV4yT6uyYXRhIdjiBGV2lbYHnEsnE3/3KnURxMZykGdowhegGbajvCGTcGwTSF 5LuZ3S4yN9E53mBcP+GE38ss1cGOUcEyHpVuvhpaTKrBjp+IvMTOIPq5TnA6lxOm2eH3bNcM86O EqrX8qVjD9O15ct8lC3H3mPMAPHt38REpDVmmD5Cpmm/FouGG1Ad9TS+8W1p7HX/1JWhDiFoDVr SehD1JFeEuBTIVcY3IYnt1ADUhugZrV5dEFOyZVBtGzIiZjetpMWfH8ONt2dsDS6fr8kmcMa7fV cAPGerMrBazcSbu3uLwIC7Ve3bebTJqOlINYa+oEwhfnjieqiswfvEqxtIIxc1ipe518lPrFjpM LIGIFYIZvm8b/Uro1ijq1EoRgV4XkKBv7fAR5kcbKduLly6uXsnp1IOjdbwfvMGnYn8thn6kcYq tVNvQMsj3x8Y1M1cHO/2Xa+CuTGieoZdrT+jFP/zf4Z7YTh5Zo7z13ScdeknWWtxB1Pkg8Cl0Zt mEMmoOkX87+AxyuP8THDxbkcaFS9CUXo1beRGunxlZQSo6CRMz3tIAqIcALmnv+MxZz5XtxLjXF o2U7PO6hhBY27Lw== X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Document how platforms can generate GUIDs at runtime rather than maintaining a list of UUIDs per-board. Reviewed-by: Ilias Apalodimas Signed-off-by: Caleb Connolly --- doc/develop/uefi/uefi.rst | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/doc/develop/uefi/uefi.rst b/doc/develop/uefi/uefi.rst index d450b12bf801..944827585731 100644 --- a/doc/develop/uefi/uefi.rst +++ b/doc/develop/uefi/uefi.rst @@ -448,8 +448,35 @@ 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. +Dynamic Firmware Update GUIDs +***************************** + +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 the board's devicetree root compatible +(e.g. "qcom,qrb5165-rb5"). + +These strings are combined with the fw_image name to generate GUIDs for +each image. Support for dynamic UUIDs can be enabled by generating a new +namespace UUID and setting EFI_CAPSULE_NAMESPACE_GUID to it. Dynamic GUID +generation is only enabled if the image_type_id property is unset for your +firmware images, this is to avoid breaking existing boards with hardcoded +GUIDs. + +The mkeficapsule tool can be used to determine the GUIDs for a particular +board and image. It can be found in the tools directory. + +Firmware update images +********************** + The firmware images structure defines the GUID values, image index values and the name of the images that are to be updated through the capsule update feature. These values are to be defined as part of an array. These GUID values would be used by the Firmware Management From patchwork Fri Aug 30 12:34:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 1978979 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=a/LGgrA1; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WwHgD2mHnz1ydy for ; Fri, 30 Aug 2024 22:35:36 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 91AF288C66; Fri, 30 Aug 2024 14:34:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=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="a/LGgrA1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1D12388C3A; Fri, 30 Aug 2024 14:34:43 +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-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) (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 F39C288C01 for ; Fri, 30 Aug 2024 14:34:40 +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-wr1-x42f.google.com with SMTP id ffacd0b85a97d-37193ef72a4so1149086f8f.1 for ; Fri, 30 Aug 2024 05:34:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725021280; x=1725626080; 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=r6YJ+zEV9RlWK+fgXZsmPvk1MUsoZRb/Nw//sI06sYU=; b=a/LGgrA10q2uDtwF8TE47qOf+IbFKbdTHFEz1RXqpXd/BgRd9jwc13UpjXNFRDHGO1 j/u7XpMpa4kjpWHEDa7w24qLZnDOqw+a+38ihroxjMJIYAAxNX54lSWbkHIpm57srsrN MYF0Z7Dk+7CexwxAGRw1C+FW3XnhSXj67eLu/2suVKpiIgf6+i/S3+Dip9fZjazloQ2O aphJ27/GwgOMo6plSEHSUzC+GOB/YragGc5bcgNuo5JeRTQP8YTkNXO8OYhRCS6oGmRl +BScxW05Rjmv9rtSRjElCJp/Bt/gVVlLasGt7/Zen6hJFguqE6Lq/Fud5I5I5LHOItRK qAyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725021280; x=1725626080; 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=r6YJ+zEV9RlWK+fgXZsmPvk1MUsoZRb/Nw//sI06sYU=; b=Y/VFwMBw0Rp4CNp8wApxH2Dg3nCkGSwrO4buwIO6ud1l72EhmqFuEHeA6ph/rCKL5m ux6r3eHnfJLfqlViymZ2eFa+jSkKGsWdR6GuQ7LeN3O5OhWyyLmhXwZ3xWOVgZk55Pvy GQLHvOYW1oPUE7GuMi830MuzDhSl7vXXQg8oaZjtSb7jLwQWZvQQ9DFgzvWR8Ge8kzCq kHCI/cBpl6x75/t/2uMNEA+y7kfaesVT91YSzOHBxPvcHeY5PTejGQWOT6zmkCMVXNhY DIAxP4kIFhSt499s8YWb5R3SMdrWo1DzkiILhsnmbXmpkujinQQzjXvl5dNzkVG5MVtA h6pw== X-Forwarded-Encrypted: i=1; AJvYcCXXhgG9R+JJhSkP/KCJ2UM8l6l6nl/vd4sRthD8ivTmICAhk2mNJSR5nJUgYeANoAZenPCemkM=@lists.denx.de X-Gm-Message-State: AOJu0YwX4Dj+2sALuJwucj7fcVrLpt2FtrBSNSj2Yu7wTCbF3IvloLSA sVTwDpKgDKlUqZwWoAMHqmErl80aRMUT/CeS+scpGGs+hb8uBtxUxo7Yd0Tx9nY= X-Google-Smtp-Source: AGHT+IHtiCG4vo6hP4mxh7ajPNsV1hAZuasdkBYR+Pxt01UhBMFRJlnw+EV0LEWw9BTs8KeiSbDLdg== X-Received: by 2002:a5d:5d85:0:b0:374:b5bc:8c93 with SMTP id ffacd0b85a97d-374b5bc8f24mr723010f8f.8.1725021280311; Fri, 30 Aug 2024 05:34:40 -0700 (PDT) Received: from [192.168.1.17] (host-80-47-105-51.as13285.net. [80.47.105.51]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-374b960ef94sm648207f8f.103.2024.08.30.05.34.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Aug 2024 05:34:39 -0700 (PDT) From: Caleb Connolly Date: Fri, 30 Aug 2024 13:34:35 +0100 Subject: [PATCH v8 05/11] sandbox: switch to dynamic UUIDs MIME-Version: 1.0 Message-Id: <20240830-b4-dynamic-uuid-v8-5-79b31b199bee@linaro.org> References: <20240830-b4-dynamic-uuid-v8-0-79b31b199bee@linaro.org> In-Reply-To: <20240830-b4-dynamic-uuid-v8-0-79b31b199bee@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=10634; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=o31iVK1g11OWZDtfgCEcTtP5yaGmjPRi3LpsdCMNZtY=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBm0bxZMyuGbs0V2/uPPPmg3p9XdAH3AnGxsac91 nMOOIxs5PWJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZtG8WQAKCRAFgzErGV9k tl3oD/sFLdnIjdleP9sbb6dJXn6HQAo20dZtXRRyaz52+sR6DcxeKk4vqXpAUjn5HGmT1rzao57 jj11q5Sar+1pLUnWZN5nvTEq1n0/vUSeZLvfYUd+wR/ffkHPNXohuhcOFaDSLgPS9MgTNcX4JUQ jXkIrv1OXkAwRxcIzjfb7ohYY7h/8y3TPLP5JMwaePYdRkx8ASKukV4Y6Ovbemz2Z03oBpOeUYl mLwLkrheCaa+GuwSONP7u+YIuesiFZhkhMpW2FW4k+4SPogP5XuICg+bciWhEwO31oNupaYc0AO uyrwGjCSUYZqODBEgR613OXS0LxJluPy/6+175fqTnBN71HVIZ7kQGjl1nWTUz/MzHeWQkin4Ks 7NX1ORA8WFbe3HoeEIgl5JbPOS8+/ylUTX5kV3tQlcjlj8+ZCcxSEWIljTiquFkJTMoSn0sS1N3 cdjzAxd8QpHACoZ+9xWyMSYiPQVAd+ahsV8/85vi9eMLyioGZYZimT/iaJKPzgQ67EmNx0d1oY7 Dd4q43hrjRGdbf+oKtNjM7twt3yZarzoOaCSCnu3NdL7X4TTH3NKlkXs1QHEu3b5j1IVHXiP8Xa TmN6MlABXPr6f29IwBJ5KJNnUMkFQ0RooygLWMo32NRyGTRN9O1vFJYFFkxgBMK0MMLYY4cv0Lc aAlO48VlQyalmng== 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. Acked-by: Ilias Apalodimas Signed-off-by: Caleb Connolly --- board/sandbox/sandbox.c | 16 ---------------- 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.dtso | 6 +++--- tools/binman/etype/efi_capsule.py | 2 +- tools/binman/ftest.py | 2 +- 9 files changed, 16 insertions(+), 32 deletions(-) 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/include/sandbox_efi_capsule.h b/include/sandbox_efi_capsule.h index 3e288e8a84a2..84d45ec5cfd5 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 "985f2937-7c2e-5e9a-8a5e-8e063312964b" +#define SANDBOX_UBOOT_ENV_IMAGE_GUID "9e339473-c2eb-530a-a69b-0cd6bbbed40e" +#define SANDBOX_FIT_IMAGE_GUID "46610520-469e-59dc-a8dd-c11832b877ea" #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..a726c71c1138 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 '985F2937-7C2E-5E9A-8A5E-8E063312964B' 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 f3a2dff5c2c8..8a790405c7c4 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 @@ -144,12 +144,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 '9E339473-C2EB-530A-A69B-0CD6BBBED40E' in ''.join(output) # ensure that SANDBOX_UBOOT_IMAGE_GUID is in the ESRT. - assert '09D7CF52-0720-4710-91D1-08469B7FE9C8' in ''.join(output) + assert '985F2937-7C2E-5E9A-8A5E-8E063312964B' in ''.join(output) check_file_removed(u_boot_console, disk_img, capsule_files) expected = 'u-boot:Old' if capsule_auth else 'u-boot:New' @@ -198,14 +198,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 '985F2937-7C2E-5E9A-8A5E-8E063312964B' 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 '9E339473-C2EB-530A-A69B-0CD6BBBED40E' 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..debbce8bdbdf 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 '46610520-469E-59DC-A8DD-C11832B877EA' 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..439bd71b3a7d 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 '985F2937-7C2E-5E9A-8A5E-8E063312964B' 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 '9E339473-C2EB-530A-A69B-0CD6BBBED40E' 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.dtso b/test/py/tests/test_efi_capsule/version.dtso index 07850cc6064c..3aebb5b64fbd 100644 --- a/test/py/tests/test_efi_capsule/version.dtso +++ b/test/py/tests/test_efi_capsule/version.dtso @@ -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 = "985F2937-7C2E-5E9A-8A5E-8E063312964B"; }; image2 { lowest-supported-version = <7>; image-index = <2>; - image-type-id = "5A7021F5-FEF2-48B4-AABA-832E777418C0"; + image-type-id = "9E339473-C2EB-530A-A69B-0CD6BBBED40E"; }; image3 { lowest-supported-version = <3>; image-index = <1>; - image-type-id = "3673B45D-6A7C-46F3-9E60-ADABB03F7937"; + image-type-id = "46610520-469E-59DC-A8DD-C11832B877EA"; }; }; }; diff --git a/tools/binman/etype/efi_capsule.py b/tools/binman/etype/efi_capsule.py index 5941545d0b29..768e006dc50d 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' : '985f2937-7c2e-5e9a-8a5e-8e063312964b' } return TYPE_TO_GUID[type_str] diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 93f3d22cf573..2577c0016c0c 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -124,9 +124,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 = '985F2937-7C2E-5E9A-8A5E-8E063312964B' # Windows cert GUID WIN_CERT_TYPE_EFI_GUID = '4aafd29d-68df-49ee-8aa9-347d375665a7' # Empty capsule GUIDs EMPTY_CAPSULE_ACCEPT_GUID = '0c996046-bcc0-4d04-85ec-e1fcedf1c6f8' From patchwork Fri Aug 30 12:34:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 1978980 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=lQxIC2MK; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WwHgQ4r4Tz1ydy for ; Fri, 30 Aug 2024 22:35:46 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0F62588C42; Fri, 30 Aug 2024 14:34:48 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=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="lQxIC2MK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E9DA488BBC; Fri, 30 Aug 2024 14:34:43 +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-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) (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 E91A988C1D for ; Fri, 30 Aug 2024 14:34:41 +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-wr1-x434.google.com with SMTP id ffacd0b85a97d-371ba7e46easo1215347f8f.0 for ; Fri, 30 Aug 2024 05:34:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725021281; x=1725626081; 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=+tWn7S7F6fQZgqjDN+flyyE00k/zWkvOf5I9LrWFh+Y=; b=lQxIC2MK0abMZJOi5BRHVLvOUZhrYB/267AVST69dO0Iz62Pqp40S9onrKms/qd4KG RzjmRSrkND5th31JDb808KuWDuLbU8YdPTjQRYwsdxqBgFsRBwtvFQDmeMGKGWdeHO5T fCFUmZ42tpk06vG0oJTC89OPlEAZ3PN4f6EyIgcrEz3BIxuittS1Q0vCSdgbyfESDFo1 /OVnkBfdAoYHm7kF5aEjnRTsXBwb5ncu1D9rZZKXrO8RMUAQkE+bZ0Ihk6RIczRy98mI RHNb+jE1RZLAtxq7Ly8F3HwMFNkAWJh62HSxQT3ygNYEjTQt0osdzPvBGGUkbyp1EKuU HCVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725021281; x=1725626081; 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=+tWn7S7F6fQZgqjDN+flyyE00k/zWkvOf5I9LrWFh+Y=; b=PTEa3vRjQGpcNW6/vc2pg/E9aBatN7T2nfM+bXBPyeus9GuBRRfTDGtfc3uLRtVNDK MAWztjixO1gDLD+avU4KcaR07vH8KsPXlDOVW2Xw7gLnxGwMMLv+13Kc6H0LMjmRczoF cUkhC3BeZateuRFc0GnoOzdViLdPh9coLTALdOsrXKHcw/mjorGLhyDiqEpIji4LRw4K 1NwDBopNAko846fHogHkulApp2ME812L3vZbMXgNwByp++bD0dkFDnUBIcFgUvkz66sj 5khHykuy5hJruQRPa/v7ubHsl7wnr89MA7hzKxtAeFxC2+dRxVPIGIspqdPeV3JMSgBT rljA== X-Forwarded-Encrypted: i=1; AJvYcCUjfJELfV5lnCQTmvY850fm0YHAFOXHnfpnvHpcLcotexrennj1HVt8BrhDnR1L9tOq7nGh7tk=@lists.denx.de X-Gm-Message-State: AOJu0YyMSBFhpGBR9bVnfRloTHeuxoUVFMxF+8q/1MvMV4B3ruD+LH34 0W9ENDptBgcbLBP3UMUhIb2o6D/+LTl5wskYUYQt6fHYBjybegr2rdhgU373eBs= X-Google-Smtp-Source: AGHT+IFxf1q84Tgneg/hrQzeMZKGdQi60Wj/ABkDMTFzKFgMTpkIpzqiFUeVn3p3eWOmK7CZheM8wA== X-Received: by 2002:adf:f008:0:b0:371:93eb:78a4 with SMTP id ffacd0b85a97d-3749b52ec3dmr4060667f8f.9.1725021281395; Fri, 30 Aug 2024 05:34:41 -0700 (PDT) Received: from [192.168.1.17] (host-80-47-105-51.as13285.net. [80.47.105.51]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-374b960ef94sm648207f8f.103.2024.08.30.05.34.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Aug 2024 05:34:40 -0700 (PDT) From: Caleb Connolly Date: Fri, 30 Aug 2024 13:34:36 +0100 Subject: [PATCH v8 06/11] lib: uuid: supporting building as part of host tools MIME-Version: 1.0 Message-Id: <20240830-b4-dynamic-uuid-v8-6-79b31b199bee@linaro.org> References: <20240830-b4-dynamic-uuid-v8-0-79b31b199bee@linaro.org> In-Reply-To: <20240830-b4-dynamic-uuid-v8-0-79b31b199bee@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=5314; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=7aAo+sig05F8UL/v3fHY/H8w6OBhvCpEAQe/4iFU7YM=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBm0bxZj20hh4o8PQDSD6NkAg+NaBh55HlUcCYVR flTdBjvWsiJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZtG8WQAKCRAFgzErGV9k tkEbEACDBNOfo/REER3YXLrAHdHA5+7UuI+0ccPIdKUnxiWpSoFuymoEbHYl0oEETtsu6Cuzq3l 5hKed4S9BksOOzo7ONHOvTYVQiQA9XtBNonvWHxvVuKzn2fjv/4ocJj4CHhCrZ/PS8a7EcPkcjN LT9QC1NbnREHx3mEAH9CzTyIQzCpkgh+Tl/O594gPzUyskiRGW+vKtjLtwoADO318oIN3kDVRxw JwgQ7Wto5ZP1vP/3dwbBdCw8pdMZCUYCa3zpThb6eyw3QIaG/+idkbP4NfpON9znIxUVIFgCmJ3 MS1SQAzNBEaJDm2wmxBOKtLepcF50ccZLZYKghr37rXOb3oBLmEHEOVbHaGrPZV2eCsgrZLWolU fnKkBY/TTWiInIM2Oj3ii+cilcxwe6Mrcyz8Ev3nhsRByH07rmfU+PXqjpCdvPX1Konrfq2GhlP 4SvbNjo0EDvG5bARCcsjk9kieZ/MRcPh+Vyl2ruLGqOx2UFBepI9JzNfsAauxRdbgpuX0o66RDj 324cgba+4y+LYrHpCKJi0wG9yO1X5EtaEqr76HXtM2IraKPs8DryvB75CjyYZlV4Frj9jG3sXcu pkw4tB+6FKSb2Pcuf06EYq0a23CYSe+3hYGjpGrDhtSuAqgsNb6lgNWwSR+hwtFBvflSW5kG1W9 qeNPtsRCTldKukg== 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. Acked-by: Ilias Apalodimas 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 1f4fa103b5e9..7f8414dc906c 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 c9dfdf007a18..6fdae7997702 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; /* @@ -419,8 +433,9 @@ void gen_v5_guid(const struct uuid *namespace, struct efi_guid *guid, ...) tmp16 = (uint16_t *)&guid->b[6]; *tmp16 = cpu_to_le16(be16_to_cpu(*tmp16)); } +#ifndef USE_HOSTCC #if defined(CONFIG_RANDOM_UUID) || defined(CONFIG_CMD_UUID) void gen_rand_uuid(unsigned char *uuid_bin) { u32 ptr[4]; @@ -502,4 +517,5 @@ U_BOOT_CMD(guid, CONFIG_SYS_MAXARGS, 1, do_uuid, "e.g. guid guid_env" ); #endif /* CONFIG_CMD_UUID */ #endif /* CONFIG_RANDOM_UUID || CONFIG_CMD_UUID */ +#endif /* !USE_HOSTCC */ From patchwork Fri Aug 30 12:34:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 1978981 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=lyyL1l4T; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WwHgd4vN1z1ydy for ; Fri, 30 Aug 2024 22:35:57 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6ED7188C4D; Fri, 30 Aug 2024 14:34:48 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=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="lyyL1l4T"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 85D1E88C53; Fri, 30 Aug 2024 14:34:45 +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-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) (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 3861F88C3F for ; Fri, 30 Aug 2024 14:34:43 +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-wm1-x331.google.com with SMTP id 5b1f17b1804b1-428e3129851so15765865e9.3 for ; Fri, 30 Aug 2024 05:34:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725021283; x=1725626083; 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=0CN5w97ylaw/CErONqtMmnfNAjTTm3YPDAwnAvBicuY=; b=lyyL1l4TvijRYrhq+xGFhDMXuIa6Hkd8cGpwpozqKrjnCmrfP3NeLiHvMGUsZ46ivJ lMWjV40yDSMAVYr7drknSawBpoVyd3dRoeRoE/HFwJBNiwFTzccPCLxPNPYkHXSaJJRz RFo6NQb5zrQZtHreF+DLvA/wzdoKb3Wq/9KoED3Iod4TJbfxwHKOgDYEFl3nzFf/DE98 BgXaydoHheJwLlwNSa/wT028/wMWczT63UCDaTDih6lefiLG/eFn57W8GeXKWmVMbj0v kDIGI0Avp2/i64U9ccDVe//lMIZJnsetPLtHWltZ9+4apCJo/VpCgHFLvXKK0NubcELI qndw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725021283; x=1725626083; 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=0CN5w97ylaw/CErONqtMmnfNAjTTm3YPDAwnAvBicuY=; b=UjidwXQYaJbEaX40X20Wc/D/nlY6nL3kzgS10g760/Q0M9wjj0zki4R8tPuQlErwxi rzZhUYwttsbNeyVpwb5FYurekRJ1jgkNia7mfoQbkROL0lX255dDXf10EtJiik27+xiN kcwPXfRn9ts4SdN6K2DqffkUysvlP6RwwLaa3Cwlbxt+ve4tQgeEnMXXcnzPJdIfz3bL gwcmR63DWF/zTfWrn3EJXVD+xHAMbC8O6G7s+Pse423VmFG1GJdLxyAEXdpZjne4fCqx NlxNq5wI2SEBeKb+h/NzpQbnW5aAQZZ1Xd38uP2Dd3iZykTmoDDzjFgJOFgif7+sDqO9 iEFQ== X-Forwarded-Encrypted: i=1; AJvYcCUAEHh71eIN/w6FBmG2Hr+yL9Px4/XdNv9vJkFZLGG2YxDGuZMcx2uDj/eO+A5vRe+iQEhE/G0=@lists.denx.de X-Gm-Message-State: AOJu0YywvCyzCvcsb/ILuG/o2bDMCBtuWd6sRTFNzyCHJOHukiXicIR0 VejiASyjOPzwEKYL1YT30GPPGisMo372x50W4H211slmYQdjo0KlH9mwkyV7ulc= X-Google-Smtp-Source: AGHT+IGdda9ua4VTwyDtETai9/e9aDobIE1H9TZ+dleoH69HCJ/e2shv9N8px6I0az32XiJkw+5rcw== X-Received: by 2002:adf:b312:0:b0:371:82bc:7d93 with SMTP id ffacd0b85a97d-3749b526ec0mr4107056f8f.12.1725021282553; Fri, 30 Aug 2024 05:34:42 -0700 (PDT) Received: from [192.168.1.17] (host-80-47-105-51.as13285.net. [80.47.105.51]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-374b960ef94sm648207f8f.103.2024.08.30.05.34.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Aug 2024 05:34:42 -0700 (PDT) From: Caleb Connolly Date: Fri, 30 Aug 2024 13:34:37 +0100 Subject: [PATCH v8 07/11] include: export uuid.h MIME-Version: 1.0 Message-Id: <20240830-b4-dynamic-uuid-v8-7-79b31b199bee@linaro.org> References: <20240830-b4-dynamic-uuid-v8-0-79b31b199bee@linaro.org> In-Reply-To: <20240830-b4-dynamic-uuid-v8-0-79b31b199bee@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=15788; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=FcNtT1+wvv1lmD+dZOOogYZ0xKDMTXJuq72DJrRw0Ao=; b=kA0DAAgBBYMxKxlfZLYByyZiAGbRvFmhXyyFh1cFoOUQgCMqOEBdiIvs5zof1pwIpR9707i7p YkCMwQAAQgAHRYhBLZRoUY8ar7QaQxVzQWDMSsZX2S2BQJm0bxZAAoJEAWDMSsZX2S2neMP/AnR 2UpVu2px5E31RZsefRM9SnnewLOF+4yk23SkaPxUXp6IZprJ1hFHGTxw+9JCnyiyo8BAQ0jrEeR sPKj0sTwyf7bRTYAA7sRfDOQ6EIeiqfH4hppf/tX4ONktR+JaSje/AxWgsU8W2rwQfhJOyhaMDu 5R9bf/kPW3z6wwtcbcJLfcconENHnqmSHJ78X0PXJKvgxSBIEFSFICvTQ3qOrABasbKTGL89VC2 v+3KRJ5k2N5S49U92VgGRUnvbbqxOZkTZfdbBGWX09bD8jalaN0DTmvcDdg8KETdrows4tMd/SU cUrh1XGnge60bNWtjJS9u2rlHfIEWfCxJQV+jlbZA6ToyoQl7OouXmCHTqEKUnnEaW8L40ifhes GVd72pXQ+8vLekL3x6bdQ1P/nndmqgh89zepwM0nASfIvqOeoYYB9gSlzD4qooChE5qv3ATdWUm NXVCTpeMlfsV2s6saVfh5WZFH5cibhjz2wgcHC/CNpX/gI/HvGmOWj8uCKU3K50hkWiMdtnEUZ0 WS1JtSTpKbjDsb69fXE4QQfZfhR3FJYBM5ObZzY5F6d+8cAS/7vXDxPy/Viy/n0ME0kjAxqqt3i WlFri0ytVQ9wDVegVaqlwe46cR0L2Lnkbm0iIKG9+3vGhZhlvAJOyWhmxGscBJDv/InpGROcxwT JjBiN 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 Move this header to include/u-boot/ so that it can be used by external tools. Reviewed-by: Ilias Apalodimas Signed-off-by: Caleb Connolly --- arch/arm/mach-rockchip/board.c | 2 +- board/cobra5272/flash.c | 2 +- board/gardena/smart-gateway-mt7688/board.c | 2 +- board/socrates/socrates.c | 2 +- board/xilinx/common/board.c | 2 +- cmd/efi.c | 2 +- cmd/efi_common.c | 2 +- cmd/flash.c | 2 +- cmd/gpt.c | 2 +- cmd/nvedit_efi.c | 2 +- cmd/x86/hob.c | 2 +- common/flash.c | 2 +- disk/part_efi.c | 2 +- drivers/firmware/arm-ffa/arm-ffa-uclass.c | 2 +- env/sf.c | 2 +- fs/btrfs/btrfs.c | 2 +- fs/btrfs/compat.h | 2 +- fs/btrfs/disk-io.c | 2 +- fs/ext4/ext4fs.c | 2 +- include/fwu.h | 2 +- include/part.h | 2 +- include/rkmtd.h | 2 +- include/{ => u-boot}/uuid.h | 0 lib/acpi/acpi_dp.c | 2 +- lib/acpi/acpigen.c | 2 +- lib/efi/efi_app.c | 2 +- lib/efi_loader/efi_capsule.c | 2 +- lib/efi_loader/efi_device_path.c | 2 +- lib/efi_loader/efi_variable.c | 2 +- lib/fwu_updates/fwu_mtd.c | 2 +- lib/uuid.c | 2 +- lib/vsprintf.c | 2 +- net/bootp.c | 2 +- test/dm/acpi_dp.c | 2 +- test/dm/acpigen.c | 2 +- test/lib/uuid.c | 2 +- 36 files changed, 35 insertions(+), 35 deletions(-) diff --git a/arch/arm/mach-rockchip/board.c b/arch/arm/mach-rockchip/board.c index 8a57b8217ff2..0fdf9365b41e 100644 --- a/arch/arm/mach-rockchip/board.c +++ b/arch/arm/mach-rockchip/board.c @@ -24,9 +24,9 @@ #include #include #include #include -#include +#include #include #include #include #include diff --git a/board/cobra5272/flash.c b/board/cobra5272/flash.c index 616842e62f4e..f16f2f1184f3 100644 --- a/board/cobra5272/flash.c +++ b/board/cobra5272/flash.c @@ -10,9 +10,9 @@ #include #include #include #include -#include +#include #include #include #include diff --git a/board/gardena/smart-gateway-mt7688/board.c b/board/gardena/smart-gateway-mt7688/board.c index c6b14bed41fb..eb7fcd630a10 100644 --- a/board/gardena/smart-gateway-mt7688/board.c +++ b/board/gardena/smart-gateway-mt7688/board.c @@ -15,9 +15,9 @@ #include #include #include #include -#include +#include #include #include #define MT76XX_AGPIO_CFG 0x1000003c diff --git a/board/socrates/socrates.c b/board/socrates/socrates.c index 6e6e276cc741..5e5a45ee00db 100644 --- a/board/socrates/socrates.c +++ b/board/socrates/socrates.c @@ -14,9 +14,9 @@ #include #include #include #include -#include +#include #include #include #include #include diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c index 0b43407b9e94..8cec455ae984 100644 --- a/board/xilinx/common/board.c +++ b/board/xilinx/common/board.c @@ -30,9 +30,9 @@ #include #include #include #include -#include +#include #include "fru.h" #if IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) diff --git a/cmd/efi.c b/cmd/efi.c index 6bed2d743ba6..687ccb520428 100644 --- a/cmd/efi.c +++ b/cmd/efi.c @@ -10,9 +10,9 @@ #include #include #include #include -#include +#include #include DECLARE_GLOBAL_DATA_PTR; diff --git a/cmd/efi_common.c b/cmd/efi_common.c index c46764e6eea7..d2f2b59e9e3b 100644 --- a/cmd/efi_common.c +++ b/cmd/efi_common.c @@ -7,9 +7,9 @@ */ #include #include -#include +#include void efi_show_tables(struct efi_system_table *systab) { int i; diff --git a/cmd/flash.c b/cmd/flash.c index de0e04f09cfb..fd660ec477c9 100644 --- a/cmd/flash.c +++ b/cmd/flash.c @@ -9,9 +9,9 @@ */ #include #include #include -#include +#include #if defined(CONFIG_CMD_MTDPARTS) #include diff --git a/cmd/gpt.c b/cmd/gpt.c index 86b7701886a3..27aea2df197c 100644 --- a/cmd/gpt.c +++ b/cmd/gpt.c @@ -18,9 +18,9 @@ #include #include #include #include -#include +#include #include #include #include #include diff --git a/cmd/nvedit_efi.c b/cmd/nvedit_efi.c index 64ae2ad2ce24..32b7d0490747 100644 --- a/cmd/nvedit_efi.c +++ b/cmd/nvedit_efi.c @@ -14,9 +14,9 @@ #include #include #include #include -#include +#include #include /* * From efi_variable.c, diff --git a/cmd/x86/hob.c b/cmd/x86/hob.c index 2dd30808bd10..d3713cef3312 100644 --- a/cmd/x86/hob.c +++ b/cmd/x86/hob.c @@ -4,9 +4,9 @@ */ #include #include -#include +#include #include #include #include diff --git a/common/flash.c b/common/flash.c index 24ddc8bee724..226646c6868f 100644 --- a/common/flash.c +++ b/common/flash.c @@ -7,9 +7,9 @@ /* #define DEBUG */ #include #include -#include +#include #include #include diff --git a/disk/part_efi.c b/disk/part_efi.c index b1a03bd165e0..580821a6ee9c 100644 --- a/disk/part_efi.c +++ b/disk/part_efi.c @@ -14,9 +14,9 @@ #include #include #include -#include +#include #include #include #include #include diff --git a/drivers/firmware/arm-ffa/arm-ffa-uclass.c b/drivers/firmware/arm-ffa/arm-ffa-uclass.c index e0767fc75517..96c64964bb73 100644 --- a/drivers/firmware/arm-ffa/arm-ffa-uclass.c +++ b/drivers/firmware/arm-ffa/arm-ffa-uclass.c @@ -10,9 +10,9 @@ #include #include #include #include -#include +#include #include #include #include #include diff --git a/env/sf.c b/env/sf.c index 906b85b0db44..21ac0c202e73 100644 --- a/env/sf.c +++ b/env/sf.c @@ -15,9 +15,9 @@ #include #include #include #include -#include +#include #include #include #include #include diff --git a/fs/btrfs/btrfs.c b/fs/btrfs/btrfs.c index 1149a3b20077..350cff0cbca0 100644 --- a/fs/btrfs/btrfs.c +++ b/fs/btrfs/btrfs.c @@ -6,9 +6,9 @@ */ #include #include -#include +#include #include #include "btrfs.h" #include "crypto/hash.h" #include "disk-io.h" diff --git a/fs/btrfs/compat.h b/fs/btrfs/compat.h index 02173dea5f48..4596b9d1dd39 100644 --- a/fs/btrfs/compat.h +++ b/fs/btrfs/compat.h @@ -4,9 +4,9 @@ #define __BTRFS_COMPAT_H__ #include #include -#include +#include /* Provide a compatibility layer to make code syncing easier */ /* A simple wraper to for error() used in btrfs-progs */ diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 34d9d5351216..14efe7218df5 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -1,8 +1,8 @@ // SPDX-License-Identifier: GPL-2.0+ #include #include -#include +#include #include #include "kernel-shared/btrfs_tree.h" #include "common/rbtree-utils.h" #include "disk-io.h" diff --git a/fs/ext4/ext4fs.c b/fs/ext4/ext4fs.c index da59cb008fce..15587e92e3e7 100644 --- a/fs/ext4/ext4fs.c +++ b/fs/ext4/ext4fs.c @@ -26,9 +26,9 @@ #include "ext4_common.h" #include #include #include -#include +#include int ext4fs_symlinknest; struct ext_filesystem ext_fs; diff --git a/include/fwu.h b/include/fwu.h index 77ec65e61807..c317613eaaab 100644 --- a/include/fwu.h +++ b/include/fwu.h @@ -9,9 +9,9 @@ #include #include #include #include -#include +#include #include struct fwu_mdata; diff --git a/include/part.h b/include/part.h index 54b986cee631..797b542ef1ff 100644 --- a/include/part.h +++ b/include/part.h @@ -7,9 +7,9 @@ #define _PART_H #include #include -#include +#include #include #include #include diff --git a/include/rkmtd.h b/include/rkmtd.h index 145fede6c840..b7479036b397 100644 --- a/include/rkmtd.h +++ b/include/rkmtd.h @@ -10,9 +10,9 @@ #ifndef __RKMTD__ #define __RKMTD__ #include -#include +#include #define LBA 64 + 512 + 33 #define RK_TAG 0xFCDC8C3B diff --git a/include/uuid.h b/include/u-boot/uuid.h similarity index 100% rename from include/uuid.h rename to include/u-boot/uuid.h diff --git a/lib/acpi/acpi_dp.c b/lib/acpi/acpi_dp.c index 6733809986ae..5714acce0882 100644 --- a/lib/acpi/acpi_dp.c +++ b/lib/acpi/acpi_dp.c @@ -8,9 +8,9 @@ #include #include #include -#include +#include #include #include #include diff --git a/lib/acpi/acpigen.c b/lib/acpi/acpigen.c index b95cabb91493..ecff5a50d504 100644 --- a/lib/acpi/acpigen.c +++ b/lib/acpi/acpigen.c @@ -9,9 +9,9 @@ #define LOG_CATEGORY LOGC_ACPI #include #include -#include +#include #include #include #include #include diff --git a/lib/efi/efi_app.c b/lib/efi/efi_app.c index 88332c3c910a..9b94a93ee4f1 100644 --- a/lib/efi/efi_app.c +++ b/lib/efi/efi_app.c @@ -16,9 +16,9 @@ #include #include #include #include -#include +#include #include #include #include #include diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c index f3a2388506cc..a4ea28730387 100644 --- a/lib/efi_loader/efi_capsule.c +++ b/lib/efi_loader/efi_capsule.c @@ -19,9 +19,9 @@ #include #include #include #include -#include +#include #include #include #include diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c index 0f684590f22a..9de3b95d073b 100644 --- a/lib/efi_loader/efi_device_path.c +++ b/lib/efi_loader/efi_device_path.c @@ -16,9 +16,9 @@ #include #include #include #include -#include +#include #include #include /* U16_MAX */ /* template END node: */ diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c index e888c52efe3e..f3533f4def3a 100644 --- a/lib/efi_loader/efi_variable.c +++ b/lib/efi_loader/efi_variable.c @@ -15,9 +15,9 @@ #include #include #include #include -#include +#include #include #include #include #include diff --git a/lib/fwu_updates/fwu_mtd.c b/lib/fwu_updates/fwu_mtd.c index ccaba3f3115a..11b42a3d796c 100644 --- a/lib/fwu_updates/fwu_mtd.c +++ b/lib/fwu_updates/fwu_mtd.c @@ -9,9 +9,9 @@ #include #include #include #include -#include +#include #include #include diff --git a/lib/uuid.c b/lib/uuid.c index 6fdae7997702..11b86ffb02e6 100644 --- a/lib/uuid.c +++ b/lib/uuid.c @@ -28,9 +28,9 @@ #endif #include #include #include -#include +#include #include #ifdef USE_HOSTCC /* polyfill hextoul to avoid pulling in strto.c */ diff --git a/lib/vsprintf.c b/lib/vsprintf.c index cfd1f1914edf..e5802866632e 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -17,9 +17,9 @@ #include #include #include #include -#include +#include #include #include #include #include diff --git a/net/bootp.c b/net/bootp.c index 9dfb50749b49..512ab2ed7c81 100644 --- a/net/bootp.c +++ b/net/bootp.c @@ -14,9 +14,9 @@ #include #include #include #include -#include +#include #include #include #include "bootp.h" #ifdef CONFIG_LED_STATUS diff --git a/test/dm/acpi_dp.c b/test/dm/acpi_dp.c index eaeda2b8a7af..038806004b55 100644 --- a/test/dm/acpi_dp.c +++ b/test/dm/acpi_dp.c @@ -6,9 +6,9 @@ * Written by Simon Glass */ #include -#include +#include #include #include #include #include diff --git a/test/dm/acpigen.c b/test/dm/acpigen.c index 3e912fadaef8..23c16bd98669 100644 --- a/test/dm/acpigen.c +++ b/test/dm/acpigen.c @@ -8,9 +8,9 @@ #include #include #include -#include +#include #include #include #include #include diff --git a/test/lib/uuid.c b/test/lib/uuid.c index 8fe65dbf78ba..3d62e18bcfee 100644 --- a/test/lib/uuid.c +++ b/test/lib/uuid.c @@ -7,9 +7,9 @@ * Authors: * Abdellatif El Khlifi */ -#include +#include #include #include #include From patchwork Fri Aug 30 12:34:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 1978982 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=o+mLPlRo; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WwHgq6DnFz1ydy for ; Fri, 30 Aug 2024 22:36:07 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D17B988C78; Fri, 30 Aug 2024 14:34:48 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=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="o+mLPlRo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5584B88C01; Fri, 30 Aug 2024 14:34:46 +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-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) (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 4EC4C88BB8 for ; Fri, 30 Aug 2024 14:34:44 +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-wr1-x429.google.com with SMTP id ffacd0b85a97d-37186c2278bso1537174f8f.1 for ; Fri, 30 Aug 2024 05:34:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725021284; x=1725626084; 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=l5r79sQC+0jVmVErM6RlNVJOcMhMKvSSp+nwTJsGWy0=; b=o+mLPlRoeueThdYPwiDUXXki/vRXdh++TL2auAE3uvkkMmjE46HS0pISthmoh6UEei RGIXFA2HnDHvXAkvY0K++bTD4FEhumlCgpvEtRvpH7Z2qunVu5+UVNvMcyn/eqNKafYO I45iS8agrVo9ovwITae9or7vODfkD475Onm2MKaGpIAnu4gEb9yhvIYlhzTDO5SfN7oc Xk6AVMv2TkMsEpZ43kEUEcrl/ir8ScsgQbSnJ7AmSl0HwC2gnaDdP70XWp+6GB8PcfHq wadc1Vq+tM6UBumdq0iyt+3ZNrowMeoByn22BJ5KPAk+MY/qN0S1Fq2nPtGcDYJHnZsy wx3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725021284; x=1725626084; 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=l5r79sQC+0jVmVErM6RlNVJOcMhMKvSSp+nwTJsGWy0=; b=Xa5VPQaBen/3WC8Ug5I3fG94eI5qoZ7q4VT+u3w/ekALbGiZvdMCaNVfHwH3T8Jufr LwN3WoXuNPtgPDeNchojCH/hxipuqgXmkOmcSx3sAeevy+LBUrHAswBCAn+cEMCBAwy1 vAEDUu482RZGzAo3JPavmQ8i1/LYRrQDFwgfsu6GFuvxvXWbXTYO8Qhq/2gv/9vxjIs/ wa1t9H7d2zDYHM97Nro7LrjSOFlbP85yN0qDOnRh1XFoE0UZeSobXGxebxYx8ue8YsAM khvpzTYrCAIpQa6L8V7a4Xxs3daWd2hsJuDH2WjGSEL75gVpVYXY7/VTSsBDN+Qrlbsz 8hvQ== X-Forwarded-Encrypted: i=1; AJvYcCUVywtXYYPQJpD+kIugwZruxpYdcT1CfisO65TP+OHnClIE28tvvGDNfkwl+8RFuVo49jK46M0=@lists.denx.de X-Gm-Message-State: AOJu0Yw62qg0xTwutpnnLwiCDJnpUIpcXauwNtOcs+xeOLdQGFunXnDx N5VNqgPMUncf6zdWSVcChfKarqowmCZs1hYZHlHPlJdeBihodNTWknjsFpF6VVM= X-Google-Smtp-Source: AGHT+IFyAcFj0BHZdJokS2lNdFvwnBMZ+LuHGDl85NTSR2wf1dwJCSZkrmcxrRXejWoKFzJpPy5sUA== X-Received: by 2002:a5d:6086:0:b0:36d:255e:39b0 with SMTP id ffacd0b85a97d-374a918b936mr1308906f8f.14.1725021283693; Fri, 30 Aug 2024 05:34:43 -0700 (PDT) Received: from [192.168.1.17] (host-80-47-105-51.as13285.net. [80.47.105.51]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-374b960ef94sm648207f8f.103.2024.08.30.05.34.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Aug 2024 05:34:43 -0700 (PDT) From: Caleb Connolly Date: Fri, 30 Aug 2024 13:34:38 +0100 Subject: [PATCH v8 08/11] tools: mkeficapsule: use u-boot UUID library MIME-Version: 1.0 Message-Id: <20240830-b4-dynamic-uuid-v8-8-79b31b199bee@linaro.org> References: <20240830-b4-dynamic-uuid-v8-0-79b31b199bee@linaro.org> In-Reply-To: <20240830-b4-dynamic-uuid-v8-0-79b31b199bee@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=3778; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=1D9v/krX71PoDrNJAoDEEw+mk5TrkItnnYCaNhfNd1o=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBm0bxZvp4NvuiPNNs3lBPsNH3iZGZepes3gQ2pb TnoIEeqeV6JAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZtG8WQAKCRAFgzErGV9k tvpwD/90FfDh3w7UwRIHYNngDYMUs9ytHf2AyXLphDpWUZeNtDCW3kWqDF6hj54mvlFDNv4W1j4 xe6QNMep2dgg31a3sAGWN14JBHhZGEDTKT190YiU5ahz4aLlPWEVgPkIZkoZyj2ISWlfndYmAMt YqIMNqmggB6P25flRA3l29LLdodKjT/t7FMpbGdzzWuRD/AhRObTWjeL4J7aOL8zWGCRCX5hnsW z51Gfm5g6zY//20OvIROklx15vzEzIhI1DGntkpHEIFsypw56DUG/LgJspFtwY2NY14YoWuCxHx C4Qyf4BbpcBHF1nbd4mcAKmmjYBP11AoORE4FZ620L+GMwB7fY8ydgoBv4RMpNntV7RaGLQrlLu czERzT0CerI34tl7jl2w9gegqHAob0GmVnMVQqPHVlmgCSnb9sGaAALFFaxRdQ7R/rzUvjeWa5c aCK8/4Yv7te6pPGdORbr2Yd7fdjQOH+CC8gLGGeckztPEoplGGkJxYQTN6MD+LWyKG9QgMTwty/ zwaysC50Aw1d8njFgwpdTrddEvbpC3dekGWf7xjvdpu/TjFwg/7UiZL9pL1/mDTOeQVk38mK2JD +nWYv51RYjaicsYG0pVHMp8D7YCmFBRTPEjdmi63Gv31sp5qd38Rza8YcPaM6QMcEwUbHGTuDJJ si8Sdnb382d659w== 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 Replace the use of libuuid with U-Boot's own UUID library. This prepares us to add support for generating v5 GUIDs. Signed-off-by: Caleb Connolly --- tools/Makefile | 8 ++++---- tools/mkeficapsule.c | 52 +++++----------------------------------------------- 2 files changed, 9 insertions(+), 51 deletions(-) diff --git a/tools/Makefile b/tools/Makefile index 6a4280e3668f..ee08a9675df8 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -245,14 +245,14 @@ hostprogs-$(CONFIG_ASN1_COMPILER) += asn1_compiler HOSTCFLAGS_asn1_compiler.o = -idirafter $(srctree)/include HOSTCFLAGS_mkeficapsule.o += \ $(shell pkg-config --cflags gnutls 2> /dev/null || echo "") -HOSTCFLAGS_mkeficapsule.o += \ - $(shell pkg-config --cflags uuid 2> /dev/null || echo "") HOSTLDLIBS_mkeficapsule += \ $(shell pkg-config --libs gnutls 2> /dev/null || echo "-lgnutls") -HOSTLDLIBS_mkeficapsule += \ - $(shell pkg-config --libs uuid 2> /dev/null || echo "-luuid") +mkeficapsule-objs := generated/lib/uuid.o \ + generated/lib/sha1.o \ + $(LIBFDT_OBJS) \ + mkeficapsule.o hostprogs-$(CONFIG_TOOLS_MKEFICAPSULE) += mkeficapsule mkfwumdata-objs := mkfwumdata.o generated/lib/crc32.o HOSTLDLIBS_mkfwumdata += -luuid diff --git a/tools/mkeficapsule.c b/tools/mkeficapsule.c index f28008a0829f..68c97cfb9db4 100644 --- a/tools/mkeficapsule.c +++ b/tools/mkeficapsule.c @@ -14,15 +14,15 @@ #include #include #include -#include #include #include #include #include +#include #include "eficapsule.h" static const char *tool_name = "mkeficapsule"; @@ -576,39 +576,8 @@ err: return ret; } -/** - * convert_uuid_to_guid() - convert UUID to GUID - * @buf: UUID binary - * - * UUID and GUID have the same data structure, but their binary - * formats are different due to the endianness. See lib/uuid.c. - * Since uuid_parse() can handle only UUID, this function must - * be called to get correct data for GUID when parsing a string. - * - * The correct data will be returned in @buf. - */ -void convert_uuid_to_guid(unsigned char *buf) -{ - unsigned char c; - - c = buf[0]; - buf[0] = buf[3]; - buf[3] = c; - c = buf[1]; - buf[1] = buf[2]; - buf[2] = c; - - c = buf[4]; - buf[4] = buf[5]; - buf[5] = c; - - c = buf[6]; - buf[6] = buf[7]; - buf[7] = c; -} - static int create_empty_capsule(char *path, efi_guid_t *guid, bool fw_accept) { struct efi_capsule_header header = { 0 }; FILE *f = NULL; @@ -652,22 +621,12 @@ err: } static void print_guid(void *ptr) { - int i; - efi_guid_t *guid = ptr; - const uint8_t seq[] = { - 3, 2, 1, 0, '-', 5, 4, '-', 7, 6, - '-', 8, 9, '-', 10, 11, 12, 13, 14, 15 }; + static char buf[37] = { 0 }; - for (i = 0; i < ARRAY_SIZE(seq); i++) { - if (seq[i] == '-') - putchar(seq[i]); - else - printf("%02X", guid->b[seq[i]]); - } - - printf("\n"); + uuid_bin_to_str(ptr, buf, UUID_STR_FORMAT_GUID | UUID_STR_UPPER_CASE); + printf("%s\n", buf); } static uint32_t dump_fmp_payload_header( struct fmp_payload_header *fmp_payload_hdr) @@ -905,13 +864,12 @@ int main(int argc, char **argv) fprintf(stderr, "Image type already specified\n"); exit(EXIT_FAILURE); } - if (uuid_parse(optarg, uuid_buf)) { + if (uuid_str_to_bin(optarg, uuid_buf, UUID_STR_FORMAT_GUID)) { fprintf(stderr, "Wrong guid format\n"); exit(EXIT_FAILURE); } - convert_uuid_to_guid(uuid_buf); guid = (efi_guid_t *)uuid_buf; break; case 'i': index = strtoul(optarg, NULL, 0); From patchwork Fri Aug 30 12:34:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 1978983 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=MvRF8DZm; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WwHh125YFz1ydy for ; Fri, 30 Aug 2024 22:36:17 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 39B3888BFB; Fri, 30 Aug 2024 14:34:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="MvRF8DZm"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9EC0E88C4C; Fri, 30 Aug 2024 14:34:47 +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-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) (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 5DBCA88C4C for ; Fri, 30 Aug 2024 14:34:45 +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-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-42bbd16fca8so4146935e9.0 for ; Fri, 30 Aug 2024 05:34:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725021285; x=1725626085; 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=ev/6wfhw/Pybgv0hjqelWSIXspb7A0iHWxmEAj9+hYc=; b=MvRF8DZmyixjpIsnVvZag58n/1ru5Z69Ft+nShlWNpctKWoEOzkBvgiC/g6uLZQspq 9wQh+xhuZd3Tg1I02ljcxjvRBJjgEKIh+vQ+s0Jc3O5AQOe12nTFeD+qagl1kT+Iw93R c5cGOrugcYQXCs7cKMZAW1L3xO6lP/pXQAOnXhQYwQR8o6eM/UMo1P4pN3VExYrRQFth SrWAH8Sd3m4xuWtDBUGrDM15084zuOI5blEytdAQXOZUKpBo1C6ZZxJE70+BFkzzrGuZ BeKP/2m/sNzZwF8yljJ43N/I7oPONd0pRdwozcPUlMsRwhKeKT5En3rZg3Cp+OM3YkOC 8s+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725021285; x=1725626085; 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=ev/6wfhw/Pybgv0hjqelWSIXspb7A0iHWxmEAj9+hYc=; b=Dcfg0SYSlbX4ZAonCJOZ7qYFUXrQWM9h5HN+eWEfl9q8j2HsCu2Ac2+MlPGDVbcrMz u+Os9SHT/vIJIqgvzSuhY7gqL7XJI+HpW7PEoCKpL6ymXZI2PzjCBR/8dJlILzGHYU0/ AJtHXhEGzJVEpSmOgx6rc8gElqfiXslJ77jmQjK6lFeEpi99W4DHvJ2BPRhJ3eWTsHw9 mhvIUx8X/8x3164aKYk0s/cqbvTjYuMNBzbsmJ2LGsYX/AOkQk8Ejbi5hTbBhffG/baN g6KzOLYiSEP+y5eIfnzSdLT0PrbNhV9hyGTIttmICx48sS9JMy/w+jATmJZ6C7Na711r MrNw== X-Forwarded-Encrypted: i=1; AJvYcCWi7BfbJVTjyrcYYQmBAUBsKk26MvVa4kK30OZPj5Ve0GBleye/7RJLJXgNWXk7vqkrjY4KkqI=@lists.denx.de X-Gm-Message-State: AOJu0YxZHPOP75CYI/xEr1nXf4i2ydCyOyOobb0IVoycnNabLUmTtRif dO9SiXlSlWEP50I+Q23nT7RA+RXei5oYQ+/lgYWPGPpeaDoWwPbfd1xHmAv1FLk= X-Google-Smtp-Source: AGHT+IHtEKqZFiuBRK+kvF8kNLe7K+6UwCIz248YTdJieM4SRxHWKCT0sFpSSk6uhSps/pf8oObnKw== X-Received: by 2002:a05:600c:1c83:b0:42b:a9b4:3f59 with SMTP id 5b1f17b1804b1-42bb0293da3mr41309635e9.14.1725021284631; Fri, 30 Aug 2024 05:34:44 -0700 (PDT) Received: from [192.168.1.17] (host-80-47-105-51.as13285.net. [80.47.105.51]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-374b960ef94sm648207f8f.103.2024.08.30.05.34.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Aug 2024 05:34:44 -0700 (PDT) From: Caleb Connolly Date: Fri, 30 Aug 2024 13:34:39 +0100 Subject: [PATCH v8 09/11] tools: mkeficapsule: support generating dynamic GUIDs MIME-Version: 1.0 Message-Id: <20240830-b4-dynamic-uuid-v8-9-79b31b199bee@linaro.org> References: <20240830-b4-dynamic-uuid-v8-0-79b31b199bee@linaro.org> In-Reply-To: <20240830-b4-dynamic-uuid-v8-0-79b31b199bee@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=8380; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=J5ba0Lf0VOIvi4e4WDju/mENF1r21gmz7iDbfAGA9Ro=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBm0bxamiSHnMH+yYidM2y9D/ij2B8Q8R0hcuOkn DJES4ld4vuJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZtG8WgAKCRAFgzErGV9k toomD/9im/7U5rMLIwDUm0/ror/t4YN8ct0aSviO186U9xZvp/m7QgIfSijdGpQKN5ZUk7qJ6VA IUcBFcp8udpSDb/jxeUcG9xgvody0mlY7rHf6CZnmUgFnUsRdjj3veFPuN+kBmTkZWDw6IG2lmM p7o+Ehfvw9ESvUWVpRrjM9HbOVqzH07qnI89Rtyyo/tOOBMA6j/KElEWAnBdkm2jhhlTVQzb0lv 5CIa9muG0ngAdN6gd9TRuIhe7IBKjOC7+9p85PTkULh8+A54ijEk8zqGgKGGU+Sl1popf5K6U4k y6xvvMzYo0ers/CdcbwHCKs09ek118uHAeItAs38avOR65RWfr9fy7De+QbBhopA3eP6cvcsEYP Zzl7NYdkl7cr4YM+eyA9dZfvodLEsrAqUltIWRFYswQVh7yDJbevSX/8AqMSHHtM0WY44sVlWmX CAHsGfJkBS7LQ7bn/0UYQNTTTEXpUi2EC3/b3PCPR1qCa+QwoJ46+OKC9AHOs93earzIXp/J9Qv tIA4jFhk8UvsbORoVg8/tL5Q2mRio4rI8BztRy1L2/S1CvCGev6i/vowvfm/zBdkeYf56BNenn4 amuv3iSOAAnqcrJEFx5AIH6V49dd0Vt5yIZHPasgFs/WWjZxAIDfwRvtIpHzODTFyu5NK8M1Q7y N0Bge/mJ50XT3Nw== X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Add support for generating GUIDs that match those generated internally by U-Boot for capsule update fw_images when using dynamic UUIDs. Dynamic UUIDs in U-Boot work by taking a namespace UUID and hashing it with the board compatible and fw_image name. This feature just provides a way to determine the UUIDs for a particular board without having to actually boot U-Boot on it. Acked-by: Ilias Apalodimas Signed-off-by: Caleb Connolly --- doc/mkeficapsule.1 | 23 ++++++++ tools/mkeficapsule.c | 156 +++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 174 insertions(+), 5 deletions(-) diff --git a/doc/mkeficapsule.1 b/doc/mkeficapsule.1 index c3d0f21488ad..a5545f7898a8 100644 --- a/doc/mkeficapsule.1 +++ b/doc/mkeficapsule.1 @@ -9,8 +9,11 @@ mkeficapsule \- Generate EFI capsule file for U-Boot .SH SYNOPSIS .B mkeficapsule .RI [ options ] " " [ image-blob ] " " capsule-file +.B mkeficapsule +.RI guidgen " " [ GUID ] " " DTB " " IMAGE_NAME... + .SH "DESCRIPTION" The .B mkeficapsule command is used to create an EFI capsule file to be used by U-Boot for firmware @@ -41,8 +44,12 @@ format is the same as used in the new uImage format and allows for multiple binary blobs in a single capsule file. This type of image file can be generated by .BR mkimage . +mkeficapsule can also be used to simulate the dynamic GUID generation used to +identify firmware images in capsule updates by providing the namespace guid, dtb +for the board, and a list of firmware images. + .SH "OPTIONS" .TP .BI "-g\fR,\fB --guid " guid-string @@ -116,8 +123,24 @@ at every firmware update. .TP .B "-d\fR,\fB --dump_sig" Dump signature data into *.p7 file +.SH "GUIDGEN OPTIONS" + +.TP +.B "[GUID]" +The namespace/salt GUID, by default this is EFI_CAPSULE_NAMESPACE_GUID. +The format is: + xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx + +.TP +.B DTB +The device tree blob file for the board. + +.TP +.B IMAGE_NAME... +The names of the firmware images to generate GUIDs for. + .PP .SH FILES .TP .I /EFI/UpdateCapsule diff --git a/tools/mkeficapsule.c b/tools/mkeficapsule.c index 68c97cfb9db4..7068c936c530 100644 --- a/tools/mkeficapsule.c +++ b/tools/mkeficapsule.c @@ -20,12 +20,16 @@ #include #include #include +#include #include #include "eficapsule.h" +// Matches CONFIG_EFI_CAPSULE_NAMESPACE_GUID +#define DEFAULT_NAMESPACE_GUID "8c9f137e-91dc-427b-b2d6-b420faebaf2a" + static const char *tool_name = "mkeficapsule"; efi_guid_t efi_guid_fm_capsule = EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID; efi_guid_t efi_guid_cert_type_pkcs7 = EFI_CERT_TYPE_PKCS7_GUID; @@ -54,11 +58,22 @@ static struct option options[] = { {"help", no_argument, NULL, 'h'}, {NULL, 0, NULL, 0}, }; -static void print_usage(void) +static void print_usage_guidgen(void) { - fprintf(stderr, "Usage: %s [options] \n" + fprintf(stderr, "%s guidgen [GUID] DTB IMAGE_NAME...\n" + "Options:\n" + + "\tGUID Namespace GUID (default: %s)\n" + "\tDTB Device Tree Blob\n" + "\tIMAGE_NAME... One or more names of fw_images to generate GUIDs for\n", + tool_name, DEFAULT_NAMESPACE_GUID); +} + +static void print_usage_mkeficapsule(void) +{ + fprintf(stderr, "Usage:\n\n%s [options] \n" "Options:\n" "\t-g, --guid guid for image blob type\n" "\t-i, --index update image index\n" @@ -72,10 +87,11 @@ static void print_usage(void) "\t-R, --fw-revert firmware revert capsule, takes no GUID, no image blob\n" "\t-o, --capoemflag Capsule OEM Flag, an integer between 0x0000 and 0xffff\n" "\t-D, --dump-capsule dump the contents of the capsule headers\n" "\t-V, --version show version number\n" - "\t-h, --help print a help message\n", + "\t-h, --help print a help message\n\n", tool_name); + print_usage_guidgen(); } /** * auth_context - authentication context @@ -818,8 +834,131 @@ static void dump_capsule_contents(char *capsule_file) exit(EXIT_FAILURE); } } +static struct fdt_header *load_dtb(const char *path) +{ + struct fdt_header *dtb; + ssize_t dtb_size; + FILE *f; + + /* Open and parse DTB */ + f = fopen(path, "r"); + if (!f) { + fprintf(stderr, "Cannot open %s\n", path); + return NULL; + } + + if (fseek(f, 0, SEEK_END)) { + fprintf(stderr, "Cannot seek to the end of %s: %s\n", + path, strerror(errno)); + return NULL; + } + + dtb_size = ftell(f); + if (dtb_size < 0) { + fprintf(stderr, "Cannot ftell %s: %s\n", + path, strerror(errno)); + return NULL; + } + + fseek(f, 0, SEEK_SET); + + dtb = malloc(dtb_size); + if (!dtb) { + fprintf(stderr, "Can't allocated %ld\n", dtb_size); + return NULL; + } + + if (fread(dtb, dtb_size, 1, f) != 1) { + fprintf(stderr, "Can't read %ld bytes from %s\n", + dtb_size, path); + free(dtb); + return NULL; + } + + fclose(f); + + return dtb; +} + +#define MAX_IMAGE_NAME_LEN 128 +static int genguid(int argc, char **argv) +{ + int idx = 2, ret; + unsigned char namespace[16]; + struct efi_guid image_type_id; + const char *dtb_path; + struct fdt_header *dtb; + const char *compatible; + int compatlen, namelen; + uint16_t fw_image[MAX_IMAGE_NAME_LEN]; + + if (argc < 2) { + fprintf(stderr, "Usage: "); + print_usage_guidgen(); + return -1; + } + + if (uuid_str_to_bin(argv[1], namespace, UUID_STR_FORMAT_GUID)) { + uuid_str_to_bin(DEFAULT_NAMESPACE_GUID, namespace, UUID_STR_FORMAT_GUID); + dtb_path = argv[1]; + } else { + dtb_path = argv[2]; + idx = 3; + } + + if (idx == argc) { + fprintf(stderr, "Usage: "); + print_usage_guidgen(); + return -1; + } + + dtb = load_dtb(dtb_path); + if (!dtb) + return -1; + + ret = fdt_check_header(dtb); + if (ret) { + fprintf(stderr, "Invalid DTB header: %d\n", ret); + return -1; + } + + compatible = fdt_getprop(dtb, 0, "compatible", &compatlen); + if (!compatible) { + fprintf(stderr, "No compatible string found in DTB\n"); + return -1; + } + if (strnlen(compatible, compatlen) >= compatlen) { + fprintf(stderr, "Compatible string not null-terminated\n"); + return -1; + } + + printf("Generating GUIDs for %s with namespace %s:\n", + compatible, DEFAULT_NAMESPACE_GUID); + for (; idx < argc; idx++) { + memset(fw_image, 0, sizeof(fw_image)); + namelen = strlen(argv[idx]); + if (namelen > MAX_IMAGE_NAME_LEN) { + fprintf(stderr, "Image name too long: %s\n", argv[idx]); + return -1; + } + + for (int i = 0; i < namelen; i++) + fw_image[i] = (uint16_t)argv[idx][i]; + + gen_v5_guid((struct uuid *)&namespace, &image_type_id, + compatible, strlen(compatible), + fw_image, namelen * sizeof(uint16_t), + NULL); + + printf("%s: ", argv[idx]); + print_guid(&image_type_id); + } + + return 0; +} + /** * main - main entry function of mkeficapsule * @argc: Number of arguments * @argv: Array of pointers to arguments @@ -842,8 +981,15 @@ int main(int argc, char **argv) char *privkey_file, *cert_file; int c, idx; struct fmp_payload_header_params fmp_ph_params = { 0 }; + /* Generate dynamic GUIDs */ + if (argc > 1 && !strcmp(argv[1], "guidgen")) { + if (genguid(argc - 1, argv + 1)) + exit(EXIT_FAILURE); + exit(EXIT_SUCCESS); + } + guid = NULL; index = 0; instance = 0; mcount = 0; @@ -933,9 +1079,9 @@ int main(int argc, char **argv) case 'V': printf("mkeficapsule version %s\n", PLAIN_VERSION); exit(EXIT_SUCCESS); default: - print_usage(); + print_usage_mkeficapsule(); exit(EXIT_FAILURE); } } @@ -956,9 +1102,9 @@ int main(int argc, char **argv) (capsule_type != CAPSULE_NORMAL_BLOB && ((argc != optind + 1) || ((capsule_type == CAPSULE_ACCEPT) && !guid) || ((capsule_type == CAPSULE_REVERT) && guid)))) { - print_usage(); + print_usage_mkeficapsule(); exit(EXIT_FAILURE); } if (capsule_type != CAPSULE_NORMAL_BLOB) { From patchwork Fri Aug 30 12:34:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 1978984 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=CJFRPAK2; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WwHhD1J6zz1ydy for ; Fri, 30 Aug 2024 22:36:28 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 96FB688C51; Fri, 30 Aug 2024 14:34:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="CJFRPAK2"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8BB9988C3F; Fri, 30 Aug 2024 14:34:49 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) (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 7321688BBC for ; Fri, 30 Aug 2024 14:34:46 +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-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4281ca54fd3so16088395e9.2 for ; Fri, 30 Aug 2024 05:34:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725021286; x=1725626086; 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=XQKUnmyBwBLvsTbpwbjgaHTP7ZZ59+35Ps2sQ2R6uIk=; b=CJFRPAK2qB/bP1/kt4ue2PukcaANK7rD2WOC/IoCKSrFZVh1RFuzGxajuT2NUAMfmB SlnH3pwJlntia/+MhaDVRUJVp61603fSlQqEYPQ9A/lqacNIb3wvTF/KXMkk1M70XvVH xXY7gjsVKEyEkNdpdDNzBSY8hF8y61gpf6ZLwan0JsfGFg97hTlRWDyq63bQ9KcwMZ0U 4mbE++5nRMAnQLM+q1qd1CTDPwfbM21tl+klgCfGqhSEdAW4QO6S9CapMmUNAvV03ce/ q7b1W7ZwLvJJUsX4xOKJwr+Sz/7d7vl2EBmRWMiQQxOCnRQzrw/NObSEhUmWEUz2FOM7 xwqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725021286; x=1725626086; 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=XQKUnmyBwBLvsTbpwbjgaHTP7ZZ59+35Ps2sQ2R6uIk=; b=NyXCLmEb9/f8ZTsNw0YCen0Sw6zJv+30ebSEjYP3Ca8ygG24155+uJWAWTdi0ouRau msTY6LSggMHrlYvv5XFlL/8nw/qN1KVFdPclWSlmkb+weTbUkTANRw/X77yWKC5wL0iH ksphN93TmpOLoUm5xgEabmZarwIZavimxNUnQwKMdMq1SPxkYZd2lvKoiVmR0F+FhGyN InXjimRfuy7QK0BnxstALBqsBDs8WrAgxCFFSI8jrDfY88GELlGL763POj1ej7cuvxlI AWBJdTZOfn/ip/F3HW9JxcDbmyntQSfj1q0G6iP/hhe7Qmcqz2zkFlt/NaV5dzPzHxRo quBQ== X-Forwarded-Encrypted: i=1; AJvYcCXU3q3X0a/IJyKd+ZDxIppNz1QSDAr1hiWlVXJbfLWKdl1OxTx3NfteRKxPYks+rUyDBd8zUy0=@lists.denx.de X-Gm-Message-State: AOJu0YxQWliYH9B/nAP3PDvdqeqeC2bfkyyNKcOlZQMHx/iCikWIbC3H bitwQJD0Ae4+X6ui8q51K3TFTIQ/Ycn6gT0q6/0UQOKVnQ7GXucJ1x47cr7Bqh6TPZLIYUaExy8 S X-Google-Smtp-Source: AGHT+IGSqRKeXcoTiP+8Byy8Qcvd/vkW61KBbeC65le4mIXZ5j8T3O6FbhY/OUBHfHAviaBz0MtlkQ== X-Received: by 2002:adf:9b89:0:b0:371:9366:6d8d with SMTP id ffacd0b85a97d-3749b5495abmr4289097f8f.19.1725021285832; Fri, 30 Aug 2024 05:34:45 -0700 (PDT) Received: from [192.168.1.17] (host-80-47-105-51.as13285.net. [80.47.105.51]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-374b960ef94sm648207f8f.103.2024.08.30.05.34.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Aug 2024 05:34:45 -0700 (PDT) From: Caleb Connolly Date: Fri, 30 Aug 2024 13:34:40 +0100 Subject: [PATCH v8 10/11] test: lib/uuid: add unit tests for dynamic UUIDs MIME-Version: 1.0 Message-Id: <20240830-b4-dynamic-uuid-v8-10-79b31b199bee@linaro.org> References: <20240830-b4-dynamic-uuid-v8-0-79b31b199bee@linaro.org> In-Reply-To: <20240830-b4-dynamic-uuid-v8-0-79b31b199bee@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=3066; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=nQtu1CuT1dJvWShrMxbtGhtMhEP33bTMHgB54rEEcWk=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBm0bxafPDuPmk4Oj7igpnA5gfslpNag0Z6cSHaL Uf2DKBcNnSJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZtG8WgAKCRAFgzErGV9k tq4cD/9jjEkp0JBL9sJJf6YBmUnLwgxTfY58rMUrEjGn5K6f2+9PPMClO2jNbnxy+pNw6ZSU2f1 4M0Td9JmKjsFmFlss9G1N4nY+6C3YGlkpONOM8k/T28xeqNJNXWGcagCXLsO199vGj9DwHhaZ9l 4P1XPz0sxZyE+zIVpze7P1jeD0UOYSSOGgOCD2aYDp0io648tyTxdWfcbDhfL5O4KNVpavfhMe1 4TDOLH9oV+fo0eGDgCWtTrw1nwWwqUqso38i2wGlhlrLYVYsLgVs3BgZBf1veG3xO+Y/Up15xjW +uXPB6yTbL7PzHbQAH6UH5RVmsnM3JZnPDHrnUrg81oZiLmeaTDFRwcv676jS4m15oBrydINDbv UTdKR+uW+2Y5THa6utxaIi+PIxFb0CtFhEvPJI1dOLdBq/06O0tFSdwVWutrhJgUhZqP9r0Rf7p eGqi8wXqq6xloLGlQqc/uCQvp06QirMoF3EST8eT3vBBM79MgWuSyq0/0/NNflNoQwuFKOXbGPi AcYxKVR5sBaeEy+FuWG/7Oi3uM80tm9Ng8gPXgd5E+Z3f2R4r0gY09c0tMZr8ib6PEpFG8SLZKJ r9+Dg5IeF7Jt0esNLp8nZcDp0GW14spYIFFuyct6KsTYbHbI61rqS40TFCk3/1JQzaCq+v8h61X 057b98wHlqaQigg== 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. Acked-by: Ilias Apalodimas Signed-off-by: Caleb Connolly --- test/lib/uuid.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/test/lib/uuid.c b/test/lib/uuid.c index 3d62e18bcfee..4a1a16b4f315 100644 --- a/test/lib/uuid.c +++ b/test/lib/uuid.c @@ -7,15 +7,20 @@ * Authors: * Abdellatif El Khlifi */ +#include #include #include #include #include +#include + /* test UUID */ #define TEST_SVC_UUID "ed32d533-4209-99e6-2d72-cdd998a79cc0" +/* U-Boot default fw image namespace */ +#define DEFAULT_FW_IMAGE_NAMESPACE "8c9f137e-91dc-427b-b2d6-b420faebaf2a" #define UUID_SIZE 16 /* The UUID binary data (little-endian format) */ @@ -36,4 +41,81 @@ static int lib_test_uuid_to_le(struct unit_test_state *uts) return 0; } LIB_TEST(lib_test_uuid_to_le, 0); + +struct dynamic_uuid_test_data { + 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(DEFAULT_FW_IMAGE_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]; + efi_guid_t uuid; + char uuid_str[37]; + + gen_v5_guid(&namespace, &uuid, + data->compatible, strlen(data->compatible), + image, u16_strlen(image) * sizeof(uint16_t), + NULL); + uuid_bin_to_str((unsigned char *)&uuid, uuid_str, UUID_STR_FORMAT_GUID); + + ut_asserteq_str(expected_uuid, uuid_str); + } + + return 0; +} + +static int lib_test_dynamic_uuid(struct unit_test_state *uts) +{ + int ret, i; + const struct dynamic_uuid_test_data test_data[] = { + { + .compatible = "sandbox", + .images = { + u"SANDBOX-UBOOT", + u"SANDBOX-UBOOT-ENV", + u"SANDBOX-FIT", + NULL, + }, + .expected_uuids = { + "985f2937-7c2e-5e9a-8a5e-8e063312964b", + "9e339473-c2eb-530a-a69b-0cd6bbbed40e", + "46610520-469e-59dc-a8dd-c11832b877ea", + NULL, + } + }, + { + .compatible = "qcom,qrb4210-rb2", + .images = { + u"QUALCOMM-UBOOT", + NULL, + }, + .expected_uuids = { + "d5021fac-8dd0-5ed7-90c2-763c304aaf86", + 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); + From patchwork Fri Aug 30 12:34:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 1978985 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=tUPa8t+O; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WwHhQ1VVYz1ydy for ; Fri, 30 Aug 2024 22:36:38 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F195F88C75; Fri, 30 Aug 2024 14:34:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="tUPa8t+O"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9D44788BBC; Fri, 30 Aug 2024 14:34:49 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) (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 8D53C88BFB for ; Fri, 30 Aug 2024 14:34:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-42bac9469e8so14864215e9.3 for ; Fri, 30 Aug 2024 05:34:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725021287; x=1725626087; 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=T720AHi0i4hNwKP9CGAlVcXZIAOAU+9zGvK3MyjWnBM=; b=tUPa8t+OImzjM3/2s23OjQ1XNQQv5gXRsNuyVTPaSFxzgOTGn3deCZhAhc44JDc8S3 r4uyl26pghFRntPOwnTq3ufZ5yoigR3Mj7/LMT+ZDA5YTE3/ILgEAS3w4TyOOGWrThpH lj5p0aa4U7gUefMyKgNei1tAbshqfmW1Pf30KLD/wJkVGj6DZSPPxzaFBKIL8cPzIvVL lILn5YlrmLYLngwXd214OMPRLmNYD7a70yiLIHjX2AwV/htwb2qG0S1InkA6+evcdeyw 4fFX1l3Knte1AkaSWKkg2kfXymxrWlG3A66FTlkHgvm9m7oxzHpsFb2ZFIvRKhQSjH9V 2G6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725021287; x=1725626087; 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=T720AHi0i4hNwKP9CGAlVcXZIAOAU+9zGvK3MyjWnBM=; b=VZNk+yP4GBG5S6e62eUEFD2L6MhN92sl0+1S7dYRjNF1wfxoCJZ6lHzp0yMWuWNqBZ UfS4TeOCAV8nqiYzgn/ptbbvWB+vNlV9Uj1A9neXyojXD+y7Ynxg45J8YvgBq57cqIxZ PBvWZg7g12nvW8QAlz59R1rxsRaE9mxj8XnJQdq9Y7rTzhc/HPSOkCaAAYegO5GtavM7 YeHTSrKLQXXKpVYXoqA9hAAQaVWy5zhcCZQ9iQCqV3Kbl4FEOMl/7uEy7sIkG7Ob+eRi 4QPW3K8NxCAQ1gsXhTOmp7yKpthVa5QBtErrZTIy/JL7MNfTA0VhQGZCUuUt9UuMpHin yMuw== X-Forwarded-Encrypted: i=1; AJvYcCWVQJyEUyifV0iCQpLaO+906hbmn7CuNQOzhQTaZGbIQP0rGyJ7inVb8snLAiMDrM5db5V+mQY=@lists.denx.de X-Gm-Message-State: AOJu0YxdS6cb0wQ7NzNLLIOO+A31o7TQnNmqMh7R4NpwHS9IDS8wgO7o uWTYSEn1pGjB+Hu7GUmU/fNKfJvlol7ZKSCL7ax1yVAdmPGUxDpM1njzfZyoOGc= X-Google-Smtp-Source: AGHT+IFKO1YTo4DIL/hHbR9dTQuF8pl0y1ZmBARCkGDN9W//2H7E5AYURO4zGedcxZZByLUlj4eeGw== X-Received: by 2002:a05:600c:3596:b0:42b:8a35:1ade with SMTP id 5b1f17b1804b1-42bb02d94f0mr50289425e9.27.1725021286994; Fri, 30 Aug 2024 05:34:46 -0700 (PDT) Received: from [192.168.1.17] (host-80-47-105-51.as13285.net. [80.47.105.51]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-374b960ef94sm648207f8f.103.2024.08.30.05.34.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Aug 2024 05:34:46 -0700 (PDT) From: Caleb Connolly Date: Fri, 30 Aug 2024 13:34:41 +0100 Subject: [PATCH v8 11/11] test: lib/uuid: add tests for UUID version/variant bits MIME-Version: 1.0 Message-Id: <20240830-b4-dynamic-uuid-v8-11-79b31b199bee@linaro.org> References: <20240830-b4-dynamic-uuid-v8-0-79b31b199bee@linaro.org> In-Reply-To: <20240830-b4-dynamic-uuid-v8-0-79b31b199bee@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=1868; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=N9V0m2aNtjrngrrxhmdCcdsnP8l6Sxth44kFjZd/FOA=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBm0bxaMn3NkReWtygfjw2EKX7TErNPR4UvfQdu9 g980KT7KB6JAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZtG8WgAKCRAFgzErGV9k thBQEACMLUIhBxGMbW8dBkMXmC7x3CLnX/Me6xo9ckTcaVAXaThgU4iXOdJabQRQZNoJHeF7xTK Sp/S/LbzaE+81ghlGDS54T9kj7ESCwDEen1U5GVOnzTurMJ7G2hKolRBdrim+UddYvitwtYP5d2 yKCe51NHawyycLn/iPYamXSXPb3OYYnG9KGIxsnyYTwkrUbMfF3JCWNMyfldV2EoWUvksFv6Gtl IqT7fqKiCXuI+u8F7X+q+nUU7BeJTKvIzE6UMPQAfSxi1+wvW8rzmi/gUXOJemDkNjPywy5U62H 0WyyXk+ARegKwpiYmyF8jGBrD8515UvethRqPb7L1qILUu7QX1kfOMcZq0kbhlclXKMYNb0QTMn uaO0tUNRGfxgYFMQXaYxkFj/csQ46WrZVDl7lu3sYgso41hD22GE+wgzn0m2xIWCgyme5jVS7MH axiaHaaOpNzEQOOSVzFAscRDE/uFeDO+xcE5Ka31fXrQNXwURWZUvXmALw+nze5heZKbqBxGaIA OvAngOjkCOxrXQM+gJr6VIAgtKIOMa77f95/GrfXB8envfjrWcKHP1PjXhrloIbtTqcQFhKQT9g MZHb2bCwXrXFEyd3I4Ppgt82oouUOlYyiBvA8bx81ZpMLdapnjhPvLd2XADM1xdkXsIRoXHUkLE CJnAdzDbeNwY86w== 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 test to check the version/variant bits of v4 and v5 UUIDs. Acked-by: Ilias Apalodimas Signed-off-by: Caleb Connolly --- test/lib/uuid.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/test/lib/uuid.c b/test/lib/uuid.c index 4a1a16b4f315..bf5d5afdb521 100644 --- a/test/lib/uuid.c +++ b/test/lib/uuid.c @@ -42,8 +42,49 @@ static int lib_test_uuid_to_le(struct unit_test_state *uts) return 0; } LIB_TEST(lib_test_uuid_to_le, 0); +#if defined(CONFIG_RANDOM_UUID) || defined(CONFIG_CMD_UUID) +/* Test UUID attribute bits (version, variant) */ +static int lib_test_uuid_bits(struct unit_test_state *uts) +{ + unsigned char uuid[16]; + efi_guid_t guid; + int i; + + /* + * Reduce the chance of a randomly generated UUID disguising + * a regression by testing multiple times. + */ + for (i = 0; i < 5; i++) { + /* Test UUID v4 */ + gen_rand_uuid((unsigned char *)&uuid); + + printf("v4 UUID: %pUb\n", (efi_guid_t *)uuid); + + /* version 4 */ + ut_assert((uuid[6] & 0xf0) == 0x40); + /* variant 1 */ + ut_assert((uuid[8] & UUID_VARIANT_MASK) == (UUID_VARIANT << UUID_VARIANT_SHIFT)); + + /* Test v5, use the v4 UUID as the namespace */ + gen_v5_guid((struct uuid *)uuid, + &guid, "test", 4, NULL); + + printf("v5 GUID: %pUl\n", (efi_guid_t *)uuid); + + /* This is a GUID so bits 6 and 7 are swapped (little endian). Version 5 */ + ut_assert((guid.b[7] & 0xf0) == 0x50); + /* variant 1 */ + ut_assert((guid.b[8] & UUID_VARIANT_MASK) == (UUID_VARIANT << UUID_VARIANT_SHIFT)); + } + + return 0; +} + +LIB_TEST(lib_test_uuid_bits, 0); +#endif + struct dynamic_uuid_test_data { const char *compatible; const u16 *images[4]; const char *expected_uuids[4];