ARM: better diagnostics with missing/corrupt dtb
authorRussell King <rmk+kernel@armlinux.org.uk>
Thu, 21 Sep 2017 11:06:20 +0000 (12:06 +0100)
committerRussell King <rmk+kernel@armlinux.org.uk>
Fri, 29 Sep 2017 12:57:21 +0000 (13:57 +0100)
With a kernel containing both DT and atag support, the diagnostics
output when the dtb is missing or corrupt assume that we're trying
to boot using atags and the machine ID, and only print the machine
ID.  This is not useful for diagnosing a missing or corrupt dtb.

Move the message into arch/arm/kernel/setup.c, and print the address
of the dtb/atag list, and the first 16 bytes of memory of the dtb or
atag list.

This allows us to see whether the dtb was corrupted in some way,
causing the fallback to the machine ID / atag list.

Tested-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
arch/arm/kernel/atags_parse.c
arch/arm/kernel/setup.c

index 98fbfd235ac875662c6666abfad5c53fbd93b1df..c10a3e8ee998efeaabc0c544037006ef0ab6cb3f 100644 (file)
@@ -196,11 +196,8 @@ setup_machine_tags(phys_addr_t __atags_pointer, unsigned int machine_nr)
                        break;
                }
 
-       if (!mdesc) {
-               early_print("\nError: unrecognized/unsupported machine ID"
-                           " (r1 = 0x%08x).\n\n", machine_nr);
-               dump_machine_table(); /* does not return */
-       }
+       if (!mdesc)
+               return NULL;
 
        if (__atags_pointer)
                tags = phys_to_virt(__atags_pointer);
index 8e9a3e40d949567598cfdcc8146823f5ada96cb2..fc40a2b40595bef5411d2d948a06774a0d78b2b7 100644 (file)
@@ -1069,6 +1069,16 @@ void __init setup_arch(char **cmdline_p)
        mdesc = setup_machine_fdt(__atags_pointer);
        if (!mdesc)
                mdesc = setup_machine_tags(__atags_pointer, __machine_arch_type);
+       if (!mdesc) {
+               early_print("\nError: invalid dtb and unrecognized/unsupported machine ID\n");
+               early_print("  r1=0x%08x, r2=0x%08x\n", __machine_arch_type,
+                           __atags_pointer);
+               if (__atags_pointer)
+                       early_print("  r2[]=%*ph\n", 16,
+                                   phys_to_virt(__atags_pointer));
+               dump_machine_table();
+       }
+
        machine_desc = mdesc;
        machine_name = mdesc->name;
        dump_stack_set_arch_desc("%s", mdesc->name);