linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ARM: avoid corrupts register in mcaro kputc kphex etc.
@ 2014-08-20  9:50 Wang Long
  2014-08-20 10:01 ` Russell King - ARM Linux
  0 siblings, 1 reply; 2+ messages in thread
From: Wang Long @ 2014-08-20  9:50 UTC (permalink / raw)
  To: linux-arm-kernel

when use macro 'kputc' kphex' to print the content of
register r0-r3, they will corrupts these registers.

the same as the macro 'debug_reloc_start' and 'debug_reloc_end'.

so using 'push' when enter the macro and 'pop' when leave
the macro to fix it.

Signed-off-by: Wang Long <long.wanglong@huawei.com>
---
 arch/arm/boot/compressed/head.S | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
index 413fd94..aa57a09 100644
--- a/arch/arm/boot/compressed/head.S
+++ b/arch/arm/boot/compressed/head.S
@@ -19,6 +19,7 @@
  * 100% relocatable.  Any attempt to do so will result in a crash.
  * Please select one of the following when turning on debugging.
  */
+#define DEBUG
 #ifdef DEBUG
 
 #if defined(CONFIG_DEBUG_ICEDCC)
@@ -69,18 +70,23 @@
 #endif
 
 		.macro	kputc,val
+		push	{r0-r3}
 		mov	r0, \val
 		bl	putc
+		pop	{r0-r3}
 		.endm
 
 		.macro	kphex,val,len
+		push	{r0-r3}
 		mov	r0, \val
 		mov	r1, #\len
 		bl	phex
+		pop	{r0-r3}
 		.endm
 
 		.macro	debug_reloc_start
 #ifdef DEBUG
+		push	{r0-r3}
 		kputc	#'\n'
 		kphex	r6, 8		/* processor id */
 		kputc	#':'
@@ -97,15 +103,18 @@
 		kputc	#'>'
 		kphex	r4, 8		/* kernel execution address */
 		kputc	#'\n'
+		pop	{r0-r3}
 #endif
 		.endm
 
 		.macro	debug_reloc_end
 #ifdef DEBUG
+		push    {r0-r3,r10-r12}
 		kphex	r5, 8		/* end of kernel */
 		kputc	#'\n'
 		mov	r0, r4
 		bl	memdump		/* dump 256 bytes at start of kernel */
+		pop	{r0-r3,r10-r12}
 #endif
 		.endm
 
-- 
1.8.3.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH] ARM: avoid corrupts register in mcaro kputc kphex etc.
  2014-08-20  9:50 [PATCH] ARM: avoid corrupts register in mcaro kputc kphex etc Wang Long
@ 2014-08-20 10:01 ` Russell King - ARM Linux
  0 siblings, 0 replies; 2+ messages in thread
From: Russell King - ARM Linux @ 2014-08-20 10:01 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Aug 20, 2014 at 05:50:02PM +0800, Wang Long wrote:
> when use macro 'kputc' kphex' to print the content of
> register r0-r3, they will corrupts these registers.
> 
> the same as the macro 'debug_reloc_start' and 'debug_reloc_end'.
> 
> so using 'push' when enter the macro and 'pop' when leave
> the macro to fix it.

NAK.  These are expected to corrupt r0-r3, and it is expected that
users of these macros save r0-r3 if they contain important values.
This is especially important as these get used in places where there
is no stack to save registers.

-- 
FTTC broadband for 0.8mile line: currently at 9.5Mbps down 400kbps up
according to speedtest.net.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-08-20 10:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-20  9:50 [PATCH] ARM: avoid corrupts register in mcaro kputc kphex etc Wang Long
2014-08-20 10:01 ` Russell King - ARM Linux

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).