From patchwork Tue Dec 3 16:36:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 846967 Delivered-To: patch@linaro.org Received: by 2002:a5d:44cd:0:b0:385:e875:8a9e with SMTP id z13csp595803wrr; Tue, 3 Dec 2024 08:36:52 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVDpRBeZ7EO7H7zYBOcs4vrwbLG6Q2Hm89t2L3vQEP/CfGsImQrC63DTkCCcon4NRFcYYDwqA==@linaro.org X-Google-Smtp-Source: AGHT+IFWl/NyjYdJYJK9JZMbwt7BDSGJIghEyyUyuH98Z4tlaSXot8pL+gMs+oE7ASYaOskIc/5M X-Received: by 2002:a05:6512:1387:b0:53d:d0f0:ad0d with SMTP id 2adb3069b0e04-53e12a21851mr1803655e87.46.1733243812024; Tue, 03 Dec 2024 08:36:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733243811; cv=none; d=google.com; s=arc-20240605; b=Lb2aRTZYPzKGuxzsbMrmvgCL+iZuPWTAxbmgIgBqTz5q9xqcrzaKtdYP+fUkFWr4ls xrSRHoMO30YLbCJr1AcHtGDJfFRdBxiTnr77dKa839omOxtSplVbL63HW8zLKiEQc61u k7qsumh6mRVlBvkdvnVHweL0B6lw8CFxjiayWdcpjkM85s55r4exgB/c+0l7yy1YniGk L0/uxJdzwIkL/1Lyc0bWOvzvShkoKbhQZKdYWX9uls8k8o4+RiU64M3WMqeYq3Q/76Qg FEp9pGdmZowATXwJjLEfYZBppnM8BvotovRlkejZQrPW1gu9ABpl/EOx+fKimChoqaP6 vSVw== 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=Ecda4JxLib6wLH7IRs6FUKkU4y5/3veBJDyjIucVhBE=; fh=rPmMTArAbwoOFNVFb2co+289VhVVNzBHoPR9c3uaLKo=; b=b3lzZqC8i/lfeG0FSn1M0b/10m1P8V958jnFwy81zYh/TKjkap+CS71sR6oTnVBYoB 42PF3LEZO0bE4BaFHi64PcclQuMPPKS5DRU6bKDIgbNfczLCSlcqWtupPtoniOtTIqOi lHLmquqXYSP8EujO4NKG56swlDJ+D/jHIma7Rj9R43YiXojAIY58Oc+iDUir2Bde3T7B k/a7tb956Bw8x0ryJAL8H7jd/Z3H7fepEJUHXEbzBrfuhYbcRm8YGgYVKsbz5PhYG2+F +9GEQrroYOyOqLvspC5/C2akXPlJZurDyp4m7JStxwCT81OwgxXBuSTZzUfPDN1Lo74N S9Dg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id a640c23a62f3a-aa5998e5f10si893056166b.370.2024.12.03.08.36.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2024 08:36:51 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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 C8BC889677; Tue, 3 Dec 2024 17:36:32 +0100 (CET) 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 E4D1489651; Tue, 3 Dec 2024 17:36:30 +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=-1.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no 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 A2AEA893A9 for ; Tue, 3 Dec 2024 17:36:28 +0100 (CET) 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 0DC70143D; Tue, 3 Dec 2024 08:36:56 -0800 (PST) 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 B3EDC3F71E; Tue, 3 Dec 2024 08:36:25 -0800 (PST) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Masahisa Kojima , Anton Antonov , Tom Rini , Sughosh Ganu Subject: [PATCH v2 4/4] efi: add helper functions to insert pmem node for DT fixup Date: Tue, 3 Dec 2024 22:06:05 +0530 Message-Id: <20241203163605.1482152-5-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241203163605.1482152-1-sughosh.ganu@linaro.org> References: <20241203163605.1482152-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 --- Changes since V1: * Use log_err() to print the error message in image_setup_libfdt() * Remove "ERROR:" from the error print in image_setup_libfdt() 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 3d5b6f9e2dc..de479d3ffa0 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) { + log_err("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 24e40799eee..87b9a6e4da0 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 b906e53e26e..db4eb6a7376 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; @@ -427,6 +429,7 @@ static 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; } @@ -447,6 +450,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 * @@ -476,6 +496,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 bf96f61d3d0..6fae37ad617 100644 --- a/lib/efi_loader/efi_helper.c +++ b/lib/efi_loader/efi_helper.c @@ -313,6 +313,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')