Skip to content

Commit 8592edf

Browse files
committed
ARM: alignment: correctly decode instructions in BE8 mode.
If we are in BE8 mode, we must deal with the instruction stream being in LE order when data is being loaded in BE order. Ensure the data is swapped before processing to avoid thre following: Change to using <asm/opcodes.h> to provide the necessary conversion functions to change the byte ordering. This stops the following warning messages from the kernel on a fault: Unhandled fault: alignment exception (0x001) at 0xbfa09567 Alignment trap: not handling instruction 030091e8 at [<80333e8c>] 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>
1 parent 98dec91 commit 8592edf

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎arch/arm/mm/alignment.c‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <asm/cp15.h>
2626
#include <asm/system_info.h>
2727
#include <asm/unaligned.h>
28+
#include <asm/opcodes.h>
2829

2930
#include "fault.h"
3031

@@ -762,21 +763,25 @@ do_alignment(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
762763
if (thumb_mode(regs)) {
763764
u16 *ptr = (u16 *)(instrptr & ~1);
764765
fault = probe_kernel_address(ptr, tinstr);
766+
tinstr = __mem_to_opcode_thumb16(tinstr);
765767
if (!fault) {
766768
if (cpu_architecture() >= CPU_ARCH_ARMv7 &&
767769
IS_T32(tinstr)) {
768770
/* Thumb-2 32-bit */
769771
u16 tinst2 = 0;
770772
fault = probe_kernel_address(ptr + 1, tinst2);
771-
instr = (tinstr << 16) | tinst2;
773+
tinst2 = __mem_to_opcode_thumb16(tinst2);
774+
instr = __opcode_thumb32_compose(tinstr, tinst2);
772775
thumb2_32b = 1;
773776
} else {
774777
isize = 2;
775778
instr = thumb2arm(tinstr);
776779
}
777780
}
778-
} else
781+
} else {
779782
fault = probe_kernel_address(instrptr, instr);
783+
instr = __mem_to_opcode_arm(instr);
784+
}
780785

781786
if (fault) {
782787
type = TYPE_FAULT;

0 commit comments

Comments
 (0)