ARM: 8786/1: Debug kernel copy by printing
authorFabrizio Castro <fabrizio.castro@bp.renesas.com>
Tue, 21 Aug 2018 17:54:13 +0000 (18:54 +0100)
committerRussell King <rmk+kernel@armlinux.org.uk>
Wed, 19 Sep 2018 09:44:50 +0000 (10:44 +0100)
It may happen that when we relocate the kernel we corrupt other
sensible memory (e.g. the memory needed by U-Boot for dealing
with bootm command) while copying the kernel. If we overwrite
the content of the memory area used by U-Boot's command bootm
(described by U-Boot's parameters bootm_low and bootm_size),
the kernel won't be able to boot. Troubleshooting the problem
then is not straightforward.

This commit allows the user to easily print information on
where the kernel gets copied from/to in order to help with the
design of the system memory map (e.g. bootm_low and bootm_size)
at boot up.

Signed-off-by: Fabrizio Castro <fabrizio.castro@bp.renesas.com>
Reviewed-by: Chris Paterson <Chris.Paterson2@renesas.com>
Acked-by: Biju Das <biju.das@bp.renesas.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
arch/arm/boot/compressed/head.S

index 517e0e18f0b8307855447abfec63f0827cb72cec..6c7ccb428c079c3e43ef9cce2c344ec4b6809369 100644 (file)
 #endif
                .endm
 
+               /*
+                * Debug kernel copy by printing the memory addresses involved
+                */
+               .macro dbgkc, begin, end, cbegin, cend
+#ifdef DEBUG
+               kputc   #'\n'
+               kputc   #'C'
+               kputc   #':'
+               kputc   #'0'
+               kputc   #'x'
+               kphex   \begin, 8       /* Start of compressed kernel */
+               kputc   #'-'
+               kputc   #'0'
+               kputc   #'x'
+               kphex   \end, 8         /* End of compressed kernel */
+               kputc   #'-'
+               kputc   #'>'
+               kputc   #'0'
+               kputc   #'x'
+               kphex   \cbegin, 8      /* Start of kernel copy */
+               kputc   #'-'
+               kputc   #'0'
+               kputc   #'x'
+               kphex   \cend, 8        /* End of kernel copy */
+               kputc   #'\n'
+               kputc   #'\r'
+#endif
+               .endm
+
                .section ".start", #alloc, #execinstr
 /*
  * sort out different calling conventions
@@ -450,6 +479,20 @@ dtb_check_done:
                add     r6, r9, r5
                add     r9, r9, r10
 
+#ifdef DEBUG
+               sub     r10, r6, r5
+               sub     r10, r9, r10
+               /*
+                * We are about to copy the kernel to a new memory area.
+                * The boundaries of the new memory area can be found in
+                * r10 and r9, whilst r5 and r6 contain the boundaries
+                * of the memory we are going to copy.
+                * Calling dbgkc will help with the printing of this
+                * information.
+                */
+               dbgkc   r5, r6, r10, r9
+#endif
+
 1:             ldmdb   r6!, {r0 - r3, r10 - r12, lr}
                cmp     r6, r5
                stmdb   r9!, {r0 - r3, r10 - r12, lr}