From patchwork Thu Feb 27 11:15:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 868952 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:1561:b0:38f:210b:807b with SMTP id 1csp207571wrz; Thu, 27 Feb 2025 03:15:55 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXW7ax6YGMX7RxU342VlOcOtav7oXROD6VY2N/k4GJsW4dbMXJITrAPmiXUuZLkaISII8213w==@linaro.org X-Google-Smtp-Source: AGHT+IG032WxmMQHbcQXQOcuFf1LuOc8y6n5ULLyGOK9GaKUVre4fgpUM3Cln1OB46LQqGdbFVOe X-Received: by 2002:a17:907:7d89:b0:ab7:d6c:5781 with SMTP id a640c23a62f3a-abc0da36233mr3174868266b.24.1740654955246; Thu, 27 Feb 2025 03:15:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1740654955; cv=none; d=google.com; s=arc-20240605; b=Y+JehglTfalCrNT4GRm/9WUu8QJSCJuocjKMFOPuU6POtHV+1WU/bXNeQToTnvNwxY YHSk8+a+eopz+AB6Mh25PVIXxVUbnEh/XSCXzatBzqxnScNez7Ol6dOwQQAvdP9y+Mln Q465nNd84dVMqMbGciRAIgU4GeKSInJyP6gw3+AR+FdkgwodE6kLqkcHbU2EMkbUBgXh z+vgbJTyP6CAT1Vdc4i3kFXYQQ+gEF7VA6Vqqo0GW50u7rKFaKI4zHFVjdNz/IenSyz5 SomADSUY/ytpmPsZqeYT2XeyI5CL16GzwltgQNomnoK5U4fL0s/bhttJVJYsHjuPI80F vjrg== 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=7OpIjRgAarf6XxdDF8beI09KCEOmBc8AeOKFA/eMa6w=; fh=ncKX6Psppa2mA/qi0jSiZhkst8cqIKIl8luKo8HO7JM=; b=IFp9uti91tb9FIZj5bD298/c3Yan3QlBgRklgd8zO0+S9KK0Je3Q8ozYyDF97DLhFS BK+EKUFptv+iav3VYvlaSeYFJfR4egMO3fSZ+GA9IqB7l6pw8pVhD9CMtsGJhYWntx6q StNzJUKqWGCkQTaBgtw9RIisG5n8Jvo3b4I4wzDFroVaonlnzxMeXKnI4QDxp8sgR2Mg b/XnLdpUMyv/ohKX5lJcpyLvRkVoaDQEFJNurq0A6cymuH0NG5w/p3ov6FrTLq+yHjbA bjShTgZPbe8jAmP7S0VzDPSDSIyHsITyXEbF/fP18sNKDELgPdZ/jLIdZtRJtKC0F4x7 C8yA==; 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-abf0c0b7866si141517766b.57.2025.02.27.03.15.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Feb 2025 03:15:55 -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 A2431811B2; Thu, 27 Feb 2025 12:15:49 +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 E830D811B2; Thu, 27 Feb 2025 12:15:48 +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 0CBB180FF0 for ; Thu, 27 Feb 2025 12:15:46 +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 0B85D2BCC; Thu, 27 Feb 2025 03:16:01 -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 62AC33F6A8; Thu, 27 Feb 2025 03:15:42 -0800 (PST) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Simon Glass , Tom Rini , Heinrich Schuchardt , Anton Antonov , Tobias Waldekranz , Bin Meng , Masahisa Kojima , Sughosh Ganu Subject: [PATCH v5 1/6] fdt: add support for adding pmem nodes Date: Thu, 27 Feb 2025 16:45:14 +0530 Message-Id: <20250227111519.45787-2-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250227111519.45787-1-sughosh.ganu@linaro.org> References: <20250227111519.45787-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 Reviewed-by: Ilias Apalodimas --- Changes since V4: 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 Thu Feb 27 11:15:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 868953 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:1561:b0:38f:210b:807b with SMTP id 1csp207625wrz; Thu, 27 Feb 2025 03:16:03 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUI/94XADhql+jGCmN85fV1qbxqgf/BA4WmoCAcD+6ufGoQxLK+2hVLPmyaUShJ4Uuu30GguA==@linaro.org X-Google-Smtp-Source: AGHT+IF9L+aQVHL6SKJVwQbOjv101rFotwd7mabyV86QMElG+yKzuL1pO0rXIMEBHEb/kY96GZrG X-Received: by 2002:a05:6402:2116:b0:5dc:74f1:8a31 with SMTP id 4fb4d7f45d1cf-5e4a0dfc952mr8853143a12.26.1740654963234; Thu, 27 Feb 2025 03:16:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1740654963; cv=none; d=google.com; s=arc-20240605; b=cah++WNtKHh1gU7OggpYJCWDFjREGu5jafp7BTNwO2dheCCQSF3SeZa+wOa7E4E6eg TbE7616l/d4nFmsyglzZSNr5B6xIic9yuySQJkStJuE29mwXNL0L3tmjk1UYvyVuxD0i sz4V27qngHNH51NhmXC8fDaIKMnGXGbpzbTApJh9X4M91lSQcjcpJv0UxFqRCf8cPcAy jk4g9Z8rM4l1UHX2a8DM6xTG1bDndY9Q1Pn71yvrw4BhU83ZEdLQnJhW1/t7KtsRMjWf cPkdtsbRM2jRGemcorxSD9IxWCRIscgaBBiD09KBZn0wAeuthFvi2SpeoROIede1poio cUGQ== 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=mFwWWQ7khXYseogPy8Cpx21142wB2VHFf4MFnFpDoLM=; fh=lgWTzqvGRhDnolX3HZp7xT5Ay2YCUf5TPbyImzyOM5c=; b=FNkqNoVe1u3qkxtk/0dOP1g28fuVBOtn2ZErHVEPJfWV4K9i/V1WtzAwuxYwDkwU6V YN0C3QP7qUUtt+knsUSg+5A0fCE6bTq69Ok27U9ByNUgh3d8l0eFHmsOyRf/dVXe7nUM +Fp/QwJRP8hckJ5eFbc/FKGHmEc/PM4cQP0l/imFIJwNhDGabC6CFLjPuGfO8ciWzEyP zE1kNoVh30BR7Mvez95rplJRWIbfygZs9Bor8ynB5Rh6xSi+T9zesTdCdPRyVJaAdJAp sryjF14eU36vJTjrDZmSKC+0XE7vqbBHEg9hgELCfucCbi41kS3a8uClzB/FI5TUIWaZ 1wrQ==; 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 4fb4d7f45d1cf-5e4c44ca4e7si1446978a12.537.2025.02.27.03.16.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Feb 2025 03:16:03 -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 0784A8123D; Thu, 27 Feb 2025 12:15: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 DFFF18118A; Thu, 27 Feb 2025 12:15:51 +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 8A84480FF0 for ; Thu, 27 Feb 2025 12:15:49 +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 9A3432BCC; Thu, 27 Feb 2025 03:16:04 -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 F1E203F6A8; Thu, 27 Feb 2025 03:15:45 -0800 (PST) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Simon Glass , Tom Rini , Heinrich Schuchardt , Anton Antonov , Tobias Waldekranz , Bin Meng , Heinrich Schuchardt , Sughosh Ganu Subject: [PATCH v5 2/6] efi_loader: add a function to remove memory from the EFI map Date: Thu, 27 Feb 2025 16:45:15 +0530 Message-Id: <20250227111519.45787-3-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250227111519.45787-1-sughosh.ganu@linaro.org> References: <20250227111519.45787-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 Reviewed-by: Heinrich Schuchardt Signed-off-by: Sughosh Ganu --- Changes since V4: * Rebase patch changes on top of the next branch 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 1d75d97ebbc..0ac00911598 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -852,6 +852,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 Thu Feb 27 11:15:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 868954 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:1561:b0:38f:210b:807b with SMTP id 1csp207678wrz; Thu, 27 Feb 2025 03:16:11 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUd2nO2dWJJ2rmbKXFJXAnROGE1K+QTZWhFAkv8u/9ac/OMxDdi5s3kv67JcFb9Tn26Bd9hKQ==@linaro.org X-Google-Smtp-Source: AGHT+IG1lcUv6LtxgnWoj+EXrahyP2aYIvAjvZTLQhgNrpeokAEp6eXzIid2oWAjxCYLbhEKPYnY X-Received: by 2002:a05:6000:1a85:b0:38d:d759:3dea with SMTP id ffacd0b85a97d-38f707a6294mr18215084f8f.26.1740654971412; Thu, 27 Feb 2025 03:16:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1740654971; cv=none; d=google.com; s=arc-20240605; b=J2qx6Rue6xA9rO43BKcgpKoLzQ4ORnhB6eM2FItbpFU7E68225OWTLZYCVLsn/Pf4R +MyTFUxqozsdX/rOkeFKI90GJNFj4o5T707+caBDk7CCddsE2GBgl3y/K7ylr4CGCFYm qOZLFbUNsJYtOctU1pOHbrof0oofYbQXoMwVOP/xKSncekJZGcArHqCBS/C5stWC6JGe RIAKlE7j2isdiB9lTJuirXrjkgjzcniWB+ZpKjYm8168yc4Y7PdUsHMqk1eow1H6nl1x /2Y6yaWx8nq/+qmLG2UjWJo3F+y7eivD+ZOAtbwLbVH97M74Ju5QAKS6YfUyo1uMS1bo m0zw== 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=DfwSTVbUiRtUoMOAo5VdjORUCdMgQZbrCvx7f5Lbr88=; fh=WIErNPtEyr4LSk0kn+FyUcnvc47vQRNxykSeJQzwMAA=; b=bYPSIVuwniD3YS0HIxjDRQxi63QGfr73cs1cbPoQbxOQNB3L9AnD6P3ZMGVSfW6dqP XTACgHMJl+gMvYxJBIUyoGvCeUpoAO7QjF+aSHoxDz/XPDucNWmjq7XoOupig9VObiSc NAJgtmW2mokNG+Hn4ch+NIMNTR6dfSLtfPb3cJjEJmcvOPgtZI1a5XxjLbtvr7XINbA1 kSaw3i/Kk3M44IrWKfwGBMgcgLoh1xspw5PcBQLVGLX7LnhvuHRweiH7Afk7zb0iVVBN mDdLxQJhIuMZlhV4p0BZ2Hao7lstHduEKDO7UAp9QcLcGIkQI/SuTV/F1crY+4fN3D/W fuCw==; 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 ffacd0b85a97d-390e4858af2si837449f8f.895.2025.02.27.03.16.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Feb 2025 03:16:11 -0800 (PST) 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 4FABF81219; Thu, 27 Feb 2025 12:15:56 +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 35102811E0; Thu, 27 Feb 2025 12:15: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=-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 E401B8118A for ; Thu, 27 Feb 2025 12:15:52 +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 EAAC22BCC; Thu, 27 Feb 2025 03:16:07 -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 8C7563F6A8; Thu, 27 Feb 2025 03:15:49 -0800 (PST) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Simon Glass , Tom Rini , Heinrich Schuchardt , Anton Antonov , Tobias Waldekranz , Bin Meng , Sughosh Ganu Subject: [PATCH v5 3/6] efi_loader: preserve installer images in pmem Date: Thu, 27 Feb 2025 16:45:16 +0530 Message-Id: <20250227111519.45787-4-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250227111519.45787-1-sughosh.ganu@linaro.org> References: <20250227111519.45787-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 V4: 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 Thu Feb 27 11:15: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: 868955 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:1561:b0:38f:210b:807b with SMTP id 1csp207712wrz; Thu, 27 Feb 2025 03:16:19 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCX+tArhM5d+i2CetA3qx1Wj7svCDGSMPCDf+xlyQBgZydttwH5ovkuP7HD+SBEBi24qFzrmxg==@linaro.org X-Google-Smtp-Source: AGHT+IHaltFvNUNGb1fDSsdlNQamn1P5E54aXyColMKchKEV+SBy0MHqMX6z9n7IAcwNj8shLaG3 X-Received: by 2002:a05:6000:1845:b0:390:d82d:6d4f with SMTP id ffacd0b85a97d-390d82d71cemr5600612f8f.52.1740654979386; Thu, 27 Feb 2025 03:16:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1740654979; cv=none; d=google.com; s=arc-20240605; b=ciZ1bVhDMYDJs2OBQ1c/u1eqwbITC+hF/CH6UUtSaSPE+RwFmtkcpF1OmdTkKbnbQU WWlK0EZTxl/PhqnL6kbv4ZU1EQkuCMSVst3jdf69cNrYHmHRTe82cDYD4p8Z1qJ0l9PU R2RcaFOaWAeLVEuXmXvGje0e2NNq3H78RN70/Hy7xSXDvklvulnMU5o+bR0k5J5nFDj/ DNgskqHqKxkKq0tAi5FkUJ3lJYCMGDfdMtE5GK/+sfUs10egdmEO+uAURdQFV+DTrPzk 868hOH+cR/pqgPmtWpeuXakqfEeth7Jggiln+OTpbWw7g1CCCnlt8lihuImQF0PaYWKj 5nvQ== 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=ApZSLZqpYKrrEinDzztBnELkhkg+KB2CbSebOyjdXO4=; fh=WIErNPtEyr4LSk0kn+FyUcnvc47vQRNxykSeJQzwMAA=; b=YGBEjv9wWdAee1Nh+psayEiFZrzRC0HCjiwQQ92osdYEZqQtVbXYAw3fMteU5i28M4 iOKpztz/TWckUsXztnVQel0JstM5ZYougC6YLCmh/1n3cNNBApADMJSGzsDCINo9xzWb L2QQp8yhkHUGZ9UyYWz0IeVjnCXI4IepqNXuG6VMc7da0ck+MyX1F5NJYSCCPaQfXMXR lcoNL/Yj3UqbVuBfPU5PAsykMk3BivIkB4eWovIP1eV0kLudU8PU6fDijZGinc4G4qPa TYSNp/H21yvWwrpsjC3e2aq1JKQw3haKU1a2wv/F//eLDEg/h7+TCGclXdntbgJZZrhG RGMw==; 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 ffacd0b85a97d-390e4797976si894348f8f.166.2025.02.27.03.16.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Feb 2025 03:16:19 -0800 (PST) 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 A2336812BB; Thu, 27 Feb 2025 12:15: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 467D5812BB; Thu, 27 Feb 2025 12:15:58 +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 3683B8118A for ; Thu, 27 Feb 2025 12:15: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 470362BCC; Thu, 27 Feb 2025 03:16:11 -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 DD00D3F6A8; Thu, 27 Feb 2025 03:15:52 -0800 (PST) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Simon Glass , Tom Rini , Heinrich Schuchardt , Anton Antonov , Tobias Waldekranz , Bin Meng , Sughosh Ganu Subject: [PATCH v5 4/6] blkmap: store type of blkmap slice in corresponding structure Date: Thu, 27 Feb 2025 16:45:17 +0530 Message-Id: <20250227111519.45787-5-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250227111519.45787-1-sughosh.ganu@linaro.org> References: <20250227111519.45787-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 --- Changes since V4: * Use BIT() based macros instead of enum * Change the name of the field from type to attr as it would contain attributes other than the type of the slice 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 Thu Feb 27 11:15: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: 868956 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:1561:b0:38f:210b:807b with SMTP id 1csp207763wrz; Thu, 27 Feb 2025 03:16:28 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUw174pNugNF1cbsFOq4Zry5oA85UVpCW2KhWG/zUiSWwZgBlKg43u162E+bI79nvpXtMdi2Q==@linaro.org X-Google-Smtp-Source: AGHT+IGvsEsLn+i/AFg1vFwd+D1rTVWYyAPmkoy5nAdEgB+0Klds/y1zUhey+3p3IYmQFkLlZ5fP X-Received: by 2002:a05:6402:50d3:b0:5e0:87eb:956b with SMTP id 4fb4d7f45d1cf-5e0b722348bmr27896084a12.22.1740654988182; Thu, 27 Feb 2025 03:16:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1740654988; cv=none; d=google.com; s=arc-20240605; b=WI3hihnoK6y/GbVxjhNKEfl+f0jJf1XnTgDRM2MEwGKG8ENb7FVpp0oPgJM3O6EsNg vDwHImK1vcu54WZgalnP+PmDp8GDonXU1MVkP5QoTx+56DcbqKo4hm1w1RbFON0dLkX7 Sw/LFPmn3xkvjKg0JsXL9GFgTJ4Lvlk07oWRyEAGmU2BqtJE0a85nLd9IOPUmzjjIY5y jJOk/KfSLgXAxor6W1C5SAJ5XomTqu/Km/Ku43/23mjJUsYx1tyU4r2KYFDW5lKyWhF6 5M+Ywk5Ziigf1vOyovVI8Oz75pUpJ2kvNf7TqE/FlKLLA+kUJup+NOG2Mc+6nKvqDM58 B0qA== 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=eMOT2IP72xyM7JWSbZc669glo5+4hA0Dj3xxorM8ks4=; fh=WIErNPtEyr4LSk0kn+FyUcnvc47vQRNxykSeJQzwMAA=; b=iS5aEgDPLGWSkmutHCZPnVw6MGCrhqgaNpaG7hN4XWJ2IOfEDXz0/h5pMl4HieKoG0 mCfG/rJpjRht/nVl8TrMoqYLqEHL8Xi7bmUtVtaCUYD9qhiYd+ju0IGaW7Le+Bv+QwTt 2oTNOHLvqVpPEmOk8IAPaC9FrKXumnRUooB9+fsFFc7XZSiKyz3MWxpHT04WFjNbJdwd rIVpXOiSLFbIuIjCJn5kgiKRIye9cxnnkkRAiiV9XIxrCBojQJcQ6ZMKiyrNRbY391Pl b6C8s0BSrDNte6B7xAuTMF7Yyub37yUwRrhOqN7tGQNYWy8FVFjKkrFHOqeOu2QTOVIA gZXQ==; 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 4fb4d7f45d1cf-5e4c3b6130fsi1436552a12.32.2025.02.27.03.16.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Feb 2025 03:16:28 -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 F087F8128D; Thu, 27 Feb 2025 12:16: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 DDA56811E0; Thu, 27 Feb 2025 12:16:01 +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 88CCC812C0 for ; Thu, 27 Feb 2025 12:15: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 97FE42BCC; Thu, 27 Feb 2025 03:16:14 -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 3932C3F6A8; Thu, 27 Feb 2025 03:15:55 -0800 (PST) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Simon Glass , Tom Rini , Heinrich Schuchardt , Anton Antonov , Tobias Waldekranz , Bin Meng , Sughosh Ganu Subject: [PATCH v5 5/6] blkmap: add an attribute to preserve the mem mapping Date: Thu, 27 Feb 2025 16:45:18 +0530 Message-Id: <20250227111519.45787-6-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250227111519.45787-1-sughosh.ganu@linaro.org> References: <20250227111519.45787-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 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 --- Changes since V4: New patch 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