aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/kernel/head.S
diff options
context:
space:
mode:
authorBen Dooks <ben.dooks@codethink.co.uk>2013-02-01 10:23:08 -0500
committerBen Dooks <ben.dooks@codethink.co.uk>2013-10-19 15:46:33 -0400
commit2f9bf9beddb1649485b47302a5aba9761cbc9084 (patch)
tree081553c2289fe7f1964550c01b5bc420cf0796cd /arch/arm/kernel/head.S
parent457c2403c513c74f60d5757fd11ae927e5554a38 (diff)
ARM: fixup_pv_table bug when CPU_ENDIAN_BE8
The fixup_pv_table assumes that the instructions are in the same endian configuration as the data, but when the CPU is running in BE8 the instructions stay in little-endian format. Make sure if CONFIG_CPU_ENDIAN_BE8 is set that we do all the alterations to the instructions taking in to account the LDR/STR will be swapping the data endian-ness. Since the code is only modifying a byte, we avoid dual-swapping the data, and just change the bits we clear and ORR in (in the case where the code is not thumb2). For thumb2, we add the necessary rev16 instructions to ensure that the instructions are processed in the correct format, as it was easier than re-writing the code to contain a mask and shift. Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk> Reviewed-by: Dave Martin <Dave.Martin@arm.com> Tested-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Diffstat (limited to 'arch/arm/kernel/head.S')
-rw-r--r--arch/arm/kernel/head.S8
1 files changed, 8 insertions, 0 deletions
diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
index 2c7cc1e03473..9e5906cf7d32 100644
--- a/arch/arm/kernel/head.S
+++ b/arch/arm/kernel/head.S
@@ -582,8 +582,10 @@ __fixup_a_pv_table:
582 b 2f 582 b 2f
5831: add r7, r3 5831: add r7, r3
584 ldrh ip, [r7, #2] 584 ldrh ip, [r7, #2]
585ARM_BE8(rev16 ip, ip)
585 and ip, 0x8f00 586 and ip, 0x8f00
586 orr ip, r6 @ mask in offset bits 31-24 587 orr ip, r6 @ mask in offset bits 31-24
588ARM_BE8(rev16 ip, ip)
587 strh ip, [r7, #2] 589 strh ip, [r7, #2]
5882: cmp r4, r5 5902: cmp r4, r5
589 ldrcc r7, [r4], #4 @ use branch for delay slot 591 ldrcc r7, [r4], #4 @ use branch for delay slot
@@ -592,8 +594,14 @@ __fixup_a_pv_table:
592#else 594#else
593 b 2f 595 b 2f
5941: ldr ip, [r7, r3] 5961: ldr ip, [r7, r3]
597#ifdef CONFIG_CPU_ENDIAN_BE8
598 @ in BE8, we load data in BE, but instructions still in LE
599 bic ip, ip, #0xff000000
600 orr ip, ip, r6, lsl#24
601#else
595 bic ip, ip, #0x000000ff 602 bic ip, ip, #0x000000ff
596 orr ip, ip, r6 @ mask in offset bits 31-24 603 orr ip, ip, r6 @ mask in offset bits 31-24
604#endif
597 str ip, [r7, r3] 605 str ip, [r7, r3]
5982: cmp r4, r5 6062: cmp r4, r5
599 ldrcc r7, [r4], #4 @ use branch for delay slot 607 ldrcc r7, [r4], #4 @ use branch for delay slot