--- zzzz-none-000/linux-5.4.213/drivers/of/fdt.c 2022-09-15 10:04:56.000000000 +0000 +++ alder-5690pro-762/linux-5.4.213/drivers/of/fdt.c 2024-08-14 09:02:08.000000000 +0000 @@ -1046,6 +1046,7 @@ int l; const char *p; const void *rng_seed; + char *q = data; pr_debug("search \"chosen\", depth: %d, uname: %s\n", depth, uname); @@ -1059,6 +1060,16 @@ p = of_get_flat_dt_prop(node, "bootargs", &l); if (p != NULL && l > 0) strlcpy(data, p, min(l, COMMAND_LINE_SIZE)); + p = of_get_flat_dt_prop(node, "bootargs-append", &l); + if (p != NULL && l > 0) + strlcat(data, p, min_t(int, strlen(data) + (int)l, COMMAND_LINE_SIZE)); + p = of_get_flat_dt_prop(node, "bootargs-prepend", &l); + if (p != NULL && l > 0 && l < COMMAND_LINE_SIZE) { + /* XXX: This may truncate the command line. */ + memmove(&q[l - 1], q, COMMAND_LINE_SIZE - l + 1); + memcpy(q, p, l - 1); + q[COMMAND_LINE_SIZE - 1] = 0; + } /* * CONFIG_CMDLINE is meant to be a default in case nothing else @@ -1117,6 +1128,20 @@ size -= PAGE_SIZE - (base & ~PAGE_MASK); base = PAGE_ALIGN(base); } + + +#ifndef CONFIG_PHYS_ADDR_T_64BIT + if (base + size > ULONG_MAX) { + pr_crit("Truncating memory at 0x%08llx to fit in 32-bit physical address space\n", + (long long)base); + /* + * To ensure bank->start + bank->size is representable in + * 32 bits, we use ULONG_MAX as the upper limit rather than 4GB. + * This means we lose a page after masking. + */ + size = ULONG_MAX - base; + } +#endif size &= PAGE_MASK; if (base > MAX_MEMBLOCK_ADDR) {