All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [stable v3.18.y] ARM: 8383/1: nommu: avoid deprecated source register on mov
@ 2017-04-27 19:32 Arnd Bergmann
  2017-04-28 20:31 ` Stefan Agner
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2017-04-27 19:32 UTC (permalink / raw)
  To: linux-arm-kernel

From: Stefan Agner <stefan@agner.ch>

Commit 970d96f9a81b0dd83ddd8bce0e5e1ba31881c5f5 upstream.

In Thumb2 mode, the stack register r13 is deprecated if the
destination register is the program counter (r15). Similar to
head.S, head-nommu.S uses r13 to store the return address used
after configuring the CPU's CP15 register. However, since we do
not enable a MMU, there will be no address switch and it is
possible to use branch with link instruction to call
__after_proc_init.

Avoid using r13 completely by using bl to call __after_proc_init
and get rid of __secondary_switched.

Beside removing unnecessary complexity, this also fixes a
compiler warning when compiling a !MMU kernel:
Warning: Use of r13 as a source register is deprecated when r15
is the destination register.

Tested-?by: Maxime Coquelin <mcoquelin.stm32@gmail.com>

Signed-off-by: Stefan Agner <stefan@agner.ch>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
----
I've backported this build fix to 3.18.y as the original
patch did not apply cleanly. I rebased it one patch at a time,
and each step was fairly straightforward, but I did not test
it on hardware, so it would still be nice to have someone else
look over the patch to see if I did something wrong.
---
 arch/arm/kernel/head-nommu.S | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/arch/arm/kernel/head-nommu.S b/arch/arm/kernel/head-nommu.S
index cc176b67c134..c6c66dd4be89 100644
--- a/arch/arm/kernel/head-nommu.S
+++ b/arch/arm/kernel/head-nommu.S
@@ -77,13 +77,12 @@ ENTRY(stext)
 	orr	r6, r6, #(1 << MPU_RSR_EN)	@ Set region enabled bit
 	bl	__setup_mpu
 #endif
-	ldr	r13, =__mmap_switched		@ address to jump to after
-						@ initialising sctlr
 	adr	lr, BSYM(1f)			@ return (PIC) address
  ARM(	add	pc, r10, #PROCINFO_INITFUNC	)
  THUMB(	add	r12, r10, #PROCINFO_INITFUNC	)
  THUMB(	ret	r12				)
- 1:	b	__after_proc_init
+1:	bl	__after_proc_init
+	b	__mmap_switched
 ENDPROC(stext)
 
 #ifdef CONFIG_SMP
@@ -106,8 +105,7 @@ ENTRY(secondary_startup)
 	movs	r10, r5				@ invalid processor?
 	beq	__error_p			@ yes, error 'p'
 
-	adr	r4, __secondary_data
-	ldmia	r4, {r7, r12}
+	ldr	r7, __secondary_data
 
 #ifdef CONFIG_ARM_MPU
 	/* Use MPU region info supplied by __cpu_up */
@@ -115,23 +113,19 @@ ENTRY(secondary_startup)
 	bl      __setup_mpu			@ Initialize the MPU
 #endif
 
-	adr	lr, BSYM(__after_proc_init)	@ return address
-	mov	r13, r12			@ __secondary_switched address
+	adr	lr, BSYM(1f)			@ return (PIC) address
  ARM(	add	pc, r10, #PROCINFO_INITFUNC	)
  THUMB(	add	r12, r10, #PROCINFO_INITFUNC	)
  THUMB(	ret	r12				)
-ENDPROC(secondary_startup)
-
-ENTRY(__secondary_switched)
+1:	bl	__after_proc_init
 	ldr	sp, [r7, #8]			@ set up the stack pointer
 	mov	fp, #0
 	b	secondary_start_kernel
-ENDPROC(__secondary_switched)
+ENDPROC(secondary_startup)
 
 	.type	__secondary_data, %object
 __secondary_data:
 	.long	secondary_data
-	.long	__secondary_switched
 #endif /* CONFIG_SMP */
 
 /*
@@ -164,7 +158,7 @@ __after_proc_init:
 #endif
 	mcr	p15, 0, r0, c1, c0, 0		@ write control reg
 #endif /* CONFIG_CPU_CP15 */
-	ret	r13
+	ret	lr
 ENDPROC(__after_proc_init)
 	.ltorg
 
-- 
2.9.0

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

* [PATCH] [stable v3.18.y] ARM: 8383/1: nommu: avoid deprecated source register on mov
  2017-04-27 19:32 [PATCH] [stable v3.18.y] ARM: 8383/1: nommu: avoid deprecated source register on mov Arnd Bergmann
@ 2017-04-28 20:31 ` Stefan Agner
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Agner @ 2017-04-28 20:31 UTC (permalink / raw)
  To: linux-arm-kernel

On 2017-04-27 12:32, Arnd Bergmann wrote:
> From: Stefan Agner <stefan@agner.ch>
> 
> Commit 970d96f9a81b0dd83ddd8bce0e5e1ba31881c5f5 upstream.
> 
> In Thumb2 mode, the stack register r13 is deprecated if the
> destination register is the program counter (r15). Similar to
> head.S, head-nommu.S uses r13 to store the return address used
> after configuring the CPU's CP15 register. However, since we do
> not enable a MMU, there will be no address switch and it is
> possible to use branch with link instruction to call
> __after_proc_init.
> 
> Avoid using r13 completely by using bl to call __after_proc_init
> and get rid of __secondary_switched.
> 
> Beside removing unnecessary complexity, this also fixes a
> compiler warning when compiling a !MMU kernel:
> Warning: Use of r13 as a source register is deprecated when r15
> is the destination register.
> 
> Tested-?by: Maxime Coquelin <mcoquelin.stm32@gmail.com>
> 
> Signed-off-by: Stefan Agner <stefan@agner.ch>
> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ----
> I've backported this build fix to 3.18.y as the original
> patch did not apply cleanly. I rebased it one patch at a time,
> and each step was fairly straightforward, but I did not test
> it on hardware, so it would still be nice to have someone else
> look over the patch to see if I did something wrong.

Looks good to me.

--
Stefan

> ---
>  arch/arm/kernel/head-nommu.S | 20 +++++++-------------
>  1 file changed, 7 insertions(+), 13 deletions(-)
> 
> diff --git a/arch/arm/kernel/head-nommu.S b/arch/arm/kernel/head-nommu.S
> index cc176b67c134..c6c66dd4be89 100644
> --- a/arch/arm/kernel/head-nommu.S
> +++ b/arch/arm/kernel/head-nommu.S
> @@ -77,13 +77,12 @@ ENTRY(stext)
>  	orr	r6, r6, #(1 << MPU_RSR_EN)	@ Set region enabled bit
>  	bl	__setup_mpu
>  #endif
> -	ldr	r13, =__mmap_switched		@ address to jump to after
> -						@ initialising sctlr
>  	adr	lr, BSYM(1f)			@ return (PIC) address
>   ARM(	add	pc, r10, #PROCINFO_INITFUNC	)
>   THUMB(	add	r12, r10, #PROCINFO_INITFUNC	)
>   THUMB(	ret	r12				)
> - 1:	b	__after_proc_init
> +1:	bl	__after_proc_init
> +	b	__mmap_switched
>  ENDPROC(stext)
>  
>  #ifdef CONFIG_SMP
> @@ -106,8 +105,7 @@ ENTRY(secondary_startup)
>  	movs	r10, r5				@ invalid processor?
>  	beq	__error_p			@ yes, error 'p'
>  
> -	adr	r4, __secondary_data
> -	ldmia	r4, {r7, r12}
> +	ldr	r7, __secondary_data
>  
>  #ifdef CONFIG_ARM_MPU
>  	/* Use MPU region info supplied by __cpu_up */
> @@ -115,23 +113,19 @@ ENTRY(secondary_startup)
>  	bl      __setup_mpu			@ Initialize the MPU
>  #endif
>  
> -	adr	lr, BSYM(__after_proc_init)	@ return address
> -	mov	r13, r12			@ __secondary_switched address
> +	adr	lr, BSYM(1f)			@ return (PIC) address
>   ARM(	add	pc, r10, #PROCINFO_INITFUNC	)
>   THUMB(	add	r12, r10, #PROCINFO_INITFUNC	)
>   THUMB(	ret	r12				)
> -ENDPROC(secondary_startup)
> -
> -ENTRY(__secondary_switched)
> +1:	bl	__after_proc_init
>  	ldr	sp, [r7, #8]			@ set up the stack pointer
>  	mov	fp, #0
>  	b	secondary_start_kernel
> -ENDPROC(__secondary_switched)
> +ENDPROC(secondary_startup)
>  
>  	.type	__secondary_data, %object
>  __secondary_data:
>  	.long	secondary_data
> -	.long	__secondary_switched
>  #endif /* CONFIG_SMP */
>  
>  /*
> @@ -164,7 +158,7 @@ __after_proc_init:
>  #endif
>  	mcr	p15, 0, r0, c1, c0, 0		@ write control reg
>  #endif /* CONFIG_CPU_CP15 */
> -	ret	r13
> +	ret	lr
>  ENDPROC(__after_proc_init)
>  	.ltorg

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

end of thread, other threads:[~2017-04-28 20:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-27 19:32 [PATCH] [stable v3.18.y] ARM: 8383/1: nommu: avoid deprecated source register on mov Arnd Bergmann
2017-04-28 20:31 ` Stefan Agner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.