From patchwork Mon Mar 17 08:33:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 874146 Delivered-To: patch@linaro.org Received: by 2002:a5d:4308:0:b0:38f:210b:807b with SMTP id h8csp1869739wrq; Mon, 17 Mar 2025 01:34:35 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVHkk87xMzAHljCq2stPgLoS2tsv8EWbHzv8XInMl+imexhWocKrj62R2M5J1r48aNUWs+gsA==@linaro.org X-Google-Smtp-Source: AGHT+IGcXzO8DKu1px+rEZvzI8CYY4IjotAhyyBY8szGS7fT6Hb/IymNOOjwZnTGDsgMamcdEaoW X-Received: by 2002:a17:907:970f:b0:ac3:45b8:968c with SMTP id a640c23a62f3a-ac345b8aef5mr811378566b.1.1742200475513; Mon, 17 Mar 2025 01:34:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1742200475; cv=none; d=google.com; s=arc-20240605; b=aLM5HLukUPTRWO4YDJpEfEGcCm0NdNDskIKhfPfBoTUsL01nVaqM8Nr5Lcj/a1Lxkn hIZki3Xs9EWhuAk8V5bsLuUJbL3/ONgkK8YX5mZN1/5iKXHKvLMOnBRFL5xmRDZIaJ71 0zuhL6t0ETssPCYAqb+ce2XqlOYaUo/hRaxsUjfeKi28pl8ZrX/KuQPgCH1IqBszHDZ6 0Hto1PLmyNV5lGK3iqO/qMiuHGobRjaxkk6Ep9u3inJcmV7caJHKn1DzPilwpJHrePSc gVV7AzFlm4JX9HdtoE10AVVyFcymjMxjlNVZP6SCuH4/xseGmSglKkdhYH5/91YMMmZY 1mtA== 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:message-id:date:subject:cc:to:from; bh=eLhl7/mj2kNau0gS6wz69yRpjQ/yg2GWF/WtUD/KhUI=; fh=bHr605NUXl1F7suejM5+0d5DcANY/0ccb1yuu1CAhjY=; b=GvP321Lq+ghgqeP1o+J/Pt5xP4Gd/iNWtmPrLtx0gh6R8TJ8+7BBG707bFMb4iu81r ZXPPiwbQfabtrF1858yNgCvSHJJQWR61gJqLbxcxx3ovQVCk9VP/+mVZckPWbzwhM+59 3nYrrY0GQ1LW5sJu1YI771TMuRCRf/WBWq/91/UAfGTK5DhxhxBWXqfp/GF46H1ol7XX qWAQ38mKOyk39EIk3LrHayJYC7sJ09eSLZbhLqVpGcCmh07Eb3+Cc4eO1RtLnPTAtlza YOA+xGYvI+PFrEqNXYk3uRBoqTPvgXBwhmZXd9n6qb2R7txtTwDlt89Ubs571wZUuWP5 Nb6g==; 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 a640c23a62f3a-ac3146ac469si704906966b.24.2025.03.17.01.34.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Mar 2025 01:34:35 -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 2C7D980FEC; Mon, 17 Mar 2025 09:34:31 +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 D2F1980F70; Mon, 17 Mar 2025 09:34:29 +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 69CFA80107 for ; Mon, 17 Mar 2025 09:34:27 +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 6018A13D5; Mon, 17 Mar 2025 01:34:35 -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 3705D3F673; Mon, 17 Mar 2025 01:34:23 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Simon Glass , Tom Rini , Heinrich Schuchardt , Anton Antonov , Tobias Waldekranz Subject: [PATCH v9 0/8] Add pmem node for preserving distro ISO's Date: Mon, 17 Mar 2025 14:03:54 +0530 Message-Id: <20250317083402.412310-1-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 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 This is problematic in EFI, since U-Boot mounts the image, starts the installer, and eventually calls ExitBootServices. At that point the image U-Boot mounted disappears. Some distros don't care and download the missing packages from a web archive, while others halt the installation complaining they can't find certain packages. If the firmware uses ACPI, this is supported by using NFIT which provides NVDIMM ramdisks to the OS and preserves the image. We don't have anything in place for Device Trees though. Since DT supports persistent memory nodes (pmem) use those and preserve the .iso for installers. The issue can be reproduced by attempting an EFI HTTP boot with Ubuntu live server ISO, or a Rocky Linux ISO. The installation would fail with the failure to locate certain packages. The patches are adding support for adding the pmem node to the DT that is being passed to the OS, along with removing the memory region containing the ISO image from the EFI memory map. This is being done through a helper function in the blkmap driver which scans for all blkmap mappings and does the above configurations for the relevant mappings. This version of the patchset is adding two patches to the front of the series, which re-install a device-tree(DT) on the EFI configuration table afresh on every invocation of efi_install_fdt(). This fixes the issue of a stale DT being passed on to a OS in the scenario where the DT was already installed on the configuration table. Changes since V8: * Re-word the commit message to indicate DT being installed as EFI configuration table (patch 2) * Remove the existing EFI config table in copy_fdt() (patch 2) * Move assignment of new_fdt_addr and fdt_pages variables to the block freeing up the existing config table memory (patch 2) * Re-word the commit message to indicate that the ramdisk information is being passed to the OS through pmem node (patch 3) * Change the type of addr and size parameters to the fdt_fixup_pmem_region() as u64 (patch 3) * Rename the first parameter of fdt_fixup_pmem_region() as fdt instead of blob (patch 3) * Modify the format specifier of snprintf() call in fdt_fixup_pmem_region() accordingly (patch 3) * Remove pmem_start and pmem_size array variables in fdt_fixup_pmem_region() (patch 3) * s/pmem_node/node_name/g (patch 3) * Do not initialise node_name variable (patch 3) * Re-word the commit message to indicate using efi_update_memory_map() for removal of memory from the EFI memory map (patch 4) * Use efi_update_memory_map() for removing memory from the EFI memory map instead of adding a new function efi_remove_memory_map() (patch 4) * Re-word the commit message to indicate that the ramdisk region is being removed from the EFI memory map (patch 5) * Fix the comment in prepare_loaded_image() on similar lines as above (patch 5) * s/pmem memory area/pmem memory areas/ (patch 5) * s/MB/MiB/g (patch 5) * s/blkmap slice/blkmap slices/ in the commit message (patch 6) * Add comments to the macros added in the patch (patch 6) * Add comments to the macro added in the patch (patch 7) * s/blkmap_get_preserved_pmem_slice/blkmap_get_preserved_pmem_slices/g to highlight that more than one slice is being looked for (patch 8) * Add information on the parameters being passed to the callback function in blkmap_get_preserved_pmem_slices() description (patch 8) * Highlight the fact that the callback gets called for every slice found in blkmap_get_preserved_pmem_slices() description (patch 8) * Highlight the fact that invoking the callback stops when an error is returned by the callback in blkmap_get_preserved_pmem_slices() description (patch 8) * Put some description of a typical use-case of the callback function in blkmap_get_preserved_pmem_slices() description (patch 8) Ilias Apalodimas (2): efi_loader: allow for removal of memory from the EFI map efi_loader: remove memory occupied by a ramdisk from EFI memory map Masahisa Kojima (1): fdt: add support for adding pmem nodes Sughosh Ganu (5): efi_loader: remove unused code from copy_fdt() efi_loader: install device-tree on configuration table on every invocation blkmap: store type of blkmap slice in corresponding structure blkmap: add an attribute to preserve the mem mapping blkmap: pass information on ISO image to the OS boot/fdt_support.c | 39 +++++++++++++++- boot/image-fdt.c | 7 +++ cmd/blkmap.c | 9 +++- drivers/block/blkmap.c | 82 +++++++++++++++++++++++++++++++-- drivers/block/blkmap_helper.c | 2 +- include/blkmap.h | 33 +++++++++++++- include/efi.h | 13 ++++++ include/efi_loader.h | 15 +++++++ include/fdt_support.h | 14 ++++++ lib/efi_loader/efi_bootmgr.c | 25 ++++++++--- lib/efi_loader/efi_helper.c | 85 +++++++++++++++++++++++++++-------- lib/efi_loader/efi_memory.c | 34 +++++++------- 12 files changed, 310 insertions(+), 48 deletions(-)