From patchwork Tue Sep 30 23:25:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 456 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274809; bh=kRjWts1h24GTjH64etKFAYZC20Vdm8MAzD0Pw8DzK2I=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=gjUKvHIzYkACdbrkZdXqn0hw0KZ1H0yXkGge18hk/NBVeAPm88pOTk05lP803j50u fbCyRHon9H7OB1sd9aqxBGbe63znjEpJwUPLDBD6hp02oiixT7mg7tV9R2ebrrpRTL +4SxNPDBWc3vteAYDGapNRt+CtSxW1nh+4TB4L3w4gO8XS7bzKRNzJ/FcEF9Do3e8c BDexgZfPXZtc1UN91L3cyHqQI4yWrVdO+9k1/noHjq12VEMFvwsYV20XgnlubPNfZY s5TWwi8CzCHUbuJ9MwyTcJ+L1oBL6OHCTRewZM+Ln2BcqUehfGo329z+qvOCPR/6cX lCkLEHWhDosbw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2BEF867E7F for ; Tue, 30 Sep 2025 17:26:49 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id jKZt1gt2zFPu for ; Tue, 30 Sep 2025 17:26:49 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274809; bh=kRjWts1h24GTjH64etKFAYZC20Vdm8MAzD0Pw8DzK2I=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=gjUKvHIzYkACdbrkZdXqn0hw0KZ1H0yXkGge18hk/NBVeAPm88pOTk05lP803j50u fbCyRHon9H7OB1sd9aqxBGbe63znjEpJwUPLDBD6hp02oiixT7mg7tV9R2ebrrpRTL +4SxNPDBWc3vteAYDGapNRt+CtSxW1nh+4TB4L3w4gO8XS7bzKRNzJ/FcEF9Do3e8c BDexgZfPXZtc1UN91L3cyHqQI4yWrVdO+9k1/noHjq12VEMFvwsYV20XgnlubPNfZY s5TWwi8CzCHUbuJ9MwyTcJ+L1oBL6OHCTRewZM+Ln2BcqUehfGo329z+qvOCPR/6cX lCkLEHWhDosbw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 16C9367E2E for ; Tue, 30 Sep 2025 17:26:49 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274806; bh=jq6pVu2REfwOs8m85xG58M/pVnh7Wo+CKlEBT80FGiA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M+BWhRZH20B4i+o86RfZstpkn3dnv4JTBHGMm4u6Iw/AuHy0LV2pbVit8GsC1HBeK uxQy6lf54zS9Qhc3hjG20VdguOoOn3llRK3JDj1GuJncStKJynsooanH2V1TxzUQiW wkzq2bGyVT6JknTZRWs+ISX9p5n93g4uY4pso5f6se8QNrDWGZNQhUPDonnOi8fshs GCMeRL5SRP7Y8l00fX4hcF1RaYXAGufz6Jy54Qjz+4ZcVvZ7tbTC8/Hgp4zW5vBjO3 UgawRiVU8ExwcBdcRY+sbnERRudaK0GyHXi5XSUmxMo1v6dcl0DOVgjUyuefa3nK43 LZuVb68yoHDZA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 198EE67B5E; Tue, 30 Sep 2025 17:26:46 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id yPDAmd-xfZKS; Tue, 30 Sep 2025 17:26:46 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274802; bh=UD+OObYKa1yXIf5qX6bBC88W8RsQHLiJFEhIE3Mg7A8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mwKdW7RD+g1P0Pl4GNelwgniKZZyHe7Yt5O+roGPCSRdyaYNmKfYBRsxbiaAcpqPO KHo7uU3uT+h5NI6tcRIT5dAJG3SP3WLiP2XyFHP185x4tZekyqVCtRkVACZ0buA+67 PLsHu7PbiJv92wZPu/9YIhQNo2ivTE5ZcFpHgFTqTdf9QWeS1Wc2MPIPG4H+IoW3zl hklqifDZzD/MYKhGMSCy5MEN2g4klmT7p4+KL6anirNilnj8vje88YpCrSHbWbU4GA H7u/a1bcmK4Bdp5Ul4ekJZEE/exd8TICo1W4/eR4cnkLDDPzEJ/7eofdp3EcgHuJl3 h1h+3bKY7exZw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id BF43467E2E; Tue, 30 Sep 2025 17:26:41 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 30 Sep 2025 17:25:42 -0600 Message-ID: <20250930232611.1564850-6-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250930232611.1564850-1-sjg@u-boot.org> References: <20250930232611.1564850-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: SWQCZEGA22JMU2P5UA7RZ6X4ZYVBTMTZ X-Message-ID-Hash: SWQCZEGA22JMU2P5UA7RZ6X4ZYVBTMTZ X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH v2 05/15] boot: Update first_glob_method when dropping a bootmeth List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass For now we only support dropping non-global bootmeths from the iteration. Update first_glob_method in that case and add a few checks that things are correct. Signed-off-by: Simon Glass --- (no changes since v1) boot/bootflow.c | 6 ++++++ test/boot/bootflow.c | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/boot/bootflow.c b/boot/bootflow.c index de86f196503..dab4397e5eb 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -169,11 +169,17 @@ int bootflow_iter_drop_bootmeth(struct bootflow_iter *iter, iter->method_order[iter->cur_method] != bmeth) return -EINVAL; + log_debug("Dropping bootmeth '%s'\n", bmeth->name); + memmove(&iter->method_order[iter->cur_method], &iter->method_order[iter->cur_method + 1], (iter->num_methods - iter->cur_method - 1) * sizeof(void *)); iter->num_methods--; + if (iter->first_glob_method > 0) { + iter->first_glob_method--; + log_debug("first_glob_method %d\n", iter->first_glob_method); + } return 0; } diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index 69a965dfa4b..7748a5ad534 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -521,7 +521,11 @@ static int bootflow_iter_disable(struct unit_test_state *uts) /* Try to boot the bootmgr flow, which will fail */ console_record_reset_enable(); ut_assertok(bootflow_scan_first(NULL, NULL, &iter, 0, &bflow)); + + /* at this point the global bootmeths are stranded above num_methods */ ut_asserteq(4, iter.num_methods); + ut_assert(!iter.doing_global); + ut_asserteq(4, iter.first_glob_method); ut_asserteq_str("sandbox", iter.method->name); ut_assertok(inject_response(uts)); ut_asserteq(-ENOTSUPP, bootflow_run_boot(&iter, &bflow)); @@ -531,9 +535,13 @@ static int bootflow_iter_disable(struct unit_test_state *uts) /* Check that the sandbox bootmeth has been removed */ ut_asserteq(3, iter.num_methods); + for (i = 0; i < iter.num_methods; i++) ut_assert(strcmp("sandbox", iter.method_order[i]->name)); + /* the first global bootmeth is now down one place in the list */ + ut_asserteq(3, iter.first_glob_method); + return 0; } BOOTSTD_TEST(bootflow_iter_disable, UTF_DM | UTF_SCAN_FDT | UTF_CONSOLE);