From patchwork Sat Sep 16 08:23:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Massimo Pegorer X-Patchwork-Id: 1835461 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=erLq8nxS; 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) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Rnkb85MB5z1yfd for ; Sat, 16 Sep 2023 18:23:16 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2ACD186504; Sat, 16 Sep 2023 10:23:08 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (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=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="erLq8nxS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4A6248650A; Sat, 16 Sep 2023 10:23:07 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) (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 6772A86503 for ; Sat, 16 Sep 2023 10:23:05 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=massimo.pegorer+oss@gmail.com Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-404573e6c8fso27868855e9.1 for ; Sat, 16 Sep 2023 01:23:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694852585; x=1695457385; darn=lists.denx.de; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:from:to:cc:subject:date:message-id:reply-to; bh=QuwLIPVk/uRNLcc2W3inuJxZwPuTgc431WKv7WAGimg=; b=erLq8nxSUO9R/dbklPee4Fy1dW8SNniwYNHmxap0KlaOMuLkLRLunLTBJZTmcIhu2r CS1DXoVRDUwYxry1VB3hZGZRi5HNWyXI8qiU4OOXM1PBJgo4QRqBUvpPVqlpvqc6kd7M QKhVk4Jqm7snUaLaQMWD74G3M7fLiATOxqV1Ie5bCJpiLfGymULdTAo58En8P+cTMVGf w8Tw0BcRCu/pCG80ZbEclVy0QBQsNBHL2m8we+AmKe2NNRVSOKZFoOunxglMRm1VEckP 6ZjS0XsUv8tjqw0J+iHyNKPjX0flepCtBNplZWpPUS/r5FNa0xnfBrPgStsXMem5rBlk UjNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694852585; x=1695457385; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=QuwLIPVk/uRNLcc2W3inuJxZwPuTgc431WKv7WAGimg=; b=p407rDXizc7ltXF7ZimanHBsNGUCcyGltvCXHbMPjeGyTbi3ilORbAG/HK/quoXv46 UdoIJrlEDblCoUT5nQVQgH4lIw9ay5tsefC6PxCXsZlwoidlFaaZU+Z5HyNAJDonxt1t YCtW/USqvjIkc2mapv9NNCXQhXFAc+lRAZmrcqmsPzNWzv+UnNvPgJLumFWa1uL7UA4m tmIDkp23ZSsbSfphP86YKYSD03FQdapNZPi+zDyqccAZJ/NO+7lDKrXagRCcKeaUnm5h kbcBop2ZOK46CtLKVq1IfnmeaWQMCQWxx81Kt0auIJmZwqcuc9mmulpMfnE2ptlA25mX tS3w== X-Gm-Message-State: AOJu0YyhsPywEJWfrdD2qnJM+80Eh+H4BmLvLiOWMs8x6HvMwRn6pAUJ CIiMmdin4+cqOCLwdFGKrdCsafXNwH4= X-Google-Smtp-Source: AGHT+IEDwQKLjK6/a4+dEn8AgWW211SALM3UZl646rx7yRhISlMLG6VkTKBBpk32wCvG1q4FT6E4Uw== X-Received: by 2002:a1c:6a0a:0:b0:3fa:77ed:9894 with SMTP id f10-20020a1c6a0a000000b003fa77ed9894mr3216138wmc.7.1694852584866; Sat, 16 Sep 2023 01:23:04 -0700 (PDT) Received: from pegmas-T15.fritz.box ([151.71.172.204]) by smtp.gmail.com with ESMTPSA id r4-20020adfdc84000000b0031753073abcsm6475794wrj.36.2023.09.16.01.23.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 01:23:04 -0700 (PDT) From: Massimo Pegorer To: u-boot@lists.denx.de, Simon Glass Cc: Michal Simek , Philipp Tomsich , Joseph Chen , Kever Yang , Massimo Pegorer Subject: [PATCH 1/4] spl: atf: Improve comments and code readability Date: Sat, 16 Sep 2023 10:23:01 +0200 Message-Id: <20230916082301.583248-1-massimo.pegorer+oss@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.8 at phobos.denx.de X-Virus-Status: Clean Rename bl31_entry static function to avoid name clash with its first argument. Fix spaces misuse. Describe code accurately: load address is used if getting entry point address fails, and not if addresses differ. Remove not up-to-date comment about BL3-2 usage. Signed-off-by: Massimo Pegorer Reviewed-by: Simon Glass --- common/spl/spl_atf.c | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/common/spl/spl_atf.c b/common/spl/spl_atf.c index 2c10252834..3d022ed4e7 100644 --- a/common/spl/spl_atf.c +++ b/common/spl/spl_atf.c @@ -189,10 +189,10 @@ static inline void raw_write_daif(unsigned int daif) typedef void (*atf_entry_t)(struct bl31_params *params, void *plat_params); -static void bl31_entry(uintptr_t bl31_entry, uintptr_t bl32_entry, - uintptr_t bl33_entry, uintptr_t fdt_addr) +static void spl_enter_atf(uintptr_t bl31_entry, uintptr_t bl32_entry, + uintptr_t bl33_entry, uintptr_t fdt_addr) { - atf_entry_t atf_entry = (atf_entry_t)bl31_entry; + atf_entry_t atf_entry = (atf_entry_t)bl31_entry; void *bl31_params; if (CONFIG_IS_ENABLED(ATF_LOAD_IMAGE_V2)) @@ -240,7 +240,7 @@ static int spl_fit_images_find(void *blob, int os) uintptr_t spl_fit_images_get_entry(void *blob, int node) { - ulong val; + ulong val; int ret; ret = fit_image_get_entry(blob, node, &val); @@ -253,25 +253,25 @@ uintptr_t spl_fit_images_get_entry(void *blob, int node) void spl_invoke_atf(struct spl_image_info *spl_image) { - uintptr_t bl32_entry = 0; - uintptr_t bl33_entry = CONFIG_TEXT_BASE; + uintptr_t bl32_entry = 0; + uintptr_t bl33_entry = CONFIG_TEXT_BASE; void *blob = spl_image->fdt_addr; uintptr_t platform_param = (uintptr_t)blob; int node; /* - * Find the OP-TEE binary (in /fit-images) load address or - * entry point (if different) and pass it as the BL3-2 entry - * point, this is optional. + * Find (in /fit-images) the TEE binary entry point address + * (or load address if entry point is missing) and pass it as + * the BL3-2 entry point. This is optional. */ node = spl_fit_images_find(blob, IH_OS_TEE); if (node >= 0) bl32_entry = spl_fit_images_get_entry(blob, node); /* - * Find the U-Boot binary (in /fit-images) load addreess or - * entry point (if different) and pass it as the BL3-3 entry - * point. + * Find (in /fit-images) the U-Boot binary entry point address + * (or load address if entry point is missing) and pass it as + * the BL3-3 entry point. * This will need to be extended to support Falcon mode. */ @@ -281,17 +281,13 @@ void spl_invoke_atf(struct spl_image_info *spl_image) /* * If ATF_NO_PLATFORM_PARAM is set, we override the platform - * parameter and always pass 0. This is a workaround for + * parameter and always pass 0. This is a workaround for * older ATF versions that have insufficiently robust (or * overzealous) argument validation. */ if (CONFIG_IS_ENABLED(ATF_NO_PLATFORM_PARAM)) platform_param = 0; - /* - * We don't provide a BL3-2 entry yet, but this will be possible - * using similar logic. - */ - bl31_entry(spl_image->entry_point, bl32_entry, - bl33_entry, platform_param); + spl_enter_atf(spl_image->entry_point, bl32_entry, + bl33_entry, platform_param); } From patchwork Sat Sep 16 08:23:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Massimo Pegorer X-Patchwork-Id: 1835462 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=DJc4RHyM; 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 4Rnkbr5kFYz1yfd for ; Sat, 16 Sep 2023 18:23:52 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 96C63862B6; Sat, 16 Sep 2023 10:23:50 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (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=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="DJc4RHyM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AC4CD864D7; Sat, 16 Sep 2023 10:23:49 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) (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 CCE3F86290 for ; Sat, 16 Sep 2023 10:23:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=massimo.pegorer+oss@gmail.com Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-3ff7d73a6feso32650215e9.1 for ; Sat, 16 Sep 2023 01:23:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694852627; x=1695457427; darn=lists.denx.de; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:from:to:cc:subject:date:message-id:reply-to; bh=SZNeA/n5BLBh9MFeKSb7P7kJHnSKo7n+M1NYBCHIGCk=; b=DJc4RHyMc4LKDHgwx5eMpg7zRs12TI8MQLDZ1CgeOX17XijhrAmsPd+Et1jcxb6BFs Lwii7JRYMpq7fG/yu59FXMuTBTVV4bf6dMHldKRMNtsU4JzWE9KucGYBpky3EXvdSbjx uWs6o3JPqw0NEh2gEhoZkmSj6DXfEMxsjCPjvdSk7Pk0MhDgWK/qN5M69268XomWfAKG R05dcUNbRwpeUz1VpbZUP1bOSi2fV5uWCvDA7AFNRAkR3S0W3dGE5Y/USSZZG8MLDsPB u+5qCfmwdD3U3t09MMtA/NtjLONqOHWKJfKosrxWZtUmgr+nnBD0Ex6OSdaYe3MqWWsR tAPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694852627; x=1695457427; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=SZNeA/n5BLBh9MFeKSb7P7kJHnSKo7n+M1NYBCHIGCk=; b=kLCvfoftCwJ5h8X9JF0mxqLF3Ds5LLfiuUe5G/DMYSmEK2Hqd0AwRS//130AniT+UU UFQ6/jaDryLxye6ikIMQZ2LsmoDsjQbQ9vnecCDEWxJFNwsFDCXxrEZMb3d4gGMEhWUI ic1H/W9X8tTQZR2NLynzrP8WjNKF3xWMjjxt0zyb3ATxmfBdEy+kAdK3ra881275ZL1E rjsgbsE381GIJJJ758ZU8YtdoAaTlfJ7GMmpEvihOsG7w9QF3IMkZz8iVdx+GgmjQ8QZ VdIN+QG0QwQeb+XxbKJi1yqUcnaIe/PNU5hznCjgo5uKbQJRfEyuyVjpl8RfbA+VoGRo nfgA== X-Gm-Message-State: AOJu0YyeW15jqSiku9g2/UfYf7O/TltZYgN6i4+kVgOJvD2d6WOcu1JR rx1awTvVjA3VScQcvnIM06wkjM2GOCU= X-Google-Smtp-Source: AGHT+IEWFaXNOhp+MRk1wF6Esl4AGNjcbqXxWwUX8UEh9PfsadaCWtHvrDtvGYichP5q3lgfdmg7qw== X-Received: by 2002:a05:600c:2299:b0:400:419c:bbde with SMTP id 25-20020a05600c229900b00400419cbbdemr3620040wmf.18.1694852626962; Sat, 16 Sep 2023 01:23:46 -0700 (PDT) Received: from pegmas-T15.fritz.box ([151.71.172.204]) by smtp.gmail.com with ESMTPSA id y5-20020a1c4b05000000b0040303a9965asm9542507wma.40.2023.09.16.01.23.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 01:23:46 -0700 (PDT) From: Massimo Pegorer To: u-boot@lists.denx.de, Simon Glass Cc: Heinrich Schuchardt , Massimo Pegorer Subject: [PATCH 2/4] image: fit: Improve functions description comments Date: Sat, 16 Sep 2023 10:23:44 +0200 Message-Id: <20230916082344.583308-1-massimo.pegorer+oss@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.8 at phobos.denx.de X-Virus-Status: Clean Load and entry addresses are returned in ulong variables, which are 32 or 64 bit depending on architecture. Specify that on failure these functions do not set memory pointed by load / entry argument: this detail is relavant for correct functions usage. Signed-off-by: Massimo Pegorer Reviewed-by: Simon Glass --- boot/image-fit.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/boot/image-fit.c b/boot/image-fit.c index 3cc556b727..7e87a513e7 100644 --- a/boot/image-fit.c +++ b/boot/image-fit.c @@ -869,10 +869,11 @@ static int fit_image_get_address(const void *fit, int noffset, char *name, * fit_image_get_load() - get load addr property for given component image node * @fit: pointer to the FIT format image header * @noffset: component image node offset - * @load: pointer to the uint32_t, will hold load address + * @load: pointer to ulong, will hold load address * * fit_image_get_load() finds load address property in a given component * image node. If the property is found, its value is returned to the caller. + * Otherwise, on failure, *load will be left untouched. * * returns: * 0, on success @@ -887,14 +888,11 @@ int fit_image_get_load(const void *fit, int noffset, ulong *load) * fit_image_get_entry() - get entry point address property * @fit: pointer to the FIT format image header * @noffset: component image node offset - * @entry: pointer to the uint32_t, will hold entry point address - * - * This gets the entry point address property for a given component image - * node. + * @entry: pointer to ulong, will hold entry point address * * fit_image_get_entry() finds entry point address property in a given - * component image node. If the property is found, its value is returned - * to the caller. + * component image node. If the property is found, its value is returned + * to the caller. Otherwise, on failure, *entry will be left untouched. * * returns: * 0, on success From patchwork Sat Sep 16 08:24:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Massimo Pegorer X-Patchwork-Id: 1835463 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=TizCIJug; 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 4RnkdN1qLzz1yhy for ; Sat, 16 Sep 2023 18:25:12 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1384D864D7; Sat, 16 Sep 2023 10:25:10 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (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=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="TizCIJug"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5EBC686538; Sat, 16 Sep 2023 10:25:08 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) (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 7E6E0862B6 for ; Sat, 16 Sep 2023 10:25:06 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=massimo.pegorer+oss@gmail.com Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-404571cbb8dso29325165e9.3 for ; Sat, 16 Sep 2023 01:25:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694852701; x=1695457501; darn=lists.denx.de; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:from:to:cc:subject:date:message-id:reply-to; bh=9tq2vHEeiO1F3TUExjOv1mbMVoQjoL8a94+M35YaAN8=; b=TizCIJug5LucuM0QGd0ZO5SzZ65I1IEE1ruzhsAaC+NZ/0sO/HWRzNuUiDDw9KaQFx 3GeE0DBDPuDxZMqfM1YPzs9VSzIUfUqB9RwHnBEu/LlggSQtYMzMMJwzOfEh9uL+2ztA pjMbkErJNyNtnIfPgMhI61sQ9iHgl2rjT3jIdIuyAQBUzvYEAdn94Y1YNt6awjXYTexT FZeNqMVdVMg4vBC380YDi4Mhb/ZT4VLVIZ8bPm7t4ajBDtkfGBXXt2vpxkLNWHeP2pLm I+/HmueCUpaR8yg0F9870CSYgP05CASG95K/74Y7v0inmXD8oqKeoj+4lgc4RzRUDcqb ym4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694852701; x=1695457501; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=9tq2vHEeiO1F3TUExjOv1mbMVoQjoL8a94+M35YaAN8=; b=nfh7V0U/+4t2CjCz/ePJbU87xQE8TSUdbQsodctRSYe5ZYJRp7udfx397Vh/78hBmI AAGVHvGuE34069A8d2FQhfp5DqXoF7qQ2yJtVfW1sO89uwwlVe+pkk5iTw3aXp3HIpPw UjiLTj164sMfhOhTOfWalIfo2Lf0w47M0LNrdPY4gsg0mNwtraEx6thHko4pfqrC04xO 2tFqVM1fKROdOsPhIrc29GD2/WBL+L0bmEr3nNo0K1JANmeJbNAoCOe2zh75knBpSb+Z GKCT94JRQja0Hsn3bteDSnA5ADH/UD57FspTKc1mV9UPIVGRwuLsRDX4TjKeDK++dnL6 RDCw== X-Gm-Message-State: AOJu0YzKNfi4MKT6HF//Z9sM4O/fj8bRvze/EAJzpYLzdO1a6qARDrpv b2tXrLfqF36EbKxbmHXhi3eg0XV2s1Q= X-Google-Smtp-Source: AGHT+IFpCDSJE2trC7Ohr+yzmFkADIUt26sF8sNp+FaekC8aYAVlzKlZ/wYeSr8vGEZ68awSLL9yiA== X-Received: by 2002:a05:600c:210c:b0:401:b1c6:97e8 with SMTP id u12-20020a05600c210c00b00401b1c697e8mr3584049wml.36.1694852700674; Sat, 16 Sep 2023 01:25:00 -0700 (PDT) Received: from pegmas-T15.fritz.box ([151.71.172.204]) by smtp.gmail.com with ESMTPSA id y6-20020a05600c364600b003fe2bea77ccsm6687183wmq.5.2023.09.16.01.24.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 01:25:00 -0700 (PDT) From: Massimo Pegorer To: u-boot@lists.denx.de, Simon Glass Cc: Michal Simek , Philipp Tomsich , Joseph Chen , Kever Yang , Massimo Pegorer Subject: [PATCH 3/4] spl: atf: Fix potential but not occurring bug Date: Sat, 16 Sep 2023 10:24:57 +0200 Message-Id: <20230916082457.583383-1-massimo.pegorer+oss@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.8 at phobos.denx.de X-Virus-Status: Clean Bug: function spl_fit_images_get_entry returns uninitialized variable val if both fit_image_get_entry() and fit_image_get_load() fail (note that both of them do not set val on failure). Fix: use val only if entry or load address has been retrieved successfully. Note: in real world a failure of fit_image_get_load() will make current SPL flow to break on loading images, see spl_load_fit_image(), before entering spl_invoke_atf(). Signed-off-by: Massimo Pegorer Reviewed-by: Simon Glass --- common/spl/spl_atf.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/common/spl/spl_atf.c b/common/spl/spl_atf.c index 3d022ed4e7..0d8db2d14e 100644 --- a/common/spl/spl_atf.c +++ b/common/spl/spl_atf.c @@ -238,17 +238,16 @@ static int spl_fit_images_find(void *blob, int os) return -FDT_ERR_NOTFOUND; } -uintptr_t spl_fit_images_get_entry(void *blob, int node) +void spl_fit_images_get_entry(void *blob, int node, uintptr_t *entry_p) { ulong val; - int ret; - ret = fit_image_get_entry(blob, node, &val); - if (ret) - ret = fit_image_get_load(blob, node, &val); + if (fit_image_get_entry(blob, node, &val)) + if (fit_image_get_load(blob, node, &val)) + return; debug("%s: entry point 0x%lx\n", __func__, val); - return val; + *entry_p = val; } void spl_invoke_atf(struct spl_image_info *spl_image) @@ -266,7 +265,7 @@ void spl_invoke_atf(struct spl_image_info *spl_image) */ node = spl_fit_images_find(blob, IH_OS_TEE); if (node >= 0) - bl32_entry = spl_fit_images_get_entry(blob, node); + spl_fit_images_get_entry(blob, node, &bl32_entry); /* * Find (in /fit-images) the U-Boot binary entry point address @@ -277,7 +276,7 @@ void spl_invoke_atf(struct spl_image_info *spl_image) node = spl_fit_images_find(blob, IH_OS_U_BOOT); if (node >= 0) - bl33_entry = spl_fit_images_get_entry(blob, node); + spl_fit_images_get_entry(blob, node, &bl33_entry); /* * If ATF_NO_PLATFORM_PARAM is set, we override the platform From patchwork Sat Sep 16 08:25:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Massimo Pegorer X-Patchwork-Id: 1835464 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=OAt5mbV4; 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 4RnkdW41ckz1yhy for ; Sat, 16 Sep 2023 18:25:19 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 767418658E; Sat, 16 Sep 2023 10:25:13 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (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=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="OAt5mbV4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 46F3386589; Sat, 16 Sep 2023 10:25:12 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 6A4348655E for ; Sat, 16 Sep 2023 10:25:10 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=massimo.pegorer+oss@gmail.com Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-401d80f4ef8so32208345e9.1 for ; Sat, 16 Sep 2023 01:25:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694852710; x=1695457510; darn=lists.denx.de; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:from:to:cc:subject:date:message-id:reply-to; bh=aI+9hJ/am1VvVJg/d4wjr8D70jZ36Dsvpo6y+ALITIY=; b=OAt5mbV4WNNE0GaP4sv7X5x+OMLr+FA/rsKdz1+WSHVZxuEi6i7V9MRedCIE3KP7Nq HIDturm84W+rdKmGuuwhUguEi73POPuS7ftE5DOXU1N4WH0cTWRNQ16KWREP/zOekodO 9Mt5M3Hs728c/rNhYOwphyWBLd3OfbY5HZEgZoCKPZc9snRkzpWVVI/Ax5764JbEhJKY oF2Q2EV/xrF73N+TrmesHqyt0pKEO6b7cYIwPg1kpPh2Rw7+pSe34A2nv22fVuoNVqs4 wj7mRcnILeCSixzzrGNHrEhIrvp6UnttZmrO8Z9JDeDh2uMpjZiQ0/DSbEiVVnskpwgZ eZHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694852710; x=1695457510; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=aI+9hJ/am1VvVJg/d4wjr8D70jZ36Dsvpo6y+ALITIY=; b=M4NQ4ZDZgoqvsa1NxVqSxy8xG1QkLM1ntBQ06phqxfmZNnoY1zUilXsAtRY1KEUyd5 DyCiz14Xu+Q3pctRHg/Z53Ha7FD483A8aqcVwjmkhiS87xiGAizqgT1VQRwKq56kt2O0 ZbGe2hTQvf751HhoeJmTXS4DyjNOz1K2x5a49ZJDhatk7CbSftooDb8Sc7x5ggFpEaCm 8q3iBE5/UgggQQijUpx6n3NFBfE7Fa+uVUThGEe5GYbuiG0s060GmDQR0KbR8CAAqO+y y24qWOxsHfz2ux997xGJRP2aZWf9FI4J0Yk6pfRzGXS0dKosahNHjyM/Jlj4Fr9gxosD oCqw== X-Gm-Message-State: AOJu0YyndyynceN9Q9yZcGxiQfCg2p3oXNgq+c6waGQCEbmCx+Q4c039 BugbE8v1IDKgCFBZ/8XBGC/ZTu6Fti4= X-Google-Smtp-Source: AGHT+IHNNlddU4QeQaQLgAthr4bfDEyPi0OqNXVyRz7+iI7unu75hQfc2NU9dmca8oz4Qs8A++B9RA== X-Received: by 2002:a7b:c44b:0:b0:401:b2c7:349d with SMTP id l11-20020a7bc44b000000b00401b2c7349dmr3869992wmi.29.1694852709810; Sat, 16 Sep 2023 01:25:09 -0700 (PDT) Received: from pegmas-T15.fritz.box ([151.71.172.204]) by smtp.gmail.com with ESMTPSA id 12-20020a05600c024c00b003fc06169ab3sm9480635wmj.20.2023.09.16.01.25.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 01:25:09 -0700 (PDT) From: Massimo Pegorer To: u-boot@lists.denx.de, Simon Glass Cc: Michal Simek , Philipp Tomsich , Joseph Chen , Kever Yang , Massimo Pegorer Subject: [PATCH 4/4] spl: atf: Reduce SPL code size Date: Sat, 16 Sep 2023 10:25:07 +0200 Message-Id: <20230916082507.583405-1-massimo.pegorer+oss@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.8 at phobos.denx.de X-Virus-Status: Clean Previous fix commit increases code size of a few bytes. This minor rework finally reduces SPL size of about 64-72 bytes (tested with buildman on several aarch64 boards). Signed-off-by: Massimo Pegorer Reviewed-by: Simon Glass --- common/spl/spl_atf.c | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/common/spl/spl_atf.c b/common/spl/spl_atf.c index 0d8db2d14e..fa79f73be2 100644 --- a/common/spl/spl_atf.c +++ b/common/spl/spl_atf.c @@ -209,7 +209,19 @@ static void spl_enter_atf(uintptr_t bl31_entry, uintptr_t bl32_entry, atf_entry(bl31_params, (void *)fdt_addr); } -static int spl_fit_images_find(void *blob, int os) +static void spl_fit_images_get_entry(void *blob, int node, uintptr_t *entry_p) +{ + ulong val; + + if (fit_image_get_entry(blob, node, &val)) + if (fit_image_get_load(blob, node, &val)) + return; + + debug("%s: entry point 0x%lx\n", __func__, val); + *entry_p = val; +} + +static int spl_fit_images_get_os_entry(void *blob, int os, uintptr_t *entry_p) { int parent, node, ndepth = 0; const void *data; @@ -231,41 +243,28 @@ static int spl_fit_images_find(void *blob, int os) if (!data) continue; - if (genimg_get_os_id(data) == os) - return node; + if (genimg_get_os_id(data) == os) { + spl_fit_images_get_entry(blob, node, entry_p); + return 0; + } }; return -FDT_ERR_NOTFOUND; } -void spl_fit_images_get_entry(void *blob, int node, uintptr_t *entry_p) -{ - ulong val; - - if (fit_image_get_entry(blob, node, &val)) - if (fit_image_get_load(blob, node, &val)) - return; - - debug("%s: entry point 0x%lx\n", __func__, val); - *entry_p = val; -} - void spl_invoke_atf(struct spl_image_info *spl_image) { uintptr_t bl32_entry = 0; uintptr_t bl33_entry = CONFIG_TEXT_BASE; void *blob = spl_image->fdt_addr; uintptr_t platform_param = (uintptr_t)blob; - int node; /* * Find (in /fit-images) the TEE binary entry point address * (or load address if entry point is missing) and pass it as * the BL3-2 entry point. This is optional. */ - node = spl_fit_images_find(blob, IH_OS_TEE); - if (node >= 0) - spl_fit_images_get_entry(blob, node, &bl32_entry); + spl_fit_images_get_os_entry(blob, IH_OS_TEE, &bl32_entry); /* * Find (in /fit-images) the U-Boot binary entry point address @@ -273,10 +272,7 @@ void spl_invoke_atf(struct spl_image_info *spl_image) * the BL3-3 entry point. * This will need to be extended to support Falcon mode. */ - - node = spl_fit_images_find(blob, IH_OS_U_BOOT); - if (node >= 0) - spl_fit_images_get_entry(blob, node, &bl33_entry); + spl_fit_images_get_os_entry(blob, IH_OS_U_BOOT, &bl33_entry); /* * If ATF_NO_PLATFORM_PARAM is set, we override the platform