From patchwork Fri Dec 17 19:40:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1570306 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=COoX+N0+; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JFzrN5BY4z9sXM for ; Sat, 18 Dec 2021 06:41:40 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 789AC83772; Fri, 17 Dec 2021 20:41:29 +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="COoX+N0+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 57C3B83751; Fri, 17 Dec 2021 20:41:26 +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.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2A29183736 for ; Fri, 17 Dec 2021 20:41:22 +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-il1-x135.google.com with SMTP id x15so2477969ilc.5 for ; Fri, 17 Dec 2021 11:41:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WcHkGvCJ1tbqvZ7BTYFwpZsAONEwYpOhBC0xy5P2ZYs=; b=COoX+N0+dlE6FCLX8pRiiCeqrH+yB/P1mcj0PGpr9/mGxz6xVYuOezK4FPUwwrzeQi 2yMEwcHcWoihYQV2dordXKM2IMC25H/5prcPMVsCyOzvKAksEi9l16udtEFcQf7vbNAV o8DgfXKeb9UamxAujCACz93eApbXXcD/yaSkk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WcHkGvCJ1tbqvZ7BTYFwpZsAONEwYpOhBC0xy5P2ZYs=; b=eD65zYhbubszS6uZikSLvNYBx/B6UZqKLmH+0Ke/ZTpu+hnk3fLAtF0o4HBBONiDtm 6oID4yhhaEwDPUoi9ZAS8oAoOtfvo/5G9XYl816b4GlqO2wN+5Ni8QlOV1UH5XRsTGjK 55zBRqOdWHME03sQYeZGQBxT7gr79SRtsDFu7c4e88czk516TWFXN0a/wXegly/RuKkr kdLx8TRuMcjG+eo9ZlUn5yFuLZa6g4C9hJ5m4jjF6AwOxPXEXml4AhBs3FGpNg7kud9b /Dy7EVcHeH7RBubfbH2KhoM4Vg746FEfeseFxWAlibmdCMmu69vAK4rN6h/gmNfXo5PJ S0Bw== X-Gm-Message-State: AOAM532OICqIJweWEKu/CBvd2JeYrAbq93HCsgV1UHezRkHagji2LxnS nObAPcQmCMi+cow08+YWcLLIk647yRmiCQ== X-Google-Smtp-Source: ABdhPJzGu0BXIB0K1Xz4bnzzXvq/K9tVGZDiSzyhvAZF2zYWjHT5hyyhGMQGkNbFKv3T0YoVSQZEVA== X-Received: by 2002:a92:c089:: with SMTP id h9mr2322261ile.289.1639770080658; Fri, 17 Dec 2021 11:41:20 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id w19sm6079605iov.12.2021.12.17.11.41.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Dec 2021 11:41:20 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Heinrich Schuchardt , Tom Rini , Ilias Apalodimas , Christian Melki , Simon Glass , Alexander Graf Subject: [PATCH v6 01/27] efi: Rename UCLASS_EFI and IF_TYPE_EFI Date: Fri, 17 Dec 2021 12:40:33 -0700 Message-Id: <20211217124039.v6.1.I0fe54c28f143525a17746622da0465cdee6bf405@changeid> X-Mailer: git-send-email 2.34.1.173.g76aa8bc2d0-goog In-Reply-To: <20211217194059.858580-1-sjg@chromium.org> References: <20211217194059.858580-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 at phobos.denx.de X-Virus-Status: Clean These names are better used for access to devices provided by an EFI layer. Use EFI_LOADER instead here, since these are only available in U-Boot's EFI_LOADER layer. Signed-off-by: Simon Glass Reviewed-by: Heinrich Schuchardt --- Changes in v6: - Update comment to UCLASS_EFI_LOADER Changes in v5: - Add new patch to resolve EFI/EFI_LOADER conflict doc/develop/uefi/uefi.rst | 8 ++++---- drivers/block/blk-uclass.c | 4 ++-- include/blk.h | 2 +- include/dm/uclass-id.h | 2 +- lib/efi_driver/efi_block_device.c | 8 ++++---- lib/efi_driver/efi_uclass.c | 8 ++++---- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/doc/develop/uefi/uefi.rst b/doc/develop/uefi/uefi.rst index f17138f5c76..a3e2656ab81 100644 --- a/doc/develop/uefi/uefi.rst +++ b/doc/develop/uefi/uefi.rst @@ -620,12 +620,12 @@ EFI_DRIVER_BINDING_PROTOCOL implementation for the UEFI drivers. A linker created list is used to keep track of the UEFI drivers. To create an entry in the list the UEFI driver uses the U_BOOT_DRIVER macro specifying -UCLASS_EFI as the ID of its uclass, e.g:: +UCLASS_EFI_LOADER as the ID of its uclass, e.g:: /* Identify as UEFI driver */ U_BOOT_DRIVER(efi_block) = { .name = "EFI block driver", - .id = UCLASS_EFI, + .id = UCLASS_EFI_LOADER, .ops = &driver_ops, }; @@ -651,8 +651,8 @@ UEFI block IO driver The UEFI block IO driver supports devices exposing the EFI_BLOCK_IO_PROTOCOL. When connected it creates a new U-Boot block IO device with interface type -IF_TYPE_EFI, adds child controllers mapping the partitions, and installs the -EFI_SIMPLE_FILE_SYSTEM_PROTOCOL on these. This can be used together with the +IF_TYPE_EFI_LOADER, adds child controllers mapping the partitions, and installs +the EFI_SIMPLE_FILE_SYSTEM_PROTOCOL on these. This can be used together with the software iPXE to boot from iSCSI network drives [4]. This driver is only available if U-Boot is configured with:: diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c index 83682dcc181..a7470ae28d5 100644 --- a/drivers/block/blk-uclass.c +++ b/drivers/block/blk-uclass.c @@ -28,7 +28,7 @@ static const char *if_typename_str[IF_TYPE_COUNT] = { [IF_TYPE_SATA] = "sata", [IF_TYPE_HOST] = "host", [IF_TYPE_NVME] = "nvme", - [IF_TYPE_EFI] = "efi", + [IF_TYPE_EFI_LOADER] = "efiloader", [IF_TYPE_VIRTIO] = "virtio", [IF_TYPE_PVBLOCK] = "pvblock", }; @@ -44,7 +44,7 @@ static enum uclass_id if_type_uclass_id[IF_TYPE_COUNT] = { [IF_TYPE_SATA] = UCLASS_AHCI, [IF_TYPE_HOST] = UCLASS_ROOT, [IF_TYPE_NVME] = UCLASS_NVME, - [IF_TYPE_EFI] = UCLASS_EFI, + [IF_TYPE_EFI_LOADER] = UCLASS_EFI_LOADER, [IF_TYPE_VIRTIO] = UCLASS_VIRTIO, [IF_TYPE_PVBLOCK] = UCLASS_PVBLOCK, }; diff --git a/include/blk.h b/include/blk.h index f0cc7ca1a28..f0835c3fed5 100644 --- a/include/blk.h +++ b/include/blk.h @@ -34,7 +34,7 @@ enum if_type { IF_TYPE_SATA, IF_TYPE_HOST, IF_TYPE_NVME, - IF_TYPE_EFI, + IF_TYPE_EFI_LOADER, IF_TYPE_PVBLOCK, IF_TYPE_VIRTIO, diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h index fd139b9b2a0..2d05694982b 100644 --- a/include/dm/uclass-id.h +++ b/include/dm/uclass-id.h @@ -48,7 +48,7 @@ enum uclass_id { UCLASS_DMA, /* Direct Memory Access */ UCLASS_DSA, /* Distributed (Ethernet) Switch Architecture */ UCLASS_ECDSA, /* Elliptic curve cryptographic device */ - UCLASS_EFI, /* EFI managed devices */ + UCLASS_EFI_LOADER, /* Devices created by UEFI apps and drivers */ UCLASS_ETH, /* Ethernet device */ UCLASS_ETH_PHY, /* Ethernet PHY device */ UCLASS_FIRMWARE, /* Firmware */ diff --git a/lib/efi_driver/efi_block_device.c b/lib/efi_driver/efi_block_device.c index 0937e3595a4..04cb3ef0d4e 100644 --- a/lib/efi_driver/efi_block_device.c +++ b/lib/efi_driver/efi_block_device.c @@ -147,7 +147,7 @@ static int efi_bl_bind(efi_handle_t handle, void *interface) if (!obj) return -ENOENT; - devnum = blk_find_max_devnum(IF_TYPE_EFI); + devnum = blk_find_max_devnum(IF_TYPE_EFI_LOADER); if (devnum == -ENODEV) devnum = 0; else if (devnum < 0) @@ -159,8 +159,8 @@ static int efi_bl_bind(efi_handle_t handle, void *interface) sprintf(name, "efiblk#%d", devnum); /* Create driver model udevice for the EFI block io device */ - ret = blk_create_device(parent, "efi_blk", name, IF_TYPE_EFI, devnum, - io->media->block_size, + ret = blk_create_device(parent, "efi_blk", name, IF_TYPE_EFI_LOADER, + devnum, io->media->block_size, (lbaint_t)io->media->last_block, &bdev); if (ret) return ret; @@ -209,6 +209,6 @@ static const struct efi_driver_ops driver_ops = { /* Identify as EFI driver */ U_BOOT_DRIVER(efi_block) = { .name = "EFI block driver", - .id = UCLASS_EFI, + .id = UCLASS_EFI_LOADER, .ops = &driver_ops, }; diff --git a/lib/efi_driver/efi_uclass.c b/lib/efi_driver/efi_uclass.c index 382c2b477f4..b01ce89c84e 100644 --- a/lib/efi_driver/efi_uclass.c +++ b/lib/efi_driver/efi_uclass.c @@ -308,7 +308,7 @@ efi_status_t efi_driver_init(void) log_debug("Initializing EFI driver framework\n"); for (drv = ll_entry_start(struct driver, driver); drv < ll_entry_end(struct driver, driver); ++drv) { - if (drv->id == UCLASS_EFI) { + if (drv->id == UCLASS_EFI_LOADER) { ret = efi_add_driver(drv); if (ret != EFI_SUCCESS) { log_err("Failed to add EFI driver %s\n", @@ -328,7 +328,7 @@ efi_status_t efi_driver_init(void) */ static int efi_uc_init(struct uclass *class) { - log_debug("Initializing UCLASS_EFI\n"); + log_debug("Initializing UCLASS_EFI_LOADER\n"); return 0; } @@ -340,13 +340,13 @@ static int efi_uc_init(struct uclass *class) */ static int efi_uc_destroy(struct uclass *class) { - log_debug("Destroying UCLASS_EFI\n"); + log_debug("Destroying UCLASS_EFI_LOADER\n"); return 0; } UCLASS_DRIVER(efi) = { .name = "efi", - .id = UCLASS_EFI, + .id = UCLASS_EFI_LOADER, .init = efi_uc_init, .destroy = efi_uc_destroy, }; From patchwork Fri Dec 17 19:40:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1570307 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=hWfkaMec; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JFzrR4ddrz9sXS for ; Sat, 18 Dec 2021 06:41:43 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 60B4183775; Fri, 17 Dec 2021 20:41:40 +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="hWfkaMec"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4ACA283767; Fri, 17 Dec 2021 20:41:28 +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.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) (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 C69A683731 for ; Fri, 17 Dec 2021 20:41:22 +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-io1-xd32.google.com with SMTP id x10so4477801ioj.9 for ; Fri, 17 Dec 2021 11:41:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=fMLjwB1RLFpAVHfPeK6lYDUESseL1hlYywp5TXJ0JNU=; b=hWfkaMecFLpBo0403jMs6Q6DBGu3dLVjTXESWrJiVgwO1dLPcwO4Y++QTVjK0P/1gO Ghkg83Rb5vEG1lTmMsbX4ptwq2B2Fm1IhowaPdFbcyrFYmoyWDThaEh/qzgf2uWjwmFP 1ryVTVW/8lsp4cnGpQW8ApC7XuI0k1EPlf7Io= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fMLjwB1RLFpAVHfPeK6lYDUESseL1hlYywp5TXJ0JNU=; b=r2NdC7XX6O5VyDjen4b/HSRGeNvA4LIqkkEMqvyhAZCsI8L6vsXBjlEl6sL5BLohe9 u103moExqEoqeKSOKT6LIsD3+fPlbtb4M1T9MqAVrS95RjralFa6elIKG8K5jiAxW+hc fCbJRDPoOk1w93eLSyv17ygClluBWfbdd8GE/sS86miD1RMPfr5CevuQu97QMqF1Qc8H chmpCCVebnjiaYivEKdIxqpqepQxnjox29iH9rsivA63UCAMry8ph62/TQWBzSRuZy4Q 8Om0t5W5SMiHn3rPDATdBE/SF8NNvy+qO6r5T6Hl3LBpXAgN1585dEEkJ7AopsneFvky fMSw== X-Gm-Message-State: AOAM532+L1Wo0E5/HCSg4W9z3H7DQjb5JTO2yB2z1MGOhP4ifiwAN2zH PnLz/1AnNNnE8WdhIph+0Gs5ELX9UtnMEg== X-Google-Smtp-Source: ABdhPJy/DMT2NnFR2cSmCdAyfKUk1Ir/X+aOkvLu6dYPkudlXaCgck9dwZNnmSvwdahtfIAfkMT5ZA== X-Received: by 2002:a05:6602:2b10:: with SMTP id p16mr2485881iov.2.1639770081334; Fri, 17 Dec 2021 11:41:21 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id w19sm6079605iov.12.2021.12.17.11.41.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Dec 2021 11:41:21 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Heinrich Schuchardt , Tom Rini , Ilias Apalodimas , Christian Melki , Simon Glass , Alexander Graf Subject: [PATCH v6 02/27] efi: Add EFI uclass for media Date: Fri, 17 Dec 2021 12:40:34 -0700 Message-Id: <20211217124039.v6.2.I50ca59e389adf282bbff50eecc593f010a89c0f7@changeid> X-Mailer: git-send-email 2.34.1.173.g76aa8bc2d0-goog In-Reply-To: <20211217194059.858580-1-sjg@chromium.org> References: <20211217194059.858580-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 at phobos.denx.de X-Virus-Status: Clean At present UCLASS_EFI_LOADER is used to represent an EFI filesystem among other things. The only driver that uses this uclass is in fact not a real U-Boot driver, since its operations do not include a struct udevice. Rather than mess with this, create a new UCLASS_EFI_MEDIA uclass to handle EFI media such as disks. Make this the uclass to use for devices provided by a UEFI implementation loading U-Boot as an EFI application, so that it can be used with 'part list', for example. The existing implementation using UCLASS_EFI remains as is, for discussion. Signed-off-by: Simon Glass Reviewed-by: Heinrich Schuchardt --- Changes in v6: - Reword commit message - Update comment for UCLASS_EFI_MEDIA (within space constraints) Changes in v2: - Add MAINTAINERS entry - Show the correct interface type with 'part list' - Update the commit message to explain things better MAINTAINERS | 3 +++ arch/sandbox/dts/test.dts | 4 ++++ disk/part.c | 5 ++++- drivers/block/Kconfig | 23 +++++++++++++++++++++++ drivers/block/Makefile | 3 +++ drivers/block/blk-uclass.c | 2 ++ drivers/block/efi-media-uclass.c | 15 +++++++++++++++ drivers/block/sb_efi_media.c | 20 ++++++++++++++++++++ include/blk.h | 1 + include/dm/uclass-id.h | 1 + test/dm/Makefile | 1 + test/dm/efi_media.c | 24 ++++++++++++++++++++++++ 12 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 drivers/block/efi-media-uclass.c create mode 100644 drivers/block/sb_efi_media.c create mode 100644 test/dm/efi_media.c diff --git a/MAINTAINERS b/MAINTAINERS index 9045e509d73..5b162ad2978 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -714,8 +714,11 @@ W: https://u-boot.readthedocs.io/en/latest/develop/uefi/u-boot_on_efi.html F: board/efi/efi-x86_app F: configs/efi-x86_app* F: doc/develop/uefi/u-boot_on_efi.rst +F: drivers/block/efi-media-uclass.c +F: drivers/block/sb_efi_media.c F: lib/efi/efi_app.c F: scripts/build-efi.sh +F: test/dm/efi_media.c EFI PAYLOAD M: Heinrich Schuchardt diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index e5261bb9fa2..48ca3e1e472 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -499,6 +499,10 @@ compatible = "sandbox,clk-ccf"; }; + efi-media { + compatible = "sandbox,efi-media"; + }; + eth@10002000 { compatible = "sandbox,eth"; reg = <0x10002000 0x1000>; diff --git a/disk/part.c b/disk/part.c index fe1ebd4adf7..e857a9f9585 100644 --- a/disk/part.c +++ b/disk/part.c @@ -296,8 +296,11 @@ static void print_part_header(const char *type, struct blk_desc *dev_desc) case IF_TYPE_VIRTIO: puts("VirtIO"); break; + case IF_TYPE_EFI_MEDIA: + puts("EFI"); + break; default: - puts ("UNKNOWN"); + puts("UNKNOWN"); break; } printf (" device %d -- Partition Type: %s\n\n", diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig index 56a4eec05ac..755fdccb574 100644 --- a/drivers/block/Kconfig +++ b/drivers/block/Kconfig @@ -61,6 +61,29 @@ config TPL_BLOCK_CACHE help This option enables the disk-block cache in TPL +config EFI_MEDIA + bool "Support EFI media drivers" + default y if EFI || SANDBOX + help + Enable this to support media devices on top of UEFI. This enables + just the uclass so you also need a specific driver to make this do + anything. + + For sandbox there is a test driver. + +if EFI_MEDIA + +config EFI_MEDIA_SANDBOX + bool "Sandbox EFI media driver" + depends on SANDBOX + default y + help + Enables a simple sandbox media driver, used for testing just the + EFI_MEDIA uclass. It does not do anything useful, since sandbox does + not actually support running on top of UEFI. + +endif # EFI_MEDIA + config IDE bool "Support IDE controllers" select HAVE_BLOCK_DEVICE diff --git a/drivers/block/Makefile b/drivers/block/Makefile index 94ab5c6f906..3778633da1d 100644 --- a/drivers/block/Makefile +++ b/drivers/block/Makefile @@ -14,3 +14,6 @@ obj-$(CONFIG_IDE) += ide.o endif obj-$(CONFIG_SANDBOX) += sandbox.o obj-$(CONFIG_$(SPL_TPL_)BLOCK_CACHE) += blkcache.o + +obj-$(CONFIG_EFI_MEDIA) += efi-media-uclass.o +obj-$(CONFIG_EFI_MEDIA_SANDBOX) += sb_efi_media.o diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c index a7470ae28d5..4ae8af6d609 100644 --- a/drivers/block/blk-uclass.c +++ b/drivers/block/blk-uclass.c @@ -28,6 +28,7 @@ static const char *if_typename_str[IF_TYPE_COUNT] = { [IF_TYPE_SATA] = "sata", [IF_TYPE_HOST] = "host", [IF_TYPE_NVME] = "nvme", + [IF_TYPE_EFI_MEDIA] = "efi", [IF_TYPE_EFI_LOADER] = "efiloader", [IF_TYPE_VIRTIO] = "virtio", [IF_TYPE_PVBLOCK] = "pvblock", @@ -44,6 +45,7 @@ static enum uclass_id if_type_uclass_id[IF_TYPE_COUNT] = { [IF_TYPE_SATA] = UCLASS_AHCI, [IF_TYPE_HOST] = UCLASS_ROOT, [IF_TYPE_NVME] = UCLASS_NVME, + [IF_TYPE_EFI_MEDIA] = UCLASS_EFI_MEDIA, [IF_TYPE_EFI_LOADER] = UCLASS_EFI_LOADER, [IF_TYPE_VIRTIO] = UCLASS_VIRTIO, [IF_TYPE_PVBLOCK] = UCLASS_PVBLOCK, diff --git a/drivers/block/efi-media-uclass.c b/drivers/block/efi-media-uclass.c new file mode 100644 index 00000000000..e012f6f2f4c --- /dev/null +++ b/drivers/block/efi-media-uclass.c @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Uclass for EFI media devices + * + * Copyright 2021 Google LLC + */ + +#include +#include + +UCLASS_DRIVER(efi_media) = { + .id = UCLASS_EFI_MEDIA, + .name = "efi_media", + .flags = DM_UC_FLAG_SEQ_ALIAS, +}; diff --git a/drivers/block/sb_efi_media.c b/drivers/block/sb_efi_media.c new file mode 100644 index 00000000000..52af155a600 --- /dev/null +++ b/drivers/block/sb_efi_media.c @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * EFI_MEDIA driver for sandbox + * + * Copyright 2021 Google LLC + */ + +#include +#include + +static const struct udevice_id sandbox_efi_media_ids[] = { + { .compatible = "sandbox,efi-media" }, + { } +}; + +U_BOOT_DRIVER(sandbox_efi_media) = { + .name = "sandbox_efi_media", + .id = UCLASS_EFI_MEDIA, + .of_match = sandbox_efi_media_ids, +}; diff --git a/include/blk.h b/include/blk.h index f0835c3fed5..dde21732572 100644 --- a/include/blk.h +++ b/include/blk.h @@ -37,6 +37,7 @@ enum if_type { IF_TYPE_EFI_LOADER, IF_TYPE_PVBLOCK, IF_TYPE_VIRTIO, + IF_TYPE_EFI_MEDIA, IF_TYPE_COUNT, /* Number of interface types */ }; diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h index 2d05694982b..2d8a39349e3 100644 --- a/include/dm/uclass-id.h +++ b/include/dm/uclass-id.h @@ -49,6 +49,7 @@ enum uclass_id { UCLASS_DSA, /* Distributed (Ethernet) Switch Architecture */ UCLASS_ECDSA, /* Elliptic curve cryptographic device */ UCLASS_EFI_LOADER, /* Devices created by UEFI apps and drivers */ + UCLASS_EFI_MEDIA, /* EFI media/devs provided by UEFI firmware */ UCLASS_ETH, /* Ethernet device */ UCLASS_ETH_PHY, /* Ethernet PHY device */ UCLASS_FIRMWARE, /* Firmware */ diff --git a/test/dm/Makefile b/test/dm/Makefile index 548649f8e82..d46552fbf32 100644 --- a/test/dm/Makefile +++ b/test/dm/Makefile @@ -37,6 +37,7 @@ obj-$(CONFIG_DMA) += dma.o obj-$(CONFIG_VIDEO_MIPI_DSI) += dsi_host.o obj-$(CONFIG_DM_DSA) += dsa.o obj-$(CONFIG_ECDSA_VERIFY) += ecdsa.o +obj-$(CONFIG_EFI_MEDIA_SANDBOX) += efi_media.o obj-$(CONFIG_DM_ETH) += eth.o ifneq ($(CONFIG_EFI_PARTITION),) obj-$(CONFIG_FASTBOOT_FLASH_MMC) += fastboot.o diff --git a/test/dm/efi_media.c b/test/dm/efi_media.c new file mode 100644 index 00000000000..e343a0e9c85 --- /dev/null +++ b/test/dm/efi_media.c @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Test for EFI_MEDIA uclass + * + * Copyright 2021 Google LLC + */ + +#include +#include +#include +#include +#include +#include + +/* Test that we can use the EFI_MEDIA uclass */ +static int dm_test_efi_media(struct unit_test_state *uts) +{ + struct udevice *dev; + + ut_assertok(uclass_first_device_err(UCLASS_EFI_MEDIA, &dev)); + + return 0; +} +DM_TEST(dm_test_efi_media, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); From patchwork Fri Dec 17 19:40:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1570308 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=mpgCwfOx; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JFzrd16grz9sXM for ; Sat, 18 Dec 2021 06:41:53 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 147F383781; Fri, 17 Dec 2021 20:41: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="mpgCwfOx"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A1E7A8373B; Fri, 17 Dec 2021 20:41:31 +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.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) (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 94CA78373B for ; Fri, 17 Dec 2021 20:41:23 +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-io1-xd29.google.com with SMTP id x10so4477840ioj.9 for ; Fri, 17 Dec 2021 11:41:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zM9YM2tR+hFgnAIDGxbHmIG23wqPgBG89NJFwvSwxvY=; b=mpgCwfOxi0X+qBXjN1BemsYsR51lQUxhVPgqlYk93pNYZcmfi3gPZnQ7f0UVV5pzBD 60ew3wQzJqMwZs5XKtXMXlqkouwUQcPuPSRM9MQDufx9qiu5xynFy2cuYPcEYX65wrKM RGD+DhbxYBMZle2Hty9TVjkcky+eZ+qnNzJGo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zM9YM2tR+hFgnAIDGxbHmIG23wqPgBG89NJFwvSwxvY=; b=qXWg3MEe/DU+YmHvvkAlvBYMkuAIMWBu14lXMvNgO7O4hRUgtw5zNJddsng7YBwBkN vZF5f9WNBFa12fVvWdOMZ0AP2uMbeZg01xLyGSCvEH7CdjaTaWDs2VABJETtPYkfeZwE RT+HmiLSErn514tqxGKUlv1QhmiMZ9/xeaGYid6qrBI/oNt27nVsLQp+dHm2GdmC4Gze eXfyyMimpJyqRDAXWeVH5mA1Ex9JqSIG+oCcjXYVgt78Vh/xKRsOzVEyXjS7qoK/xz+R 2lYk69KVeiL0IiCynfX6yOFcCsv3URbVIAvFgGT2mMEhDYUKN3p5mk6HY3Lf1rQKYwxM 0vLg== X-Gm-Message-State: AOAM530CZ1h9FoxRXuS9EGrsmUgkKIbdsAn1l84ZvGZpCApHsR4dJF+U 202imNhbCkfZUittqdJc8yK+BjSIG95SjQ== X-Google-Smtp-Source: ABdhPJxoK+vbYqsfY+bEfoxZA799MtFmMg5S2UyLXdX3sTl+DWoZlsax6yym3p7++IDCVR2BWwD58Q== X-Received: by 2002:a05:6602:14ce:: with SMTP id b14mr2466407iow.143.1639770082159; Fri, 17 Dec 2021 11:41:22 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id w19sm6079605iov.12.2021.12.17.11.41.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Dec 2021 11:41:21 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Heinrich Schuchardt , Tom Rini , Ilias Apalodimas , Christian Melki , Simon Glass , Alexander Graf Subject: [PATCH v6 03/27] efi: Add a media/block driver for EFI block devices Date: Fri, 17 Dec 2021 12:40:35 -0700 Message-Id: <20211217124039.v6.3.I9b48fe5f6b8c61348f16a1b5df114282240238c0@changeid> X-Mailer: git-send-email 2.34.1.173.g76aa8bc2d0-goog In-Reply-To: <20211217194059.858580-1-sjg@chromium.org> References: <20211217194059.858580-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 at phobos.denx.de X-Virus-Status: Clean Add a block driver which handles read/write for EFI block devices. This driver actually already exists ('efi_block') but is not really suitable for use as a real U-Boot driver: - The operations do not provide a udevice - The code is designed for running as part of EFI loader, so uses EFI_PRINT() and EFI_CALL(). - The bind method probes the device, which is not permitted - It uses 'EFI' as its parent device The new driver is more 'normal', just requiring its platform data be set up in advance. Signed-off-by: Simon Glass Reviewed-by: Heinrich Schuchardt --- (no changes since v2) Changes in v2: - Drop mention of partitions from the commit message drivers/block/Kconfig | 10 ++++ drivers/block/Makefile | 1 + drivers/block/efi_blk.c | 115 ++++++++++++++++++++++++++++++++++++++++ include/efi.h | 11 ++++ 4 files changed, 137 insertions(+) create mode 100644 drivers/block/efi_blk.c diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig index 755fdccb574..8235430497d 100644 --- a/drivers/block/Kconfig +++ b/drivers/block/Kconfig @@ -82,6 +82,16 @@ config EFI_MEDIA_SANDBOX EFI_MEDIA uclass. It does not do anything useful, since sandbox does not actually support running on top of UEFI. +config EFI_MEDIA_BLK + bool "EFI media block driver" + depends on EFI_APP + default y + help + Enables a block driver for providing access to UEFI devices. This + allows use of block devices detected by the underlying UEFI + implementation. With this it is possible to use filesystems on these + devices, for example. + endif # EFI_MEDIA config IDE diff --git a/drivers/block/Makefile b/drivers/block/Makefile index 3778633da1d..b221a7c6eea 100644 --- a/drivers/block/Makefile +++ b/drivers/block/Makefile @@ -17,3 +17,4 @@ obj-$(CONFIG_$(SPL_TPL_)BLOCK_CACHE) += blkcache.o obj-$(CONFIG_EFI_MEDIA) += efi-media-uclass.o obj-$(CONFIG_EFI_MEDIA_SANDBOX) += sb_efi_media.o +obj-$(CONFIG_EFI_MEDIA_BLK) += efi_blk.o diff --git a/drivers/block/efi_blk.c b/drivers/block/efi_blk.c new file mode 100644 index 00000000000..9d25ecbf37f --- /dev/null +++ b/drivers/block/efi_blk.c @@ -0,0 +1,115 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Block driver for EFI devices + * This supports a media driver of UCLASS_EFI with a child UCLASS_BLK + * It allows block-level access to EFI devices made available via EFI boot + * services + * + * Copyright 2021 Google LLC + */ + +#include +#include +#include +#include +#include + +struct efi_block_plat { + struct efi_block_io *blkio; +}; + +/** + * Read from block device + * + * @dev: device + * @blknr: first block to be read + * @blkcnt: number of blocks to read + * @buffer: output buffer + * Return: number of blocks transferred + */ +static ulong efi_bl_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, + void *buffer) +{ + struct efi_block_plat *plat = dev_get_plat(dev); + struct efi_block_io *io = plat->blkio; + efi_status_t ret; + + log_debug("read buf=%p, block=%lx, count=%lx: ", buffer, (ulong)blknr, + (ulong)blkcnt); + ret = io->read_blocks(io, io->media->media_id, blknr, + blkcnt * io->media->block_size, buffer); + log_debug("ret=%lx (dec %ld)\n", ret & ~EFI_ERROR_MASK, + ret & ~EFI_ERROR_MASK); + if (ret) + return 0; + + return blkcnt; +} + +/** + * Write to block device + * + * @dev: device + * @blknr: first block to be write + * @blkcnt: number of blocks to write + * @buffer: input buffer + * Return: number of blocks transferred + */ +static ulong efi_bl_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, + const void *buffer) +{ + struct efi_block_plat *plat = dev_get_plat(dev); + struct efi_block_io *io = plat->blkio; + efi_status_t ret; + + log_debug("write buf=%p, block=%lx, count=%lx: ", buffer, (ulong)blknr, + (ulong)blkcnt); + ret = io->write_blocks(io, io->media->media_id, blknr, + blkcnt * io->media->block_size, (void *)buffer); + log_debug("ret=%lx (dec %ld)\n", ret & ~EFI_ERROR_MASK, + ret & ~EFI_ERROR_MASK); + if (ret) + return 0; + + return blkcnt; +} + +/* Block device driver operators */ +static const struct blk_ops efi_blk_ops = { + .read = efi_bl_read, + .write = efi_bl_write, +}; + +U_BOOT_DRIVER(efi_block) = { + .name = "efi_block", + .id = UCLASS_BLK, + .ops = &efi_blk_ops, + .plat_auto = sizeof(struct efi_block_plat), +}; + +static int efi_media_bind(struct udevice *dev) +{ + struct efi_media_plat *plat = dev_get_plat(dev); + struct efi_block_plat *blk_plat; + struct udevice *blk; + int ret; + + ret = blk_create_devicef(dev, "efi_block", "blk", IF_TYPE_EFI_MEDIA, + dev_seq(dev), plat->blkio->media->block_size, + plat->blkio->media->last_block, &blk); + if (ret) { + debug("Cannot create block device\n"); + return ret; + } + blk_plat = dev_get_plat(blk); + blk_plat->blkio = plat->blkio; + + return 0; +} + +U_BOOT_DRIVER(efi_media) = { + .name = "efi_media", + .id = UCLASS_EFI_MEDIA, + .bind = efi_media_bind, + .plat_auto = sizeof(struct efi_media_plat), +}; diff --git a/include/efi.h b/include/efi.h index b5835422b95..0ec5913ddd1 100644 --- a/include/efi.h +++ b/include/efi.h @@ -414,6 +414,17 @@ struct efi_priv { void *next_hdr; }; +/* + * EFI attributes of the udevice handled by efi_media driver + * + * @handle: handle of the controller on which this driver is installed + * @blkio: block io protocol proxied by this driver + */ +struct efi_media_plat { + efi_handle_t handle; + struct efi_block_io *blkio; +}; + /* Base address of the EFI image */ extern char image_base[]; From patchwork Fri Dec 17 19:40:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1570313 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=H3R2E718; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JFzsh4HCwz9sXM for ; Sat, 18 Dec 2021 06:42:48 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E4D1883762; Fri, 17 Dec 2021 20:42:08 +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="H3R2E718"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8423E83775; Fri, 17 Dec 2021 20:41:37 +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.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) (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 5D52383741 for ; Fri, 17 Dec 2021 20:41:24 +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-io1-xd2c.google.com with SMTP id q72so4443782iod.12 for ; Fri, 17 Dec 2021 11:41:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Gjep1XmEEqvnpqwYjVPGdjmXA1kzdYLhVs9kMUt8EGM=; b=H3R2E718kImDYtKFksyogtIh+7oMM9JwPgakMWi+3aJWhItswIewGeqC2UjN/K2QbL TE2nDApEuEJLpBhEGnwIcF0pS1xIvgAmweGYQpqwaJ4YKF889/vA95KtQeFJu1e8SSSk c97xx9pw9IowJ+zVGAlVDkmNr6V8C5G6xFVD4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Gjep1XmEEqvnpqwYjVPGdjmXA1kzdYLhVs9kMUt8EGM=; b=MMiBseDHtT9f21BDplp1h9ICygOHvayPevw+oYzUiiQAcJN8Q2ml+oGBe8zlDSMHDl KXJ9Wtaiu0dZUpQ9iemMaoSJaPareHNcvPe/P31lmiR9nosCSMYtmQVJYC2wvXsekQRQ jEr3h9EZ39aR6SAgO65dCulE6dGW2vwH5tp6XWbz+rRX+PchgF6O+VCx87R9ntNjD6cH bywpqQENX1+ZcQnQVXFttFEIK1xp9okcwiSp2/CcfK81XoGXB2hdyI7gVRDUB8F5oZUi godTPQzVbmVt94rkuatjRLFlo9A2z8eGI+gqmHkP0Tu0f0w1dpwn0e7I18lpTbXjfVge pFog== X-Gm-Message-State: AOAM533YqtdUmddE9p5KCnipTezTjl+pK7rn59DNwReV/6jPMkx+0Fwi hRD+0YpM43WM2txLJDjhEFP+VcuczlXhBg== X-Google-Smtp-Source: ABdhPJz6my9KIDL8NgogNvkQUgSUMdKyeHUMI63Fc9QmytA5flZwV0xxYcAeeIIWS8AbjEh18ePIsw== X-Received: by 2002:a05:6638:1682:: with SMTP id f2mr2987904jat.123.1639770082928; Fri, 17 Dec 2021 11:41:22 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id w19sm6079605iov.12.2021.12.17.11.41.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Dec 2021 11:41:22 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Heinrich Schuchardt , Tom Rini , Ilias Apalodimas , Christian Melki , Simon Glass , Alexander Graf Subject: [PATCH v6 04/27] efi: Locate all block devices in the app Date: Fri, 17 Dec 2021 12:40:36 -0700 Message-Id: <20211217124039.v6.4.I0774d3540ebe726f31838b851815e829fb6a4056@changeid> X-Mailer: git-send-email 2.34.1.173.g76aa8bc2d0-goog In-Reply-To: <20211217194059.858580-1-sjg@chromium.org> References: <20211217194059.858580-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 at phobos.denx.de X-Virus-Status: Clean When starting the app, locate all block devices and make them available to U-Boot. This allows listing partitions and accessing files in filesystems. EFI also has the concept of 'disks', meaning boot media. For now, this is not obviously useful in U-Boot, but add code to at least locate these. This can be expanded later as needed. Signed-off-by: Simon Glass --- Changes in v6: - Add comment for dm_scan_other() - Add comment for free_memory() - Drop setup_disks() as U-Boot does not support it - Fix 'have have' typo - Update comment format for devpath_is_partition() Changes in v2: - Don't export efi_bind_block() - Only bind devices for media devices, not for partitions - Show devices that are processed - Store device path in struct efi_media_plat - Update documentation doc/develop/uefi/u-boot_on_efi.rst | 4 +- include/efi.h | 6 +- include/efi_api.h | 15 ++ lib/efi/efi_app.c | 216 +++++++++++++++++++++++++++++ 4 files changed, 236 insertions(+), 5 deletions(-) diff --git a/doc/develop/uefi/u-boot_on_efi.rst b/doc/develop/uefi/u-boot_on_efi.rst index 5f2f850f071..8f81b799072 100644 --- a/doc/develop/uefi/u-boot_on_efi.rst +++ b/doc/develop/uefi/u-boot_on_efi.rst @@ -265,9 +265,7 @@ This work could be extended in a number of ways: - Figure out how to solve the interrupt problem -- Add more drivers to the application side (e.g. block devices, USB, - environment access). This would mostly be an academic exercise as a strong - use case is not readily apparent, but it might be fun. +- Add more drivers to the application side (e.g.USB, environment access). - Avoid turning off boot services in the stub. Instead allow U-Boot to make use of boot services in case it wants to. It is unclear what it might want diff --git a/include/efi.h b/include/efi.h index 0ec5913ddd1..908c5dc6ebd 100644 --- a/include/efi.h +++ b/include/efi.h @@ -419,10 +419,12 @@ struct efi_priv { * * @handle: handle of the controller on which this driver is installed * @blkio: block io protocol proxied by this driver + * @device_path: EFI path to the device */ struct efi_media_plat { - efi_handle_t handle; - struct efi_block_io *blkio; + efi_handle_t handle; + struct efi_block_io *blkio; + struct efi_device_path *device_path; }; /* Base address of the EFI image */ diff --git a/include/efi_api.h b/include/efi_api.h index 80109f012bc..ec9fa89a935 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -2035,4 +2035,19 @@ struct efi_firmware_management_protocol { const u16 *package_version_name); }; +#define EFI_DISK_IO_PROTOCOL_GUID \ + EFI_GUID(0xce345171, 0xba0b, 0x11d2, 0x8e, 0x4f, \ + 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b) + +struct efi_disk { + u64 revision; + efi_status_t (EFIAPI *read_disk)(struct efi_disk *this, u32 media_id, + u64 offset, efi_uintn_t buffer_size, + void *buffer); + + efi_status_t (EFIAPI *write_disk)(struct efi_disk *this, u32 media_id, + u64 offset, efi_uintn_t buffer_size, + void *buffer); +}; + #endif diff --git a/lib/efi/efi_app.c b/lib/efi/efi_app.c index f61665686c5..6a71cef7acb 100644 --- a/lib/efi/efi_app.c +++ b/lib/efi/efi_app.c @@ -21,6 +21,9 @@ #include #include #include +#include +#include +#include DECLARE_GLOBAL_DATA_PTR; @@ -46,6 +49,64 @@ int efi_info_get(enum efi_entry_t type, void **datap, int *sizep) return -ENOSYS; } +/** + * efi_print_str() - Print a UFT-16 string to the U-Boot console + * + * @str: String to print + */ +static void efi_print_str(const u16 *str) +{ + while (*str) { + int ch = *str++; + + if (ch > ' ' && ch < 127) + putc(ch); + } +} + +/** + * efi_bind_block() - bind a new block device to an EFI device + * + * Binds a new top-level EFI_MEDIA device as well as a child block device so + * that the block device can be accessed in U-Boot. + * + * The device can then be accessed using 'part list efi 0', 'fat ls efi 0:1', + * for example, just like any other interface type. + * + * @handle: handle of the controller on which this driver is installed + * @blkio: block io protocol proxied by this driver + * @device_path: EFI device path structure for this + * @len: Length of @device_path in bytes + * @devp: Returns the bound device + * @return 0 if OK, -ve on error + */ +int efi_bind_block(efi_handle_t handle, struct efi_block_io *blkio, + struct efi_device_path *device_path, int len, + struct udevice **devp) +{ + struct efi_media_plat plat; + struct udevice *dev; + char name[18]; + int ret; + + plat.handle = handle; + plat.blkio = blkio; + plat.device_path = malloc(device_path->length); + if (!plat.device_path) + return log_msg_ret("path", -ENOMEM); + memcpy(plat.device_path, device_path, device_path->length); + ret = device_bind(dm_root(), DM_DRIVER_GET(efi_media), "efi_media", + &plat, ofnode_null(), &dev); + if (ret) + return log_msg_ret("bind", ret); + + snprintf(name, sizeof(name), "efi_media_%x", dev_seq(dev)); + device_set_name(dev, name); + *devp = dev; + + return 0; +} + static efi_status_t setup_memory(struct efi_priv *priv) { struct efi_boot_services *boot = priv->boot; @@ -91,6 +152,14 @@ static efi_status_t setup_memory(struct efi_priv *priv) return 0; } +/** + * free_memory() - Free memory used by the U-Boot app + * + * This frees memory allocated in setup_memory(), in preparation for returning + * to UEFI. It also zeroes the global_data pointer. + * + * @priv: Private EFI data + */ static void free_memory(struct efi_priv *priv) { struct efi_boot_services *boot = priv->boot; @@ -105,6 +174,153 @@ static void free_memory(struct efi_priv *priv) global_data_ptr = NULL; } +/** + * devpath_is_partition() - Figure out if a device path is a partition + * + * Checks if a device path refers to a partition on some media device. This + * works by checking for a valid partition number in a hard-driver media device + * as the final component of the device path. + * + * Return: true if a partition, false if not (e.g. it might be media which + * contains partitions) + */ +static bool devpath_is_partition(const struct efi_device_path *path) +{ + const struct efi_device_path *p; + bool was_part; + + for (p = path; p->type != DEVICE_PATH_TYPE_END; + p = (void *)p + p->length) { + was_part = false; + if (p->type == DEVICE_PATH_TYPE_MEDIA_DEVICE && + p->sub_type == DEVICE_PATH_SUB_TYPE_HARD_DRIVE_PATH) { + struct efi_device_path_hard_drive_path *hd = + (void *)path; + + if (hd->partition_number) + was_part = true; + } + } + + return was_part; +} + +/** + * setup_block() - Find all block devices and setup EFI devices for them + * + * Partitions are ignored, since U-Boot has partition handling. Errors with + * particular devices produce a warning but execution continues to try to + * find others. + * + * Return: 0 if found, -ENOSYS if there is no boot-services table, -ENOTSUPP + * if a required protocol is not supported + */ +static int setup_block(void) +{ + efi_guid_t efi_blkio_guid = EFI_BLOCK_IO_PROTOCOL_GUID; + efi_guid_t efi_devpath_guid = EFI_DEVICE_PATH_PROTOCOL_GUID; + efi_guid_t efi_pathutil_guid = EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID; + efi_guid_t efi_pathtext_guid = EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID; + struct efi_boot_services *boot = efi_get_boot(); + struct efi_device_path_utilities_protocol *util; + struct efi_device_path_to_text_protocol *text; + struct efi_device_path *path; + struct efi_block_io *blkio; + efi_uintn_t num_handles; + efi_handle_t *handle; + int ret, i; + + if (!boot) + return log_msg_ret("sys", -ENOSYS); + + /* Find all devices which support the block I/O protocol */ + ret = boot->locate_handle_buffer(BY_PROTOCOL, &efi_blkio_guid, NULL, + &num_handles, &handle); + if (ret) + return log_msg_ret("loc", -ENOTSUPP); + log_debug("Found %d handles:\n", (int)num_handles); + + /* We need to look up the path size and convert it to text */ + ret = boot->locate_protocol(&efi_pathutil_guid, NULL, (void **)&util); + if (ret) + return log_msg_ret("util", -ENOTSUPP); + ret = boot->locate_protocol(&efi_pathtext_guid, NULL, (void **)&text); + if (ret) + return log_msg_ret("text", -ENOTSUPP); + + for (i = 0; i < num_handles; i++) { + struct udevice *dev; + const u16 *name; + bool is_part; + int len; + + ret = boot->handle_protocol(handle[i], &efi_devpath_guid, + (void **)&path); + if (ret) { + log_warning("- devpath %d failed (ret=%d)\n", i, ret); + continue; + } + + ret = boot->handle_protocol(handle[i], &efi_blkio_guid, + (void **)&blkio); + if (ret) { + log_warning("- blkio %d failed (ret=%d)\n", i, ret); + continue; + } + + name = text->convert_device_path_to_text(path, true, false); + is_part = devpath_is_partition(path); + + if (!is_part) { + len = util->get_device_path_size(path); + ret = efi_bind_block(handle[i], blkio, path, len, &dev); + if (ret) { + log_warning("- blkio bind %d failed (ret=%d)\n", + i, ret); + continue; + } + } else { + dev = NULL; + } + + /* + * Show the device name if we created one. Otherwise indicate + * that it is a partition. + * + * We don't seem to have a way to print unicode on the U-Boot + * console at present, so use our own function. + */ + printf("%2d: %-12s ", i, dev ? dev->name : ""); + efi_print_str(name); + printf("\n"); + } + boot->free_pool(handle); + + return 0; +} + +/** + * dm_scan_other() - Scan for UEFI devices that should be available to U-Boot + * + * This sets up block devices within U-Boot for those found in UEFI. With this, + * U-Boot can access those devices + * + * @pre_reloc_only: true to only bind pre-relocation devices (ignored) + * Returns: 0 on success, -ve on error + */ +int dm_scan_other(bool pre_reloc_only) +{ + if (gd->flags & GD_FLG_RELOC) { + int ret; + + ret = setup_block(); + if (ret) + return ret; + } + + return 0; +} + /** * efi_main() - Start an EFI image * From patchwork Fri Dec 17 19:40:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1570310 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=b1eW/gcO; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JFzs15JMLz9sXM for ; Sat, 18 Dec 2021 06:42:13 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B47EC83791; Fri, 17 Dec 2021 20:41: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="b1eW/gcO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5318383767; Fri, 17 Dec 2021 20:41:32 +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.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) (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 9FF4583744 for ; Fri, 17 Dec 2021 20:41:25 +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-io1-xd2a.google.com with SMTP id c3so4483163iob.6 for ; Fri, 17 Dec 2021 11:41:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=d7Z8zp7bLmVdhzeEdlwZ2sowAd9qDZ0zngUO5lzoJzA=; b=b1eW/gcOpmX/UEkbZUV1Y1o6ZTsVLoRnKkW7qhDKIwnEM32kHk5SDYzmPPEg3MTqRg uJks8xgKL92OP/mtugvUSayRrmIdj78uLwbtBxVn5Qxsk2O8yJhMuKE0PXumoN9U1hUt JCnZ/8ii7WEqiHwixoWkd/MgbcnH/dLZTC2M4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=d7Z8zp7bLmVdhzeEdlwZ2sowAd9qDZ0zngUO5lzoJzA=; b=ZYn7WvnraI4yWKnXb9c0aYBcm6RHeQ/wVugvFRTigDIeDK2LZOj6yUeBhmyeqH7MPF E7mjDCvMpnU5vc7YOXW2LteQ1xzBTx7WM4ft/O0wNkfNoAnX0TGUfJjkUI6Okxjkahjf BN9MEgEuquiXmijMAV0hlXxrF8GoM0jLHeXQs3YPq7f9h+TMZySLvKDILZVHmvQTIWlg dMv5kNB8vMZEZwgJc8ykw2laoGh4CtEBylqWnB4QfsC6V82vm9B4gB4Rr7NnBYsQB/1T +PoSLXBjRdEVBbDYCJM2tezcmmQ0+whHvrSXjB2gUO+Sx5rNx70G23s8rxAsnhFj7oCc sMag== X-Gm-Message-State: AOAM531RaRphWY/GKU8t08NtFOg1NHB+K0kXAL2IjZPDBMiJ3jPUvmMa R2vAj02ejRsM/EftortajKcjn8DhJSF4bQ== X-Google-Smtp-Source: ABdhPJwn+pvxzGVQ0sT2QjaFq+x3CV1lxzGEoOmG3T5rLAr3bGwySM2y1zr24gWUrdyfvDpulk944A== X-Received: by 2002:a05:6638:3711:: with SMTP id k17mr3023058jav.72.1639770083644; Fri, 17 Dec 2021 11:41:23 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id w19sm6079605iov.12.2021.12.17.11.41.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Dec 2021 11:41:23 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Heinrich Schuchardt , Tom Rini , Ilias Apalodimas , Christian Melki , Simon Glass , Alexander Graf Subject: [PATCH v6 05/27] efi: serial: Support arrow keys Date: Fri, 17 Dec 2021 12:40:37 -0700 Message-Id: <20211217194059.858580-2-sjg@chromium.org> X-Mailer: git-send-email 2.34.1.173.g76aa8bc2d0-goog In-Reply-To: <20211217194059.858580-1-sjg@chromium.org> References: <20211217194059.858580-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 at phobos.denx.de X-Virus-Status: Clean At present only the backspace key is supported in U-Boot, when running as an EFI app. Add support for arrows, home and end as well, to make the CLI more friendly. Signed-off-by: Simon Glass --- (no changes since v1) drivers/serial/serial_efi.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/serial/serial_efi.c b/drivers/serial/serial_efi.c index 33ddbd6080c..0067576389d 100644 --- a/drivers/serial/serial_efi.c +++ b/drivers/serial/serial_efi.c @@ -24,6 +24,9 @@ struct serial_efi_priv { bool have_key; }; +/* Convert a lower-case character to its ctrl-char equivalent */ +#define CTL_CH(c) ((c) - 'a' + 1) + int serial_efi_setbrg(struct udevice *dev, int baudrate) { return 0; @@ -49,6 +52,7 @@ static int serial_efi_get_key(struct serial_efi_priv *priv) static int serial_efi_getc(struct udevice *dev) { struct serial_efi_priv *priv = dev_get_priv(dev); + char conv_scan[10] = {0, 'p', 'n', 'f', 'b', 'a', 'e', 0, 8}; int ret, ch; ret = serial_efi_get_key(priv); @@ -63,8 +67,11 @@ static int serial_efi_getc(struct udevice *dev) * key scan code of 8. Handle this so that backspace works correctly * in the U-Boot command line. */ - if (!ch && priv->key.scan_code == 8) - ch = 8; + if (!ch && priv->key.scan_code < sizeof(conv_scan)) { + ch = conv_scan[priv->key.scan_code]; + if (ch >= 'a') + ch -= 'a' - 1; + } debug(" [%x %x %x] ", ch, priv->key.unicode_char, priv->key.scan_code); return ch; From patchwork Fri Dec 17 19:40:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1570311 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=Lj+gNhTg; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JFzsD5Bbwz9sXM for ; Sat, 18 Dec 2021 06:42:24 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 07C6683774; Fri, 17 Dec 2021 20:41:59 +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="Lj+gNhTg"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BC4C583759; Fri, 17 Dec 2021 20:41:32 +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.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) (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 6B7B583736 for ; Fri, 17 Dec 2021 20:41:26 +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-io1-xd30.google.com with SMTP id p23so4485673iod.7 for ; Fri, 17 Dec 2021 11:41:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=f0JQH/bPVzyLjoiSk3LUocC1P4fb4o1YBbYD1r4nDRc=; b=Lj+gNhTgxDXPO/Ujr5IyCG5snXZ7BrihIcsWRUsBv1ulchOVbTOhDynXNcM7ckso22 LN8skZ3CYa7UkNszwcvnxL5O2swIGV0Td8nN6nesvCeFDLoPYdNJRdLiMKnyZbCMUFuO ADFSYGbqe79LdzbY41VovsGNOELMMKl1DjHMU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=f0JQH/bPVzyLjoiSk3LUocC1P4fb4o1YBbYD1r4nDRc=; b=iuRCKq/N2rlQA3I4nLEc0my+4HVZ1cetmJRijUOlywQJBfSvVvIX9b8Yx2Y2u1RPa8 VOAY9CXDjEDa3m4TrUBnRaBNpwSw5zcg1R1uDyLJN8C4UZDV4m6oDOuQnv4U9OEYlI4y pEiZqq65C9D74K/njpNZjuduau6HSI6L8rXkXs7wPsHAIC/uv4DJDR5n7EsPnl4qIn1Y Mpmur+acGkm9Vaw1bmmqi4K1l5lmvXs5WUypHp7uPIcLFgTKm0OYbaLG+RoyX17wi+Hd AvCTaNkf47PBN0PLLJP8XJAD974Rir46LR6zEUEXcIkt9vy5gVhQfJ4rrpLGR46c5Zvf WcGA== X-Gm-Message-State: AOAM530Bnt0vHvDGZHN3oudHcsgenoMtTf0nAox23bu4B3OMHWYj5ly6 /1XUENpYqYNd2t7I2ZI8/7ixw9aeZW0dMA== X-Google-Smtp-Source: ABdhPJwkaGpVdeg2AkYNeFdlne4NCcSVVFFveEDKLhEf12mNPqdo0S9DCmld5NbP52LPEzKqmQewhQ== X-Received: by 2002:a05:6638:d56:: with SMTP id d22mr2963165jak.20.1639770085040; Fri, 17 Dec 2021 11:41:25 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id w19sm6079605iov.12.2021.12.17.11.41.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Dec 2021 11:41:24 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Heinrich Schuchardt , Tom Rini , Ilias Apalodimas , Christian Melki , Simon Glass Subject: [PATCH v6 06/27] x86: Allow booting a kernel from the EFI app Date: Fri, 17 Dec 2021 12:40:38 -0700 Message-Id: <20211217194059.858580-3-sjg@chromium.org> X-Mailer: git-send-email 2.34.1.173.g76aa8bc2d0-goog In-Reply-To: <20211217194059.858580-1-sjg@chromium.org> References: <20211217194059.858580-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 at phobos.denx.de X-Virus-Status: Clean At present this is disabled, but it should work so long as the kernel does not need EFI services. Enable it and add a note about remaining work. Signed-off-by: Simon Glass --- (no changes since v2) Changes in v2: - Update documentation arch/x86/lib/bootm.c | 11 +++++++---- doc/develop/uefi/u-boot_on_efi.rst | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/arch/x86/lib/bootm.c b/arch/x86/lib/bootm.c index 667e5e689e3..57cba5c65d3 100644 --- a/arch/x86/lib/bootm.c +++ b/arch/x86/lib/bootm.c @@ -179,10 +179,14 @@ int boot_linux_kernel(ulong setup_base, ulong load_address, bool image_64bit) * U-Boot is setting them up that way for itself in * arch/i386/cpu/cpu.c. * - * Note that we cannot currently boot a kernel while running as - * an EFI application. Please use the payload option for that. + * Note: this is incomplete for EFI kernels! + * + * This can boot a kernel while running as an EFI application, + * but if the kernel requires EFI support then that support needs + * to be enabled first (see EFI_LOADER). Also the EFI information + * must enabled with setup_efi_info(). See setup_zimage() for + * how this is done with the stub. */ -#ifndef CONFIG_EFI_APP __asm__ __volatile__ ( "movl $0, %%ebp\n" "cli\n" @@ -191,7 +195,6 @@ int boot_linux_kernel(ulong setup_base, ulong load_address, bool image_64bit) [boot_params] "S"(setup_base), "b"(0), "D"(0) ); -#endif } /* We can't get to here */ diff --git a/doc/develop/uefi/u-boot_on_efi.rst b/doc/develop/uefi/u-boot_on_efi.rst index 8f81b799072..acad6397e81 100644 --- a/doc/develop/uefi/u-boot_on_efi.rst +++ b/doc/develop/uefi/u-boot_on_efi.rst @@ -269,7 +269,7 @@ This work could be extended in a number of ways: - Avoid turning off boot services in the stub. Instead allow U-Boot to make use of boot services in case it wants to. It is unclear what it might want - though. + though. It is better to use the app. Where is the code? ------------------ From patchwork Fri Dec 17 19:40:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1570309 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=E1BOEz80; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JFzrq1d1Nz9sXM for ; Sat, 18 Dec 2021 06:42:03 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8A1B083787; Fri, 17 Dec 2021 20:41: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="E1BOEz80"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CBEBD8377B; Fri, 17 Dec 2021 20:41: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.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) (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 14DFF8375B for ; Fri, 17 Dec 2021 20:41:27 +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-il1-x12c.google.com with SMTP id d14so2500339ila.1 for ; Fri, 17 Dec 2021 11:41:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RNglBiSvoBYFxOs016qVH8c6rUV0/5sIoEgWYpgjmrM=; b=E1BOEz80h4Pcsesxm0CXwp9eHuOB6E2K/83gtvuVFFInfrHmRzR/ww/goXdSqkNsfY TisRxmwWhElfIj3ujmHNPDaxsPk4dUBET6Hsl3NAJkjuLcAiAzsUu+NLX8n0Svqkcu6Y VlZ5vVOJk+fSrnZLpeibfRmSf19SagTQ0W8HY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RNglBiSvoBYFxOs016qVH8c6rUV0/5sIoEgWYpgjmrM=; b=o04on2/t7nMDoqGP+V3pVyzqv8lnSa61VDxgXdrgWtsUXszVj3jE1cveINuDnTXU90 lxi18BcKFhO85DYDB9jcw87KUbLA9gQxrG0mEZ9i95GNTO2xe7ZU93+/B+ZfJj4KYSer x3aHU7phXRmKYiiEq2aP5v7NWA/fD92riBjdBooAPoq71344pZbhpXsfZqVQw8wtBmKz IeHFKE+cGXMOV/DPnHaIM0wX/A5JQ4QygfNPKIG+bEdhzHb5hluqAn6kzaj8LUWw8Vf+ EEGJt2GTneLPYq9DVYELFCGdMQ3Q+Emgi/H5OkpT+KKmg7YvTsoQsrYAV3DunZhmpq7V bK2A== X-Gm-Message-State: AOAM533pvx+S2XQtmcjkQVw1EM9wbyGFZ3R420GCQ9f4FHgUyY5jmRmu O/JvEI84tIk96L7+xzvHz8xypd9kH3VeYQ== X-Google-Smtp-Source: ABdhPJzinvackoYkfYU3UuT/u65lRRjzOgBUhiXDzOivXxnLBnT0ajYAzIF1Z++8OzgUIwq7kMZ02g== X-Received: by 2002:a05:6e02:12ce:: with SMTP id i14mr2438001ilm.99.1639770085785; Fri, 17 Dec 2021 11:41:25 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id w19sm6079605iov.12.2021.12.17.11.41.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Dec 2021 11:41:25 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Heinrich Schuchardt , Tom Rini , Ilias Apalodimas , Christian Melki , Simon Glass Subject: [PATCH v6 07/27] x86: Don't process the kernel command line unless enabled Date: Fri, 17 Dec 2021 12:40:39 -0700 Message-Id: <20211217194059.858580-4-sjg@chromium.org> X-Mailer: git-send-email 2.34.1.173.g76aa8bc2d0-goog In-Reply-To: <20211217194059.858580-1-sjg@chromium.org> References: <20211217194059.858580-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 at phobos.denx.de X-Virus-Status: Clean If the 'bootm' command is not enabled then this code is not available and this causes a link error. Fix it. Note that for the EFI app, there is no indication of missing code. It just hangs! Signed-off-by: Simon Glass --- (no changes since v1) arch/x86/lib/zimage.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c index 7ce02226ef9..9cc04490307 100644 --- a/arch/x86/lib/zimage.c +++ b/arch/x86/lib/zimage.c @@ -365,11 +365,14 @@ int setup_zimage(struct boot_params *setup_base, char *cmd_line, int auto_boot, strcpy(cmd_line, (char *)cmdline_force); else build_command_line(cmd_line, auto_boot); - ret = bootm_process_cmdline(cmd_line, max_size, BOOTM_CL_ALL); - if (ret) { - printf("Cmdline setup failed (max_size=%x, bootproto=%x, err=%d)\n", - max_size, bootproto, ret); - return ret; + if (IS_ENABLED(CONFIG_CMD_BOOTM)) { + ret = bootm_process_cmdline(cmd_line, max_size, + BOOTM_CL_ALL); + if (ret) { + printf("Cmdline setup failed (max_size=%x, bootproto=%x, err=%d)\n", + max_size, bootproto, ret); + return ret; + } } printf("Kernel command line: \""); puts(cmd_line); From patchwork Fri Dec 17 19:40:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1570312 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=k0jq+l7f; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JFzsS5dSCz9sXM for ; Sat, 18 Dec 2021 06:42:36 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 96CD98378C; Fri, 17 Dec 2021 20:42:04 +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="k0jq+l7f"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CA9198378C; Fri, 17 Dec 2021 20:41:37 +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.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) (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 BFB8B83762 for ; Fri, 17 Dec 2021 20:41:27 +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-io1-xd33.google.com with SMTP id z26so4440911iod.10 for ; Fri, 17 Dec 2021 11:41:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lbG/BpIMbEc+RN90JK8nv53FpgkYDTuDOI1Vc+tsUeM=; b=k0jq+l7fQJNtGVDfaSu9AFcfmWcjxlYY8Sb+JwtNbSibhsYbryaAyyfYemsn1sS9mY E6JYcrwJir7LQ5JsLpHvg59oiirWBBTOZyONgECAA4zZR/OH56BtKGWd4TkiOgE8Clag goBq3cTn8mOlCxsUzCKWCQQrZEVbPXSAtoYIo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lbG/BpIMbEc+RN90JK8nv53FpgkYDTuDOI1Vc+tsUeM=; b=zxjBOH1s0iKqdy4kSTGUatebE2zbSCQ5dAUg6a2hM8b9rYXMGrvjXx9rgK0aoP0ZFQ AD844D/QEwCLU+4BUnIpMBUj+691rJ4d41eDtHq1WlbhdwqngXCwaZZ6HdoSh+Qh9ibv s0XsuOuZKewb2rAqx2eVFsSmqqTsRHABEwnFI9N2eBT0Sac/JywUp/t2IOu2zMciXzWX rq7+hzUJiA++Gw0ZbZGD97gQoyTnUN5jWgdiHq6NPBiqYpY4EXb/iQDwZ81To2EnscFi mcYY7y060fnRhUGAaB8616FeJ5PSsTvisdiwH/jwJSHb2+bW4JA1AwIHmKYjzOx3lWuz IuUg== X-Gm-Message-State: AOAM531LAGq06martAlA0jQ9Tl9faWAtfd/sBB9m42RTuE2ClVagSJ19 +icBNjvvT5tdQvYenNczBh3BqQjTpN4XqA== X-Google-Smtp-Source: ABdhPJyZ5i4897Knb/ehcevV9JuJnbV0w6J96ldhHDXarIfi4AK6IhpwduXs1AIBkvGkrp3p9AqRUg== X-Received: by 2002:a05:6638:1395:: with SMTP id w21mr3044425jad.125.1639770086439; Fri, 17 Dec 2021 11:41:26 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id w19sm6079605iov.12.2021.12.17.11.41.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Dec 2021 11:41:26 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Heinrich Schuchardt , Tom Rini , Ilias Apalodimas , Christian Melki , Simon Glass , Alexander Graf Subject: [PATCH v6 08/27] x86: efi: Add room for the binman definition in the dtb Date: Fri, 17 Dec 2021 12:40:40 -0700 Message-Id: <20211217194059.858580-5-sjg@chromium.org> X-Mailer: git-send-email 2.34.1.173.g76aa8bc2d0-goog In-Reply-To: <20211217194059.858580-1-sjg@chromium.org> References: <20211217194059.858580-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 at phobos.denx.de X-Virus-Status: Clean At present only 4KB of spare space is left in the DTB when building the EFI app. Increase this to 32KB so there is plenty of space to insert the binman definition. This cannot be expanded later (as with OF_SEPARATE) because the ELF image has already been built. Signed-off-by: Simon Glass --- (no changes since v1) arch/x86/dts/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/dts/Makefile b/arch/x86/dts/Makefile index be209aaaf8f..5c8c05ec499 100644 --- a/arch/x86/dts/Makefile +++ b/arch/x86/dts/Makefile @@ -24,7 +24,7 @@ dtb-y += bayleybay.dtb \ targets += $(dtb-y) -DTC_FLAGS += -R 4 -p 0x1000 +DTC_FLAGS += -R 4 -p $(if $(CONFIG_EFI_APP),0x8000,0x1000) PHONY += dtbs dtbs: $(addprefix $(obj)/, $(dtb-y)) From patchwork Fri Dec 17 19:40:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1570316 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=c0q6FoSc; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JFztL0B21z9sXM for ; Sat, 18 Dec 2021 06:43:21 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 962C48363F; Fri, 17 Dec 2021 20:42:24 +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="c0q6FoSc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4629883740; Fri, 17 Dec 2021 20:41:39 +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.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) (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 826D283731 for ; Fri, 17 Dec 2021 20:41:28 +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-io1-xd33.google.com with SMTP id m9so4574282iop.0 for ; Fri, 17 Dec 2021 11:41:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pTkPpnPr9jvN+tWgRMe7oDWUee7CTLRLMjpla4Vh69M=; b=c0q6FoScheXlfOLnuPoL0eggthJg+nweNxT0BK7DAvMAkOM0rrM1HRAJRZ9HeQaGp4 UomC8pSF1RIJlM/zAOjcZj2Td5RACb3YJz9mYK7NbwjCcTAcHjU0TsLA1DIgb8Cd6R0d Dmq+XthEhqr+7bF177fynPftLdHFOVBvIoDUQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pTkPpnPr9jvN+tWgRMe7oDWUee7CTLRLMjpla4Vh69M=; b=MIOCPFdqEYZZ5ZmOb+qWz1rxcCjHB2lzbMflZ4PD551b68ARjmozcofGex9e1uALae yhCeVycnI/6qB6I4DxrS/NUCQRQ+BOn4ADuDpRP9n0UwNvvX0GzWZosERaqqdUaboG4c 5dhyyf+76iOoDae46pRcWyKpodDP2pH5Ff+qQ7lkNh1dPq7iiHjlpbhayrJYPzZcOZZb 0zWmwPHl2CoAsGFc6m3NYMXaZziuS6nYh1RMGyV/8XoSyo8zVznAxbksG0T1h1lKOBBy 6hvceQyjczFhk0hbaWOrUt7qeuUJ2rtUhxJIWscx1VMAjjldA49QN3mEYnF/JNnDuvz+ 5PBg== X-Gm-Message-State: AOAM530WDZ68KTGq6RCuRUbBOrfat4QXfVc5tc8Q3JHcZYd5/eodZHP4 ChyhFEjHqlLqrpL1Y5zYFUDiHFdWHn2Ypw== X-Google-Smtp-Source: ABdhPJxf9ONsQbOh1eVndTeENA9zJRndofyJlM4t19oVdNqfOl2BIgbgJIhKHWetpPaR3E+QqS3sKw== X-Received: by 2002:a05:6638:2215:: with SMTP id l21mr2994570jas.147.1639770087238; Fri, 17 Dec 2021 11:41:27 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id w19sm6079605iov.12.2021.12.17.11.41.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Dec 2021 11:41:26 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Heinrich Schuchardt , Tom Rini , Ilias Apalodimas , Christian Melki , Simon Glass , Alexander Graf Subject: [PATCH v6 09/27] efi: Drop device_path from struct efi_priv Date: Fri, 17 Dec 2021 12:40:41 -0700 Message-Id: <20211217194059.858580-6-sjg@chromium.org> X-Mailer: git-send-email 2.34.1.173.g76aa8bc2d0-goog In-Reply-To: <20211217194059.858580-1-sjg@chromium.org> References: <20211217194059.858580-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 at phobos.denx.de X-Virus-Status: Clean This is not used anywhere drop it. Signed-off-by: Simon Glass --- (no changes since v3) Changes in v3: - Move device_path path change to its own patch include/efi.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/efi.h b/include/efi.h index 908c5dc6ebd..77e599c256e 100644 --- a/include/efi.h +++ b/include/efi.h @@ -402,7 +402,6 @@ static inline struct efi_mem_desc *efi_get_next_mem_desc( struct efi_priv { efi_handle_t parent_image; - struct efi_device_path *device_path; struct efi_system_table *sys_table; struct efi_boot_services *boot; struct efi_runtime_services *run; From patchwork Fri Dec 17 19:40:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1570314 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=N1elojq6; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JFzsv40c7z9sXM for ; Sat, 18 Dec 2021 06:42:59 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 71B3A83772; Fri, 17 Dec 2021 20:42:14 +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="N1elojq6"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E70D883759; Fri, 17 Dec 2021 20:41: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.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) (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 44DF08376C for ; Fri, 17 Dec 2021 20:41:29 +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-io1-xd32.google.com with SMTP id c3so4483361iob.6 for ; Fri, 17 Dec 2021 11:41:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ND5mCN0ybv+9PywGpKlTFLDRn/Bo9vrpC8UK55gMk3I=; b=N1elojq6lM0hWyLI5rtA0yXO+5E/vMFlchOxSFXe3VuHnPxobzqRJ6D/iRGI63Idsw fS5lf08bPL2qZqcAbDii3BjLY5gLvaPcUjFzgXOH+bma70YpJLsIj/GXA1+WjyqspLqZ mly9xZ6f8tiAl1EGQl5+6Hg/6CDi9MYiXq8TM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ND5mCN0ybv+9PywGpKlTFLDRn/Bo9vrpC8UK55gMk3I=; b=I8K9+8qBGFtlVtIvKr+EWUIY5tY2b1Jp6Sgp91ntf+2Hx0U3rZkCkzoz9U6hauKpkh BLkXN7iZuxwaFzo0ruOQz1f/RAe//sHzIoydBEc0fIO12vWr+HkC84HXBOiTPwIy3EZk AVR1FEDYlbkn+ZUkbF+IrpHnfB4HKkBp01Lc1erHbFqXnNSpfbABhjxzmrhe0TmiMWiu z+MmxUh06eMaF6MyNsXPSt/o2B46rqvlhVuR7W7QhG4GvWztQfe1LtyHMSjP1ZOdzZBn M0J2Zs8ImdpaiGSlgHTs3nA4UHU727Rr2UqttBvz31V8A5KAKpjLFZwJHPRK5QPlgyC5 qmRw== X-Gm-Message-State: AOAM533R9L7VFHec7oVUWB508r+l9NQFASJX4FfCS57GAWMMc1nBy5sQ HKn4Gru5CK40t8DUbXSqrPRyTyiQ6QVnng== X-Google-Smtp-Source: ABdhPJxvXMHNqHYdJCQNNAA2Gm+EikG1oBIdJFVS+/VpuQhQFhzRi0mmB/WRGJQc+EVEOOWYhk4/8Q== X-Received: by 2002:a05:6638:dc3:: with SMTP id m3mr2907613jaj.304.1639770087931; Fri, 17 Dec 2021 11:41:27 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id w19sm6079605iov.12.2021.12.17.11.41.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Dec 2021 11:41:27 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Heinrich Schuchardt , Tom Rini , Ilias Apalodimas , Christian Melki , Simon Glass , Alexander Graf Subject: [PATCH v6 10/27] efi: Add comments to struct efi_priv Date: Fri, 17 Dec 2021 12:40:42 -0700 Message-Id: <20211217194059.858580-7-sjg@chromium.org> X-Mailer: git-send-email 2.34.1.173.g76aa8bc2d0-goog In-Reply-To: <20211217194059.858580-1-sjg@chromium.org> References: <20211217194059.858580-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 at phobos.denx.de X-Virus-Status: Clean This structure is uncommented. Fix it. Signed-off-by: Simon Glass --- (no changes since v3) Changes in v3: - Drop comments that confuse sphinx - Move device_path path change to its own patch include/efi.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/include/efi.h b/include/efi.h index 77e599c256e..6622a733e6e 100644 --- a/include/efi.h +++ b/include/efi.h @@ -400,14 +400,37 @@ static inline struct efi_mem_desc *efi_get_next_mem_desc( return (struct efi_mem_desc *)((ulong)desc + map->desc_size); } +/** + * struct efi_priv - Information about the environment provided by EFI + * + * @parent_image: image passed into the EFI app or stub + * @sys_table: Pointer to system table + * @boot: Pointer to boot-services table + * @run: Pointer to runtime-services table + * + * @use_pool_for_malloc: true if all allocation should go through the EFI 'pool' + * methods allocate_pool() and free_pool(); false to use 'pages' methods + * allocate_pages() and free_pages() + * @ram_base: Base address of RAM (size CONFIG_EFI_RAM_SIZE) + * @image_data_type: Type of the loaded image (e.g. EFI_LOADER_CODE) + * + * @info: Header of the info list, holding info collected by the stub and passed + * to U-Boot + * @info_size: Size of the info list, in bytes from @info + * @next_hdr: Pointer to where to put the next header when adding to the list + */ struct efi_priv { efi_handle_t parent_image; struct efi_system_table *sys_table; struct efi_boot_services *boot; struct efi_runtime_services *run; + + /* app: */ bool use_pool_for_malloc; unsigned long ram_base; unsigned int image_data_type; + + /* stub: */ struct efi_info_hdr *info; unsigned int info_size; void *next_hdr; From patchwork Fri Dec 17 19:40:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1570315 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=MLmUDAuU; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JFzt70xJRz9sXM for ; Sat, 18 Dec 2021 06:43:11 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AAB468377E; Fri, 17 Dec 2021 20:42:20 +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="MLmUDAuU"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C877A83731; Fri, 17 Dec 2021 20:41:39 +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.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) (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 0C64183774 for ; Fri, 17 Dec 2021 20:41:30 +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-io1-xd31.google.com with SMTP id x10so4478246ioj.9 for ; Fri, 17 Dec 2021 11:41:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3BC3uL0V9+yjE+w0+VXh8roqsABK+9JyZFDTE5SHYqE=; b=MLmUDAuUfadQeaMDVRLg/UrduYNfK2DgEuNJlZhVh+baWiojErH7gZUsH+tRBc6DH0 HrmtZqvdZCu3QVPTOHaSIy7X081UjhrGCDx+BLVGwGN+sUi2+GS9etb2jWvdTRImE53b eik5f0qnmxRtuPWkbYS/Y4xJDnWeHCYZ0Luk4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3BC3uL0V9+yjE+w0+VXh8roqsABK+9JyZFDTE5SHYqE=; b=zFIM+bPdAeVm30arZlLcfcG7rtu8BRcamw/A7X8vs94+62pQCNs9f1/OnV2eZwiw4m R+Pr2mc6gJC9I44L5vyr53b1zX36jf9AMhXUjejS5aIVE1Zi9KpwSRMHZdhpoy0/tw4C 4oDzeiYFsYkbA4P1nLH2IlmDo3T0E9pO5065VwNWNliFTkr6NdV0kIjzkcmLZ+Ys2KiT rIeYi/d4voyfZqVYMo1rx4K00orPbo2wmC6smzccV5pdWQ5sCbL6RyFhm3zGtGIwV8EJ OVGleJcOk30UZopHb8jBoxbIisfw3B7pzpXcAfpqmHOdQPeb3t3/APabz7RX7nmIjlDA jlWg== X-Gm-Message-State: AOAM532fh/6RBJS1O2jcG525YefuG6t8W53f945/mhnpBlJ1ydPa6uRb 0NO+Xi7eIpYkO6yPKuVEnOBKGyx3xO3Jww== X-Google-Smtp-Source: ABdhPJzdvjoL/+naAJOLX8+XdcHZxHVfSr11CibKh2ZD5C3E4JL/XpsTRJLF7tvcH7V9QPcGpJJr0w== X-Received: by 2002:a05:6638:3891:: with SMTP id b17mr3131155jav.100.1639770088720; Fri, 17 Dec 2021 11:41:28 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id w19sm6079605iov.12.2021.12.17.11.41.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Dec 2021 11:41:28 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Heinrich Schuchardt , Tom Rini , Ilias Apalodimas , Christian Melki , Simon Glass , Alexander Graf Subject: [PATCH v6 11/27] efi: Fix ll_boot_init() operation with the app Date: Fri, 17 Dec 2021 12:40:43 -0700 Message-Id: <20211217194059.858580-8-sjg@chromium.org> X-Mailer: git-send-email 2.34.1.173.g76aa8bc2d0-goog In-Reply-To: <20211217194059.858580-1-sjg@chromium.org> References: <20211217194059.858580-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 at phobos.denx.de X-Virus-Status: Clean This should return false when the EFI app is running, since UEFI has done the required low-level init. Fix it. Signed-off-by: Simon Glass --- (no changes since v1) include/init.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/init.h b/include/init.h index f2cd46dead0..3ce7b8b95bd 100644 --- a/include/init.h +++ b/include/init.h @@ -15,7 +15,7 @@ #include /* Avoid using CONFIG_EFI_STUB directly as we may boot from other loaders */ -#ifdef CONFIG_EFI_STUB +#ifdef CONFIG_EFI #define ll_boot_init() false #else #include From patchwork Fri Dec 17 19:40:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1570317 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=n8PLK4pk; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JFztX6S64z9sXM for ; Sat, 18 Dec 2021 06:43:32 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 49C4D837BD; Fri, 17 Dec 2021 20:42:29 +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="n8PLK4pk"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1FAF583740; Fri, 17 Dec 2021 20:41:42 +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.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) (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 808418377E for ; Fri, 17 Dec 2021 20:41:31 +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-io1-xd31.google.com with SMTP id b187so4448654iof.11 for ; Fri, 17 Dec 2021 11:41:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=u/tUlh4q9X6aSvqRwsxWvbvrtFmKFIUjSyT/jySITsA=; b=n8PLK4pk7omrhmm7BY07tjU21zBWcjxWXOopiBsUWptDqlPZ2EK5htGXYDvhXcECHB r5A0vFeVqZS8XvK1FiifIFwOhDHSCqrnRcRrsRPYaq3jb0+2XDhhkrjYsLvt8McMhuCI J2ah2uArK7M6jI3GN8or3IJrRGUL3GqsaKG4E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=u/tUlh4q9X6aSvqRwsxWvbvrtFmKFIUjSyT/jySITsA=; b=STepG6ueSv3OMJ7E/VLqFRNpX6gJVPx82Rjfkw6vMAirFrIQ3p0Ro78ES1iGXWeUd7 yoLyGr94DtsPK+FdL24TJWFYqZh3OJhMJXwh55T1JftEgYKapa3+Ic2ttkBnGl7BeM5Q 8oqTowDQHFC7RLvJz0WJYVnu8qH7VfjBO4JriIC6apTdhKJmAPO04zgz/dBmWN7SvI0M oLTG8aLFIDN0PTotBh5EbS5sFyylkct4GRMn4RoaxzzxRrICoFKmoaWWHONpM39K1hXp 5QwlCPgl2AlsvCn6bsTUADnPbJwCdjx7Qg0doe8u5Zq/nqi71wgkSU3nUFri17ss8WkQ qUZA== X-Gm-Message-State: AOAM532jc+KGxsHhVSjF3hKNS17vWlNH9RqENU2XSzGBkgh0tfeOsXhv znKTpr+nIvFD8NYWYRg1Wz0WJL0O5mCuPQ== X-Google-Smtp-Source: ABdhPJz90R3Nhg8TH1+jvQmpuVCDb5BJOu74svond/oZI5wfERrqfaSoKNwvLuPmI1WIJLjsISTbMw== X-Received: by 2002:a05:6638:2708:: with SMTP id m8mr3029985jav.286.1639770089409; Fri, 17 Dec 2021 11:41:29 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id w19sm6079605iov.12.2021.12.17.11.41.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Dec 2021 11:41:29 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Heinrich Schuchardt , Tom Rini , Ilias Apalodimas , Christian Melki , Simon Glass , Alexander Graf Subject: [PATCH v6 12/27] efi: Add a few comments to the stub Date: Fri, 17 Dec 2021 12:40:44 -0700 Message-Id: <20211217194059.858580-9-sjg@chromium.org> X-Mailer: git-send-email 2.34.1.173.g76aa8bc2d0-goog In-Reply-To: <20211217194059.858580-1-sjg@chromium.org> References: <20211217194059.858580-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 at phobos.denx.de X-Virus-Status: Clean Comment some functions that need more information. Signed-off-by: Simon Glass --- Changes in v6: - Fix comment style in setup_info_table() lib/efi/efi_stub.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/efi/efi_stub.c b/lib/efi/efi_stub.c index b3393e47fae..e8a594cb2aa 100644 --- a/lib/efi/efi_stub.c +++ b/lib/efi/efi_stub.c @@ -225,6 +225,22 @@ static int get_codeseg32(void) return cs32; } +/** + * setup_info_table() - sets up a table containing information from EFI + * + * We must call exit_boot_services() before jumping out of the stub into U-Boot + * proper, so that U-Boot has full control of peripherals, memory, etc. + * + * Once we do this, we cannot call any boot-services functions so we must find + * out everything we need to before doing that. + * + * Set up a struct efi_info_hdr table which can hold various records (e.g. + * struct efi_entry_memmap) with information obtained from EFI. + * + * @priv: Pointer to our private information which contains the list + * @size: Size of the table to allocate + * Return: 0 if OK, non-zero on error + */ static int setup_info_table(struct efi_priv *priv, int size) { struct efi_info_hdr *info; @@ -248,6 +264,12 @@ static int setup_info_table(struct efi_priv *priv, int size) return 0; } +/** + * add_entry_addr() - Add a new entry to the efi_info list + * + * @priv: Pointer to our private information which contains the list + * + */ static void add_entry_addr(struct efi_priv *priv, enum efi_entry_t type, void *ptr1, int size1, void *ptr2, int size2) { From patchwork Fri Dec 17 19:40:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1570320 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=WVy0Chpq; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JFzvB1vzlz9sXM for ; Sat, 18 Dec 2021 06:44:06 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3CCA3837C8; Fri, 17 Dec 2021 20:42: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="WVy0Chpq"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 11AA683784; Fri, 17 Dec 2021 20:41:47 +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.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) (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 F418483737 for ; Fri, 17 Dec 2021 20:41: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-io1-xd29.google.com with SMTP id c3so4483582iob.6 for ; Fri, 17 Dec 2021 11:41:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6vtDmI7kDRQndUx094IImguEqkqnQOXsEU8JnQgM2Nc=; b=WVy0ChpqNPSeHtm53yASP1HpWzRoQU6BAKX1V3RRZ/FLolvg0ZE1j+bNLO90xbCf16 kP6TM5YeTIxHNlbakB1tmNN9SNVpIXIvmUurcpojJX5J3WE/M+tkKt3SrzvVISjCprlp NPLYIZQzvugtH7gAGdjvh9KgzbtCiW5JR1MG8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6vtDmI7kDRQndUx094IImguEqkqnQOXsEU8JnQgM2Nc=; b=ItfGYBlRh1m1h09zwM6VMfU7/hQFFOV1Ur1BAxD5Ke15fjIDV6VffoaaIwuPZdTMJ2 tuH3B2ZaHq9ZSjShPBYR5CMX3ZpuTcHH8lYSr6YY3JtwM52Q7cnCKXowVDqDZqu0A7zy 5q1omntzp0IK6mZCd21dOQdEzTx0B0Ws6EiPg1i/4KUgr0W/M04zSgiQqSPWQmfzXRGn QXQ2cfvjrxCCgVbNrPgmeeYbfjvQmOz/P/U/svkjxYojhYBQkVvwsJerZfjOScY212Wt CJW1Vpv2RTXsyYcM1bDlGdWKbCwycWuYCyEzJcEBNGDj4DDG5zLaaWX8987Je00PlylH to4g== X-Gm-Message-State: AOAM532YPRikQltgJqxWsroTVb0M5xKsCGscLGZQFpS659hyfQThADI7 egzaMkiAyh9/dKeMm6/G7/QoscLKepk6DA== X-Google-Smtp-Source: ABdhPJwIM+awv/x1bDUsxewDjK2qkZ6yAYp1LIp9HtZzdCDXI0VJzyD+Tx0OyRhl/Ndl1Z5X/UdAjQ== X-Received: by 2002:a02:a816:: with SMTP id f22mr2963169jaj.81.1639770090087; Fri, 17 Dec 2021 11:41:30 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id w19sm6079605iov.12.2021.12.17.11.41.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Dec 2021 11:41:29 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Heinrich Schuchardt , Tom Rini , Ilias Apalodimas , Christian Melki , Simon Glass , Alexander Graf Subject: [PATCH v6 13/27] efi: Share struct efi_priv between the app and stub code Date: Fri, 17 Dec 2021 12:40:45 -0700 Message-Id: <20211217194059.858580-10-sjg@chromium.org> X-Mailer: git-send-email 2.34.1.173.g76aa8bc2d0-goog In-Reply-To: <20211217194059.858580-1-sjg@chromium.org> References: <20211217194059.858580-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 at phobos.denx.de X-Virus-Status: Clean At present each of these has its own static variable and helper functions. Move them into a shared file. Signed-off-by: Simon Glass --- (no changes since v1) include/efi.h | 21 +++++++++++++++++++++ lib/efi/efi.c | 29 +++++++++++++++++++++++++++++ lib/efi/efi_app.c | 21 ++------------------- lib/efi/efi_stub.c | 7 ++++--- 4 files changed, 56 insertions(+), 22 deletions(-) diff --git a/include/efi.h b/include/efi.h index 6622a733e6e..ca301db7cb5 100644 --- a/include/efi.h +++ b/include/efi.h @@ -474,6 +474,27 @@ extern char _binary_u_boot_bin_start[], _binary_u_boot_bin_end[]; EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS | \ EFI_VARIABLE_APPEND_WRITE) +/** + * efi_get_priv() - Get access to the EFI-private information + * + * This struct it used by both the stub and the app to record things about the + * EFI environment. It is not available in U-Boot proper after the stub has + * jumped there. Use efi_info_get() to obtain info in that case. + * + * @return pointer to private info + */ +struct efi_priv *efi_get_priv(void); + +/** + * efi_set_priv() - Set up a pointer to the EFI-private information + * + * This is called in the stub and app to record the location of this + * information. + * + * @priv: New location of private data + */ +void efi_set_priv(struct efi_priv *priv); + /** * efi_get_sys_table() - Get access to the main EFI system table * diff --git a/lib/efi/efi.c b/lib/efi/efi.c index 69e52e45748..cd6bf47b180 100644 --- a/lib/efi/efi.c +++ b/lib/efi/efi.c @@ -1,5 +1,7 @@ // SPDX-License-Identifier: GPL-2.0+ /* + * Functions shared by the app and stub + * * Copyright (c) 2015 Google, Inc * * EFI information obtained here: @@ -17,6 +19,33 @@ #include #include +static struct efi_priv *global_priv; + +struct efi_priv *efi_get_priv(void) +{ + return global_priv; +} + +void efi_set_priv(struct efi_priv *priv) +{ + global_priv = priv; +} + +struct efi_system_table *efi_get_sys_table(void) +{ + return global_priv->sys_table; +} + +struct efi_boot_services *efi_get_boot(void) +{ + return global_priv->boot; +} + +unsigned long efi_get_ram_base(void) +{ + return global_priv->ram_base; +} + /* * Global declaration of gd. * diff --git a/lib/efi/efi_app.c b/lib/efi/efi_app.c index 6a71cef7acb..122945e1ddd 100644 --- a/lib/efi/efi_app.c +++ b/lib/efi/efi_app.c @@ -27,23 +27,6 @@ DECLARE_GLOBAL_DATA_PTR; -static struct efi_priv *global_priv; - -struct efi_system_table *efi_get_sys_table(void) -{ - return global_priv->sys_table; -} - -struct efi_boot_services *efi_get_boot(void) -{ - return global_priv->boot; -} - -unsigned long efi_get_ram_base(void) -{ - return global_priv->ram_base; -} - int efi_info_get(enum efi_entry_t type, void **datap, int *sizep) { return -ENOSYS; @@ -337,7 +320,7 @@ efi_status_t EFIAPI efi_main(efi_handle_t image, /* Set up access to EFI data structures */ efi_init(priv, "App", image, sys_table); - global_priv = priv; + efi_set_priv(priv); /* * Set up the EFI debug UART so that printf() works. This is @@ -363,7 +346,7 @@ efi_status_t EFIAPI efi_main(efi_handle_t image, static void efi_exit(void) { - struct efi_priv *priv = global_priv; + struct efi_priv *priv = efi_get_priv(); free_memory(priv); printf("U-Boot EFI exiting\n"); diff --git a/lib/efi/efi_stub.c b/lib/efi/efi_stub.c index e8a594cb2aa..b4e9f49a6df 100644 --- a/lib/efi/efi_stub.c +++ b/lib/efi/efi_stub.c @@ -31,7 +31,6 @@ #error "This file needs to be ported for use on architectures" #endif -static struct efi_priv *global_priv; static bool use_uart; struct __packed desctab_info { @@ -63,6 +62,8 @@ void _debug_uart_init(void) void putc(const char ch) { + struct efi_priv *priv = efi_get_priv(); + if (ch == '\n') putc('\r'); @@ -73,7 +74,7 @@ void putc(const char ch) ; outb(ch, (ulong)&com_port->thr); } else { - efi_putc(global_priv, ch); + efi_putc(priv, ch); } } @@ -313,7 +314,7 @@ efi_status_t EFIAPI efi_main(efi_handle_t image, puts(" efi_init() failed\n"); return ret; } - global_priv = priv; + efi_set_priv(priv); cs32 = get_codeseg32(); if (cs32 < 0) From patchwork Fri Dec 17 19:40:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1570321 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=NI+JNQLl; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JFzvP3m1cz9sXM for ; Sat, 18 Dec 2021 06:44:17 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3402B837D6; Fri, 17 Dec 2021 20:42:50 +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="NI+JNQLl"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 235B283782; Fri, 17 Dec 2021 20:41: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.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) (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 61ED983744 for ; Fri, 17 Dec 2021 20:41: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-io1-xd35.google.com with SMTP id x10so4478399ioj.9 for ; Fri, 17 Dec 2021 11:41:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=U1z0Wvmyh2JRddH6ajGiiOXf69cY5FvyrJeSjtVQE+Y=; b=NI+JNQLlWi0aEBC1QJ0uOXX3KbFI8xgTA6gTZfBf88WLrSMZi/RaE8Dbc6XDWc+tAT D8FvhUmIisJ+ipczWoG7VcQyFtQG3N4QAceXsmD/w1AHhUdN69JbYH6t5DB9uD1r5Ug/ yJW6o+jLLu6AbPyx0BbrlpdsKsA8/Nw8qaeWM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=U1z0Wvmyh2JRddH6ajGiiOXf69cY5FvyrJeSjtVQE+Y=; b=yZH3m2StrQFhhTg11hi+/QUGoNRlFM3ml8QDiwCiGHPo3+xLvGtJLZ5s3Wv8gMv8sR jNydBFhccAycRyhDlAQ7TxMSfrVEYYoyQ2yBq1QwDvWxMTU5b5nKlYNGqMwbLE87AZYz sA5VQCyzdHuqylhJR5rERvkazSJ+W4pxU4aiVujEBT4KaAfupy2fB624R4Zb29z7xFYl 0Py1w3d+/t8DC2rm++LWUqQI9L8r6U+imPEvcka15bspqd620w4VkLITu+MoGjoVbRDh Z4/T7Z3KJYaG/eftBXDIfo+3SBHcbl6EU18kIH64wW/TvJZ88zcqDK2bid5wHdDPk0mo fuSQ== X-Gm-Message-State: AOAM530AVUvmlh6E0QKMfbDnNi7OeVcVIX2nZMxClLNrym8IZopqwlt1 JsEi0nruCz1LtybBt7oRx48GZKZYQMi47Q== X-Google-Smtp-Source: ABdhPJw28wVnumgCwoN0W3X8tXhit1C3D4ZKwxkKJujH1gxGK6rDnwMsTZcfcOjcmIYX40JcnvAJfA== X-Received: by 2002:a05:6602:483:: with SMTP id y3mr2501123iov.42.1639770090917; Fri, 17 Dec 2021 11:41:30 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id w19sm6079605iov.12.2021.12.17.11.41.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Dec 2021 11:41:30 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Heinrich Schuchardt , Tom Rini , Ilias Apalodimas , Christian Melki , Simon Glass , Alexander Graf Subject: [PATCH v6 14/27] efi: Move exit_boot_services into a function Date: Fri, 17 Dec 2021 12:40:46 -0700 Message-Id: <20211217194059.858580-11-sjg@chromium.org> X-Mailer: git-send-email 2.34.1.173.g76aa8bc2d0-goog In-Reply-To: <20211217194059.858580-1-sjg@chromium.org> References: <20211217194059.858580-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 at phobos.denx.de X-Virus-Status: Clean At present this code is inline in the app and stub. But they do the same thing. The difference is that the stub does it immediately and the app doesn't want to do it until the end (when it boots a kernel) or not at all, if returning to UEFI. Move it into a function so it can be called as needed. Also store the memory map so that it can be accessed within the app if needed. Signed-off-by: Simon Glass --- Changes in v6: - Fix typo in function comment Changes in v2: - Add a sentence about what the patch does include/efi.h | 32 ++++++++++++++++++++++ lib/efi/efi.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++ lib/efi/efi_app.c | 3 ++ lib/efi/efi_stub.c | 66 ++++++++------------------------------------ 4 files changed, 114 insertions(+), 55 deletions(-) diff --git a/include/efi.h b/include/efi.h index ca301db7cb5..ca4afaf524b 100644 --- a/include/efi.h +++ b/include/efi.h @@ -407,6 +407,12 @@ static inline struct efi_mem_desc *efi_get_next_mem_desc( * @sys_table: Pointer to system table * @boot: Pointer to boot-services table * @run: Pointer to runtime-services table + * @memmap_key: Key returned from get_memory_map() + * @memmap_desc: List of memory-map records + * @memmap_alloc: Amount of memory allocated for memory map list + * @memmap_size Size of memory-map list in bytes + * @memmap_desc_size: Size of an individual memory-map record, in bytes + * @memmap_version: Memory-map version * * @use_pool_for_malloc: true if all allocation should go through the EFI 'pool' * methods allocate_pool() and free_pool(); false to use 'pages' methods @@ -424,6 +430,12 @@ struct efi_priv { struct efi_system_table *sys_table; struct efi_boot_services *boot; struct efi_runtime_services *run; + efi_uintn_t memmap_key; + struct efi_mem_desc *memmap_desc; + efi_uintn_t memmap_alloc; + efi_uintn_t memmap_size; + efi_uintn_t memmap_desc_size; + u32 memmap_version; /* app: */ bool use_pool_for_malloc; @@ -574,4 +586,24 @@ void efi_putc(struct efi_priv *priv, const char ch); */ int efi_info_get(enum efi_entry_t type, void **datap, int *sizep); +/** + * efi_store_memory_map() - Collect the memory-map info from EFI + * + * Collect the memory info and store it for later use, e.g. in calling + * exit_boot_services() + * + * @priv: Pointer to private EFI structure + * @return 0 if OK, non-zero on error + */ +int efi_store_memory_map(struct efi_priv *priv); + +/** + * efi_call_exit_boot_services() - Handle the exit-boot-service procedure + * + * Tell EFI we don't want their boot services anymore + * + * Return: 0 if OK, non-zero on error + */ +int efi_call_exit_boot_services(void); + #endif /* _LINUX_EFI_H */ diff --git a/lib/efi/efi.c b/lib/efi/efi.c index cd6bf47b180..20da88c9151 100644 --- a/lib/efi/efi.c +++ b/lib/efi/efi.c @@ -135,3 +135,71 @@ void efi_free(struct efi_priv *priv, void *ptr) boot->free_pool(ptr); } + +int efi_store_memory_map(struct efi_priv *priv) +{ + struct efi_boot_services *boot = priv->sys_table->boottime; + efi_uintn_t size, desc_size; + efi_status_t ret; + + /* Get the memory map so we can switch off EFI */ + size = 0; + ret = boot->get_memory_map(&size, NULL, &priv->memmap_key, + &priv->memmap_desc_size, + &priv->memmap_version); + if (ret != EFI_BUFFER_TOO_SMALL) { + printhex2(EFI_BITS_PER_LONG); + putc(' '); + printhex2(ret); + puts(" No memory map\n"); + return ret; + } + /* + * Since doing a malloc() may change the memory map and also we want to + * be able to read the memory map in efi_call_exit_boot_services() + * below, after more changes have happened + */ + priv->memmap_alloc = size + 1024; + priv->memmap_size = priv->memmap_alloc; + priv->memmap_desc = efi_malloc(priv, size, &ret); + if (!priv->memmap_desc) { + printhex2(ret); + puts(" No memory for memory descriptor\n"); + return ret; + } + + ret = boot->get_memory_map(&priv->memmap_size, priv->memmap_desc, + &priv->memmap_key, &desc_size, + &priv->memmap_version); + if (ret) { + printhex2(ret); + puts(" Can't get memory map\n"); + return ret; + } + + return 0; +} + +int efi_call_exit_boot_services(void) +{ + struct efi_priv *priv = efi_get_priv(); + const struct efi_boot_services *boot = priv->boot; + efi_uintn_t size; + u32 version; + efi_status_t ret; + + size = priv->memmap_alloc; + ret = boot->get_memory_map(&size, priv->memmap_desc, + &priv->memmap_key, + &priv->memmap_desc_size, &version); + if (ret) { + printhex2(ret); + puts(" Can't get memory map\n"); + return ret; + } + ret = boot->exit_boot_services(priv->parent_image, priv->memmap_key); + if (ret) + return ret; + + return 0; +} diff --git a/lib/efi/efi_app.c b/lib/efi/efi_app.c index 122945e1ddd..2024ecc37b6 100644 --- a/lib/efi/efi_app.c +++ b/lib/efi/efi_app.c @@ -334,6 +334,9 @@ efi_status_t EFIAPI efi_main(efi_handle_t image, printf("Failed to set up memory: ret=%lx\n", ret); return ret; } + ret = efi_store_memory_map(priv); + if (ret) + return ret; printf("starting\n"); diff --git a/lib/efi/efi_stub.c b/lib/efi/efi_stub.c index b4e9f49a6df..cdd023bed28 100644 --- a/lib/efi/efi_stub.c +++ b/lib/efi/efi_stub.c @@ -297,15 +297,12 @@ efi_status_t EFIAPI efi_main(efi_handle_t image, { struct efi_priv local_priv, *priv = &local_priv; struct efi_boot_services *boot = sys_table->boottime; - struct efi_mem_desc *desc; struct efi_entry_memmap map; struct efi_gop *gop; struct efi_entry_gopmode mode; struct efi_entry_systable table; efi_guid_t efi_gop_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID; - efi_uintn_t key, desc_size, size; efi_status_t ret; - u32 version; int cs32; ret = efi_init(priv, "Payload", image, sys_table); @@ -320,24 +317,11 @@ efi_status_t EFIAPI efi_main(efi_handle_t image, if (cs32 < 0) return EFI_UNSUPPORTED; - /* Get the memory map so we can switch off EFI */ - size = 0; - ret = boot->get_memory_map(&size, NULL, &key, &desc_size, &version); - if (ret != EFI_BUFFER_TOO_SMALL) { - printhex2(EFI_BITS_PER_LONG); - putc(' '); - printhex2(ret); - puts(" No memory map\n"); - return ret; - } - size += 1024; /* Since doing a malloc() may change the memory map! */ - desc = efi_malloc(priv, size, &ret); - if (!desc) { - printhex2(ret); - puts(" No memory for memory descriptor\n"); + ret = efi_store_memory_map(priv); + if (ret) return ret; - } - ret = setup_info_table(priv, size + 128); + + ret = setup_info_table(priv, priv->memmap_size + 128); if (ret) return ret; @@ -353,48 +337,20 @@ efi_status_t EFIAPI efi_main(efi_handle_t image, sizeof(struct efi_gop_mode_info)); } - ret = boot->get_memory_map(&size, desc, &key, &desc_size, &version); - if (ret) { - printhex2(ret); - puts(" Can't get memory map\n"); - return ret; - } - table.sys_table = (ulong)sys_table; add_entry_addr(priv, EFIET_SYS_TABLE, &table, sizeof(table), NULL, 0); - ret = boot->exit_boot_services(image, key); - if (ret) { - /* - * Unfortunately it happens that we cannot exit boot services - * the first time. But the second time it work. I don't know - * why but this seems to be a repeatable problem. To get - * around it, just try again. - */ - printhex2(ret); - puts(" Can't exit boot services\n"); - size = sizeof(desc); - ret = boot->get_memory_map(&size, desc, &key, &desc_size, - &version); - if (ret) { - printhex2(ret); - puts(" Can't get memory map\n"); - return ret; - } - ret = boot->exit_boot_services(image, key); - if (ret) { - printhex2(ret); - puts(" Can't exit boot services 2\n"); - return ret; - } - } + ret = efi_call_exit_boot_services(); + if (ret) + return ret; /* The EFI UART won't work now, switch to a debug one */ use_uart = true; - map.version = version; - map.desc_size = desc_size; - add_entry_addr(priv, EFIET_MEMORY_MAP, &map, sizeof(map), desc, size); + map.version = priv->memmap_version; + map.desc_size = priv->memmap_desc_size; + add_entry_addr(priv, EFIET_MEMORY_MAP, &map, sizeof(map), + priv->memmap_desc, priv->memmap_size); add_entry_addr(priv, EFIET_END, NULL, 0, 0, 0); memcpy((void *)CONFIG_SYS_TEXT_BASE, _binary_u_boot_bin_start, From patchwork Fri Dec 17 19:40:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1570319 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=TvdLzkjQ; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JFztz6HgHz9sXM for ; Sat, 18 Dec 2021 06:43:55 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 22EFD837CD; Fri, 17 Dec 2021 20:42: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="TvdLzkjQ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C68ED8377F; Fri, 17 Dec 2021 20:41: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.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) (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 983DE83781 for ; Fri, 17 Dec 2021 20:41:33 +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-io1-xd2e.google.com with SMTP id p23so4486041iod.7 for ; Fri, 17 Dec 2021 11:41:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aYnLOGjuy5mkZebYup+aZwTOEXiJztrloR8UgFRuKX4=; b=TvdLzkjQJx35pta4RbjTifLgbEN2LoF6A1/h3yEJanE/onjrvPUIg2Pjbmwk+HAVwm lMil3gE0ub9D0l85ZM4QHdMl/HglOQQR0FaOPL58dMeXVbX9FaplLWT8i2f5WF9hh3p8 bhRdyoT4xx4SPqTzav0Jc2zHwvUK35qYciM7I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aYnLOGjuy5mkZebYup+aZwTOEXiJztrloR8UgFRuKX4=; b=QGe+qhPLdacrJeD544pBDbY82jrdhoYt7aVqOrb5YwgQzB7WwS4UKPOOA5IMPXWT/l dJE2n2lw6/DuSZqrJ5s3ppBUe7De+nxVHHw3B27Bu7aVcVRHkt7RT+Gcd7/o6qs5pr8A Ak8VdAkPyjuM9FbN6BZDVUQBlEibWpy6eyf0b1D51ok7xaIRMjlvW25xoYr18IUczdwl 3d/7qTwZyd6gdyZPfU3VR7XgU+DJMCPe4HiiqpTtnI33gcrLTZnylupQBF7qS/XelA2J RzTT6Y30T8nmMoejIEpBr1xT146xZAdfMF5RyAsJhe4MInwXAAVcqa7qkjdir+L1wq58 PJIw== X-Gm-Message-State: AOAM533cCXMLSam+xjFpkziqhbsYY7gjUu4r/M6wviYuduTUlanzK0tr 5iacbKh00kyAogQxGhrrucd+hhDKjMxPNw== X-Google-Smtp-Source: ABdhPJzHwfmwRiLKzziLYtkta5986twb4t7nuwouDgIH1yBKPhdR4e9ZmtkoyPaRaiHHSU5Y+6+q+g== X-Received: by 2002:a05:6638:410b:: with SMTP id ay11mr2899540jab.120.1639770091684; Fri, 17 Dec 2021 11:41:31 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id w19sm6079605iov.12.2021.12.17.11.41.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Dec 2021 11:41:31 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Heinrich Schuchardt , Tom Rini , Ilias Apalodimas , Christian Melki , Simon Glass , Alexander Graf Subject: [PATCH v6 15/27] efi: Check for failure when initing the app Date: Fri, 17 Dec 2021 12:40:47 -0700 Message-Id: <20211217194059.858580-12-sjg@chromium.org> X-Mailer: git-send-email 2.34.1.173.g76aa8bc2d0-goog In-Reply-To: <20211217194059.858580-1-sjg@chromium.org> References: <20211217194059.858580-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 at phobos.denx.de X-Virus-Status: Clean The stub checks for failure with efi_init(). Add this for the app as well. It is unlikely that anything can be done, but we may as well stop. Signed-off-by: Simon Glass --- Changes in v6: - Use 'U-Boot' instead of 'ARP' typo lib/efi/efi_app.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/efi/efi_app.c b/lib/efi/efi_app.c index 2024ecc37b6..2a6740b836a 100644 --- a/lib/efi/efi_app.c +++ b/lib/efi/efi_app.c @@ -318,8 +318,11 @@ efi_status_t EFIAPI efi_main(efi_handle_t image, efi_status_t ret; /* Set up access to EFI data structures */ - efi_init(priv, "App", image, sys_table); - + ret = efi_init(priv, "App", image, sys_table); + if (ret) { + printf("Failed to set up U-Boot: err=%lx\n", ret); + return ret; + } efi_set_priv(priv); /* From patchwork Fri Dec 17 19:40:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1570318 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=B72uzNFL; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JFztl2ZXCz9sXM for ; Sat, 18 Dec 2021 06:43:43 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 92ABB837AA; Fri, 17 Dec 2021 20:42: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=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="B72uzNFL"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AD2D583791; Fri, 17 Dec 2021 20:41: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.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) (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 E0B0C83769 for ; Fri, 17 Dec 2021 20:41:33 +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-io1-xd2b.google.com with SMTP id y16so4470594ioc.8 for ; Fri, 17 Dec 2021 11:41:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=fg6TOFn3WtGjWU0rRrYvcQQAgxvXTL+4yvXvrzWhr8M=; b=B72uzNFLe0aK0FLIDS5v/KkiMWiYZMtazTnu3EHtz+CL5WGLMPk4M3Dk6TcRkamNA+ UjZwhnnJrScK1UHXVOnb5iCnCXJrskbzIyYmXw00J05CzjvcvYIRLGmXDpcIgpG9trox AR+HU9fWkR7c1D7lcbs2oYZObcqtXxBiNOLEE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fg6TOFn3WtGjWU0rRrYvcQQAgxvXTL+4yvXvrzWhr8M=; b=V2cYlD8uqA/cHYZnzzsQCVw43q72JdBO6ORphkfB+pyWBj0wHSxJbu+PlEVwpfv2S9 fBTfJxYoH7rzfnHXPTkTBxO0R6AJr5G9Wf2l6nKgK8gBasooNDPpB50VB9XAs1H3mQFF X9t4EvlKDDKgV7o6sZCZtLDEqSlkad/YzbHBW14lKgvg9uZIuX9v+Vv+Uq1asexsDbuC 7sfWpgDm7idSx5/WZ0g5pCH+kpvL16Mr4Of2Lw+nKOVCJdn0bxNLZuqTEBNZNwYFBMSY jltSay+IEbBpO79TiYCIDdpth1Oyn5WU2LFWN3ugsGDZPZr2/dylv00ie9suIMc5OigB qmwg== X-Gm-Message-State: AOAM533Nd0CG7lgM+LJQ/KoP/p5RSFPVDDvLlVlTs7UrNtSzzl43G2j8 NZFl/aoFumTLtPyek0+VxRYRn3f+GXdxnQ== X-Google-Smtp-Source: ABdhPJxmUYBSiePlVewwV6dxUp0jz0Jn0N2LQQ9Sqd5eOfimwbppap/Un+SXJamyBkoAy2HSWgYzVg== X-Received: by 2002:a5d:8244:: with SMTP id n4mr2513537ioo.27.1639770092376; Fri, 17 Dec 2021 11:41:32 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id w19sm6079605iov.12.2021.12.17.11.41.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Dec 2021 11:41:32 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Heinrich Schuchardt , Tom Rini , Ilias Apalodimas , Christian Melki , Simon Glass , Alexander Graf Subject: [PATCH v6 16/27] efi: Mention that efi_info_get() is only used in the stub Date: Fri, 17 Dec 2021 12:40:48 -0700 Message-Id: <20211217194059.858580-13-sjg@chromium.org> X-Mailer: git-send-email 2.34.1.173.g76aa8bc2d0-goog In-Reply-To: <20211217194059.858580-1-sjg@chromium.org> References: <20211217194059.858580-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 at phobos.denx.de X-Virus-Status: Clean This provides access to EFI tables after U-Boot has exited boot services. It is not needed in the app since boot services remain alive and we can just call them whenever needed. Add a comment to explain this. Signed-off-by: Simon Glass --- Changes in v6: - Fix 'stuff' typo in comment - Update to 'This function' in comment Changes in v2: - Fix 'as' typo include/efi.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/efi.h b/include/efi.h index ca4afaf524b..0aa07193640 100644 --- a/include/efi.h +++ b/include/efi.h @@ -578,6 +578,10 @@ void efi_putc(struct efi_priv *priv, const char ch); /** * efi_info_get() - get an entry from an EFI table * + * This function is called from U-Boot proper to read information set up by the + * EFI stub. It can only be used when running from the EFI stub, not when U-Boot + * is running as an app. + * * @type: Entry type to search for * @datap: Returns pointer to entry data * @sizep: Returns pointer to entry size From patchwork Fri Dec 17 19:40:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1570323 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=mY40P3ON; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JFzvn6LBHz9sXM for ; Sat, 18 Dec 2021 06:44:37 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 21400837D1; Fri, 17 Dec 2021 20:42:59 +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="mY40P3ON"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D80168373B; Fri, 17 Dec 2021 20:41:52 +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.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) (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 083738378A for ; Fri, 17 Dec 2021 20:41: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-io1-xd2b.google.com with SMTP id x6so4387680iol.13 for ; Fri, 17 Dec 2021 11:41:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3l2Y7Mu0WkqQ7S3W+QGuRJbNhBfQCJI6V6Ajyol6RmU=; b=mY40P3ON2juVSngH8Mgj5r3yJXoh4j1EDTntqs3qe9pEX/91teZZmoCIbBF91QYghJ xzpw9myZ1tpRBX5NAO/xDwfRilmYnJc2TR5kH4UsRfrw5OvsOt//yPoFrqJslpp8XjHv Tr4VSAfi1VT8sOYLIIV4jX6qEvRXlEOa8K8Fw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3l2Y7Mu0WkqQ7S3W+QGuRJbNhBfQCJI6V6Ajyol6RmU=; b=ZxSnx1SRqIKUyvvut9kX6MShtnApiK3UlI5dcHRB/tglo9GlTR0UebET9o1g+BWh83 mvYhuCAnH/gpik34C5H6TDg5OXkO9tyOoPy4SKIfuRShRuirFcpZ8qe/qNnMbYrnDiDu bA8frj4+SvT5TQJGwg3bJnaEfz3/wzBbTj5hR6wbEUusktHNsfbVVTBEU8emaNguX0y6 3i6hevBF6DwGBk3OJNtEPFfkcdmWlo1eB7DV4I9UIbcE5YQXMaKxZmQChDIoQd/jekGx qq6gkRuHR7Z4K8nV+WpX/Ee6r5ZrHN6ttacvAmCvH8PIR/YE8RoBJV9hhJLb/2/Y0u+0 0JBg== X-Gm-Message-State: AOAM533fg0zLmveeVddz2AT7MTdwIp+H6ILaoFT74uAvkTOeSWh9TI8k BBuIcFndy17RTIIxcU5QhcTjAdHqpW1KdQ== X-Google-Smtp-Source: ABdhPJyeY/qXG4k6RLyi81GmdIEHnriTyvkrAI3y+ivexj9V2N0uwEACgdglhSbcbgVA1KVoEcxXRw== X-Received: by 2002:a02:cdd9:: with SMTP id m25mr3065639jap.110.1639770093072; Fri, 17 Dec 2021 11:41:33 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id w19sm6079605iov.12.2021.12.17.11.41.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Dec 2021 11:41:32 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Heinrich Schuchardt , Tom Rini , Ilias Apalodimas , Christian Melki , Simon Glass , Alexander Graf Subject: [PATCH v6 17/27] efi: Show when allocated pages are used Date: Fri, 17 Dec 2021 12:40:49 -0700 Message-Id: <20211217124039.v6.17.I2eff1cd4f12753d0d86e9751fa350458ef5789e0@changeid> X-Mailer: git-send-email 2.34.1.173.g76aa8bc2d0-goog In-Reply-To: <20211217194059.858580-1-sjg@chromium.org> References: <20211217194059.858580-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 at phobos.denx.de X-Virus-Status: Clean Add a message here so that both paths of memory allocation are reported. Signed-off-by: Simon Glass --- (no changes since v2) Changes in v2: - Use log_info() instead of printf() lib/efi/efi_app.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/efi/efi_app.c b/lib/efi/efi_app.c index 2a6740b836a..b2d2de1dc3a 100644 --- a/lib/efi/efi_app.c +++ b/lib/efi/efi_app.c @@ -121,13 +121,14 @@ static efi_status_t setup_memory(struct efi_priv *priv) ret = boot->allocate_pages(EFI_ALLOCATE_MAX_ADDRESS, priv->image_data_type, pages, &addr); if (ret) { - printf("(using pool %lx) ", ret); + log_info("(using pool %lx) ", ret); priv->ram_base = (ulong)efi_malloc(priv, CONFIG_EFI_RAM_SIZE, &ret); if (!priv->ram_base) return ret; priv->use_pool_for_malloc = true; } else { + log_info("(using allocated RAM address %lx) ", (ulong)addr); priv->ram_base = addr; } gd->ram_size = pages << 12; From patchwork Fri Dec 17 19:40:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1570322 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=g97JTf7S; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JFzvb3Xg2z9sXM for ; Sat, 18 Dec 2021 06:44:27 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2ED34837DC; Fri, 17 Dec 2021 20:42:54 +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="g97JTf7S"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3F87383790; Fri, 17 Dec 2021 20:41: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.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) (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 424A98373B for ; Fri, 17 Dec 2021 20:41: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=sjg@chromium.org Received: by mail-io1-xd2e.google.com with SMTP id e128so4536302iof.1 for ; Fri, 17 Dec 2021 11:41:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WFlrf8lNMDHuMdz++pKK/D8Pb9GPuCd/StlxK/otA8Q=; b=g97JTf7Splf+v1bxRbBEhexyElAe+VFmAL5p3BtN8JYMIWG/MTLylKRucGUaY4wPZL +Xp9SI9JHlP6DmkelrD/VQMNP/06AXTjrTcUA/G+qIqmVLlCzJ3KgFLsW1FKbzofA3xG 4ZL5Q0WDYiXgz+EMX9DXy5/yKmUIJotQ6VlJM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WFlrf8lNMDHuMdz++pKK/D8Pb9GPuCd/StlxK/otA8Q=; b=euugzcTGSkVX/WcezCNuK75/wknA5yqlC26cJk03q0dTOxRua+TnQAEzt8bmRp0gMT kqkfa3K09PlqOXJv4Vnt3oO0vKgG0EAd4X/MIy+JJ/wPi9ixi0L/ELrwmxDnQEbc8Nbb mZgT1l3Y80UzGHM25Ob68eRMOL7fy8GUSb00tXG9ESsF1zWGEzrgiZn8HobzH6BglLwj b0qje7Xa75DF/oDWiR5irPClOUylTD8m1th1rqViK1FJFT76gFYbQdL5RGoPJqrNxori 9oo9dq2oFi8+cqDmK1bVaQztdxRFl1u+7TThTldzQTYIrBlcZ2EqcB9s9T0JweImUznp aGqA== X-Gm-Message-State: AOAM533JWbWPELpJzzsjyGJmH11iyCz62Vl4Mmc39+yudQ4qOnoAv+Jh QZ3tgCM2GI7xmzSFDizuAVK2+ARhzkLtKQ== X-Google-Smtp-Source: ABdhPJwJZI7J3w0uPU7yKqeahpQg1CA9Y9RoTBFt+ISJaW8hECEcV/M5WH4pNMdTNHrgyJfLvSkuIg== X-Received: by 2002:a5e:da09:: with SMTP id x9mr2539352ioj.171.1639770093794; Fri, 17 Dec 2021 11:41:33 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id w19sm6079605iov.12.2021.12.17.11.41.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Dec 2021 11:41:33 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Heinrich Schuchardt , Tom Rini , Ilias Apalodimas , Christian Melki , Simon Glass , Alexander Graf Subject: [PATCH v6 18/27] efi: Allow easy selection of serial-only operation Date: Fri, 17 Dec 2021 12:40:50 -0700 Message-Id: <20211217124039.v6.18.I8927cdce4b36339b962ef31074500198fcc3be1c@changeid> X-Mailer: git-send-email 2.34.1.173.g76aa8bc2d0-goog In-Reply-To: <20211217194059.858580-1-sjg@chromium.org> References: <20211217194059.858580-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 at phobos.denx.de X-Virus-Status: Clean Add info about how to select vidconsole or serial. Also set up a demo boot command. Signed-off-by: Simon Glass --- (no changes since v2) Changes in v2: - Add a better boot command too include/configs/efi-x86_app.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/include/configs/efi-x86_app.h b/include/configs/efi-x86_app.h index 6061a6db0a4..33afb7ca0f9 100644 --- a/include/configs/efi-x86_app.h +++ b/include/configs/efi-x86_app.h @@ -10,8 +10,33 @@ #undef CONFIG_TPM_TIS_BASE_ADDRESS +/* + * Select the output device: Put an 'x' prefix before one of these to disable it + */ + +/* + * Video output - can normally continue after exit_boot_services has been + * called, since output to the display does not require EFI services at that + * point. U-Boot sets up the console memory and does its own drawing. + */ #define CONFIG_STD_DEVICES_SETTINGS "stdin=serial\0" \ "stdout=vidconsole\0" \ "stderr=vidconsole\0" +/* + * Serial output with no console. Run qemu with: + * + * -display none -serial mon:stdio + * + * This will hang or fail to output on the console after exit_boot_services is + * called. + */ +#define xCONFIG_STD_DEVICES_SETTINGS "stdin=serial\0" \ + "stdout=serial\0" \ + "stderr=serial\0" + +#undef CONFIG_BOOTCOMMAND + +#define CONFIG_BOOTCOMMAND "part list efi 0; fatls efi 0:1" + #endif From patchwork Fri Dec 17 19:40:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1570324 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=WFZmTZvf; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JFzw05xMqz9sXM for ; Sat, 18 Dec 2021 06:44:48 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4D59D837E7; Fri, 17 Dec 2021 20:43:07 +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="WFZmTZvf"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7E65B83790; Fri, 17 Dec 2021 20:41:55 +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.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) (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 10D2C8378B for ; Fri, 17 Dec 2021 20:41: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-il1-x129.google.com with SMTP id f11so1094150ilr.8 for ; Fri, 17 Dec 2021 11:41:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xlCTD61hspCF/BpZcyg42MBOiNvt9nq23t/hPkjIrww=; b=WFZmTZvfV/+Gnv8SgHRF957QvMMZo7ZMVs1kPTFdmkXgwZyzkZ8NF/T9ZvPm3/AW+P NsF19GJsycUmFuH6SQOJrgVGskRWj5Q9oGH0nQi+uu5q9Y+XNlrSDcOnTF/BmGsbSNJL aO3sq8h0erGtJbfF+q4pnY98/CbVSl6yw7iEQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xlCTD61hspCF/BpZcyg42MBOiNvt9nq23t/hPkjIrww=; b=6/nnxJ9l//Tez+F8tqifzGp8S4PgHltZdNX53dboEjhuBqpEm/sg3JczLRxPl+nvxD 3hCV9CdmkTYHY9Cc+hDd4RW7m9iE6MCYC3tqZKmePjItiuCNlyJuMQHL6MV9wiPoty97 2HQxMG6gxqQzWlmqPElK4iSagP4JXDyHN0oGYumcfBrbpXxXJ6o8yHopLQjGPuksmPcf M1NwXi/a4uvLAJn1jrssZfIlg5kT4a587YIb4xS0z9JhzSpOb59uVE2mbrJtSrSCkOTt eK+qJRQqpTCyfMUXVB029N+P99LxeR9lipwlW/Hx182jx82+wB7qaKN78RTFxRTlU8/G 7VEQ== X-Gm-Message-State: AOAM531acsPYZvz8Or3C0CYCLgk90yw9R07gX2PPQLDIj5U7puBTagnB Cu/LwqlrLfTnZPzTDfuHCIYTX+PYU8++7A== X-Google-Smtp-Source: ABdhPJx1JQOy5pnHpLDkCrhUNHuuzN0CLgnZTxcVanNqm/dcBkGf+N9TgjRSpxes5eDYABiACHaWDA== X-Received: by 2002:a92:ca0e:: with SMTP id j14mr2438516ils.27.1639770094556; Fri, 17 Dec 2021 11:41:34 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id w19sm6079605iov.12.2021.12.17.11.41.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Dec 2021 11:41:34 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Heinrich Schuchardt , Tom Rini , Ilias Apalodimas , Christian Melki , Simon Glass , Alexander Graf Subject: [PATCH v6 19/27] x86: efi: Update efi_get_next_mem_desc() to avoid needing a map Date: Fri, 17 Dec 2021 12:40:51 -0700 Message-Id: <20211217124039.v6.19.I28bc9b47c17e9ce562088556d635ed3493b055ed@changeid> X-Mailer: git-send-email 2.34.1.173.g76aa8bc2d0-goog In-Reply-To: <20211217194059.858580-1-sjg@chromium.org> References: <20211217194059.858580-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 at phobos.denx.de X-Virus-Status: Clean At present this function requires a pointer to struct efi_entry_memmap but the only field used in there is the desc_size. We want to be able to use it from the app, so update it to use desc_size directly. Signed-off-by: Simon Glass --- (no changes since v1) arch/x86/cpu/efi/payload.c | 8 ++++---- cmd/efi.c | 34 ++++++++++++++++++---------------- include/efi.h | 4 ++-- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/arch/x86/cpu/efi/payload.c b/arch/x86/cpu/efi/payload.c index 3a9f7d72868..d2aa889a2b9 100644 --- a/arch/x86/cpu/efi/payload.c +++ b/arch/x86/cpu/efi/payload.c @@ -50,7 +50,7 @@ ulong board_get_usable_ram_top(ulong total_size) end = (struct efi_mem_desc *)((ulong)map + size); desc = map->desc; - for (; desc < end; desc = efi_get_next_mem_desc(map, desc)) { + for (; desc < end; desc = efi_get_next_mem_desc(desc, map->desc_size)) { if (desc->type != EFI_CONVENTIONAL_MEMORY || desc->physical_start >= 1ULL << 32) continue; @@ -88,7 +88,7 @@ int dram_init(void) end = (struct efi_mem_desc *)((ulong)map + size); gd->ram_size = 0; desc = map->desc; - for (; desc < end; desc = efi_get_next_mem_desc(map, desc)) { + for (; desc < end; desc = efi_get_next_mem_desc(desc, map->desc_size)) { if (desc->type < EFI_MMAP_IO) gd->ram_size += desc->num_pages << EFI_PAGE_SHIFT; } @@ -113,7 +113,7 @@ int dram_init_banksize(void) desc = map->desc; for (num_banks = 0; desc < end && num_banks < CONFIG_NR_DRAM_BANKS; - desc = efi_get_next_mem_desc(map, desc)) { + desc = efi_get_next_mem_desc(desc, map->desc_size)) { /* * We only use conventional memory and ignore * anything less than 1MB. @@ -196,7 +196,7 @@ unsigned int install_e820_map(unsigned int max_entries, end = (struct efi_mem_desc *)((ulong)map + size); for (desc = map->desc; desc < end; - desc = efi_get_next_mem_desc(map, desc)) { + desc = efi_get_next_mem_desc(desc, map->desc_size)) { if (desc->num_pages == 0) continue; diff --git a/cmd/efi.c b/cmd/efi.c index f2ed26bd4b2..d2400acbbba 100644 --- a/cmd/efi.c +++ b/cmd/efi.c @@ -75,16 +75,17 @@ static int h_cmp_entry(const void *v1, const void *v2) /** * efi_build_mem_table() - make a sorted copy of the memory table * - * @map: Pointer to EFI memory map table + * @desc_base: Pointer to EFI memory map table * @size: Size of table in bytes + * @desc_size: Size of each @desc_base record * @skip_bs: True to skip boot-time memory and merge it with conventional * memory. This will significantly reduce the number of table * entries. * Return: pointer to the new table. It should be freed with free() by the * caller. */ -static void *efi_build_mem_table(struct efi_entry_memmap *map, int size, - bool skip_bs) +static void *efi_build_mem_table(struct efi_mem_desc *desc_base, int size, + int desc_size, bool skip_bs) { struct efi_mem_desc *desc, *end, *base, *dest, *prev; int count; @@ -95,15 +96,16 @@ static void *efi_build_mem_table(struct efi_entry_memmap *map, int size, debug("%s: Cannot allocate %#x bytes\n", __func__, size); return NULL; } - end = (struct efi_mem_desc *)((ulong)map + size); - count = ((ulong)end - (ulong)map->desc) / map->desc_size; - memcpy(base, map->desc, (ulong)end - (ulong)map->desc); - qsort(base, count, map->desc_size, h_cmp_entry); + end = (void *)desc_base + size; + count = ((ulong)end - (ulong)desc_base) / desc_size; + memcpy(base, desc_base, (ulong)end - (ulong)desc_base); + qsort(base, count, desc_size, h_cmp_entry); prev = NULL; addr = 0; dest = base; - end = (struct efi_mem_desc *)((ulong)base + count * map->desc_size); - for (desc = base; desc < end; desc = efi_get_next_mem_desc(map, desc)) { + end = (struct efi_mem_desc *)((ulong)base + count * desc_size); + for (desc = base; desc < end; + desc = efi_get_next_mem_desc(desc, desc_size)) { bool merge = true; u32 type = desc->type; @@ -116,7 +118,7 @@ static void *efi_build_mem_table(struct efi_entry_memmap *map, int size, if (skip_bs && is_boot_services(desc->type)) type = EFI_CONVENTIONAL_MEMORY; - memcpy(dest, desc, map->desc_size); + memcpy(dest, desc, desc_size); dest->type = type; if (!skip_bs || !prev) merge = false; @@ -131,7 +133,7 @@ static void *efi_build_mem_table(struct efi_entry_memmap *map, int size, prev->num_pages += desc->num_pages; } else { prev = dest; - dest = efi_get_next_mem_desc(map, dest); + dest = efi_get_next_mem_desc(dest, desc_size); } addr = desc->physical_start + (desc->num_pages << EFI_PAGE_SHIFT); @@ -143,8 +145,8 @@ static void *efi_build_mem_table(struct efi_entry_memmap *map, int size, return base; } -static void efi_print_mem_table(struct efi_entry_memmap *map, - struct efi_mem_desc *desc, bool skip_bs) +static void efi_print_mem_table(struct efi_mem_desc *desc, int desc_size, + bool skip_bs) { u64 attr_seen[ATTR_SEEN_MAX]; int attr_seen_count; @@ -158,7 +160,7 @@ static void efi_print_mem_table(struct efi_entry_memmap *map, attr_seen_count = 0; addr = 0; for (upto = 0; desc->type != EFI_MAX_MEMORY_TYPE; - upto++, desc = efi_get_next_mem_desc(map, desc)) { + upto++, desc = efi_get_next_mem_desc(desc, desc_size)) { const char *name; u64 size; @@ -238,13 +240,13 @@ static int do_efi_mem(struct cmd_tbl *cmdtp, int flag, int argc, goto done; } - desc = efi_build_mem_table(map, size, skip_bs); + desc = efi_build_mem_table(map->desc, size, map->desc_size, skip_bs); if (!desc) { ret = -ENOMEM; goto done; } - efi_print_mem_table(map, desc, skip_bs); + efi_print_mem_table(desc, map->desc_size, skip_bs); free(desc); done: if (ret) diff --git a/include/efi.h b/include/efi.h index 0aa07193640..d6d73c5fab4 100644 --- a/include/efi.h +++ b/include/efi.h @@ -395,9 +395,9 @@ struct efi_entry_systable { }; static inline struct efi_mem_desc *efi_get_next_mem_desc( - struct efi_entry_memmap *map, struct efi_mem_desc *desc) + struct efi_mem_desc *desc, int desc_size) { - return (struct efi_mem_desc *)((ulong)desc + map->desc_size); + return (struct efi_mem_desc *)((ulong)desc + desc_size); } /** From patchwork Fri Dec 17 19:40:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1570326 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=mRp4cwL3; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JFzwP1T5hz9sXM for ; Sat, 18 Dec 2021 06:45:09 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 99081837F7; Fri, 17 Dec 2021 20:43:16 +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="mRp4cwL3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 23B668377E; Fri, 17 Dec 2021 20:41:57 +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.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) (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 B98DD8378E for ; Fri, 17 Dec 2021 20:41: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-io1-xd30.google.com with SMTP id x6so4387718iol.13 for ; Fri, 17 Dec 2021 11:41:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=64M3DxGONBInDU2G/2gjlpkEA3FwdQkx9/yPYRMtCYE=; b=mRp4cwL3tH8YwigaaSsmLoFlRzBVA3S+5yBUgc8fVO74UCN3TanScRjdRjD5C66Jt/ 79ArV8Wez37afMMMhp+vZpmZEIPnSsEbV6RXivmYOSpVOSv4vN7OOvYJBXCOsbgPdP1G Xna1qZjooF1QoKn3+UYxOxBfVF0e9pTBwenR0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=64M3DxGONBInDU2G/2gjlpkEA3FwdQkx9/yPYRMtCYE=; b=p3f16//vn8S18+1nx6g07534avOmUtnEg/pvFQQEVcpvM2qWGjDqpEhX4CVHot+4Ui QcO7sFOW6yDoCdTHMpQL9LhGj65QiW/xuebXTvknHLdycR5+vSWTrhc0LFCTMN/wvz6j qn+7S/X/YZx5BQ1LVf4OqJGHz3SRDZst1kZxD+13AgYlLlDV7iMe+YUzsRB3zTINr0jF gmPp0YOq/dNjK05gwSBUWjQmgT4uIFgkR9ZM3b4O0gVHgo+6UIkstUYXGfT6WjZOM1Sg sTLu4S9DRKLBOe2PgzsMEzVJE/5XXWSc0KOqHtgLgjYHyBiAPoIyUpaRrjwRIUfa99Zk 3bQQ== X-Gm-Message-State: AOAM533NyqMSTqfVxX/d4iULVMGkWF295eTNqCk1M5fVtlHqA4ctv97y /lhBvr/eHzePF+8l2GLyOiSmGcfRc/n1Nw== X-Google-Smtp-Source: ABdhPJwsatCR76tTaZbScI6H6GGtzw5hMbmghCcEXMQbProzamCfYtrU2chOBq4ELQuWV5GFRWXQLQ== X-Received: by 2002:a05:6602:2e11:: with SMTP id o17mr2515847iow.172.1639770095248; Fri, 17 Dec 2021 11:41:35 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id w19sm6079605iov.12.2021.12.17.11.41.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Dec 2021 11:41:35 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Heinrich Schuchardt , Tom Rini , Ilias Apalodimas , Christian Melki , Simon Glass , Alexander Graf Subject: [PATCH v6 20/27] efi: Support the efi command in the app Date: Fri, 17 Dec 2021 12:40:52 -0700 Message-Id: <20211217194059.858580-14-sjg@chromium.org> X-Mailer: git-send-email 2.34.1.173.g76aa8bc2d0-goog In-Reply-To: <20211217194059.858580-1-sjg@chromium.org> References: <20211217194059.858580-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 at phobos.denx.de X-Virus-Status: Clean At present the 'efi' command only works in the EFI payload. Update it to work in the app too, so the memory map can be examined. Signed-off-by: Simon Glass --- (no changes since v1) cmd/Makefile | 2 +- cmd/efi.c | 48 ++++++++++++++++++++++++++++++++--------------- include/efi.h | 15 +++++++++++++++ lib/efi/efi_app.c | 33 ++++++++++++++++++++++++++++++++ 4 files changed, 82 insertions(+), 16 deletions(-) diff --git a/cmd/Makefile b/cmd/Makefile index 891819ae0f6..df50625bde7 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -58,7 +58,7 @@ obj-$(CONFIG_CMD_EXTENSION) += extension_board.o obj-$(CONFIG_CMD_ECHO) += echo.o obj-$(CONFIG_ENV_IS_IN_EEPROM) += eeprom.o obj-$(CONFIG_CMD_EEPROM) += eeprom.o -obj-$(CONFIG_EFI_STUB) += efi.o +obj-$(CONFIG_EFI) += efi.o obj-$(CONFIG_CMD_EFIDEBUG) += efidebug.o obj-$(CONFIG_CMD_ELF) += elf.o obj-$(CONFIG_HUSH_PARSER) += exit.o diff --git a/cmd/efi.c b/cmd/efi.c index d2400acbbba..c0384e0db28 100644 --- a/cmd/efi.c +++ b/cmd/efi.c @@ -13,6 +13,8 @@ #include #include +DECLARE_GLOBAL_DATA_PTR; + static const char *const type_name[] = { "reserved", "loader_code", @@ -217,37 +219,53 @@ static void efi_print_mem_table(struct efi_mem_desc *desc, int desc_size, static int do_efi_mem(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct efi_mem_desc *desc; - struct efi_entry_memmap *map; + struct efi_mem_desc *orig, *desc; + uint version, key; + int desc_size; int size, ret; bool skip_bs; skip_bs = !argc || *argv[0] != 'a'; - ret = efi_info_get(EFIET_MEMORY_MAP, (void **)&map, &size); - switch (ret) { - case -ENOENT: - printf("No EFI table available\n"); - goto done; - case -EPROTONOSUPPORT: - printf("Incorrect EFI table version\n"); - goto done; + if (IS_ENABLED(CONFIG_EFI_APP)) { + ret = efi_get_mmap(&orig, &size, &key, &desc_size, &version); + if (ret) { + printf("Cannot read memory map (err=%d)\n", ret); + return CMD_RET_FAILURE; + } + } else { + struct efi_entry_memmap *map; + + ret = efi_info_get(EFIET_MEMORY_MAP, (void **)&map, &size); + switch (ret) { + case -ENOENT: + printf("No EFI table available\n"); + goto done; + case -EPROTONOSUPPORT: + printf("Incorrect EFI table version\n"); + goto done; + } + orig = map->desc; + desc_size = map->desc_size; + version = map->version; } - printf("EFI table at %lx, memory map %p, size %x, version %x, descr. size %#x\n", - gd->arch.table, map, size, map->version, map->desc_size); - if (map->version != EFI_MEM_DESC_VERSION) { + printf("EFI table at %lx, memory map %p, size %x, key %x, version %x, descr. size %#x\n", + gd->arch.table, orig, size, key, version, desc_size); + if (version != EFI_MEM_DESC_VERSION) { printf("Incorrect memory map version\n"); ret = -EPROTONOSUPPORT; goto done; } - desc = efi_build_mem_table(map->desc, size, map->desc_size, skip_bs); + desc = efi_build_mem_table(orig, size, desc_size, skip_bs); if (!desc) { ret = -ENOMEM; goto done; } - efi_print_mem_table(desc, map->desc_size, skip_bs); + efi_print_mem_table(desc, desc_size, skip_bs); free(desc); + if (IS_ENABLED(CONFIG_EFI_APP)) + free(orig); done: if (ret) printf("Error: %d\n", ret); diff --git a/include/efi.h b/include/efi.h index d6d73c5fab4..bd23a867136 100644 --- a/include/efi.h +++ b/include/efi.h @@ -610,4 +610,19 @@ int efi_store_memory_map(struct efi_priv *priv); */ int efi_call_exit_boot_services(void); +/** + * efi_get_mmap() - Get the memory map from EFI + * + * This is used in the app. The caller must free *@descp when done + * + * @descp: Returns allocated pointer to EFI memory map table + * @sizep: Returns size of table in bytes + * @keyp: Returns memory-map key + * @desc_sizep: Returns size of each @desc_base record + * @versionp: Returns version number of memory map + * @return 0 on success, -ve on error + */ +int efi_get_mmap(struct efi_mem_desc **descp, int *sizep, uint *keyp, + int *desc_sizep, uint *versionp); + #endif /* _LINUX_EFI_H */ diff --git a/lib/efi/efi_app.c b/lib/efi/efi_app.c index b2d2de1dc3a..d798bf98ca6 100644 --- a/lib/efi/efi_app.c +++ b/lib/efi/efi_app.c @@ -32,6 +32,39 @@ int efi_info_get(enum efi_entry_t type, void **datap, int *sizep) return -ENOSYS; } +int efi_get_mmap(struct efi_mem_desc **descp, int *sizep, uint *keyp, + int *desc_sizep, uint *versionp) +{ + struct efi_priv *priv = efi_get_priv(); + struct efi_boot_services *boot = priv->sys_table->boottime; + efi_uintn_t size, desc_size, key; + struct efi_mem_desc *desc; + efi_status_t ret; + u32 version; + + /* Get the memory map so we can switch off EFI */ + size = 0; + ret = boot->get_memory_map(&size, NULL, &key, &desc_size, &version); + if (ret != EFI_BUFFER_TOO_SMALL) + return log_msg_ret("get", -ENOMEM); + + desc = malloc(size); + if (!desc) + return log_msg_ret("mem", -ENOMEM); + + ret = boot->get_memory_map(&size, desc, &key, &desc_size, &version); + if (ret) + return log_msg_ret("get", -EINVAL); + + *descp = desc; + *sizep = size; + *desc_sizep = desc_size; + *versionp = version; + *keyp = key; + + return 0; +} + /** * efi_print_str() - Print a UFT-16 string to the U-Boot console * From patchwork Fri Dec 17 19:40:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1570334 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=nsoM/Z+a; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JG00S3vk0z9sXM for ; Sat, 18 Dec 2021 06:48:40 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 76F34837C8; Fri, 17 Dec 2021 20:48: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="nsoM/Z+a"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E6019837D6; Fri, 17 Dec 2021 20:48:34 +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.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) (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 493B78377B for ; Fri, 17 Dec 2021 20:41: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-io1-xd32.google.com with SMTP id y16so4470785ioc.8 for ; Fri, 17 Dec 2021 11:41:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SNqsk0czae2tbBpQQ9bAghd37jGo4B14N8cmjFESgi8=; b=nsoM/Z+ao81p+buhiX9OYe5h4p+T1dAIhUYdI7fNYX/kALJgnIlPSPLu0q6aVX2BE8 f5/equRMdIwkyvQ75O9DTmBG7BShSgIyBemVzn1PNWo6/ommv3sJa6rNZg39mK6L2pvT AbD/+4EynWKq/L5OUwJOxIQyIT+aZi6Uzmn7U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SNqsk0czae2tbBpQQ9bAghd37jGo4B14N8cmjFESgi8=; b=kqp4hVZeZ70XFtDPVpWkMrWxl0uYTtnbyI76S6gjznNYhIhE9qrY7oE9ve0RSLkVX2 XhmWvJ36pKmg7s5a1K4Tq3Gm1BwOO0LRKcJSt0IWSYuaBsuzUV1eQtYVKo1a2eXEAuib F/+6FtcatGujHsnsVh42rdJH1UMWRNrGlv/FjRiX+IaZmXxJdOfB3aJvbYDw43WyUOoY LgExL7vjgoAnW4Epok8UU7Biwb5zeH4Thq8V1teqfo0IW/vaAFdYDNtzqWdcqB+43+O7 P5RgeT3n2VaQtZIGPpvHY6ocLZ0Bnw3aq76GTZ5/mquf6OYjT5fdatNVNjIqTikC0Jo5 h8iA== X-Gm-Message-State: AOAM530AI8W8a/LP52mLsYCwW/W4tbgb4aSgEhAe3WQJ5kxp08YyIMez DwmWE2YjY7AB8GFZLPUo4aMNfCkaXCUsIw== X-Google-Smtp-Source: ABdhPJw3MEyTFL81pDJMGHgR1yr1eBMIyrKoZtU+KCAc7slKtn0ZZ1SEoamu+qlni4Fl7YaGLutUhQ== X-Received: by 2002:a05:6638:2054:: with SMTP id t20mr3070407jaj.42.1639770095942; Fri, 17 Dec 2021 11:41:35 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id w19sm6079605iov.12.2021.12.17.11.41.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Dec 2021 11:41:35 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Heinrich Schuchardt , Tom Rini , Ilias Apalodimas , Christian Melki , Simon Glass , Alexander Graf Subject: [PATCH v6 21/27] x86: efi: Show the system-table revision Date: Fri, 17 Dec 2021 12:40:53 -0700 Message-Id: <20211217124039.v6.21.I06df84f267228992662b3897e92747937e6b317a@changeid> X-Mailer: git-send-email 2.34.1.173.g76aa8bc2d0-goog In-Reply-To: <20211217194059.858580-1-sjg@chromium.org> References: <20211217194059.858580-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 at phobos.denx.de X-Virus-Status: Clean Show the revision of this table as it can be important. Also update the 'efi table' entry to show the actual address of the EFI table rather than our table that points to it. This saves a step and the intermediate table has nothing else in it. Signed-off-by: Simon Glass --- Changes in v6: - Fix Alo typo in commit message Changes in v5: - Fix grammar in commit message Changes in v3: - Add new patch to show the system-table revision arch/x86/cpu/efi/payload.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/x86/cpu/efi/payload.c b/arch/x86/cpu/efi/payload.c index d2aa889a2b9..b7778565b19 100644 --- a/arch/x86/cpu/efi/payload.c +++ b/arch/x86/cpu/efi/payload.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -296,8 +297,14 @@ void setup_efi_info(struct efi_info *efi_info) void efi_show_bdinfo(void) { struct efi_entry_systable *table = NULL; + struct efi_system_table *sys_table; int size, ret; ret = efi_info_get(EFIET_SYS_TABLE, (void **)&table, &size); - bdinfo_print_num_l("efi_table", (ulong)table); + if (!ret) { + bdinfo_print_num_l("efi_table", table->sys_table); + sys_table = (struct efi_system_table *)(uintptr_t) + table->sys_table; + bdinfo_print_num_l(" revision", sys_table->fw_revision); + } } From patchwork Fri Dec 17 19:40:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1570325 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=VSQztaWB; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JFzwB74jqz9sXM for ; Sat, 18 Dec 2021 06:44:58 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CAFFF837DE; Fri, 17 Dec 2021 20:43:11 +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="VSQztaWB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7B70B83774; Fri, 17 Dec 2021 20:41:56 +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.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) (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 E1E508370D for ; Fri, 17 Dec 2021 20:41: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-io1-xd32.google.com with SMTP id x6so4387788iol.13 for ; Fri, 17 Dec 2021 11:41:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=No9SN3IPxYwiDDCrGiEv5wrYbvXYj8mFsK797rBKjrI=; b=VSQztaWBQhF2/78X3QD0SpMZiJqokEuaBwS3lqgBymikJ6kmguQVb69Recx1olkYLb v+P+PnPYX5Umrm7DVleJqRNX2Fq819xruIvahXfFnEoDiUapIKhZCYXBcR9TRKEoS7j3 5cjrXlu0ZSAq+R8P1WE4467CpblFZEl0um8hs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=No9SN3IPxYwiDDCrGiEv5wrYbvXYj8mFsK797rBKjrI=; b=wroLm3ujTt1s3U27VH/9TxEJHs27Hbb/G40ZlaSJLE9JnR0KA2yfbzm2v5LlHWh5fI vF54VWzwihY/b8YjFkH9cYbiGAVaGW4Uz4Hwq7TM7Qshy6Bzb6a09KWAu6UzA2+VzE53 Gz109GZdHUIGh6j4xzMwGkwN48TCCwGxswoE56yN4pQyfMDKcStEyYcI+Np1JINjgLW8 cl1Sj8ofFjRW8knJJlN8mRC0L54nTtj4Fv2DsOeIGUhhWiZyWQ3YTEDAuR6AgR7sWzRk p+zp3UgeDLGdCE2mPQwYzrqAF5DIFZFMjB/jg7euzCb//sNgNvm9qy+okUWU7JZxmRKE sy/w== X-Gm-Message-State: AOAM5322t8Zu4nEIlIrYQ0tXlSfOykLJSthYT2cTiUBVg/tTUXTs2NgB 25pD0eCk8hhxcSSCLRfO8+UycD8b4EcjIA== X-Google-Smtp-Source: ABdhPJw0L0nXXfNZDGdnku91eUu3vdFLWyXofnnh3EI7CtMW+PDL7/Z/tWNHsHIH1TW//1gAJDQKxw== X-Received: by 2002:a05:6638:2191:: with SMTP id s17mr3209225jaj.67.1639770096617; Fri, 17 Dec 2021 11:41:36 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id w19sm6079605iov.12.2021.12.17.11.41.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Dec 2021 11:41:36 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Heinrich Schuchardt , Tom Rini , Ilias Apalodimas , Christian Melki , Simon Glass , Alexander Graf Subject: [PATCH v6 22/27] x86: efi: Don't set up global_data again with EFI Date: Fri, 17 Dec 2021 12:40:54 -0700 Message-Id: <20211217124039.v6.22.I8106c6bf199fd2c7ec7ba51f3cd19b917f195e73@changeid> X-Mailer: git-send-email 2.34.1.173.g76aa8bc2d0-goog In-Reply-To: <20211217194059.858580-1-sjg@chromium.org> References: <20211217194059.858580-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 at phobos.denx.de X-Virus-Status: Clean Since EFI does not relocate and uses the same global_data pointer throughout the board-init process, drop this unnecessary setup, to avoid a hang. Signed-off-by: Simon Glass --- (no changes since v5) Changes in v5: - Add new patch to avoid setting up global_data again with EFI common/board_r.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/common/board_r.c b/common/board_r.c index 31a59c585a8..8b5948100b1 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -817,9 +817,8 @@ void board_init_r(gd_t *new_gd, ulong dest_addr) * TODO(sjg@chromium.org): Consider doing this for all archs, or * dropping the new_gd parameter. */ -#if CONFIG_IS_ENABLED(X86_64) - arch_setup_gd(new_gd); -#endif + if (CONFIG_IS_ENABLED(X86_64) && !IS_ENABLED(CONFIG_EFI_APP)) + arch_setup_gd(new_gd); #ifdef CONFIG_NEEDS_MANUAL_RELOC int i; From patchwork Fri Dec 17 19:40:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1570330 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=Th2HeCgL; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JFzx95rn1z9sXM for ; Sat, 18 Dec 2021 06:45:49 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1BFCE837FA; Fri, 17 Dec 2021 20:43:31 +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="Th2HeCgL"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 400DA83790; Fri, 17 Dec 2021 20:42:00 +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.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) (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 B1F0083762 for ; Fri, 17 Dec 2021 20:41:38 +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-il1-x134.google.com with SMTP id m12so2533721ild.0 for ; Fri, 17 Dec 2021 11:41:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=O39fzl2hzuGjbPueWAgHq3n76RtMOH1354jL7MY61V0=; b=Th2HeCgL8pNcc1C9sGo1oWsvKhVWi8mA0avQmgn7JMW+2nrkKpjqOzrXm9UhrQ9REz kxW+Snzr1tYwZqYfLU42nr8z2uDk7K8mxkJNO0E7fGomrd3M9e3Xck2NFwyyp036USI8 sAEiZK4TAMudHjBPbggTr0L8+k4xAO7qsNwu0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=O39fzl2hzuGjbPueWAgHq3n76RtMOH1354jL7MY61V0=; b=LPbjjnIAyOw+MX74fyMiFTBeJ8hcCiuyAxqO4Y8IjB/4VnIFtwriYOl/1oOzNuiFk8 sN/J2P8o4KWojTGDnndwqPulj+0IO+PxzC2LIY2djK/iJgtFuXVWPrFOnhMUmftpKu1a 5vO1cxNyIINDo3jSjUeH3Rr4t4zpIBypaGXy31LXyGtkKIUQ81Eud3zzE9vuSV9IJzpz dhFC3e29bR7MqJ9VFEMOO+lt/QCMIEXwzhCF8XERgL+zH/f/EIklTVSSNzeWKJ9fMbpf Wt+16raPSsM/OikWH7dkIO9iSZFOUX0fij4eHMUwpLSuIg0q9V7krkTdqzUnIKGufZZO C2dg== X-Gm-Message-State: AOAM5338IEkBhBqHpzRqu0KXJNn+vm8KhjJ4orH9nhW0YTQpeHvqxs8r HELwnzJOkR0sLj/E+I3fWfgMpjQgFVCCPQ== X-Google-Smtp-Source: ABdhPJzacv0/6DGRA01+2qRSUvbiIvnODHtMzViaVn7MbpZsiSA3RCmnjVkBQWJaXLEVBiglk1qI1g== X-Received: by 2002:a92:c609:: with SMTP id p9mr2421616ilm.49.1639770097325; Fri, 17 Dec 2021 11:41:37 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id w19sm6079605iov.12.2021.12.17.11.41.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Dec 2021 11:41:37 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Heinrich Schuchardt , Tom Rini , Ilias Apalodimas , Christian Melki , Simon Glass , Alexander Graf Subject: [PATCH v6 23/27] x86: efi: Tweak the code used for the 64-bit EFI app Date: Fri, 17 Dec 2021 12:40:55 -0700 Message-Id: <20211217124039.v6.23.Ie7b956a0ec72d43bd83558492e70a193c520a574@changeid> X-Mailer: git-send-email 2.34.1.173.g76aa8bc2d0-goog In-Reply-To: <20211217194059.858580-1-sjg@chromium.org> References: <20211217194059.858580-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 at phobos.denx.de X-Virus-Status: Clean Add an empty CPU init function to avoid fiddling with low-level CPU features in the app. Set up the C runtime correctly for 64-bit use and avoid clearing BSS, since this is done by EFI when U-Boot is loaded. Signed-off-by: Simon Glass --- (no changes since v5) Changes in v5: - Add new patch to tweak the code used for the 64-bit EFI app arch/x86/cpu/x86_64/cpu.c | 5 +++++ arch/x86/lib/Makefile | 5 ++--- arch/x86/lib/relocate.c | 2 ++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/arch/x86/cpu/x86_64/cpu.c b/arch/x86/cpu/x86_64/cpu.c index a3674e8e29a..6a387612916 100644 --- a/arch/x86/cpu/x86_64/cpu.c +++ b/arch/x86/cpu/x86_64/cpu.c @@ -45,3 +45,8 @@ int cpu_phys_address_size(void) { return CONFIG_CPU_ADDR_BITS; } + +int x86_cpu_init_f(void) +{ + return 0; +} diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile index 18757b29aa9..e5235b7c4f4 100644 --- a/arch/x86/lib/Makefile +++ b/arch/x86/lib/Makefile @@ -65,9 +65,8 @@ endif lib-$(CONFIG_USE_PRIVATE_LIBGCC) += div64.o -ifeq ($(CONFIG_$(SPL_)X86_64),) -obj-$(CONFIG_EFI_APP) += crt0_ia32_efi.o reloc_ia32_efi.o -endif +obj-$(CONFIG_EFI_APP_32BIT) += crt0_ia32_efi.o reloc_ia32_efi.o +obj-$(CONFIG_EFI_APP_64BIT) += crt0_x86_64_efi.o reloc_x86_64_efi.o ifneq ($(CONFIG_EFI_STUB),) diff --git a/arch/x86/lib/relocate.c b/arch/x86/lib/relocate.c index 6fe51516477..9060d19d46a 100644 --- a/arch/x86/lib/relocate.c +++ b/arch/x86/lib/relocate.c @@ -35,6 +35,7 @@ int copy_uboot_to_ram(void) return 0; } +#ifndef CONFIG_EFI_APP int clear_bss(void) { ulong dst_addr = (ulong)&__bss_start + gd->reloc_off; @@ -46,6 +47,7 @@ int clear_bss(void) return 0; } +#endif #if CONFIG_IS_ENABLED(X86_64) static void do_elf_reloc_fixups64(unsigned int text_base, uintptr_t size, From patchwork Fri Dec 17 19:40:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1570331 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=kjRABk8e; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JFzxM3cLRz9sXM for ; Sat, 18 Dec 2021 06:45:59 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0C3D783813; Fri, 17 Dec 2021 20:43: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=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="kjRABk8e"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AC24B837A5; Fri, 17 Dec 2021 20:42:09 +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.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12f.google.com (mail-il1-x12f.google.com [IPv6:2607:f8b0:4864:20::12f]) (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 A6D6683751 for ; Fri, 17 Dec 2021 20:41: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-il1-x12f.google.com with SMTP id j6so1045129ila.4 for ; Fri, 17 Dec 2021 11:41:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ieGZgKQau7GvHN6R9mMTcbHeB8QrduEGsq79db1UF3Y=; b=kjRABk8eQa1vQSwuja2yEB228grcr5f1IyR9nt6Hkir7jz4crzKkqdmXc2F9Yg8YYA jfWjjY3aiiI9wi/nXkFZ1enfrxpdu5I9yuwCAZjrgG5bOWWAnB5Tjs7e28dKVSF+tQII w0M1ZPCDSkiPxBXDmOLz99QuUn2o5B0mZo2os= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ieGZgKQau7GvHN6R9mMTcbHeB8QrduEGsq79db1UF3Y=; b=0BlkqQdutXXQ1ju2dOhPpUGB/0+RwwFPM25aSDIoA5a5pQEHUHpcOgbc+F7bVQj1wA Ptk2qt9UQB/TdErQtKeuLwxPkphXa/PN9xsIR7Vwzq3stVz/2VVsJxR3nZ/Mz/44Xy+s yCZIgxsrAXQ40HtSnV8XsT58sDugKtMVwrS9jj1BG5uL2jcI4JLw49T6t9mAdYNrYx81 yZJmhSY8JrGk0EMDtlENShDuBoS/jKKleBf3nPCnvolAAJ4YR848UNWNPr1X8tVkTgnX 7sX1OLheK4BU2T63NR6sfKwN310qF2dCM8+HfjlhCTFHIpbLuOY6jUvC31F3YScMk9JA dwZg== X-Gm-Message-State: AOAM532VsNbIF/RqM2mc8PutYF7wPQVKoL+RokAUMnEGiUAvbZ+/vlvA tr8L/WDflB8jNUue8jMW+V4dho+1zdWTqw== X-Google-Smtp-Source: ABdhPJxkn7GbmaSyHXNu0lsbduUPg0DjrMLx0lWxmIUU7kqQQ0Zxkq2trxgWEGeSp29E0Uw+JuhG3A== X-Received: by 2002:a05:6e02:1a47:: with SMTP id u7mr2417255ilv.258.1639770098078; Fri, 17 Dec 2021 11:41:38 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id w19sm6079605iov.12.2021.12.17.11.41.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Dec 2021 11:41:37 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Heinrich Schuchardt , Tom Rini , Ilias Apalodimas , Christian Melki , Simon Glass , Alexander Graf Subject: [PATCH v6 24/27] x86: efi: Round out the link script for 64-bit EFI Date: Fri, 17 Dec 2021 12:40:56 -0700 Message-Id: <20211217124039.v6.24.Ibbbfbb93440dae511929e6f988c0c13741f4bf2f@changeid> X-Mailer: git-send-email 2.34.1.173.g76aa8bc2d0-goog In-Reply-To: <20211217194059.858580-1-sjg@chromium.org> References: <20211217194059.858580-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 at phobos.denx.de X-Virus-Status: Clean Make sure the linker lists are in the right place and drop the eh_frame section, which is not needed. Signed-off-by: Simon Glass --- (no changes since v5) Changes in v5: - Add new patch to round out the link script for 64-bit EFI arch/x86/lib/elf_x86_64_efi.lds | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/x86/lib/elf_x86_64_efi.lds b/arch/x86/lib/elf_x86_64_efi.lds index b436429b33e..75727400aa4 100644 --- a/arch/x86/lib/elf_x86_64_efi.lds +++ b/arch/x86/lib/elf_x86_64_efi.lds @@ -63,6 +63,7 @@ SECTIONS *(.rela.data*) *(.rela.got) *(.rela.stab) + *(.rela.u_boot_list*) } . = ALIGN(4096); @@ -70,9 +71,11 @@ SECTIONS . = ALIGN(4096); .dynstr : { *(.dynstr) } . = ALIGN(4096); + + /DISCARD/ : { *(.eh_frame) } + .ignored.reloc : { *(.rela.reloc) - *(.eh_frame) *(.note.GNU-stack) } From patchwork Fri Dec 17 19:40:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1570327 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=hfITjPqj; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JFzwb0Lvbz9sXM for ; Sat, 18 Dec 2021 06:45:18 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3C5B1837E5; Fri, 17 Dec 2021 20:43:20 +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="hfITjPqj"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 46D728373B; Fri, 17 Dec 2021 20:41:56 +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.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) (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 40CB283774 for ; Fri, 17 Dec 2021 20:41:40 +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-io1-xd2b.google.com with SMTP id y16so4470947ioc.8 for ; Fri, 17 Dec 2021 11:41:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DRWYBSyocrGuMVSNltcMDfeP/N+J6ej8EI46N+MNqCk=; b=hfITjPqjGX2YUMfWeQnl9dj94WAAfQdJjUA50f/hrbDOwP7OU4kqXfnZMnKPLUyoCV +TbSWz+KC/j/uG0GT6ujjq/hDETm2CRExGo+basDNrI2zvfCNsmTdyQCE7D+zc2v/0Yc Y06fNZwgJrFthNA1jZr8ua1/+PcgeklBOgS98= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DRWYBSyocrGuMVSNltcMDfeP/N+J6ej8EI46N+MNqCk=; b=7PMc5KeRzTiYp3/VwJW3cyYOKBpgZLRj28shmMkFvMkEYAiYJp8aR1D3H2VsWuqPF1 2tUjJfa+naVH18QoO71ddL73PVtcBooq0CfpxG46CCQRXJTEQH/7L6egPYU9T1UYh0m/ KMzfd+vtzN5jSV8tmxB72sr0RB7wWDvdl7eVP09Q6HZofMfeRevrn/6PTBQcd3cmLuRN sFDHjTSdXv4eTKMiDEhITM3Ihy7wCayth1L6Dzlv1oAaFrcmftKXycGYbkcnT2jRLWXn yLo7R9wvDJeiNoDEoXt7C5+hLzW1ipbdLsEeV6Fd2YlU4EdrsmgrtXQSbYzFJhuohT4Q k+wA== X-Gm-Message-State: AOAM533N8jy2s8Uhv6kW0jmDKa/bgQyqqf99DeuqAljjCV/rAjJdIqR7 uPwl5/j6a8x7K9T1DbH3r3sGH6J+6eHM/Q== X-Google-Smtp-Source: ABdhPJygpncXKzT6mabze+IJ3xf4BYYduy3XHFIZc4jAr5VPPOWhDUPqZZgyUEse3ZjGNomCz4PxiQ== X-Received: by 2002:a6b:740b:: with SMTP id s11mr2530364iog.120.1639770098944; Fri, 17 Dec 2021 11:41:38 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id w19sm6079605iov.12.2021.12.17.11.41.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Dec 2021 11:41:38 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Heinrich Schuchardt , Tom Rini , Ilias Apalodimas , Christian Melki , Simon Glass , Alexander Graf Subject: [PATCH v6 25/27] x86: efi: Don't use the 64-bit link script for the EFI app Date: Fri, 17 Dec 2021 12:40:57 -0700 Message-Id: <20211217124039.v6.25.I457b0dce49eb718fa49be2583f8ea506beddb93c@changeid> X-Mailer: git-send-email 2.34.1.173.g76aa8bc2d0-goog In-Reply-To: <20211217194059.858580-1-sjg@chromium.org> References: <20211217194059.858580-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 at phobos.denx.de X-Virus-Status: Clean That script is not intended for use with EFI, so update the logic to avoid using it. Signed-off-by: Simon Glass --- (no changes since v5) Changes in v5: - Add new patch to avoid using the 64-bit link script for the EFI app arch/x86/cpu/config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/cpu/config.mk b/arch/x86/cpu/config.mk index d3033b41603..87e242a2065 100644 --- a/arch/x86/cpu/config.mk +++ b/arch/x86/cpu/config.mk @@ -9,7 +9,7 @@ LDPPFLAGS += -DRESET_VEC_LOC=$(CONFIG_RESET_VEC_LOC) LDPPFLAGS += -DSTART_16=$(CONFIG_SYS_X86_START16) ifdef CONFIG_X86_64 -ifndef CONFIG_SPL_BUILD +ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_EFI_APP),) LDSCRIPT = $(srctree)/arch/x86/cpu/u-boot-64.lds endif endif From patchwork Fri Dec 17 19:40:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1570329 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=TF+M/0PL; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JFzwz5jwbz9sXM for ; Sat, 18 Dec 2021 06:45:39 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 946AB8380A; Fri, 17 Dec 2021 20:43:26 +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="TF+M/0PL"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 35C1683762; Fri, 17 Dec 2021 20:42:02 +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.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) (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 E508D8378C for ; Fri, 17 Dec 2021 20:41:40 +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-io1-xd2d.google.com with SMTP id p65so4527343iof.3 for ; Fri, 17 Dec 2021 11:41:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0yGLmd50DR2EHwsByw7zicPn3mG3EanLr+dGq3ty8h0=; b=TF+M/0PLzSpNEX0UO6tvqZuaWCvILAbrK6dDKL2RLSc1NOQdGkEdHnFZBtNIMS3N3Q HUOBVvnll6S3linkbcYu+JcE2hUL75wMTZebL0Ze7chO+wPCfFhfErDBZtHiTzL3UTMZ ba+hccRBqZCC1ahMsj7ekPz/zyHvRrAcxD4ps= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0yGLmd50DR2EHwsByw7zicPn3mG3EanLr+dGq3ty8h0=; b=BSZUIFIe50AUhS1ZDYR3ll+ZFm+O4nuzJxSLZeyNu/i+wPz+IFNYV+36/5K/8l59sr RR/b/YgqsT48/pnZ7QH7hvp5PsASH9k7GK4/u7paZJYfv5cpjvLJgjiU5onI8U2DJhuC b1/vtGPHHwTKKlK2Avkx/eJ0C+0i/f4H1PY5/PypvWeH/VLfhSbQtbrIvZap5ktoLlby m937I+SPn8+ATHPNnryZRfE7/Q7e7VfJzCf+FKTm1CVUY/FUO45QZvr8Sn3nJ8+xhsEk gtzBN5Gw8uHeeSxN19sAJsUqIKAudXm4HKef2Ii+Kmj+nGhFOQRceb3JLdCVK3HXKP+V 6YLA== X-Gm-Message-State: AOAM533mKihJomHtta8IIk7ZiPe+QVMVC8UZAyac1d5nf/P93HR5MaKp hVtQAvz0ldNcuArzXKJt67qjFX1wnJoe8w== X-Google-Smtp-Source: ABdhPJz37SAhJffVjM32GBTeg1MdYwePhq5bUSLAZh1xw03jfIw0h9DisB4tLBZ5auBpMRdtwNk6aA== X-Received: by 2002:a05:6638:1926:: with SMTP id p38mr2971381jal.165.1639770099617; Fri, 17 Dec 2021 11:41:39 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id w19sm6079605iov.12.2021.12.17.11.41.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Dec 2021 11:41:39 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Heinrich Schuchardt , Tom Rini , Ilias Apalodimas , Christian Melki , Simon Glass , Alexander Graf Subject: [PATCH v6 26/27] x86: efi: Set the correct link flags for the 64-bit EFI app Date: Fri, 17 Dec 2021 12:40:58 -0700 Message-Id: <20211217124039.v6.26.Id52316b4a3898ba8dff4c085a2c320173e7b35ea@changeid> X-Mailer: git-send-email 2.34.1.173.g76aa8bc2d0-goog In-Reply-To: <20211217194059.858580-1-sjg@chromium.org> References: <20211217194059.858580-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 at phobos.denx.de X-Virus-Status: Clean At present some 32-bit settings are used with the 64-bit app. Fix this by separating out the two cases. Be careful not to break the 64-bit payload, which needs to build a 64-bit EFI stub with a 32-bit U-Boot. Signed-off-by: Simon Glass --- (no changes since v5) Changes in v5: - Add new patch to set the correct link flags for the 64-bit EFI app arch/x86/config.mk | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/arch/x86/config.mk b/arch/x86/config.mk index 589f2aed2bc..889497b6bd7 100644 --- a/arch/x86/config.mk +++ b/arch/x86/config.mk @@ -20,6 +20,11 @@ IS_32BIT := y endif endif +EFI_IS_32BIT := $(IS_32BIT) +ifdef CONFIG_EFI_STUB_64BIT +EFI_IS_32BIT := +endif + ifeq ($(IS_32BIT),y) PLATFORM_CPPFLAGS += -march=i386 -m32 else @@ -44,8 +49,14 @@ CFLAGS_EFI := -fpic -fshort-wchar # Compiler flags to be removed when building UEFI applications CFLAGS_NON_EFI := -mregparm=3 -fstack-protector-strong -ifeq ($(CONFIG_EFI_STUB_64BIT),) +ifeq ($(IS_32BIT),y) +EFIPAYLOAD_BFDARCH = i386 +else CFLAGS_EFI += $(call cc-option, -mno-red-zone) +EFIPAYLOAD_BFDARCH = x86_64 +endif + +ifeq ($(EFI_IS_32BIT),y) EFIARCH = ia32 EFIPAYLOAD_BFDTARGET = elf32-i386 else @@ -53,8 +64,6 @@ EFIARCH = x86_64 EFIPAYLOAD_BFDTARGET = elf64-x86-64 endif -EFIPAYLOAD_BFDARCH = i386 - LDSCRIPT_EFI := $(srctree)/arch/x86/lib/elf_$(EFIARCH)_efi.lds EFISTUB := crt0_$(EFIARCH)_efi.o reloc_$(EFIARCH)_efi.o OBJCOPYFLAGS_EFI += --target=efi-app-$(EFIARCH) From patchwork Fri Dec 17 19:40:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1570328 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=aM/FRa1Q; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JFzwn0kBCz9sXM for ; Sat, 18 Dec 2021 06:45:29 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DD49083801; Fri, 17 Dec 2021 20:43:23 +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="aM/FRa1Q"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3667C83769; Fri, 17 Dec 2021 20:42:05 +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.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) (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 9F6B183759 for ; Fri, 17 Dec 2021 20:41: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-il1-x131.google.com with SMTP id w1so2466696ilh.9 for ; Fri, 17 Dec 2021 11:41:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iIXc6K2l9LOzThTVxI0UsxKh99q+Zs95GeKUzITFluQ=; b=aM/FRa1Q3t4wdyMj6qB/iEd2gF3oqZCg+59dF/UGL37trl3LySxetiyqa4hln8XO7J NtYlNlpuaKn48T5hwH14jUWepNorNx4ioieSbDdw58kPTggMBUO49V9QUkySq0vdgbFV +NE44jOEMIk1rEufWPGp/9Ej0fisqCOuEtJl0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iIXc6K2l9LOzThTVxI0UsxKh99q+Zs95GeKUzITFluQ=; b=ISpucmTMWGmgca7LioMc2ndyOBtcZaHE95uvv0XnWmuam4NwukscfYFXq/LiaDhqBv wbhvrlWlYKQ1wueRUMpuKEVT9G9qNnzk0VYLD0cJYllSReNZ6SYd7ySdiFQpFRCDJ7Dk zC+ec1mB6mxxm5bVw27Orz8QH+dRk38T6D6MveM26aO9ZjG3pnVPPr9FpJ7FBFbSTZX6 3fu4XAMmF0ufxef+XDhvkcJmyuJC4nMyQtZBlxYL5Wi59OU91xrfd6z7byvcFzku6XoT wYvBv1kju29gG+1XpS+UjRODz4mGy9fXQky2xclZGwA+2ho/lebn0+hWeo9T8cMtK8Zc j8ew== X-Gm-Message-State: AOAM5314KEXCXhDg7iVJZHQpQUcDVatKSUY6hReI44i88hzHw+xs+1FK MRiCzozddxOLltbnVLtpIMNSTGu6fhhOAA== X-Google-Smtp-Source: ABdhPJyeLnmLk5mhlBqOIH1jUXUBSxfmqzKCUmIqUpLBrdYIS3uKmnUtoV4cdoLssCI1HIy6zg0TKA== X-Received: by 2002:a92:3606:: with SMTP id d6mr2430250ila.186.1639770100314; Fri, 17 Dec 2021 11:41:40 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id w19sm6079605iov.12.2021.12.17.11.41.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Dec 2021 11:41:40 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Heinrich Schuchardt , Tom Rini , Ilias Apalodimas , Christian Melki , Simon Glass , Alexander Graf Subject: [PATCH v6 27/27] efi: Build the 64-bit app properly Date: Fri, 17 Dec 2021 12:40:59 -0700 Message-Id: <20211217124039.v6.27.I4eec28bb290377e1e7fe1085dac1c20ca3e3a93d@changeid> X-Mailer: git-send-email 2.34.1.173.g76aa8bc2d0-goog In-Reply-To: <20211217194059.858580-1-sjg@chromium.org> References: <20211217194059.858580-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 at phobos.denx.de X-Virus-Status: Clean Now that the linker crash is resolved, build the 64-bit EFI app, including all the required code. Signed-off-by: Simon Glass --- (no changes since v5) Changes in v5: - Add new patch to build the 64-bit app properly - Add various patches to fix up the 64-bit app so that it boots Changes in v2: - Add new patch to support the efi command in the app Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 18fe6fdb440..83f2e04c225 100644 --- a/Makefile +++ b/Makefile @@ -1772,9 +1772,9 @@ else quiet_cmd_u-boot__ ?= LD $@ cmd_u-boot__ ?= $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_u-boot) -o $@ \ -T u-boot.lds $(u-boot-init) \ - $(if $(CONFIG_EFI_APP_64BIT),,--whole-archive) \ + --whole-archive \ $(u-boot-main) \ - $(if $(CONFIG_EFI_APP_64BIT),,--no-whole-archive) \ + --no-whole-archive \ $(PLATFORM_LIBS) -Map u-boot.map; \ $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) endif