diff mbox

[1/2,Trusty,SRU] powerpc/relocate fix relocate processing in LE mode

Message ID 1398437439-8112-1-git-send-email-tim.gardner@canonical.com
State New
Headers show

Commit Message

Tim Gardner April 25, 2014, 2:50 p.m. UTC
From: Laurent Dufour <ldufour@linux.vnet.ibm.com>

BugLink: http://bugs.launchpad.net/bugs/1312783

Relocation's code is not working in little endian mode because the r_info
field, which is a 64 bits value, should be read from the right offset.

The current code is optimized to read the r_info field as a 32 bits value
starting at the middle of the double word (offset 12). When running in LE
mode, the read value is not correct since only the MSB is read.

This patch removes this optimization which consist to deal with a 32 bits
value instead of a 64 bits one. This way it works in big and little endian
mode.

Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
(cherry picked from commit 3b830c824a8b15bf032eafe09c48a09d2441f16d)
---
 arch/powerpc/kernel/reloc_64.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Brad Figg April 25, 2014, 3:08 p.m. UTC | #1
On 04/25/2014 07:50 AM, Tim Gardner wrote:
> From: Laurent Dufour <ldufour@linux.vnet.ibm.com>
> 
> BugLink: http://bugs.launchpad.net/bugs/1312783
> 
> Relocation's code is not working in little endian mode because the r_info
> field, which is a 64 bits value, should be read from the right offset.
> 
> The current code is optimized to read the r_info field as a 32 bits value
> starting at the middle of the double word (offset 12). When running in LE
> mode, the read value is not correct since only the MSB is read.
> 
> This patch removes this optimization which consist to deal with a 32 bits
> value instead of a 64 bits one. This way it works in big and little endian
> mode.
> 
> Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> (cherry picked from commit 3b830c824a8b15bf032eafe09c48a09d2441f16d)
> ---
>  arch/powerpc/kernel/reloc_64.S | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/reloc_64.S b/arch/powerpc/kernel/reloc_64.S
> index c712ece..d88736f 100644
> --- a/arch/powerpc/kernel/reloc_64.S
> +++ b/arch/powerpc/kernel/reloc_64.S
> @@ -69,8 +69,8 @@ _GLOBAL(relocate)
>  	 * R_PPC64_RELATIVE ones.
>  	 */
>  	mtctr	r8
> -5:	lwz	r0,12(9)	/* ELF64_R_TYPE(reloc->r_info) */
> -	cmpwi	r0,R_PPC64_RELATIVE
> +5:	ld	r0,8(9)		/* ELF64_R_TYPE(reloc->r_info) */
> +	cmpdi	r0,R_PPC64_RELATIVE
>  	bne	6f
>  	ld	r6,0(r9)	/* reloc->r_offset */
>  	ld	r0,16(r9)	/* reloc->r_addend */
>
Tim Gardner April 25, 2014, 3:48 p.m. UTC | #2
Benjamin and Laurent - I did not intend to include you guys in the 
original email. git send-email defaults to Cc patch signatories. Sorry.

rtg
diff mbox

Patch

diff --git a/arch/powerpc/kernel/reloc_64.S b/arch/powerpc/kernel/reloc_64.S
index c712ece..d88736f 100644
--- a/arch/powerpc/kernel/reloc_64.S
+++ b/arch/powerpc/kernel/reloc_64.S
@@ -69,8 +69,8 @@  _GLOBAL(relocate)
 	 * R_PPC64_RELATIVE ones.
 	 */
 	mtctr	r8
-5:	lwz	r0,12(9)	/* ELF64_R_TYPE(reloc->r_info) */
-	cmpwi	r0,R_PPC64_RELATIVE
+5:	ld	r0,8(9)		/* ELF64_R_TYPE(reloc->r_info) */
+	cmpdi	r0,R_PPC64_RELATIVE
 	bne	6f
 	ld	r6,0(r9)	/* reloc->r_offset */
 	ld	r0,16(r9)	/* reloc->r_addend */