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,
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.
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
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
linaro-kernel@lists.linaro.org