From: Felix Fietkau Date: Sat, 30 Jul 2016 10:18:08 +0000 (+0200) Subject: kernel: fix crashlog regression on x86 X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=9a3852bf8c4b71d19109a1e4c2c490ecf96c283c;p=openwrt%2Fstaging%2Fnbd.git kernel: fix crashlog regression on x86 Check memblock regions for sufficient size before attempting to use them. Allow checks for multiple memblock regions until a suitable one is found. Signed-off-by: Felix Fietkau --- diff --git a/target/linux/generic/patches-4.4/930-crashlog.patch b/target/linux/generic/patches-4.4/930-crashlog.patch index 339cffa34e..311a4f1159 100644 --- a/target/linux/generic/patches-4.4/930-crashlog.patch +++ b/target/linux/generic/patches-4.4/930-crashlog.patch @@ -43,7 +43,7 @@ --- /dev/null +++ b/kernel/crashlog.c -@@ -0,0 +1,193 @@ +@@ -0,0 +1,196 @@ +/* + * Crash information logger + * Copyright (C) 2010 Felix Fietkau @@ -127,6 +127,9 @@ + if (crashlog_addr) + return; + ++ if (size <= CRASHLOG_OFFSET + CRASHLOG_SIZE) ++ return; ++ + addr += size - CRASHLOG_OFFSET; + if (memblock_reserve(addr, CRASHLOG_SIZE)) { + printk("Crashlog failed to allocate RAM at address 0x%lx\n", (unsigned long) addr); @@ -237,24 +240,6 @@ + return 0; +} +module_init(crashlog_init_fs); ---- a/mm/bootmem.c -+++ b/mm/bootmem.c -@@ -15,6 +15,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -177,6 +178,7 @@ static unsigned long __init free_all_boo - if (!bdata->node_bootmem_map) - return 0; - -+ crashlog_init_bootmem(bdata); - map = bdata->node_bootmem_map; - start = bdata->node_min_pfn; - end = bdata->node_low_pfn; --- a/kernel/module.c +++ b/kernel/module.c @@ -275,6 +275,9 @@ static void mod_update_bounds(struct mod @@ -277,7 +262,16 @@ #include #include -@@ -541,6 +542,8 @@ int __init_memblock memblock_add_range(s +@@ -503,6 +504,8 @@ static void __init_memblock memblock_ins + memblock_set_region_node(rgn, nid); + type->cnt++; + type->total_size += size; ++ if (type == &memblock.memory) ++ crashlog_init_memblock(base, size); + } + + /** +@@ -541,6 +544,8 @@ int __init_memblock memblock_add_range(s type->regions[0].flags = flags; memblock_set_region_node(&type->regions[0], nid); type->total_size = size; @@ -286,3 +280,21 @@ return 0; } repeat: +--- a/mm/bootmem.c ++++ b/mm/bootmem.c +@@ -15,6 +15,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -177,6 +178,7 @@ static unsigned long __init free_all_boo + if (!bdata->node_bootmem_map) + return 0; + ++ crashlog_init_bootmem(bdata); + map = bdata->node_bootmem_map; + start = bdata->node_min_pfn; + end = bdata->node_low_pfn;