mirror of
https://github.com/torvalds/linux.git
synced 2024-11-18 10:01:43 +00:00
ARM: traps: use <asm/opcodes.h> to get correct instruction order
The trap handler needs to take into account the endian configuration of the system when loading instructions. Use <asm/opcodes.h> to provide the necessary conversion functions. Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk> Tested-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
This commit is contained in:
parent
8592edf0de
commit
a79a0cb1d3
@ -34,6 +34,7 @@
|
|||||||
#include <asm/unwind.h>
|
#include <asm/unwind.h>
|
||||||
#include <asm/tls.h>
|
#include <asm/tls.h>
|
||||||
#include <asm/system_misc.h>
|
#include <asm/system_misc.h>
|
||||||
|
#include <asm/opcodes.h>
|
||||||
|
|
||||||
static const char *handler[]= { "prefetch abort", "data abort", "address exception", "interrupt" };
|
static const char *handler[]= { "prefetch abort", "data abort", "address exception", "interrupt" };
|
||||||
|
|
||||||
@ -402,25 +403,28 @@ asmlinkage void __exception do_undefinstr(struct pt_regs *regs)
|
|||||||
if (processor_mode(regs) == SVC_MODE) {
|
if (processor_mode(regs) == SVC_MODE) {
|
||||||
#ifdef CONFIG_THUMB2_KERNEL
|
#ifdef CONFIG_THUMB2_KERNEL
|
||||||
if (thumb_mode(regs)) {
|
if (thumb_mode(regs)) {
|
||||||
instr = ((u16 *)pc)[0];
|
instr = __mem_to_opcode_thumb16(((u16 *)pc)[0]);
|
||||||
if (is_wide_instruction(instr)) {
|
if (is_wide_instruction(instr)) {
|
||||||
instr <<= 16;
|
u16 inst2;
|
||||||
instr |= ((u16 *)pc)[1];
|
inst2 = __mem_to_opcode_thumb16(((u16 *)pc)[1]);
|
||||||
|
instr = __opcode_thumb32_compose(instr, inst2);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
instr = *(u32 *) pc;
|
instr = __mem_to_opcode_arm(*(u32 *) pc);
|
||||||
} else if (thumb_mode(regs)) {
|
} else if (thumb_mode(regs)) {
|
||||||
if (get_user(instr, (u16 __user *)pc))
|
if (get_user(instr, (u16 __user *)pc))
|
||||||
goto die_sig;
|
goto die_sig;
|
||||||
|
instr = __mem_to_opcode_thumb16(instr);
|
||||||
if (is_wide_instruction(instr)) {
|
if (is_wide_instruction(instr)) {
|
||||||
unsigned int instr2;
|
unsigned int instr2;
|
||||||
if (get_user(instr2, (u16 __user *)pc+1))
|
if (get_user(instr2, (u16 __user *)pc+1))
|
||||||
goto die_sig;
|
goto die_sig;
|
||||||
instr <<= 16;
|
instr2 = __mem_to_opcode_thumb16(instr2);
|
||||||
instr |= instr2;
|
instr = __opcode_thumb32_compose(instr, instr2);
|
||||||
}
|
}
|
||||||
} else if (get_user(instr, (u32 __user *)pc)) {
|
} else if (get_user(instr, (u32 __user *)pc)) {
|
||||||
|
instr = __mem_to_opcode_arm(instr);
|
||||||
goto die_sig;
|
goto die_sig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user