ARM: signal: sigreturn_codes should be endian neutral to work in BE8
PATCH 1/1 ARM: signal: sigreturn_codes should be endian neutral to work in BE8
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.
--- arch/arm/kernel/signal.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
arch/arm/kernel/signal.c +7 -6
@@ -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 ,
Signature · 1 line
1.8.1.4
PATCH 1/1 ARM: signal: sigreturn_codes should be endian neutral to work in BE8
Quoted 6 lines · Victor Kamensky
In case of BE8 kernel data is in BE order whereas code stays in LE order.
sigreturn_codesarray 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.
PATCH 1/1 ARM: signal: sigreturn_codes should be endian neutral to work in BE8
Quoted 9 lines · Russell King - ARM Linux
Quoted 6 lines · Victor Kamensky
In case of BE8 kernel data is in BE order whereas code stays in LE order.
sigreturn_codesarray 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
PATCH 1/1 ARM: signal: sigreturn_codes should be endian neutral to work in BE8
Quoted 9 lines · Dave Martin
Quoted 8 lines · Russell King - ARM Linux
Quoted 6 lines · Victor Kamensky
In case of BE8 kernel data is in BE order whereas code stays in LE order.
sigreturn_codesarray 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.
Quoted 7 lines
Quoted 1 line
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
Quoted 2 lines
Cheers
---Dave