Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2194436/?format=api
{ "id": 2194436, "url": "http://patchwork.ozlabs.org/api/patches/2194436/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/patch/20260208223715.3721340-1-james.hilliard1@gmail.com/", "project": { "id": 18, "url": "http://patchwork.ozlabs.org/api/projects/18/?format=api", "name": "U-Boot", "link_name": "uboot", "list_id": "u-boot.lists.denx.de", "list_email": "u-boot@lists.denx.de", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260208223715.3721340-1-james.hilliard1@gmail.com>", "list_archive_url": null, "date": "2026-02-08T22:37:15", "name": "[1/1] image: fit: Apply overlays on a writable FDT copy", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "37c1c2def530714a44da7b94399ed8baf9c98db1", "submitter": { "id": 66301, "url": "http://patchwork.ozlabs.org/api/people/66301/?format=api", "name": "James Hilliard", "email": "james.hilliard1@gmail.com" }, "delegate": { "id": 3651, "url": "http://patchwork.ozlabs.org/api/users/3651/?format=api", "username": "trini", "first_name": "Tom", "last_name": "Rini", "email": "trini@ti.com" }, "mbox": "http://patchwork.ozlabs.org/project/uboot/patch/20260208223715.3721340-1-james.hilliard1@gmail.com/mbox/", "series": [ { "id": 491449, "url": "http://patchwork.ozlabs.org/api/series/491449/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/list/?series=491449", "date": "2026-02-08T22:37:15", "name": "[1/1] image: fit: Apply overlays on a writable FDT copy", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/491449/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2194436/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2194436/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<u-boot-bounces@lists.denx.de>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20230601 header.b=LQhe8adz;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de\n (client-ip=85.214.62.61; helo=phobos.denx.de;\n envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org)", "phobos.denx.de;\n dmarc=pass (p=none dis=none) header.from=gmail.com", "phobos.denx.de;\n spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de", "phobos.denx.de;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.b=\"LQhe8adz\";\n\tdkim-atps=neutral", "phobos.denx.de;\n dmarc=pass (p=none dis=none) header.from=gmail.com", "phobos.denx.de;\n spf=pass smtp.mailfrom=james.hilliard1@gmail.com" ], "Received": [ "from phobos.denx.de (phobos.denx.de [85.214.62.61])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4f8Q4z66v3z1xtr\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 09 Feb 2026 11:08:03 +1100 (AEDT)", "from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id 244C08341A;\n\tMon, 9 Feb 2026 01:07:58 +0100 (CET)", "by phobos.denx.de (Postfix, from userid 109)\n id B1A9083642; Sun, 8 Feb 2026 23:37:43 +0100 (CET)", "from mail-oo1-xc2c.google.com (mail-oo1-xc2c.google.com\n [IPv6:2607:f8b0:4864:20::c2c])\n (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits))\n (No client certificate requested)\n by phobos.denx.de (Postfix) with ESMTPS id 77C9E805D7\n for <u-boot@lists.denx.de>; Sun, 8 Feb 2026 23:37:41 +0100 (CET)", "by mail-oo1-xc2c.google.com with SMTP id\n 006d021491bc7-662f5c4665eso1418716eaf.2\n for <u-boot@lists.denx.de>; Sun, 08 Feb 2026 14:37:41 -0800 (PST)", "from james-x399.localdomain (71-218-105-26.hlrn.qwest.net.\n [71.218.105.26]) by smtp.gmail.com with ESMTPSA id\n 006d021491bc7-66d391ae639sm4779452eaf.7.2026.02.08.14.37.38\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Sun, 08 Feb 2026 14:37:38 -0800 (PST)" ], "X-Spam-Checker-Version": "SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de", "X-Spam-Level": "", "X-Spam-Status": "No, score=-0.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,\n DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_GMAIL_RCVD,\n FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_BLOCKED,\n SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20230601; t=1770590260; x=1771195060; darn=lists.denx.de;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:from:to:cc:subject:date:message-id:reply-to;\n bh=IqFq8nsYflsqyI3/dCnBG7Qn9qujfSH4rQSEYDqIUB8=;\n b=LQhe8adzjBN2Vu9FxGrDxB1hAuS/adogo2ip97/GBBn3zFQFqOVOsSIkqmdIaqnkWN\n S6OquAx7eZxbmKIJK0H1rUyj+/dJDO20JBdhE1lW9nlZ+HfvrifdE4F13GJiMzA/U4Rp\n 0CzbGgOoEwIn8PTLpBcgV6RNzJ3GvqgFIEvuJkqn/JVei+zuJVoiT9ATAYA0xELuWf0K\n KTa8gKV94fVgqx07goNsP2nwRS2XA9hvODRAUeUut7k8GOhlosogvadVDOuUgJOTigLO\n bvNGSoDxh5GcZLRDv1dbVx14KGb6QZga6NmDKIRV1t/5wkBRrhcaT4xl65r/wupbqBuK\n kd0Q==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1770590260; x=1771195060;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date\n :message-id:reply-to;\n bh=IqFq8nsYflsqyI3/dCnBG7Qn9qujfSH4rQSEYDqIUB8=;\n b=pTnSxNdLgTsoUMcKCFCkmLSQZj1EXkahv51BmgAcjyXxMFBw9TSKyGiJ4uXwvXnlWo\n aKhJw+8FO1/yGwIWAN/I0tSeVZKy344/urVU3M99zdZ7b+h3IGpAs8O6PY+Y4Bl4OOsR\n NISI6UKiJnfqYCsPEL6nWpBvwyhDWrIkN1RqmBN+BDZnWUUbAhZh50L4ix6yhwUnWi6x\n kHsAVjTVOfZa3y0fk2tw/U0ai2VhlUj2HaRvgDa3JELT0wxhtPqgG5ccNSjVDqTJAbph\n 5a7gh78GUZJ3CD6l6NTOK1x7be1ED00JwW81iAmbqnVEkpizGvV80WwW9GzX+W+9LjQI\n oqIQ==", "X-Gm-Message-State": "AOJu0YzeYdNOUGzW+3vpkho6eS5rDvwF+OjJvbeH2Z1+6gPPbzud3uAe\n dV6hppcte25UdSH+7gZo0jcSxEHDdy88b6ysKTpnei1imStJt0u/tWxBqMRYhg==", "X-Gm-Gg": "AZuq6aJQ+EcMXY+vKq8ukb6cPGwXihm2+yu1lViUzS7Y0NLNAVqKVhTWYoHv0sUbKcT\n n7JyG1R+RvdRPsJYt9DUgvX5YcI6L87Z68wqIfdfXDLcA2mJLO30Mc559CY0UV514XSIUWibuN6\n Vz8sz2DpZ7mxAqaleD1JLM1v+15aIaGTPqAmi8UegmEzLpN5FD2J9O8EvlTGCNVpD5wzXIBg+VJ\n 1w6oXA8CHKnvtptY0eijtzN+Tyjz0T54P6rme26TUy0nGM2oEfz7byiSTXOgyFJkNwZKJXMdAS1\n NH/7KDw10oIzJtXCJwnEoYiiMKZyjG9vIN+HWjou2zaWkzaQS1SsF5jJIoMNgsL9riVkPFIz7QH\n LDYrJzE9hrhu98rMQC+JMOCnV6G1WsE/1bf73crSOFvalpK9k2RQ9K4blxrqEy21hox4eZYO4bR\n O5UP8jkfz+hHgOL8MExg2Km1FlXOTn+0nEESW0d1b1zn7lt3jlvU2kLizNHf2FwEFzsTciOgFoN\n ar4PDVvOzZo3dEhgdq2rBvk89KAdCjMnEOYVHL5bruPlz9ga0p67m38bE1R6Q==", "X-Received": "by 2002:a4a:bc85:0:b0:66d:fb53:8279 with SMTP id\n 006d021491bc7-66dfb5383dcmr2467185eaf.2.1770590259580;\n Sun, 08 Feb 2026 14:37:39 -0800 (PST)", "From": "James Hilliard <james.hilliard1@gmail.com>", "To": "u-boot@lists.denx.de", "Cc": "James Hilliard <james.hilliard1@gmail.com>, Tom Rini <trini@konsulko.com>,\n Marek Vasut <marek.vasut+renesas@mailbox.org>,\n Quentin Schulz <quentin.schulz@cherry.de>", "Subject": "[PATCH 1/1] image: fit: Apply overlays on a writable FDT copy", "Date": "Sun, 8 Feb 2026 15:37:15 -0700", "Message-ID": "<20260208223715.3721340-1-james.hilliard1@gmail.com>", "X-Mailer": "git-send-email 2.43.0", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-Mailman-Approved-At": "Mon, 09 Feb 2026 01:07:56 +0100", "X-BeenThere": "u-boot@lists.denx.de", "X-Mailman-Version": "2.1.39", "Precedence": "list", "List-Id": "U-Boot discussion <u-boot.lists.denx.de>", "List-Unsubscribe": "<https://lists.denx.de/options/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>", "List-Archive": "<https://lists.denx.de/pipermail/u-boot/>", "List-Post": "<mailto:u-boot@lists.denx.de>", "List-Help": "<mailto:u-boot-request@lists.denx.de?subject=help>", "List-Subscribe": "<https://lists.denx.de/listinfo/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=subscribe>", "Errors-To": "u-boot-bounces@lists.denx.de", "Sender": "\"U-Boot\" <u-boot-bounces@lists.denx.de>", "X-Virus-Scanned": "clamav-milter 0.103.8 at phobos.denx.de", "X-Virus-Status": "Clean" }, "content": "boot_get_fdt_fit() relocates the base FDT with boot_relocate_fdt()\nbefore applying overlays. That uses the bootm memory map and can\noverlap with the FIT buffer when the FIT is loaded into RAM, corrupting\ndata needed to load the kernel and ramdisk.\n\nAllocate a writable copy of the base FDT with memalign() and\nfdt_open_into(), grow it as needed for each overlay, and apply the\noverlays to this buffer. Also check fdt_pack() errors and free the\ntemporary overlay copy after each application.\n\nFixes: 881f0b77dc8c (\"image: apply FDTOs on FDT node\")\nSigned-off-by: James Hilliard <james.hilliard1@gmail.com>\n---\n boot/image-fit.c | 91 +++++++++++++++++++++++++++++++++++-------------\n 1 file changed, 67 insertions(+), 24 deletions(-)", "diff": "diff --git a/boot/image-fit.c b/boot/image-fit.c\nindex 41ab1f552b0..922a3606f47 100644\n--- a/boot/image-fit.c\n+++ b/boot/image-fit.c\n@@ -2356,18 +2356,12 @@ int boot_get_fdt_fit(struct bootm_headers *images, ulong addr,\n \tchar *next_config = NULL;\n \tulong load, len;\n #ifdef CONFIG_OF_LIBFDT_OVERLAY\n-\tulong ovload, ovlen, ovcopylen;\n+\tulong ovload, ovlen, ovcopylen, need;\n \tconst char *uconfig;\n \tconst char *uname;\n-\t/*\n-\t * of_flat_tree is storing the void * returned by map_sysmem, then its\n-\t * address is passed to boot_relocate_fdt which expects a char ** and it\n-\t * is then cast into a ulong. Setting its type to void * would require\n-\t * to cast its address to char ** when passing it to boot_relocate_fdt.\n-\t * Instead, let's be lazy and use void *.\n-\t */\n-\tchar *of_flat_tree;\n-\tvoid *base, *ov, *ovcopy = NULL;\n+\tvoid *base, *ov, *ovcopy = NULL, *new_base;\n+\tvoid *base_buf = NULL;\n+\tulong base_buf_size = 0;\n \tint i, err, noffset, ov_noffset;\n #endif\n \n@@ -2410,18 +2404,32 @@ int boot_get_fdt_fit(struct bootm_headers *images, ulong addr,\n \t/* we need to apply overlays */\n \n #ifdef CONFIG_OF_LIBFDT_OVERLAY\n-\t/* Relocate FDT so resizing does not overwrite other data in FIT. */\n-\tof_flat_tree = map_sysmem(load, len);\n-\tlen = ALIGN(fdt_totalsize(load), SZ_4K);\n-\terr = boot_relocate_fdt(&of_flat_tree, &len);\n-\tif (err) {\n-\t\tprintf(\"Required FDT relocation for applying DTOs failed: %d\\n\",\n-\t\t err);\n-\t\tfdt_noffset = -EBADF;\n+\t/*\n+\t * Make a writable copy of the base FDT for applying overlays.\n+\t *\n+\t * Do not use boot_relocate_fdt() here: it allocates from the bootm map and\n+\t * may overlap with the FIT buffer (still needed to load the kernel /\n+\t * ramdisk) when the FIT is loaded into RAM.\n+\t */\n+\tbase = map_sysmem(load, len);\n+\tbase_buf_size = ALIGN(fdt_totalsize(base), SZ_4K) + CONFIG_SYS_FDT_PAD;\n+\tbase_buf = memalign(SZ_4K, base_buf_size);\n+\tif (!base_buf) {\n+\t\tprintf(\"Required FDT copy for applying DTOs failed: out of memory\\n\");\n+\t\tfdt_noffset = -ENOMEM;\n \t\tgoto out;\n \t}\n \n-\tload = (ulong)of_flat_tree;\n+\terr = fdt_open_into(base, base_buf, base_buf_size);\n+\tif (err < 0) {\n+\t\tprintf(\"Required FDT copy for applying DTOs failed: %s\\n\",\n+\t\t fdt_strerror(err));\n+\t\tfdt_noffset = err;\n+\t\tgoto out;\n+\t}\n+\n+\tload = map_to_sysmem(base_buf);\n+\tlen = fdt_totalsize(base);\n \n \t/* apply extra configs in FIT first, followed by args */\n \tfor (i = 1; ; i++) {\n@@ -2482,8 +2490,34 @@ int boot_get_fdt_fit(struct bootm_headers *images, ulong addr,\n \t\t\tgoto out;\n \t\t}\n \n-\t\tbase = map_sysmem(load, len + ovlen);\n-\t\terr = fdt_open_into(base, base, len + ovlen);\n+\t\t/*\n+\t\t * Ensure the base FDT buffer is open and has enough room for the\n+\t\t * overlay. Grow it on demand.\n+\t\t */\n+\t\tneed = ALIGN(len + ovcopylen + CONFIG_SYS_FDT_PAD, SZ_4K);\n+\t\tif (need > base_buf_size) {\n+\t\t\tnew_base = memalign(SZ_4K, need);\n+\t\t\tif (!new_base) {\n+\t\t\t\tprintf(\"failed to expand FDT for DTO application\\n\");\n+\t\t\t\tfdt_noffset = -ENOMEM;\n+\t\t\t\tgoto out;\n+\t\t\t}\n+\n+\t\t\terr = fdt_open_into(base_buf, new_base, need);\n+\t\t\tif (err < 0) {\n+\t\t\t\tprintf(\"failed on fdt_open_into while expanding FDT\\n\");\n+\t\t\t\tfree(new_base);\n+\t\t\t\tfdt_noffset = err;\n+\t\t\t\tgoto out;\n+\t\t\t}\n+\n+\t\t\tfree(base_buf);\n+\t\t\tbase_buf = new_base;\n+\t\t\tbase_buf_size = need;\n+\t\t\tload = map_to_sysmem(base_buf);\n+\t\t}\n+\n+\t\terr = fdt_open_into(base_buf, base_buf, base_buf_size);\n \t\tif (err < 0) {\n \t\t\tprintf(\"failed on fdt_open_into\\n\");\n \t\t\tfdt_noffset = err;\n@@ -2491,13 +2525,20 @@ int boot_get_fdt_fit(struct bootm_headers *images, ulong addr,\n \t\t}\n \n \t\t/* the verbose method prints out messages on error */\n-\t\terr = fdt_overlay_apply_verbose(base, ovcopy);\n+\t\terr = fdt_overlay_apply_verbose(base_buf, ovcopy);\n+\t\tif (err < 0) {\n+\t\t\tfdt_noffset = err;\n+\t\t\tgoto out;\n+\t\t}\n+\t\terr = fdt_pack(base_buf);\n \t\tif (err < 0) {\n \t\t\tfdt_noffset = err;\n \t\t\tgoto out;\n \t\t}\n-\t\tfdt_pack(base);\n-\t\tlen = fdt_totalsize(base);\n+\t\tlen = fdt_totalsize(base_buf);\n+\n+\t\tfree(ovcopy);\n+\t\tovcopy = NULL;\n \t}\n #else\n \tprintf(\"config with overlays but CONFIG_OF_LIBFDT_OVERLAY not set\\n\");\n@@ -2515,6 +2556,8 @@ out:\n \t\t*fit_uname_configp = fit_uname_config;\n \n #ifdef CONFIG_OF_LIBFDT_OVERLAY\n+\tif (fdt_noffset < 0)\n+\t\tfree(base_buf);\n \tfree(ovcopy);\n #endif\n \tfree(fit_uname_config_copy);\n", "prefixes": [ "1/1" ] }