kernel/ipq806x: Create kernel files for v6.6 (from v6.1)
[openwrt/openwrt.git] / target / linux / ipq806x / patches-6.6 / 901-02-ARM-decompressor-add-option-to-ignore-MEM-ATAGs.patch
1 From 781d7cd4c3364e9d38fa12a342c5ad4c7e33a5ba Mon Sep 17 00:00:00 2001
2 From: Christian Marangi <ansuelsmth@gmail.com>
3 Date: Fri, 19 Jan 2024 20:33:10 +0100
4 Subject: [PATCH v2 2/2] ARM: decompressor: add option to ignore MEM ATAGs
5
6 Some bootloaders can pass broken MEM ATAGs that provide hardcoded
7 information about mounted RAM size and physical location.
8 Example booloader provide RAM of size 1.7Gb but actual mounted RAM
9 size is 512Mb causing kernel panic.
10
11 Add option CONFIG_ARM_ATAG_DTB_COMPAT_IGNORE_MEM to ignore these ATAG
12 and not augument appended DTB memory node.
13
14 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
15 Acked-by: Linus Walleij <linus.walleij@linaro.org>
16 ---
17 arch/arm/Kconfig | 12 ++++++++++++
18 arch/arm/boot/compressed/atags_to_fdt.c | 4 ++++
19 2 files changed, 16 insertions(+)
20
21 --- a/arch/arm/Kconfig
22 +++ b/arch/arm/Kconfig
23 @@ -1570,6 +1570,18 @@ config ARM_ATAG_DTB_COMPAT
24 bootloaders, this option allows zImage to extract the information
25 from the ATAG list and store it at run time into the appended DTB.
26
27 +config ARM_ATAG_DTB_COMPAT_IGNORE_MEM
28 + bool "Ignore MEM ATAG information from bootloader"
29 + depends on ARM_ATAG_DTB_COMPAT
30 + help
31 + Some bootloaders can pass broken MEM ATAGs that provide hardcoded
32 + information about mounted RAM size and physical location.
33 + Example booloader provide RAM of size 1.7Gb but actual mounted RAM
34 + size is 512Mb causing kernel panic.
35 +
36 + Enable this option if MEM ATAGs should be ignored and the memory
37 + node in the appended DTB should NOT be augumented.
38 +
39 choice
40 prompt "Kernel command line type" if ARM_ATAG_DTB_COMPAT
41 default ARM_ATAG_DTB_COMPAT_CMDLINE_FROM_BOOTLOADER
42 --- a/arch/arm/boot/compressed/atags_to_fdt.c
43 +++ b/arch/arm/boot/compressed/atags_to_fdt.c
44 @@ -169,6 +169,10 @@ int atags_to_fdt(void *atag_list, void *
45 setprop_string(fdt, "/chosen", "bootargs",
46 atag->u.cmdline.cmdline);
47 } else if (atag->hdr.tag == ATAG_MEM) {
48 + /* Bootloader MEM ATAG are broken and should be ignored */
49 + if (IS_ENABLED(CONFIG_ARM_ATAG_DTB_COMPAT_IGNORE_MEM))
50 + continue;
51 +
52 if (memcount >= sizeof(mem_reg_property)/4)
53 continue;
54 if (!atag->u.mem.size)