* [PATCH v4] ARM: signal: fix armv7-m build issue in sigreturn_codes.S
@ 2013-11-20 7:21 Victor Kamensky
2013-11-20 7:21 ` Victor Kamensky
0 siblings, 1 reply; 4+ messages in thread
From: Victor Kamensky @ 2013-11-20 7:21 UTC (permalink / raw)
To: linux-arm-kernel
Hi,
Here is version 4 of fix to armv7-m build failure in
sigreturn_codes.S. The difference with version 3 is
fixed formating and renamed internally used macro
as per Dave's comments on [3].
Solution is based on .org directive Dave's suggestion
on last email in [1].
It uses conditional compilation and it uses .org
directive to keep sigreturn_codes layout.
Note I did not use ARM and THUMB macros because
those switch between CONFIG_THUMB2_KERNEL and not.
On v7a kernel we need both arm and thumb snipets
regardless of CONFIG_THUMB2_KERNEL setting.
And conditional compilation only kicks in with
CONFIG_CPU_THUMBONLY, for that local ARM_INSTR
macro is created.
Version 3 [3] conditional compilation and .org directive.
Pretty much the same code but incorrectly formated. Please
look at [3] for details.
Version 2 [2] tried to use '.acrh armv4t' directive
to allow both arm and thumb2 opcodes, but solution
deemed to be too fragile.
Version 1 [1] used conditional compilation and added
thumb2 nop instructions in CONFIG_CPU_THUMBONLY
Fix was tested
linux-next with efm32_defconfig build (along with few other fixes)
rmk-next BE/LE vexpress build/boot and LTP rt_sigaction0? tests run
Uwe tested version 1 and 3 with efm32
Thanks,
Victor
[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2013-November/210393.html
[2] http://lists.infradead.org/pipermail/linux-arm-kernel/2013-November/210949.html
[3] http://lists.infradead.org/pipermail/linux-arm-kernel/2013-November/212307.html
Victor Kamensky (1):
ARM: signal: fix armv7-m build issue in sigreturn_codes.S
arch/arm/kernel/sigreturn_codes.S | 40 ++++++++++++++++++++++++++++++---------
1 file changed, 31 insertions(+), 9 deletions(-)
--
1.8.1.4
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v4] ARM: signal: fix armv7-m build issue in sigreturn_codes.S
2013-11-20 7:21 [PATCH v4] ARM: signal: fix armv7-m build issue in sigreturn_codes.S Victor Kamensky
@ 2013-11-20 7:21 ` Victor Kamensky
2013-11-20 11:21 ` Dave Martin
0 siblings, 1 reply; 4+ messages in thread
From: Victor Kamensky @ 2013-11-20 7:21 UTC (permalink / raw)
To: linux-arm-kernel
After "ARM: signal: sigreturn_codes should be endian neutral to
work in BE8" commit, thumb only platforms, like armv7m, fails to
compile sigreturn_codes.S. The reason is that for such arch
values '.arm' directive and arm opcodes are not allowed.
Fix conditionally enables arm opcodes only if no CONFIG_CPU_THUMBONLY
defined and it uses .org instructions to keep sigreturn_codes
layout.
Suggested-by: Dave Martin <Dave.Martin@arm.com>
Signed-off-by: Victor Kamensky <victor.kamensky@linaro.org>
Tested-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de>
---
arch/arm/kernel/sigreturn_codes.S | 40 ++++++++++++++++++++++++++++++---------
1 file changed, 31 insertions(+), 9 deletions(-)
diff --git a/arch/arm/kernel/sigreturn_codes.S b/arch/arm/kernel/sigreturn_codes.S
index 3c5d0f2..b84d0cb 100644
--- a/arch/arm/kernel/sigreturn_codes.S
+++ b/arch/arm/kernel/sigreturn_codes.S
@@ -30,6 +30,27 @@
* snippets.
*/
+/*
+ * In CPU_THUMBONLY case kernel arm opcodes are not allowed.
+ * Note in this case codes skips those instructions but it uses .org
+ * directive to keep correct layout of sigreturn_codes array.
+ */
+#ifndef CONFIG_CPU_THUMBONLY
+#define ARM_OK(code...) code
+#else
+#define ARM_OK(code...)
+#endif
+
+ .macro arm_slot n
+ .org sigreturn_codes + 12 * (\n)
+ARM_OK( .arm )
+ .endm
+
+ .macro thumb_slot n
+ .org sigreturn_codes + 12 * (\n) + 8
+ .thumb
+ .endm
+
#if __LINUX_ARM_ARCH__ <= 4
/*
* Note we manually set minimally required arch that supports
@@ -45,26 +66,27 @@
.global sigreturn_codes
.type sigreturn_codes, #object
- .arm
+ .align
sigreturn_codes:
/* ARM sigreturn syscall code snippet */
- mov r7, #(__NR_sigreturn - __NR_SYSCALL_BASE)
- swi #(__NR_sigreturn)|(__NR_OABI_SYSCALL_BASE)
+ arm_slot 0
+ARM_OK( mov r7, #(__NR_sigreturn - __NR_SYSCALL_BASE) )
+ARM_OK( swi #(__NR_sigreturn)|(__NR_OABI_SYSCALL_BASE) )
/* Thumb sigreturn syscall code snippet */
- .thumb
+ thumb_slot 0
movs r7, #(__NR_sigreturn - __NR_SYSCALL_BASE)
swi #0
/* ARM sigreturn_rt syscall code snippet */
- .arm
- mov r7, #(__NR_rt_sigreturn - __NR_SYSCALL_BASE)
- swi #(__NR_rt_sigreturn)|(__NR_OABI_SYSCALL_BASE)
+ arm_slot 1
+ARM_OK( mov r7, #(__NR_rt_sigreturn - __NR_SYSCALL_BASE) )
+ARM_OK( swi #(__NR_rt_sigreturn)|(__NR_OABI_SYSCALL_BASE) )
/* Thumb sigreturn_rt syscall code snippet */
- .thumb
+ thumb_slot 1
movs r7, #(__NR_rt_sigreturn - __NR_SYSCALL_BASE)
swi #0
@@ -74,7 +96,7 @@ sigreturn_codes:
* it is thumb case or not, so we need additional
* word after real last entry.
*/
- .arm
+ arm_slot 2
.space 4
.size sigreturn_codes, . - sigreturn_codes
--
1.8.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v4] ARM: signal: fix armv7-m build issue in sigreturn_codes.S
2013-11-20 7:21 ` Victor Kamensky
@ 2013-11-20 11:21 ` Dave Martin
2013-11-21 6:24 ` Victor Kamensky
0 siblings, 1 reply; 4+ messages in thread
From: Dave Martin @ 2013-11-20 11:21 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, Nov 19, 2013 at 11:21:12PM -0800, Victor Kamensky wrote:
> After "ARM: signal: sigreturn_codes should be endian neutral to
> work in BE8" commit, thumb only platforms, like armv7m, fails to
> compile sigreturn_codes.S. The reason is that for such arch
> values '.arm' directive and arm opcodes are not allowed.
>
> Fix conditionally enables arm opcodes only if no CONFIG_CPU_THUMBONLY
> defined and it uses .org instructions to keep sigreturn_codes
> layout.
>
> Suggested-by: Dave Martin <Dave.Martin@arm.com>
> Signed-off-by: Victor Kamensky <victor.kamensky@linaro.org>
> Tested-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de>
I believe this looks correct now:
Reviewed-by: Dave Martin <Dave.Martin@arm.com>
Cheers
---Dave
> ---
> arch/arm/kernel/sigreturn_codes.S | 40 ++++++++++++++++++++++++++++++---------
> 1 file changed, 31 insertions(+), 9 deletions(-)
>
> diff --git a/arch/arm/kernel/sigreturn_codes.S b/arch/arm/kernel/sigreturn_codes.S
> index 3c5d0f2..b84d0cb 100644
> --- a/arch/arm/kernel/sigreturn_codes.S
> +++ b/arch/arm/kernel/sigreturn_codes.S
> @@ -30,6 +30,27 @@
> * snippets.
> */
>
> +/*
> + * In CPU_THUMBONLY case kernel arm opcodes are not allowed.
> + * Note in this case codes skips those instructions but it uses .org
> + * directive to keep correct layout of sigreturn_codes array.
> + */
> +#ifndef CONFIG_CPU_THUMBONLY
> +#define ARM_OK(code...) code
> +#else
> +#define ARM_OK(code...)
> +#endif
> +
> + .macro arm_slot n
> + .org sigreturn_codes + 12 * (\n)
> +ARM_OK( .arm )
> + .endm
> +
> + .macro thumb_slot n
> + .org sigreturn_codes + 12 * (\n) + 8
> + .thumb
> + .endm
> +
> #if __LINUX_ARM_ARCH__ <= 4
> /*
> * Note we manually set minimally required arch that supports
> @@ -45,26 +66,27 @@
> .global sigreturn_codes
> .type sigreturn_codes, #object
>
> - .arm
> + .align
>
> sigreturn_codes:
>
> /* ARM sigreturn syscall code snippet */
> - mov r7, #(__NR_sigreturn - __NR_SYSCALL_BASE)
> - swi #(__NR_sigreturn)|(__NR_OABI_SYSCALL_BASE)
> + arm_slot 0
> +ARM_OK( mov r7, #(__NR_sigreturn - __NR_SYSCALL_BASE) )
> +ARM_OK( swi #(__NR_sigreturn)|(__NR_OABI_SYSCALL_BASE) )
>
> /* Thumb sigreturn syscall code snippet */
> - .thumb
> + thumb_slot 0
> movs r7, #(__NR_sigreturn - __NR_SYSCALL_BASE)
> swi #0
>
> /* ARM sigreturn_rt syscall code snippet */
> - .arm
> - mov r7, #(__NR_rt_sigreturn - __NR_SYSCALL_BASE)
> - swi #(__NR_rt_sigreturn)|(__NR_OABI_SYSCALL_BASE)
> + arm_slot 1
> +ARM_OK( mov r7, #(__NR_rt_sigreturn - __NR_SYSCALL_BASE) )
> +ARM_OK( swi #(__NR_rt_sigreturn)|(__NR_OABI_SYSCALL_BASE) )
>
> /* Thumb sigreturn_rt syscall code snippet */
> - .thumb
> + thumb_slot 1
> movs r7, #(__NR_rt_sigreturn - __NR_SYSCALL_BASE)
> swi #0
>
> @@ -74,7 +96,7 @@ sigreturn_codes:
> * it is thumb case or not, so we need additional
> * word after real last entry.
> */
> - .arm
> + arm_slot 2
> .space 4
>
> .size sigreturn_codes, . - sigreturn_codes
> --
> 1.8.1.4
>
>
> _______________________________________________
> linaro-kernel mailing list
> linaro-kernel at lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/linaro-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v4] ARM: signal: fix armv7-m build issue in sigreturn_codes.S
2013-11-20 11:21 ` Dave Martin
@ 2013-11-21 6:24 ` Victor Kamensky
0 siblings, 0 replies; 4+ messages in thread
From: Victor Kamensky @ 2013-11-21 6:24 UTC (permalink / raw)
To: linux-arm-kernel
On 20 November 2013 03:21, Dave Martin <Dave.Martin@arm.com> wrote:
> On Tue, Nov 19, 2013 at 11:21:12PM -0800, Victor Kamensky wrote:
>> After "ARM: signal: sigreturn_codes should be endian neutral to
>> work in BE8" commit, thumb only platforms, like armv7m, fails to
>> compile sigreturn_codes.S. The reason is that for such arch
>> values '.arm' directive and arm opcodes are not allowed.
>>
>> Fix conditionally enables arm opcodes only if no CONFIG_CPU_THUMBONLY
>> defined and it uses .org instructions to keep sigreturn_codes
>> layout.
>>
>> Suggested-by: Dave Martin <Dave.Martin@arm.com>
>> Signed-off-by: Victor Kamensky <victor.kamensky@linaro.org>
>> Tested-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de>
>
> I believe this looks correct now:
>
> Reviewed-by: Dave Martin <Dave.Martin@arm.com>
It is posted to Russell's patch system now.
Dave, thank you very much for help and guidance.
Uwe, thank you for reporting, testing.
Thanks,
Victor
> Cheers
> ---Dave
>
>> ---
>> arch/arm/kernel/sigreturn_codes.S | 40 ++++++++++++++++++++++++++++++---------
>> 1 file changed, 31 insertions(+), 9 deletions(-)
>>
>> diff --git a/arch/arm/kernel/sigreturn_codes.S b/arch/arm/kernel/sigreturn_codes.S
>> index 3c5d0f2..b84d0cb 100644
>> --- a/arch/arm/kernel/sigreturn_codes.S
>> +++ b/arch/arm/kernel/sigreturn_codes.S
>> @@ -30,6 +30,27 @@
>> * snippets.
>> */
>>
>> +/*
>> + * In CPU_THUMBONLY case kernel arm opcodes are not allowed.
>> + * Note in this case codes skips those instructions but it uses .org
>> + * directive to keep correct layout of sigreturn_codes array.
>> + */
>> +#ifndef CONFIG_CPU_THUMBONLY
>> +#define ARM_OK(code...) code
>> +#else
>> +#define ARM_OK(code...)
>> +#endif
>> +
>> + .macro arm_slot n
>> + .org sigreturn_codes + 12 * (\n)
>> +ARM_OK( .arm )
>> + .endm
>> +
>> + .macro thumb_slot n
>> + .org sigreturn_codes + 12 * (\n) + 8
>> + .thumb
>> + .endm
>> +
>> #if __LINUX_ARM_ARCH__ <= 4
>> /*
>> * Note we manually set minimally required arch that supports
>> @@ -45,26 +66,27 @@
>> .global sigreturn_codes
>> .type sigreturn_codes, #object
>>
>> - .arm
>> + .align
>>
>> sigreturn_codes:
>>
>> /* ARM sigreturn syscall code snippet */
>> - mov r7, #(__NR_sigreturn - __NR_SYSCALL_BASE)
>> - swi #(__NR_sigreturn)|(__NR_OABI_SYSCALL_BASE)
>> + arm_slot 0
>> +ARM_OK( mov r7, #(__NR_sigreturn - __NR_SYSCALL_BASE) )
>> +ARM_OK( swi #(__NR_sigreturn)|(__NR_OABI_SYSCALL_BASE) )
>>
>> /* Thumb sigreturn syscall code snippet */
>> - .thumb
>> + thumb_slot 0
>> movs r7, #(__NR_sigreturn - __NR_SYSCALL_BASE)
>> swi #0
>>
>> /* ARM sigreturn_rt syscall code snippet */
>> - .arm
>> - mov r7, #(__NR_rt_sigreturn - __NR_SYSCALL_BASE)
>> - swi #(__NR_rt_sigreturn)|(__NR_OABI_SYSCALL_BASE)
>> + arm_slot 1
>> +ARM_OK( mov r7, #(__NR_rt_sigreturn - __NR_SYSCALL_BASE) )
>> +ARM_OK( swi #(__NR_rt_sigreturn)|(__NR_OABI_SYSCALL_BASE) )
>>
>> /* Thumb sigreturn_rt syscall code snippet */
>> - .thumb
>> + thumb_slot 1
>> movs r7, #(__NR_rt_sigreturn - __NR_SYSCALL_BASE)
>> swi #0
>>
>> @@ -74,7 +96,7 @@ sigreturn_codes:
>> * it is thumb case or not, so we need additional
>> * word after real last entry.
>> */
>> - .arm
>> + arm_slot 2
>> .space 4
>>
>> .size sigreturn_codes, . - sigreturn_codes
>> --
>> 1.8.1.4
>>
>>
>> _______________________________________________
>> linaro-kernel mailing list
>> linaro-kernel at lists.linaro.org
>> http://lists.linaro.org/mailman/listinfo/linaro-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-11-21 6:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-20 7:21 [PATCH v4] ARM: signal: fix armv7-m build issue in sigreturn_codes.S Victor Kamensky
2013-11-20 7:21 ` Victor Kamensky
2013-11-20 11:21 ` Dave Martin
2013-11-21 6:24 ` 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).