* [PATCH] ARM: asm: Rewrite get_thread_info using BIC
@ 2020-05-27 12:22 Linus Walleij
2020-05-27 13:13 ` Russell King - ARM Linux admin
2020-07-21 13:37 ` Dmitry Osipenko
0 siblings, 2 replies; 6+ messages in thread
From: Linus Walleij @ 2020-05-27 12:22 UTC (permalink / raw)
To: Russell King; +Cc: Linus Walleij, Ard Biesheuvel, linux-arm-kernel
By using two BIC instructions we can replace the ARM/thumb
split instructions with something that works on either
and also save one instruction.
Based on code from proc-macros.S and an idea from Ard
Biesheuvel.
We need to include <linux/const.h> to expand the
THREAD_SIZE definition properly in the preprocessor.
Suggested-by: Russell King <linux@armlinux.org.uk>
Suggested-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
arch/arm/include/asm/assembler.h | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/arch/arm/include/asm/assembler.h b/arch/arm/include/asm/assembler.h
index 99929122dad7..f218e8cf7f88 100644
--- a/arch/arm/include/asm/assembler.h
+++ b/arch/arm/include/asm/assembler.h
@@ -17,6 +17,7 @@
#error "Only include this from assembly code"
#endif
+#include <linux/const.h>
#include <asm/ptrace.h>
#include <asm/domain.h>
#include <asm/opcodes-virt.h>
@@ -203,10 +204,8 @@
* Get current thread_info.
*/
.macro get_thread_info, rd
- ARM( mov \rd, sp, lsr #THREAD_SIZE_ORDER + PAGE_SHIFT )
- THUMB( mov \rd, sp )
- THUMB( lsr \rd, \rd, #THREAD_SIZE_ORDER + PAGE_SHIFT )
- mov \rd, \rd, lsl #THREAD_SIZE_ORDER + PAGE_SHIFT
+ bic \rd, sp, #(THREAD_SIZE - 1) & ~63
+ bic \rd, \rd, #63
.endm
/*
--
2.25.4
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] ARM: asm: Rewrite get_thread_info using BIC
2020-05-27 12:22 [PATCH] ARM: asm: Rewrite get_thread_info using BIC Linus Walleij
@ 2020-05-27 13:13 ` Russell King - ARM Linux admin
2020-07-21 13:37 ` Dmitry Osipenko
1 sibling, 0 replies; 6+ messages in thread
From: Russell King - ARM Linux admin @ 2020-05-27 13:13 UTC (permalink / raw)
To: Linus Walleij; +Cc: Ard Biesheuvel, linux-arm-kernel
On Wed, May 27, 2020 at 02:22:01PM +0200, Linus Walleij wrote:
> By using two BIC instructions we can replace the ARM/thumb
> split instructions with something that works on either
> and also save one instruction.
>
> Based on code from proc-macros.S and an idea from Ard
> Biesheuvel.
>
> We need to include <linux/const.h> to expand the
> THREAD_SIZE definition properly in the preprocessor.
>
> Suggested-by: Russell King <linux@armlinux.org.uk>
> Suggested-by: Ard Biesheuvel <ardb@kernel.org>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Looks good to me, thanks.
> ---
> arch/arm/include/asm/assembler.h | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/arch/arm/include/asm/assembler.h b/arch/arm/include/asm/assembler.h
> index 99929122dad7..f218e8cf7f88 100644
> --- a/arch/arm/include/asm/assembler.h
> +++ b/arch/arm/include/asm/assembler.h
> @@ -17,6 +17,7 @@
> #error "Only include this from assembly code"
> #endif
>
> +#include <linux/const.h>
> #include <asm/ptrace.h>
> #include <asm/domain.h>
> #include <asm/opcodes-virt.h>
> @@ -203,10 +204,8 @@
> * Get current thread_info.
> */
> .macro get_thread_info, rd
> - ARM( mov \rd, sp, lsr #THREAD_SIZE_ORDER + PAGE_SHIFT )
> - THUMB( mov \rd, sp )
> - THUMB( lsr \rd, \rd, #THREAD_SIZE_ORDER + PAGE_SHIFT )
> - mov \rd, \rd, lsl #THREAD_SIZE_ORDER + PAGE_SHIFT
> + bic \rd, sp, #(THREAD_SIZE - 1) & ~63
> + bic \rd, \rd, #63
> .endm
>
> /*
> --
> 2.25.4
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC for 0.8m (est. 1762m) line in suburbia: sync at 13.1Mbps down 424kbps up
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ARM: asm: Rewrite get_thread_info using BIC
2020-05-27 12:22 [PATCH] ARM: asm: Rewrite get_thread_info using BIC Linus Walleij
2020-05-27 13:13 ` Russell King - ARM Linux admin
@ 2020-07-21 13:37 ` Dmitry Osipenko
2020-07-21 13:38 ` Russell King - ARM Linux admin
2020-07-21 13:54 ` Linus Walleij
1 sibling, 2 replies; 6+ messages in thread
From: Dmitry Osipenko @ 2020-07-21 13:37 UTC (permalink / raw)
To: Linus Walleij, Russell King; +Cc: Ard Biesheuvel, linux-arm-kernel
27.05.2020 15:22, Linus Walleij пишет:
> By using two BIC instructions we can replace the ARM/thumb
> split instructions with something that works on either
> and also save one instruction.
>
> Based on code from proc-macros.S and an idea from Ard
> Biesheuvel.
>
> We need to include <linux/const.h> to expand the
> THREAD_SIZE definition properly in the preprocessor.
>
> Suggested-by: Russell King <linux@armlinux.org.uk>
> Suggested-by: Ard Biesheuvel <ardb@kernel.org>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> arch/arm/include/asm/assembler.h | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/arch/arm/include/asm/assembler.h b/arch/arm/include/asm/assembler.h
> index 99929122dad7..f218e8cf7f88 100644
> --- a/arch/arm/include/asm/assembler.h
> +++ b/arch/arm/include/asm/assembler.h
> @@ -17,6 +17,7 @@
> #error "Only include this from assembly code"
> #endif
>
> +#include <linux/const.h>
> #include <asm/ptrace.h>
> #include <asm/domain.h>
> #include <asm/opcodes-virt.h>
> @@ -203,10 +204,8 @@
> * Get current thread_info.
> */
> .macro get_thread_info, rd
> - ARM( mov \rd, sp, lsr #THREAD_SIZE_ORDER + PAGE_SHIFT )
> - THUMB( mov \rd, sp )
> - THUMB( lsr \rd, \rd, #THREAD_SIZE_ORDER + PAGE_SHIFT )
> - mov \rd, \rd, lsl #THREAD_SIZE_ORDER + PAGE_SHIFT
> + bic \rd, sp, #(THREAD_SIZE - 1) & ~63
> + bic \rd, \rd, #63
> .endm
>
> /*
>
Hello, Linus!
This patch was merged into a recent linux-next, unfortunately it breaks
CONFIG_THUMB2_KERNEL=y compilation:
arch/arm/kernel/entry-common.S: Assembler messages:
arch/arm/kernel/entry-common.S:159: Error: r13 not allowed here -- `bic
tsk,sp,#(((1<<12)<<1)-1)&~63'
arch/arm/kernel/entry-common.S:246: Error: r13 not allowed here -- `bic
tsk,sp,#(((1<<12)<<1)-1)&~63'
make[2]: *** [scripts/Makefile.build:361:
arch/arm/kernel/entry-common.o] Error 1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ARM: asm: Rewrite get_thread_info using BIC
2020-07-21 13:37 ` Dmitry Osipenko
@ 2020-07-21 13:38 ` Russell King - ARM Linux admin
2020-07-21 13:39 ` Dmitry Osipenko
2020-07-21 13:54 ` Linus Walleij
1 sibling, 1 reply; 6+ messages in thread
From: Russell King - ARM Linux admin @ 2020-07-21 13:38 UTC (permalink / raw)
To: Dmitry Osipenko; +Cc: Linus Walleij, Ard Biesheuvel, linux-arm-kernel
On Tue, Jul 21, 2020 at 04:37:09PM +0300, Dmitry Osipenko wrote:
> 27.05.2020 15:22, Linus Walleij пишет:
> > By using two BIC instructions we can replace the ARM/thumb
> > split instructions with something that works on either
> > and also save one instruction.
> >
> > Based on code from proc-macros.S and an idea from Ard
> > Biesheuvel.
> >
> > We need to include <linux/const.h> to expand the
> > THREAD_SIZE definition properly in the preprocessor.
> >
> > Suggested-by: Russell King <linux@armlinux.org.uk>
> > Suggested-by: Ard Biesheuvel <ardb@kernel.org>
> > Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> > ---
> > arch/arm/include/asm/assembler.h | 7 +++----
> > 1 file changed, 3 insertions(+), 4 deletions(-)
> >
> > diff --git a/arch/arm/include/asm/assembler.h b/arch/arm/include/asm/assembler.h
> > index 99929122dad7..f218e8cf7f88 100644
> > --- a/arch/arm/include/asm/assembler.h
> > +++ b/arch/arm/include/asm/assembler.h
> > @@ -17,6 +17,7 @@
> > #error "Only include this from assembly code"
> > #endif
> >
> > +#include <linux/const.h>
> > #include <asm/ptrace.h>
> > #include <asm/domain.h>
> > #include <asm/opcodes-virt.h>
> > @@ -203,10 +204,8 @@
> > * Get current thread_info.
> > */
> > .macro get_thread_info, rd
> > - ARM( mov \rd, sp, lsr #THREAD_SIZE_ORDER + PAGE_SHIFT )
> > - THUMB( mov \rd, sp )
> > - THUMB( lsr \rd, \rd, #THREAD_SIZE_ORDER + PAGE_SHIFT )
> > - mov \rd, \rd, lsl #THREAD_SIZE_ORDER + PAGE_SHIFT
> > + bic \rd, sp, #(THREAD_SIZE - 1) & ~63
> > + bic \rd, \rd, #63
> > .endm
> >
> > /*
> >
>
> Hello, Linus!
>
> This patch was merged into a recent linux-next, unfortunately it breaks
> CONFIG_THUMB2_KERNEL=y compilation:
>
> arch/arm/kernel/entry-common.S: Assembler messages:
> arch/arm/kernel/entry-common.S:159: Error: r13 not allowed here -- `bic
> tsk,sp,#(((1<<12)<<1)-1)&~63'
> arch/arm/kernel/entry-common.S:246: Error: r13 not allowed here -- `bic
> tsk,sp,#(((1<<12)<<1)-1)&~63'
> make[2]: *** [scripts/Makefile.build:361:
> arch/arm/kernel/entry-common.o] Error 1
I've dropped it before you sent this email...
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ARM: asm: Rewrite get_thread_info using BIC
2020-07-21 13:38 ` Russell King - ARM Linux admin
@ 2020-07-21 13:39 ` Dmitry Osipenko
0 siblings, 0 replies; 6+ messages in thread
From: Dmitry Osipenko @ 2020-07-21 13:39 UTC (permalink / raw)
To: Russell King - ARM Linux admin
Cc: Linus Walleij, Ard Biesheuvel, linux-arm-kernel
21.07.2020 16:38, Russell King - ARM Linux admin пишет:
> On Tue, Jul 21, 2020 at 04:37:09PM +0300, Dmitry Osipenko wrote:
>> 27.05.2020 15:22, Linus Walleij пишет:
>>> By using two BIC instructions we can replace the ARM/thumb
>>> split instructions with something that works on either
>>> and also save one instruction.
>>>
>>> Based on code from proc-macros.S and an idea from Ard
>>> Biesheuvel.
>>>
>>> We need to include <linux/const.h> to expand the
>>> THREAD_SIZE definition properly in the preprocessor.
>>>
>>> Suggested-by: Russell King <linux@armlinux.org.uk>
>>> Suggested-by: Ard Biesheuvel <ardb@kernel.org>
>>> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
>>> ---
>>> arch/arm/include/asm/assembler.h | 7 +++----
>>> 1 file changed, 3 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/arch/arm/include/asm/assembler.h b/arch/arm/include/asm/assembler.h
>>> index 99929122dad7..f218e8cf7f88 100644
>>> --- a/arch/arm/include/asm/assembler.h
>>> +++ b/arch/arm/include/asm/assembler.h
>>> @@ -17,6 +17,7 @@
>>> #error "Only include this from assembly code"
>>> #endif
>>>
>>> +#include <linux/const.h>
>>> #include <asm/ptrace.h>
>>> #include <asm/domain.h>
>>> #include <asm/opcodes-virt.h>
>>> @@ -203,10 +204,8 @@
>>> * Get current thread_info.
>>> */
>>> .macro get_thread_info, rd
>>> - ARM( mov \rd, sp, lsr #THREAD_SIZE_ORDER + PAGE_SHIFT )
>>> - THUMB( mov \rd, sp )
>>> - THUMB( lsr \rd, \rd, #THREAD_SIZE_ORDER + PAGE_SHIFT )
>>> - mov \rd, \rd, lsl #THREAD_SIZE_ORDER + PAGE_SHIFT
>>> + bic \rd, sp, #(THREAD_SIZE - 1) & ~63
>>> + bic \rd, \rd, #63
>>> .endm
>>>
>>> /*
>>>
>>
>> Hello, Linus!
>>
>> This patch was merged into a recent linux-next, unfortunately it breaks
>> CONFIG_THUMB2_KERNEL=y compilation:
>>
>> arch/arm/kernel/entry-common.S: Assembler messages:
>> arch/arm/kernel/entry-common.S:159: Error: r13 not allowed here -- `bic
>> tsk,sp,#(((1<<12)<<1)-1)&~63'
>> arch/arm/kernel/entry-common.S:246: Error: r13 not allowed here -- `bic
>> tsk,sp,#(((1<<12)<<1)-1)&~63'
>> make[2]: *** [scripts/Makefile.build:361:
>> arch/arm/kernel/entry-common.o] Error 1
>
> I've dropped it before you sent this email...
Hello, Russell!
Good to know, thank you!
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ARM: asm: Rewrite get_thread_info using BIC
2020-07-21 13:37 ` Dmitry Osipenko
2020-07-21 13:38 ` Russell King - ARM Linux admin
@ 2020-07-21 13:54 ` Linus Walleij
1 sibling, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2020-07-21 13:54 UTC (permalink / raw)
To: Dmitry Osipenko; +Cc: Russell King, Linux ARM, Ard Biesheuvel
On Tue, Jul 21, 2020 at 3:37 PM Dmitry Osipenko <digetx@gmail.com> wrote:
> This patch was merged into a recent linux-next, unfortunately it breaks
> CONFIG_THUMB2_KERNEL=y compilation:
>
> arch/arm/kernel/entry-common.S: Assembler messages:
> arch/arm/kernel/entry-common.S:159: Error: r13 not allowed here -- `bic
> tsk,sp,#(((1<<12)<<1)-1)&~63'
> arch/arm/kernel/entry-common.S:246: Error: r13 not allowed here -- `bic
> tsk,sp,#(((1<<12)<<1)-1)&~63'
> make[2]: *** [scripts/Makefile.build:361:
> arch/arm/kernel/entry-common.o] Error 1
Ah how typical. I suppose we simply need to give up on this
idea to simplify using BIC. It was worth a try.
Yours,
Linus Walleij
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-07-21 13:56 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-27 12:22 [PATCH] ARM: asm: Rewrite get_thread_info using BIC Linus Walleij
2020-05-27 13:13 ` Russell King - ARM Linux admin
2020-07-21 13:37 ` Dmitry Osipenko
2020-07-21 13:38 ` Russell King - ARM Linux admin
2020-07-21 13:39 ` Dmitry Osipenko
2020-07-21 13:54 ` Linus Walleij
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.