From: ben.dooks@codethink.co.uk (Ben Dooks)
To: linux-arm-kernel@lists.infradead.org
Subject: alignment handler instruction endian-ness
Date: Fri, 19 Jul 2013 13:15:33 +0100 [thread overview]
Message-ID: <51E92DE5.6090404@codethink.co.uk> (raw)
In-Reply-To: <20130719110947.GD24642@n2100.arm.linux.org.uk>
On 19/07/13 12:09, Russell King - ARM Linux wrote:
> On Fri, Jul 19, 2013 at 11:58:45AM +0100, Ben Dooks wrote:
>> I ran in to an issue with the alignment handler when running BE8 where
>> it loads instructions and fails to swap.
>>
>> Is there a better way of swapping instructions for ARM when loading
>> from arbitrary places? Have I missed any other places this could happen?
>
> Maybe we need a macro which deals with this automatically?
>
> arm_instr_to_cpu(x)
> thumb_instr_to_cpu(x)
>
> These should probably make use of the swab*() macros when an endian swap
> is needed.
>
>> The following patch is my first attempt at solving the problem for the
>> alignment handler:
>
> I'd suggest checking this with sparse too - you have some type errors here.
How about:
diff --git a/arch/arm/include/uapi/asm/byteorder.h
b/arch/arm/include/uapi/asm/b
index 7737974..9e63a00 100644
--- a/arch/arm/include/uapi/asm/byteorder.h
+++ b/arch/arm/include/uapi/asm/byteorder.h
@@ -21,5 +21,13 @@
#include <linux/byteorder/little_endian.h>
#endif
+#ifdef CONFIG_CPU_ENDIAN_BE8
+#define cpu_to_arm_instr(__instr) swab32(__instr)
+#define cpu_to_thum_instr(__instr) swab16(__instr)
+#else
+#define cpu_to_arm_instr(__instr) (__instr)
+#define cpu_to_thum_instr(__instr) (__instr)
+#endif
--
Ben Dooks http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
next prev parent reply other threads:[~2013-07-19 12:15 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-19 10:58 alignment handler instruction endian-ness Ben Dooks
2013-07-19 11:09 ` Russell King - ARM Linux
2013-07-19 11:26 ` Ben Dooks
2013-07-19 12:15 ` Ben Dooks [this message]
2013-07-19 12:32 ` Russell King - ARM Linux
2013-07-19 13:19 ` Ben Dooks
2013-07-22 18:31 ` Nicolas Pitre
2013-07-22 18:34 ` Ben Dooks
2013-07-19 14:01 ` Jon Medhurst (Tixy)
2013-07-19 14:05 ` Russell King - ARM Linux
2013-07-19 14:50 ` Ben Dooks
2013-07-19 14:56 ` Russell King - ARM Linux
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=51E92DE5.6090404@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).