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;