From patchwork Fri Oct 25 11:14:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 838338 Delivered-To: patch@linaro.org Received: by 2002:adf:e287:0:b0:37d:45d0:187 with SMTP id v7csp210906wri; Fri, 25 Oct 2024 04:15:53 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUFu+8I353nd3Qzo0yJLk9k3xO4jJrTgCViUEc9Rct6zAYDIQrsTYUkZe0QGBbrqlDhzU13cg==@linaro.org X-Google-Smtp-Source: AGHT+IF2Ygl2l1ZyzcLTR2QjvtfDoDsofHH2yirM82+U6uxl38eUB8OxoxHopksucDGDxO+nYOtF X-Received: by 2002:a05:6512:31cd:b0:539:edbe:ac86 with SMTP id 2adb3069b0e04-53b23dde45cmr3543114e87.10.1729854953639; Fri, 25 Oct 2024 04:15:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729854953; cv=none; d=google.com; s=arc-20240605; b=Cxg5/LgQGoYU6Mlk9BoMeML4GRdzoYRIf08dC1ignTI4iMXDApdRKrPiVmLWDeL3cZ sJwZfsHbXQEEaGi9rvLtxhSCo66q0SdMfTGqhblfmPAWwBszD4iz2XByY0TauFT1pScK S30F9a3b4CO9AvYR7UQd3T+Tp0ixPWHn4BZ87KyAVUCALjvTHJPoMKDSifbMIpmPEE9M txm5U5hdOJEBdzF3YV2PbuAalQUv6Kdoyhxs/BzT3wMYRrMAw1FSNyyGXre8RI0bRjZm Fyqx+CgawzqgiozcxoGq3+qGfoX89JAPCIOG+TPwulYlVluzWxNSirjFAGqfN3GvNtYf e2cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=Tm+eRBNyRsfLEf5ySiN01WtiIPPkERntHl+7958ngkg=; fh=u6ljpCS4uZ/kj1Y8Zoinr3YBaBeaYO7JTxZPQgvPhM8=; b=goonU6tNWGxDE2nXPG7G/QtZ4Ixv/xRI5y2AKLoQQSN/rYqaTtsNuudqvXi1F/nv4+ AwjWbap3lSoGCqbeGwswavQ5Cg+5GLbZ9x0koxcgRtqChMGfd2ceFQgE56ED8dCMRTZ/ w/iTiw4RK3S+cAuRBr3NMpxy+2B/cdLYfOtyjCysfv/gtZwxYm/+Nb1jHi4mA4J3+LK0 QmVcVVcey1xcGqic3WdbnoBFVZnTDRZsLw9ACYk6mwfCynWzRhLjACaNxFNPo605E+dZ iA28ZwRZcb8tiORsav3OjiN4wLOfT1g0FaXfcC5l3TY8xnlDt2wUKAHXZFlME1WZzaYm WUAQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id 2adb3069b0e04-53b2e1b082bsi366823e87.252.2024.10.25.04.15.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 04:15:53 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6BDFD88F94; Fri, 25 Oct 2024 13:15:13 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 44BAC88F94; Fri, 25 Oct 2024 13:15:12 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE,T_SPF_TEMPERROR autolearn=ham autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 807EB88BEF for ; Fri, 25 Oct 2024 13:14:57 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9EA83339; Fri, 25 Oct 2024 04:15:26 -0700 (PDT) Received: from a079122.blr.arm.com (a079122.arm.com [10.162.17.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1014D3F73B; Fri, 25 Oct 2024 04:14:54 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Tom Rini , Sughosh Ganu Subject: [PATCH 4/4] efi: add helper functions to insert pmem node for DT fixup Date: Fri, 25 Oct 2024 16:44:11 +0530 Message-Id: <20241025111411.165904-5-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241025111411.165904-1-sughosh.ganu@linaro.org> References: <20241025111411.165904-1-sughosh.ganu@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean The EFI HTTP boot puts the iso installer image at some location in memory which needs to be reserved in the devicetree as persistent memory (pmem). Add helper functions which add this pmem node when the EFI_DT_FIXUP protocol's fixup callback is invoked. Signed-off-by: Sughosh Ganu --- boot/image-fdt.c | 9 +++++++++ include/efi_loader.h | 17 +++++++++++++++++ lib/efi_loader/efi_bootmgr.c | 21 +++++++++++++++++++++ lib/efi_loader/efi_helper.c | 12 ++++++++++++ 4 files changed, 59 insertions(+) diff --git a/boot/image-fdt.c b/boot/image-fdt.c index 8eda521693..b39e81ad30 100644 --- a/boot/image-fdt.c +++ b/boot/image-fdt.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -648,6 +649,14 @@ int image_setup_libfdt(struct bootm_headers *images, void *blob, bool lmb) if (!ft_verify_fdt(blob)) goto err; + if (CONFIG_IS_ENABLED(EFI_HTTP_BOOT)) { + fdt_ret = fdt_efi_pmem_setup(blob); + if (fdt_ret) { + printf("ERROR: HTTP boot pmem fixup failed\n"); + goto err; + } + } + /* after here we are using a livetree */ if (!of_live_active() && CONFIG_IS_ENABLED(EVENT)) { struct event_ft_fixup fixup; diff --git a/include/efi_loader.h b/include/efi_loader.h index d450e304c6..031de18746 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -748,6 +748,15 @@ bool efi_varname_is_load_option(u16 *var_name16, int *index); efi_status_t efi_next_variable_name(efi_uintn_t *size, u16 **buf, efi_guid_t *guid); +/** + * fdt_efi_pmem_setup() - Setup the pmem node in the devicetree + * + * @fdt: Pointer to the devicetree + * + * Return: 0 on success, negative on failure + */ +int fdt_efi_pmem_setup(void *fdt); + /** * efi_size_in_pages() - convert size in bytes to size in pages * @@ -964,6 +973,14 @@ efi_status_t efi_set_load_options(efi_handle_t handle, void *load_options); efi_status_t efi_bootmgr_load(efi_handle_t *handle, void **load_options); +/** + * efi_bootmgr_pmem_setup() - Put a pmem node for UEFI HTTP installers + * + * @fdt: Pointer to the DT blob + * Return: status code + */ +efi_status_t efi_bootmgr_pmem_setup(void *fdt); + /** * struct efi_image_regions - A list of memory regions * diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c index 16f75555f6..1d9246be61 100644 --- a/lib/efi_loader/efi_bootmgr.c +++ b/lib/efi_loader/efi_bootmgr.c @@ -41,6 +41,8 @@ struct uridp_context { efi_handle_t mem_handle; }; +static struct uridp_context *uctx; + const efi_guid_t efi_guid_bootmenu_auto_generated = EFICONFIG_AUTO_GENERATED_ENTRY_GUID; @@ -423,6 +425,7 @@ efi_status_t efi_bootmgr_release_uridp(struct uridp_context *ctx) efi_free_pool(ctx->loaded_dp); free(ctx); + uctx = NULL; return ret == EFI_SUCCESS ? ret2 : ret; } @@ -443,6 +446,23 @@ static void EFIAPI efi_bootmgr_http_return(struct efi_event *event, EFI_EXIT(ret); } +/** + * efi_bootmgr_pmem_setup() - Put a pmem node for UEFI HTTP installers + * + * @fdt: Pointer to the DT blob + * Return: status code + */ +efi_status_t efi_bootmgr_pmem_setup(void *fdt) +{ + if (!uctx) { + log_warning("No EFI HTTP boot context found\n"); + return EFI_SUCCESS; + } + + return !fdt_fixup_pmem_region(fdt, uctx->image_addr, uctx->image_size) ? + EFI_SUCCESS : EFI_INVALID_PARAMETER; +} + /** * try_load_from_uri_path() - Handle the URI device path * @@ -472,6 +492,7 @@ static efi_status_t try_load_from_uri_path(struct efi_device_path_uri *uridp, if (!ctx) return EFI_OUT_OF_RESOURCES; + uctx = ctx; s = env_get("loadaddr"); if (!s) { log_err("Error: loadaddr is not set\n"); diff --git a/lib/efi_loader/efi_helper.c b/lib/efi_loader/efi_helper.c index 00167bd2a1..33cd8b9a50 100644 --- a/lib/efi_loader/efi_helper.c +++ b/lib/efi_loader/efi_helper.c @@ -242,6 +242,18 @@ int efi_unlink_dev(efi_handle_t handle) return 0; } +/** + * fdt_efi_pmem_setup() - Setup the pmem node in the devicetree + * + * @fdt: Pointer to the devicetree + * + * Return: 0 on success, negative on failure + */ +int fdt_efi_pmem_setup(void *fdt) +{ + return efi_bootmgr_pmem_setup(fdt) == EFI_SUCCESS ? 0 : -1; +} + static int u16_tohex(u16 c) { if (c >= '0' && c <= '9')