diff --git a/Add-pmem-node-for-preserving-distro-ISO-s.patch b/Add-pmem-node-for-preserving-distro-ISO-s.patch deleted file mode 100644 index bc8620b..0000000 --- a/Add-pmem-node-for-preserving-distro-ISO-s.patch +++ /dev/null @@ -1,1288 +0,0 @@ -From patchwork Fri Feb 28 08:45:24 2025 -Content-Type: text/plain; charset="utf-8" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -X-Patchwork-Submitter: Sughosh Ganu -X-Patchwork-Id: 2053441 -X-Patchwork-Delegate: xypron.glpk@gmx.de -Return-Path: -X-Original-To: incoming@patchwork.ozlabs.org -Delivered-To: patchwork-incoming@legolas.ozlabs.org -Authentication-Results: legolas.ozlabs.org; - spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de - (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; - envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) -Received: from phobos.denx.de (phobos.denx.de - [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) - (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) - key-exchange X25519 server-signature ECDSA (secp384r1)) - (No client certificate requested) - by legolas.ozlabs.org (Postfix) with ESMTPS id 4Z41yQ5Fkdz1yKH - for ; Fri, 28 Feb 2025 19:46:06 +1100 (AEDT) -Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) - by phobos.denx.de (Postfix) with ESMTP id 2504E81100; - Fri, 28 Feb 2025 09:46:02 +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 B0BC2807D7; Fri, 28 Feb 2025 09:46:00 +0100 (CET) -X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de -X-Spam-Level: -X-Spam-Status: No, score=-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 E55D680BA4 - for ; Fri, 28 Feb 2025 09:45:57 +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 99830150C; - Fri, 28 Feb 2025 00:46:12 -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 2C1F13F673; - Fri, 28 Feb 2025 00:45:53 -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 v6 1/6] fdt: add support for adding pmem nodes -Date: Fri, 28 Feb 2025 14:15:24 +0530 -Message-Id: <20250228084529.127823-2-sughosh.ganu@linaro.org> -X-Mailer: git-send-email 2.34.1 -In-Reply-To: <20250228084529.127823-1-sughosh.ganu@linaro.org> -References: <20250228084529.127823-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 V5: 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 Fri Feb 28 08:45:25 2025 -Content-Type: text/plain; charset="utf-8" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -X-Patchwork-Submitter: Sughosh Ganu -X-Patchwork-Id: 2053442 -X-Patchwork-Delegate: xypron.glpk@gmx.de -Return-Path: -X-Original-To: incoming@patchwork.ozlabs.org -Delivered-To: patchwork-incoming@legolas.ozlabs.org -Authentication-Results: legolas.ozlabs.org; - spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de - (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; - envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) -Received: from phobos.denx.de (phobos.denx.de - [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) - (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) - key-exchange X25519 server-signature ECDSA (secp384r1)) - (No client certificate requested) - by legolas.ozlabs.org (Postfix) with ESMTPS id 4Z41yc0t0Hz1yKH - for ; Fri, 28 Feb 2025 19:46:16 +1100 (AEDT) -Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) - by phobos.denx.de (Postfix) with ESMTP id 70EA880BA4; - Fri, 28 Feb 2025 09:46: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 7E3C9810ED; Fri, 28 Feb 2025 09:46: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 A11D3810EB - for ; Fri, 28 Feb 2025 09:46:01 +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 58EBF113E; - Fri, 28 Feb 2025 00:46:16 -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 E0A503F673; - Fri, 28 Feb 2025 00:45:57 -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 , - Heinrich Schuchardt -Subject: [PATCH v6 2/6] efi_loader: add a function to remove memory from the - EFI map -Date: Fri, 28 Feb 2025 14:15:25 +0530 -Message-Id: <20250228084529.127823-3-sughosh.ganu@linaro.org> -X-Mailer: git-send-email 2.34.1 -In-Reply-To: <20250228084529.127823-1-sughosh.ganu@linaro.org> -References: <20250228084529.127823-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 V5: 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 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 Fri Feb 28 08:45:26 2025 -Content-Type: text/plain; charset="utf-8" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -X-Patchwork-Submitter: Sughosh Ganu -X-Patchwork-Id: 2053443 -X-Patchwork-Delegate: xypron.glpk@gmx.de -Return-Path: -X-Original-To: incoming@patchwork.ozlabs.org -Delivered-To: patchwork-incoming@legolas.ozlabs.org -Authentication-Results: legolas.ozlabs.org; - spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de - (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; - envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) -Received: from phobos.denx.de (phobos.denx.de - [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) - (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) - key-exchange X25519 server-signature ECDSA (secp384r1)) - (No client certificate requested) - by legolas.ozlabs.org (Postfix) with ESMTPS id 4Z41ym1cNCz1yKH - for ; Fri, 28 Feb 2025 19:46:24 +1100 (AEDT) -Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) - by phobos.denx.de (Postfix) with ESMTP id BD37E810F1; - Fri, 28 Feb 2025 09:46:08 +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 4D257810F1; Fri, 28 Feb 2025 09:46:07 +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 23B3B80FE1 - for ; Fri, 28 Feb 2025 09:46:05 +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 CB084113E; - Fri, 28 Feb 2025 00:46:19 -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 A01053F673; - Fri, 28 Feb 2025 00:46:01 -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 v6 3/6] efi_loader: preserve installer images in pmem -Date: Fri, 28 Feb 2025 14:15:26 +0530 -Message-Id: <20250228084529.127823-4-sughosh.ganu@linaro.org> -X-Mailer: git-send-email 2.34.1 -In-Reply-To: <20250228084529.127823-1-sughosh.ganu@linaro.org> -References: <20250228084529.127823-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 V5: 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 Fri Feb 28 08:45:27 2025 -Content-Type: text/plain; charset="utf-8" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -X-Patchwork-Submitter: Sughosh Ganu -X-Patchwork-Id: 2053444 -X-Patchwork-Delegate: xypron.glpk@gmx.de -Return-Path: -X-Original-To: incoming@patchwork.ozlabs.org -Delivered-To: patchwork-incoming@legolas.ozlabs.org -Authentication-Results: legolas.ozlabs.org; - spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de - (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; - envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) -Received: from phobos.denx.de (phobos.denx.de - [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) - (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) - key-exchange X25519 server-signature ECDSA (secp384r1)) - (No client certificate requested) - by legolas.ozlabs.org (Postfix) with ESMTPS id 4Z41z21cqkz1yKH - for ; Fri, 28 Feb 2025 19:46:38 +1100 (AEDT) -Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) - by phobos.denx.de (Postfix) with ESMTP id B7A2B810FE; - Fri, 28 Feb 2025 09:46: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 9A8D9811C5; Fri, 28 Feb 2025 09:46:10 +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 A52C180FE1 - for ; Fri, 28 Feb 2025 09:46:08 +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 48F081688; - Fri, 28 Feb 2025 00:46:23 -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 1E23D3F673; - Fri, 28 Feb 2025 00:46:04 -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 v6 4/6] blkmap: store type of blkmap slice in corresponding - structure -Date: Fri, 28 Feb 2025 14:15:27 +0530 -Message-Id: <20250228084529.127823-5-sughosh.ganu@linaro.org> -X-Mailer: git-send-email 2.34.1 -In-Reply-To: <20250228084529.127823-1-sughosh.ganu@linaro.org> -References: <20250228084529.127823-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 V5: 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 Fri Feb 28 08:45:28 2025 -Content-Type: text/plain; charset="utf-8" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -X-Patchwork-Submitter: Sughosh Ganu -X-Patchwork-Id: 2053445 -X-Patchwork-Delegate: xypron.glpk@gmx.de -Return-Path: -X-Original-To: incoming@patchwork.ozlabs.org -Delivered-To: patchwork-incoming@legolas.ozlabs.org -Authentication-Results: legolas.ozlabs.org; - spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de - (client-ip=85.214.62.61; helo=phobos.denx.de; - envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) -Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) - (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) - key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) - (No client certificate requested) - by legolas.ozlabs.org (Postfix) with ESMTPS id 4Z41zB6lfpz1yKH - for ; Fri, 28 Feb 2025 19:46:46 +1100 (AEDT) -Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) - by phobos.denx.de (Postfix) with ESMTP id 1822281111; - Fri, 28 Feb 2025 09:46:15 +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 A6651807D7; Fri, 28 Feb 2025 09:46:14 +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 7B487811C5 - for ; Fri, 28 Feb 2025 09:46:12 +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 3B092113E; - Fri, 28 Feb 2025 00:46:27 -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 103233F673; - Fri, 28 Feb 2025 00:46:08 -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 v6 5/6] blkmap: add an attribute to preserve the mem mapping -Date: Fri, 28 Feb 2025 14:15:28 +0530 -Message-Id: <20250228084529.127823-6-sughosh.ganu@linaro.org> -X-Mailer: git-send-email 2.34.1 -In-Reply-To: <20250228084529.127823-1-sughosh.ganu@linaro.org> -References: <20250228084529.127823-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 -Reviewed-by: Tobias Waldekranz -Reviewed-by: Ilias Apalodimas ---- -Changes since V5: None - - 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