From: u.kleine-koenig@pengutronix.de (Uwe Kleine-König)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 20/23] ARM: signal: sigreturn_codes should be endian neutral to work in BE8
Date: Tue, 5 Nov 2013 22:18:07 +0100 [thread overview]
Message-ID: <20131105211807.GR14892@pengutronix.de> (raw)
In-Reply-To: <1381271679-27804-21-git-send-email-ben.dooks@codethink.co.uk>
Hello,
On Wed, Oct 09, 2013 at 12:34:36AM +0200, Ben Dooks wrote:
> From: Victor Kamensky <victor.kamensky@linaro.org>
>
> In case of BE8 kernel data is in BE order whereas code stays in LE
> order. Move sigreturn_codes to separate .S file and use proper
> assembler mnemonics for these code snippets. In this case compiler
> will take care of proper instructions byteswaps for BE8 case.
> Change assumes that sufficiently Thumb-capable tools are used to
> build kernel.
>
> 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>
> Reviewed-by: Dave Martin <Dave.Martin@arm.com>
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> ---
> arch/arm/kernel/Makefile | 3 +-
> arch/arm/kernel/signal.c | 24 +-----------
> arch/arm/kernel/sigreturn_codes.S | 80 +++++++++++++++++++++++++++++++++++++++
> 3 files changed, 83 insertions(+), 24 deletions(-)
> create mode 100644 arch/arm/kernel/sigreturn_codes.S
>
> diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile
> index 5140df5f..39c9834 100644
> --- a/arch/arm/kernel/Makefile
> +++ b/arch/arm/kernel/Makefile
> @@ -17,7 +17,8 @@ CFLAGS_REMOVE_return_address.o = -pg
>
> obj-y := elf.o entry-common.o irq.o opcodes.o \
> process.o ptrace.o return_address.o \
> - setup.o signal.o stacktrace.o sys_arm.o time.o traps.o
> + setup.o signal.o sigreturn_codes.o \
> + stacktrace.o sys_arm.o time.o traps.o
>
> obj-$(CONFIG_ATAGS) += atags_parse.o
> obj-$(CONFIG_ATAGS_PROC) += atags_proc.o
> diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
> index ab33042..64845fc 100644
> --- a/arch/arm/kernel/signal.c
> +++ b/arch/arm/kernel/signal.c
> @@ -21,29 +21,7 @@
> #include <asm/unistd.h>
> #include <asm/vfp.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))
> -
> -/*
> - * 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))
> -
> -/*
> - * 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))
> -
> -static const unsigned long sigreturn_codes[7] = {
> - MOV_R7_NR_SIGRETURN, SWI_SYS_SIGRETURN, SWI_THUMB_SIGRETURN,
> - MOV_R7_NR_RT_SIGRETURN, SWI_SYS_RT_SIGRETURN, SWI_THUMB_RT_SIGRETURN,
> -};
> +extern const unsigned long sigreturn_codes[7];
>
> static unsigned long signal_return_offset;
>
> diff --git a/arch/arm/kernel/sigreturn_codes.S b/arch/arm/kernel/sigreturn_codes.S
> new file mode 100644
> index 0000000..3c5d0f2
> --- /dev/null
> +++ b/arch/arm/kernel/sigreturn_codes.S
> @@ -0,0 +1,80 @@
> +/*
> + * sigreturn_codes.S - code sinpets for sigreturn syscalls
> + *
> + * Created by: Victor Kamensky, 2013-08-13
> + * Copyright: (C) 2013 Linaro Limited
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + */
> +
> +#include <asm/unistd.h>
> +
> +/*
> + * For ARM syscalls, we encode the syscall number into the instruction.
> + * With EABI, the syscall number has to be loaded into r7. As result
> + * ARM syscall sequence snippet will have move and svc in .arm encoding
> + *
> + * For Thumb syscalls, we pass the syscall number via r7. We therefore
> + * need two 16-bit instructions in .thumb encoding
> + *
> + * Please note sigreturn_codes code are not executed in place. Instead
> + * they just copied by kernel into appropriate places. Code inside of
> + * arch/arm/kernel/signal.c is very sensitive to layout of these code
> + * snippets.
> + */
> +
> +#if __LINUX_ARM_ARCH__ <= 4
> + /*
> + * Note we manually set minimally required arch that supports
> + * required thumb opcodes for early arch versions. It is OK
> + * for this file to be used in combination with other
> + * lower arch variants, since these code snippets are only
> + * used as input data.
> + */
> + .arch armv4t
> +#endif
> +
> + .section .rodata
> + .global sigreturn_codes
> + .type sigreturn_codes, #object
> +
> + .arm
This breaks a ARMv7-M build, see
http://arm-soc.lixom.net/buildlogs/misc/next-20131105-1-g2b29c44/buildall.arm.efm32_defconfig.log.failed
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |
next prev parent reply other threads:[~2013-11-05 21:18 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-08 22:34 New big-endian patch series against 3.12-rc4 Ben Dooks
2013-10-08 22:34 ` [PATCH 01/23] ARM: fix ARCH_IXP4xx usage of ARCH_SUPPORTS_BIG_ENDIAN Ben Dooks
2013-10-08 22:34 ` [PATCH 02/23] ARM: asm: Add ARM_BE8() assembly helper Ben Dooks
2013-10-08 22:34 ` [PATCH 03/23] ARM: fixup_pv_table bug when CPU_ENDIAN_BE8 Ben Dooks
2013-10-08 22:34 ` [PATCH 04/23] ARM: set BE8 if LE in head code Ben Dooks
2013-10-08 22:34 ` [PATCH 05/23] ARM: pl01x debug code endian fix Ben Dooks
2013-10-08 22:34 ` [PATCH 06/23] ARM: twd: data " Ben Dooks
2013-10-08 22:34 ` [PATCH 07/23] ARM: smp_scu: data endian fixes Ben Dooks
2013-10-08 22:34 ` [PATCH 08/23] ARM: highbank: enable big-endian Ben Dooks
2013-10-08 22:34 ` [PATCH 09/23] ARM: mvebu: support running big-endian Ben Dooks
2013-10-08 22:34 ` [PATCH 10/23] ARM: vexpress: add big endian support Ben Dooks
2013-10-08 22:34 ` [PATCH 11/23] ARM: alignment: correctly decode instructions in BE8 mode Ben Dooks
2013-10-08 22:34 ` [PATCH 12/23] ARM: traps: use <asm/opcodes.h> to get correct instruction order Ben Dooks
2013-10-09 11:42 ` Will Deacon
2013-10-08 22:34 ` [PATCH 13/23] ARM: module: correctly relocate instructions in BE8 Ben Dooks
2013-10-08 22:34 ` [PATCH 14/23] ARM: set --be8 when linking modules Ben Dooks
2013-10-08 22:34 ` [PATCH 15/23] ARM: hardware: fix endian-ness in <hardware/coresight.h> Ben Dooks
2013-10-08 22:34 ` [PATCH 16/23] ARM: net: fix arm instruction endian-ness in bpf_jit_32.c Ben Dooks
2013-10-08 22:34 ` [PATCH 17/23] ARM: Correct BUG() assembly to ensure it is endian-agnostic Ben Dooks
2013-10-08 22:34 ` [PATCH 18/23] ARM: kdgb: use <asm/opcodes.h> for data to be assembled as intruction Ben Dooks
2013-10-08 22:34 ` [PATCH 19/23] ARM: atomic64: fix endian-ness in atomic.h Ben Dooks
2013-10-08 22:34 ` [PATCH 20/23] ARM: signal: sigreturn_codes should be endian neutral to work in BE8 Ben Dooks
2013-11-05 21:18 ` Uwe Kleine-König [this message]
2013-11-06 3:48 ` Victor Kamensky
2013-11-06 8:46 ` Uwe Kleine-König
2013-10-08 22:34 ` [PATCH 21/23] ARM: mcpm: fix big endian issue in mcpm startup code Ben Dooks
2013-10-08 22:34 ` [PATCH 22/23] ARM: cci: driver need big endian fixes in asm code Ben Dooks
2013-10-09 14:35 ` Dave Martin
2013-10-14 20:53 ` Ben Dooks
2013-10-15 1:40 ` Nicolas Pitre
2013-10-15 9:58 ` Ben Dooks
2013-10-08 22:34 ` [PATCH 23/23] ARM: tlb: ASID macro should give 32bit result for BE correct operation Ben Dooks
2013-10-09 6:20 ` New big-endian patch series against 3.12-rc4 Victor Kamensky
2013-10-09 7:10 ` Ben Dooks
2013-10-11 10:49 ` Marc Zyngier
2013-10-11 13:47 ` Thomas Petazzoni
2013-10-17 12:07 ` Thomas Petazzoni
2013-10-17 12:15 ` Will Deacon
2013-10-17 12:20 ` Thomas Petazzoni
2013-10-17 12:27 ` Will Deacon
2013-10-17 12:29 ` Thomas Petazzoni
[not found] <20131111141258.GA3166@localhost.localdomain>
2013-11-11 17:00 ` [PATCH 20/23] ARM: signal: sigreturn_codes should be endian neutral to work in BE8 Uwe Kleine-König
2013-11-12 6:41 ` Victor Kamensky
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=20131105211807.GR14892@pengutronix.de \
--to=u.kleine-koenig@pengutronix.de \
--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).