* [PATCH] ARM: signal: sigreturn_codes should be endian neutral to work in BE8
@ 2013-08-13 7:12 Victor Kamensky
2013-08-13 12:12 ` Russell King - ARM Linux
0 siblings, 1 reply; 4+ messages in thread
From: Victor Kamensky @ 2013-08-13 7:12 UTC (permalink / raw)
To: linux-arm-kernel
In case of BE8 kernel data is in BE order whereas code stays in LE
order. sigreturn_codes array initializer need to use macros from
<asm/opcodes.h> to setup instructions code in endian neutral way.
Problem was discovered during ltp testing of BE system: all rt_sig*
tests failed. Tested against the same tests in both BE and LE modes.
Signed-off-by: Victor Kamensky <victor.kamensky@linaro.org>
---
arch/arm/kernel/signal.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
index ab33042..333a67f 100644
--- a/arch/arm/kernel/signal.c
+++ b/arch/arm/kernel/signal.c
@@ -20,25 +20,26 @@
#include <asm/ucontext.h>
#include <asm/unistd.h>
#include <asm/vfp.h>
+#include <asm/opcodes.h>
/*
* For ARM syscalls, we encode the syscall number into the instruction.
*/
-#define SWI_SYS_SIGRETURN (0xef000000|(__NR_sigreturn)|(__NR_OABI_SYSCALL_BASE))
-#define SWI_SYS_RT_SIGRETURN (0xef000000|(__NR_rt_sigreturn)|(__NR_OABI_SYSCALL_BASE))
+#define SWI_SYS_SIGRETURN (__opcode_to_mem_arm(0xef000000|(__NR_sigreturn)|(__NR_OABI_SYSCALL_BASE)))
+#define SWI_SYS_RT_SIGRETURN (__opcode_to_mem_arm(0xef000000|(__NR_rt_sigreturn)|(__NR_OABI_SYSCALL_BASE)))
/*
* With EABI, the syscall number has to be loaded into r7.
*/
-#define MOV_R7_NR_SIGRETURN (0xe3a07000 | (__NR_sigreturn - __NR_SYSCALL_BASE))
-#define MOV_R7_NR_RT_SIGRETURN (0xe3a07000 | (__NR_rt_sigreturn - __NR_SYSCALL_BASE))
+#define MOV_R7_NR_SIGRETURN (__opcode_to_mem_arm(0xe3a07000 | (__NR_sigreturn - __NR_SYSCALL_BASE)))
+#define MOV_R7_NR_RT_SIGRETURN (__opcode_to_mem_arm(0xe3a07000 | (__NR_rt_sigreturn - __NR_SYSCALL_BASE)))
/*
* For Thumb syscalls, we pass the syscall number via r7. We therefore
* need two 16-bit instructions.
*/
-#define SWI_THUMB_SIGRETURN (0xdf00 << 16 | 0x2700 | (__NR_sigreturn - __NR_SYSCALL_BASE))
-#define SWI_THUMB_RT_SIGRETURN (0xdf00 << 16 | 0x2700 | (__NR_rt_sigreturn - __NR_SYSCALL_BASE))
+#define SWI_THUMB_SIGRETURN (__opcode_to_mem_arm(0xdf00 << 16 | 0x2700 | (__NR_sigreturn - __NR_SYSCALL_BASE)))
+#define SWI_THUMB_RT_SIGRETURN (__opcode_to_mem_arm(0xdf00 << 16 | 0x2700 | (__NR_rt_sigreturn - __NR_SYSCALL_BASE)))
static const unsigned long sigreturn_codes[7] = {
MOV_R7_NR_SIGRETURN, SWI_SYS_SIGRETURN, SWI_THUMB_SIGRETURN,
--
1.8.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] ARM: signal: sigreturn_codes should be endian neutral to work in BE8
2013-08-13 7:12 [PATCH] ARM: signal: sigreturn_codes should be endian neutral to work in BE8 Victor Kamensky
@ 2013-08-13 12:12 ` Russell King - ARM Linux
2013-08-13 12:33 ` Dave Martin
0 siblings, 1 reply; 4+ messages in thread
From: Russell King - ARM Linux @ 2013-08-13 12:12 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, Aug 13, 2013 at 12:12:11AM -0700, Victor Kamensky wrote:
> In case of BE8 kernel data is in BE order whereas code stays in LE
> order. sigreturn_codes array initializer need to use macros from
> <asm/opcodes.h> to setup instructions code in endian neutral way.
>
> Problem was discovered during ltp testing of BE system: all rt_sig*
> tests failed. Tested against the same tests in both BE and LE modes.
It might make more sense to move these into a .S file actually.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] ARM: signal: sigreturn_codes should be endian neutral to work in BE8
2013-08-13 12:12 ` Russell King - ARM Linux
@ 2013-08-13 12:33 ` Dave Martin
2013-08-13 14:59 ` Victor Kamensky
0 siblings, 1 reply; 4+ messages in thread
From: Dave Martin @ 2013-08-13 12:33 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, Aug 13, 2013 at 01:12:45PM +0100, Russell King - ARM Linux wrote:
> On Tue, Aug 13, 2013 at 12:12:11AM -0700, Victor Kamensky wrote:
> > In case of BE8 kernel data is in BE order whereas code stays in LE
> > order. sigreturn_codes array initializer need to use macros from
> > <asm/opcodes.h> to setup instructions code in endian neutral way.
> >
> > Problem was discovered during ltp testing of BE system: all rt_sig*
> > tests failed. Tested against the same tests in both BE and LE modes.
>
> It might make more sense to move these into a .S file actually.
That would make sense. Since the kernel assumes v4, I think we can
assume sufficiently Thumb-capable tools that all these instructions can
be assembled directly without needing magic numbers.
Then the swabbing should be correct in vmlinux with no extra effort.
Cheers
---Dave
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] ARM: signal: sigreturn_codes should be endian neutral to work in BE8
2013-08-13 12:33 ` Dave Martin
@ 2013-08-13 14:59 ` Victor Kamensky
0 siblings, 0 replies; 4+ messages in thread
From: Victor Kamensky @ 2013-08-13 14:59 UTC (permalink / raw)
To: linux-arm-kernel
On 13 August 2013 05:33, Dave Martin <Dave.Martin@arm.com> wrote:
> On Tue, Aug 13, 2013 at 01:12:45PM +0100, Russell King - ARM Linux wrote:
>> On Tue, Aug 13, 2013 at 12:12:11AM -0700, Victor Kamensky wrote:
>> > In case of BE8 kernel data is in BE order whereas code stays in LE
>> > order. sigreturn_codes array initializer need to use macros from
>> > <asm/opcodes.h> to setup instructions code in endian neutral way.
>> >
>> > Problem was discovered during ltp testing of BE system: all rt_sig*
>> > tests failed. Tested against the same tests in both BE and LE modes.
>>
>> It might make more sense to move these into a .S file actually.
>
> That would make sense. Since the kernel assumes v4, I think we can
> assume sufficiently Thumb-capable tools that all these instructions can
> be assembled directly without needing magic numbers.
>
> Then the swabbing should be correct in vmlinux with no extra effort.
Ok, I will try to redo this with .S file.
Thanks,
Victor
> Cheers
> ---Dave
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-08-13 14:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-13 7:12 [PATCH] ARM: signal: sigreturn_codes should be endian neutral to work in BE8 Victor Kamensky
2013-08-13 12:12 ` Russell King - ARM Linux
2013-08-13 12:33 ` Dave Martin
2013-08-13 14:59 ` Victor Kamensky
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).