From patchwork Wed Mar 12 08:54:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 872818 Delivered-To: patch@linaro.org Received: by 2002:a5d:64e7:0:b0:38f:210b:807b with SMTP id g7csp158505wri; Wed, 12 Mar 2025 01:55:02 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW6CoQi5YiUXpsVomwKQCRM6tmqGr28GX/sHminXBUvkzjc74eYrJ+JO4cJAjZHZeWZtipVaA==@linaro.org X-Google-Smtp-Source: AGHT+IHUY/MsTrgjTAV+2jxB0EUbqsKBlvKl1ktp08YUKkT1PCjciHf0qoaVV+UwsXAnQEhR3mVa X-Received: by 2002:a05:690c:3384:b0:6fd:485c:9dd4 with SMTP id 00721157ae682-6febf3e06abmr294787157b3.32.1741769702091; Wed, 12 Mar 2025 01:55:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1741769702; cv=none; d=google.com; s=arc-20240605; b=BxhlCzuqJG0UjklVTXwVkmxDDKtOi5oz1kCaLaIah9cLrj8+O6cUShKlJDFNDdSU8E l42vGA9Q5WQ0Atu7do1DKfywHIoashAktV0aq1eV442xoVeumBO0GOff8OwqvW4YMmeY OO+kLiA7Kpu3qghJe5Vdc+y3PXTjcMmq/PEAKOY+zYNSb4uxll/0chZnGBbL96RCPmsI WTDbGZwBt5BUWt0sslo+L4qRxeuOylewjHhz3smhT/ZGG2EXGbdbJfv+Q7W3XQGOSOJu hNd9SlT2KxLwbGfh/esNz7Me6IFVzmxy2yENVgNAWaCJR25Auh4lQ5l5IaoBq3LM7Y+Z 1fHA== 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=V+zbAAi6hQmW/Woy+Hy7CXUWrIzZ12DjcG4NyvPX5oQ=; fh=Evn5eBx2ytD/hj+tB8Xv1T61prWYrP0E59LRKWAPORI=; b=JGXIfsin+FkeZ0+RvFogu4NE2oyYHs5Gv9Hz7rbRlQ10DeKlr7Rg+UdD7Hops+7LDN UC7cMteXWG2PTsFDVqyx3q/ldI2S46ATPIL3v/Vgh2vPKjiu9YauY75O94qNnIvbFX6F inXlcynF/1Kzk/mjuew720+4nP1EFHTCIy9OisorVHvgaEU3VjXOBiwnDaCmUEcFgbxD 0/ZqqJChhUp2aqxU61NeracCO9WtIoQbXm2p3ORZZQvT5xvT6AHMfGGoYNOplCpg2dRZ UArVjAKRoJKSwe+cy1kj3HZ+yW7WdxW8L8vu80aU+HLiWQxGxPXFpne5AMnOda2wlYPE Ct+w==; 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 00721157ae682-6fecd2a091fsi83481597b3.184.2025.03.12.01.55.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Mar 2025 01:55:02 -0700 (PDT) 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 8BF66817A5; Wed, 12 Mar 2025 09:54:53 +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 CB802801FB; Wed, 12 Mar 2025 09:54: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=-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 4B25980FB9 for ; Wed, 12 Mar 2025 09:54:50 +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 55C07152B; Wed, 12 Mar 2025 01:55:00 -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 F2AF23F5A1; Wed, 12 Mar 2025 01:54:46 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Simon Glass , Tom Rini , Heinrich Schuchardt , Anton Antonov , Tobias Waldekranz , Sughosh Ganu Subject: [PATCH v8 1/8] efi_loader: remove unused code from copy_fdt() Date: Wed, 12 Mar 2025 14:24:17 +0530 Message-Id: <20250312085424.1201148-2-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250312085424.1201148-1-sughosh.ganu@linaro.org> References: <20250312085424.1201148-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 There is logic in the copy_fdt() function which is iterating over the platform's DRAM banks and setting the fdt_ram_start variable. However, this variable is not used subsequently in the function. Remove this superfluous code. Signed-off-by: Sughosh Ganu Reviewed-by: Ilias Apalodimas Reviewed-by: Heinrich Schuchardt --- Changes since V7: None lib/efi_loader/efi_helper.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/lib/efi_loader/efi_helper.c b/lib/efi_loader/efi_helper.c index 04b2efc4a3b..15ad042bc61 100644 --- a/lib/efi_loader/efi_helper.c +++ b/lib/efi_loader/efi_helper.c @@ -454,23 +454,11 @@ efi_status_t efi_env_set_load_options(efi_handle_t handle, */ static efi_status_t copy_fdt(void **fdtp) { - unsigned long fdt_ram_start = -1L, fdt_pages; + unsigned long fdt_pages; efi_status_t ret = 0; void *fdt, *new_fdt; u64 new_fdt_addr; uint fdt_size; - int i; - - for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { - u64 ram_start = gd->bd->bi_dram[i].start; - u64 ram_size = gd->bd->bi_dram[i].size; - - if (!ram_size) - continue; - - if (ram_start < fdt_ram_start) - fdt_ram_start = ram_start; - } /* * Give us at least 12 KiB of breathing room in case the device tree From patchwork Wed Mar 12 08:54:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 872819 Delivered-To: patch@linaro.org Received: by 2002:a5d:64e7:0:b0:38f:210b:807b with SMTP id g7csp158610wri; Wed, 12 Mar 2025 01:55:12 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUJh+AsDaiMG6TQi3xqW1KCoJBJVqLfWB6senlh8IGMyG+fHO0gjkpabSsVq5pGsyTJruJeLg==@linaro.org X-Google-Smtp-Source: AGHT+IGasp7Vz466gDe2pI+iIpDONuNszn/ZWR7IwHrBAv2Hf//RQFPN6PKo2aF5xIwWIxHuaKPA X-Received: by 2002:a05:690c:6502:b0:6fd:1d9c:bd6a with SMTP id 00721157ae682-6ff091ab2fbmr85120007b3.3.1741769712253; Wed, 12 Mar 2025 01:55:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1741769712; cv=none; d=google.com; s=arc-20240605; b=WAx5uAeMrvPRymnq03kXcK0bj4qfvocsa70UuBNeuBKMOWIEXngeWUM4fR/4eLSah4 etPqMfJwqhmUakkzfbPkIv3jXM9+0tof6F2wMgLKexeo8VvctRlxdfVwY3gfPMyRi3v2 7sbKoWZIk+uSbKCIpn5A0s4ybhDjF8sMDLwpKYpbedotBO93QhGqvNcw7u0nop5XbaBN KjrGfCyzZk6wdhX9g2PFz025AaVFhIlZ8OSS2VJCOR9wo1rQGIwVMCOxY/HHxRyZkUCm CsgXOgpYY8hLYPmBo9uieebk7A5Aa9e33SYcwbKNYpVh9FMFBsVchf/pAKAgFKyW1km4 rvag== 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=rjhhGsOve/9mOhtFPuLfNvZNpBLVz4X5DOyMc+XXD/M=; fh=Evn5eBx2ytD/hj+tB8Xv1T61prWYrP0E59LRKWAPORI=; b=F6ha9ki+CuHvCTvYKJCwQu2dwvEOcrsnLn7obfVvRbCYms4Yv6voMAfdZ8IRa/Joks TU/TdYJNefF3urJbsPC2MC6L02FsYm1MiSGydANPz07RXlJZyqOPsDdzQi2sEGT3wWm7 gWvR1m9cJ+9soKYcIwal7CraT4KaOfpUzKz1SsrzjKgeqO2TQO9r6PUSlnnv0Gkj5BgO FpUmQLyYYzNwG5NZK5vBoUkYl6kqQyvMVr6vwOp3X1EexUeeiPeu7olhhGckX8IqBi2G NsGrNLvsjkYSMbFwzKZSXmFpGST4hq+EHgYeA5xQ2GBdoMi1dfM6m8/ekWffoXjfEAHv aQ/w==; 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 00721157ae682-6febbfcf564si94778227b3.0.2025.03.12.01.55.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Mar 2025 01:55:12 -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 0390E8197D; Wed, 12 Mar 2025 09:54:58 +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 426B0818C7; Wed, 12 Mar 2025 09:54: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=-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 327E5801FB for ; Wed, 12 Mar 2025 09:54:53 +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 6B94A152B; Wed, 12 Mar 2025 01:55:03 -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 145FA3F5A1; Wed, 12 Mar 2025 01:54:49 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Simon Glass , Tom Rini , Heinrich Schuchardt , Anton Antonov , Tobias Waldekranz , Sughosh Ganu Subject: [PATCH v8 2/8] efi_loader: install device-tree on configuration table on every invocation Date: Wed, 12 Mar 2025 14:24:18 +0530 Message-Id: <20250312085424.1201148-3-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250312085424.1201148-1-sughosh.ganu@linaro.org> References: <20250312085424.1201148-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_install_fdt() function is called before booting an EFI binary, either directly, or through a bootmanager. This function installs a copy of the device-tree(DT) on the EFI configuration table, which is passed on to the OS. The current logic in this function does not install a DT if the table already has a DT installed on it. However, this existing copy of the DT might not be up-to-date, or it could be a wrong DT for the image that is being booted. Always install a DT afresh to the configuration table before booting the EFI binary. Installing a new DT also involves some additional checks that are needed to clean up memory associated with the existing DT copy. Check for an existing copy, and free up that memory. Signed-off-by: Sughosh Ganu --- Changes since V7: * Change the type of fdt_pages to efi_uintn_t * Remove the check for either of fdt_pages or new_fdt_addr being 0 * Change the format specifier for fdt_pages in the debug messages for size_t * Put the assignment of new_fdt_addr and fdt_pages on separate lines to avoid checkpatch error lib/efi_loader/efi_helper.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/lib/efi_loader/efi_helper.c b/lib/efi_loader/efi_helper.c index 15ad042bc61..37e5859741f 100644 --- a/lib/efi_loader/efi_helper.c +++ b/lib/efi_loader/efi_helper.c @@ -454,11 +454,21 @@ efi_status_t efi_env_set_load_options(efi_handle_t handle, */ static efi_status_t copy_fdt(void **fdtp) { - unsigned long fdt_pages; efi_status_t ret = 0; void *fdt, *new_fdt; - u64 new_fdt_addr; - uint fdt_size; + static u64 new_fdt_addr; + static efi_uintn_t fdt_pages; + ulong fdt_size; + + if (new_fdt_addr) { + log_debug("%s: Found allocated memory at %#llx, with %#zx pages\n", + __func__, new_fdt_addr, fdt_pages); + ret = efi_free_pages(new_fdt_addr, fdt_pages); + if (ret != EFI_SUCCESS) { + log_err("Unable to free up existing FDT memory region\n"); + return ret; + } + } /* * Give us at least 12 KiB of breathing room in case the device tree @@ -472,16 +482,21 @@ static efi_status_t copy_fdt(void **fdtp) EFI_ACPI_RECLAIM_MEMORY, fdt_pages, &new_fdt_addr); if (ret != EFI_SUCCESS) { + new_fdt_addr = 0; + fdt_pages = 0; log_err("Failed to reserve space for FDT\n"); - goto done; + return ret; } + log_debug("%s: Allocated memory at %#llx, with %#zx pages\n", + __func__, new_fdt_addr, fdt_pages); + new_fdt = (void *)(uintptr_t)new_fdt_addr; memcpy(new_fdt, fdt, fdt_totalsize(fdt)); fdt_set_totalsize(new_fdt, fdt_size); - *fdtp = (void *)(uintptr_t)new_fdt_addr; -done: - return ret; + *fdtp = new_fdt; + + return EFI_SUCCESS; } /** @@ -534,9 +549,6 @@ efi_status_t efi_install_fdt(void *fdt) const char *fdt_opt; uintptr_t fdt_addr; - /* Look for device tree that is already installed */ - if (efi_get_configuration_table(&efi_guid_fdt)) - return EFI_SUCCESS; /* Check if there is a hardware device tree */ fdt_opt = env_get("fdt_addr"); /* Use our own device tree as fallback */ From patchwork Wed Mar 12 08:54:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 872820 Delivered-To: patch@linaro.org Received: by 2002:a5d:64e7:0:b0:38f:210b:807b with SMTP id g7csp158841wri; Wed, 12 Mar 2025 01:55:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUY65bBRjzZ0ZcLYtSqaqquiLoyTO0L6XN4jx8e6DWsUBZ2OIaCGMS+EviVOhOZQi12UtiZkg==@linaro.org X-Google-Smtp-Source: AGHT+IG5RebWjTQELRWAmhOZ7g9BnCXeQ5DOs7Ul3oQZpV2UqlRXsfWB8y5/pXUJFdGCZ/MEji8n X-Received: by 2002:a25:53c2:0:b0:e63:6b79:5b15 with SMTP id 3f1490d57ef6-e636b795d65mr17990274276.7.1741769720928; Wed, 12 Mar 2025 01:55:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1741769720; cv=none; d=google.com; s=arc-20240605; b=Da+4L82nZpU8NtJc3mKHIjj+7pnEO3RPnjT+r8GZnBgg12Dm9khJQlrlEvGzsWX9b2 rLi5j7SFkIu0nA76ielN6Gyw1IBUZ5TpiNwYQzQgF3mxPtaa1pkzM+9A/qnBuz9x1Dac rDPj0mE+1iAeOSRizfSXE0EPk6K8KSxRgwq3kzQeBbNsaNqiwUUENRqjrfD31E4Lu4zd 6iaKvtOhdFR1qnSIK1BpNv1T23EQjKSQih469TJrOTx0o4QuA3sIeAWM6xIK0Ufr1J8T uWSCAuJaRqNUGPiOydKwBZ4aRyqe47eDxSaAt664SUdQyVVeEpOc4qk2fJht3p+UmOWU 9JQg== 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=BeuVOhzZGPk/jk50FTxIyaNGM1C38wPZ9iPRn9A4Sf4=; fh=ky/3EXJ4V9VcIMC2RiXGMLRKI2lBbfUuCc6cZ3L4Gic=; b=Bg5bmvZp+T04NYX5nxcqj5CQTT+Jg7DDY5Rx4/maNToeq/GZO2BMvD8DJs5kpru00d xFHSEeN9qPEj23h1ZVfwGsglwf6Wt2F1YG3OEhwJDj1F5rpsdU60cdnEtqnPgKZqAmmJ ZdhttWWAQXH9/pghnPOUfO+hrv/l5Owtw3tagBPUnxiUOpCZpaaBSdvJxSmiPTEzXXCd DXto8zpHmpBcdKJ/DE8pWEXVLppJUttQHMybhdTV0aYwubIwvf1rdMkHpuY/w1grJQB3 kG1OAmyISqlxKWtspGn+aqkuxhmoVsYywoCMNi8bgn9RnarcxzkouCZzdvXpnXY9jtqK A+iQ==; 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 3f1490d57ef6-e634b8b8a02si11326498276.290.2025.03.12.01.55.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Mar 2025 01:55:20 -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 58A198141D; Wed, 12 Mar 2025 09:55:00 +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 3346A805D7; Wed, 12 Mar 2025 09:54:59 +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 8F4A380756 for ; Wed, 12 Mar 2025 09:54:56 +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 C0F4B1688; Wed, 12 Mar 2025 01:55:06 -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 2B2123F5A1; Wed, 12 Mar 2025 01:54:52 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Simon Glass , Tom Rini , Heinrich Schuchardt , Anton Antonov , Tobias Waldekranz , Masahisa Kojima , Sughosh Ganu Subject: [PATCH v8 3/8] fdt: add support for adding pmem nodes Date: Wed, 12 Mar 2025 14:24:19 +0530 Message-Id: <20250312085424.1201148-4-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250312085424.1201148-1-sughosh.ganu@linaro.org> References: <20250312085424.1201148-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 From: Masahisa Kojima One of the problems OS installers face, when running in EFI, is that the mounted ISO after calling ExitBootServices goes away. For some distros this is a problem since they rely on finding some core packages before continuing the installation. Distros have works around this -- e.g Fedora has a special kernel command line parameter called inst.stage2 [0]. ACPI has NFIT and NVDIMM support to provide ramdisks to the OS, but we don't have anything in place for DTs. Linux and device trees have support for persistent memory devices. So add a function that can inject a pmem node in a DT, so we can use it when launhing OS installers with EFI. [0] https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/7/html/installation_guide/chap-anaconda-boot-options#sect-boot-options-installer Signed-off-by: Masahisa Kojima Signed-off-by: Sughosh Ganu --- Changes since V7: None boot/fdt_support.c | 41 ++++++++++++++++++++++++++++++++++++++++- include/fdt_support.h | 14 ++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/boot/fdt_support.c b/boot/fdt_support.c index 49efeec3681..e20b9759138 100644 --- a/boot/fdt_support.c +++ b/boot/fdt_support.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -464,7 +465,6 @@ void do_fixup_by_compat_u32(void *fdt, const char *compat, do_fixup_by_compat(fdt, compat, prop, &tmp, 4, create); } -#ifdef CONFIG_ARCH_FIXUP_FDT_MEMORY /* * fdt_pack_reg - pack address and size array into the "reg"-suitable stream */ @@ -493,6 +493,7 @@ static int fdt_pack_reg(const void *fdt, void *buf, u64 *address, u64 *size, return p - (char *)buf; } +#ifdef CONFIG_ARCH_FIXUP_FDT_MEMORY #if CONFIG_NR_DRAM_BANKS > 4 #define MEMORY_BANKS_MAX CONFIG_NR_DRAM_BANKS #else @@ -2222,3 +2223,41 @@ int fdt_valid(struct fdt_header **blobp) } return 1; } + +int fdt_fixup_pmem_region(void *blob, ulong addr, u32 size) +{ + u64 pmem_start[2] = { 0 }; + u64 pmem_size[2] = { 0 }; + char pmem_node[32] = {0}; + int nodeoffset, len; + int err; + u8 tmp[4 * 16]; /* Up to 64-bit address + 64-bit size */ + + if (!IS_ALIGNED(addr, SZ_2M) || !IS_ALIGNED(addr + size, SZ_2M)) { + printf("Start and end address must be 2MiB aligned\n"); + return -1; + } + + snprintf(pmem_node, sizeof(pmem_node), "pmem@%lx", addr); + nodeoffset = fdt_find_or_add_subnode(blob, 0, pmem_node); + if (nodeoffset < 0) + return nodeoffset; + + err = fdt_setprop_string(blob, nodeoffset, "compatible", "pmem-region"); + if (err) + return err; + err = fdt_setprop_empty(blob, nodeoffset, "volatile"); + if (err) + return err; + pmem_start[0] = addr; + pmem_size[0] = size; + len = fdt_pack_reg(blob, tmp, pmem_start, pmem_size, 1); + err = fdt_setprop(blob, nodeoffset, "reg", tmp, len); + if (err < 0) { + printf("WARNING: could not set pmem %s %s.\n", "reg", + fdt_strerror(err)); + return err; + } + + return 0; +} diff --git a/include/fdt_support.h b/include/fdt_support.h index f0ad2e6b365..b72cd2920de 100644 --- a/include/fdt_support.h +++ b/include/fdt_support.h @@ -507,4 +507,18 @@ void fdt_fixup_pstore(void *blob); */ int fdt_kaslrseed(void *blob, bool overwrite); +/** + * fdt_fixup_pmem_region() - add a pmem node on the device tree + * + * This functions adds/updates a pmem node to the device tree. + * Usually used with EFI installers to preserve installer + * images + * + * @blob: device tree provided by caller + * @addr: start address of the pmem node + * @size: size of the memory of the pmem node + * Return: 0 on success or < 0 on failure + */ +int fdt_fixup_pmem_region(void *blob, ulong addr, u32 size); + #endif /* ifndef __FDT_SUPPORT_H */ From patchwork Wed Mar 12 08:54:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 872821 Delivered-To: patch@linaro.org Received: by 2002:a5d:64e7:0:b0:38f:210b:807b with SMTP id g7csp159085wri; Wed, 12 Mar 2025 01:55:30 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUa/gWh7o5ZxBn/NyjdUkVSjYejVZyn3qJX61JAJ/h5BiaJopyw4WgYL3RLanSNHRTRTwD1aA==@linaro.org X-Google-Smtp-Source: AGHT+IFLriZSkL+RA7oa6+XPEPUpq4tLaSYbtoAJLzNqMs8Ctp9ZT0yuUD39J2bYQqV+2J2TWYso X-Received: by 2002:a05:690c:3804:b0:6f9:af1f:fdd0 with SMTP id 00721157ae682-6ff092b2cfemr96392037b3.31.1741769730501; Wed, 12 Mar 2025 01:55:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1741769730; cv=none; d=google.com; s=arc-20240605; b=XBIF6JeHnQWrSTJ9y4C8wDQEclM8HjJ5Jn4SMyfmEZwVoklf9OxUs7QmGnUcFdiLga LdhOvzIPSlf/MDVpXrPD/H6wY/9LWEZj0d7cBaOF6S7hgNXWnhWFa2zPYXAcenNHN7wT c9GaaXRcur4PSTVdMagnFrN8iUQTCRo6+8tikK0hg4eyXNQsfqsi8SII9hM5ccBEDo3i HGR9zWefmFdcw7cmGj5HHbOqBK3VyrrxEWRo6c2nhtYX2SqijEbT9OMOrLKiDSTPDUJs SpuWGeZAYL3sKDRVIWFGG9hMBSG8zKa6HuZM9dXqyWc6WEOzOSjuGFThiknH3LqAhkGA TqQQ== 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=wR/gf+unWEbDyhzGjMCCWen8SUvEj9L5Vm/5z0go74A=; fh=bRtumU9xx/JRtTnNsnMvlgvziP9v+DkFMfKqzGFksOo=; b=OWGFw4gY45rzBNVywbIWjNXmmZvZPQpnAfdECRZ/nLKOn8gjbgwjK0QLT4dvcfDP9F XvTsC3WmUR1rrtFTBeKieOzcrtgcnDfBF8XjXn7qBCGGh7XncbLvZJz+VB502RhRnH+W aStvZd//u0DUFMfTZg16uLaN/hHZy3jfgMFZ9kXM+DjqqO9lHcLE5UtYUZobKGNXqN0V N7YhIDjKXL+eafPTDjR05E+Mm1ARvdjJiwxwx+uwkFQnqDDL3c+dnP/nL14Gn9ubMiAo Rlqrg/+W3zh4caKRp//Mup0NYFZmOwWcSsXgerF7a+R0RaYZPvQWRIOHGyGP1Q5Wy7H7 Cxcg==; 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 00721157ae682-6ff1cf1c408si10834737b3.458.2025.03.12.01.55.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Mar 2025 01:55:30 -0700 (PDT) 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 A3E4A81898; Wed, 12 Mar 2025 09:55:03 +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 3019C818C7; Wed, 12 Mar 2025 09:55: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=-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 D48EE805D7 for ; Wed, 12 Mar 2025 09:54:59 +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 22BE8152B; Wed, 12 Mar 2025 01:55:10 -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 809163F5A1; Wed, 12 Mar 2025 01:54:56 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Simon Glass , Tom Rini , Heinrich Schuchardt , Anton Antonov , Tobias Waldekranz , Sughosh Ganu , Heinrich Schuchardt Subject: [PATCH v8 4/8] efi_loader: add a function to remove memory from the EFI map Date: Wed, 12 Mar 2025 14:24:20 +0530 Message-Id: <20250312085424.1201148-5-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250312085424.1201148-1-sughosh.ganu@linaro.org> References: <20250312085424.1201148-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 From: Ilias Apalodimas With upcoming changes supporting pmem nodes, we need to remove the pmem area from the EFI memory map. Add a function to do that. Signed-off-by: Ilias Apalodimas Signed-off-by: Sughosh Ganu Reviewed-by: Heinrich Schuchardt --- Changes since V7: None include/efi_loader.h | 18 ++++++++++++ lib/efi_loader/efi_memory.c | 56 ++++++++++++++++++++++++++----------- 2 files changed, 58 insertions(+), 16 deletions(-) diff --git a/include/efi_loader.h b/include/efi_loader.h index e9c10819ba2..c20c98c6476 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -878,6 +878,24 @@ efi_status_t efi_get_memory_map(efi_uintn_t *memory_map_size, /* Adds a range into the EFI memory map */ efi_status_t efi_add_memory_map(u64 start, u64 size, int memory_type); +/** + * efi_update_memory_map() - update the memory map by adding/removing pages + * + * @start: start address, must be a multiple of + * EFI_PAGE_SIZE + * @pages: number of pages to add + * @memory_type: type of memory added + * @overlap_conventional: region may only overlap free(conventional) + * memory + * @remove: remove memory map + * Return: status code + */ +efi_status_t efi_update_memory_map(u64 start, u64 pages, int memory_type, + bool overlap_conventional, bool remove); + +/* Remove memory from the EFI memory map */ +efi_status_t efi_remove_memory_map(u64 start, u64 size, int memory_type); + /* Called by board init to initialize the EFI drivers */ efi_status_t efi_driver_init(void); /* Called when a block device is added */ diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index 6d00b186250..3fec40b6de5 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -258,7 +258,7 @@ static s64 efi_mem_carve_out(struct efi_mem_list *map, } /** - * efi_add_memory_map_pg() - add pages to the memory map + * efi_update_memory_map() - update the memory map by adding/removing pages * * @start: start address, must be a multiple of * EFI_PAGE_SIZE @@ -266,12 +266,11 @@ static s64 efi_mem_carve_out(struct efi_mem_list *map, * @memory_type: type of memory added * @overlap_conventional: region may only overlap free(conventional) * memory + * @remove: remove memory map * Return: status code */ -static -efi_status_t efi_add_memory_map_pg(u64 start, u64 pages, - int memory_type, - bool overlap_conventional) +efi_status_t efi_update_memory_map(u64 start, u64 pages, int memory_type, + bool overlap_conventional, bool remove) { struct efi_mem_list *lmem; struct efi_mem_list *newlist; @@ -279,9 +278,9 @@ efi_status_t efi_add_memory_map_pg(u64 start, u64 pages, uint64_t carved_pages = 0; struct efi_event *evt; - EFI_PRINT("%s: 0x%llx 0x%llx %d %s\n", __func__, + EFI_PRINT("%s: 0x%llx 0x%llx %d %s %s\n", __func__, start, pages, memory_type, overlap_conventional ? - "yes" : "no"); + "yes" : "no", remove ? "remove" : "add"); if (memory_type >= EFI_MAX_MEMORY_TYPE) return EFI_INVALID_PARAMETER; @@ -364,7 +363,10 @@ efi_status_t efi_add_memory_map_pg(u64 start, u64 pages, } /* Add our new map */ - list_add_tail(&newlist->link, &efi_mem); + if (!remove) + list_add_tail(&newlist->link, &efi_mem); + else + free(newlist); /* And make sure memory is listed in descending order */ efi_mem_sort(); @@ -401,7 +403,29 @@ efi_status_t efi_add_memory_map(u64 start, u64 size, int memory_type) pages = efi_size_in_pages(size + (start & EFI_PAGE_MASK)); start &= ~EFI_PAGE_MASK; - return efi_add_memory_map_pg(start, pages, memory_type, false); + return efi_update_memory_map(start, pages, memory_type, false, false); +} + +/** + * efi_remove_memory_map() - remove memory area to the memory map + * + * @start: start address of the memory area + * @size: length in bytes of the memory area + * @memory_type: type of memory removed + * + * Return: status code + * + * This function automatically aligns the start and size of the memory area + * to EFI_PAGE_SIZE. + */ +efi_status_t efi_remove_memory_map(u64 start, u64 size, int memory_type) +{ + u64 pages; + + pages = efi_size_in_pages(size + (start & EFI_PAGE_MASK)); + start &= ~EFI_PAGE_MASK; + + return efi_update_memory_map(start, pages, memory_type, false, true); } /** @@ -502,7 +526,7 @@ efi_status_t efi_allocate_pages(enum efi_allocate_type type, efi_addr = (u64)(uintptr_t)map_sysmem(addr, 0); /* Reserve that map in our memory maps */ - ret = efi_add_memory_map_pg(efi_addr, pages, memory_type, true); + ret = efi_update_memory_map(efi_addr, pages, memory_type, true, false); if (ret != EFI_SUCCESS) { /* Map would overlap, bail out */ lmb_free_flags(addr, (u64)pages << EFI_PAGE_SHIFT, flags); @@ -823,8 +847,8 @@ static void add_u_boot_and_runtime(void) uboot_stack_size) & ~EFI_PAGE_MASK; uboot_pages = ((uintptr_t)map_sysmem(gd->ram_top - 1, 0) - uboot_start + EFI_PAGE_MASK) >> EFI_PAGE_SHIFT; - efi_add_memory_map_pg(uboot_start, uboot_pages, EFI_BOOT_SERVICES_CODE, - false); + efi_update_memory_map(uboot_start, uboot_pages, EFI_BOOT_SERVICES_CODE, + false, false); #if defined(__aarch64__) /* * Runtime Services must be 64KiB aligned according to the @@ -842,8 +866,8 @@ static void add_u_boot_and_runtime(void) runtime_end = (uintptr_t)__efi_runtime_stop; runtime_end = (runtime_end + runtime_mask) & ~runtime_mask; runtime_pages = (runtime_end - runtime_start) >> EFI_PAGE_SHIFT; - efi_add_memory_map_pg(runtime_start, runtime_pages, - EFI_RUNTIME_SERVICES_CODE, false); + efi_update_memory_map(runtime_start, runtime_pages, + EFI_RUNTIME_SERVICES_CODE, false, false); } int efi_memory_init(void) @@ -878,11 +902,11 @@ int efi_map_update_notify(phys_addr_t addr, phys_size_t size, pages = efi_size_in_pages(size + (efi_addr & EFI_PAGE_MASK)); efi_addr &= ~EFI_PAGE_MASK; - status = efi_add_memory_map_pg(efi_addr, pages, + status = efi_update_memory_map(efi_addr, pages, op == LMB_MAP_OP_RESERVE ? EFI_BOOT_SERVICES_DATA : EFI_CONVENTIONAL_MEMORY, - false); + false, false); if (status != EFI_SUCCESS) { log_err("LMB Map notify failure %lu\n", status & ~EFI_ERROR_MASK); From patchwork Wed Mar 12 08:54:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 872822 Delivered-To: patch@linaro.org Received: by 2002:a5d:64e7:0:b0:38f:210b:807b with SMTP id g7csp159366wri; Wed, 12 Mar 2025 01:55:41 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVawsXNV4379g6gvwiFRdueoWTcQ0QiktC0DMnqJdCjebqSOcaUotXH5LHHhEPdH4u3O3h6kg==@linaro.org X-Google-Smtp-Source: AGHT+IEf/8ZmhT/9wdvTpR7F0Ag+gwjTV6bMKeTcn+eMqzu+FZIHUF//yJmvj4kjLvH01Dd8/CAS X-Received: by 2002:a05:690c:650a:b0:6f9:50aa:b7e2 with SMTP id 00721157ae682-6febf3220f4mr308563317b3.21.1741769740788; Wed, 12 Mar 2025 01:55:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1741769740; cv=none; d=google.com; s=arc-20240605; b=Zx8/VAJcGl7uAT2aXMHDpDxlr0UTZCjxpRYZQgxC+2lV4l+md4FdcoLSKeuk9IRQZE NX3hAZi3Iq3U0SaxKLNbq5JtEsbyMa0TEERlNE/eqlmvFKxPTpcBNSoLaK0143vQrHlo PB44rdt5/WXQ/lqvM4oQOfe/cLjQbISVytOGt4w6bIs7QMQqygyIRPHX4kpfMGM8VPNd 0DvO/ZEnRHfDgvIt4IZJQ7fbsSYaqOWA2bSW+KAxObx6EziOoO6UXzKstS/KhuK9MSoV FQ5UdpenEhyIzTxvlSRA+yA45XhokEJMaFcv2dvxrlOTB2INIl/k/ukfTeaBCrmMsUsL 3Pzw== 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=8PBg36dVe+e8fWxE7HDO5GBcY79WBJztGCf2MhBvWUg=; fh=Evn5eBx2ytD/hj+tB8Xv1T61prWYrP0E59LRKWAPORI=; b=eZ9li+a7BuPe2/oQzA94+s9/9ArFg27D3THtIYd54jsTkAhd02jlYyNIUWuzjA0jdy Uc3M7AV/T/3jMk+JJlyiBSGX1/X0E9D40u+PYfI44tELONduJYPuCxSWK47TUC3Nwwky I5R2VFxzI2XlHFk8/QmknBJoLTS6r/dIt942QAHEvvGSJRNcpbRgiKuRbN1U9HenS7pD 7CGvdutzV7L5FrY/L/jA6acHYsZtL6d4DBXjPDFObIhuifBKqpZdASOfQ6gKnB0T8LVM KtQCDskEAYLI/v8LunhgQMZpAQlDh2qKPZoSBICOVuiDA93Gr/IEJBmreRNKIkyDRWT3 LLTw==; 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 00721157ae682-6fec637af96si80661577b3.384.2025.03.12.01.55.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Mar 2025 01:55:40 -0700 (PDT) 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 ECE0081A0C; Wed, 12 Mar 2025 09:55:06 +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 40E51805D7; Wed, 12 Mar 2025 09:55: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=-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 00635805D7 for ; Wed, 12 Mar 2025 09:55:02 +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 39623152B; Wed, 12 Mar 2025 01:55:13 -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 D6D703F5A1; Wed, 12 Mar 2025 01:54:59 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Simon Glass , Tom Rini , Heinrich Schuchardt , Anton Antonov , Tobias Waldekranz , Sughosh Ganu Subject: [PATCH v8 5/8] efi_loader: preserve installer images in pmem Date: Wed, 12 Mar 2025 14:24:21 +0530 Message-Id: <20250312085424.1201148-6-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250312085424.1201148-1-sughosh.ganu@linaro.org> References: <20250312085424.1201148-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 From: Ilias Apalodimas One of the problems OS installers face, when running in EFI, is that the mounted ISO after calling ExitBootServices goes away. For some distros this is a problem since they rely on finding some core packages before continuing the installation. Distros have works around this -- e.g Fedora has a special kernel command line parameter called inst.stage2 [0]. ACPI has NFIT and NVDIMM support to provide ramdisks to the OS, but we don't have anything in place for DTs. Linux and device trees have support for persistent memory devices. It's worth noting that for linux to instantiate the /dev/pmemX device, the memory described in the pmem node has to be omitted from the EFI memory map we hand over to the OS if ZONE_DEVICES and SPARSEMEM is enabled. With those enabled the pmem driver ends up calling devm_memremap_pages() instead of devm_memremap(). The latter works whether the memory is omitted or marked as reserved, but mapping pages only works if the memory is omitted. On top of that, depending on how the kernel is configured, that memory area must be page aligned or 2MB aligned. PowerPC is an exception here and requires 16MB alignment, but since we don't have EFI support for it, limit the alignment to 2MB. Ensure that the ISO image is 2MB aligned and remove the region occupied by the image from the EFI memory map. Signed-off-by: Ilias Apalodimas Signed-off-by: Sughosh Ganu --- Changes since V7: None lib/efi_loader/efi_bootmgr.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c index c6124c590d9..081eff057f4 100644 --- a/lib/efi_loader/efi_bootmgr.c +++ b/lib/efi_loader/efi_bootmgr.c @@ -18,6 +18,8 @@ #include #include #include +#include +#include static const struct efi_boot_services *bs; static const struct efi_runtime_services *rs; @@ -362,13 +364,16 @@ static efi_status_t prepare_loaded_image(u16 *label, ulong addr, ulong size, } /* - * TODO: expose the ramdisk to OS. - * Need to pass the ramdisk information by the architecture-specific - * methods such as 'pmem' device-tree node. + * Linux supports 'pmem' which allows OS installers to find, reclaim + * the mounted images and continue the installation since the contents + * of the pmem region are treated as local media. + * + * The memory regions used for it needs to be carved out of the EFI + * memory map. */ - ret = efi_add_memory_map(addr, size, EFI_RESERVED_MEMORY_TYPE); + ret = efi_remove_memory_map(addr, size, EFI_CONVENTIONAL_MEMORY); if (ret != EFI_SUCCESS) { - log_err("Memory reservation failed\n"); + log_err("Failed to reserve memory\n"); goto err; } @@ -490,6 +495,13 @@ static efi_status_t try_load_from_uri_path(struct efi_device_path_uri *uridp, ret = EFI_INVALID_PARAMETER; goto err; } + /* + * Depending on the kernel configuration, pmem memory area must be page + * aligned or 2MB aligned. PowerPC is an exception here and requires + * 16MB alignment, but since we don't have EFI support for it, limit + * the alignment to 2MB. + */ + image_size = ALIGN(image_size, SZ_2M); /* * If the file extension is ".iso" or ".img", mount it and try to load From patchwork Wed Mar 12 08:54:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 872823 Delivered-To: patch@linaro.org Received: by 2002:a5d:64e7:0:b0:38f:210b:807b with SMTP id g7csp159644wri; Wed, 12 Mar 2025 01:55:50 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXFeLOeeqnt+t//OeBrbqAXGtpLzrGVf0pVAR50aBW1sQ5A09TjIeASlvBJiaKYDMvtEyTbtA==@linaro.org X-Google-Smtp-Source: AGHT+IH+9TuWgAhTJYOA9nzwAfkjT5jcAcc34VVgJs5JgNHf8XL7y6RaQPVZmbhex/pejGfloIHJ X-Received: by 2002:a05:6902:2308:b0:e5b:1119:60d0 with SMTP id 3f1490d57ef6-e63b521144cmr8102979276.34.1741769750492; Wed, 12 Mar 2025 01:55:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1741769750; cv=none; d=google.com; s=arc-20240605; b=czE7PzOe/pHVQ6GPIJwncxNzIyZnrYm/iMTUJ55gOzP8WZFVrc6hzeJQ0SKeqm/4y3 p3mNdy4aFAtYaIYkiyrdJrOUJy9VZxEu8mmxJ606Fp7ANx8ty2qygiYFvcJi003Q5GpM nxSZrQCBthwBVXfIhT4EfMQkjT+0L/13xlwEIhAI2wGhZ4uvThXQmIb/tgJYw6zmI/FK eUg0LhNl4zKLwQE0gRyUXLd7bineMtIebbZnxyxgANikveVzqK20nEP1+DIVSnq5LVob PvOzUAYM2DCo9REF6GAs4frWjz0ANNX5fKwdSr2N1TmsgQU3/2du1qyViZRWv/JvOqOh ljsA== 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=BNY4+Y9Qwa0ZfylKUS55yLml7GVG0fF0heh5oHpFR7k=; fh=Evn5eBx2ytD/hj+tB8Xv1T61prWYrP0E59LRKWAPORI=; b=OT14DLBflbgVq81OGDeiocvvG9ETUGginSPkddU1tSWyaDKEd7Aq6F7qZhD4Aosh/g l6ae8YeTlE0xlZYTks5yIMjWZ0rfKys/lhW+4mD9JPllUIFx5pdGNP1FVSK3Pd6ptSe3 FTBzyz9HtDJmo7ZEktCgBqZEi+dzhBsTTCq6uONaab4bHN4zQqH+gQrPOZxgBzJuqWvt lCgaSUBuQ4gOylznpFI3WFysjd25qeYzfl5qN4m3lNgnyxh52pjn+Ni+C4Zzo0WCLvfm nsZsQlQ6yo5u/IdJLvKU5YmQTV0u5p4a/GCk7T2FN+lJtJg6lm5YKqCQVrCKCiI9LrkW dRvg==; 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 3f1490d57ef6-e634b8d18c1si13261695276.369.2025.03.12.01.55.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Mar 2025 01:55:50 -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 F312C801FB; Wed, 12 Mar 2025 09:55:11 +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 9375081895; Wed, 12 Mar 2025 09:55: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=-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 0C2058169D for ; Wed, 12 Mar 2025 09:55:06 +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 4EB18152B; Wed, 12 Mar 2025 01:55:16 -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 EC17B3F5A1; Wed, 12 Mar 2025 01:55:02 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Simon Glass , Tom Rini , Heinrich Schuchardt , Anton Antonov , Tobias Waldekranz , Sughosh Ganu Subject: [PATCH v8 6/8] blkmap: store type of blkmap slice in corresponding structure Date: Wed, 12 Mar 2025 14:24:22 +0530 Message-Id: <20250312085424.1201148-7-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250312085424.1201148-1-sughosh.ganu@linaro.org> References: <20250312085424.1201148-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 Add information about the type of blkmap slice as an attribute in the corresponding slice structure. Put information in the blkmap slice structure to identify if it is associated with a memory or linear mapped device. Which can then be used to take specific action based on the type of the blkmap slice. Signed-off-by: Sughosh Ganu Reviewed-by: Tobias Waldekranz Reviewed-by: Ilias Apalodimas --- Changes since V7: None drivers/block/blkmap.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/block/blkmap.c b/drivers/block/blkmap.c index 34eed1380dc..453510cca62 100644 --- a/drivers/block/blkmap.c +++ b/drivers/block/blkmap.c @@ -16,6 +16,10 @@ struct blkmap; +/* Attributes of blkmap slice */ +#define BLKMAP_SLICE_LINEAR BIT(0) +#define BLKMAP_SLICE_MEM BIT(1) + /** * struct blkmap_slice - Region mapped to a blkmap * @@ -25,12 +29,14 @@ struct blkmap; * @node: List node used to associate this slice with a blkmap * @blknr: Start block number of the mapping * @blkcnt: Number of blocks covered by this mapping + * @attr: Attributes of blkmap slice */ struct blkmap_slice { struct list_head node; lbaint_t blknr; lbaint_t blkcnt; + uint attr; /** * @read: - Read from slice @@ -169,6 +175,7 @@ int blkmap_map_linear(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, .slice = { .blknr = blknr, .blkcnt = blkcnt, + .attr = BLKMAP_SLICE_LINEAR, .read = blkmap_linear_read, .write = blkmap_linear_write, @@ -248,6 +255,7 @@ int __blkmap_map_mem(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, .slice = { .blknr = blknr, .blkcnt = blkcnt, + .attr = BLKMAP_SLICE_MEM, .read = blkmap_mem_read, .write = blkmap_mem_write, From patchwork Wed Mar 12 08:54:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 872824 Delivered-To: patch@linaro.org Received: by 2002:a5d:64e7:0:b0:38f:210b:807b with SMTP id g7csp159881wri; Wed, 12 Mar 2025 01:56:01 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWLwfPmCS1n3TQeEFKIPe6pHMOOyNmRfII+2DraMruNpiXv0T/C0yk5JfKWreG+Kzkuh1qBcQ==@linaro.org X-Google-Smtp-Source: AGHT+IETMcAlpuqkwMMLS20XmEC2rJmw6UKZiNbnC0pQvq99WumFozwehIrX73J4z2vWDRd1dDfL X-Received: by 2002:a25:21c1:0:b0:e63:c2d2:94f2 with SMTP id 3f1490d57ef6-e63c2d2956emr2773803276.4.1741769760964; Wed, 12 Mar 2025 01:56:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1741769760; cv=none; d=google.com; s=arc-20240605; b=YFlz7D+lh+n8X4KDwUDhBEW40JrT+0axlJwcG4GwSPIiNxX4jSQMMVjS0zAgrJbigG CsyZpZ62LEoGVunbfMP40+4XW79TqvrVVxiaX5GSI7s4wzR1E2evxhjlQA/v42molt4w 9JLDZxUzSUO0MXqj4AAebDWVld9PcUAD/mllIY/R0xDZmAoVtIa3dAL5qJg67i93w2rn SztHFjIm0HMvkNF+ctmwWfRhkDhqG1XoDhPOGYq2T7H8/q5BZat4Oe6mNfeoovhO7rx+ J0cIkO6HlPskIxZ5Xnfoi+cgSTka5Fmx6/QCwt9vkhVB12ZMdzm2/OTFlL/b2qPDcMCe RSCQ== 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=swE3YrBbV3XnlWEav5TBYUHDk6bAn3eEO1kfrlIhJ5w=; fh=Evn5eBx2ytD/hj+tB8Xv1T61prWYrP0E59LRKWAPORI=; b=bIVxFKI4mM9kwgy+UKtyyKRYp8JLRqvYAee36X53gCr37MVBnYHEL3WT098zk2Zznw 5mEiz4CpjhSIGIu/LHfeHEDx+bh0E3NNcwuia//E/eSfx0QZ0yt/J4wbkngThHLTvSe9 ms8FBXIdJACOxjgjaJqqHtUMI7rt/i2NpiAbW1E2mMjhAG1PwsYuw4q4VHMvj+Cmmnb3 DsdeWWFcYH4q2JwG/7rPnx4HFzhtAKG4kaCc8z9fqIp0Chb+WWs83z2GORXqw/I26l3p OsZqaPc6j2qc5HfT+Oo56TzWw0Sym0gHPcIo7W8zotgvi/6nTewIcStonEKmxKKdTzM8 ln8g==; 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 3f1490d57ef6-e634b70f05dsi11867041276.81.2025.03.12.01.56.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Mar 2025 01:56:00 -0700 (PDT) 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 595058193A; Wed, 12 Mar 2025 09:55:14 +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 2E28C818C7; Wed, 12 Mar 2025 09:55:12 +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 2D1DF805D7 for ; Wed, 12 Mar 2025 09:55:09 +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 657DF152B; Wed, 12 Mar 2025 01:55:19 -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 0E57A3F5A1; Wed, 12 Mar 2025 01:55:05 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Simon Glass , Tom Rini , Heinrich Schuchardt , Anton Antonov , Tobias Waldekranz , Sughosh Ganu Subject: [PATCH v8 7/8] blkmap: add an attribute to preserve the mem mapping Date: Wed, 12 Mar 2025 14:24:23 +0530 Message-Id: <20250312085424.1201148-8-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250312085424.1201148-1-sughosh.ganu@linaro.org> References: <20250312085424.1201148-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 Some blkmap memory mapped devices might have to be relevant even after U-Boot passes control to the next image as part of the platform boot. An example of such a mapping would be an OS installer ISO image, information for which has to be provided to the OS kernel. Use the 'preserve' attribute for such mappings. The code for adding a pmem node to the device-tree then checks if this attribute is set, and adds a node only for mappings which have this attribute. Signed-off-by: Sughosh Ganu Reviewed-by: Tobias Waldekranz Reviewed-by: Ilias Apalodimas --- Changes since V7: * Fix repeated word in the commit message cmd/blkmap.c | 9 +++++++-- drivers/block/blkmap.c | 12 ++++++++---- drivers/block/blkmap_helper.c | 2 +- include/blkmap.h | 4 +++- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/cmd/blkmap.c b/cmd/blkmap.c index 164f80f1387..86a123b1cd3 100644 --- a/cmd/blkmap.c +++ b/cmd/blkmap.c @@ -62,13 +62,18 @@ static int do_blkmap_map_mem(struct map_ctx *ctx, int argc, char *const argv[]) { phys_addr_t addr; int err; + bool preserve = false; if (argc < 2) return CMD_RET_USAGE; addr = hextoul(argv[1], NULL); - err = blkmap_map_pmem(ctx->dev, ctx->blknr, ctx->blkcnt, addr); + if (argc == 3 && !strcmp(argv[2], "preserve")) + preserve = true; + + err = blkmap_map_pmem(ctx->dev, ctx->blknr, ctx->blkcnt, addr, + preserve); if (err) { printf("Unable to map %#llx at block 0x" LBAF ": %d\n", (unsigned long long)addr, ctx->blknr, err); @@ -221,7 +226,7 @@ U_BOOT_CMD_WITH_SUBCMDS( "blkmap create