From patchwork Tue Oct 29 19:22:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2003869 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=TpEwAvO4; 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 4XdKsH4JY2z1xwc for ; Wed, 30 Oct 2024 06:22:43 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2CD7E8919B; Tue, 29 Oct 2024 20:22:35 +0100 (CET) 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="TpEwAvO4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id ED48E89197; Tue, 29 Oct 2024 20:22:33 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.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 1A40D89191 for ; Tue, 29 Oct 2024 20:22:32 +0100 (CET) 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-5cb15b84544so7359687a12.2 for ; Tue, 29 Oct 2024 12:22:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1730229751; x=1730834551; 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=8ajO0kE4L7pLjYAYTWLV7R8mXk5S+6K44+EJo4R+uIc=; b=TpEwAvO47m9y363VySZIkMZueM42BMpRX5o0+pGLC8QSHhZgu07mwPzR5vuF1oAatF FNx/Hl4lu1NvOt5yBQd9TVlhDtBVRIumF4pDCS41yQMnKnHScb4kTwS7jjlzS3Qx5VXP 4g8z1nESNvq8UflwIwKj0nTo4z3CIlP+LYCus= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730229751; x=1730834551; 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=8ajO0kE4L7pLjYAYTWLV7R8mXk5S+6K44+EJo4R+uIc=; b=oJC5g1kL22QBcioZ0kGHPFJ7AWdRvlDP393FCsuJugqX474WIJh78wF0AhJecz1G2n qKYGTKp2FZvSyilhNSZrrMrefz9IErXr6ezCrE81cY+9nRr22YTqwxJA9AcqW5PyHgv4 V+2vseBpnTHHgr1odEtVOnFn31CjGRF+izer6d/NQes+phZkC6YANFgYCNCRqUNL+h4v z90NYFvy0LGUM97Lpv5lpfPB5JEfQiGogGAFUriqJjTYSRyJ0c8UgASm9ngbjpaNKZL5 9eQjRcdN1t7cGKNS4wgWuxlucvOv+OOvFZtOFJN0sG+BSq2jbAwWgUe9wJzjiq3NEq3u mAVA== X-Gm-Message-State: AOJu0YzxW1rYBgK4FwJFDFhRia//1VpDUUvvswOAyYIMr1RFsiy9foLG rJOweBOjtBNpccfllDkbGH1rjXclFCZqoGqoffE3ogl2UIOv2wQfWSAdPnnIwxX2bh3nzPGTn+O e1Hth X-Google-Smtp-Source: AGHT+IHzLUrc1JpcrXs9DNvlXG5WoD88sqMCSVSu7SlWrSX36Z7DTlTy0aj0Ip9izmeIJ70nDOCFCQ== X-Received: by 2002:a05:6402:3584:b0:5cb:6709:3cd7 with SMTP id 4fb4d7f45d1cf-5cbbf872064mr8633863a12.4.1730229750935; Tue, 29 Oct 2024 12:22:30 -0700 (PDT) Received: from chromium.org ([87.215.50.114]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cbb629f65esm4272770a12.36.2024.10.29.12.22.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 12:22:30 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Ilias Apalodimas , Tom Rini , Heinrich Schuchardt , Simon Glass , AKASHI Takahiro , Mattijs Korpershoek Subject: [PATCH v9 01/11] test: boot: Update bootflow_iter() for console checking Date: Tue, 29 Oct 2024 20:22:09 +0100 Message-ID: <20241029192222.362445-2-sjg@chromium.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241029192222.362445-1-sjg@chromium.org> References: <20241029192222.362445-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 --- (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 0d4e966892e..841729bd1ac 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 29 19:22:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2003870 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=VjUxPYYK; 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 4XdKsS2zkSz1xwc for ; Wed, 30 Oct 2024 06:22:52 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 867028919A; Tue, 29 Oct 2024 20:22:37 +0100 (CET) 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="VjUxPYYK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 50305891AC; Tue, 29 Oct 2024 20:22:36 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.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-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) (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 4020289191 for ; Tue, 29 Oct 2024 20:22:34 +0100 (CET) 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-lj1-x234.google.com with SMTP id 38308e7fff4ca-2fb388e64b0so57915481fa.0 for ; Tue, 29 Oct 2024 12:22:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1730229753; x=1730834553; 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=lx0eESSUPcgWQ5AeNES/zyKJ1d7YeNCBq6nf5MAq3yk=; b=VjUxPYYKVKw93xficMV1TIm8wrtIVBFokb2+ugcHDizE10sv3gcwWpZfNuoCdlLJ19 5XxzleIKnYn+eEXQcGAgdsFln6ki9o0CrLtu7fZNgGZSVoyxvYxCv4Rv/VzNPathCfY/ BnUsnaOrUeabYrmIFgCar6dD93XQ0rptoB8FU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730229753; x=1730834553; 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=lx0eESSUPcgWQ5AeNES/zyKJ1d7YeNCBq6nf5MAq3yk=; b=N25Um0l6RMEtnaG9f3bwbjABV4NVNyr/sSGCnmTazPiZ2kRlj4OiQVpzKModOzqlrx k1iD65ymJBnZIDK8TAMaQhf1Swq2UZC0/gXRIzUAq3Hv8QgunDophOVif+HY87CdhrOv RDkcdQFdHnZXUMAw7EJyYTURIBCbIgQDDc5kbs2BRQ9qexMgqYZlv7lzilF6ueA2ss7d 1po8z6zqO8kyAS4sPbNg00PwBIYayDk8gLg/kMqL9g3J00aTq5eFF+f59mzjY2wOLEH1 6p3MwN4T8uTxapNNWJkeJJf0QVrfwu2R/5c1EcOLTLhSfU9nTm3iKw06sPYYrTmXo2O+ iBkA== X-Gm-Message-State: AOJu0YzlNjvRhuft30KBuQBYGrtytNfcMHR/gtsK07GGNHBDR+WyYhVl T2zhBHa9IjCnwnvab6kzFBKycffBybDNY5BYjee/radl9/o6i2q9CVq//zIsQXvDr+/53yzIPJS pbJDY X-Google-Smtp-Source: AGHT+IFFs7AtyiFr4ozdRcBoAiYGeYdoHYCwEjWcW3z3vErudhdYLaTA1VLugwLax16ZIDBcr/OusA== X-Received: by 2002:a05:651c:b20:b0:2fa:c0fc:e3d8 with SMTP id 38308e7fff4ca-2fd059ea07cmr5061551fa.38.1730229752453; Tue, 29 Oct 2024 12:22:32 -0700 (PDT) Received: from chromium.org ([87.215.50.114]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cbb629f65esm4272770a12.36.2024.10.29.12.22.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 12:22:31 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Ilias Apalodimas , Tom Rini , Heinrich Schuchardt , Simon Glass , AKASHI Takahiro , Caleb Connolly , Michal Simek Subject: [PATCH v9 02/11] efi_loader: Add a test app Date: Tue, 29 Oct 2024 20:22:10 +0100 Message-ID: <20241029192222.362445-3-sjg@chromium.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241029192222.362445-1-sjg@chromium.org> References: <20241029192222.362445-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 --- Changes in v9: - Update license - Fix 'sevices' typo 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 37572c82f54..44319729bda 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -584,6 +584,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 8ec240cb864..7c8b2dd1ad6 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..a28fc17ce5b --- /dev/null +++ b/lib/efi_loader/testapp.c @@ -0,0 +1,68 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * 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 services\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 29 19:22:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2003871 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=E33eE5qi; 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 4XdKsf46cPz1xwc for ; Wed, 30 Oct 2024 06:23:02 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F0362891BB; Tue, 29 Oct 2024 20:22:37 +0100 (CET) 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="E33eE5qi"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 91209891AF; Tue, 29 Oct 2024 20:22:36 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.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 97AFA89198 for ; Tue, 29 Oct 2024 20:22:34 +0100 (CET) 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-5c948c41edeso6841812a12.1 for ; Tue, 29 Oct 2024 12:22:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1730229753; x=1730834553; 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=PVkqanoExg/W5ZFXEjGqu/ADcv5p/TLMf5DbkvHyR+I=; b=E33eE5qiaCLVJ1K0SxzN2WQRpBFIJyw14hy7vMPvrn/7H68Ng1NUGZTZ/LN1ifDdR8 IXaqPFzlMymGr5wNBTSazrCbSD+DVZVmdyuM0jTMq039wf/QD5q7dkuLrBDLOwmY4FP+ LrIlxpJqqLgyTRItoSsOXzPBNVlrG2+5pFW1A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730229753; x=1730834553; 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=PVkqanoExg/W5ZFXEjGqu/ADcv5p/TLMf5DbkvHyR+I=; b=RjmIDZoGuOfOqEvv1qhcc7QHjKATKiCsSqEutu5N2ioAhOfpaxfERgzBb90ovXwVcB OX3Q02nOaqD8ZEVkeYgONK1+nV9ix4W8XP16TxeGAZl7INKBeE3WbWYcAtIuniF3kn4/ SsI9MVbAP+2h9X8zcfHh03VNO9UPJyzJEuuQEegrzufuaJmKP4akpB3y+ArV/EMJViMy OsVfx+cvbPNoCPfh3X4CdEc9Uumvm0xa2Ykjobez7tirF2YMveLa3iRtRvKDJqCg47tW eiuU63X/3Pfj6Wb2IvROl6fOcN6GZz3N9VKdQV7jmsPGpr8SKn7AEoyEfoLp5wcLLr71 4KmA== X-Gm-Message-State: AOJu0YxqPyfY70WWyedp1X9GQ72oETPAU18LzNXsffSfaz0RgBAEBclB g9C1xNgvsVALrz5OJbkPFwUPrTzVpi4WRp48RV1CjeQ1u8QK6DYno4ijb1K1OI3FgJ7ZA+Emkdj uOIES X-Google-Smtp-Source: AGHT+IHi+CCXV80fuqDfO252cJPyGYJ4E7G9lq1FMBOQS1L+9egPifPglyKtDKYEELxiEhzPCDh88A== X-Received: by 2002:a05:6402:34c7:b0:5c9:5c40:6d9a with SMTP id 4fb4d7f45d1cf-5cbbfae67ecmr8079139a12.34.1730229753351; Tue, 29 Oct 2024 12:22:33 -0700 (PDT) Received: from chromium.org ([87.215.50.114]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cbb629f65esm4272770a12.36.2024.10.29.12.22.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 12:22:32 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Ilias Apalodimas , Tom Rini , Heinrich Schuchardt , Simon Glass Subject: [PATCH v9 03/11] sandbox: Add a -N flag to control on-host behaviour Date: Tue, 29 Oct 2024 20:22:11 +0100 Message-ID: <20241029192222.362445-4-sjg@chromium.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241029192222.362445-1-sjg@chromium.org> References: <20241029192222.362445-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 --- (no changes since v8) 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 29 19:22:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2003872 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=aHSmcH3J; 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 4XdKss1k7vz1xwc for ; Wed, 30 Oct 2024 06:23:13 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E62DA89197; Tue, 29 Oct 2024 20:22:39 +0100 (CET) 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="aHSmcH3J"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9C65B89197; Tue, 29 Oct 2024 20:22:38 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.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-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) (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 2BD6F891AA for ; Tue, 29 Oct 2024 20:22:36 +0100 (CET) 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-ej1-x633.google.com with SMTP id a640c23a62f3a-a9a16b310f5so900523266b.0 for ; Tue, 29 Oct 2024 12:22:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1730229755; x=1730834555; 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=8rHSz2fsMRcdSxbd3sELN6bnU3Y/7BPLKxZ5AJpMA8s=; b=aHSmcH3JeiFtke0JS0599VYhH0RR0VvEhFLfvhJMTpEwCyGz1i6UDDvD5AOw1hiAIn l+YM2QR0MhDIZpSjSBQsMHmbQ9JReV4SpltfgbnUYTg4VUNo0J/f9CaVqEpHgxypafoz 5n3VJkKKkkDY2Cswjr4JVlHb+qOjRgFMCHCOc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730229755; x=1730834555; 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=8rHSz2fsMRcdSxbd3sELN6bnU3Y/7BPLKxZ5AJpMA8s=; b=eVpm1PDncHFEQPvnuQbDIvuRR9pDyG79Tq7OkqW1qrx0a8R5bAzZad47yP9+voYUjF Eh9qLoRDIdN9ZbGVPAlAu7XpPNOsjfUjp+G4NMy3LcLWlUbeS3+YkNi4n7pzuBvRCKvZ DnEcD1G/k19zZSY9YRhN2P+x29T4wgwObuPQ9IMYsrY7iPp1ZksYzS2siPEH8ioUrROo 46aLq/FPlTYrkt3Oh/B0bSkKWWfG56Yd6nmtLglaiAg9GTDdR7bpAPQEkXgr9/cNuQQ8 BsOljBfa+EznG4zu4QuD52jyHENjwYjoSTVx8dWLdlwewErH8l+2an9Eg4TzFKmoEHv7 2Vaw== X-Gm-Message-State: AOJu0YyokhAGkgJ8nG8FpV2ZG6frbX2Ztp41xKrtW/8STtHcg5HtRZ0a YMc9Tg1DTo0bT26Q1bvsfEiqA5tyax+vHpCfD9O2YamQr+kU+GtBT81gAotNDZPzND9k400kmxI 4bOEx X-Google-Smtp-Source: AGHT+IGGVcSkEd7t9rT8F6VGHFgIKen1u2SMkcc07W6YHBv1Ja+TuT0Xdz/WXai+GHD5i09i1ZI3DA== X-Received: by 2002:a17:906:c105:b0:a9a:10c9:f4b8 with SMTP id a640c23a62f3a-a9de62eaf3dmr1280177266b.61.1730229755144; Tue, 29 Oct 2024 12:22:35 -0700 (PDT) Received: from chromium.org ([87.215.50.114]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cbb629f65esm4272770a12.36.2024.10.29.12.22.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 12:22:33 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Ilias Apalodimas , Tom Rini , Heinrich Schuchardt , Simon Glass , AKASHI Takahiro , Caleb Connolly , Mark Kettenis , Masahisa Kojima , Mattijs Korpershoek , Shantur Rathore , Sughosh Ganu , =?utf-8?q?Vincent_Stehl=C3=A9?= Subject: [PATCH v9 04/11] efi: Move default filename to a function Date: Tue, 29 Oct 2024 20:22:12 +0100 Message-ID: <20241029192222.362445-5-sjg@chromium.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241029192222.362445-1-sjg@chromium.org> References: <20241029192222.362445-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 v9: - Move the function into efi_helper.c Changes in v8: - Add new patch to move default filename to a function boot/bootmeth_efi.c | 4 +-- include/efi.h | 9 ++++++ include/efi_default_filename.h | 56 ---------------------------------- lib/efi_loader/efi_bootmgr.c | 10 ++++-- lib/efi_loader/efi_helper.c | 45 +++++++++++++++++++++++++++ test/boot/bootflow.c | 7 +++-- 6 files changed, 67 insertions(+), 64 deletions(-) delete mode 100644 include/efi_default_filename.h 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.h b/include/efi.h index f7419b80d4d..fef88e9c5d6 100644 --- a/include/efi.h +++ b/include/efi.h @@ -670,4 +670,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 function returns BOOTAA64.EFI for an aarch target + * + * Return: Default EFI filename + */ +const char *efi_get_basename(void); + #endif /* _LINUX_EFI_H */ diff --git a/include/efi_default_filename.h b/include/efi_default_filename.h deleted file mode 100644 index 77932984b55..00000000000 --- a/include/efi_default_filename.h +++ /dev/null @@ -1,56 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* - * When a boot option does not provide a file path the EFI file to be - * booted is \EFI\BOOT\$(BOOTEFI_NAME).EFI. The architecture specific - * file name is defined in this include. - * - * Copyright (c) 2022, Heinrich Schuchardt - * Copyright (c) 2022, Linaro Limited - */ - -#ifndef _EFI_DEFAULT_FILENAME_H -#define _EFI_DEFAULT_FILENAME_H - -#include - -#undef BOOTEFI_NAME - -#ifdef CONFIG_SANDBOX - -#if HOST_ARCH == HOST_ARCH_X86_64 -#define BOOTEFI_NAME "BOOTX64.EFI" -#elif HOST_ARCH == HOST_ARCH_X86 -#define BOOTEFI_NAME "BOOTIA32.EFI" -#elif HOST_ARCH == HOST_ARCH_AARCH64 -#define BOOTEFI_NAME "BOOTAA64.EFI" -#elif HOST_ARCH == HOST_ARCH_ARM -#define BOOTEFI_NAME "BOOTARM.EFI" -#elif HOST_ARCH == HOST_ARCH_RISCV32 -#define BOOTEFI_NAME "BOOTRISCV32.EFI" -#elif HOST_ARCH == HOST_ARCH_RISCV64 -#define BOOTEFI_NAME "BOOTRISCV64.EFI" -#else -#error Unsupported UEFI architecture -#endif - -#else - -#if defined(CONFIG_ARM64) -#define BOOTEFI_NAME "BOOTAA64.EFI" -#elif defined(CONFIG_ARM) -#define BOOTEFI_NAME "BOOTARM.EFI" -#elif defined(CONFIG_X86_64) -#define BOOTEFI_NAME "BOOTX64.EFI" -#elif defined(CONFIG_X86) -#define BOOTEFI_NAME "BOOTIA32.EFI" -#elif defined(CONFIG_ARCH_RV32I) -#define BOOTEFI_NAME "BOOTRISCV32.EFI" -#elif defined(CONFIG_ARCH_RV64I) -#define BOOTEFI_NAME "BOOTRISCV64.EFI" -#else -#error Unsupported UEFI architecture -#endif - -#endif - -#endif diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c index 431a38704e9..2ea20909491 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/lib/efi_loader/efi_helper.c b/lib/efi_loader/efi_helper.c index 00167bd2a10..51e0c4852c5 100644 --- a/lib/efi_loader/efi_helper.c +++ b/lib/efi_loader/efi_helper.c @@ -12,18 +12,63 @@ #include #include #include +#include #include #include #include #include +#include #include #include +#ifdef CONFIG_SANDBOX + +#if HOST_ARCH == HOST_ARCH_X86_64 +#define BOOTEFI_NAME "BOOTX64.EFI" +#elif HOST_ARCH == HOST_ARCH_X86 +#define BOOTEFI_NAME "BOOTIA32.EFI" +#elif HOST_ARCH == HOST_ARCH_AARCH64 +#define BOOTEFI_NAME "BOOTAA64.EFI" +#elif HOST_ARCH == HOST_ARCH_ARM +#define BOOTEFI_NAME "BOOTARM.EFI" +#elif HOST_ARCH == HOST_ARCH_RISCV32 +#define BOOTEFI_NAME "BOOTRISCV32.EFI" +#elif HOST_ARCH == HOST_ARCH_RISCV64 +#define BOOTEFI_NAME "BOOTRISCV64.EFI" +#else +#error Unsupported UEFI architecture +#endif + +#else + +#if defined(CONFIG_ARM64) +#define BOOTEFI_NAME "BOOTAA64.EFI" +#elif defined(CONFIG_ARM) +#define BOOTEFI_NAME "BOOTARM.EFI" +#elif defined(CONFIG_X86_64) +#define BOOTEFI_NAME "BOOTX64.EFI" +#elif defined(CONFIG_X86) +#define BOOTEFI_NAME "BOOTIA32.EFI" +#elif defined(CONFIG_ARCH_RV32I) +#define BOOTEFI_NAME "BOOTRISCV32.EFI" +#elif defined(CONFIG_ARCH_RV64I) +#define BOOTEFI_NAME "BOOTRISCV64.EFI" +#else +#error Unsupported UEFI architecture +#endif + +#endif + #if defined(CONFIG_CMD_EFIDEBUG) || defined(CONFIG_EFI_LOAD_FILE2_INITRD) /* GUID used by Linux to identify the LoadFile2 protocol with the initrd */ const efi_guid_t efi_lf2_initrd_guid = EFI_INITRD_MEDIA_GUID; #endif +const char *efi_get_basename(void) +{ + return BOOTEFI_NAME; +} + /** * efi_create_current_boot_var() - Return Boot#### name were #### is replaced by * the value of BootCurrent diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index 841729bd1ac..7cfb217088e 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,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/" - 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 29 19:22:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2003873 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=Lc1N22Ei; 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 4XdKt26zf8z1xwc for ; Wed, 30 Oct 2024 06:23:22 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5A97B891AA; Tue, 29 Oct 2024 20:22:44 +0100 (CET) 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="Lc1N22Ei"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D8948891A8; Tue, 29 Oct 2024 20:22:40 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.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-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) (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 D7E39891B6 for ; Tue, 29 Oct 2024 20:22:37 +0100 (CET) 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-lj1-x234.google.com with SMTP id 38308e7fff4ca-2fb5638dd57so54021381fa.0 for ; Tue, 29 Oct 2024 12:22:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1730229757; x=1730834557; 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=ofGwYljnh2oh1BIgJMhD1YAKquGpAWcsW2USCwLdKmw=; b=Lc1N22EiUFuBae/niGFjNlZQxhx2YR9LU9bswGBUAqthD4Unsfmbu4EZMU1weEhax0 /g79TUYYs/R58Vxpq95MO9Y4dakJ3XVs4vWp1ifHE1jEMx4T+pFVUtzdwVUkEtGUNnQd +9PyQrBZDXo9XT4Vd7lk2tFzxl+jN0FWmaj9o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730229757; x=1730834557; 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=ofGwYljnh2oh1BIgJMhD1YAKquGpAWcsW2USCwLdKmw=; b=QsaDCMatjei74Vv6VJCtQP5GoqIkv3O22kTMpwYlu8XtQOejEasY7vt66z8QKm5C4n UpkScBDM2UDB601ULY7XJnooJmMm3OcZs8U2UM1CkEVvmtDLlizK9z5BMSpj2CVqNdRQ K75u1ZCS816YooDd3ifvzMP1PMLsstyIX03H2s3pbxYhw8HB8njqHCtFngu7fEiCYprU BdXPuW4VXrNTei4fXrXtmMGi16mD7u1qT9D0XN0v8d8ltcBkxAzD1+Cf31g4x6FMHfS8 kTsfGAhOy60S1WmzpT6OQSNWYw7CQTTeCKSKbkucZRs/STzvEV+ipDkniLvK6T+KqWio 5r4w== X-Gm-Message-State: AOJu0YwwxBuegPVH6xmKbKZEarNNvPG+D/iuN3CPi0f8o2YHhTxCpqk/ ApJJekEh9BqqfdwRL3pxiePiKJ42l97qjRCyj/U5SnYM3VVPCOptKpzoUdEIQdhtnz4PKKkmMGr tp25h X-Google-Smtp-Source: AGHT+IHZP39/O86qQ7M3X4FkoFZUqo13U8/8+XNKJkHf9bQILkpmyZVrNnuGbyR/vuBs4lbno+WbHA== X-Received: by 2002:a2e:812:0:b0:2fc:ba7a:c982 with SMTP id 38308e7fff4ca-2fcbe07bbd9mr52661751fa.36.1730229756516; Tue, 29 Oct 2024 12:22:36 -0700 (PDT) Received: from chromium.org ([87.215.50.114]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cbb629f65esm4272770a12.36.2024.10.29.12.22.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 12:22:35 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Ilias Apalodimas , Tom Rini , Heinrich Schuchardt , Simon Glass , AKASHI Takahiro , Caleb Connolly , Mark Kettenis , Masahisa Kojima , Mattijs Korpershoek , Shantur Rathore , Sughosh Ganu , =?utf-8?q?Vincent_Stehl=C3=A9?= Subject: [PATCH v9 05/11] efi_loader: Move get_efi_pxe_arch() to efi_helper Date: Tue, 29 Oct 2024 20:22:13 +0100 Message-ID: <20241029192222.362445-6-sjg@chromium.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241029192222.362445-1-sjg@chromium.org> References: <20241029192222.362445-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 Move this function from the EFI bootmeth to the common efi_helper file. No functional change is intended. Signed-off-by: Simon Glass --- Changes in v9: - Split out into a separate change boot/bootmeth_efi.c | 25 ++----------------------- include/efi.h | 10 ++++++++++ lib/efi_loader/efi_helper.c | 23 +++++++++++++++++++++++ 3 files changed, 35 insertions(+), 23 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/include/efi.h b/include/efi.h index fef88e9c5d6..633f5b4acb5 100644 --- a/include/efi.h +++ b/include/efi.h @@ -679,4 +679,14 @@ void efi_show_tables(struct efi_system_table *systab); */ const char *efi_get_basename(void); +/** + * 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 */ diff --git a/lib/efi_loader/efi_helper.c b/lib/efi_loader/efi_helper.c index 51e0c4852c5..b8ece1c2e0c 100644 --- a/lib/efi_loader/efi_helper.c +++ b/lib/efi_loader/efi_helper.c @@ -21,6 +21,8 @@ #include #include +#undef BOOTEFI_NAME + #ifdef CONFIG_SANDBOX #if HOST_ARCH == HOST_ARCH_X86_64 @@ -69,6 +71,27 @@ const char *efi_get_basename(void) return BOOTEFI_NAME; } +int efi_get_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; +} + /** * efi_create_current_boot_var() - Return Boot#### name were #### is replaced by * the value of BootCurrent From patchwork Tue Oct 29 19:22:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2003874 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=DKMckKNa; 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 4XdKtD2sf1z1xwc for ; Wed, 30 Oct 2024 06:23:32 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C8CCA89191; Tue, 29 Oct 2024 20:22:44 +0100 (CET) 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="DKMckKNa"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CFC6F891AA; Tue, 29 Oct 2024 20:22:41 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.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-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) (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 DFCF789174 for ; Tue, 29 Oct 2024 20:22:39 +0100 (CET) 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-x531.google.com with SMTP id 4fb4d7f45d1cf-5c9634c9160so6664125a12.2 for ; Tue, 29 Oct 2024 12:22:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1730229759; x=1730834559; 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=GnM7MM7p6MWwzPuPCcQyIMM+5swduzRBP8G273R0g1Y=; b=DKMckKNa23lowr6/Chu5QVwmknORUW5Y3EjHth7OoujKi/iq6pqCuB/reXvEdBNhje B9D37UUiK1woBE5vxgjl3xIMq/VBDn/jhBdqNkt2QnIxCiEihFsT/E8hl2PRM6KjmHyX H1gTeAMNuxj46yxe+tULuVjn/rVJFgLSUpydA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730229759; x=1730834559; 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=GnM7MM7p6MWwzPuPCcQyIMM+5swduzRBP8G273R0g1Y=; b=fu3uuDhtQ5fFfKebXmSspIVb8MB2TVymsyh1BSb923UPl5ovuXnm3nU+cFtGLid+Bs BgUsV9ugcxZO2ldpi/w4OYD7x0YvUe0aoMOJtbESU+lHYnnQk2f/mMLtTszrCWeHeRHM F41TZ9cj0lFE4RFIvt7I95aLZhiIAR/FM22TXDeoc0E9tB273taLPXG8lfQlZp7uznAA swqqgVjp4SI/iB+OD+aFo2hkvsOnO++cTkLfIg6tBS9UBWE3PaIWv9h6JP5IeiCuGmfb WRSb/zlM5VZd87oNntLb3ia9uu5ghW9kW35Jo3dx+VQc/gGXvONRwB0K8FyAJeqwhW87 3y4Q== X-Gm-Message-State: AOJu0YysekvJbH8QujvdpZM3Sx9exb/E90YiTkIe/nRZYGQIc+w3kch9 ZR4pbs2jE6X/+CkKxYjsZVodJb7xsIJO5K2Ey6IJidR3zHod/laov82UIxYuPc1IE/s9WNnG/FV zUDpD X-Google-Smtp-Source: AGHT+IGE9IG7t4ETBNqEfvgzuQpCgCsytIiR4no/XM/Z9axpsXa4Anu3TNRQw2kqY0HWJDSmDpPajA== X-Received: by 2002:a05:6402:849:b0:5ca:e5d:f187 with SMTP id 4fb4d7f45d1cf-5cbbf8b4f45mr11283320a12.17.1730229758228; Tue, 29 Oct 2024 12:22:38 -0700 (PDT) Received: from chromium.org ([87.215.50.114]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cbb629f65esm4272770a12.36.2024.10.29.12.22.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 12:22:37 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Ilias Apalodimas , Tom Rini , Heinrich Schuchardt , Simon Glass , AKASHI Takahiro , Masahisa Kojima Subject: [PATCH v9 06/11] efi_loader: Allow reporting the host defaults Date: Tue, 29 Oct 2024 20:22:14 +0100 Message-ID: <20241029192222.362445-7-sjg@chromium.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241029192222.362445-1-sjg@chromium.org> References: <20241029192222.362445-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 an 'efidebug filename' command to report the default filename and PXE architecture. Signed-off-by: Simon Glass --- Changes in v9: - Split out into its own patch Changes in v8: - Add new patch to report host default-filename in native mode cmd/efidebug.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/cmd/efidebug.c b/cmd/efidebug.c index bba984b2b75..ff6d118876d 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -536,6 +536,27 @@ static int do_efi_show_log(struct cmd_tbl *cmdtp, int flag, return CMD_RET_FAILURE; } + return 0; +} + +/** + * 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; } @@ -1589,6 +1610,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(log, CONFIG_SYS_MAXARGS, 1, do_efi_show_log, "", ""), @@ -1688,6 +1711,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 log\n" From patchwork Tue Oct 29 19:22:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2003875 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=hmK5uy/N; 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 4XdKtR1Fwbz1xwc for ; Wed, 30 Oct 2024 06:23:43 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3A5A5891C3; Tue, 29 Oct 2024 20:22:45 +0100 (CET) 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="hmK5uy/N"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8D0B7891A4; Tue, 29 Oct 2024 20:22:43 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.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-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) (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 4BDA58919E for ; Tue, 29 Oct 2024 20:22:41 +0100 (CET) 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-x531.google.com with SMTP id 4fb4d7f45d1cf-5c935d99dc5so6659608a12.1 for ; Tue, 29 Oct 2024 12:22:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1730229760; x=1730834560; 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=bTPCC4UB6hVwvrzr+y2rw+9+YanVNb1eOV/wKPn0aPM=; b=hmK5uy/N2fHWH2rgr+skXk+S/B5l5X0Q5LuOXQ20pl73Lu81UedvUYg9sSxLj8rJvC sabzF/oPp8UdaIg/dKhh3Cfj+lP2XIxL5Cub8FzkinNTBk4DEokfJnyLtm3vZROBuNay vsvUCzbEGD46wyNjGAjTRfXEb9JUyH4R8KpTA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730229760; x=1730834560; 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=bTPCC4UB6hVwvrzr+y2rw+9+YanVNb1eOV/wKPn0aPM=; b=aFNmjknzILRxavU3vlYkJblaXLsrDy+y8fl9DRDZStAlLS9g9yJQZS3tpco7tnmIjG HuF96X9hYgSBhJWn+aD+nuaApzvlUfZoO2eGEaCYC9YOnYDRItx436NrLKRbiMZadLKm QwZ9p2HyVLB0wvnPjm2QDTbpCesU42V2Nh0v1rHaPZR2h8BLNOIx2Scz7Mn/7USHcYOy vApDezsIjr0E+6r+eAtTZo9aRFUXIdUUrGd6Bqzt7smymScZ6XxQlmwN122DaJSOuU66 /vToHhbuplsONdClITXfS2w2mv8HDrfz1bEJoSECrElgD8Zl6If0uu8mwygJqUQL281G Q2fA== X-Gm-Message-State: AOJu0YysZLK8lkuxVWmelLtyC6hILmNbOxQanNTMyI/2GAeXdvLOOdiB rTsG1t4WH73WyyKZgXPXUpxUUol7qk6DEWOSVCqS0xx+oXMS6unIhIsDElfb0S2GB1tOzNZJiLx rEWbs X-Google-Smtp-Source: AGHT+IFM3ijxEaTFXCUYAidcODc4g6Qr7O92TEZMY8PSoMb7pbtGDmXpg7pwFUcmJo5Ioekeirq3ug== X-Received: by 2002:a05:6402:5202:b0:5c9:5cff:3cc2 with SMTP id 4fb4d7f45d1cf-5cbbfa71a66mr9625671a12.29.1730229760259; Tue, 29 Oct 2024 12:22:40 -0700 (PDT) Received: from chromium.org ([87.215.50.114]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cbb629f65esm4272770a12.36.2024.10.29.12.22.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 12:22:39 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Ilias Apalodimas , Tom Rini , Heinrich Schuchardt , Simon Glass , AKASHI Takahiro , Caleb Connolly , Mark Kettenis , Masahisa Kojima , Sughosh Ganu , =?utf-8?q?Vincent_Stehl=C3=A9?= Subject: [PATCH v9 07/11] sandbox: Report host default-filename in native mode Date: Tue, 29 Oct 2024 20:22:15 +0100 Message-ID: <20241029192222.362445-8-sjg@chromium.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241029192222.362445-1-sjg@chromium.org> References: <20241029192222.362445-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. Allow the same control for PXE too. Signed-off-by: Simon Glass --- Changes in v9: - Separate into separate patches Changes in v8: - Add new patch to report host default-filename in native mode include/efi.h | 15 +++++++++++++++ lib/efi_loader/efi_helper.c | 35 ++++++++++++++++++++--------------- 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/include/efi.h b/include/efi.h index 633f5b4acb5..817bc56c835 100644 --- a/include/efi.h +++ b/include/efi.h @@ -679,6 +679,21 @@ 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 * diff --git a/lib/efi_loader/efi_helper.c b/lib/efi_loader/efi_helper.c index b8ece1c2e0c..ab5678eb66c 100644 --- a/lib/efi_loader/efi_helper.c +++ b/lib/efi_loader/efi_helper.c @@ -23,27 +23,31 @@ #undef BOOTEFI_NAME -#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" @@ -59,8 +63,6 @@ #error Unsupported UEFI architecture #endif -#endif - #if defined(CONFIG_CMD_EFIDEBUG) || defined(CONFIG_EFI_LOAD_FILE2_INITRD) /* GUID used by Linux to identify the LoadFile2 protocol with the initrd */ const efi_guid_t efi_lf2_initrd_guid = EFI_INITRD_MEDIA_GUID; @@ -68,11 +70,14 @@ const efi_guid_t efi_lf2_initrd_guid = EFI_INITRD_MEDIA_GUID; 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; From patchwork Tue Oct 29 19:22:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2003876 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=eOVsclOz; 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 4XdKtd66Zjz1xwc for ; Wed, 30 Oct 2024 06:23:53 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A75D1891B6; Tue, 29 Oct 2024 20:22:48 +0100 (CET) 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="eOVsclOz"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B0B52891B1; Tue, 29 Oct 2024 20:22:44 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.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 C969F89174 for ; Tue, 29 Oct 2024 20:22:42 +0100 (CET) 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-5c96df52c52so7315421a12.1 for ; Tue, 29 Oct 2024 12:22:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1730229762; x=1730834562; 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=apWNiKGtUTezi357mxk6DHyTrCacxB1McHI5th0XYxs=; b=eOVsclOz58MyyTVFE86Iu/vy68RTGtWLOsgm2ZozZeiCuJxH2FOtjtzS2n5C4nHlmZ iqduLu9JaYbUa4sr/hCzu29vrxCBaaB7xdSdxEUb1DQPpnzaj33A1K0REqlNFVvaovjK km5JadbBbJc5jAQBRzW4nYaXn2Ro5dRlffwac= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730229762; x=1730834562; 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=apWNiKGtUTezi357mxk6DHyTrCacxB1McHI5th0XYxs=; b=iFof0OyWGXi4lbd2CICAgGZ9eGCx/wJcbBlGeJtk1C8UWe2EfAaCPwH2Krwe1cU4BM HlR5JyrmZ+volvc3663AmZlqvbsYDbjODRNoheok8lWfHsS1LniDPmMxzDHo9Y1+B3z6 Bdu2RWFgBnERFUE3xBadnS1JdL8obTqa0ptMjq47iHHim9f7cqXK1t4XH/2uE7hBoTNu v96ZqhY2++vVJZjIvVTUQF8fHgzCI1ldVHT1LlBwhDrwmV66F6czLnFUxmXZyJplqUho Q2mRJx5Frbl7pying87kHwtYNH3+ojh5UaX5D3zU89OfCH8rgCrAz8f2U8roVTvjTAbh qL1A== X-Gm-Message-State: AOJu0YwO0WhYDk2BeNP5yQlU7aumrVoTbvE1LLSZLVr7ZwvPaiTD0dLE +4bnHOysN3y4d3PefYNKe92BkAd6g6mTrs1e9+PokgIhVztu+Jwh8otpXAcpGiR+sdw+r2jM/bL Zu03t X-Google-Smtp-Source: AGHT+IF+J1Dp+dc+/OrChjb+91L2htsv3SvwyOlazLG9PtPBHGa/tdYO0S+5v959x8qdxVljuBW+BA== X-Received: by 2002:a05:6402:440a:b0:5cb:dcf7:fd35 with SMTP id 4fb4d7f45d1cf-5cbdcf7fdb7mr6583983a12.13.1730229761783; Tue, 29 Oct 2024 12:22:41 -0700 (PDT) Received: from chromium.org ([87.215.50.114]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cbb629f65esm4272770a12.36.2024.10.29.12.22.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 12:22:40 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Ilias Apalodimas , Tom Rini , Heinrich Schuchardt , Simon Glass , AKASHI Takahiro , Mark Kettenis , Masahisa Kojima , Sughosh Ganu Subject: [PATCH v9 08/11] efi_loader: Drop sandbox PXE architecture Date: Tue, 29 Oct 2024 20:22:16 +0100 Message-ID: <20241029192222.362445-9-sjg@chromium.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241029192222.362445-1-sjg@chromium.org> References: <20241029192222.362445-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 Rather than returning 0, just return an error, since sandbox is not used with PXE at present. Signed-off-by: Simon Glass Reviewed-by: Tom Rini --- Changes in v9: - Add new patch to drop sandbox PXE architecture lib/efi_loader/efi_helper.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/efi_loader/efi_helper.c b/lib/efi_loader/efi_helper.c index ab5678eb66c..bf96f61d3d0 100644 --- a/lib/efi_loader/efi_helper.c +++ b/lib/efi_loader/efi_helper.c @@ -91,8 +91,6 @@ int efi_get_pxe_arch(void) return 0x19; else if (IS_ENABLED(CONFIG_ARCH_RV64I)) return 0x1b; - else if (IS_ENABLED(CONFIG_SANDBOX)) - return 0; /* not used */ return -EINVAL; } From patchwork Tue Oct 29 19:22:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2003877 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=FD5jb2R4; 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 4XdKtq00gDz1xwc for ; Wed, 30 Oct 2024 06:24:02 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 192E6891C7; Tue, 29 Oct 2024 20:22:49 +0100 (CET) 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="FD5jb2R4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5C04C891D6; Tue, 29 Oct 2024 20:22:46 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.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-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) (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 2B4528919E for ; Tue, 29 Oct 2024 20:22:44 +0100 (CET) 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-x534.google.com with SMTP id 4fb4d7f45d1cf-5c935d99dc5so6659659a12.1 for ; Tue, 29 Oct 2024 12:22:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1730229763; x=1730834563; 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=FD5jb2R4mRZA7QGpJvZ8/iVdgG+pOB4/dfmiWGNEHO+qa78clBlm2Qj2RKbyrojJ7e Q1K8NFav68N4Em4yrLvsX0oyQQ+WSafZpYwewpMJeZ08L/XEV48/bIQiyzf6OVsq+lJ9 MmQV6p85oh1IiGqej8Mxkn4pWc08+rsgKx+UY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730229763; x=1730834563; 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=Z1unirOWAufmmzhnqcebQCpH/KtUCtF+5Thj5bdUN44mqjhB2YsrV9Vyncx8SwK72h l0F1wk/ZlLDH0jbDj1Yz7n0LndUOGpAmDFMQuTFW4Whl58h6dRTXUBY5JxEw7SCsCuqy V8xs3I30fZPmszDjkMVPZu1O5CJeEZWUpT3fRKAGkhvx0m71b7WIChdKHjk7GqT5oczS tDkIedPojwLrvojb9K40WoPi0/9chPpsV5HEnYKKtKozlE8iFjW3A8wevXKKqu47AWvR 5wuKoDDwvwBoOoJTN9OkLYC5tkC/bvH7rZoUqJ39dx4BFgFocjwRjWorQ103UalBt3zX lR4w== X-Gm-Message-State: AOJu0Yww8lQORVOoJ2F0lbjvBfBzGB5UfayE/lYgtsdpp1r3rUrD0BBx z47jBHeIU8vqBG8wqUcOveSaixSjh1UYOH0tdLj7WjkL9KtR/o1dIAvEVHyRPydq+2F75D5/bkE AM5f1 X-Google-Smtp-Source: AGHT+IG3AWaKA3/oQ8McOlVZ1iy3KxZNJ0JI8wl+Btxv08P2GGNZCOh4O1gPTukUeVdvyXRuRah8dw== X-Received: by 2002:a05:6402:2711:b0:5c3:d2bc:2f64 with SMTP id 4fb4d7f45d1cf-5cbbfac3a40mr8995006a12.35.1730229763121; Tue, 29 Oct 2024 12:22:43 -0700 (PDT) Received: from chromium.org ([87.215.50.114]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cbb629f65esm4272770a12.36.2024.10.29.12.22.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 12:22:42 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Ilias Apalodimas , Tom Rini , Heinrich Schuchardt , Simon Glass , Dan Carpenter , Jiaxun Yang Subject: [PATCH v9 09/11] sandbox: virtio: Disable the sandbox virtio blk device Date: Tue, 29 Oct 2024 20:22:17 +0100 Message-ID: <20241029192222.362445-10-sjg@chromium.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241029192222.362445-1-sjg@chromium.org> References: <20241029192222.362445-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 29 19:22:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2003879 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=Gtzaq/vW; 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 4XdKvB4lzXz1xwc for ; Wed, 30 Oct 2024 06:24:22 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 250E7891D4; Tue, 29 Oct 2024 20:22:53 +0100 (CET) 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="Gtzaq/vW"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C6499891A8; Tue, 29 Oct 2024 20:22:50 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.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-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) (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 C3424891D4 for ; Tue, 29 Oct 2024 20:22:45 +0100 (CET) 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-ej1-x62c.google.com with SMTP id a640c23a62f3a-a9a977d6cc7so413489066b.3 for ; Tue, 29 Oct 2024 12:22:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1730229765; x=1730834565; 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=MiBONus4oTVlVBr/jerbObQ2Ci+VSu2+aOE9bUGQhoI=; b=Gtzaq/vWj4jLITuICWRIxQ5oLUvmo0VDou0PcyFdDTvJip1HQqASEn9N6i3l5seaTa csbH1u0H4y+Y5Ln8NAKmOubz53oQNY28LYf4jimuOG+SyMtuxnsm3kN0Ud7vuD+/9+v8 dcweDjODIcilVdX5L9P4F/3lgWsYKeEC4c6p0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730229765; x=1730834565; 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=MiBONus4oTVlVBr/jerbObQ2Ci+VSu2+aOE9bUGQhoI=; b=BD076A93Q9jvspkE8YWb8c0QV8DBBMuLB7Lq0pLdS9YcrEJcpZ05Mp0qazrs2nt9W3 0ZalWXTXZN7mMMi+l4othG7wVNMjPEPfzkIvNmw7H2nHh8+8Yl4Y3Nh2qSjnv+0hUL7X RaVDZtPOH8BJoqkVydTvmaB6YD+8Q7PpHMNVxVPfmxFPWBqxS4qPtBhQ+boKv7BrOmnx PbZ+VQnhKDxdutRSHsb51pAdK89cQd3xymXUNS9T5hHpTRpDhk5RvP6ZeAXL0IhhlvgZ d7LfWJoxM29Yxc0dP45EMb1byKLrb0cdG8ovKM3fLBkQjyBAEuwsNksRBUSw4s8r/oVS aIAg== X-Gm-Message-State: AOJu0YwVLx78RlAcB0YYrdCkZJ1l/4q5BPNeblOo7OqZgjy74KK5U1du XES40D2slS1MzaPSKg/TdOzniVYl1BUGZheJkttheANmsKg2WX5R7vdidovsun07TBdJ4yLGiQ8 BYO5m X-Google-Smtp-Source: AGHT+IGMt1OIfEEIUlLRA+XY0F4aiybJRHXLQ5wsb1ReyYqK0/MEsuhmEIbda7mVnIpu8P/+WniwZQ== X-Received: by 2002:a05:6402:28c5:b0:5cb:bebb:38d8 with SMTP id 4fb4d7f45d1cf-5cbbf8c2365mr12819562a12.14.1730229764720; Tue, 29 Oct 2024 12:22:44 -0700 (PDT) Received: from chromium.org ([87.215.50.114]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cbb629f65esm4272770a12.36.2024.10.29.12.22.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 12:22:43 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Ilias Apalodimas , Tom Rini , Heinrich Schuchardt , Simon Glass , AKASHI Takahiro , Algapally Santosh Sagar , Caleb Connolly , Christian Marangi , Francis Laniel , Guillaume La Roque , Jerome Forissier , Julien Masson , Marek Vasut , Mattijs Korpershoek , Patrick Rudolph , Sean Anderson , Sughosh Ganu , Venkatesh Yadav Abbarapu , Yang Xiwen Subject: [PATCH v9 10/11] test: efi: boot: Set up an image suitable for EFI testing Date: Tue, 29 Oct 2024 20:22:18 +0100 Message-ID: <20241029192222.362445-11-sjg@chromium.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241029192222.362445-1-sjg@chromium.org> References: <20241029192222.362445-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/ Changes in v9: - Mark the image as complete after writing it 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 -> 4980 bytes test/py/tests/test_ut.py | 53 ++++++++++++++++++++++++---- 5 files changed, 66 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 3017b33d67b..dee280184b1 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -1515,7 +1515,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 7cfb217088e..d7e94c8cc59 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -534,7 +534,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..0efd9cbe146db6e8f422d9d66f11a772a493ce29 GIT binary patch literal 4980 zcmeI0=Tj4i7R3`1KqLr)p-B}&4JFb+KqH94Kp+GJlp<0VkeU!Wgx;4TBDm5Pr7FED zum+G$fT%1rNH5YmQu5x+`}FqBzPG!xyC2^87o53g&OP@x_f*N>%mM%aFAUe*q5%j3 z*#Q6mPG&xzN)-a1Spop=rzd*T-}PL~uF2S?6A#+6_UCgv&5T9A@HnTfgBnG<#29-G zQ6tzw#X%K2(1UtSDtsp9_5%5!ac(BcwW3K00~9b=T*7bL&CqGC>h>p|X~|)K>Oqyf z)h%5P@>EV`jkscdNBa6sNNkEw9L%R&;xk~xv&@anG4u<9j!i?nAJ@-!PXKu|X{>%I zZpWZT=#_XhRjany-Yjih!mOd^fJ|n)KxKJ+=;>>I$kLY^9L5>>7ZuAM(@XEUY|K5* zAu`A5=kXg1qvfV_qr3a^%Rr*yh|R<2%A`u>6i4UTB(vk5YolsiJ^E$UJ}(TAq<$=W z#=gnJSCw}>?DA&!8LqJArM;*mDQv0FK8HF83^jUYxV`_L!EVr zx3?_5J~;hJDtzUu9dFefk9XsyKGbhqFlj=Ql)U1G9d@j!T2~lyn!=2U?BlZ1sWBxx zF9Mr{KA99TzM{bZm7`OA!)9*b(%kkrWzjbb7tY+WwAwj7R3kg5s8_bZVDxAC2&R?0 zEq>h@Pg%?QA5{?bHYS4PDqlt0hK_x!Qz4Hf$z90Rx?%kUS$hswy8*Ew_HKkEP{5c0kzySZNs-C8qq z!Ohdx2yF~>)HupV;UtD5a#)+un%=BpRc}Wg$4I5?arpzYX&0eX@a9J^VR&^YFGyL< zJeh>W37J1<8e@SA)k5=id4#fS!?mt%sfm2y@v45Uf0l6}(!Xvo-*@N@v3iJ{rLsO>!p*QyMwShucG(c8m(LW_x8q4#-UidLW zq!`8&wOPwlit6aob#)X4I=W6forH0=%lT`B;g!UH$vxH%zw=HZcR2!f(}uyn?qJ)0J>I$qoK`483QN7q9Q z@PQ;^CZ7^52Ks?wJ*HvtupMwbJs?9*w1zN%trQk%cn!}SBXKkub~~Zni{>f|o$ZY0 z70~mLxNvHG7Lvl`wzK`QW*)uozrnvutu|`EcMt0R$dY{RNM5?=8RRotR`vaIU|}-d z-sg!WY{Y}^xK-tlnl0#Ax%)@d1U}kQ}NwP#&;~H7-1D zDGNk!=hP=6+&r=ig{)V_dLxIPWW)taq-=|NA8@^+%Me3-MJ-9^#eeBClE8s(7Ph@- z7~Q4vk-K*^E*abYN45M?@NaCjzgD^emF|3)LuCO<{#NJoGfqd!KP5B&(U$&e=lQP( z;!lw_V%Dt6p*8{4f8DU?p1Fo#*IY&@W?FR*PU#{@@j@?XRbl*&Ph|nQ3*Ix3lBZ2P zgqIx}X<`oEq{>ARp`t^&_|d(PVW!KPK|ZD7mjvC0KKcK@W^sDMoA51jzk`SVmAP+A z`kMjrn_<6`xW5_phYZsPhyD5)_;=#?TkmF0;NTPd(YU2wt5s)>DRZQJt#oyAkX-nF zWxssL8b|#_C8TMPMsYjQh6j0ZW7|Tsh4U^3l8I=rD$1@hZ{XNvWe=Wxs+~umO%OzFTSy?aAX}AGTV^02V^Ok7T&eLi2lR+15yk}lUC!7_?ZZSce@NeOxIexYVA`D)=HT90%^g7hu3+#Fv zv^5E$4?-`AJ^()aF)zUjMRDbmjdc$m^E~a+-;Cgp6X(;15Y)#s6+T81Rg0Vb8sk*5 zlfSb*OIXyrLIa6hzAov`P#lB@ai>-v%}=d%`lhNpxxDF*;sTe`?*a7(k2nO?VOwz> z3$k2d?XGr4_uLDx8)ESv&c9jS&TaBfUR^^speQ-Va_vI7X{3>K_kXNl@KFkOqP z8+>bth>~@z;|$qwm1ak`WH?{2Nq#9eI?#>%Bsys)cDGbLpX_4fLRPKD;D5X-)Xkq7 zn!1qIAFX2WpxJu*gX=h?fFp#vv)=J0Ev%vOTGID#XfBI8P!17f)g@J1l>&k_*vbDa zKCAW!Yo(JaLmu0);+r4{;6u)j*w@xfY(EWSWZMXg@zbPM5Od(C4 zq6x=m7aeu3GuDqlyKIYalzyMFh^iGU5J+e#DZ34s?gL%6sLB;iv3b|{krg9J=u-YI;wxFMxP!AsSr8K5;3(JN}%jY##0`Wmn%BsC6^9X%?8P zd0?UFwfqbzpe#M`*^z%Ca3NP~YinhvZnjRXTC`#2I%mR`{dx<=+O?Ie^yq_m8Amw} zL!YEBKPHmqnur`MC;En#uoLaE?tIr*=D;lD(_BIByy7T~>AvE9LlKT{fname}']) def setup_bootmenu_image(cons): @@ -549,6 +551,44 @@ 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()) + complete = True + 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 +599,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 29 19:22:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2003878 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=CYr8SG8C; 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 4XdKv01nLMz1xwc for ; Wed, 30 Oct 2024 06:24:12 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B5389891A8; Tue, 29 Oct 2024 20:22:52 +0100 (CET) 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="CYr8SG8C"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C83FC891CF; Tue, 29 Oct 2024 20:22:49 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.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-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) (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 6FDE989174 for ; Tue, 29 Oct 2024 20:22:47 +0100 (CET) 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-x532.google.com with SMTP id 4fb4d7f45d1cf-5cb74434bc5so7429259a12.0 for ; Tue, 29 Oct 2024 12:22:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1730229766; x=1730834566; 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=W4mf6kPVh3FFmXUMKUYDgNJh5FYJ4rXkV8XtpeXAdyI=; b=CYr8SG8CYU+KZdHIcYi2qi78P7jK+C9aCxRpt2c008dEd7A/US8aLjxhqhTTOXwsh9 O7cZmdCW2dH7IrGt+1i2GT5ouTCSEHXFQSsJeAONj905vvzi4xC39lqH28TgN86cAKbn eAP7OBeqMW0a2PbedmOj2J7a9iYof1JM2yzhk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730229766; x=1730834566; 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=W4mf6kPVh3FFmXUMKUYDgNJh5FYJ4rXkV8XtpeXAdyI=; b=Ilg53BihaJ0d8zeUNbQ9CvJ/9e8crnyrs7wQ8gWp4qQvkU+W8vKi0HBX4W7HQ8mAJf je1ecvjhh/yyQLptij1uuy+s54tScgGtfhg/hYkePXKlc+hLstCoZjFDN9kJX0VLfJrr UzMxQBmsm1hRt0TRsShTdJi1riRVQ5Dv935bAck/Tx1nyKxMTBQhFlq0IuwxhZ3z75EE G0yMY40OJMvq7zg+CpYmjnfikeQ+6NzwY0+DPHi4SUZaVDf3awNKJ3/qhKJxeynKD/KZ WE0b0llT1DBD6WA+4rAEVXFt/5uvrdKw8z52zfbGc8OpCKrsrLBUcGxOe+pArfqvfBwD fYNw== X-Gm-Message-State: AOJu0Yxe29qY4QwO9+BR2NE/f5ONUrVT17w8LUxyCW4C6NpnwndKAxDI jujsIui/xbigQdZHPZF7XIpblp1RjvMg9KkvzNKhjN51yAz+byHRLg1Yf5nqOyWXV5/ET4RtGHw 19/I0 X-Google-Smtp-Source: AGHT+IHvTVGtvGDWIw77FWOD+2ovE3k+7oaPrzXlszlrYydLsUPMhbyKiozN1EZSrecC1/QeDO5tgQ== X-Received: by 2002:a05:6402:26cb:b0:5c9:218d:7071 with SMTP id 4fb4d7f45d1cf-5cbbf8af006mr9970980a12.20.1730229766320; Tue, 29 Oct 2024 12:22:46 -0700 (PDT) Received: from chromium.org ([87.215.50.114]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cbb629f65esm4272770a12.36.2024.10.29.12.22.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 12:22:45 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Ilias Apalodimas , Tom Rini , Heinrich Schuchardt , Simon Glass , AKASHI Takahiro , Mattijs Korpershoek Subject: [PATCH v9 11/11] test: efi: boot: Add a test for the efi bootmeth Date: Tue, 29 Oct 2024 20:22:19 +0100 Message-ID: <20241029192222.362445-12-sjg@chromium.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241029192222.362445-1-sjg@chromium.org> References: <20241029192222.362445-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/ Changes in v9: - Fix 'sevices' typo 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 | 60 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index d7e94c8cc59..8d4cbbb0702 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) { /* @@ -1217,3 +1221,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 services"); + 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);