From patchwork Tue Feb 8 23:06:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alper Nebi Yasak X-Patchwork-Id: 1590145 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=BWIuJNPz; dkim-atps=neutral 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=) 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) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JtdvP3Vd8z9s5B for ; Wed, 9 Feb 2022 10:07:27 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 34D6083DAB; Wed, 9 Feb 2022 00:07:18 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com 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=gmail.com header.i=@gmail.com header.b="BWIuJNPz"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A84B283DB8; Wed, 9 Feb 2022 00:07:15 +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,FREEMAIL_FROM,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 63A4883D8C for ; Wed, 9 Feb 2022 00:07:11 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=alpernebiyasak@gmail.com Received: by mail-ej1-x632.google.com with SMTP id o12so1870907eju.13 for ; Tue, 08 Feb 2022 15:07:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=m30x2ydIwOfwWreaW7wMk7fjEkiGhpNmntUawnrQAZM=; b=BWIuJNPz8IWG0NWEK5DsH6g5dxbIxv8W7B0lW66GSF4sJ+/srhdTj+5LNJBQhLbR5p ZwlDUHwo5vTAZioQETXbkS3+wkNWn/79eX4AsL+eVt2Equ+0h8je49d0X2b8iJhrpra1 kg5kVaCufzBIa0kcaja7vu2UDgil2nDLb/ZSAn78/qxh5xTJNwAtoOUCCwakdvC8ssnV NBgcvvdVEMy4MnNzUnVPd3aTcs1bi3pQKjIifgqf5SRhEDATU+qTnFewZfdbK74WEhB/ F2IMbJA4pd9PToAUlRwc2BPvHSX16wpTzt1vuahqefBIrT5WZAvP9XKmip2Z/Iw/q4y9 eDiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=m30x2ydIwOfwWreaW7wMk7fjEkiGhpNmntUawnrQAZM=; b=Bm0M7750TV+NI1++5XEK0rB/tVyLB0j4b9UDEcMo1MvcjvdhVdrtt0T0Yu2E8470H7 9JX4nmwGsV0oTu8fmtKBWJuJSeySkkVO1qguPVZ0vKX457dM3yUxJ8Aa9nF5yStCTXig N5K8cj6J+cAd7B+AnPXcFkX8781R5pHRWFZ37ODCII33GApfek9PGeAlq0ggI2CvTpMG MfqESVttuYieTQ2Ng339aVOqYfGwssKyvaTA+ohZXpdjY6EXLJR9r1a1+xFf69EwJ/y5 RHcQHioV6lXoQXIl1qh2uguJMB59MsKGaqL47KNqXXszNKJIGIS09n6DSjEYa+0QdCsW DJDg== X-Gm-Message-State: AOAM5319kHzvbm1IA5mBXz6aB8zWSQuDA8xXRCbF/8Zf5LSxkBwRQa6F sIOPvG75/S7tC2sN3PDzlELmdDnZX74= X-Google-Smtp-Source: ABdhPJwH/80NYcO5C8VSAym1XXEtqSIRS/LlDUvha8tXOnUZM5JTp6zxGbqeZ6Cnj+laHRKiKC76CA== X-Received: by 2002:a17:907:a413:: with SMTP id sg19mr5525388ejc.28.1644361629698; Tue, 08 Feb 2022 15:07:09 -0800 (PST) Received: from localhost.localdomain ([178.233.26.119]) by smtp.gmail.com with ESMTPSA id o3sm2573331edt.67.2022.02.08.15.07.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 15:07:08 -0800 (PST) From: Alper Nebi Yasak To: u-boot@lists.denx.de Cc: Heiko Thiery , Jan Kiszka , Simon Glass , Alper Nebi Yasak Subject: [PATCH] binman: Skip processing "hash" subnodes of FIT subsections Date: Wed, 9 Feb 2022 02:06:55 +0300 Message-Id: <20220208230656.43504-1-alpernebiyasak@gmail.com> X-Mailer: git-send-email 2.34.1 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.5 at phobos.denx.de X-Virus-Status: Clean Binman's FIT entry type can have image subentries with "hash" subnodes intended to be processed by mkimage, but not binman. However, the Entry class and any subclass that reuses its implementation tries to process these unconditionally. This can lead to an error when boards specify hash algorithms that binman doesn't support, but mkimage supports. Let entries skip processing these "hash" subnodes based on an instance variable, and set this instance variable for FIT subsections. Also re-enable processing of calculated and missing properties of FIT entries which was disabled to mitigate this issue. Signed-off-by: Alper Nebi Yasak --- This applies on top of u-boot-dm/master, and does not resend my "binman: Update image positions of FIT subentries" patch [1] which should be applied on top of this. [1] https://patchwork.ozlabs.org/project/uboot/patch/20220207220809.4497-6-alpernebiyasak@gmail.com/ tools/binman/entry.py | 15 +++++++++++---- tools/binman/etype/fit.py | 12 ++---------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/tools/binman/entry.py b/tools/binman/entry.py index dc26f8f167b0..6f98353c8569 100644 --- a/tools/binman/entry.py +++ b/tools/binman/entry.py @@ -78,6 +78,8 @@ class Entry(object): external: True if this entry contains an external binary blob bintools: Bintools used by this entry (only populated for Image) missing_bintools: List of missing bintools for this entry + update_hash: True if this entry's "hash" subnode should be + updated with a hash of the entry contents """ def __init__(self, section, etype, node, name_prefix=''): # Put this here to allow entry-docs and help to work without libfdt @@ -111,6 +113,7 @@ def __init__(self, section, etype, node, name_prefix=''): self.allow_fake = False self.bintools = {} self.missing_bintools = [] + self.update_hash = True @staticmethod def FindEntryClass(etype, expanded): @@ -315,9 +318,11 @@ def AddMissingProperties(self, have_image_pos): if self.compress != 'none': state.AddZeroProp(self._node, 'uncomp-size') - err = state.CheckAddHashProp(self._node) - if err: - self.Raise(err) + + if self.update_hash: + err = state.CheckAddHashProp(self._node) + if err: + self.Raise(err) def SetCalculatedProperties(self): """Set the value of device-tree properties calculated by binman""" @@ -333,7 +338,9 @@ def SetCalculatedProperties(self): state.SetInt(self._node, 'orig-size', self.orig_size, True) if self.uncomp_size is not None: state.SetInt(self._node, 'uncomp-size', self.uncomp_size) - state.CheckSetHashValue(self._node, self.GetData) + + if self.update_hash: + state.CheckSetHashValue(self._node, self.GetData) def ProcessFdt(self, fdt): """Allow entries to adjust the device tree diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py index a56b0564f9a1..a979d0f1a613 100644 --- a/tools/binman/etype/fit.py +++ b/tools/binman/etype/fit.py @@ -186,6 +186,8 @@ def _AddNode(base_node, depth, node): # 'data' property later. entry = Entry.Create(self.section, node, etype='section') entry.ReadNode() + # The hash subnodes here are for mkimage, not binman. + entry.update_hash = False self._entries[rel_path] = entry for subnode in node.subnodes: @@ -294,13 +296,3 @@ def _BuildInput(self, fdt): def AddBintools(self, tools): super().AddBintools(tools) self.mkimage = self.AddBintool(tools, 'mkimage') - - def AddMissingProperties(self, have_image_pos): - # We don't want to interfere with any hash properties in the FIT, so - # disable this for now. - pass - - def SetCalculatedProperties(self): - # We don't want to interfere with any hash properties in the FIT, so - # disable this for now. - pass