From patchwork Tue Sep 30 00:51:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 442 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=1759193536; bh=nUnuQkweADJ2xdjPDsjxrzQ0noYj45fpl1BlrKIgJlw=; 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=LjJa6UemWx5LJtirqOuy72lKYF3AG4OOmX+c7SxRFWBI3M3gS6UgohQ7P1wzZlI6q Mcv0Cg55V9uCmuZIjNOqdy52RXsgC46gen51Aezsg9OJNMz9u2QaWnrWv4kQLMpSoI z0Tk/uwOGtOwnImqd1EsotzOrULk7L+TBw9RfSWgPcBBxIbnTQKzcc0QD+TZsBQqSO 5h4XG0O/7I7xZFt/1c1Pzblre21WxTy0jvLfZUoeKDAWfXHquTqD8Ab+5gJOqPjR3h mPqy9OJQjnOUqFyE+XU9WHr9w2C6tZ6+lWaET4RlA3bJLVzydtiesx33wTrL5gAGLF LdV5WUwwZTSdQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 71E3D67E74 for ; Mon, 29 Sep 2025 18:52:16 -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 2RhF0HUP0zbd for ; Mon, 29 Sep 2025 18:52:16 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193534; bh=nUnuQkweADJ2xdjPDsjxrzQ0noYj45fpl1BlrKIgJlw=; 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=Pd+7tgLwxbofT2y3/S0seNcgfFIsTnqRfe2sQoyxo6XViRThuPQPkS+zkiOJEJv/R HWfAdMGtMECLr/jdCbpTC29M8TA9t5CP1TWG9smOa8+g3BfbkjIrIkFve3gdS4sDWk S1uWMx0REjwyLW466bO4mBH9nfB3iGlOCKQ2rL7o6sRYxawQm1wc612dSV3qxUVs4z ELN4efB/35M0IRkOkeZR64g9vpIAvMqSvJBKuAeQZXA7eEPaxLweRQXb6EcKwB122E He8E+v6e5aYA3RJ5pMnxm24KR+BQz/lHyyYI14pppaHVYiNwwz4iJtuFmEjNn/whaB pu8KhJeLBvKYQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7045567E57 for ; Mon, 29 Sep 2025 18:52:14 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193531; bh=s964LfQ17sNehmyc5aNNBfEUPqLupQhkulQkXwo07Nc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OBkFQo9S4fUTJGf+p0kiHh8Ykndoyj6T5iwpLqIB42CQZLmp6mobfgegazFqJmmDd cAEkEMgcv7MifGWOjCeNy3O6jZzzAkki1DjX6Qmtcfw1jgrhO5fwVLkjO/PBLs19QT xLDyOz0VX/JB7mt4OyphP07te7iC4KD1Lnn7yNBsn2o5c0LubHO4KXe8AxtrHN37BZ ErYXCpMovp4BZYg3vYs/eYcZbqT+bOXGOI1rVVXbKeaGHv/eTpOjstz0MJg8tVXL8y 6QDLhdZFG/y18+aqKpKk7FiSObQfT/mugAgqwulQKXijnZ3x84KOv/OHJgGiQpJUIe xmWuQU05bhESw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7690D67E31; Mon, 29 Sep 2025 18:52:11 -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 wOC2MqvGyZ7v; Mon, 29 Sep 2025 18:52:11 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193523; bh=rG+3HMPBhRS5z/Sh4kvEjZvN2eHJ4L7I6d5f8vo46uc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mNcmIopBZyaoAP7VIPeSUZQgUTdFmlDP01sfryB1h/hLI2HFci+ztv8sxzBeUPWGO +ndEg6HvxRREzt6/S7w2efWVbnSUvwE9903HkQHFVZ+Ywb90UKoMcypNYNvvelrLd6 bX2ODn9GCBimUO86xIidCJ7hqRSrVIvhicYed1UoZFU/7rQyvJADtZnFYqQOqfjDxD tip8MlcOlSq2olvYSuSVstS8XG2KRxzaw3x26n7A4MM8g6lxjEcbzApmLisXPvBFLM jiBkIC5RMgZdNmLZ7y8TAcg1cz0Eid4c/rqZJCtM+bhlVitboJ+NodcqfGcngUVnaG BQpqlhP2x2Q2g== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 93F7D67B49; Mon, 29 Sep 2025 18:52:03 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 29 Sep 2025 18:51:21 -0600 Message-ID: <20250930005137.3650600-6-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250930005137.3650600-1-sjg@u-boot.org> References: <20250930005137.3650600-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: AJBRORDIA35ZXGC3SW6S6QIW2VOPS263 X-Message-ID-Hash: AJBRORDIA35ZXGC3SW6S6QIW2VOPS263 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 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 --- 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 4e646202f3d..efe8aea765d 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -167,11 +167,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);