Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

Ben Dooks 2f9bf9be 457c2403

+8
+8
arch/arm/kernel/head.S
··· 582 582 b 2f 583 583 1: add r7, r3 584 584 ldrh ip, [r7, #2] 585 + ARM_BE8(rev16 ip, ip) 585 586 and ip, 0x8f00 586 587 orr ip, r6 @ mask in offset bits 31-24 588 + ARM_BE8(rev16 ip, ip) 587 589 strh ip, [r7, #2] 588 590 2: cmp r4, r5 589 591 ldrcc r7, [r4], #4 @ use branch for delay slot ··· 594 592 #else 595 593 b 2f 596 594 1: ldr ip, [r7, r3] 595 + #ifdef CONFIG_CPU_ENDIAN_BE8 596 + @ in BE8, we load data in BE, but instructions still in LE 597 + bic ip, ip, #0xff000000 598 + orr ip, ip, r6, lsl#24 599 + #else 597 600 bic ip, ip, #0x000000ff 598 601 orr ip, ip, r6 @ mask in offset bits 31-24 602 + #endif 599 603 str ip, [r7, r3] 600 604 2: cmp r4, r5 601 605 ldrcc r7, [r4], #4 @ use branch for delay slot