From patchwork Mon Oct 26 23:40:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1388218 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: 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=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=exCc8c7q; dkim-atps=neutral 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 RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CKs2K6yFgz9sTf for ; Tue, 27 Oct 2020 10:47:21 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E011B82544; Tue, 27 Oct 2020 00:41:34 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="exCc8c7q"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A9F1582508; Tue, 27 Oct 2020 00:41:07 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) (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 5E7F18248B for ; Tue, 27 Oct 2020 00:40:51 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12c.google.com with SMTP id g7so10918262ilr.12 for ; Mon, 26 Oct 2020 16:40:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=w5+eHKD2xEByPbbgo699tyG7CulQmF6MqSVk27Ssh2U=; b=exCc8c7qHTGk+7hchriunMhgjLoi27hGfAzBfHjAV2YnVC2T0J8h7CJ9b6wQJPjRyh wjy/Vw7AxVL2frPNOv35Fr+iSAm+VVizILcS0CUN1m4qMecfJsSwqmb1mkQjO2Rvjil4 IwYYd9wfXIDIT3+pwsPevU/Pido+JFrrHP0Jw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=w5+eHKD2xEByPbbgo699tyG7CulQmF6MqSVk27Ssh2U=; b=pnioPVgqBgmIlfqICJLgpa7FaKSRCOLBDpfepa/4CQ0r+jypb5IuRIXony0JVfLnn7 yNocQx7og2X0Dy9LPoPQHD04keBgJxmUxtHJRbG/0t1hBwn2cRgugdFWk0lXvJiO7P5U WeK81+Gx94BBglsfI21HqgyStEovQs7Ahw2YfOtmefYOjdY7SCd8XtwCPB9eFvcqDoOi hRqksuUNVE2dGzFuY4/YG7u93cX1/9wn1MgwxlT/3/4Zn5oYbS03BOa6322gC8GD7OBQ UK2+W/C9YIp9HXIuH0RTSX6IElFmYidYleGJvZ9YVqHLOJJE4uZ65FhYD/y6V9R+gQ/d G55w== X-Gm-Message-State: AOAM5330LnxprXMyctXyuYFs20LlpzkuScDCyQ6xr7UDQ7lPmk//YnyJ kfDBQInJRdbifmgqCF/zJ6j9joP8iSqW0SyW X-Google-Smtp-Source: ABdhPJy2FRwhcpqaqSTWwuZUQwk3D+Z3Gwn7rrlywsdi9fMS6XRD+RI5hZ5t0cH+6MVFY6dSgfoztw== X-Received: by 2002:a92:41c6:: with SMTP id o189mr1159491ila.261.1603755650567; Mon, 26 Oct 2020 16:40:50 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id e17sm7066857ile.60.2020.10.26.16.40.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 16:40:50 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Alper Nebi Yasak , Simon Glass Subject: [PATCH v2 24/28] binman: Drop CheckEntries() Date: Mon, 26 Oct 2020 17:40:22 -0600 Message-Id: <20201026234026.1903778-24-sjg@chromium.org> X-Mailer: git-send-email 2.29.0.rc2.309.g374f81d7ae-goog In-Reply-To: <20201026234026.1903778-1-sjg@chromium.org> References: <20201026234026.1903778-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean This method introduces a separation between packing and checking that is different for sections. In order to handle compression properly, we need to be able to deal with a section's size being smaller than the uncompressed size of its contents. It is easier to make this work if everything happens in the Pack() method. The only real user of CheckEntries() is entry_Section and it can call it directly. Drop the call from 'control' and handle it locally. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) tools/binman/README | 22 ++++++++++------------ tools/binman/control.py | 1 - tools/binman/etype/section.py | 4 +++- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/tools/binman/README b/tools/binman/README index c7c787c99fd..c14cee5d115 100644 --- a/tools/binman/README +++ b/tools/binman/README @@ -712,40 +712,38 @@ size of an entry. The 'current' image offset is passed in, and the function returns the offset immediately after the entry being packed. The default implementation of Pack() is usually sufficient. -Note: for sections, this also sets the size of the entry to be large enough -for all entries it contains. +Note: for sections, this also checks that the entries do not overlap, nor extend +outside the section. If the section does not have a defined size, the size is +set large enough to hold all the entries. -6. CheckEntries() - checks that the entries do not overlap, nor extend -outside the image. - -7. SetImagePos() - sets the image position of every entry. This is the absolute +6. SetImagePos() - sets the image position of every entry. This is the absolute position 'image-pos', as opposed to 'offset' which is relative to the containing section. This must be done after all offsets are known, which is why it is quite late in the ordering. -8. SetCalculatedProperties() - update any calculated properties in the device +7. SetCalculatedProperties() - update any calculated properties in the device tree. This sets the correct 'offset' and 'size' vaues, for example. -9. ProcessEntryContents() - this calls Entry.ProcessContents() on each entry. +8. ProcessEntryContents() - this calls Entry.ProcessContents() on each entry. The default implementatoin does nothing. This can be overriden to adjust the contents of an entry in some way. For example, it would be possible to create an entry containing a hash of the contents of some other entries. At this stage the offset and size of entries should not be adjusted unless absolutely necessary, since it requires a repack (going back to PackEntries()). -10. ResetForPack() - if the ProcessEntryContents() step failed, in that an entry +9. ResetForPack() - if the ProcessEntryContents() step failed, in that an entry has changed its size, then there is no alternative but to go back to step 5 and try again, repacking the entries with the updated size. ResetForPack() removes the fixed offset/size values added by binman, so that the packing can start from scratch. -11. WriteSymbols() - write the value of symbols into the U-Boot SPL binary. +10. WriteSymbols() - write the value of symbols into the U-Boot SPL binary. See 'Access to binman entry offsets at run time' below for a description of what happens in this stage. -12. BuildImage() - builds the image and writes it to a file +11. BuildImage() - builds the image and writes it to a file -13. WriteMap() - writes a text file containing a map of the image. This is the +12. WriteMap() - writes a text file containing a map of the image. This is the final step. diff --git a/tools/binman/control.py b/tools/binman/control.py index 9eeac5db995..072417f3644 100644 --- a/tools/binman/control.py +++ b/tools/binman/control.py @@ -513,7 +513,6 @@ def ProcessImage(image, update_fdt, write_map, get_contents=True, for pack_pass in range(passes): try: image.PackEntries() - image.CheckEntries() except Exception as e: if write_map: fname = image.WriteMap() diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py index f93469a170b..1618bebe4be 100644 --- a/tools/binman/etype/section.py +++ b/tools/binman/etype/section.py @@ -267,7 +267,9 @@ class Entry_section(Entry): size = self.CheckSize() self.size = size - return super().Pack(offset) + offset = super().Pack(offset) + self.CheckEntries() + return offset def _PackEntries(self): """Pack all entries into the section"""