From: ben.dooks@codethink.co.uk (Ben Dooks)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/4] ARM: traps: use <asm/opcodes.h> to get correct instruction order
Date: Mon, 22 Jul 2013 17:33:51 +0100 [thread overview]
Message-ID: <1374510833-25716-3-git-send-email-ben.dooks@codethink.co.uk> (raw)
In-Reply-To: <1374510833-25716-1-git-send-email-ben.dooks@codethink.co.uk>
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>
---
arch/arm/kernel/traps.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
index 1c08911..0a56e13 100644
--- a/arch/arm/kernel/traps.c
+++ b/arch/arm/kernel/traps.c
@@ -34,6 +34,7 @@
#include <asm/unwind.h>
#include <asm/tls.h>
#include <asm/system_misc.h>
+#include <asm/opcodes.h>
#include "signal.h"
@@ -411,23 +412,24 @@ asmlinkage void __exception do_undefinstr(struct pt_regs *regs)
if (processor_mode(regs) == SVC_MODE) {
#ifdef CONFIG_THUMB2_KERNEL
if (thumb_mode(regs)) {
- instr = ((u16 *)pc)[0];
+ instr = __mem_to_opcode_thumb16(((u16 *)pc)[0]);
if (is_wide_instruction(instr)) {
instr <<= 16;
- instr |= ((u16 *)pc)[1];
+ instr |= __mem_to_opcode_thumb16(((u16 *)pc)[1]);
}
} else
#endif
- instr = *(u32 *) pc;
+ instr = __mem_to_opcode_arm(*(u32 *) pc);
} else if (thumb_mode(regs)) {
if (get_user(instr, (u16 __user *)pc))
goto die_sig;
+ instr = __mem_to_opcode_thumb16(instr);
if (is_wide_instruction(instr)) {
unsigned int instr2;
if (get_user(instr2, (u16 __user *)pc+1))
goto die_sig;
instr <<= 16;
- instr |= instr2;
+ instr |= __mem_to_opcode_thumb16(instr2);
}
} else if (get_user(instr, (u32 __user *)pc)) {
goto die_sig;
--
1.7.10.4
next prev parent reply other threads:[~2013-07-22 16:33 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-22 16:33 updates for be8 patch series Ben Dooks
2013-07-22 16:33 ` [PATCH 1/4] ARM: alignment: correctly decode instructions in BE8 mode Ben Dooks
2013-07-24 17:16 ` Dave Martin
2013-07-25 11:48 ` Ben Dooks
2013-07-22 16:33 ` Ben Dooks [this message]
2013-07-24 17:34 ` [PATCH 2/4] ARM: traps: use <asm/opcodes.h> to get correct instruction order Dave Martin
2013-07-25 11:17 ` Ben Dooks
2013-07-26 16:04 ` Dave Martin
2013-07-22 16:33 ` [PATCH 3/4] ARM: module: correctly relocate instructions in BE8 Ben Dooks
2013-07-24 17:52 ` Dave Martin
2013-07-22 16:33 ` [PATCH 4/4] ARM: set --be8 when linking modules Ben Dooks
2013-07-22 17:05 ` Stephen Boyd
2013-07-22 17:20 ` Ben Dooks
2013-07-22 18:53 ` Nicolas Pitre
2013-07-22 18:56 ` Ben Dooks
2013-07-23 8:16 ` Ben Dooks
2013-07-22 20:26 ` Ben Dooks
2013-07-22 16:49 ` updates for be8 patch series Ben Dooks
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1374510833-25716-3-git-send-email-ben.dooks@codethink.co.uk \
--to=ben.dooks@codethink.co.uk \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).