From patchwork Mon Dec 18 18:18:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raymond Mao X-Patchwork-Id: 1877535 X-Patchwork-Delegate: sjg@chromium.org 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=L1/9Mscw; 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 4Sv7QT1Pgvz2402 for ; Tue, 19 Dec 2023 05:19:45 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 27A9A870DF; Mon, 18 Dec 2023 19:19:42 +0100 (CET) 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="L1/9Mscw"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3571E871C3; Mon, 18 Dec 2023 19:19:41 +0100 (CET) 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-oo1-xc36.google.com (mail-oo1-xc36.google.com [IPv6:2607:f8b0:4864:20::c36]) (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 E2E678743A for ; Mon, 18 Dec 2023 19:19:37 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=raymond.mao@linaro.org Received: by mail-oo1-xc36.google.com with SMTP id 006d021491bc7-59091e4a0f9so1424088eaf.1 for ; Mon, 18 Dec 2023 10:19:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1702923576; x=1703528376; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TPrgZpWodwgPb0KblJAhNU0xeDi0U0o9ZvIxm3m/fmI=; b=L1/9Mscw7aOM85tE9odTS9uoHtfKtrbHdnJoylte0vGTSSpnPztv0rK4mmkvI0uV95 aT+k79kXBGhb/ztI8Ckia8GOBUVAMlEkHitqcgnRaIdt+Kh3h7cYAGJAzIKzkde8Anm0 FOoP3MpajVBQfR2/awecRngcEgti2bHombDIk3Q7TT574r8sChfy8bF/Ao2EhaxGzXot UtNYDzFpeVZc4t2IUyvZ6T3chOnVx6Cl8KakZ7VA++REFUSYOLq844riIkhws2KVANIC bvujR1ovfe9D3ysmNtniffBJT/42ZLk9ygomvEq318ZyLOwx6V7eksEkiEysA06zw+Wt cVsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702923576; x=1703528376; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TPrgZpWodwgPb0KblJAhNU0xeDi0U0o9ZvIxm3m/fmI=; b=NPTsxH/0T09zIy7GRsWWBX8nT7siTffbelhj++AuB5jB8/CF8AJ0rS0vrmouTMDWC9 J2DPTNFyuzobJruO7sLq/+eWOVlI3ZeValPwkE/I1vHGkVK9WPWz3wmsMoYlTJXAp2e5 2RPiGCUX8b77TfnguWw/ANYkWxb5Thw8qJ6EF9U8c2g04WQsLEeY1C5kaQrb1HQqXPf9 WjRHJOPrLKTG/8gVPgYQOKJ7w3xJBZqErqN3Tn/v91ZpvUsXbgEGBQ6CNBpCU5Sii050 n+wVoKEVU+SRsUvFHiRa1vIDMKMUa3X+3D1SUpw6pw//LZffPD5XP84lUuOTmmDLBtpq J7TQ== X-Gm-Message-State: AOJu0YzU9naL1rDxRAk2O9bESC8pG2icIKuFOGWBYdzifTon57CE1JxM tGesAOSqvqxZYA5dkkw3WpkUnvbcoUfrEUDGJ/Q= X-Google-Smtp-Source: AGHT+IFZKWSvUCIz0GHux3vVx2eUeS3o9s58d24Byeq6vOoi4WTXsabtR/AHPbXSfDUXmLEZl0Zgaw== X-Received: by 2002:a05:6358:921d:b0:16d:bc51:7601 with SMTP id d29-20020a056358921d00b0016dbc517601mr5408954rwb.9.1702923575961; Mon, 18 Dec 2023 10:19:35 -0800 (PST) Received: from ubuntu.localdomain (cpe688f2e182063-cm688f2e182060.sdns.net.rogers.com. [174.115.4.214]) by smtp.gmail.com with ESMTPSA id dy7-20020ad44e87000000b0067f213933bdsm3046136qvb.2.2023.12.18.10.19.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 10:19:35 -0800 (PST) From: Raymond Mao To: u-boot@lists.denx.de, ilias.apalodimas@linaro.org, sjg@chromium.org, jwerner@chromium.org Cc: Raymond Mao , Bin Meng , Nikhil M Jain Subject: [PATCH v3 01/14] bloblist: Update the tag numbering Date: Mon, 18 Dec 2023 10:18:46 -0800 Message-Id: <20231218181901.337515-2-raymond.mao@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231218181901.337515-1-raymond.mao@linaro.org> References: <20231218181901.337515-1-raymond.mao@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Simon Glass Align bloblist tags with the FW handoff spec v0.9. The most common ones are from 0. TF related ones are from 0x100. All non-standard ones from 0xfff000. Added new defined tags: BLOBLISTT_OPTEE_PAGABLE_PART for TF. BLOBLISTT_TPM_EVLOG and BLOBLISTT_TPM_CRB_BASE for TPM. Signed-off-by: Simon Glass Co-developed-by: Raymond Mao Signed-off-by: Raymond Mao --- Changes in v2 - Align bloblist tags to FW handoff spec v0.9. Changes in v3 - Add TPM related tags common/bloblist.c | 18 ++++++++++--- include/bloblist.h | 67 +++++++++++++++++++++++++--------------------- test/bloblist.c | 4 +-- 3 files changed, 52 insertions(+), 37 deletions(-) diff --git a/common/bloblist.c b/common/bloblist.c index a22f6c12b0..5606487f5b 100644 --- a/common/bloblist.c +++ b/common/bloblist.c @@ -36,16 +36,26 @@ static struct tag_name { enum bloblist_tag_t tag; const char *name; } tag_name[] = { - { BLOBLISTT_NONE, "(none)" }, + { BLOBLISTT_VOID, "(void)" }, /* BLOBLISTT_AREA_FIRMWARE_TOP */ + { BLOBLISTT_CONTROL_FDT, "Control FDT" }, + { BLOBLISTT_HOB_BLOCK, "HOB block" }, + { BLOBLISTT_HOB_LIST, "HOB list" }, + { BLOBLISTT_ACPI_TABLES, "ACPI tables for x86" }, + { BLOBLISTT_TPM_EVLOG, "TPM event log defined by TCG EFI" }, + { BLOBLISTT_TPM_CRB_BASE, "TPM Command Response Buffer address" }, /* BLOBLISTT_AREA_FIRMWARE */ - { BLOBLISTT_ACPI_GNVS, "ACPI GNVS" }, - { BLOBLISTT_INTEL_VBT, "Intel Video-BIOS table" }, { BLOBLISTT_TPM2_TCG_LOG, "TPM v2 log space" }, { BLOBLISTT_TCPA_LOG, "TPM log space" }, - { BLOBLISTT_ACPI_TABLES, "ACPI tables for x86" }, + { BLOBLISTT_ACPI_GNVS, "ACPI GNVS" }, + + /* BLOBLISTT_AREA_TF */ + { BLOBLISTT_OPTEE_PAGABLE_PART, "OP-TEE pagable part" }, + + /* BLOBLISTT_AREA_OTHER */ + { BLOBLISTT_INTEL_VBT, "Intel Video-BIOS table" }, { BLOBLISTT_SMBIOS_TABLES, "SMBIOS tables for x86" }, { BLOBLISTT_VBOOT_CTX, "Chrome OS vboot context" }, diff --git a/include/bloblist.h b/include/bloblist.h index 080cc46a12..92dbfda21b 100644 --- a/include/bloblist.h +++ b/include/bloblist.h @@ -81,7 +81,7 @@ enum { /* Supported tags - add new ones to tag_name in bloblist.c */ enum bloblist_tag_t { - BLOBLISTT_NONE = 0, + BLOBLISTT_VOID = 0, /* * Standard area to allocate blobs used across firmware components, for @@ -89,42 +89,36 @@ enum bloblist_tag_t { * projects. */ BLOBLISTT_AREA_FIRMWARE_TOP = 0x1, + /* + * Devicetree for use by firmware. On some platforms this is passed to + * the OS also + */ + BLOBLISTT_CONTROL_FDT = 1, + BLOBLISTT_HOB_BLOCK = 2, + BLOBLISTT_HOB_LIST = 3, + BLOBLISTT_ACPI_TABLES = 4, + BLOBLISTT_TPM_EVLOG = 5, + BLOBLISTT_TPM_CRB_BASE = 6, /* Standard area to allocate blobs used across firmware components */ - BLOBLISTT_AREA_FIRMWARE = 0x100, + BLOBLISTT_AREA_FIRMWARE = 0x10, + BLOBLISTT_TPM2_TCG_LOG = 0x10, /* TPM v2 log space */ + BLOBLISTT_TCPA_LOG = 0x11, /* TPM log space */ /* * Advanced Configuration and Power Interface Global Non-Volatile * Sleeping table. This forms part of the ACPI tables passed to Linux. */ - BLOBLISTT_ACPI_GNVS = 0x100, - BLOBLISTT_INTEL_VBT = 0x101, /* Intel Video-BIOS table */ - BLOBLISTT_TPM2_TCG_LOG = 0x102, /* TPM v2 log space */ - BLOBLISTT_TCPA_LOG = 0x103, /* TPM log space */ - BLOBLISTT_ACPI_TABLES = 0x104, /* ACPI tables for x86 */ - BLOBLISTT_SMBIOS_TABLES = 0x105, /* SMBIOS tables for x86 */ - BLOBLISTT_VBOOT_CTX = 0x106, /* Chromium OS verified boot context */ + BLOBLISTT_ACPI_GNVS = 0x12, - /* - * Project-specific tags are permitted here. Projects can be open source - * or not, but the format of the data must be fuily documented in an - * open source project, including all fields, bits, etc. Naming should - * be: BLOBLISTT__ - */ - BLOBLISTT_PROJECT_AREA = 0x8000, - BLOBLISTT_U_BOOT_SPL_HANDOFF = 0x8000, /* Hand-off info from SPL */ - BLOBLISTT_VBE = 0x8001, /* VBE per-phase state */ - BLOBLISTT_U_BOOT_VIDEO = 0x8002, /* Video information from SPL */ - - /* - * Vendor-specific tags are permitted here. Projects can be open source - * or not, but the format of the data must be fuily documented in an - * open source project, including all fields, bits, etc. Naming should - * be BLOBLISTT__ - */ - BLOBLISTT_VENDOR_AREA = 0xc000, + /* Standard area to allocate blobs used for Trusted Firmware */ + BLOBLISTT_AREA_TF = 0x100, + BLOBLISTT_OPTEE_PAGABLE_PART = 0x100, - /* Tags after this are not allocated for now */ - BLOBLISTT_EXPANSION = 0x10000, + /* Other standard area to allocate blobs */ + BLOBLISTT_AREA_OTHER = 0x200, + BLOBLISTT_INTEL_VBT = 0x200, /* Intel Video-BIOS table */ + BLOBLISTT_SMBIOS_TABLES = 0x201, /* SMBIOS tables for x86 */ + BLOBLISTT_VBOOT_CTX = 0x202, /* Chromium OS verified boot context */ /* * Tags from here are on reserved for private use within a single @@ -133,9 +127,20 @@ enum bloblist_tag_t { * implementation, but cannot be used in upstream code. Allocate a * tag in one of the areas above if you want that. * - * This area may move in future. + * Project-specific tags are permitted here. Projects can be open source + * or not, but the format of the data must be fuily documented in an + * open source project, including all fields, bits, etc. Naming should + * be: BLOBLISTT__ + * + * Vendor-specific tags are also permitted. Projects can be open source + * or not, but the format of the data must be fuily documented in an + * open source project, including all fields, bits, etc. Naming should + * be BLOBLISTT__ */ - BLOBLISTT_PRIVATE_AREA = 0xffff0000, + BLOBLISTT_PRIVATE_AREA = 0xfff000, + BLOBLISTT_U_BOOT_SPL_HANDOFF = 0xfff000, /* Hand-off info from SPL */ + BLOBLISTT_VBE = 0xfff001, /* VBE per-phase state */ + BLOBLISTT_U_BOOT_VIDEO = 0xfff002, /* Video info from SPL */ }; /** diff --git a/test/bloblist.c b/test/bloblist.c index 720be7e244..efa1e32afd 100644 --- a/test/bloblist.c +++ b/test/bloblist.c @@ -291,9 +291,9 @@ static int bloblist_test_cmd_list(struct unit_test_state *uts) console_record_reset(); run_command("bloblist list", 0); ut_assert_nextline("Address Size Tag Name"); - ut_assert_nextline("%08lx %8x 8000 SPL hand-off", + ut_assert_nextline("%08lx %8x fff000 SPL hand-off", (ulong)map_to_sysmem(data), TEST_SIZE); - ut_assert_nextline("%08lx %8x 106 Chrome OS vboot context", + ut_assert_nextline("%08lx %8x 202 Chrome OS vboot context", (ulong)map_to_sysmem(data2), TEST_SIZE2); ut_assert_console_end(); ut_unsilence_console(uts); From patchwork Mon Dec 18 18:18:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raymond Mao X-Patchwork-Id: 1877536 X-Patchwork-Delegate: sjg@chromium.org 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=WkGG7chd; 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 4Sv7Qf0cdDz2402 for ; Tue, 19 Dec 2023 05:19:54 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id ADD47874AC; Mon, 18 Dec 2023 19:19:45 +0100 (CET) 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="WkGG7chd"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3AC9C874AC; Mon, 18 Dec 2023 19:19:45 +0100 (CET) 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-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) (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 EFBEF8743A for ; Mon, 18 Dec 2023 19:19:42 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=raymond.mao@linaro.org Received: by mail-oi1-x22f.google.com with SMTP id 5614622812f47-3ba1be5ad0aso2292004b6e.0 for ; Mon, 18 Dec 2023 10:19:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1702923581; x=1703528381; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IsqrUktKLzdZdekQAcMypgh6BKNeAFI6UxN1CYjFwPQ=; b=WkGG7chd9x/GK0WyDt2Pf4MQTQylA3j7m6JwxRbPr2Rx7AU6FYfcsUlMbfZ4lzsA68 xxIymb2+tm6KJQanrLBD+RKTC+bBuDB7Fjnljf+5r9brcyFvC5pUAtIt2K8pHZ6/LOIp XMoH7ss73TotaaaX+WJcglJB8n9ucMNmYHCBbt6+4Cpd7aAimsdDjLBC8FXT7RrLID6a 8cbtjvfHBfNifJIucxloxsP0BjCxY4UJBShfEIzZwg9KvGQYtiH9gO0R3XCsJzrg/6a4 QN8Y8EllyxdmO3QOLISrBU4IdUgkUW9l8KZVqsTgDeXVLlmX+AqfkPDvSOEaiVvVZshE 3bbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702923581; x=1703528381; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IsqrUktKLzdZdekQAcMypgh6BKNeAFI6UxN1CYjFwPQ=; b=LycitjlS+7a2lXBgc99TsfzrWDfTy3r5on4TzRk27DlluGBxssz2v16Lm3yLVITwaH Au+Cu2ZC9LhxGJSHZeUNGdLn+B478rur7TPfbcvgDuFMonI+/J1aQQ1iquS1NAXTgUQ6 9Trgi8azpgmwV6GEOWK0EZTaz2AJe6pf8v0hLVTw6EiGvMs7/YpFZPmIbDP03JXwVmNZ vDlRagkxtP3++NW8ACwHx8zvoiNYtWYeF0b8gppHTp+BNzrxyV0lucQJ9td8Rv0/Va4r NvPrn2m9hqPy/KqQdhfxRK17E+ZHnOHUxka2NqEjJbo85UA6YF12R1ziesl606GAEFkc 2hqg== X-Gm-Message-State: AOJu0YzkpeU3vNGi9OQ8czCb8nb3U5Qtdfg8Ynbk8tLmZHcABbt3dDuj mLZtepBjGdHSnSQ6rmmK6Woy0ZwE50Cr7JdRPXE= X-Google-Smtp-Source: AGHT+IGVW/ZsLqklwz4uIK0SD8AV3ViHVtBzpthGi8Hl6UTCXPYMJrJsTCXJ4EYQFC1O6O5Dd6SSCg== X-Received: by 2002:a05:6358:419d:b0:16e:12e:e232 with SMTP id w29-20020a056358419d00b0016e012ee232mr11448730rwc.6.1702923581206; Mon, 18 Dec 2023 10:19:41 -0800 (PST) Received: from ubuntu.localdomain (cpe688f2e182063-cm688f2e182060.sdns.net.rogers.com. [174.115.4.214]) by smtp.gmail.com with ESMTPSA id dy7-20020ad44e87000000b0067f213933bdsm3046136qvb.2.2023.12.18.10.19.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 10:19:40 -0800 (PST) From: Raymond Mao To: u-boot@lists.denx.de, ilias.apalodimas@linaro.org, sjg@chromium.org, jwerner@chromium.org Cc: Raymond Mao , Bin Meng , Nikhil M Jain Subject: [PATCH v3 02/14] bloblist: Adjust API to align in powers of 2 Date: Mon, 18 Dec 2023 10:18:47 -0800 Message-Id: <20231218181901.337515-3-raymond.mao@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231218181901.337515-1-raymond.mao@linaro.org> References: <20231218181901.337515-1-raymond.mao@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Simon Glass The updated bloblist structure stores the alignment as a power-of-two value in its structures. Adjust the API to use this, to avoid needing to calling ilog2(). Drop a stale comment while we are here. Signed-off-by: Simon Glass Co-developed-by: Raymond Mao Signed-off-by: Raymond Mao Reviewed-by: Simon Glass --- Changes in v2 - Update the bloblist alignment to align to FW handoff spec v0.9. arch/x86/lib/tables.c | 3 ++- common/bloblist.c | 24 +++++++++++------------- include/bloblist.h | 12 +++++++----- test/bloblist.c | 4 ++-- 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/arch/x86/lib/tables.c b/arch/x86/lib/tables.c index 5b5070f7ca..d43e77d373 100644 --- a/arch/x86/lib/tables.c +++ b/arch/x86/lib/tables.c @@ -16,6 +16,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -104,7 +105,7 @@ int write_tables(void) if (!gd->arch.table_end) gd->arch.table_end = rom_addr; rom_addr = (ulong)bloblist_add(table->tag, size, - table->align); + ilog2(table->align)); if (!rom_addr) return log_msg_ret("bloblist", -ENOBUFS); diff --git a/common/bloblist.c b/common/bloblist.c index 5606487f5b..1e78a3d4b3 100644 --- a/common/bloblist.c +++ b/common/bloblist.c @@ -26,8 +26,6 @@ * start address of the data in each blob is aligned as required. Note that * each blob's *data* is aligned to BLOBLIST_ALIGN regardless of the alignment * of the bloblist itself or the blob header. - * - * So far, only BLOBLIST_ALIGN alignment is supported. */ DECLARE_GLOBAL_DATA_PTR; @@ -128,24 +126,24 @@ static struct bloblist_rec *bloblist_findrec(uint tag) return NULL; } -static int bloblist_addrec(uint tag, int size, int align, +static int bloblist_addrec(uint tag, int size, int align_log2, struct bloblist_rec **recp) { struct bloblist_hdr *hdr = gd->bloblist; struct bloblist_rec *rec; int data_start, new_alloced; - if (!align) - align = BLOBLIST_ALIGN; + if (!align_log2) + align_log2 = BLOBLIST_ALIGN_LOG2; /* Figure out where the new data will start */ data_start = map_to_sysmem(hdr) + hdr->alloced + sizeof(*rec); /* Align the address and then calculate the offset from ->alloced */ - data_start = ALIGN(data_start, align) - map_to_sysmem(hdr); + data_start = ALIGN(data_start, 1U << align_log2) - map_to_sysmem(hdr); /* Calculate the new allocated total */ - new_alloced = data_start + ALIGN(size, align); + new_alloced = data_start + ALIGN(size, 1U << align_log2); if (new_alloced > hdr->size) { log_err("Failed to allocate %x bytes size=%x, need size=%x\n", @@ -169,7 +167,7 @@ static int bloblist_addrec(uint tag, int size, int align, } static int bloblist_ensurerec(uint tag, struct bloblist_rec **recp, int size, - int align) + int align_log2) { struct bloblist_rec *rec; @@ -182,7 +180,7 @@ static int bloblist_ensurerec(uint tag, struct bloblist_rec **recp, int size, } else { int ret; - ret = bloblist_addrec(tag, size, align, &rec); + ret = bloblist_addrec(tag, size, align_log2, &rec); if (ret) return ret; } @@ -204,22 +202,22 @@ void *bloblist_find(uint tag, int size) return (void *)rec + rec->hdr_size; } -void *bloblist_add(uint tag, int size, int align) +void *bloblist_add(uint tag, int size, int align_log2) { struct bloblist_rec *rec; - if (bloblist_addrec(tag, size, align, &rec)) + if (bloblist_addrec(tag, size, align_log2, &rec)) return NULL; return (void *)rec + rec->hdr_size; } -int bloblist_ensure_size(uint tag, int size, int align, void **blobp) +int bloblist_ensure_size(uint tag, int size, int align_log2, void **blobp) { struct bloblist_rec *rec; int ret; - ret = bloblist_ensurerec(tag, &rec, size, align); + ret = bloblist_ensurerec(tag, &rec, size, align_log2); if (ret) return ret; *blobp = (void *)rec + rec->hdr_size; diff --git a/include/bloblist.h b/include/bloblist.h index 92dbfda21b..5ad1337d1f 100644 --- a/include/bloblist.h +++ b/include/bloblist.h @@ -76,7 +76,9 @@ enum { BLOBLIST_VERSION = 0, BLOBLIST_MAGIC = 0xb00757a3, - BLOBLIST_ALIGN = 16, + + BLOBLIST_ALIGN_LOG2 = 3, + BLOBLIST_ALIGN = 1 << BLOBLIST_ALIGN_LOG2, }; /* Supported tags - add new ones to tag_name in bloblist.c */ @@ -254,11 +256,11 @@ void *bloblist_find(uint tag, int size); * * @tag: Tag to add (enum bloblist_tag_t) * @size: Size of the blob - * @align: Alignment of the blob (in bytes), 0 for default + * @align_log2: Alignment of the blob (in bytes log2), 0 for default * Return: pointer to the newly added block, or NULL if there is not enough * space for the blob */ -void *bloblist_add(uint tag, int size, int align); +void *bloblist_add(uint tag, int size, int align_log2); /** * bloblist_ensure_size() - Find or add a blob @@ -268,11 +270,11 @@ void *bloblist_add(uint tag, int size, int align); * @tag: Tag to add (enum bloblist_tag_t) * @size: Size of the blob * @blobp: Returns a pointer to blob on success - * @align: Alignment of the blob (in bytes), 0 for default + * @align_log2: Alignment of the blob (in bytes log2), 0 for default * Return: 0 if OK, -ENOSPC if it is missing and could not be added due to lack * of space, or -ESPIPE it exists but has the wrong size */ -int bloblist_ensure_size(uint tag, int size, int align, void **blobp); +int bloblist_ensure_size(uint tag, int size, int align_log2, void **blobp); /** * bloblist_ensure() - Find or add a blob diff --git a/test/bloblist.c b/test/bloblist.c index efa1e32afd..8b435e27ca 100644 --- a/test/bloblist.c +++ b/test/bloblist.c @@ -336,7 +336,7 @@ static int bloblist_test_align(struct unit_test_state *uts) /* Check larger alignment */ for (i = 0; i < 3; i++) { - int align = 32 << i; + int align = 5 - i; data = bloblist_add(3 + i, i * 4, align); ut_assertnonnull(data); @@ -351,7 +351,7 @@ static int bloblist_test_align(struct unit_test_state *uts) ut_assertok(bloblist_new(TEST_ADDR + BLOBLIST_ALIGN, TEST_BLOBLIST_SIZE, 0)); - data = bloblist_add(1, 5, BLOBLIST_ALIGN * 2); + data = bloblist_add(1, 5, BLOBLIST_ALIGN_LOG2 + 1); ut_assertnonnull(data); addr = map_to_sysmem(data); ut_asserteq(0, addr & (BLOBLIST_ALIGN * 2 - 1)); From patchwork Mon Dec 18 18:18:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raymond Mao X-Patchwork-Id: 1877537 X-Patchwork-Delegate: sjg@chromium.org 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=xEhexXOW; 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 4Sv7Qv4Hmpz2402 for ; Tue, 19 Dec 2023 05:20:07 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 30B3A874F3; Mon, 18 Dec 2023 19:19:52 +0100 (CET) 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="xEhexXOW"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 55781874D9; Mon, 18 Dec 2023 19:19:51 +0100 (CET) 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-qv1-xf2e.google.com (mail-qv1-xf2e.google.com [IPv6:2607:f8b0:4864:20::f2e]) (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 4A64F870D5 for ; Mon, 18 Dec 2023 19:19:49 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=raymond.mao@linaro.org Received: by mail-qv1-xf2e.google.com with SMTP id 6a1803df08f44-67ab16c38caso28662106d6.1 for ; Mon, 18 Dec 2023 10:19:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1702923588; x=1703528388; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=w0y7/FM8kxorN6EOJRQuzupPhG42wMtgQYbRCNlFYkw=; b=xEhexXOWgsesbeg47Nje4aK1mVScOT1Y1mT1tNfb7DND2Y4OwXtmzvC1RAoDDU+QUS 6l3RTMpyoDmbHLU/38p3ygzkohjpFZri5vh4hK8/fuxT04Mhyc09PCPvoLfrnMCjJ5bM 0xr45EXAujuW+cd5+wE2MT7rUzuGBEeaOUyEB/OD2qbdlcfvWhCAb4YDz1VgiMvmKSYr aprXLa4cFloS2frZJbBV9eiWyhBsnQWkeqibutiSpC9752ydlrpBjlYQ3pCuhlS7HVIq kug0KVjI3//9L0TnQdmjJ4YD1sUNei221Vqb4XAtMsR6HST9UPc4jnmd7tFF8KK0uSk2 wIRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702923588; x=1703528388; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=w0y7/FM8kxorN6EOJRQuzupPhG42wMtgQYbRCNlFYkw=; b=js8XrqIomoYtWeEIMrFl94pnaZLas/xdk1MEsMj0Bt08kwLLOjoygYol1938+MSQBR E+ftWuPwQlNblCLe95UlGpOocu45SKYsW2laURb05J/9uxmdbhJzcAKxSk0Pwqwv+SU6 m6Sela6CgyFGw37SEzeDaxPFEvUTS+XeZEN6QDuJpxclklESD5CrMW63+mfinve24tbd gXItKuer8/C4GwKzXo0TGGVVh2+f7ji2/WTSo5FwTgeod9UzcQNtOR2X9YEsqlz+oulc T/VdoHWN4AlrTytTCKD6+XSSOG+AivYhAck42Lb9QODumSs9Sb6VDwUQVllEDUTLrewn ipbA== X-Gm-Message-State: AOJu0YyaRDnCKew45NdnTeiRqAm/1WIAjfev/MRCpQZtB0KcbvXowcWG A0uFFQwLXuQ/m+xuq7rYzuio9K9taPuyGUZuNgk= X-Google-Smtp-Source: AGHT+IG+URN8zEuctdewL3sEWPhoKNbEfHt9yTfuvEpTQsy/+223n/F7ZqeuXzGMlQ0v4+Km1mQYzA== X-Received: by 2002:ad4:43ec:0:b0:67e:e816:8ef9 with SMTP id f12-20020ad443ec000000b0067ee8168ef9mr12099815qvu.85.1702923587937; Mon, 18 Dec 2023 10:19:47 -0800 (PST) Received: from ubuntu.localdomain (cpe688f2e182063-cm688f2e182060.sdns.net.rogers.com. [174.115.4.214]) by smtp.gmail.com with ESMTPSA id dy7-20020ad44e87000000b0067f213933bdsm3046136qvb.2.2023.12.18.10.19.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 10:19:47 -0800 (PST) From: Raymond Mao To: u-boot@lists.denx.de, ilias.apalodimas@linaro.org, sjg@chromium.org, jwerner@chromium.org Cc: Raymond Mao , Bin Meng , Nikhil M Jain Subject: [PATCH v3 03/14] bloblist: Change the magic value Date: Mon, 18 Dec 2023 10:18:48 -0800 Message-Id: <20231218181901.337515-4-raymond.mao@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231218181901.337515-1-raymond.mao@linaro.org> References: <20231218181901.337515-1-raymond.mao@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Simon Glass This uses a new value with spec v0.9 so change it. Signed-off-by: Simon Glass Co-developed-by: Raymond Mao Signed-off-by: Raymond Mao Reviewed-by: Ilias Apalodimas Reviewed-by: Simon Glass --- Changes in v2 - Update the bloblist magic to align to FW handoff spec v0.9. Changes in v3 - Update the bloblist magic to align to FW handoff spec up to commit 3592349. include/bloblist.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/bloblist.h b/include/bloblist.h index 5ad1337d1f..72c785411d 100644 --- a/include/bloblist.h +++ b/include/bloblist.h @@ -75,7 +75,7 @@ enum { BLOBLIST_VERSION = 0, - BLOBLIST_MAGIC = 0xb00757a3, + BLOBLIST_MAGIC = 0x4a0fb10b, BLOBLIST_ALIGN_LOG2 = 3, BLOBLIST_ALIGN = 1 << BLOBLIST_ALIGN_LOG2, From patchwork Mon Dec 18 18:18:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raymond Mao X-Patchwork-Id: 1877538 X-Patchwork-Delegate: sjg@chromium.org 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=unyCHCl6; 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) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Sv7R72Vmcz23yx for ; Tue, 19 Dec 2023 05:20:19 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9B7DA8743A; Mon, 18 Dec 2023 19:19:57 +0100 (CET) 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="unyCHCl6"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5A7C98749F; Mon, 18 Dec 2023 19:19:56 +0100 (CET) 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-oi1-x234.google.com (mail-oi1-x234.google.com [IPv6:2607:f8b0:4864:20::234]) (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 4AC9C870D5 for ; Mon, 18 Dec 2023 19:19:54 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=raymond.mao@linaro.org Received: by mail-oi1-x234.google.com with SMTP id 5614622812f47-3b9d8bfe845so2859884b6e.0 for ; Mon, 18 Dec 2023 10:19:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1702923593; x=1703528393; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qO5wMGyLmtP17mXl6SJk+QUJ9h/FXcc299FuxgH2TWU=; b=unyCHCl6b3zLKI9Kh2GrNH+Wwr/3PvM+33s5rfyu87T3rN/hpkyTGcmhnk4sCjfbzI LctA3CiV8T4nPFVG9hs/mRju0sKW4C7Lu4q80CJnKnrHR3nrHdAss87S2jRWEYwMI29U qbOIpFGcXWgR061qpbuXicNAtjgCpa2b/XbPoLpHRyOYpZMhkg6YuCc1J9GyGP8mL3T9 cDT0n069547BQwjqFFG2JVEeJsAB+Ji1WAmVOSQLzRXkHBS4Z3n0Ak3Q2jzXrmm6+42f qnNAkmjSjq72ll7O0bszW79W0nTLlXSYEQqivsSi55IxJitsQAjdxxP4ti5RS7qWeHty TiOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702923593; x=1703528393; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qO5wMGyLmtP17mXl6SJk+QUJ9h/FXcc299FuxgH2TWU=; b=asnG7eM69WSwrltLaLcx4N/6/zTvi/vKkOrbSU96QgoVW8kYJoUMNfiN4VsOb8xXb9 v/JqxkxxgKj2VS4w8TLChh1Cnon7MGmnaoyB3QkxrL2c4VSnMrofknbxBB11mk88U6Dj 81qgYU85NAIHryESf6+bl/JzCA46ysQfBdYPvASg5UqiZJiUqPQUnlpGQMiizKmYepRx T+mf75hPa3m9oKQCHcYcmgngd0RR3T096pngnlZEp5RkkmWLdpj0SFvkK64IRBLk3tQA j7vUsKUIJI/4kxviePXhLWG1bR3CciT8/vB1Ecv78uukjkN66TtTupn+TjUjU5K37DaY Odcg== X-Gm-Message-State: AOJu0YxSdJeee2wApSOkxFKKPn+BtyZGWEeDb8UfXiQW97Ek08KnJTo5 oETACf0Nm1HteqAb1JVh16WaDgSIw2KKir54dQE= X-Google-Smtp-Source: AGHT+IEZX+dn1+D7n2k8zkXvEYchVa4W1ravAe7v+I1ysSs3jN3u3IRgxZz2VbnWSPkW+sHI8ZP65w== X-Received: by 2002:a05:6808:1285:b0:3b8:b063:6b9d with SMTP id a5-20020a056808128500b003b8b0636b9dmr20685803oiw.76.1702923592802; Mon, 18 Dec 2023 10:19:52 -0800 (PST) Received: from ubuntu.localdomain (cpe688f2e182063-cm688f2e182060.sdns.net.rogers.com. [174.115.4.214]) by smtp.gmail.com with ESMTPSA id dy7-20020ad44e87000000b0067f213933bdsm3046136qvb.2.2023.12.18.10.19.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 10:19:52 -0800 (PST) From: Raymond Mao To: u-boot@lists.denx.de, ilias.apalodimas@linaro.org, sjg@chromium.org, jwerner@chromium.org Cc: Raymond Mao , Bin Meng , Nikhil M Jain Subject: [PATCH v3 04/14] bloblist: Set version to 1 Date: Mon, 18 Dec 2023 10:18:49 -0800 Message-Id: <20231218181901.337515-5-raymond.mao@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231218181901.337515-1-raymond.mao@linaro.org> References: <20231218181901.337515-1-raymond.mao@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Simon Glass The new bloblist for v0.9 has version 1 so update this value. Signed-off-by: Simon Glass Co-developed-by: Raymond Mao Signed-off-by: Raymond Mao Reviewed-by: Ilias Apalodimas Reviewed-by: Simon Glass --- include/bloblist.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/bloblist.h b/include/bloblist.h index 72c785411d..7eff709ec8 100644 --- a/include/bloblist.h +++ b/include/bloblist.h @@ -74,7 +74,7 @@ #include enum { - BLOBLIST_VERSION = 0, + BLOBLIST_VERSION = 1, BLOBLIST_MAGIC = 0x4a0fb10b, BLOBLIST_ALIGN_LOG2 = 3, From patchwork Mon Dec 18 18:18:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raymond Mao X-Patchwork-Id: 1877539 X-Patchwork-Delegate: sjg@chromium.org 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=HrS53/j5; 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 4Sv7RJ5WPNz23yx for ; Tue, 19 Dec 2023 05:20:28 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 26723874ED; Mon, 18 Dec 2023 19:20:01 +0100 (CET) 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="HrS53/j5"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4FE9F870D5; Mon, 18 Dec 2023 19:20:00 +0100 (CET) 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-qv1-xf29.google.com (mail-qv1-xf29.google.com [IPv6:2607:f8b0:4864:20::f29]) (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 02DA9874ED for ; Mon, 18 Dec 2023 19:19:58 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=raymond.mao@linaro.org Received: by mail-qv1-xf29.google.com with SMTP id 6a1803df08f44-67f0cfd3650so28108646d6.3 for ; Mon, 18 Dec 2023 10:19:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1702923596; x=1703528396; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CG1IKF8DB3ZJdWqawoRvyPo/GvjGRdLlQ/EAMpFzTk0=; b=HrS53/j5CQw3vjrnADpf1ckbxD/BGMUPHmPndcNsDu44UFo3KVH8vDTwPsTXVtl5tX pHmvHXqdOQ9vKShWu+RCXUFX9qXzylCAWRUKG4VlirH3zk8a1oSWHy3aH6WKp3Lrq7sd i1hIumq/K+Vg0OrvN8TQnjPCA8a244wgRcYkRAK3zyaLq6eLXvFJWkx5Szw7y9mf2p4X ti5VeaN8+3YGiWUJTBXxDsIm3Whl67fJx19cMLmpK/vPNFlKqBQdicAHuHBsY+41Jeoq j/RlCdJco1nxpn/GIvkPJZJDyTT4lEX1e6j/wCh60qJzBVqKsPDUMTM+t/F0Ulu3RGGM CiZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702923596; x=1703528396; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CG1IKF8DB3ZJdWqawoRvyPo/GvjGRdLlQ/EAMpFzTk0=; b=Nc27VoMnM8heAg+e/Dfa0AOaOEKSTCgYzRfPTswzowMy9R420YIyiGdd2ApT/vAg0v 38TxKvZEKidnYvriuHopKpdRz2QKx/xQ0Ij6SECrYjxn8ABANPp17oZoTOA2UVIms6el b6q3UDQxjw3dYXNRhL8biu7BYGcald3xlFhWsfWROdOd3TiVD9gQtKK0Pm4ZcFpmWky3 QYNb5OqLsbf7LJg91aougO8Y00WLicxfm1Zti7PedvvW5PDuhWaP1lKdkiMUafXzd/od 62Ft8v1WdksUn6JfX0yFbfBP4OKWCxo1yzgBNyHS3ldhsmHbqROfn2KhTHAPJNpPYFt0 TEgw== X-Gm-Message-State: AOJu0YzbcT0ZKiv6eYmfxcJ4ES6Z3iNsARdnKze01QOP6RuMuhA/MDCj syNNKPgh5r+NSyPiWYk/hvkwasH1MPqfZs87jHc= X-Google-Smtp-Source: AGHT+IHOD0mon3mF24B1TlfzRSPaUFnXpEuKwaLq6HeWsacznRKrU14aYQTye+T7g7RBrmSTk6u3Fg== X-Received: by 2002:a0c:d690:0:b0:67c:ae8:add0 with SMTP id k16-20020a0cd690000000b0067c0ae8add0mr17170120qvi.69.1702923596635; Mon, 18 Dec 2023 10:19:56 -0800 (PST) Received: from ubuntu.localdomain (cpe688f2e182063-cm688f2e182060.sdns.net.rogers.com. [174.115.4.214]) by smtp.gmail.com with ESMTPSA id dy7-20020ad44e87000000b0067f213933bdsm3046136qvb.2.2023.12.18.10.19.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 10:19:56 -0800 (PST) From: Raymond Mao To: u-boot@lists.denx.de, ilias.apalodimas@linaro.org, sjg@chromium.org, jwerner@chromium.org Cc: Raymond Mao , Bin Meng , Nikhil M Jain Subject: [PATCH v3 05/14] bloblist: Access record hdr_size and tag via a function Date: Mon, 18 Dec 2023 10:18:50 -0800 Message-Id: <20231218181901.337515-6-raymond.mao@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231218181901.337515-1-raymond.mao@linaro.org> References: <20231218181901.337515-1-raymond.mao@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Simon Glass Convert accesses to tag and hdr_size via function for grouping tag and hdr_size together later. Signed-off-by: Simon Glass Co-developed-by: Raymond Mao Signed-off-by: Raymond Mao --- Changes in v3 - Update commit message. common/bloblist.c | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/common/bloblist.c b/common/bloblist.c index 1e78a3d4b3..168993e0a7 100644 --- a/common/bloblist.c +++ b/common/bloblist.c @@ -84,13 +84,23 @@ static struct bloblist_rec *bloblist_first_blob(struct bloblist_hdr *hdr) return (struct bloblist_rec *)((void *)hdr + hdr->hdr_size); } +static inline uint rec_hdr_size(struct bloblist_rec *rec) +{ + return rec->hdr_size; +} + +static inline uint rec_tag(struct bloblist_rec *rec) +{ + return rec->tag; +} + static ulong bloblist_blob_end_ofs(struct bloblist_hdr *hdr, struct bloblist_rec *rec) { ulong offset; offset = (void *)rec - (void *)hdr; - offset += rec->hdr_size + ALIGN(rec->size, BLOBLIST_ALIGN); + offset += rec_hdr_size(rec) + ALIGN(rec->size, BLOBLIST_ALIGN); return offset; } @@ -119,7 +129,7 @@ static struct bloblist_rec *bloblist_findrec(uint tag) return NULL; foreach_rec(rec, hdr) { - if (rec->tag == tag) + if (rec_tag(rec) == tag) return rec; } @@ -158,7 +168,7 @@ static int bloblist_addrec(uint tag, int size, int align_log2, rec->spare = 0; /* Zero the record data */ - memset((void *)rec + rec->hdr_size, '\0', rec->size); + memset((void *)rec + rec_hdr_size(rec), '\0', rec->size); hdr->alloced = new_alloced; *recp = rec; @@ -199,7 +209,7 @@ void *bloblist_find(uint tag, int size) if (size && size != rec->size) return NULL; - return (void *)rec + rec->hdr_size; + return (void *)rec + rec_hdr_size(rec); } void *bloblist_add(uint tag, int size, int align_log2) @@ -209,7 +219,7 @@ void *bloblist_add(uint tag, int size, int align_log2) if (bloblist_addrec(tag, size, align_log2, &rec)) return NULL; - return (void *)rec + rec->hdr_size; + return (void *)rec + rec_hdr_size(rec); } int bloblist_ensure_size(uint tag, int size, int align_log2, void **blobp) @@ -220,7 +230,7 @@ int bloblist_ensure_size(uint tag, int size, int align_log2, void **blobp) ret = bloblist_ensurerec(tag, &rec, size, align_log2); if (ret) return ret; - *blobp = (void *)rec + rec->hdr_size; + *blobp = (void *)rec + rec_hdr_size(rec); return 0; } @@ -232,7 +242,7 @@ void *bloblist_ensure(uint tag, int size) if (bloblist_ensurerec(tag, &rec, size, 0)) return NULL; - return (void *)rec + rec->hdr_size; + return (void *)rec + rec_hdr_size(rec); } int bloblist_ensure_size_ret(uint tag, int *sizep, void **blobp) @@ -245,7 +255,7 @@ int bloblist_ensure_size_ret(uint tag, int *sizep, void **blobp) *sizep = rec->size; else if (ret) return ret; - *blobp = (void *)rec + rec->hdr_size; + *blobp = (void *)rec + rec_hdr_size(rec); return 0; } @@ -281,7 +291,7 @@ static int bloblist_resize_rec(struct bloblist_hdr *hdr, /* Zero the new part of the blob */ if (expand_by > 0) { - memset((void *)rec + rec->hdr_size + rec->size, '\0', + memset((void *)rec + rec_hdr_size(rec) + rec->size, '\0', new_size - rec->size); } @@ -315,8 +325,9 @@ static u32 bloblist_calc_chksum(struct bloblist_hdr *hdr) chksum = crc32(0, (unsigned char *)hdr, offsetof(struct bloblist_hdr, chksum)); foreach_rec(rec, hdr) { - chksum = crc32(chksum, (void *)rec, rec->hdr_size); - chksum = crc32(chksum, (void *)rec + rec->hdr_size, rec->size); + chksum = crc32(chksum, (void *)rec, rec_hdr_size(rec)); + chksum = crc32(chksum, (void *)rec + rec_hdr_size(rec), + rec->size); } return chksum; @@ -424,8 +435,9 @@ void bloblist_show_list(void) for (rec = bloblist_first_blob(hdr); rec; rec = bloblist_next_blob(hdr, rec)) { printf("%08lx %8x %4x %s\n", - (ulong)map_to_sysmem((void *)rec + rec->hdr_size), - rec->size, rec->tag, bloblist_tag_name(rec->tag)); + (ulong)map_to_sysmem((void *)rec + rec_hdr_size(rec)), + rec->size, rec_tag(rec), + bloblist_tag_name(rec_tag(rec))); } } From patchwork Mon Dec 18 18:18:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raymond Mao X-Patchwork-Id: 1877540 X-Patchwork-Delegate: sjg@chromium.org 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=Qci6w/9w; 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 4Sv7RX3Kplz23yx for ; Tue, 19 Dec 2023 05:20:40 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C983D8750C; Mon, 18 Dec 2023 19:20:08 +0100 (CET) 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="Qci6w/9w"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E8A848745E; Mon, 18 Dec 2023 19:20:06 +0100 (CET) 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-qv1-xf30.google.com (mail-qv1-xf30.google.com [IPv6:2607:f8b0:4864:20::f30]) (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 4399887509 for ; Mon, 18 Dec 2023 19:20:03 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=raymond.mao@linaro.org Received: by mail-qv1-xf30.google.com with SMTP id 6a1803df08f44-67aa9a99915so30343856d6.3 for ; Mon, 18 Dec 2023 10:20:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1702923601; x=1703528401; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2WZKJiUZpT3hVKZ6Ft6JJtw1JDFeG+xXrcJjolkRR/s=; b=Qci6w/9wEx1ZdD3jwC6E7Cc9xQbfiG3XRZrOjBLvcanuo76c9RY7nc2uPBcY1OAWAw nifNQ2MNvPucVFDc1wgtfN/xK0cIDqfKK2pH0DLN4wFCcae4y2/HdIFayIYOs7DjxRoQ jWw+OIv5mp8T6LedWw4sqR22QrndFqPATHgNx+KByaCgvLEe/hd6dYFz4BfXxo83ttMT jPcGW6Ay6gDrglGsYvWLMnFfgF3UNHJNDe3ysqtnFHUJOENMnHKBa+G7fUQQqx+G7KuJ D1MKfoqIIrofqE2T72ZoFjlg/rbtiPA7L4xRW1ogN3dqthGiNMZ/JnHkmtwHhKOgvR/5 rSVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702923601; x=1703528401; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2WZKJiUZpT3hVKZ6Ft6JJtw1JDFeG+xXrcJjolkRR/s=; b=vp2/NAe5p8+NhWJIHm8ZaIDXSkDBkacdHqPgfzaLlzsTl55lBMalfsd4f6N+K0Pc4l 1PvgjGqO2foJl1Cm8pJ8L1wBVreRqC0EtQFRqq457VAEQAn/Kp4UoZiCgUh1Tn+6bcSQ Dvuj38oPimdzZ9HuABl1r9Mqvi7BNXzsPNOVKlwAcK6WxuI0GtDqjymPAHZlm2c5sGEs cLSy9Xlp+tdiBq5J/33sgOXtk295EoA4WM7BsadPilD5ahDKxeNQl3ZyXCWHi0kUQeA5 yRoQs7CiZvwOEshcLJNi5SVeKulmx42pTu1UjkQYXdfjrBni8d/6V/CE3tojgLQSSU6h 8kqg== X-Gm-Message-State: AOJu0YwxiU5tg5w5cT+1VUJ53ZbE4/jgPHFSO4VBipvxaCl6e+kJOqu3 Rc33z2XnBYkg/uto48mCeykdTLPTKGzdoBrAOfs= X-Google-Smtp-Source: AGHT+IGN1ABVC5svvoK4hJCXSZJSRPYWCJPCm9II42XlHumHPOcBXReElSUCVEFlTW/ccwGCXvEDag== X-Received: by 2002:a05:6214:2a8b:b0:67f:49c:4b6c with SMTP id jr11-20020a0562142a8b00b0067f049c4b6cmr11331225qvb.118.1702923601401; Mon, 18 Dec 2023 10:20:01 -0800 (PST) Received: from ubuntu.localdomain (cpe688f2e182063-cm688f2e182060.sdns.net.rogers.com. [174.115.4.214]) by smtp.gmail.com with ESMTPSA id dy7-20020ad44e87000000b0067f213933bdsm3046136qvb.2.2023.12.18.10.20.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 10:20:01 -0800 (PST) From: Raymond Mao To: u-boot@lists.denx.de, ilias.apalodimas@linaro.org, sjg@chromium.org, jwerner@chromium.org Cc: Raymond Mao , Bin Meng , Nikhil M Jain Subject: [PATCH v3 06/14] bloblist: Drop spare value from bloblist record Date: Mon, 18 Dec 2023 10:18:51 -0800 Message-Id: <20231218181901.337515-7-raymond.mao@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231218181901.337515-1-raymond.mao@linaro.org> References: <20231218181901.337515-1-raymond.mao@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Simon Glass Drop spare value from bloblist record header. For now it is still present in the header, with an underscore, so that tests continue to pass. Signed-off-by: Simon Glass Co-developed-by: Raymond Mao Signed-off-by: Raymond Mao --- Changes in v3 - Keep the spare value in the bloblist header to align to FW handoff spec up to commit 3592349. common/bloblist.c | 1 - include/bloblist.h | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/common/bloblist.c b/common/bloblist.c index 168993e0a7..88e2a0f5c0 100644 --- a/common/bloblist.c +++ b/common/bloblist.c @@ -165,7 +165,6 @@ static int bloblist_addrec(uint tag, int size, int align_log2, rec->tag = tag; rec->hdr_size = data_start - hdr->alloced; rec->size = size; - rec->spare = 0; /* Zero the record data */ memset((void *)rec + rec_hdr_size(rec), '\0', rec->size); diff --git a/include/bloblist.h b/include/bloblist.h index 7eff709ec8..68f97395b7 100644 --- a/include/bloblist.h +++ b/include/bloblist.h @@ -205,13 +205,12 @@ struct bloblist_hdr { * record's data starts at this offset from the start of the record * @size: Size of record in bytes, excluding the header size. This does not * need to be aligned (e.g. 3 is OK). - * @spare: Spare space for other things */ struct bloblist_rec { u32 tag; u32 hdr_size; u32 size; - u32 spare; + u32 _spare; }; /** From patchwork Mon Dec 18 18:18:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raymond Mao X-Patchwork-Id: 1877541 X-Patchwork-Delegate: sjg@chromium.org 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=eOH9ZyWw; 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 4Sv7Rr62Jpz23yx for ; Tue, 19 Dec 2023 05:20:56 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6462387575; Mon, 18 Dec 2023 19:20:10 +0100 (CET) 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="eOH9ZyWw"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 721EE8755D; Mon, 18 Dec 2023 19:20:09 +0100 (CET) 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-qk1-x733.google.com (mail-qk1-x733.google.com [IPv6:2607:f8b0:4864:20::733]) (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 33E0F870D5 for ; Mon, 18 Dec 2023 19:20:07 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=raymond.mao@linaro.org Received: by mail-qk1-x733.google.com with SMTP id af79cd13be357-77fbc9020deso245261685a.3 for ; Mon, 18 Dec 2023 10:20:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1702923606; x=1703528406; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dsOOx1WArnF4SRibehvqwTRxmHtCiqNXEjhUB3FZAJk=; b=eOH9ZyWwBebQ7JsvddTD/Bt4zfdcSjb6ffutBFIlZdxXOfvrE/M39mapByBbwLRBZP HECCsDRyqieE0k57NDpcnxx+/8hfYW43pukDAf2WkBlTe7OyiZEtE3u7gdDSg+JO6F+B yBUgNroes6M6GN6arlfmifUA2jgjmuvWPdK2MYKyYgWS2Uu6oWXyPaTg08F45Cag9aQk dmDCikYiH4GoTw+SGPSxGBuJO+s4J9+aCLnxlFutqoH0Ru1Jig5Doh/AB/YvyJktgzwB nd6gYNO7zWg+/HHLrGD6pJf8rTFCkU2etNgEXQqqREDxSZtAwjwa/U63w4Y593EkJMQu G4YQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702923606; x=1703528406; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dsOOx1WArnF4SRibehvqwTRxmHtCiqNXEjhUB3FZAJk=; b=knFZLE3ROp4R6Xdy2/HqbqXgRD/lJqSxrjp3cPUx5weTonxuG7eqGwm55ODeVYv8QM +u2NANEzuXAGXnNPFzqloJnOIZ0BJA4MV9jCWjVbrEQdDwNA232+K7dUI3guVlQq7zOj EqbD/BMa4bLs/Exe/yJ3AZTB/g11bn1E3VIo1WpZ/Iu79wYTsIFN5PU0FTj/FDxf/pqG aftghP/edcPB6Y/PiTe0qOQpUykOvvjQ2f4mIdPD+/ywst3c58y23KgPCTQ59j9Bowiu Mhk3KxuGOz5Gc6aNrN8er3PiQQM2YYWwmBCTWoTouFJx68CbAOznHp1Qp8psk2JEdE1y vswQ== X-Gm-Message-State: AOJu0YwxXuvwqH9R8/QFsMTM8XZooJVkd9dFFiWknkWDFdKF3pxWSB3A ZX4n5O8dpA1TzSfB61Ije2+5G/NTPJFCNtB0+Nk= X-Google-Smtp-Source: AGHT+IHfSvQ60uYcbPkR7pDYQGNh6FKtjDuBQdZyBuRGm8JnoYJBHjRJmnnehSPh4W1T5APQD6fRtw== X-Received: by 2002:ad4:4708:0:b0:67a:ba4c:6f69 with SMTP id qb8-20020ad44708000000b0067aba4c6f69mr18556892qvb.22.1702923605758; Mon, 18 Dec 2023 10:20:05 -0800 (PST) Received: from ubuntu.localdomain (cpe688f2e182063-cm688f2e182060.sdns.net.rogers.com. [174.115.4.214]) by smtp.gmail.com with ESMTPSA id dy7-20020ad44e87000000b0067f213933bdsm3046136qvb.2.2023.12.18.10.20.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 10:20:05 -0800 (PST) From: Raymond Mao To: u-boot@lists.denx.de, ilias.apalodimas@linaro.org, sjg@chromium.org, jwerner@chromium.org Cc: Raymond Mao , Bin Meng , Nikhil M Jain Subject: [PATCH v3 07/14] bloblist: Change the checksum algorithm Date: Mon, 18 Dec 2023 10:18:52 -0800 Message-Id: <20231218181901.337515-8-raymond.mao@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231218181901.337515-1-raymond.mao@linaro.org> References: <20231218181901.337515-1-raymond.mao@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Simon Glass Use a sinple 8-bit checksum for bloblist, as specified by the spec version 0.9 Signed-off-by: Simon Glass Co-developed-by: Raymond Mao Signed-off-by: Raymond Mao Reviewed-by: Simon Glass --- common/bloblist.c | 14 ++++++++------ include/bloblist.h | 5 ++--- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/common/bloblist.c b/common/bloblist.c index 88e2a0f5c0..32692d8319 100644 --- a/common/bloblist.c +++ b/common/bloblist.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -319,14 +320,15 @@ int bloblist_resize(uint tag, int new_size) static u32 bloblist_calc_chksum(struct bloblist_hdr *hdr) { struct bloblist_rec *rec; - u32 chksum; + u8 chksum; - chksum = crc32(0, (unsigned char *)hdr, - offsetof(struct bloblist_hdr, chksum)); + chksum = table_compute_checksum(hdr, hdr->hdr_size); + chksum += hdr->chksum; foreach_rec(rec, hdr) { - chksum = crc32(chksum, (void *)rec, rec_hdr_size(rec)); - chksum = crc32(chksum, (void *)rec + rec_hdr_size(rec), - rec->size); + chksum -= table_compute_checksum((void *)rec, + rec_hdr_size(rec)); + chksum -= table_compute_checksum((void *)rec + + rec_hdr_size(rec), rec->size); } return chksum; diff --git a/include/bloblist.h b/include/bloblist.h index 68f97395b7..d2dcad69a1 100644 --- a/include/bloblist.h +++ b/include/bloblist.h @@ -174,11 +174,10 @@ enum bloblist_tag_t { * sizeof(bloblist_hdr) since we need at least that much space to store a * valid bloblist * @spare: Spare space (for future use) - * @chksum: CRC32 for the entire bloblist allocated area. Since any of the + * @chksum: checksum for the entire bloblist allocated area. Since any of the * blobs can be altered after being created, this checksum is only valid * when the bloblist is finalised before jumping to the next stage of boot. - * Note that chksum is last to make it easier to exclude it from the - * checksum calculation. + * This is the value needed to make all checksummed bytes sum to 0 */ struct bloblist_hdr { u32 magic; From patchwork Mon Dec 18 18:18:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raymond Mao X-Patchwork-Id: 1877542 X-Patchwork-Delegate: sjg@chromium.org 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=cSsgR9JC; 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 4Sv7S409sfz23yx for ; Tue, 19 Dec 2023 05:21:08 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4ABDE8753C; Mon, 18 Dec 2023 19:20:14 +0100 (CET) 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="cSsgR9JC"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 329568752B; Mon, 18 Dec 2023 19:20:13 +0100 (CET) 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-qt1-x832.google.com (mail-qt1-x832.google.com [IPv6:2607:f8b0:4864:20::832]) (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 0FCF48753C for ; Mon, 18 Dec 2023 19:20:11 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=raymond.mao@linaro.org Received: by mail-qt1-x832.google.com with SMTP id d75a77b69052e-42594f0ca09so22547301cf.0 for ; Mon, 18 Dec 2023 10:20:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1702923609; x=1703528409; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HcGiS27HGHxffo+0P3QXhe9RPcCqwVdnMMivCHX/FoA=; b=cSsgR9JCFqPJ5iJk+nLgfIEnmkBOsKQf9ofKxlCkbqlOpHc5AbcKWwXQ+eQv/okzu3 igA/FzGNuHjCMRO8hGhvSuC101uyr39pa9WtRpx4pEQ0AYLF7Tk6a/TxORmE1aUeTc1q 6rnggqAlC0cfvg7EZjcDS+E6L8Q8TEEYRs+USQNy1GZhpiUajKk4pjPDOCyUvrC8jyvY IFfaojXxpMFpGG31Ct/GgvH0E5o31r/rPqp/5g5C9e1+DMzNc5GmPS3qvCdxiOxiakKz 3zHq/d8qj0u+J0T84usHR4MdiwYIGnX7snjVk7XD1BoVopNxkcnhM+Su137NHYJ6iYYW riWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702923609; x=1703528409; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HcGiS27HGHxffo+0P3QXhe9RPcCqwVdnMMivCHX/FoA=; b=OMGHXU8mCOFPfzmJgMh1ogq+G+JS4irVY5nvv1XZS921yDfVUTWmWcsLHc8ZLPtR8i bfAVFPotkMPvhOjYgCbyzSZpgl4zpwJmCe1OspKIPxCCQDETAW7P3BlD4zDoOmjAQSqN TV4mhAbpYzrcQ0UH1z40JsTOPqCtatWxJdTTB6EECsR7ASOt+VfXrwBGMaoTPwTopJ1X wTogaQm6xEh35tYq5YqaG/vVF5s3TusszpAUdELUaTeB9zrnaIIoLvlamJX7y6CgdYPO 54z8jMdQwBtbi5qJhWDsAWLABYaqv9IuSaXQKLSMKQTLE/2d9GJIql/glyKhY1H2oo36 DBww== X-Gm-Message-State: AOJu0Yw60riE2+9zK8RfuxtM/Jc50x2arSzk1ZGpRrbLVKSF2RFhINB9 2tTc4j46NIHZPBnfP118ipmwFqsAEciYG1KKBEk= X-Google-Smtp-Source: AGHT+IGYOzRXJnixcmsx1Q+EMkDKxvpp3/xz30mEZQ7EQB3Du6gaQ7Eh8lAoaNsCDtRahL1nbdt89A== X-Received: by 2002:a0c:ff46:0:b0:67e:f411:2254 with SMTP id y6-20020a0cff46000000b0067ef4112254mr7730209qvt.6.1702923609641; Mon, 18 Dec 2023 10:20:09 -0800 (PST) Received: from ubuntu.localdomain (cpe688f2e182063-cm688f2e182060.sdns.net.rogers.com. [174.115.4.214]) by smtp.gmail.com with ESMTPSA id dy7-20020ad44e87000000b0067f213933bdsm3046136qvb.2.2023.12.18.10.20.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 10:20:09 -0800 (PST) From: Raymond Mao To: u-boot@lists.denx.de, ilias.apalodimas@linaro.org, sjg@chromium.org, jwerner@chromium.org Cc: Raymond Mao , Bin Meng , Nikhil M Jain Subject: [PATCH v3 08/14] bloblist: Checksum the entire bloblist Date: Mon, 18 Dec 2023 10:18:53 -0800 Message-Id: <20231218181901.337515-9-raymond.mao@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231218181901.337515-1-raymond.mao@linaro.org> References: <20231218181901.337515-1-raymond.mao@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Simon Glass Spec v0.9 specifies that the entire bloblist area is checksummed, including unused portions. Update the code to follow this. Signed-off-by: Simon Glass Co-developed-by: Raymond Mao Signed-off-by: Raymond Mao Reviewed-by: Simon Glass --- common/bloblist.c | 9 +-------- test/bloblist.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/common/bloblist.c b/common/bloblist.c index 32692d8319..705d9c6ae9 100644 --- a/common/bloblist.c +++ b/common/bloblist.c @@ -319,17 +319,10 @@ int bloblist_resize(uint tag, int new_size) static u32 bloblist_calc_chksum(struct bloblist_hdr *hdr) { - struct bloblist_rec *rec; u8 chksum; - chksum = table_compute_checksum(hdr, hdr->hdr_size); + chksum = table_compute_checksum(hdr, hdr->alloced); chksum += hdr->chksum; - foreach_rec(rec, hdr) { - chksum -= table_compute_checksum((void *)rec, - rec_hdr_size(rec)); - chksum -= table_compute_checksum((void *)rec + - rec_hdr_size(rec), rec->size); - } return chksum; } diff --git a/test/bloblist.c b/test/bloblist.c index 8b435e27ca..49ac4b92ae 100644 --- a/test/bloblist.c +++ b/test/bloblist.c @@ -237,12 +237,18 @@ static int bloblist_test_checksum(struct unit_test_state *uts) *data2 -= 1; /* - * Changing data outside the range of valid data should not affect - * the checksum. + * Changing data outside the range of valid data should affect the + * checksum. */ ut_assertok(bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); data[TEST_SIZE]++; + ut_asserteq(-EIO, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); + data[TEST_SIZE]--; + ut_assertok(bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); + data2[TEST_SIZE2]++; + ut_asserteq(-EIO, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); + data[TEST_SIZE]--; ut_assertok(bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); return 0; From patchwork Mon Dec 18 18:18:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raymond Mao X-Patchwork-Id: 1877543 X-Patchwork-Delegate: sjg@chromium.org 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=sLbTroEK; 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 4Sv7SF4BnDz23yx for ; Tue, 19 Dec 2023 05:21:17 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E1F8A875B9; Mon, 18 Dec 2023 19:20:19 +0100 (CET) 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="sLbTroEK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5318B87578; Mon, 18 Dec 2023 19:20:18 +0100 (CET) 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-oo1-xc2e.google.com (mail-oo1-xc2e.google.com [IPv6:2607:f8b0:4864:20::c2e]) (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 2F34A87561 for ; Mon, 18 Dec 2023 19:20:16 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=raymond.mao@linaro.org Received: by mail-oo1-xc2e.google.com with SMTP id 006d021491bc7-590711b416fso2344380eaf.2 for ; Mon, 18 Dec 2023 10:20:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1702923614; x=1703528414; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Xgb2cKdn7cOAUVgfIbnLpCQYwhDWdtB6PDT7Tm5ir7U=; b=sLbTroEK+IOI94e/B0z6SopuGXboySe8CqIEh4zAyqZyi1wnMjDS8UCo1bcpPjvwgz HmT9goOUtpzROTQWe0I0c+F5EKvJgocWxiSSZDU5gKgHKYbKjnT0azCeiwFwQtBeeaVv 5DIiIYStUM4nGpikscABeIvL0OIiqhGvKZ4MGFV2IlxePm9lMOXUd0AUUgtEGrbe0eg6 5EJWnjEaO81jo03Fnci5MyWrDYAvd7l5q97VHpdLEDwtFhHarTg4hrVInITX+IctiByU 4EYSkLypY7g/+AI9Fhvv3ucLGkNZCGZSLPuEBOtaiR0LygOfbU7GUQK+KQj9Ch5lzEQS Vgyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702923614; x=1703528414; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Xgb2cKdn7cOAUVgfIbnLpCQYwhDWdtB6PDT7Tm5ir7U=; b=aH1JcS/QlbeGJvpR6j0/5g2KWI69J211eK/KCp/1C+hoZrS6H/t01pShpKFWTcHDbu 9ONHnYpBAhac6MZY1RARMRwxfM1MQrXMMimvDPlHNLnreY2GdBzC1zk95gMl9F1Rue4t 5FRQVspAYKZS+yvBWZ/fQZG9twTtVY9B4Qd/U4GZvGcl8IF+10jZGNG0vkPIrn9zIvzA dMmcyirMup96xUKIU/z58HpkfayTYkzImDa/zw26uNlZaZ8ANZCe8C2huTbHUcqZmCXh /p2HPKckQtUgU581aKVI6LBIIfT3IG8kgOWNSpT76+YtBrgmk7JMViSkX5c/hsRo0VUo UwjQ== X-Gm-Message-State: AOJu0YxVqHm73O04b+1Kwm7oOdMYBJBFl/F06EBCCH8l+zizr33lLeKW CAIhUL9OADSY5G7Piyrm3DggC1yoCji1EHVQMpQ= X-Google-Smtp-Source: AGHT+IGu88zN64Rtk5DtWvQ7O3xwujxsNLOrfNWRcI+NYt/Vc9YcI0Rj39OWyZvm02YraQhXZ1TTqQ== X-Received: by 2002:a05:6358:52c6:b0:172:8976:49be with SMTP id z6-20020a05635852c600b00172897649bemr13482141rwz.34.1702923614597; Mon, 18 Dec 2023 10:20:14 -0800 (PST) Received: from ubuntu.localdomain (cpe688f2e182063-cm688f2e182060.sdns.net.rogers.com. [174.115.4.214]) by smtp.gmail.com with ESMTPSA id dy7-20020ad44e87000000b0067f213933bdsm3046136qvb.2.2023.12.18.10.20.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 10:20:14 -0800 (PST) From: Raymond Mao To: u-boot@lists.denx.de, ilias.apalodimas@linaro.org, sjg@chromium.org, jwerner@chromium.org Cc: Raymond Mao , Bin Meng , Nikhil M Jain Subject: [PATCH v3 09/14] bloblist: Handle alignment with a void entry Date: Mon, 18 Dec 2023 10:18:54 -0800 Message-Id: <20231218181901.337515-10-raymond.mao@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231218181901.337515-1-raymond.mao@linaro.org> References: <20231218181901.337515-1-raymond.mao@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Simon Glass Rather than setting the alignment using the header size, add an entirely new entry to cover the gap left by the alignment. Signed-off-by: Simon Glass Co-developed-by: Raymond Mao Signed-off-by: Raymond Mao Reviewed-by: Simon Glass --- common/bloblist.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/common/bloblist.c b/common/bloblist.c index 705d9c6ae9..73dbbc01c0 100644 --- a/common/bloblist.c +++ b/common/bloblist.c @@ -142,7 +142,7 @@ static int bloblist_addrec(uint tag, int size, int align_log2, { struct bloblist_hdr *hdr = gd->bloblist; struct bloblist_rec *rec; - int data_start, new_alloced; + int data_start, aligned_start, new_alloced; if (!align_log2) align_log2 = BLOBLIST_ALIGN_LOG2; @@ -151,10 +151,25 @@ static int bloblist_addrec(uint tag, int size, int align_log2, data_start = map_to_sysmem(hdr) + hdr->alloced + sizeof(*rec); /* Align the address and then calculate the offset from ->alloced */ - data_start = ALIGN(data_start, 1U << align_log2) - map_to_sysmem(hdr); + aligned_start = ALIGN(data_start, 1U << align_log2) - data_start; + + /* If we need to create a dummy record, create it */ + if (aligned_start) { + int void_size = aligned_start - sizeof(*rec); + struct bloblist_rec *vrec; + int ret; + + ret = bloblist_addrec(BLOBLISTT_VOID, void_size, 0, &vrec); + if (ret) + return log_msg_ret("void", ret); + + /* start the record after that */ + data_start = map_to_sysmem(hdr) + hdr->alloced + sizeof(*vrec); + } /* Calculate the new allocated total */ - new_alloced = data_start + ALIGN(size, 1U << align_log2); + new_alloced = data_start - map_to_sysmem(hdr) + + ALIGN(size, 1U << align_log2); if (new_alloced > hdr->size) { log_err("Failed to allocate %x bytes size=%x, need size=%x\n", @@ -164,7 +179,7 @@ static int bloblist_addrec(uint tag, int size, int align_log2, rec = (void *)hdr + hdr->alloced; rec->tag = tag; - rec->hdr_size = data_start - hdr->alloced; + rec->hdr_size = sizeof(struct bloblist_rec); rec->size = size; /* Zero the record data */ From patchwork Mon Dec 18 18:18:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raymond Mao X-Patchwork-Id: 1877544 X-Patchwork-Delegate: sjg@chromium.org 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=jRGKlEF1; 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 4Sv7SR3yY0z23yx for ; Tue, 19 Dec 2023 05:21:27 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 69E1B875DB; Mon, 18 Dec 2023 19:20:23 +0100 (CET) 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="jRGKlEF1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8A32C875B6; Mon, 18 Dec 2023 19:20:22 +0100 (CET) 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-oo1-xc2d.google.com (mail-oo1-xc2d.google.com [IPv6:2607:f8b0:4864:20::c2d]) (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 362FB875DB for ; Mon, 18 Dec 2023 19:20:20 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=raymond.mao@linaro.org Received: by mail-oo1-xc2d.google.com with SMTP id 006d021491bc7-58d18c224c7so2190078eaf.2 for ; Mon, 18 Dec 2023 10:20:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1702923618; x=1703528418; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ut+hm1bVdgvxqya8O39MvlO1f9eP+oi2c0QE1kYawqg=; b=jRGKlEF1+lV06GgeVf+m0V6tAZL9rIt3kEj1bpxf27i/Pl9IlfdjsHsqrh2ll7fskI 0OwOTm+n2kdJ698UAU0PgQMSGUip7ntMyelV7Oq3lzHIDqq+cr9cKdIEHY0ltmc+zfzf aZWoFKkDi9Y04ASRIEra5kwzSuzaHJvk4wdiS75nZ6kDgfwwyQJo+ZibavTGKGTDVYGc ZO5v2k/GydH8xaqhxTUmBWjpLakq7jUqulrAj/w4zO81zlLFLs1wf3E6AcYWu4XCkUHY Ij1Nc8p+2RFCiWZv2gtbAZUsCgOGG727nShXsomioGDRFhQdFVTQd4CML1Z67ReG3fZp njjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702923618; x=1703528418; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ut+hm1bVdgvxqya8O39MvlO1f9eP+oi2c0QE1kYawqg=; b=UPUYMC7TFvp/cbNm6r3EDGRjMssK2L6Dpo56z968sth2Aj/k7T/XrU5WzFLro+DTJR 9cvS9W6Ci+xWn5E9MNRspuxM0xEwSFf2ZPTS4wU8+ipamJQQHcXA3gFAccxmWgrM8RDd tWyHf57NFc9NY1/JNMNXb0saSY14kxDK1fAa85NneQn67an4r1rFidSVgUe16qmaq+2I QMR3ZK9kCtWAiKIfFOpP55koA710+k2ObEwiRs7Ffr++LI+nS+7pzwUsz/cd1MGNJho9 sr5038q4aAa/H7k3HVZj7v5Sz+YCBkReLzhI7XhFuggdmHI+PqdJ8EOROKVFSfRxLT1F 8+Vg== X-Gm-Message-State: AOJu0YwehjF11H9FC2p2iLwPA8g1Rz+57dNjUd69YPPXBAnxaLqIZcE9 5bUtqonq3j0nHiATiC/UVpjjD2UCOTjMtC0rjjQ= X-Google-Smtp-Source: AGHT+IFxS41CxSNvv41BD/hCmGTFjQWgOQtb0RWSbOTV4FzxYjSdwBYOHd/8k22l4UFrUe/g++Q5RA== X-Received: by 2002:a05:6358:60cc:b0:172:c989:ed12 with SMTP id i12-20020a05635860cc00b00172c989ed12mr1590217rwi.37.1702923618573; Mon, 18 Dec 2023 10:20:18 -0800 (PST) Received: from ubuntu.localdomain (cpe688f2e182063-cm688f2e182060.sdns.net.rogers.com. [174.115.4.214]) by smtp.gmail.com with ESMTPSA id dy7-20020ad44e87000000b0067f213933bdsm3046136qvb.2.2023.12.18.10.20.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 10:20:18 -0800 (PST) From: Raymond Mao To: u-boot@lists.denx.de, ilias.apalodimas@linaro.org, sjg@chromium.org, jwerner@chromium.org Cc: Raymond Mao , Bin Meng , Nikhil M Jain Subject: [PATCH v3 10/14] bloblist: Reduce blob-header size Date: Mon, 18 Dec 2023 10:18:55 -0800 Message-Id: <20231218181901.337515-11-raymond.mao@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231218181901.337515-1-raymond.mao@linaro.org> References: <20231218181901.337515-1-raymond.mao@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Simon Glass The v0.9 spec provides for an 8-byte header for each blob, with fewer fields. The blob data start address should be aligned to the alignment specified by the bloblist header. Update the implementation to match this. Signed-off-by: Simon Glass Co-developed-by: Raymond Mao Signed-off-by: Raymond Mao --- Changes in v2 - Update the blob start address to align to the alignment required by the bloblist header. - Define the macros of bloblist header size and bloblist record header size as the size of their structures. Changes in v3 - Update the calculation of the bloblist record offset to make sure that each bloblist record data section start address fulfills the alignment requirement. - Update commit message. common/bloblist.c | 23 +++++++++++++++-------- include/bloblist.h | 33 ++++++++++++++++++++++----------- test/bloblist.c | 16 ++++++++-------- 3 files changed, 45 insertions(+), 27 deletions(-) diff --git a/common/bloblist.c b/common/bloblist.c index 73dbbc01c0..1c97d61e4a 100644 --- a/common/bloblist.c +++ b/common/bloblist.c @@ -87,12 +87,14 @@ static struct bloblist_rec *bloblist_first_blob(struct bloblist_hdr *hdr) static inline uint rec_hdr_size(struct bloblist_rec *rec) { - return rec->hdr_size; + return (rec->tag_and_hdr_size & BLOBLISTR_HDR_SIZE_MASK) >> + BLOBLISTR_HDR_SIZE_SHIFT; } static inline uint rec_tag(struct bloblist_rec *rec) { - return rec->tag; + return (rec->tag_and_hdr_size & BLOBLISTR_TAG_MASK) >> + BLOBLISTR_TAG_SHIFT; } static ulong bloblist_blob_end_ofs(struct bloblist_hdr *hdr, @@ -101,7 +103,13 @@ static ulong bloblist_blob_end_ofs(struct bloblist_hdr *hdr, ulong offset; offset = (void *)rec - (void *)hdr; - offset += rec_hdr_size(rec) + ALIGN(rec->size, BLOBLIST_ALIGN); + /* + * The data section of next TE should start from an address aligned + * to 1 << hdr->align_log2. + */ + offset += rec_hdr_size(rec) + rec->size; + offset = round_up(offset + rec_hdr_size(rec), 1 << hdr->align_log2); + offset -= rec_hdr_size(rec); return offset; } @@ -145,7 +153,7 @@ static int bloblist_addrec(uint tag, int size, int align_log2, int data_start, aligned_start, new_alloced; if (!align_log2) - align_log2 = BLOBLIST_ALIGN_LOG2; + align_log2 = BLOBLIST_BLOB_ALIGN_LOG2; /* Figure out where the new data will start */ data_start = map_to_sysmem(hdr) + hdr->alloced + sizeof(*rec); @@ -178,8 +186,7 @@ static int bloblist_addrec(uint tag, int size, int align_log2, } rec = (void *)hdr + hdr->alloced; - rec->tag = tag; - rec->hdr_size = sizeof(struct bloblist_rec); + rec->tag_and_hdr_size = tag | sizeof(*rec) << BLOBLISTR_HDR_SIZE_SHIFT; rec->size = size; /* Zero the record data */ @@ -283,8 +290,8 @@ static int bloblist_resize_rec(struct bloblist_hdr *hdr, int new_alloced; /* New value for @hdr->alloced */ ulong next_ofs; /* Offset of the record after @rec */ - expand_by = ALIGN(new_size - rec->size, BLOBLIST_ALIGN); - new_alloced = ALIGN(hdr->alloced + expand_by, BLOBLIST_ALIGN); + expand_by = ALIGN(new_size - rec->size, BLOBLIST_BLOB_ALIGN); + new_alloced = ALIGN(hdr->alloced + expand_by, BLOBLIST_BLOB_ALIGN); if (new_size < 0) { log_debug("Attempt to shrink blob size below 0 (%x)\n", new_size); diff --git a/include/bloblist.h b/include/bloblist.h index d2dcad69a1..7024d7bf9e 100644 --- a/include/bloblist.h +++ b/include/bloblist.h @@ -24,11 +24,11 @@ * which would add to code size. For Thumb-2 the code size needed in SPL is * approximately 940 bytes (e.g. for chromebook_bob). * - * 5. Bloblist uses 16-byte alignment internally and is designed to start on a - * 16-byte boundary. Its headers are multiples of 16 bytes. This makes it easier - * to deal with data structures which need this level of alignment, such as ACPI - * tables. For use in SPL and TPL the alignment can be relaxed, since it can be - * relocated to an aligned address in U-Boot proper. + * 5. Bloblist uses 8-byte alignment internally and is designed to start on a + * 8-byte boundary. Its headers are 8 bytes long. It is possible to achieve + * larger alignment (e.g. 16 bytes) by adding a dummy header, For use in SPL and + * TPL the alignment can be relaxed, since it can be relocated to an aligned + * address in U-Boot proper. * * 6. Bloblist is designed to be passed to Linux as reserved memory. While linux * doesn't understand the bloblist header, it can be passed the indivdual blobs. @@ -77,6 +77,9 @@ enum { BLOBLIST_VERSION = 1, BLOBLIST_MAGIC = 0x4a0fb10b, + BLOBLIST_BLOB_ALIGN_LOG2 = 3, + BLOBLIST_BLOB_ALIGN = 1 << BLOBLIST_BLOB_ALIGN_LOG2, + BLOBLIST_ALIGN_LOG2 = 3, BLOBLIST_ALIGN = 1 << BLOBLIST_ALIGN_LOG2, }; @@ -199,17 +202,25 @@ struct bloblist_hdr { * * NOTE: Only exported for testing purposes. Do not use this struct. * - * @tag: Tag indicating what the record contains - * @hdr_size: Size of this header, normally sizeof(struct bloblist_rec). The - * record's data starts at this offset from the start of the record + * @tag_and_hdr_size: Tag indicating what the record contains (bottom 24 bits), and + * size of this header (top 8 bits), normally sizeof(struct bloblist_rec). + * The record's data starts at this offset from the start of the record * @size: Size of record in bytes, excluding the header size. This does not * need to be aligned (e.g. 3 is OK). */ struct bloblist_rec { - u32 tag; - u32 hdr_size; + u32 tag_and_hdr_size; u32 size; - u32 _spare; +}; + +enum { + BLOBLISTR_TAG_SHIFT = 0, + BLOBLISTR_TAG_MASK = 0xffffffU << BLOBLISTR_TAG_SHIFT, + BLOBLISTR_HDR_SIZE_SHIFT = 24, + BLOBLISTR_HDR_SIZE_MASK = 0xffU << BLOBLISTR_HDR_SIZE_SHIFT, + + BLOBLIST_HDR_SIZE = sizeof(struct bloblist_hdr), + BLOBLIST_REC_HDR_SIZE = sizeof(struct bloblist_rec), }; /** diff --git a/test/bloblist.c b/test/bloblist.c index 49ac4b92ae..e6070041d3 100644 --- a/test/bloblist.c +++ b/test/bloblist.c @@ -272,8 +272,8 @@ static int bloblist_test_cmd_info(struct unit_test_state *uts) run_command("bloblist info", 0); ut_assert_nextline("base: %lx", (ulong)map_to_sysmem(hdr)); ut_assert_nextline("size: 400 1 KiB"); - ut_assert_nextline("alloced: 70 112 Bytes"); - ut_assert_nextline("free: 390 912 Bytes"); + ut_assert_nextline("alloced: 58 88 Bytes"); + ut_assert_nextline("free: 3a8 936 Bytes"); ut_assert_console_end(); ut_unsilence_console(uts); @@ -331,12 +331,12 @@ static int bloblist_test_align(struct unit_test_state *uts) data = bloblist_add(i, size, 0); ut_assertnonnull(data); addr = map_to_sysmem(data); - ut_asserteq(0, addr & (BLOBLIST_ALIGN - 1)); + ut_asserteq(0, addr & (BLOBLIST_BLOB_ALIGN - 1)); /* Only the bytes in the blob data should be zeroed */ for (j = 0; j < size; j++) ut_asserteq(0, data[j]); - for (; j < BLOBLIST_ALIGN; j++) + for (; j < BLOBLIST_BLOB_ALIGN; j++) ut_asserteq(ERASE_BYTE, data[j]); } @@ -351,7 +351,7 @@ static int bloblist_test_align(struct unit_test_state *uts) } /* Check alignment with an bloblist starting on a smaller alignment */ - hdr = map_sysmem(TEST_ADDR + BLOBLIST_ALIGN, TEST_BLOBLIST_SIZE); + hdr = map_sysmem(TEST_ADDR + BLOBLIST_BLOB_ALIGN, TEST_BLOBLIST_SIZE); memset(hdr, ERASE_BYTE, TEST_BLOBLIST_SIZE); memset(hdr, '\0', sizeof(*hdr)); ut_assertok(bloblist_new(TEST_ADDR + BLOBLIST_ALIGN, TEST_BLOBLIST_SIZE, @@ -360,7 +360,7 @@ static int bloblist_test_align(struct unit_test_state *uts) data = bloblist_add(1, 5, BLOBLIST_ALIGN_LOG2 + 1); ut_assertnonnull(data); addr = map_to_sysmem(data); - ut_asserteq(0, addr & (BLOBLIST_ALIGN * 2 - 1)); + ut_asserteq(0, addr & (BLOBLIST_BLOB_ALIGN * 2 - 1)); return 0; } @@ -448,7 +448,7 @@ static int bloblist_test_grow(struct unit_test_state *uts) hdr = ptr; ut_asserteq(sizeof(struct bloblist_hdr) + sizeof(struct bloblist_rec) * 2 + small_size * 2 + - BLOBLIST_ALIGN, + BLOBLIST_BLOB_ALIGN, hdr->alloced); return 0; @@ -583,7 +583,7 @@ static int bloblist_test_resize_last(struct unit_test_state *uts) ut_asserteq((u8)ERASE_BYTE, *((u8 *)hdr + alloced_val + 4)); /* Check that the new top of the allocated blobs has not been touched */ - alloced_val += BLOBLIST_ALIGN; + alloced_val += BLOBLIST_BLOB_ALIGN; ut_asserteq(alloced_val, hdr->alloced); ut_asserteq((u8)ERASE_BYTE, *((u8 *)hdr + hdr->alloced)); From patchwork Mon Dec 18 18:18:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raymond Mao X-Patchwork-Id: 1877545 X-Patchwork-Delegate: sjg@chromium.org 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=vWwqDbn5; 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 4Sv7Sk6T6Zz23yx for ; Tue, 19 Dec 2023 05:21:42 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E0511875FE; Mon, 18 Dec 2023 19:20:29 +0100 (CET) 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="vWwqDbn5"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 362C687509; Mon, 18 Dec 2023 19:20:28 +0100 (CET) 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-oi1-x22e.google.com (mail-oi1-x22e.google.com [IPv6:2607:f8b0:4864:20::22e]) (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 1E0F687613 for ; Mon, 18 Dec 2023 19:20:24 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=raymond.mao@linaro.org Received: by mail-oi1-x22e.google.com with SMTP id 5614622812f47-3bb53e20a43so642571b6e.1 for ; Mon, 18 Dec 2023 10:20:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1702923622; x=1703528422; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=J0eh9xolvMbvTdmLa2Ngqnpmy4mlzhfcUYhl8pmdkAw=; b=vWwqDbn5s25IG1oPym4XSL8qNy/DelTsCNuJ631ocH3wT8jZ1ufVAbzjEJqsF7SNyJ iITy0naB4tVhCBzk2ujd7tbuJOGX9Nw5pLFHhjke5O8ETF3eU8ynu1me8Mod8eezvXuQ 1haMtolIpQaqBsEjx1tWmMjNYpidsdkrDgejSIhVXiOPLDspcfD3SbLsynhX2tzMcK17 xZXb7lnsWCsL56i2WBr1md1BJbnFZ/sjJHTZyzzv1P4TXvStL1QmzarNqIuD6Rkdgf+8 4ADpjhaqEf4gqbZcFhBrS5vaKehuyz4Dbcuao//KYUGUGzHPwB1ieCCGDjgkgZN2E9Mp KNww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702923622; x=1703528422; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=J0eh9xolvMbvTdmLa2Ngqnpmy4mlzhfcUYhl8pmdkAw=; b=TIpehF2UzmaLivFlxMcJf5xN1Y93tw0kfSoJgXeFR3L3/JPigaFpnquXGEtEBahG69 ANXReHZbcPIS0uGgH7ptcGTSZySdKZUCh2yI+BMiD9/tBvQI0I6JO9ZcYY7zaTvUQFij nsjCvwOvUHJ8zrQCdLcI7+OkNYdUouGW4dEofGCkRJ7pMZadmfVNHGcAN3tPziTwjdH8 azEADR2TMpjEKCmNxDN80qrBEdMv2qnG0rt5h++9eFhPDrSM2qauaWj1/3P0XW1o7t3/ 0Hj53vVOb1cTlJV7Tq2FyRv960/KSFZUXPxmPyBEgcWKCfQiunDCPpiqHm1LLj4nI4jZ GJXw== X-Gm-Message-State: AOJu0YyqUIQbu6iwaCwbnZv5EC0GRbEXwDSliPzouTVIXzryyQhCKv06 +rzZLf/L2iowuwST74VZzNq6LUTew9i+JPOSW8g= X-Google-Smtp-Source: AGHT+IF/YxFQ2HW6hZl/oTXKtB//8ztkcxKqX63MG0Db4JjU6BOOLRj9W9VXj3yh+ow4SV49Bga60A== X-Received: by 2002:a05:6808:148a:b0:3b9:ca51:5186 with SMTP id e10-20020a056808148a00b003b9ca515186mr19389980oiw.42.1702923622603; Mon, 18 Dec 2023 10:20:22 -0800 (PST) Received: from ubuntu.localdomain (cpe688f2e182063-cm688f2e182060.sdns.net.rogers.com. [174.115.4.214]) by smtp.gmail.com with ESMTPSA id dy7-20020ad44e87000000b0067f213933bdsm3046136qvb.2.2023.12.18.10.20.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 10:20:22 -0800 (PST) From: Raymond Mao To: u-boot@lists.denx.de, ilias.apalodimas@linaro.org, sjg@chromium.org, jwerner@chromium.org Cc: Raymond Mao , Bin Meng , Nikhil M Jain Subject: [PATCH v3 11/14] bloblist: Adjust the bloblist header Date: Mon, 18 Dec 2023 10:18:56 -0800 Message-Id: <20231218181901.337515-12-raymond.mao@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231218181901.337515-1-raymond.mao@linaro.org> References: <20231218181901.337515-1-raymond.mao@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Simon Glass The v0.9 spec provides for a 24-byte header. Update the implementation to match this. This also adds an alignment field. Signed-off-by: Simon Glass Co-developed-by: Raymond Mao Signed-off-by: Raymond Mao --- Changes in v3 - Update the bloblist header to align to FW handoff spec up to commit 3592349. - Update the related testcases. include/bloblist.h | 29 +++++++++++++++-------------- test/bloblist.c | 6 +++--- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/include/bloblist.h b/include/bloblist.h index 7024d7bf9e..5dba630adb 100644 --- a/include/bloblist.h +++ b/include/bloblist.h @@ -166,32 +166,33 @@ enum bloblist_tag_t { * from the last. * * @magic: BLOBLIST_MAGIC + * @chksum: checksum for the entire bloblist allocated area. Since any of the + * blobs can be altered after being created, this checksum is only valid + * when the bloblist is finalized before jumping to the next stage of boot. + * This is the value needed to make all checksummed bytes sum to 0 * @version: BLOBLIST_VERSION * @hdr_size: Size of this header, normally sizeof(struct bloblist_hdr). The * first bloblist_rec starts at this offset from the start of the header - * @flags: Space for BLOBLISTF... flags (none yet) - * @size: Total size of the bloblist (non-zero if valid) including this header. - * The bloblist extends for this many bytes from the start of this header. - * When adding new records, the bloblist can grow up to this size. + * @align_log2: Power of two of the maximum alignment required by this list * @alloced: Total size allocated so far for this bloblist. This starts out as * sizeof(bloblist_hdr) since we need at least that much space to store a * valid bloblist + * @size: Total size of the bloblist (non-zero if valid) including this header. + * The bloblist extends for this many bytes from the start of this header. + * When adding new records, the bloblist can grow up to this size. + * @flags: Space for BLOBLISTF... flags (none yet) * @spare: Spare space (for future use) - * @chksum: checksum for the entire bloblist allocated area. Since any of the - * blobs can be altered after being created, this checksum is only valid - * when the bloblist is finalised before jumping to the next stage of boot. - * This is the value needed to make all checksummed bytes sum to 0 */ struct bloblist_hdr { u32 magic; - u32 version; - u32 hdr_size; - u32 flags; - - u32 size; + u8 chksum; + u8 version; + u8 hdr_size; + u8 align_log2; u32 alloced; + u32 size; + u32 flags; u32 spare; - u32 chksum; }; /** diff --git a/test/bloblist.c b/test/bloblist.c index e6070041d3..a083259d0c 100644 --- a/test/bloblist.c +++ b/test/bloblist.c @@ -78,7 +78,7 @@ static int bloblist_test_init(struct unit_test_state *uts) ut_asserteq(-EPROTONOSUPPORT, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); - ut_asserteq(-ENOSPC, bloblist_new(TEST_ADDR, 0x10, 0)); + ut_asserteq(-ENOSPC, bloblist_new(TEST_ADDR, 0xc, 0)); ut_asserteq(-EFAULT, bloblist_new(1, TEST_BLOBLIST_SIZE, 0)); ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0)); @@ -272,8 +272,8 @@ static int bloblist_test_cmd_info(struct unit_test_state *uts) run_command("bloblist info", 0); ut_assert_nextline("base: %lx", (ulong)map_to_sysmem(hdr)); ut_assert_nextline("size: 400 1 KiB"); - ut_assert_nextline("alloced: 58 88 Bytes"); - ut_assert_nextline("free: 3a8 936 Bytes"); + ut_assert_nextline("alloced: 50 80 Bytes"); + ut_assert_nextline("free: 3b0 944 Bytes"); ut_assert_console_end(); ut_unsilence_console(uts); From patchwork Mon Dec 18 18:18:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raymond Mao X-Patchwork-Id: 1877546 X-Patchwork-Delegate: sjg@chromium.org 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=Ul34CFE2; 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 4Sv7Sx0xbfz23yx for ; Tue, 19 Dec 2023 05:21:53 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 80F3C8765E; Mon, 18 Dec 2023 19:20:32 +0100 (CET) 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="Ul34CFE2"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 747F38765E; Mon, 18 Dec 2023 19:20:31 +0100 (CET) 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-qt1-x82b.google.com (mail-qt1-x82b.google.com [IPv6:2607:f8b0:4864:20::82b]) (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 0494087509 for ; Mon, 18 Dec 2023 19:20:29 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=raymond.mao@linaro.org Received: by mail-qt1-x82b.google.com with SMTP id d75a77b69052e-42588e94019so35367191cf.0 for ; Mon, 18 Dec 2023 10:20:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1702923627; x=1703528427; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZBfjHWENQCjh6sm/CoLeelAQTAXKsmE2laL1wzYv2S4=; b=Ul34CFE2W9Hg9B7tj4HgaH82AXkdgc3UUnfZCToyazOJTR/6I1B9voU98h3rKHV4VO EYYJDF580pZ6Cyh+IQd0oku8IpQDgiGvwMScOFJvWqCN1N9DHXEV+WHcD35jAX4KVANz L526152pULGpR9RMS8I4vmhh+iWLj1Aj3Hf98lB8zCDmdfuU2eoSuLH4ecSouAOwvBpO 6VlJbmtRxrL+NPO/paM6NGy2E/V4wK6jlrp99v8BIWy/8xbPeDFa4rT3VZtkzwyJExpP aY3SrZvsNMQ1akX9x4GyfLQeQ9OWgzetkyl0hcDfI2Hy92kLsFnNVaD2oR0X5ETLdXhN myBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702923627; x=1703528427; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZBfjHWENQCjh6sm/CoLeelAQTAXKsmE2laL1wzYv2S4=; b=IHYFP9cX/s6jkROYMNPnTdOGPfI0CbTNiCJqvKl2BcqiSYArX3CVp2gGQmMRw3VWJI mupBRca9cerJY3HsDS9jd7Ua27jKxgWvbxYRHcAplxC6AyCvm9k8JxdtYuZY1kYi/7pX ZM7fQgKUZmn7x8KzBA6rrlaJmrH0c8sYwyzMKuOn+597hUld8/bPkhDmUIPFBy4q6iJH c4PpVmU/sg3VForO3E5g+2M/uH1db8r4/hv3pf0Vo4C/x/WsDC/qiXkYaokFn2bI8TN0 EiW3HqYsr3kMoFf5uVTor3f4ZOoGVM0QjUGz2DEmpwpjS9aYWjcKtDZU5/C5Z5pKRQOg rvvA== X-Gm-Message-State: AOJu0Yyp5i2rb2jF91DpA2J6abn6dgvNfhW1uNx2BR87vLVASnZhUW5F 3WW/HLB69Ik8hVs0tpo/xvJrwflQx+xNphbQNUo= X-Google-Smtp-Source: AGHT+IH/8i9vkN8n0dq8PM6tRirS+TUnTYQ2REt3EdhjS2yLtfYBVRO7TBNEvNL9z0+8Sc3ERAzuMA== X-Received: by 2002:a05:6214:238d:b0:67f:268f:ecac with SMTP id fw13-20020a056214238d00b0067f268fecacmr5557102qvb.18.1702923627183; Mon, 18 Dec 2023 10:20:27 -0800 (PST) Received: from ubuntu.localdomain (cpe688f2e182063-cm688f2e182060.sdns.net.rogers.com. [174.115.4.214]) by smtp.gmail.com with ESMTPSA id dy7-20020ad44e87000000b0067f213933bdsm3046136qvb.2.2023.12.18.10.20.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 10:20:26 -0800 (PST) From: Raymond Mao To: u-boot@lists.denx.de, ilias.apalodimas@linaro.org, sjg@chromium.org, jwerner@chromium.org Cc: Raymond Mao , Bin Meng , Nikhil M Jain Subject: [PATCH v3 12/14] bloblist: Add alignment to bloblist_new() Date: Mon, 18 Dec 2023 10:18:57 -0800 Message-Id: <20231218181901.337515-13-raymond.mao@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231218181901.337515-1-raymond.mao@linaro.org> References: <20231218181901.337515-1-raymond.mao@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Simon Glass Allow the alignment to be specified when creating a bloblist. Signed-off-by: Simon Glass Co-developed-by: Raymond Mao Signed-off-by: Raymond Mao Reviewed-by: Ilias Apalodimas --- Changes in v3 - Keep the flag argument to align to FW handoff spec up to commit 3592349. common/bloblist.c | 5 +++-- include/bloblist.h | 3 ++- test/bloblist.c | 40 ++++++++++++++++++++++------------------ 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/common/bloblist.c b/common/bloblist.c index 1c97d61e4a..6d079c58f7 100644 --- a/common/bloblist.c +++ b/common/bloblist.c @@ -349,7 +349,7 @@ static u32 bloblist_calc_chksum(struct bloblist_hdr *hdr) return chksum; } -int bloblist_new(ulong addr, uint size, uint flags) +int bloblist_new(ulong addr, uint size, uint flags, uint align_log2) { struct bloblist_hdr *hdr; @@ -365,6 +365,7 @@ int bloblist_new(ulong addr, uint size, uint flags) hdr->magic = BLOBLIST_MAGIC; hdr->size = size; hdr->alloced = hdr->hdr_size; + hdr->align_log2 = align_log2 ?: BLOBLIST_BLOB_ALIGN_LOG2; hdr->chksum = 0; gd->bloblist = hdr; @@ -508,7 +509,7 @@ int bloblist_init(void) } log_debug("Creating new bloblist size %lx at %lx\n", size, addr); - ret = bloblist_new(addr, size, 0); + ret = bloblist_new(addr, size, 0, 0); } else { log_debug("Found existing bloblist size %lx at %lx\n", size, addr); diff --git a/include/bloblist.h b/include/bloblist.h index 5dba630adb..8f0286fda7 100644 --- a/include/bloblist.h +++ b/include/bloblist.h @@ -330,10 +330,11 @@ int bloblist_resize(uint tag, int new_size); * @addr: Address of bloblist * @size: Initial size for bloblist * @flags: Flags to use for bloblist + * @align_log2: Log base 2 of maximum alignment provided by this bloblist * Return: 0 if OK, -EFAULT if addr is not aligned correctly, -ENOSPC is the * area is not large enough */ -int bloblist_new(ulong addr, uint size, uint flags); +int bloblist_new(ulong addr, uint size, uint flags, uint align_log2); /** * bloblist_check() - Check if a bloblist exists diff --git a/test/bloblist.c b/test/bloblist.c index a083259d0c..29abd46862 100644 --- a/test/bloblist.c +++ b/test/bloblist.c @@ -72,15 +72,15 @@ static int bloblist_test_init(struct unit_test_state *uts) hdr = clear_bloblist(); ut_asserteq(-ENOENT, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); ut_asserteq_ptr(NULL, bloblist_check_magic(TEST_ADDR)); - ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0)); + ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0, 0)); ut_asserteq_ptr(hdr, bloblist_check_magic(TEST_ADDR)); hdr->version++; ut_asserteq(-EPROTONOSUPPORT, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); - ut_asserteq(-ENOSPC, bloblist_new(TEST_ADDR, 0xc, 0)); - ut_asserteq(-EFAULT, bloblist_new(1, TEST_BLOBLIST_SIZE, 0)); - ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0)); + ut_asserteq(-ENOSPC, bloblist_new(TEST_ADDR, 0xc, 0, 0)); + ut_asserteq(-EFAULT, bloblist_new(1, TEST_BLOBLIST_SIZE, 0, 0)); + ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0, 0)); ut_asserteq(-EIO, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); ut_assertok(bloblist_finish()); @@ -106,7 +106,7 @@ static int bloblist_test_blob(struct unit_test_state *uts) /* At the start there should be no records */ hdr = clear_bloblist(); ut_assertnull(bloblist_find(TEST_TAG, TEST_BLOBLIST_SIZE)); - ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0)); + ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0, 0)); ut_asserteq(TEST_BLOBLIST_SIZE, bloblist_get_size()); ut_asserteq(TEST_ADDR, bloblist_get_base()); ut_asserteq(map_to_sysmem(hdr), TEST_ADDR); @@ -144,7 +144,7 @@ static int bloblist_test_blob_ensure(struct unit_test_state *uts) /* At the start there should be no records */ clear_bloblist(); - ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0)); + ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0, 0)); /* Test with an empty bloblist */ size = TEST_SIZE; @@ -176,7 +176,7 @@ static int bloblist_test_bad_blob(struct unit_test_state *uts) void *data; hdr = clear_bloblist(); - ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0)); + ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0, 0)); data = hdr + 1; data += sizeof(struct bloblist_rec); ut_asserteq_addr(data, bloblist_ensure(TEST_TAG, TEST_SIZE)); @@ -192,7 +192,7 @@ static int bloblist_test_checksum(struct unit_test_state *uts) char *data, *data2; hdr = clear_bloblist(); - ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0)); + ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0, 0)); ut_assertok(bloblist_finish()); ut_assertok(bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); @@ -217,6 +217,10 @@ static int bloblist_test_checksum(struct unit_test_state *uts) ut_asserteq(-EIO, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); hdr->chksum--; + hdr->align_log2++; + ut_asserteq(-EIO, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); + hdr->align_log2--; + /* Make sure the checksum changes when we add blobs */ data = bloblist_add(TEST_TAG, TEST_SIZE, 0); ut_asserteq(-EIO, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); @@ -262,7 +266,7 @@ static int bloblist_test_cmd_info(struct unit_test_state *uts) char *data, *data2; hdr = clear_bloblist(); - ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0)); + ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0, 0)); data = bloblist_ensure(TEST_TAG, TEST_SIZE); data2 = bloblist_ensure(TEST_TAG2, TEST_SIZE2); @@ -288,7 +292,7 @@ static int bloblist_test_cmd_list(struct unit_test_state *uts) char *data, *data2; hdr = clear_bloblist(); - ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0)); + ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0, 0)); data = bloblist_ensure(TEST_TAG, TEST_SIZE); data2 = bloblist_ensure(TEST_TAG2, TEST_SIZE2); @@ -318,7 +322,7 @@ static int bloblist_test_align(struct unit_test_state *uts) /* At the start there should be no records */ hdr = clear_bloblist(); - ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0)); + ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0, 0)); ut_assertnull(bloblist_find(TEST_TAG, TEST_BLOBLIST_SIZE)); /* Check the default alignment */ @@ -355,7 +359,7 @@ static int bloblist_test_align(struct unit_test_state *uts) memset(hdr, ERASE_BYTE, TEST_BLOBLIST_SIZE); memset(hdr, '\0', sizeof(*hdr)); ut_assertok(bloblist_new(TEST_ADDR + BLOBLIST_ALIGN, TEST_BLOBLIST_SIZE, - 0)); + 0, 0)); data = bloblist_add(1, 5, BLOBLIST_ALIGN_LOG2 + 1); ut_assertnonnull(data); @@ -376,7 +380,7 @@ static int bloblist_test_reloc(struct unit_test_state *uts) ulong new_addr; ulong new_size; - ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0)); + ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0, 0)); old_ptr = map_sysmem(TEST_ADDR, TEST_BLOBLIST_SIZE); /* Add one blob and then one that won't fit */ @@ -415,7 +419,7 @@ static int bloblist_test_grow(struct unit_test_state *uts) memset(hdr, ERASE_BYTE, TEST_BLOBLIST_SIZE); /* Create two blobs */ - ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0)); + ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0, 0)); blob1 = bloblist_add(TEST_TAG, small_size, 0); ut_assertnonnull(blob1); ut_assertok(check_zero(blob1, small_size)); @@ -467,7 +471,7 @@ static int bloblist_test_shrink(struct unit_test_state *uts) ptr = map_sysmem(TEST_ADDR, TEST_BLOBLIST_SIZE); /* Create two blobs */ - ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0)); + ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0, 0)); blob1 = bloblist_add(TEST_TAG, small_size, 0); ut_assertnonnull(blob1); strcpy(blob1, test1_str); @@ -517,7 +521,7 @@ static int bloblist_test_resize_fail(struct unit_test_state *uts) ptr = map_sysmem(TEST_ADDR, TEST_BLOBLIST_SIZE); /* Create two blobs */ - ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0)); + ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0, 0)); blob1 = bloblist_add(TEST_TAG, small_size, 0); ut_assertnonnull(blob1); @@ -554,7 +558,7 @@ static int bloblist_test_resize_last(struct unit_test_state *uts) hdr = ptr; /* Create two blobs */ - ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0)); + ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0, 0)); blob1 = bloblist_add(TEST_TAG, small_size, 0); ut_assertnonnull(blob1); @@ -599,7 +603,7 @@ static int bloblist_test_blob_maxsize(struct unit_test_state *uts) /* At the start there should be no records */ clear_bloblist(); - ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0)); + ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0, 0)); /* Add a blob that takes up all space */ size = TEST_BLOBLIST_SIZE - sizeof(struct bloblist_hdr) - From patchwork Mon Dec 18 18:18:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raymond Mao X-Patchwork-Id: 1877547 X-Patchwork-Delegate: sjg@chromium.org 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=VBUmEDoz; 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 4Sv7T75mbLz23yx for ; Tue, 19 Dec 2023 05:22:03 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3CDAE87600; Mon, 18 Dec 2023 19:20:35 +0100 (CET) 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="VBUmEDoz"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E50E087509; Mon, 18 Dec 2023 19:20:34 +0100 (CET) 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-qv1-xf30.google.com (mail-qv1-xf30.google.com [IPv6:2607:f8b0:4864:20::f30]) (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 EDB0B87600 for ; Mon, 18 Dec 2023 19:20:31 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=raymond.mao@linaro.org Received: by mail-qv1-xf30.google.com with SMTP id 6a1803df08f44-67f147c04b7so28091646d6.2 for ; Mon, 18 Dec 2023 10:20:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1702923630; x=1703528430; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=41rOY4nhe0tDZZ3Xj+jiOtbIUhWWRTymvUdxcnAtoks=; b=VBUmEDozWTgrPxUIMsVeprstF5kGDRGnPlKI63Zv64rXEgobuNkjG9hOrFXufc7w4K xjfwPFJxyalG3RE3V+tABtOq9xtrqP51eeLmWrOOIufYdrpy7UnWoWTsHhyK3fGlGJIT HuXKz00wAFcw9PthICerEbtErrbTUKQNH36Z0PalcaBfzvJeE0v67gHDaJgVHkkEO+78 lHFxGjDe909Yrn/z0vqZu8usDS3FiHlfSoRXMggx7DiY57rwvIuTGIFJVeZLQ+L9lyFN +KA21kLKpPlpptjWaSB0AIjr5+IjdSSMcyCDEI5Z+viBKvqBGpRn1UDxtnwTsplU1nYm mKGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702923630; x=1703528430; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=41rOY4nhe0tDZZ3Xj+jiOtbIUhWWRTymvUdxcnAtoks=; b=r1uD2rzP0c1M0LkqcAHZKEDvoXpBKpejSNkOXgaz9PPTwco+atj8V3iYi0jvar2mSW ahK+9xg+hOU6zcbmnCXUKiMTusjQPfcmZbwpnkUcBILpEfq48wHXxRRDO06FWImqq05X gbr5jNtT4oM2NOrMWzFAN71alp9S7jWXpSQZGCQNdqFkkGyma/DVBiYxutvYiPU6sagJ UyeZr1ldQXodx9zP1nltyaaraL7miCIcF8W7EU3ocJ0Zj5yuNhfkCgoA9JRfWIGuqv6b lbuY6XYFDmSyqCBGPVWwv4fyz27SX9c1802iuBCCer8vqIChJ0WYnqXY+lVoPUJa3D4x C+Aw== X-Gm-Message-State: AOJu0YwYUeVhcQZTnVzBBw6vkZP0/Cnw/CEh3mKhcHyAcAgHTsQVN4uS vzJcMmq2OCa9TSROb/aTZAaCQnGqp7AIwuJNIvU= X-Google-Smtp-Source: AGHT+IEgg/2veHFN1HI7Nf90j02FxA6quLWe543pizfVkS0waNDghEhNK7NspddvwR+3sTF9FuI9Tg== X-Received: by 2002:a05:6214:765:b0:67f:40cd:84df with SMTP id f5-20020a056214076500b0067f40cd84dfmr3924544qvz.29.1702923630687; Mon, 18 Dec 2023 10:20:30 -0800 (PST) Received: from ubuntu.localdomain (cpe688f2e182063-cm688f2e182060.sdns.net.rogers.com. [174.115.4.214]) by smtp.gmail.com with ESMTPSA id dy7-20020ad44e87000000b0067f213933bdsm3046136qvb.2.2023.12.18.10.20.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 10:20:30 -0800 (PST) From: Raymond Mao To: u-boot@lists.denx.de, ilias.apalodimas@linaro.org, sjg@chromium.org, jwerner@chromium.org Cc: Raymond Mao , Bin Meng , Nikhil M Jain Subject: [PATCH v3 13/14] bloblist: Update documentation and header comment Date: Mon, 18 Dec 2023 10:18:58 -0800 Message-Id: <20231218181901.337515-14-raymond.mao@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231218181901.337515-1-raymond.mao@linaro.org> References: <20231218181901.337515-1-raymond.mao@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Simon Glass Align the documentation with the v0.9 spec. Signed-off-by: Simon Glass Signed-off-by: Raymond Mao Reviewed-by: Ilias Apalodimas --- doc/develop/bloblist.rst | 4 +++- include/bloblist.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/develop/bloblist.rst b/doc/develop/bloblist.rst index 81643c7674..28431039ad 100644 --- a/doc/develop/bloblist.rst +++ b/doc/develop/bloblist.rst @@ -14,6 +14,8 @@ structure defined by the code that owns it. For the design goals of bloblist, please see the comments at the top of the `bloblist.h` header file. +Bloblist is an implementation with the `Firmware Handoff`_ protocol. + Passing state through the boot process -------------------------------------- @@ -99,7 +101,7 @@ API documentation ----------------- .. kernel-doc:: include/bloblist.h - +.. _`Firmware Handoff`: https://github.com/FirmwareHandoff/firmware_handoff Simon Glass sjg@chromium.org diff --git a/include/bloblist.h b/include/bloblist.h index 8f0286fda7..e3c86808b4 100644 --- a/include/bloblist.h +++ b/include/bloblist.h @@ -66,6 +66,7 @@ * * Copyright 2018 Google, Inc * Written by Simon Glass + * Adjusted July 2023 to match Firmware handoff specification, Release 0.9 */ #ifndef __BLOBLIST_H From patchwork Mon Dec 18 18:18:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raymond Mao X-Patchwork-Id: 1877548 X-Patchwork-Delegate: sjg@chromium.org 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=QP4Om1GH; 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 4Sv7TL2wxDz23yx for ; Tue, 19 Dec 2023 05:22:14 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CBCB38763E; Mon, 18 Dec 2023 19:20:41 +0100 (CET) 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="QP4Om1GH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1D256874F3; Mon, 18 Dec 2023 19:20:40 +0100 (CET) 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-oo1-xc34.google.com (mail-oo1-xc34.google.com [IPv6:2607:f8b0:4864:20::c34]) (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 093F28765B for ; Mon, 18 Dec 2023 19:20:37 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=raymond.mao@linaro.org Received: by mail-oo1-xc34.google.com with SMTP id 006d021491bc7-59067ccb090so2318489eaf.1 for ; Mon, 18 Dec 2023 10:20:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1702923635; x=1703528435; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XIFgjIaZRfwtD/ci0bGqXAz4pdToUM6LbnS0MXgrtJQ=; b=QP4Om1GHOfUBn/QyowwoCvBmYErw6PA8EGOc/CpoSj9FyzyxID0ca576J0n94lAqfC unA6OQdbBgMNc8S/0E84/C5yjYw+8Dx+gsKQmxqZhCb5vSDFcurqy5cwiUL+p9zfSv0A 6ZtqMsJBAuvIc/hNW4XHwCNQvSYVkii+SK+qFln1j6nhXNcZdlofZuivjxAGRJ8s7iBl UFIdRC7ZC2M2OgP0fs0/NroL6mohlr5giqIVpFoAsrStgQnmb0FaUj/gQVjQs4n7xhGm V+z22SBFDFpLFjwbQc/dwkVSPsJZ2bvby2Vu2PSOIHN2YpGB6gW5s//fvOApJHoOLhSj KTkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702923635; x=1703528435; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XIFgjIaZRfwtD/ci0bGqXAz4pdToUM6LbnS0MXgrtJQ=; b=ftUrJmSMau5n7D6iMe54XDRrja97R3YjRhL0p0j2BP2zJcNkKYEy4YQgJWpcq2ql7E +sTls/IVQVxWmTHYWboDfAjBhuAipZw143jBHSyFssjuoFgbuyvWJKqdhWWz/mowyBap T2fe1/JF9Re20B3QZoW+9+tyhP19HjZ0EI4CKXTnMwm9wa/a4pyEjjz9Dfxc2FHDcy6A VJ9oDvNy7M89Hz4QSuoK8Vz89Dqw6or7dPCb/sPasyXHPTarukBJwbq7M1u4r/ii8rHh 89kuv/AmOQHXRKoXCeKgg1MrgRS/gKP7rX3Xz8dW893DrZQ2siXkpU7KboJGffbQI/qi udFw== X-Gm-Message-State: AOJu0Yx1Hfuj/vFRp1NLbFgKKpfpmfG3nEx6evDGq0/1ehYKjDHgBp7S GrZ3MS9wFw2Lr0bIzs/1pL4cbjuWWyU8Kl4WnAQ= X-Google-Smtp-Source: AGHT+IGBVeg6i/KO6SVB06kT4KeWajHwPBmIWAiNq3EDvwRDMoy0NdQh4mbT3NLmRcy7b+XeZBvesQ== X-Received: by 2002:a05:6358:3a1a:b0:171:a2ac:7f6a with SMTP id g26-20020a0563583a1a00b00171a2ac7f6amr10100123rwe.56.1702923635068; Mon, 18 Dec 2023 10:20:35 -0800 (PST) Received: from ubuntu.localdomain (cpe688f2e182063-cm688f2e182060.sdns.net.rogers.com. [174.115.4.214]) by smtp.gmail.com with ESMTPSA id dy7-20020ad44e87000000b0067f213933bdsm3046136qvb.2.2023.12.18.10.20.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 10:20:34 -0800 (PST) From: Raymond Mao To: u-boot@lists.denx.de, ilias.apalodimas@linaro.org, sjg@chromium.org, jwerner@chromium.org Cc: Raymond Mao , Bin Meng , Nikhil M Jain Subject: [PATCH v3 14/14] bloblist: Align bloblist used_size and total_size to spec Date: Mon, 18 Dec 2023 10:18:59 -0800 Message-Id: <20231218181901.337515-15-raymond.mao@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231218181901.337515-1-raymond.mao@linaro.org> References: <20231218181901.337515-1-raymond.mao@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Align used_size and total_size of the bloblist header to the definition of the FW Handoff spec v0.9. Update the related bloblist APIs and UT testcases. Signed-off-by: Raymond Mao --- Changes in v2 - New patch file created for v2. Changes in v3 - Keep the flag and spare values to align to FW handoff spec up to commit 3592349. common/bloblist.c | 86 +++++++++++++++++++++++++++------------------- include/bloblist.h | 25 +++++++++----- test/bloblist.c | 35 ++++++++++--------- 3 files changed, 84 insertions(+), 62 deletions(-) diff --git a/common/bloblist.c b/common/bloblist.c index 6d079c58f7..625e480f6b 100644 --- a/common/bloblist.c +++ b/common/bloblist.c @@ -80,7 +80,7 @@ const char *bloblist_tag_name(enum bloblist_tag_t tag) static struct bloblist_rec *bloblist_first_blob(struct bloblist_hdr *hdr) { - if (hdr->alloced <= hdr->hdr_size) + if (hdr->used_size <= hdr->hdr_size) return NULL; return (struct bloblist_rec *)((void *)hdr + hdr->hdr_size); } @@ -119,7 +119,7 @@ static struct bloblist_rec *bloblist_next_blob(struct bloblist_hdr *hdr, { ulong offset = bloblist_blob_end_ofs(hdr, rec); - if (offset >= hdr->alloced) + if (offset >= hdr->used_size) return NULL; return (struct bloblist_rec *)((void *)hdr + offset); } @@ -156,9 +156,9 @@ static int bloblist_addrec(uint tag, int size, int align_log2, align_log2 = BLOBLIST_BLOB_ALIGN_LOG2; /* Figure out where the new data will start */ - data_start = map_to_sysmem(hdr) + hdr->alloced + sizeof(*rec); + data_start = map_to_sysmem(hdr) + hdr->used_size + sizeof(*rec); - /* Align the address and then calculate the offset from ->alloced */ + /* Align the address and then calculate the offset from used size */ aligned_start = ALIGN(data_start, 1U << align_log2) - data_start; /* If we need to create a dummy record, create it */ @@ -172,19 +172,20 @@ static int bloblist_addrec(uint tag, int size, int align_log2, return log_msg_ret("void", ret); /* start the record after that */ - data_start = map_to_sysmem(hdr) + hdr->alloced + sizeof(*vrec); + data_start = map_to_sysmem(hdr) + hdr->used_size + sizeof(*vrec); } /* Calculate the new allocated total */ new_alloced = data_start - map_to_sysmem(hdr) + ALIGN(size, 1U << align_log2); - if (new_alloced > hdr->size) { - log_err("Failed to allocate %x bytes size=%x, need size=%x\n", - size, hdr->size, new_alloced); + if (new_alloced > hdr->total_size) { + log_err("Failed to allocate %x bytes\n", size); + log_err("Used size=%x, total size=%x\n", + hdr->used_size, hdr->total_size); return log_msg_ret("bloblist add", -ENOSPC); } - rec = (void *)hdr + hdr->alloced; + rec = (void *)hdr + hdr->used_size; rec->tag_and_hdr_size = tag | sizeof(*rec) << BLOBLISTR_HDR_SIZE_SHIFT; rec->size = size; @@ -192,7 +193,7 @@ static int bloblist_addrec(uint tag, int size, int align_log2, /* Zero the record data */ memset((void *)rec + rec_hdr_size(rec), '\0', rec->size); - hdr->alloced = new_alloced; + hdr->used_size = new_alloced; *recp = rec; return 0; @@ -287,29 +288,30 @@ static int bloblist_resize_rec(struct bloblist_hdr *hdr, int new_size) { int expand_by; /* Number of bytes to expand by (-ve to contract) */ - int new_alloced; /* New value for @hdr->alloced */ + int new_alloced; ulong next_ofs; /* Offset of the record after @rec */ expand_by = ALIGN(new_size - rec->size, BLOBLIST_BLOB_ALIGN); - new_alloced = ALIGN(hdr->alloced + expand_by, BLOBLIST_BLOB_ALIGN); + new_alloced = ALIGN(hdr->used_size + expand_by, BLOBLIST_BLOB_ALIGN); if (new_size < 0) { log_debug("Attempt to shrink blob size below 0 (%x)\n", new_size); return log_msg_ret("size", -EINVAL); } - if (new_alloced > hdr->size) { - log_err("Failed to allocate %x bytes size=%x, need size=%x\n", - new_size, hdr->size, new_alloced); + if (new_alloced > hdr->total_size) { + log_err("Failed to allocate %x bytes\n", new_size); + log_err("Used size=%x, total size=%x\n", + hdr->used_size, hdr->total_size); return log_msg_ret("alloc", -ENOSPC); } /* Move the following blobs up or down, if this is not the last */ next_ofs = bloblist_blob_end_ofs(hdr, rec); - if (next_ofs != hdr->alloced) { + if (next_ofs != hdr->used_size) { memmove((void *)hdr + next_ofs + expand_by, (void *)hdr + next_ofs, new_alloced - next_ofs); } - hdr->alloced = new_alloced; + hdr->used_size = new_alloced; /* Zero the new part of the blob */ if (expand_by > 0) { @@ -343,7 +345,7 @@ static u32 bloblist_calc_chksum(struct bloblist_hdr *hdr) { u8 chksum; - chksum = table_compute_checksum(hdr, hdr->alloced); + chksum = table_compute_checksum(hdr, hdr->used_size); chksum += hdr->chksum; return chksum; @@ -363,9 +365,9 @@ int bloblist_new(ulong addr, uint size, uint flags, uint align_log2) hdr->hdr_size = sizeof(*hdr); hdr->flags = flags; hdr->magic = BLOBLIST_MAGIC; - hdr->size = size; - hdr->alloced = hdr->hdr_size; + hdr->used_size = hdr->hdr_size; hdr->align_log2 = align_log2 ?: BLOBLIST_BLOB_ALIGN_LOG2; + hdr->total_size = size; hdr->chksum = 0; gd->bloblist = hdr; @@ -382,8 +384,13 @@ int bloblist_check(ulong addr, uint size) return log_msg_ret("Bad magic", -ENOENT); if (hdr->version != BLOBLIST_VERSION) return log_msg_ret("Bad version", -EPROTONOSUPPORT); - if (size && hdr->size != size) - return log_msg_ret("Bad size", -EFBIG); + if (!hdr->total_size || (size && hdr->total_size != size)) + return log_msg_ret("Bad total size", -EFBIG); + if (hdr->used_size > hdr->total_size) + return log_msg_ret("Bad used size", -ENOENT); + if (hdr->hdr_size != sizeof(struct bloblist_hdr)) + return log_msg_ret("Bad header size", -ENOENT); + chksum = bloblist_calc_chksum(hdr); if (hdr->chksum != chksum) { log_err("Checksum %x != %x\n", hdr->chksum, chksum); @@ -399,7 +406,7 @@ int bloblist_finish(void) struct bloblist_hdr *hdr = gd->bloblist; hdr->chksum = bloblist_calc_chksum(hdr); - log_debug("Finished bloblist size %lx at %lx\n", (ulong)hdr->size, + log_debug("Finished bloblist size %lx at %lx\n", (ulong)hdr->used_size, (ulong)map_to_sysmem(hdr)); return 0; @@ -414,33 +421,40 @@ ulong bloblist_get_size(void) { struct bloblist_hdr *hdr = gd->bloblist; - return hdr->size; + return hdr->used_size; +} + +ulong bloblist_get_total_size(void) +{ + struct bloblist_hdr *hdr = gd->bloblist; + + return hdr->total_size; } -void bloblist_get_stats(ulong *basep, ulong *sizep, ulong *allocedp) +void bloblist_get_stats(ulong *basep, ulong *tsizep, ulong *usizep) { struct bloblist_hdr *hdr = gd->bloblist; *basep = map_to_sysmem(gd->bloblist); - *sizep = hdr->size; - *allocedp = hdr->alloced; + *tsizep = hdr->total_size; + *usizep = hdr->used_size; } static void show_value(const char *prompt, ulong value) { - printf("%s:%*s %-5lx ", prompt, 8 - (int)strlen(prompt), "", value); + printf("%s:%*s %-5lx ", prompt, 10 - (int)strlen(prompt), "", value); print_size(value, "\n"); } void bloblist_show_stats(void) { - ulong base, size, alloced; + ulong base, tsize, usize; - bloblist_get_stats(&base, &size, &alloced); - printf("base: %lx\n", base); - show_value("size", size); - show_value("alloced", alloced); - show_value("free", size - alloced); + bloblist_get_stats(&base, &tsize, &usize); + printf("base: %lx\n", base); + show_value("total size", tsize); + show_value("used size", usize); + show_value("free", tsize - usize); } void bloblist_show_list(void) @@ -464,7 +478,7 @@ void bloblist_reloc(void *to, uint to_size, void *from, uint from_size) memcpy(to, from, from_size); hdr = to; - hdr->size = to_size; + hdr->total_size = to_size; } int bloblist_init(void) @@ -494,7 +508,7 @@ int bloblist_init(void) addr, ret); } else { /* Get the real size, if it is not what we expected */ - size = gd->bloblist->size; + size = gd->bloblist->total_size; } } if (ret) { diff --git a/include/bloblist.h b/include/bloblist.h index e3c86808b4..84fc943819 100644 --- a/include/bloblist.h +++ b/include/bloblist.h @@ -175,12 +175,12 @@ enum bloblist_tag_t { * @hdr_size: Size of this header, normally sizeof(struct bloblist_hdr). The * first bloblist_rec starts at this offset from the start of the header * @align_log2: Power of two of the maximum alignment required by this list - * @alloced: Total size allocated so far for this bloblist. This starts out as + * @used_size: Size allocated so far for this bloblist. This starts out as * sizeof(bloblist_hdr) since we need at least that much space to store a * valid bloblist - * @size: Total size of the bloblist (non-zero if valid) including this header. - * The bloblist extends for this many bytes from the start of this header. - * When adding new records, the bloblist can grow up to this size. + * @total_size: The number of total bytes that the bloblist can occupy. + * Any blob producer must check if there is sufficient space before adding + * a record to the bloblist. * @flags: Space for BLOBLISTF... flags (none yet) * @spare: Spare space (for future use) */ @@ -190,8 +190,8 @@ struct bloblist_hdr { u8 version; u8 hdr_size; u8 align_log2; - u32 alloced; - u32 size; + u32 used_size; + u32 total_size; u32 flags; u32 spare; }; @@ -366,10 +366,10 @@ int bloblist_finish(void); * This returns useful information about the bloblist * * @basep: Returns base address of bloblist - * @sizep: Returns the number of bytes used in the bloblist - * @allocedp: Returns the total space allocated to the bloblist + * @tsizep: Returns the total number of bytes of the bloblist + * @usizep: Returns the number of used bytes of the bloblist */ -void bloblist_get_stats(ulong *basep, ulong *sizep, ulong *allocedp); +void bloblist_get_stats(ulong *basep, ulong *tsizep, ulong *usizep); /** * bloblist_get_base() - Get the base address of the bloblist @@ -385,6 +385,13 @@ ulong bloblist_get_base(void); */ ulong bloblist_get_size(void); +/** + * bloblist_get_total_size() - Get the total size of the bloblist + * + * Return: the size in bytes + */ +ulong bloblist_get_total_size(void); + /** * bloblist_show_stats() - Show information about the bloblist * diff --git a/test/bloblist.c b/test/bloblist.c index 29abd46862..17d9dd03d0 100644 --- a/test/bloblist.c +++ b/test/bloblist.c @@ -107,7 +107,8 @@ static int bloblist_test_blob(struct unit_test_state *uts) hdr = clear_bloblist(); ut_assertnull(bloblist_find(TEST_TAG, TEST_BLOBLIST_SIZE)); ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0, 0)); - ut_asserteq(TEST_BLOBLIST_SIZE, bloblist_get_size()); + ut_asserteq(sizeof(struct bloblist_hdr), bloblist_get_size()); + ut_asserteq(TEST_BLOBLIST_SIZE, bloblist_get_total_size()); ut_asserteq(TEST_ADDR, bloblist_get_base()); ut_asserteq(map_to_sysmem(hdr), TEST_ADDR); @@ -205,9 +206,9 @@ static int bloblist_test_checksum(struct unit_test_state *uts) ut_asserteq(-EIO, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); hdr->flags++; - hdr->size--; + hdr->total_size--; ut_asserteq(-EFBIG, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); - hdr->size++; + hdr->total_size++; hdr->spare++; ut_asserteq(-EIO, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); @@ -274,10 +275,10 @@ static int bloblist_test_cmd_info(struct unit_test_state *uts) ut_silence_console(uts); console_record_reset(); run_command("bloblist info", 0); - ut_assert_nextline("base: %lx", (ulong)map_to_sysmem(hdr)); - ut_assert_nextline("size: 400 1 KiB"); - ut_assert_nextline("alloced: 50 80 Bytes"); - ut_assert_nextline("free: 3b0 944 Bytes"); + ut_assert_nextline("base: %lx", (ulong)map_to_sysmem(hdr)); + ut_assert_nextline("total size: 400 1 KiB"); + ut_assert_nextline("used size: 50 80 Bytes"); + ut_assert_nextline("free: 3b0 944 Bytes"); ut_assert_console_end(); ut_unsilence_console(uts); @@ -431,7 +432,7 @@ static int bloblist_test_grow(struct unit_test_state *uts) ut_asserteq(sizeof(struct bloblist_hdr) + sizeof(struct bloblist_rec) * 2 + small_size * 2, - hdr->alloced); + hdr->used_size); /* Resize the first one */ ut_assertok(bloblist_resize(TEST_TAG, small_size + 4)); @@ -453,7 +454,7 @@ static int bloblist_test_grow(struct unit_test_state *uts) ut_asserteq(sizeof(struct bloblist_hdr) + sizeof(struct bloblist_rec) * 2 + small_size * 2 + BLOBLIST_BLOB_ALIGN, - hdr->alloced); + hdr->used_size); return 0; } @@ -483,7 +484,7 @@ static int bloblist_test_shrink(struct unit_test_state *uts) hdr = ptr; ut_asserteq(sizeof(struct bloblist_hdr) + sizeof(struct bloblist_rec) * 2 + small_size * 2, - hdr->alloced); + hdr->used_size); /* Resize the first one */ new_size = small_size - BLOBLIST_ALIGN - 4; @@ -503,7 +504,7 @@ static int bloblist_test_shrink(struct unit_test_state *uts) ut_asserteq(sizeof(struct bloblist_hdr) + sizeof(struct bloblist_rec) * 2 + small_size * 2 - BLOBLIST_ALIGN, - hdr->alloced); + hdr->used_size); return 0; } @@ -531,12 +532,12 @@ static int bloblist_test_resize_fail(struct unit_test_state *uts) hdr = ptr; ut_asserteq(sizeof(struct bloblist_hdr) + sizeof(struct bloblist_rec) * 2 + small_size * 2, - hdr->alloced); + hdr->used_size); /* Resize the first one, to check the boundary conditions */ ut_asserteq(-EINVAL, bloblist_resize(TEST_TAG, -1)); - new_size = small_size + (hdr->size - hdr->alloced); + new_size = small_size + (hdr->total_size - hdr->used_size); ut_asserteq(-ENOSPC, bloblist_resize(TEST_TAG, new_size + 1)); ut_assertok(bloblist_resize(TEST_TAG, new_size)); @@ -568,9 +569,9 @@ static int bloblist_test_resize_last(struct unit_test_state *uts) /* Check the byte after the last blob */ alloced_val = sizeof(struct bloblist_hdr) + sizeof(struct bloblist_rec) * 2 + small_size * 2; - ut_asserteq(alloced_val, hdr->alloced); + ut_asserteq(alloced_val, hdr->used_size); ut_asserteq_ptr((void *)hdr + alloced_val, blob2 + small_size); - ut_asserteq((u8)ERASE_BYTE, *((u8 *)hdr + hdr->alloced)); + ut_asserteq((u8)ERASE_BYTE, *((u8 *)hdr + hdr->used_size)); /* Resize the second one, checking nothing changes */ ut_asserteq(0, bloblist_resize(TEST_TAG2, small_size + 4)); @@ -588,8 +589,8 @@ static int bloblist_test_resize_last(struct unit_test_state *uts) /* Check that the new top of the allocated blobs has not been touched */ alloced_val += BLOBLIST_BLOB_ALIGN; - ut_asserteq(alloced_val, hdr->alloced); - ut_asserteq((u8)ERASE_BYTE, *((u8 *)hdr + hdr->alloced)); + ut_asserteq(alloced_val, hdr->used_size); + ut_asserteq((u8)ERASE_BYTE, *((u8 *)hdr + hdr->used_size)); return 0; }