Merge tag 'acpi-5.20-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael...
[linux-2.6-microblaze.git] / kernel / crash_core.c
index f64d35e..07b26df 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/init.h>
 #include <linux/utsname.h>
 #include <linux/vmalloc.h>
+#include <linux/sizes.h>
 
 #include <asm/page.h>
 #include <asm/sections.h>
@@ -45,6 +46,15 @@ static int __init parse_crashkernel_mem(char *cmdline,
                                        unsigned long long *crash_base)
 {
        char *cur = cmdline, *tmp;
+       unsigned long long total_mem = system_ram;
+
+       /*
+        * Firmware sometimes reserves some memory regions for its own use,
+        * so the system memory size is less than the actual physical memory
+        * size. Work around this by rounding up the total size to 128M,
+        * which is enough for most test cases.
+        */
+       total_mem = roundup(total_mem, SZ_128M);
 
        /* for each entry of the comma-separated list */
        do {
@@ -89,13 +99,13 @@ static int __init parse_crashkernel_mem(char *cmdline,
                        return -EINVAL;
                }
                cur = tmp;
-               if (size >= system_ram) {
+               if (size >= total_mem) {
                        pr_warn("crashkernel: invalid size\n");
                        return -EINVAL;
                }
 
                /* match ? */
-               if (system_ram >= start && system_ram < end) {
+               if (total_mem >= start && total_mem < end) {
                        *crash_size = size;
                        break;
                }