From patchwork Tue Oct 22 12:00:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2000462 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=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=DPnF71al; 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 4XXrNv5wpvz1xvv for ; Tue, 22 Oct 2024 23:01:03 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AABE688F6C; Tue, 22 Oct 2024 14:00:45 +0200 (CEST) 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="DPnF71al"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1663488FD9; Tue, 22 Oct 2024 14:00:44 +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.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) (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 CF2B988F31 for ; Tue, 22 Oct 2024 14:00:40 +0200 (CEST) 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-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-5c9388a00cfso6046283a12.3 for ; Tue, 22 Oct 2024 05:00:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1729598439; x=1730203239; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PArxYUr4DF6xXohBaBZwVlmXu0h9YpEZfuQLCXw2Qlw=; b=DPnF71alcxbHLi9/epv+LWJlHB0YEIqP2mu8uuSDiuuxNx36Pu0g1wCvoevat8Ila+ +5Ec7IoVhvWfV2kW4qXxfRJtkQ6mhNuLG2rFj0qzfS9/I0Wn7UGJcAiHBcwj/2UM+Ver 0+vZW8KAGlENAe9hW0meMs0wc23QjA73viFeE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729598439; x=1730203239; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PArxYUr4DF6xXohBaBZwVlmXu0h9YpEZfuQLCXw2Qlw=; b=RqryohV46u6byUbBo4LW5dGm9iwnMksndY+UTpyvX8IkOFWaf1WHQ0V51AS3Zxh+BE DMlEREmDGT+eopvCqnfTPUefnDCt45EoYy8vL9nTTOWyF5AVOlonIVOrrKAqJysoz83/ drTWtdPztVVJAnId6lB84h1akfYmLnWAuY+R5m/nc05tZZCZbyfnbjP/grfYYnlBf9Dl Bgk6D010mBepxmfFP8yNoj7CbqyWKwTd9vEHXM+oY7CZ9K9yhZ+ZA9F2B1Uja86g8nsJ CCSlQochgUSM1a8LO1R0LzD6TB4e/7w1iD7/m1H1zoe6Rx4XdcU9dEbFYTKrQKDAjfcb WqbA== X-Gm-Message-State: AOJu0YwzVNdzXYkuJ9DZMkIWaq0IwcU8X6LgRp+iorKfO8s5qhSxWBny 0UlZnQHcfZqua3shOK5sarOUpp7XCx0VlvvT5UNvNQo6MZ/D/bpzjmOawnfH704aEc8AKiNm1oT yCnUZ X-Google-Smtp-Source: AGHT+IF0lK+wmGrH8O2SiZgINYYtsS5n7MJpTwDtyouONwMcQYKCemMmWjebUvGNtD6kCY7QWaS4/A== X-Received: by 2002:a05:6402:51c7:b0:5c9:6623:a11a with SMTP id 4fb4d7f45d1cf-5ca0ae81c14mr12563339a12.25.1729598437597; Tue, 22 Oct 2024 05:00:37 -0700 (PDT) Received: from chromium.org (43-114-103-145.static.glaslokaal.nl. [145.103.114.43]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cb66a6d0besm3083100a12.57.2024.10.22.05.00.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 05:00:35 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Ilias Apalodimas , Tom Rini , Simon Glass , AKASHI Takahiro , Mattijs Korpershoek Subject: [PATCH v8 1/8] test: boot: Update bootflow_iter() for console checking Date: Tue, 22 Oct 2024 14:00:22 +0200 Message-ID: <20241022120032.196311-2-sjg@chromium.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241022120032.196311-1-sjg@chromium.org> References: <20241022120032.196311-1-sjg@chromium.org> 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 This test checks console output so should have the UTF_CONSOLE flag. Add it. Signed-off-by: Simon Glass Acked-by: Heinrich Schuchardt --- (no changes since v1) test/boot/bootflow.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index 154dea70a59..cc894e804a4 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -370,7 +370,7 @@ static int bootflow_iter(struct unit_test_state *uts) return 0; } -BOOTSTD_TEST(bootflow_iter, UTF_DM | UTF_SCAN_FDT); +BOOTSTD_TEST(bootflow_iter, UTF_DM | UTF_SCAN_FDT | UTF_CONSOLE); #if defined(CONFIG_SANDBOX) && defined(CONFIG_BOOTMETH_GLOBAL) /* Check using the system bootdev */ From patchwork Tue Oct 22 12:00:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2000461 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=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=e0KjIe/d; 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) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XXrNh0Kphz1xvv for ; Tue, 22 Oct 2024 23:00:52 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4592C88FA5; Tue, 22 Oct 2024 14:00:43 +0200 (CEST) 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="e0KjIe/d"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3A56388969; Tue, 22 Oct 2024 14:00:42 +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.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) (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 388B288EBA for ; Tue, 22 Oct 2024 14:00:40 +0200 (CEST) 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-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-5c937b5169cso1242633a12.1 for ; Tue, 22 Oct 2024 05:00:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1729598439; x=1730203239; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4Bst1sWe8XbOnMYi1ko8v921/mS6aS27956726EYN64=; b=e0KjIe/dqMek15g4Eu06XQb4x5ruPhdBgg1qmsSfXrGMadKlVSz+nqcQTV6mfl8E/q xlaNHjU74hznLQyWxRgIL9z/keqPNT68HibWMA0JReBq1f1wV+cRy1RSILE+sqDQlbHX 3pAR09iwnIUXmwNNTjYqcOyrBhWnPbdt+isCI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729598439; x=1730203239; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4Bst1sWe8XbOnMYi1ko8v921/mS6aS27956726EYN64=; b=Aw/nYJdsm0vMArgehQPqvPFWi154UO3L4s5dtoa5PRBx+f1z703Kpz2f7/VY9M9WW2 972NHrmFXVyJVRCo6x94KTDSW6CDZy7Xyj/kjE528sjTSoNneWK31QFgW9G2Ba1+5wpg Ax1EIurUafGr9V3O47orK05TeO6zHjILTbcjzmtUXCQ60pcaFyjq+GSasxS2vPFAmRQ+ PSKTTOR5Fbdfs/GVmQqZA/i7lzNgcQieNq3z0huBoWkUTtsxGgCtYjfqrR9MAVXAMkfg Jc5BVMpUQc1b3X34/FFIo9i8v71N88LqyuDwlISk4M5FiNibX0UY72sfEuN1BovwD4O8 ZadA== X-Gm-Message-State: AOJu0YztPUwypR4v2/gvpjgPJJEmabGA8p5RnTOImspNZNBJToEoxIeR OLnh6vwUyczJL/6VLnSXTx8lelUcbHc0BbS69WWIp/3OXUu3+dFqVzuPFGj7n79QpTGziK+q0Im q0auy X-Google-Smtp-Source: AGHT+IEHFybJSvCAJERqKn12FaNmTdOpWq2h9dXn1SIzesJ/C8q5sjBGHavXUs2SNC1xlABsVy6cZw== X-Received: by 2002:a05:6402:5211:b0:5cb:83c0:dd69 with SMTP id 4fb4d7f45d1cf-5cb83c0e5c8mr1356107a12.12.1729598438491; Tue, 22 Oct 2024 05:00:38 -0700 (PDT) Received: from chromium.org (43-114-103-145.static.glaslokaal.nl. [145.103.114.43]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cb66a6d0besm3083100a12.57.2024.10.22.05.00.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 05:00:37 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Ilias Apalodimas , Tom Rini , Simon Glass , AKASHI Takahiro , Caleb Connolly , Michal Simek Subject: [PATCH v8 2/8] efi_loader: Add a test app Date: Tue, 22 Oct 2024 14:00:23 +0200 Message-ID: <20241022120032.196311-3-sjg@chromium.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241022120032.196311-1-sjg@chromium.org> References: <20241022120032.196311-1-sjg@chromium.org> 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 Add a simple app to use for testing. This is intended to do whatever it needs to for testing purposes. For now it just prints a message and exits boot services. There was a considerable amount of discussion about whether it is OK to call exit-boot-services and then return to U-Boot. This is not normally done in a real application, since exit-boot-services is used to completely disconnect from U-Boot. However, since this is a test, we need to check the results of running the app, so returning is necessary. It works correctly and it provides a nice model of how to test the EFI code in a simple way. Signed-off-by: Simon Glass --- (no changes since v7) Changes in v7: - Update commit message lib/efi_loader/Kconfig | 10 ++++++ lib/efi_loader/Makefile | 1 + lib/efi_loader/testapp.c | 68 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 lib/efi_loader/testapp.c diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index 69b2c9360d8..6ced29da719 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -565,6 +565,16 @@ config BOOTEFI_HELLO_COMPILE No additional space will be required in the resulting U-Boot binary when this option is enabled. +config BOOTEFI_TESTAPP_COMPILE + bool "Compile an EFI test app for testing" + default y + help + This compiles an app designed for testing. It is packed into an image + by the test.py testing frame in the setup_efi_image() function. + + No additional space will be required in the resulting U-Boot binary + when this option is enabled. + endif source "lib/efi/Kconfig" diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile index 00d18966f9e..87131ab911d 100644 --- a/lib/efi_loader/Makefile +++ b/lib/efi_loader/Makefile @@ -20,6 +20,7 @@ apps-$(CONFIG_EFI_LOAD_FILE2_INITRD) += initrddump ifeq ($(CONFIG_GENERATE_ACPI_TABLE),) apps-y += dtbdump endif +apps-$(CONFIG_BOOTEFI_TESTAPP_COMPILE) += testapp obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o obj-$(CONFIG_EFI_BOOTMGR) += efi_bootmgr.o diff --git a/lib/efi_loader/testapp.c b/lib/efi_loader/testapp.c new file mode 100644 index 00000000000..feb444c92e9 --- /dev/null +++ b/lib/efi_loader/testapp.c @@ -0,0 +1,68 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Hello world EFI application + * + * Copyright 2024 Google LLC + * Written by Simon Glass + * + * This test program is used to test the invocation of an EFI application. + * It writes a few messages to the console and then exits boot services + */ + +#include + +static const efi_guid_t loaded_image_guid = EFI_LOADED_IMAGE_PROTOCOL_GUID; + +static struct efi_system_table *systable; +static struct efi_boot_services *boottime; +static struct efi_simple_text_output_protocol *con_out; + +/** + * efi_main() - entry point of the EFI application. + * + * @handle: handle of the loaded image + * @systab: system table + * Return: status code + */ +efi_status_t EFIAPI efi_main(efi_handle_t handle, + struct efi_system_table *systab) +{ + struct efi_loaded_image *loaded_image; + efi_status_t ret; + efi_uintn_t map_size; + efi_uintn_t map_key; + efi_uintn_t desc_size; + u32 desc_version; + + systable = systab; + boottime = systable->boottime; + con_out = systable->con_out; + + /* Get the loaded image protocol */ + ret = boottime->open_protocol(handle, &loaded_image_guid, + (void **)&loaded_image, NULL, NULL, + EFI_OPEN_PROTOCOL_GET_PROTOCOL); + if (ret != EFI_SUCCESS) { + con_out->output_string + (con_out, u"Cannot open loaded image protocol\r\n"); + goto out; + } + + /* UEFI requires CR LF */ + con_out->output_string(con_out, u"U-Boot test app for EFI_LOADER\r\n"); + +out: + map_size = 0; + ret = boottime->get_memory_map(&map_size, NULL, &map_key, &desc_size, + &desc_version); + con_out->output_string(con_out, u"Exiting boot sevices\n"); + + /* exit boot services so that this part of U-Boot can be tested */ + boottime->exit_boot_services(handle, map_key); + + /* now exit for real */ + ret = boottime->exit(handle, ret, 0, NULL); + + /* We should never arrive here */ + return ret; +} From patchwork Tue Oct 22 12:00:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2000463 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=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=XDEfjwb6; 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 4XXrP61lyHz1xvv for ; Tue, 22 Oct 2024 23:01:14 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2261189251; Tue, 22 Oct 2024 14:00:46 +0200 (CEST) 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="XDEfjwb6"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8310288F4D; Tue, 22 Oct 2024 14:00:44 +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.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) (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 7444D88969 for ; Tue, 22 Oct 2024 14:00:42 +0200 (CEST) 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-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-5c94861ee25so2852622a12.0 for ; Tue, 22 Oct 2024 05:00:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1729598440; x=1730203240; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KwGmm8iwzbyyx/wxUS/qi5lpuro5bgSJ/kuI0eHHfXA=; b=XDEfjwb6CLrr6UqIuq+W0DlE7txg49DPlbX1oakAsx19NEOdbo/Ek46HFphSiaqZeE Y4qV7evfC5hZ6GdV12DyUPsgmjFIL666LyaOjl1q9WmJMf/L4bu4RAypm/qP3dGE+NBI oYBSP+HQm86GXQqhWrPKHrjNp3QYDG0CLKbBk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729598440; x=1730203240; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KwGmm8iwzbyyx/wxUS/qi5lpuro5bgSJ/kuI0eHHfXA=; b=qzl6FQTEOaecV33WAa7oJ5eJqXEuojOLYn3c84TO4oAd/qbJwgRBwfdptQdaF3sGrn z2P4AcAbPFwSNv70SMHnaiEJK6Oy2/8AFE1HuloHHnoBrm/shyqryWMUOtkXa7QrViLN 4zMEPX6Is+pVt4KHTCP/vCKm1xuDJWPKO6/U9i5bvX1r2DoL2lUYArdIVdTmEVe3L6B/ us3Dr2hfrVWhHDG58pA4jlL7ElfB1E2v5gmdtyg+NhN+6gFLN5/XcZAK7KvScMmRwamS aIHMaKpjmAjOoPprt2PlOt1fkzfXkK5N2G+AKWO3cUPEI+FsrKnAb97/3wbdR3T0nfu+ SOIQ== X-Gm-Message-State: AOJu0YyyiPe6gpuwbU0TDsnpazRxttJDsE6Avp479xx+eWqgKr8OwTL+ hacr80YgAUwDo1pXhVArwaQLkuDkiAShJSg6OHCykgrHQ7o47W7z4zhr4csnFfH+U1IBOK75cGW V+2pV X-Google-Smtp-Source: AGHT+IFW70j2fq8n8Ev+4ZXcKc4Q+rEGQf68uA7GEgITOCB4H4adrQETokmgQzPX72yXCsNRxj0IlA== X-Received: by 2002:a05:6402:4409:b0:5ca:d0d:6bb7 with SMTP id 4fb4d7f45d1cf-5ca0d0d715amr16333579a12.1.1729598439457; Tue, 22 Oct 2024 05:00:39 -0700 (PDT) Received: from chromium.org (43-114-103-145.static.glaslokaal.nl. [145.103.114.43]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cb66a6d0besm3083100a12.57.2024.10.22.05.00.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 05:00:38 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Ilias Apalodimas , Tom Rini , Simon Glass , AKASHI Takahiro , Caleb Connolly , Julien Masson , Masahisa Kojima , Mattijs Korpershoek , Shantur Rathore , =?utf-8?q?Vincent_Stehl=C3=A9?= Subject: [PATCH v8 3/8] efi: Move default filename to a function Date: Tue, 22 Oct 2024 14:00:24 +0200 Message-ID: <20241022120032.196311-4-sjg@chromium.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241022120032.196311-1-sjg@chromium.org> References: <20241022120032.196311-1-sjg@chromium.org> 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 Use a function to obtain the device EFI filename, so that we can control how sandbox behaves. Signed-off-by: Simon Glass --- Changes in v8: - Add new patch to move default filename to a function boot/Makefile | 4 +++- boot/bootmeth_efi.c | 4 ++-- include/efi_default_filename.h => boot/efi_fname.c | 11 +++++------ include/efi.h | 9 +++++++++ lib/efi_loader/efi_bootmgr.c | 10 +++++++--- test/boot/bootflow.c | 6 +++--- 6 files changed, 29 insertions(+), 15 deletions(-) rename include/efi_default_filename.h => boot/efi_fname.c (93%) diff --git a/boot/Makefile b/boot/Makefile index b24f806d5bf..d3f2c02068c 100644 --- a/boot/Makefile +++ b/boot/Makefile @@ -28,7 +28,7 @@ obj-$(CONFIG_$(PHASE_)BOOTSTD_PROG) += prog_boot.o obj-$(CONFIG_$(PHASE_)BOOTMETH_EXTLINUX) += bootmeth_extlinux.o obj-$(CONFIG_$(PHASE_)BOOTMETH_EXTLINUX_PXE) += bootmeth_pxe.o -obj-$(CONFIG_$(PHASE_)BOOTMETH_EFILOADER) += bootmeth_efi.o +obj-$(CONFIG_$(PHASE_)BOOTMETH_EFILOADER) += bootmeth_efi.o efi_fname.o obj-$(CONFIG_$(PHASE_)BOOTMETH_CROS) += bootm.o bootm_os.o bootmeth_cros.o obj-$(CONFIG_$(PHASE_)BOOTMETH_QFW) += bootmeth_qfw.o obj-$(CONFIG_$(PHASE_)BOOTMETH_SANDBOX) += bootmeth_sandbox.o @@ -40,6 +40,8 @@ obj-$(CONFIG_$(PHASE_)EXPO) += bootflow_menu.o obj-$(CONFIG_$(PHASE_)BOOTSTD) += bootflow_menu.o endif +obj-$(CONFIG_EFI_LOADER) += efi_fname.o + obj-$(CONFIG_$(PHASE_)OF_LIBFDT) += fdt_support.o obj-$(CONFIG_$(PHASE_)FDT_SIMPLEFB) += fdt_simplefb.o diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c index 2ad6d3b4ace..371b36d550b 100644 --- a/boot/bootmeth_efi.c +++ b/boot/bootmeth_efi.c @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include #include @@ -168,7 +168,7 @@ static int distro_efi_try_bootflow_files(struct udevice *dev, } strcpy(fname, EFI_DIRNAME); - strcat(fname, BOOTEFI_NAME); + strcat(fname, efi_get_basename()); if (bflow->blk) desc = dev_get_uclass_plat(bflow->blk); diff --git a/include/efi_default_filename.h b/boot/efi_fname.c similarity index 93% rename from include/efi_default_filename.h rename to boot/efi_fname.c index 77932984b55..a6b11383bba 100644 --- a/include/efi_default_filename.h +++ b/boot/efi_fname.c @@ -8,13 +8,9 @@ * Copyright (c) 2022, Linaro Limited */ -#ifndef _EFI_DEFAULT_FILENAME_H -#define _EFI_DEFAULT_FILENAME_H - +#include #include -#undef BOOTEFI_NAME - #ifdef CONFIG_SANDBOX #if HOST_ARCH == HOST_ARCH_X86_64 @@ -53,4 +49,7 @@ #endif -#endif +const char *efi_get_basename(void) +{ + return BOOTEFI_NAME; +} diff --git a/include/efi.h b/include/efi.h index 84640cf7b25..1b8093bd4d3 100644 --- a/include/efi.h +++ b/include/efi.h @@ -669,4 +669,13 @@ int efi_get_mmap(struct efi_mem_desc **descp, int *sizep, uint *keyp, */ void efi_show_tables(struct efi_system_table *systab); +/** + * efi_get_basename() - Get the default filename to use when loading + * + * E.g. this returns BOOTAA64.EFI for an aarch target + * + * Return: Default EFI filename + */ +const char *efi_get_basename(void); + #endif /* _LINUX_EFI_H */ diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c index a3aa2b8d1b9..cb9664c91a2 100644 --- a/lib/efi_loader/efi_bootmgr.c +++ b/lib/efi_loader/efi_bootmgr.c @@ -11,10 +11,10 @@ #include #include #include +#include #include #include #include -#include #include #include #include @@ -82,8 +82,12 @@ struct efi_device_path *expand_media_path(struct efi_device_path *device_path) &efi_simple_file_system_protocol_guid, &rem); if (handle) { if (rem->type == DEVICE_PATH_TYPE_END) { - full_path = efi_dp_from_file(device_path, - "/EFI/BOOT/" BOOTEFI_NAME); + char fname[30]; + + snprintf(fname, sizeof(fname), "/EFI/BOOT/%s", + efi_get_basename()); + full_path = efi_dp_from_file(device_path, fname); + } else { full_path = efi_dp_dup(device_path); } diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index cc894e804a4..539abe63ebe 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #ifdef CONFIG_SANDBOX #include @@ -184,8 +184,8 @@ static int bootflow_cmd_scan_e(struct unit_test_state *uts) ut_assert_nextline(" 3 efi media mmc 0 mmc1.bootdev.whole "); ut_assert_nextline(" ** No partition found, err=-2: No such file or directory"); ut_assert_nextline(" 4 extlinux ready mmc 1 mmc1.bootdev.part_1 /extlinux/extlinux.conf"); - ut_assert_nextline(" 5 efi fs mmc 1 mmc1.bootdev.part_1 /EFI/BOOT/" - BOOTEFI_NAME); + ut_assert_nextline(" 5 efi fs mmc 1 mmc1.bootdev.part_1 /EFI/BOOT/%s", + efi_get_basename()); ut_assert_skip_to_line("Scanning bootdev 'mmc0.bootdev':"); ut_assert_skip_to_line( From patchwork Tue Oct 22 12:00:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2000464 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=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=j7a8QWfe; 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 4XXrPM0YCWz1xvv for ; Tue, 22 Oct 2024 23:01:25 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 843A288FCF; Tue, 22 Oct 2024 14:00:47 +0200 (CEST) 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="j7a8QWfe"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 726438905F; Tue, 22 Oct 2024 14:00:45 +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.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) (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 1F76488F82 for ; Tue, 22 Oct 2024 14:00:43 +0200 (CEST) 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-lf1-x135.google.com with SMTP id 2adb3069b0e04-539f72c913aso6413289e87.1 for ; Tue, 22 Oct 2024 05:00:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1729598442; x=1730203242; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mDQTnVD57zTzzdd8Lp8++6fhuQQU+nwTWxx2H4CIMNg=; b=j7a8QWfectwiSBPDQqQzyc9/20MPQ8nE03tnkQoTEjsLMK8lm9SyMFmMj67w4PGuCR Rz3ug5B1CdUI1MsKP0H4armiWLa4T1N62ftwUB73NN2DRj/XVn5P9nxiHSFGvjkApgYn GSXJqkxAOV/XAHH25TikMDcGJV1RbSoiExlXI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729598442; x=1730203242; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mDQTnVD57zTzzdd8Lp8++6fhuQQU+nwTWxx2H4CIMNg=; b=PSAG5ILxXoSf9A+yUv+0AUp6jFG+MRg06/HvGGknjiV6UyYgEXyv26v9sAEzB5WXbL qPKwd4JcsS7bR/jvEvNRUH+2DZWQXzelAox/piPsFGipARHdWK0QgGjGHy0xK4aMtpAW Q5EQgCYY+2uAgPl/+WYSVA9zoHpp9CJTE0sCL/+MJws6gKrqO2mo5mIRxp3M9vAY/+8r KWbnv10r5NHzoiVOvxVoh0xcyXvRnkXtrFC/V91wAvxa1RMHoIPhWklDU1G2C5VCvi2p ICAL+m+XxcI1JFytNmHYZxltoXe1XixEMWsgfd0y2DXS3PV71Rqewz3YEjvOtba84Cfc NVrA== X-Gm-Message-State: AOJu0Ywro5OTIFkpUmloxjya9toSwsflJsxxPBn0sa7A4RNpyVhqyxBD 0orF4AXQqDJkvX+I/O+GAsVMTuqNpPd/73OMeGWbMjypWercaXXKzMhPObyXTOjcpOPpHPXuekj +RX77 X-Google-Smtp-Source: AGHT+IEzYrpgG4IcYhm8EM/PiH6muP0dL7eE70P7hJN+eXYNSBxFbGpaO7WxLwM8hbKJtz5141I3YA== X-Received: by 2002:a05:6512:2316:b0:533:711:35be with SMTP id 2adb3069b0e04-53a15229c20mr8007686e87.26.1729598441810; Tue, 22 Oct 2024 05:00:41 -0700 (PDT) Received: from chromium.org (43-114-103-145.static.glaslokaal.nl. [145.103.114.43]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cb66a6d0besm3083100a12.57.2024.10.22.05.00.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 05:00:39 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Ilias Apalodimas , Tom Rini , Simon Glass Subject: [PATCH v8 4/8] sandbox: Add a -N flag to control on-host behaviour Date: Tue, 22 Oct 2024 14:00:25 +0200 Message-ID: <20241022120032.196311-5-sjg@chromium.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241022120032.196311-1-sjg@chromium.org> References: <20241022120032.196311-1-sjg@chromium.org> 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 Sandbox is its own architecture, but sometimes we want to mimic the host architecture, e.g. when running an EFI app not built by U-Boot. Add a -N/--native flag which tells sandbox to reflect the architecture of the host. Signed-off-by: Simon Glass --- Changes in v8: - Add new patch to control on-host behaviour arch/sandbox/cpu/start.c | 10 ++++++++++ arch/sandbox/include/asm/state.h | 1 + 2 files changed, 11 insertions(+) diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c index 81752edc9f8..2940768cd1c 100644 --- a/arch/sandbox/cpu/start.c +++ b/arch/sandbox/cpu/start.c @@ -449,6 +449,16 @@ static void setup_ram_buf(struct sandbox_state *state) gd->ram_size = state->ram_size; } +static int sandbox_cmdline_cb_native(struct sandbox_state *state, + const char *arg) +{ + state->native = true; + + return 0; +} +SANDBOX_CMDLINE_OPT_SHORT(native, 'N', 0, + "Use native mode (host-based EFI boot filename)"); + void state_show(struct sandbox_state *state) { char **p; diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h index e7dc01759e8..dc21a623106 100644 --- a/arch/sandbox/include/asm/state.h +++ b/arch/sandbox/include/asm/state.h @@ -101,6 +101,7 @@ struct sandbox_state { bool disable_eth; /* Disable Ethernet devices */ bool disable_sf_bootdevs; /* Don't bind SPI flash bootdevs */ bool upl; /* Enable Universal Payload (UPL) */ + bool native; /* Adjust to reflect host arch */ /* Pointer to information for each SPI bus/cs */ struct sandbox_spi_info spi[CONFIG_SANDBOX_SPI_MAX_BUS] From patchwork Tue Oct 22 12:00:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2000465 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=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=hhLzoQ8W; 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 4XXrPX6Q95z1xvv for ; Tue, 22 Oct 2024 23:01:36 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F142588F8E; Tue, 22 Oct 2024 14:00:50 +0200 (CEST) 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="hhLzoQ8W"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C400C892AA; Tue, 22 Oct 2024 14:00:47 +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.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_FILL_THIS_FORM_SHORT autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) (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 E118988EBA for ; Tue, 22 Oct 2024 14:00:44 +0200 (CEST) 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-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-5c97c7852e8so6560416a12.1 for ; Tue, 22 Oct 2024 05:00:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1729598444; x=1730203244; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JI+nRjDslmW2Ljr5I/nJTo+p3Giei3MfIbkfguYWg4U=; b=hhLzoQ8WcPSAYx2JDQGzeG+dft+LYpugOfaZJfGCFmQT2Dd6P13xlB7hj3e+/wCndn StYuLiTQ+Zr6qy9P7s7oahygAAqLwMLj2MEFidvP8VTkvz+IJ+RmzroPABXJXELM/au0 4Pce1mytpzCdrDyUygo1CCBwjawAaay8weSS0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729598444; x=1730203244; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JI+nRjDslmW2Ljr5I/nJTo+p3Giei3MfIbkfguYWg4U=; b=jDzvNFF6ncqEAFwT+OD/a10fsdQ4/NcQa2Ii1nCjzzWSmyubD7m/oMWAtxFcgbTVAu i14+jbNl0wDjJew1/k/Uv2IuduN/aVbgfzNxpeG1PrtTqbXBPnk+fn5TsNEez5s68efU 6l+mxyxZUjasY6EUHo5wQqigDmBCnMMfOE8IR6N4QoZFYSXilL1v64h+v4UMSr6RYSXL 4Ag1jioe4Bb5lCxqT099j87T0IFop1oHZuymtZBnaeCEy4113PcsCN4bYj0TEFB8DNcZ RVK/Y0Xv5G7m+S2+bE6tujBISynZ8+inprrxUWBqPK6kgnArMNz3+bd8T8zsstJWbhjo m/sw== X-Gm-Message-State: AOJu0YzbX+p7Jt5XGBmJ+AEFiWF0zzV2yqqQ5dJJoWqjyr3W+wEb83Qy S7zuofyQPrtEZWEGjDn6Wq5jDl6gIBXiH/XIF1R7DDcO4lUFFy2GfemFFpAksWUg7vU/CTVXxHB Hd3bZ X-Google-Smtp-Source: AGHT+IEaTBFzygvCr5TB1S0TtZ0yaO8sKvZCf2pfdEEYDb00KrHO9Kn4VNgEhSD2yWd2RxFepltzUA== X-Received: by 2002:a05:6402:2745:b0:5c8:845b:c4a4 with SMTP id 4fb4d7f45d1cf-5ca0af827dcmr13836034a12.31.1729598443651; Tue, 22 Oct 2024 05:00:43 -0700 (PDT) Received: from chromium.org (43-114-103-145.static.glaslokaal.nl. [145.103.114.43]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cb66a6d0besm3083100a12.57.2024.10.22.05.00.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 05:00:42 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Ilias Apalodimas , Tom Rini , Simon Glass , AKASHI Takahiro , Caleb Connolly , Masahisa Kojima , Mattijs Korpershoek , Shantur Rathore , =?utf-8?q?Vincent_Stehl=C3=A9?= Subject: [PATCH v8 5/8] sandbox: Report host default-filename in native mode Date: Tue, 22 Oct 2024 14:00:26 +0200 Message-ID: <20241022120032.196311-6-sjg@chromium.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241022120032.196311-1-sjg@chromium.org> References: <20241022120032.196311-1-sjg@chromium.org> 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 When the --native flag is given, pretend to be running the host architecture rather than sandbox. Add an 'efidebug filename' command to report it. Signed-off-by: Simon Glass --- Changes in v8: - Add new patch to report host default-filename in native mode boot/bootmeth_efi.c | 25 ++------------------ boot/efi_fname.c | 57 +++++++++++++++++++++++++++++++++------------ cmd/efidebug.c | 25 ++++++++++++++++++++ include/efi.h | 25 ++++++++++++++++++++ 4 files changed, 94 insertions(+), 38 deletions(-) diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c index 371b36d550b..f836aa655f5 100644 --- a/boot/bootmeth_efi.c +++ b/boot/bootmeth_efi.c @@ -25,32 +25,11 @@ #define EFI_DIRNAME "/EFI/BOOT/" -static int get_efi_pxe_arch(void) -{ - /* http://www.iana.org/assignments/dhcpv6-parameters/dhcpv6-parameters.xml */ - if (IS_ENABLED(CONFIG_ARM64)) - return 0xb; - else if (IS_ENABLED(CONFIG_ARM)) - return 0xa; - else if (IS_ENABLED(CONFIG_X86_64)) - return 0x6; - else if (IS_ENABLED(CONFIG_X86)) - return 0x7; - else if (IS_ENABLED(CONFIG_ARCH_RV32I)) - return 0x19; - else if (IS_ENABLED(CONFIG_ARCH_RV64I)) - return 0x1b; - else if (IS_ENABLED(CONFIG_SANDBOX)) - return 0; /* not used */ - - return -EINVAL; -} - static int get_efi_pxe_vci(char *str, int max_len) { int ret; - ret = get_efi_pxe_arch(); + ret = efi_get_pxe_arch(); if (ret < 0) return ret; @@ -239,7 +218,7 @@ static int distro_efi_read_bootflow_net(struct bootflow *bflow) ret = get_efi_pxe_vci(str, sizeof(str)); if (ret) return log_msg_ret("vci", ret); - ret = get_efi_pxe_arch(); + ret = efi_get_pxe_arch(); if (ret < 0) return log_msg_ret("arc", ret); arch = ret; diff --git a/boot/efi_fname.c b/boot/efi_fname.c index a6b11383bba..790f9e2fa36 100644 --- a/boot/efi_fname.c +++ b/boot/efi_fname.c @@ -9,29 +9,34 @@ */ #include +#include #include -#ifdef CONFIG_SANDBOX - #if HOST_ARCH == HOST_ARCH_X86_64 -#define BOOTEFI_NAME "BOOTX64.EFI" +#define HOST_BOOTEFI_NAME "BOOTX64.EFI" +#define HOST_PXE_ARCH 0x6 #elif HOST_ARCH == HOST_ARCH_X86 -#define BOOTEFI_NAME "BOOTIA32.EFI" +#define HOST_BOOTEFI_NAME "BOOTIA32.EFI" +#define HOST_PXE_ARCH 0x7 #elif HOST_ARCH == HOST_ARCH_AARCH64 -#define BOOTEFI_NAME "BOOTAA64.EFI" +#define HOST_BOOTEFI_NAME "BOOTAA64.EFI" +#define HOST_PXE_ARCH 0xb #elif HOST_ARCH == HOST_ARCH_ARM -#define BOOTEFI_NAME "BOOTARM.EFI" +#define HOST_BOOTEFI_NAME "BOOTARM.EFI" +#define HOST_PXE_ARCH 0xa #elif HOST_ARCH == HOST_ARCH_RISCV32 -#define BOOTEFI_NAME "BOOTRISCV32.EFI" +#define HOST_BOOTEFI_NAME "BOOTRISCV32.EFI" +#define HOST_PXE_ARCH 0x19 #elif HOST_ARCH == HOST_ARCH_RISCV64 -#define BOOTEFI_NAME "BOOTRISCV64.EFI" +#define HOST_BOOTEFI_NAME "BOOTRISCV64.EFI" +#define HOST_PXE_ARCH 0x1b #else -#error Unsupported UEFI architecture +#error Unsupported Host architecture #endif -#else - -#if defined(CONFIG_ARM64) +#if defined(CONFIG_SANDBOX) +#define BOOTEFI_NAME "BOOTSBOX.EFI" +#elif defined(CONFIG_ARM64) #define BOOTEFI_NAME "BOOTAA64.EFI" #elif defined(CONFIG_ARM) #define BOOTEFI_NAME "BOOTARM.EFI" @@ -47,9 +52,31 @@ #error Unsupported UEFI architecture #endif -#endif - const char *efi_get_basename(void) { - return BOOTEFI_NAME; + return efi_use_host_arch() ? HOST_BOOTEFI_NAME : BOOTEFI_NAME; +} + +int efi_get_pxe_arch(void) +{ + if (efi_use_host_arch()) + return HOST_PXE_ARCH; + + /* http://www.iana.org/assignments/dhcpv6-parameters/dhcpv6-parameters.xml */ + if (IS_ENABLED(CONFIG_ARM64)) + return 0xb; + else if (IS_ENABLED(CONFIG_ARM)) + return 0xa; + else if (IS_ENABLED(CONFIG_X86_64)) + return 0x6; + else if (IS_ENABLED(CONFIG_X86)) + return 0x7; + else if (IS_ENABLED(CONFIG_ARCH_RV32I)) + return 0x19; + else if (IS_ENABLED(CONFIG_ARCH_RV64I)) + return 0x1b; + else if (IS_ENABLED(CONFIG_SANDBOX)) + return 0; /* not used */ + + return -EINVAL; } diff --git a/cmd/efidebug.c b/cmd/efidebug.c index e040fe75fa1..02f1e080e88 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -511,6 +511,27 @@ static int do_efi_show_images(struct cmd_tbl *cmdtp, int flag, return CMD_RET_SUCCESS; } +/** + * do_efi_show_defaults() - show UEFI default filename and PXE architecture + * + * @cmdtp: Command table + * @flag: Command flag + * @argc: Number of arguments + * @argv: Argument array + * Return: CMD_RET_SUCCESS on success, CMD_RET_RET_FAILURE on failure + * + * Implement efidebug "defaults" sub-command. + * Shows the default EFI filename and PXE architecture + */ +static int do_efi_show_defaults(struct cmd_tbl *cmdtp, int flag, + int argc, char *const argv[]) +{ + printf("Default boot path: EFI\\BOOT\\%s\n", efi_get_basename()); + printf("PXE arch: 0x%02x\n", efi_get_pxe_arch()); + + return CMD_RET_SUCCESS; +} + static const char * const efi_mem_type_string[] = { [EFI_RESERVED_MEMORY_TYPE] = "RESERVED", [EFI_LOADER_CODE] = "LOADER CODE", @@ -1561,6 +1582,8 @@ static struct cmd_tbl cmd_efidebug_sub[] = { "", ""), U_BOOT_CMD_MKENT(dh, CONFIG_SYS_MAXARGS, 1, do_efi_show_handles, "", ""), + U_BOOT_CMD_MKENT(defaults, CONFIG_SYS_MAXARGS, 1, do_efi_show_defaults, + "", ""), U_BOOT_CMD_MKENT(images, CONFIG_SYS_MAXARGS, 1, do_efi_show_images, "", ""), U_BOOT_CMD_MKENT(memmap, CONFIG_SYS_MAXARGS, 1, do_efi_show_memmap, @@ -1653,6 +1676,8 @@ U_BOOT_LONGHELP(efidebug, " - show UEFI drivers\n" "efidebug dh\n" " - show UEFI handles\n" + "efidebug defaults\n" + " - show default EFI filename and PXE architecture\n" "efidebug images\n" " - show loaded images\n" "efidebug memmap\n" diff --git a/include/efi.h b/include/efi.h index 1b8093bd4d3..70bb47e742f 100644 --- a/include/efi.h +++ b/include/efi.h @@ -678,4 +678,29 @@ void efi_show_tables(struct efi_system_table *systab); */ const char *efi_get_basename(void); +#ifdef CONFIG_SANDBOX +#include +#endif + +static inline bool efi_use_host_arch(void) +{ +#ifdef CONFIG_SANDBOX + struct sandbox_state *state = state_get_current(); + + return state->native; +#else + return false; +#endif +} + +/** + * efi_get_pxe_arch() - Get the architecture value for PXE + * + * See: + * http://www.iana.org/assignments/dhcpv6-parameters/dhcpv6-parameters.xml + * + * Return: Architecture value + */ +int efi_get_pxe_arch(void); + #endif /* _LINUX_EFI_H */ From patchwork Tue Oct 22 12:00:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2000466 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=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=OdhhVer6; 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 4XXrPl3ybCz1xvv for ; Tue, 22 Oct 2024 23:01:47 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5F0EC88F50; Tue, 22 Oct 2024 14:00:52 +0200 (CEST) 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="OdhhVer6"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8347989056; Tue, 22 Oct 2024 14:00:51 +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.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) (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 8889888EEB for ; Tue, 22 Oct 2024 14:00:46 +0200 (CEST) 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-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-5c94c4ad9d8so7141003a12.2 for ; Tue, 22 Oct 2024 05:00:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1729598445; x=1730203245; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kzWagHBBz3KBiquXdYdA9F9aQZ11VSxRtZTZmBlZBms=; b=OdhhVer6L1EBiDHJail+7JSXulrgRvWumgOPPV//d8u56ci9xQjiQDCAocgI/DlOWn e38M7JO1S4sKs/t2f72AKJ3ho4jBWo6/9g+7NFLhVKmFL1pyWUN4oigVrbJlnBf8zGtP 0O5PN2zipoJFBirFA9vMpLeFsAdsR40WWyPeg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729598445; x=1730203245; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kzWagHBBz3KBiquXdYdA9F9aQZ11VSxRtZTZmBlZBms=; b=pPzYbMxj3Z/c42Tcr84P/TK6bJcEGpgnhZ/16M37URnzmMU1GXcMWd2l6tYajzU8qG QmiwPY/qcU08io5MSKKbSO8Lucdm0eWsksIKl3c6FLjivLuCeuFiV6m3YBNTlmxeY/GT K0j1scXgvnJjvrzkvSOrr8RuRkhPF0ngw3QPRzjLj7MxXezMqBZBSq7GpoQiAX78BqrI VmUcQO4/CUByKbmSg+r3Sl7AomZrCxviTweNV0iUGPGDvqK0jZz7lxITzEQjASdedvcS R3eibr0GduBGMe7wX2YGWhzpq5KqalXMQi9JRwZ1sAHdRMVbgEwobL6LzieDI/p3LqIW WmwQ== X-Gm-Message-State: AOJu0YwVLigyeb/Y1yh9cuFsmb1O6N3Ndw06lRwfE/rnePO8UPYmJKM8 z9855wx1UdnDtSIbRKedmtZlFpR+A5j0hkzL1OnMMkZUaBjw8reKNHhfLtTg6H5RzJBuPOgYS91 esGEw X-Google-Smtp-Source: AGHT+IFgCJEfSCdFld9/ToLFrcMUkEKqxMbAYe4e5LXwC8aZKaVS9zw9oWRnR2YBUy3ImMH1zaUs/g== X-Received: by 2002:a05:6402:2741:b0:5c9:5ac1:df6c with SMTP id 4fb4d7f45d1cf-5cb7fd9676emr1696080a12.33.1729598445378; Tue, 22 Oct 2024 05:00:45 -0700 (PDT) Received: from chromium.org (43-114-103-145.static.glaslokaal.nl. [145.103.114.43]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cb66a6d0besm3083100a12.57.2024.10.22.05.00.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 05:00:44 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Ilias Apalodimas , Tom Rini , Simon Glass , Alexander Gendin , Dan Carpenter , Jiaxun Yang Subject: [PATCH v8 6/8] sandbox: virtio: Disable the sandbox virtio blk device Date: Tue, 22 Oct 2024 14:00:27 +0200 Message-ID: <20241022120032.196311-7-sjg@chromium.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241022120032.196311-1-sjg@chromium.org> References: <20241022120032.196311-1-sjg@chromium.org> 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 This is not implemented so cannot actually be used to read blocks. Disable it until it is implemented, to avoid causing a hang with EFI, which probes every available BLK device. Signed-off-by: Simon Glass Reviewed-by: Tom Rini Issue: https://source.denx.de/u-boot/u-boot/-/issues/37 --- (no changes since v6) Changes in v6: - Drop the patch to disable sandbox virtio blk with EFI - Add new patch to disable the sandbox virtio blk device arch/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/Kconfig b/arch/Kconfig index 8f1f4667012..c39efb4d0a2 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -212,7 +212,8 @@ config SANDBOX imply VIRTIO_MMIO imply VIRTIO_PCI imply VIRTIO_SANDBOX - imply VIRTIO_BLK + # Re-enable this when fully implemented + # imply VIRTIO_BLK imply VIRTIO_NET imply DM_SOUND imply PCI_SANDBOX_EP From patchwork Tue Oct 22 12:00:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2000467 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=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Hd6ikrVG; 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 4XXrPy3L7Hz1xvv for ; Tue, 22 Oct 2024 23:01:58 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BF17B88F4D; Tue, 22 Oct 2024 14:00:54 +0200 (CEST) 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="Hd6ikrVG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 704AE88FD9; Tue, 22 Oct 2024 14:00:52 +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.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) (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 CD01C891E9 for ; Tue, 22 Oct 2024 14:00:48 +0200 (CEST) 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-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-5c957d8bce2so2608202a12.2 for ; Tue, 22 Oct 2024 05:00:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1729598447; x=1730203247; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0Q6foESg9Ic26lYT+sobuj6kM/2BMcGnWeB2Zaqi3MA=; b=Hd6ikrVGVqFSpsLgmqhJBsGJppsHD0S/xHiSVjfbnrMhmx1IvQb0KJv1blNM+nGWR2 vFA/oNrQ2/Q4bTmmh5eOpG/dK/fDNHvEFzk4q23ekVEYrSeB6GSgMhPCwGWeA7n/RIBl YWjIOhWX9sRSebjPJuHiAYjG2C45YytsRod7c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729598447; x=1730203247; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0Q6foESg9Ic26lYT+sobuj6kM/2BMcGnWeB2Zaqi3MA=; b=OLh+5fLLMNKcGJLEDFrdkX6MNQmNcd3KujpbH5anxL424D/p+tvQE/nQHn4lH+TydO 5i9m0FMGdKlFqhm2lSfgO6MoXNApuiqDbGHMETn0U+gg8yPZlPf+tQkCeBjPNwu1+45V rnE8dcZRnhMYSJWrWwSkeT0fw7r20h4zSfeBz19qI6IR+u+Ft1M5ELubRaNLimCMDeqz 5525rTj5LqEoY43td75rEWUTIuk6yw7M1U/Q/cgUBAkLcYTv9fIDIK058Ka1KwVAlZMb 81+ZqeSPi0MQGUThFbq1LOnRIzF+5dXp78Dqhn63qQ2Pd1TV3IiSRO4CLjSlp+kfVoKY Eu/g== X-Gm-Message-State: AOJu0Yx5BG4RRoxqbZBNr2MNKkQViXLPJi39r+x/3/ny4KYxcSXC+pRq Cjyz683uFzBo6FjQnCv/3TNTVT5l9o8v4bUzy/wfGCooXux5sbSb8U4raY6pNUnLe4fJeJtbOAV lerkn X-Google-Smtp-Source: AGHT+IFwERVnzBtulP0btecb4EqnbZkN5qLSQFlb0LBGoNG1AxvWY1O7VFKzu77+ItmVUshYEiO5IA== X-Received: by 2002:a05:6402:27cb:b0:5cb:69b9:ddb0 with SMTP id 4fb4d7f45d1cf-5cb69b9ddffmr10216670a12.27.1729598447176; Tue, 22 Oct 2024 05:00:47 -0700 (PDT) Received: from chromium.org (43-114-103-145.static.glaslokaal.nl. [145.103.114.43]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cb66a6d0besm3083100a12.57.2024.10.22.05.00.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 05:00:45 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Ilias Apalodimas , Tom Rini , Simon Glass , AKASHI Takahiro , Alexander Gendin , Caleb Connolly , Christian Marangi , Eddie James , Francis Laniel , Guillaume La Roque , Jerome Forissier , Julien Masson , Marek Vasut , Mattijs Korpershoek , Sean Anderson , Sughosh Ganu , Yang Xiwen Subject: [PATCH v8 7/8] test: efi: boot: Set up an image suitable for EFI testing Date: Tue, 22 Oct 2024 14:00:28 +0200 Message-ID: <20241022120032.196311-8-sjg@chromium.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241022120032.196311-1-sjg@chromium.org> References: <20241022120032.196311-1-sjg@chromium.org> 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 Create a new disk for use with tests, which contains the new 'testapp' EFI app specifically intended for testing the EFI loader. Attach it to the USB device, since most testing is currently done with mmc. Initially this image will be used to test the EFI bootmeth. Fix a stale comment in prep_mmc_bootdev() while we are here. For now this uses sudo and a compressed fallback file, like all the other bootstd tests. Once this series is in, the patch which moves this to use user-space tools will be cleaned up and re-submitted. Signed-off-by: Simon Glass --- Here is the patch to avoid sudo and CI fallback: [1] https://patchwork.ozlabs.org/project/uboot/patch/ 20240802093322.15240-1-richard@nod.at/ (no changes since v1) arch/sandbox/dts/test.dts | 2 +- test/boot/bootdev.c | 18 +++++++++- test/boot/bootflow.c | 2 +- test/py/tests/bootstd/flash1.img.xz | Bin 0 -> 5016 bytes test/py/tests/test_ut.py | 52 ++++++++++++++++++++++++---- 5 files changed, 65 insertions(+), 9 deletions(-) create mode 100644 test/py/tests/bootstd/flash1.img.xz diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 9bf44ae3b0b..f40fd5a2b16 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -1512,7 +1512,7 @@ flash-stick@1 { reg = <1>; compatible = "sandbox,usb-flash"; - sandbox,filepath = "testflash1.bin"; + sandbox,filepath = "flash1.img"; }; flash-stick@2 { diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c index 369105ca4cf..c892854b227 100644 --- a/test/boot/bootdev.c +++ b/test/boot/bootdev.c @@ -221,6 +221,10 @@ static int bootdev_test_order(struct unit_test_state *uts) /* Use the environment variable to override it */ ut_assertok(env_set("boot_targets", "mmc1 mmc2 usb")); ut_assertok(bootflow_scan_first(NULL, NULL, &iter, 0, &bflow)); + + /* get the usb device which has a backing file (flash1.img) */ + ut_asserteq(0, bootflow_scan_next(&iter, &bflow)); + ut_asserteq(-ENODEV, bootflow_scan_next(&iter, &bflow)); ut_asserteq(5, iter.num_devs); ut_asserteq_str("mmc1.bootdev", iter.dev_used[0]->name); @@ -260,7 +264,11 @@ static int bootdev_test_order(struct unit_test_state *uts) ut_assertok(bootflow_scan_first(NULL, NULL, &iter, 0, &bflow)); ut_asserteq(2, iter.num_devs); - /* Now scan past mmc1 and make sure that the 3 USB devices show up */ + /* + * Now scan past mmc1 and make sure that the 3 USB devices show up. The + * first one has a backing file so returns success + */ + ut_asserteq(0, bootflow_scan_next(&iter, &bflow)); ut_asserteq(-ENODEV, bootflow_scan_next(&iter, &bflow)); ut_asserteq(6, iter.num_devs); ut_asserteq_str("mmc2.bootdev", iter.dev_used[0]->name); @@ -322,6 +330,10 @@ static int bootdev_test_prio(struct unit_test_state *uts) /* 3 MMC and 3 USB bootdevs: MMC should come before USB */ ut_assertok(bootflow_scan_first(NULL, NULL, &iter, 0, &bflow)); + + /* get the usb device which has a backing file (flash1.img) */ + ut_asserteq(0, bootflow_scan_next(&iter, &bflow)); + ut_asserteq(-ENODEV, bootflow_scan_next(&iter, &bflow)); ut_asserteq(6, iter.num_devs); ut_asserteq_str("mmc2.bootdev", iter.dev_used[0]->name); @@ -339,6 +351,10 @@ static int bootdev_test_prio(struct unit_test_state *uts) bootflow_iter_uninit(&iter); ut_assertok(bootflow_scan_first(NULL, NULL, &iter, BOOTFLOWIF_HUNT, &bflow)); + + /* get the usb device which has a backing file (flash1.img) */ + ut_asserteq(0, bootflow_scan_next(&iter, &bflow)); + ut_asserteq(-ENODEV, bootflow_scan_next(&iter, &bflow)); ut_asserteq(7, iter.num_devs); ut_asserteq_str("usb_mass_storage.lun0.bootdev", diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index 539abe63ebe..d94c07963d5 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -533,7 +533,7 @@ static int prep_mmc_bootdev(struct unit_test_state *uts, const char *mmc_dev, order[2] = mmc_dev; - /* Enable the mmc4 node since we need a second bootflow */ + /* Enable the requested mmc node since we need a second bootflow */ root = oftree_root(oftree_default()); node = ofnode_find_subnode(root, mmc_dev); ut_assert(ofnode_valid(node)); diff --git a/test/py/tests/bootstd/flash1.img.xz b/test/py/tests/bootstd/flash1.img.xz new file mode 100644 index 0000000000000000000000000000000000000000..9148b91a20c1f0acb54449b124d1408961e92507 GIT binary patch literal 5016 zcmeI0cTf{r8pRVz9+4n5AV?_EgQ1BO;n5K(kx-;pUwkwL0tBUqlz==yF+ikBDAExL zQWT{~2Sq?y06~gW5eP+U$nMPkwKMCEzInSlv*Z7F=Fa`i`OZ1tr78#8*Z}|x3nSGR z=>Wn&ZU6ufAUmH=qlqxW9033y>XG5m*pL}cy$rvQVYbMeTPGAi$9qqfMnd47Jp+b8@aTLW9^ZgBe#gV-u~nri0|VMr5lA6KhSV}ds3x_d!R zK70s*W-GN^=;}ze2DKy`8Bp8a3s-y^i!J>$OdpXOt?{Uc-H+4p?jUP+#@pmNRUwJ*{D zGJt0cjopJaH2B8t_BV*T|(V? zQE{)kaF4zAwh?({NItl!v80%xP5j+-km~m0FjHOI&3eSrr0=y}ILxn&A^gJ={@ zcWW%yKY}Nl1tu^^*#UCxf;bJ&NSo@TX5>5e+pT?chViS8Qddj*v2(zyvvS5|tWhS65&b1s# ztq%uj(ECDcNKU@WQlPgiVOeS{T^}+v^G!^rLMD_i2e;x1$aOEia;LV&Z930_1Thek8ad0!1k*%M3 z_Q0A`8vzaWYYX7vQ=^y;COH>9zmbcNam0;YlMB3IVMi>ftHk8xY%(%}{iymL<`3XMZW+f8a2?SETgT0;aAgL=a#3!1KX z^cLebMqp!W-R{zh?QA#i^JTju!o5tn8#754Z(}^I`q<{*5Rey^jYGXyHJRh;{p1ikj zc9Dqls^pvK0YX|_7#zPTf!*b82Bk?#z3fQBiu4q*qMiE6{UF>)MUAS7qBGw*k4&SI zpAJ7@{r3j-*FNfpyz$Rntz!RCiAZAuN`Ei6|5Fa%9ZzPgnpH&FE1=r9f!*ynU>LRk zs^i2fv8m7Ts$<41M5$$$O!aU5TsIe9FH*b*iXYp#Gs1FO^Y+cMC@x{|f&W>e{yEir zH?4mW<^(Pg@=wM6Kq2~v;(m_kcZ=>Pupg}4KY{%zU`U3zZ->A?w~ha5Y7#LChpCq# zjLs}(gwV(qHKH0PIq==G%UE&4)cV#zQp!hu3P)N#5~J*rP#)Mrnf2FEJB=>p2`NB0 zxrbCGW-cOk>(@E=<>XoI^r+-qsU_Hbj=2C;jaT42`)4Nl?$A9Ao502gVwPUdyH zk|c8N(S#6;Vbf5B1-#i5rvvuH#*!j4W%J!DHrzLL7Y}2FiA;&kE{gOSUX)eQM58e% zxzCf&=qNe#7eNq+P!z(uHeIWDRQiY=vVq^N5#m=JF!q>=l3~T}x`dQCQkTnB7Jyp9 z9!$S*si%Y z#K@3yE)2HKtuQf<(p%-MP;{u#ln=wpQ1YA#gF=REU4Ysw)eE4nJR61Dj5RfBZ~dM* zSMp96hovw!v!`3u@q#5n+3D*c)52Q{z19NhVU|dnO=-{cW*eIX_2Q97jaK23vWBG7 z@m-4+V3|8nS|8n5(7fuqxU~m1hiT=)sP4+=FIXUT1|kn%EzpMCxRuaG>(_h94n9E@ z^-0~gvKr&93iu$m=JxNvH`Z>5eVq0gWqPV|6Dd^9zrpc%XLqFfRKYs#OhX;3>Jm;b zh)!B^-RF<)Tr}SWQrPsyLGNqxRRqOIG#PiTgwEoM7^!y@5qBOR-Cf%U)jHUm7=x1n zabX0NS!nxd?gq)JryA$B@Ibw^qlg)E=DN@e$6aC^s8+O_{x@AiR~<_W*A_j#gJdl-^e|Hn)_#5WHWmA z*>1210plk_~Sa)Oa|ASTX<>*J$=fQh1r%Sk4yV+%E8c2*ol{zZAGEORz}_=pJYbILT?~9 zx@Ww_ZY!Phs9}DZ;|(-K7u0?|tedsc3u1!ajplM14D z?)FvVYF1EAD}VwEmh!>y)l!pF literal 0 HcmV?d00001 diff --git a/test/py/tests/test_ut.py b/test/py/tests/test_ut.py index 39aa1035e34..f647e2f0af2 100644 --- a/test/py/tests/test_ut.py +++ b/test/py/tests/test_ut.py @@ -28,21 +28,22 @@ def mkdir_cond(dirname): if not os.path.exists(dirname): os.mkdir(dirname) -def setup_image(cons, mmc_dev, part_type, second_part=False): +def setup_image(cons, devnum, part_type, second_part=False, basename='mmc'): """Create a 20MB disk image with a single partition Args: cons (ConsoleBase): Console to use - mmc_dev (int): MMC device number to use, e.g. 1 + devnum (int): Device number to use, e.g. 1 part_type (int): Partition type, e.g. 0xc for FAT32 second_part (bool): True to contain a small second partition + basename (str): Base name to use in the filename, e.g. 'mmc' Returns: tuple: str: Filename of MMC image str: Directory name of 'mnt' directory """ - fname = os.path.join(cons.config.source_dir, f'mmc{mmc_dev}.img') + fname = os.path.join(cons.config.source_dir, f'{basename}{devnum}.img') mnt = os.path.join(cons.config.persistent_data_dir, 'mnt') mkdir_cond(mnt) @@ -78,16 +79,17 @@ def mount_image(cons, fname, mnt, fstype): u_boot_utils.run_and_log(cons, f'sudo chown {getpass.getuser()} {mnt}') return loop -def copy_prepared_image(cons, mmc_dev, fname): +def copy_prepared_image(cons, devnum, fname, basename='mmc'): """Use a prepared image since we cannot create one Args: cons (ConsoleBase): Console touse - mmc_dev (int): MMC device number + devnum (int): device number fname (str): Filename of MMC image + basename (str): Base name to use in the filename, e.g. 'mmc' """ infname = os.path.join(cons.config.source_dir, - f'test/py/tests/bootstd/mmc{mmc_dev}.img.xz') + f'test/py/tests/bootstd/{basename}{devnum}.img.xz') u_boot_utils.run_and_log(cons, ['sh', '-c', f'xz -dc {infname} >{fname}']) def setup_bootmenu_image(cons): @@ -549,6 +551,43 @@ def test_ut_dm_init(u_boot_console): with open(fn, 'wb') as fh: fh.write(data) + +def setup_efi_image(cons): + """Create a 20MB disk image with an EFI app on it""" + devnum = 1 + basename = 'flash' + fname, mnt = setup_image(cons, devnum, 0xc, second_part=True, + basename=basename) + + loop = None + mounted = False + complete = False + try: + loop = mount_image(cons, fname, mnt, 'ext4') + mounted = True + efi_dir = os.path.join(mnt, 'EFI') + mkdir_cond(efi_dir) + bootdir = os.path.join(efi_dir, 'BOOT') + mkdir_cond(bootdir) + efi_src = os.path.join(cons.config.build_dir, + f'lib/efi_loader/testapp.efi') + efi_dst = os.path.join(bootdir, 'BOOTSBOX.EFI') + with open(efi_src, 'rb') as inf: + with open(efi_dst, 'wb') as outf: + outf.write(inf.read()) + except ValueError as exc: + print(f'Falled to create image, failing back to prepared copy: {exc}') + + finally: + if mounted: + u_boot_utils.run_and_log(cons, 'sudo umount --lazy %s' % mnt) + if loop: + u_boot_utils.run_and_log(cons, 'sudo losetup -d %s' % loop) + + if not complete: + copy_prepared_image(cons, devnum, fname, basename) + + @pytest.mark.buildconfigspec('cmd_bootflow') @pytest.mark.buildconfigspec('sandbox') def test_ut_dm_init_bootstd(u_boot_console): @@ -559,6 +598,7 @@ def test_ut_dm_init_bootstd(u_boot_console): setup_cedit_file(u_boot_console) setup_cros_image(u_boot_console) setup_android_image(u_boot_console) + setup_efi_image(u_boot_console) # Restart so that the new mmc1.img is picked up u_boot_console.restart_uboot() From patchwork Tue Oct 22 12:00:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2000468 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=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=XPYiib8g; 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 4XXrQB5ZKhz1xvv for ; Tue, 22 Oct 2024 23:02:10 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2FB7C892AA; Tue, 22 Oct 2024 14:00:55 +0200 (CEST) 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="XPYiib8g"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7F8A688EBA; Tue, 22 Oct 2024 14:00:53 +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.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) (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 AF52388969 for ; Tue, 22 Oct 2024 14:00:50 +0200 (CEST) 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-lf1-x12b.google.com with SMTP id 2adb3069b0e04-539e7e73740so4951563e87.3 for ; Tue, 22 Oct 2024 05:00:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1729598449; x=1730203249; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ptMBh+FYdx7Iutk0wX/CucHRJrizN/4hQEEHQFqrNKY=; b=XPYiib8g8JntHOMFo06M6YAWjnTAHcrDQS1p0R/Jrcs2eWOKSc9POn2PmU+++Tl1vc QfFpU3nTVA906rE48rlMlE2jC9BnpPI9hhyyAOpTnPCjRr03wOdOLgm8YFo9F95d+OX/ JNn2lndYtT8ysLs/8UOyBD5TVBq90/x46A3f8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729598449; x=1730203249; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ptMBh+FYdx7Iutk0wX/CucHRJrizN/4hQEEHQFqrNKY=; b=OfEmC+eDif8rKij5je+dRNQIWBCMSjm4zgGSy/V3Ivvaww3Ln4lYZJ/bBb7K0cjmGy 1tHyzJa3qZ5RbHIrKY/4bsahdt0BtsJaBQHNjs1j65LD+0BKmqxzK+cDpTD4yjles1r6 Px7Fyl1mm+XsG5NpWGnwgTw91FU6RfphnmcGbQx1XjebhxXDITNt7sfLnUZ1iRpJixSi GYfv0iNFKtfEpr1okfgl5pU5J7UD1K93w+S9+cTRY/lwHLHzIEeRJHD0oBRlRm7bRBTP iCvrqpLUReEetojQQZzVFO6sql3Fy3JyTtjzK5vy3NOC4UfG+HXt+NEIGEBQyiJccgID LDOg== X-Gm-Message-State: AOJu0YzjeqdjBvzae9Jbh7a6gKSiosnMfuuSCfyAgca94sRvuxhYjO37 XfrhmATVBCWT2nHm8JzUZQb1xTHK02TYwWauiXMPT9IX5CJqObJT/ggEKH1bqFtPe9AISq/ZvWe CKh/1 X-Google-Smtp-Source: AGHT+IFqoPJKnTz93HcX9oO17EKXUT7Je3sPKEobv9RNGbaat8xAnUf1c+MfIA0sf5tncOLxxRvV3A== X-Received: by 2002:a05:6512:1294:b0:539:f630:f233 with SMTP id 2adb3069b0e04-53b12c42bf1mr1792900e87.57.1729598449363; Tue, 22 Oct 2024 05:00:49 -0700 (PDT) Received: from chromium.org (43-114-103-145.static.glaslokaal.nl. [145.103.114.43]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cb66a6d0besm3083100a12.57.2024.10.22.05.00.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 05:00:48 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Ilias Apalodimas , Tom Rini , Simon Glass , AKASHI Takahiro , Mattijs Korpershoek Subject: [PATCH v8 8/8] test: efi: boot: Add a test for the efi bootmeth Date: Tue, 22 Oct 2024 14:00:29 +0200 Message-ID: <20241022120032.196311-9-sjg@chromium.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241022120032.196311-1-sjg@chromium.org> References: <20241022120032.196311-1-sjg@chromium.org> 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 Add a simple test of booting with the EFI bootmeth, which runs the app and checks that it can call 'exit boot-services' (to check that all the device-removal code doesn't break anything) and then exit back to U-Boot. This uses a disk image containing the testapp, ready for execution by sandbox when needed. Signed-off-by: Simon Glass --- Note that this uses the same mechanism as for the other images which are created. Once this series lands I will update[1] and revisit. [1] https://patchwork.ozlabs.org/project/uboot/patch/ 20240802093322.15240-1-richard@nod.at/ (no changes since v7) Changes in v7: - Drop patches already applied - Drop patch 'Disable ANSI output for tests' - Rebase on -master Changes in v6: - Deal with sandbox CONFIG_LOGF_FUNC - Rebase on -next - Drop patches previously applied - Drop mention of helloworld since it is no-longer used by this test Changes in v4: - Add efi_loader tag to some patches - Split out non-EFI patches into a different series Changes in v2: - Add many new patches to resolve all the outstanding test issues test/boot/bootflow.c | 65 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index d94c07963d5..2762e97d2eb 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #ifdef CONFIG_SANDBOX #include @@ -31,6 +32,9 @@ extern U_BOOT_DRIVER(bootmeth_android); extern U_BOOT_DRIVER(bootmeth_cros); extern U_BOOT_DRIVER(bootmeth_2script); +/* Use this as the vendor for EFI to tell the app to exit boot services */ +static u16 __efi_runtime_data test_vendor[] = u"U-Boot testing"; + static int inject_response(struct unit_test_state *uts) { /* @@ -184,8 +188,9 @@ static int bootflow_cmd_scan_e(struct unit_test_state *uts) ut_assert_nextline(" 3 efi media mmc 0 mmc1.bootdev.whole "); ut_assert_nextline(" ** No partition found, err=-2: No such file or directory"); ut_assert_nextline(" 4 extlinux ready mmc 1 mmc1.bootdev.part_1 /extlinux/extlinux.conf"); - ut_assert_nextline(" 5 efi fs mmc 1 mmc1.bootdev.part_1 /EFI/BOOT/%s", - efi_get_basename()); + ut_assert_nextline( + " 5 efi fs mmc 1 mmc1.bootdev.part_1 /EFI/BOOT/%s", + efi_get_basename()); ut_assert_skip_to_line("Scanning bootdev 'mmc0.bootdev':"); ut_assert_skip_to_line( @@ -1213,3 +1218,59 @@ static int bootflow_android(struct unit_test_state *uts) return 0; } BOOTSTD_TEST(bootflow_android, UTF_CONSOLE); + +/* Test EFI bootmeth */ +static int bootflow_efi(struct unit_test_state *uts) +{ + /* disable ethernet since the hunter will run dhcp */ + test_set_eth_enable(false); + + /* make USB scan without delays */ + test_set_skip_delays(true); + + bootstd_reset_usb(); + + ut_assertok(bootstd_test_drop_bootdev_order(uts)); + ut_assertok(run_command("bootflow scan", 0)); + ut_assert_skip_to_line( + "Bus usb@1: scanning bus usb@1 for devices... 5 USB Device(s) found"); + + ut_assertok(run_command("bootflow list", 0)); + + ut_assert_nextlinen("Showing all"); + ut_assert_nextlinen("Seq"); + ut_assert_nextlinen("---"); + ut_assert_nextlinen(" 0 extlinux"); + ut_assert_nextlinen( + " 1 efi ready usb_mass_ 1 usb_mass_storage.lun0.boo /EFI/BOOT/BOOTSBOX.EFI"); + ut_assert_nextlinen("---"); + ut_assert_skip_to_line("(2 bootflows, 2 valid)"); + ut_assert_console_end(); + + ut_assertok(run_command("bootflow select 1", 0)); + ut_assert_console_end(); + + systab.fw_vendor = test_vendor; + + ut_asserteq(1, run_command("bootflow boot", 0)); + ut_assert_nextline( + "** Booting bootflow 'usb_mass_storage.lun0.bootdev.part_1' with efi"); + if (IS_ENABLED(CONFIG_LOGF_FUNC)) + ut_assert_skip_to_line(" efi_run_image() Booting /\\EFI\\BOOT\\BOOTSBOX.EFI"); + else + ut_assert_skip_to_line("Booting /\\EFI\\BOOT\\BOOTSBOX.EFI"); + + /* TODO: Why the \r ? */ + ut_assert_nextline("U-Boot test app for EFI_LOADER\r"); + ut_assert_nextline("Exiting boot sevices"); + if (IS_ENABLED(CONFIG_LOGF_FUNC)) + ut_assert_nextline(" do_bootefi_exec() ## Application failed, r = 5"); + else + ut_assert_nextline("## Application failed, r = 5"); + ut_assert_nextline("Boot failed (err=-22)"); + + ut_assert_console_end(); + + return 0; +} +BOOTSTD_TEST(bootflow_efi, UTF_CONSOLE);