From patchwork Mon Sep 22 18:01:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 404 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1758564160; bh=kmhpxyCyjYP8PDl2k8cBCV8xOiJtnFXQJo/q8exLp2I=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=fjMvO94WYLqSpYR7QIXdA+8lJYWqw2xGCpKb0dL8xOplMQAuhqUXEmdmMcvWvTR06 4uIi5YCA7u/bDIbWKVjk2RXLTENgxsdx6W9TBGR9HyIMU5OUkv0QmDMndwccAEzlQ4 Vc9Ze5lpVe1EjkC5HN4UtM3OcecF9ZAcxfs/fPhj9X7se7z5UBd53SJiwMxC1wYbqv N47oDPuOYefgnm5jLstT2IAO0tPvuZmMbkLUHFSBRg1/PNWc9eKnjJ6JSjAGkLnLLl NYA2EF9U809ppCwkUyuKTGOzMzQOjwe/hovmy8QTyQaltvI6ozS7SlMo3ozmqUfE/h 6scJOv8uA/zJw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 474D467CE6 for ; Mon, 22 Sep 2025 12:02:40 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id MHpUmo95smnz for ; Mon, 22 Sep 2025 12:02:40 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1758564159; bh=kmhpxyCyjYP8PDl2k8cBCV8xOiJtnFXQJo/q8exLp2I=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Bqfa6ivdZfC0IAvCaa5o8WZRT9cb/Ii/w/xavNocsqxkFxQKS955jnZpRKORg4Lba 7iz3k0GnDt0cDb63VrstF9l0O8+BB19H71GqK/swCRvLATHdJJWcRD5Wxm3P9im+25 B6mLksvnJUxveXeBEogsdUugY6xp51F+H/+dPppUbJwBFUlnPXvZVE55jz5Y3W56dJ lliJFTouDejVTh/YQTCNiXLdRcxCleKO9nIuzFlXkD9APtXN+8xztPX3hVn4HuQfSQ MLM5xXvFXvibJwEmU4zZ/x2/pMlqJ/3dbEfN8Zo+nXE5vo5RNgmAC3b8vwgYQMApa7 cz/Gjws9eA6gw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3E45767B38 for ; Mon, 22 Sep 2025 12:02:39 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1758564156; bh=vBQj8hdtr5uZIwwQ/GxpCAoIZ9tolm8O1Du09oAEsG0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cfQCydQPQsp+vxDyNkP1WZl06+gixnKwpQxR+ru9p6kz43Sa1o25auoC3e3n0kz2f Qg3j8j329yMPHL69DX1KGwh3jA9RIfnFgcPuVoeqLji5xflwvadSmWSweG2YdaBVIp 52jBL+uqMIlNMP8kkjvkD0dDfRoWOXjiUlQBv1iTZiQxjparYj9wI6sIiuSNpDetqO 70NUsUloDHrwjdZP3r2z8FA9sbHFIygQZh36JNoyi8Ej1h7BNnZorUeXbz1PsrBc81 3IotlhyKjaT+Oq4piKf2zJHieGGZ8LoQUO8SNYLSgSqwf4WaFRcP1462J1rZ0gPOGf j7jtkWjeLSq2A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D80655FE1A; Mon, 22 Sep 2025 12:02:36 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id uLdlIqOTxByD; Mon, 22 Sep 2025 12:02:36 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1758564155; bh=vqM1aCvkQ2pb/M8Pt5SLlXpbMzfKAUIcqz34YjHkJpg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TvDeZ7n3Qo2xZ+Znkqh+kGJMdQiDnPr84HBEx/xc0ZkU2RIbbNL4ADGa9kjj/A84N 2zCE7SZmhCPo+1SXnnehVZDgnQQtXVY0JrQBRGlDchu5Je1/yklChPygnplaLkiuXw zCanOxWqKu9lb6CjkgxX072nY4W/jZ8cJbGDt3hbW1wFCMmwcTAsNJ16PUY8tSLnT6 y1Z1neI1acDkF8TraQx84u26c9DPYai+rRZMEOR4ejuxQ+WPR/l2+LCLRV1bjTVFvh 3FC9s3XuJy4ZmFBrXF/L/p8c6BJ/C1RSZ+JsaHYpluIaoH8GHGPGIHetXXnjTWzU8e NrnC2ouBaEIKQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 13C1667C32; Mon, 22 Sep 2025 12:02:35 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 22 Sep 2025 12:01:04 -0600 Message-ID: <20250922180116.3088502-21-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250922180116.3088502-1-sjg@u-boot.org> References: <20250922180116.3088502-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: G55OD7HGZVGBUGZOSHTNH4POVSIU3Q6R X-Message-ID-Hash: G55OD7HGZVGBUGZOSHTNH4POVSIU3Q6R X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 20/24] arm: Use lmb when relocating the image List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass It isn't necessarily safe to move the kernel (up to) 2MB higher in memory. If the kernel is in a FIT, this may overwrite other data such as the devicetree. Use lmb (where available) as is done with other image relocations. Update the return value to provide more specific information on failure. Signed-off-by: Simon Glass --- arch/arm/lib/image.c | 15 +++++++++++---- include/image.h | 3 ++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/arch/arm/lib/image.c b/arch/arm/lib/image.c index d78d704cb58..f97276a84c5 100644 --- a/arch/arm/lib/image.c +++ b/arch/arm/lib/image.c @@ -48,7 +48,7 @@ int booti_setup(ulong image, ulong *relocated_addr, ulong *size, if (!booti_is_valid(ih)) { puts("Bad Linux ARM64 Image magic!\n"); - return 1; + return -EPERM; } /* @@ -73,10 +73,17 @@ int booti_setup(ulong image, ulong *relocated_addr, ulong *size, * images->ep. Otherwise, relocate the image to the base of RAM * since memory below it is not accessible via the linear mapping. */ - if (!force_reloc && (le64_to_cpu(ih->flags) & BIT(3))) - dst = image - text_offset; - else + if (!force_reloc && (le64_to_cpu(ih->flags) & BIT(3))) { + if (IS_ENABLED(CONFIG_LMB)) { + dst = lmb_alloc(image_size, SZ_2M); + if (!dst) + return -ENOSPC; + } else { + dst = image - text_offset; + } + } else { dst = gd->bd->bi_dram[0].start; + } *relocated_addr = ALIGN(dst, SZ_2M) + text_offset; diff --git a/include/image.h b/include/image.h index 7f3ca1088de..a972e3f6921 100644 --- a/include/image.h +++ b/include/image.h @@ -1134,7 +1134,8 @@ int bootz_setup(ulong image, ulong *start, ulong *end); * @start: Returns start address of image * @size : Returns size image * @force_reloc: Ignore image->ep field, always place image to RAM start - * Return: 0 if OK, 1 if the image was not recognised + * Return: 0 if OK, -EPERM image was not recognised, -ENOSPC if there was not + * enough lmb space */ int booti_setup(ulong image, ulong *relocated_addr, ulong *size, bool force_reloc);