From: Christian Marangi <ansuelsmth@gmail.com>
To: Russell King <linux@armlinux.org.uk>,
Arnd Bergmann <arnd@arndb.de>,
Andrew Morton <akpm@linux-foundation.org>,
Geert Uytterhoeven <geert+renesas@glider.be>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
Jonathan Corbet <corbet@lwn.net>,
Thomas Gleixner <tglx@linutronix.de>,
Randy Dunlap <rdunlap@infradead.org>,
Christian Marangi <ansuelsmth@gmail.com>,
"Mike Rapoport (IBM)" <rppt@kernel.org>,
Eric DeVolder <eric.devolder@oracle.com>,
Nathan Chancellor <nathan@kernel.org>,
"Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>,
Kees Cook <keescook@chromium.org>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konrad.dybcio@somainline.org>,
Linus Walleij <linus.walleij@linaro.org>,
John Crispin <john@phrozen.org>
Subject: [PATCH 2/2] ARM: decompressor: add option to ignore MEM ATAGs
Date: Fri, 19 Jan 2024 21:12:45 +0100 [thread overview]
Message-ID: <20240119201356.7903-3-ansuelsmth@gmail.com> (raw)
In-Reply-To: <20240119201356.7903-1-ansuelsmth@gmail.com>
Some bootloaders can pass broken MEM ATAGs that provide hardcoded
information about mounted RAM size and physical location.
Example booloader provide RAM of size 1.7Gb but actual mounted RAM
size is 512Mb causing kernel panic.
Add option CONFIG_ARM_ATAG_DTB_COMPAT_IGNORE_MEM to ignore these ATAG
and not augument appended DTB memory node.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
arch/arm/Kconfig | 12 ++++++++++++
arch/arm/boot/compressed/atags_to_fdt.c | 10 ++++++++++
2 files changed, 22 insertions(+)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index b2ab8db63c4b..6bb5c6b28106 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1549,6 +1549,18 @@ config ARM_ATAG_DTB_COMPAT
bootloaders, this option allows zImage to extract the information
from the ATAG list and store it at run time into the appended DTB.
+config ARM_ATAG_DTB_COMPAT_IGNORE_MEM
+ bool "Ignore MEM ATAG information from bootloader"
+ depends on ARM_ATAG_DTB_COMPAT
+ help
+ Some bootloaders can pass broken MEM ATAGs that provide hardcoded
+ information about mounted RAM size and physical location.
+ Example booloader provide RAM of size 1.7Gb but actual mounted RAM
+ size is 512Mb causing kernel panic.
+
+ Enable this option if MEM ATAGs should be ignored and the memory
+ node in the appended DTB should NOT be augumented.
+
choice
prompt "Kernel command line type" if ARM_ATAG_DTB_COMPAT
default ARM_ATAG_DTB_COMPAT_CMDLINE_FROM_BOOTLOADER
diff --git a/arch/arm/boot/compressed/atags_to_fdt.c b/arch/arm/boot/compressed/atags_to_fdt.c
index 627752f18661..189db9fc7fea 100644
--- a/arch/arm/boot/compressed/atags_to_fdt.c
+++ b/arch/arm/boot/compressed/atags_to_fdt.c
@@ -10,6 +10,12 @@
#define do_extend_cmdline 0
#endif
+#if defined(CONFIG_ARM_ATAG_DTB_COMPAT_IGNORE_MEM)
+#define do_ignore_mem 1
+#else
+#define do_ignore_mem 0
+#endif
+
#define NR_BANKS 16
static int node_offset(void *fdt, const char *node_path)
@@ -170,6 +176,10 @@ int atags_to_fdt(void *atag_list, void *fdt, int total_space)
setprop_string(fdt, "/chosen", "bootargs",
atag->u.cmdline.cmdline);
} else if (atag->hdr.tag == ATAG_MEM) {
+ /* Bootloader MEM ATAG are broken and should be ignored */
+ if (do_ignore_mem)
+ continue;
+
if (memcount >= sizeof(mem_reg_property)/4)
continue;
if (!atag->u.mem.size)
--
2.43.0
next prev parent reply other threads:[~2024-01-19 20:14 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-19 20:12 [PATCH 0/2] ARM: decompressor: support AUTO_ZRELADDR and appended DTB Christian Marangi
2024-01-19 20:12 ` [PATCH 1/2] ARM: decompressor: support memory start validation for " Christian Marangi
2024-01-20 11:15 ` Geert Uytterhoeven
2024-01-20 11:48 ` Linus Walleij
2024-01-19 20:12 ` Christian Marangi [this message]
2024-01-20 11:51 ` [PATCH 2/2] ARM: decompressor: add option to ignore MEM ATAGs Linus Walleij
2024-01-20 16:57 ` Christian Marangi
2024-01-20 11:52 ` Linus Walleij
2024-01-20 17:00 ` Christian Marangi
2024-01-21 19:37 ` Linus Walleij
2024-01-20 11:19 ` [PATCH 0/2] ARM: decompressor: support AUTO_ZRELADDR and appended DTB Geert Uytterhoeven
2024-01-20 17:10 ` Christian Marangi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240119201356.7903-3-ansuelsmth@gmail.com \
--to=ansuelsmth@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=andersson@kernel.org \
--cc=arnd@arndb.de \
--cc=corbet@lwn.net \
--cc=eric.devolder@oracle.com \
--cc=geert+renesas@glider.be \
--cc=john@phrozen.org \
--cc=keescook@chromium.org \
--cc=kirill.shutemov@linux.intel.com \
--cc=konrad.dybcio@somainline.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=nathan@kernel.org \
--cc=rdunlap@infradead.org \
--cc=rmk+kernel@armlinux.org.uk \
--cc=rppt@kernel.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox