From: ben.dooks@codethink.co.uk (Ben Dooks)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2] ARM: Use udiv/sdiv for __aeabi_{u}idiv library functions
Date: Tue, 12 Nov 2013 14:17:27 +0000 [thread overview]
Message-ID: <52823877.60806@codethink.co.uk> (raw)
In-Reply-To: <20131112140436.GK16735@n2100.arm.linux.org.uk>
On 12/11/13 14:04, Russell King - ARM Linux wrote:
> On Tue, Nov 12, 2013 at 09:01:16AM -0500, Nicolas Pitre wrote:
>> What about this patch which I think is currently your best option. Note
>> it would need to use the facilities from asm/opcodes.h to make it endian
>> agnostic.
>>
>> diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
>> index 6a1b8a81b1..379cffe4ab 100644
>> --- a/arch/arm/kernel/setup.c
>> +++ b/arch/arm/kernel/setup.c
>> @@ -383,6 +383,34 @@ static void __init cpuid_init_hwcaps(void)
>> elf_hwcap |= HWCAP_IDIVT;
>> }
>>
>> + /*
>> + * Patch our division routines with the corresponding opcode
>> + * if the hardware supports it.
>> + */
>> + if (IS_ENABLED(CONFIG_THUMB2_KERNEL) && (elf_hwcap & HWCAP_IDIVT)) {
>> + extern char __aeabi_uidiv, __aeabi_idiv;
>> + u16 *uidiv = (u16 *)&__aeabi_uidiv;
>> + u16 *idiv = (u16 *)&__aeabi_idiv;
>> +
>> + uidiv[0] = 0xfbb0; /* udiv r0, r0, r1 */
>> + uidiv[1] = 0xf0f1;
>> + uidiv[2] = 0x4770; /* bx lr */
>> +
>> + idiv[0] = 0xfb90; /* sdiv r0, r0, r1 */
>> + idiv[1] = 0xf0f1;
>> + idiv[2] = 0x4770; /* bx lr */
>> + } else if (!IS_ENABLED(CONFIG_THUMB2_KERNEL) && (elf_hwcap & HWCAP_IDIVA)) {
>> + extern char __aeabi_uidiv, __aeabi_idiv;
>> + u32 *uidiv = (u32 *)&__aeabi_uidiv;
>> + u32 *idiv = (u32 *)&__aeabi_idiv;
>> +
>> + uidiv[0] = 0xe730f110; /* udiv r0, r0, r1 */
>> + uidiv[1] = 0xe12fff1e; /* bx lr */
>> +
>> + idiv[0] = 0xe710f110; /* sdiv r0, r0, r1 */
>> + idiv[1] = 0xe12fff1e; /* bx lr */
>> + }
>
> What about endianness, and what if XIP is enabled?
I was also going to add a note about endian-ness.
Given these are single instructoins for ARM, is it possible we could
make a table of all the callers and fix them up when we initialise
as we do for the SMP/UP case and for page-offset?
--
Ben Dooks http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
WARNING: multiple messages have this Message-ID (diff)
From: Ben Dooks <ben.dooks@codethink.co.uk>
To: Russell King - ARM Linux <linux@arm.linux.org.uk>
Cc: "Nicolas Pitre" <nicolas.pitre@linaro.org>,
"Måns Rullgård" <mans@mansr.com>,
"Stephen Boyd" <sboyd@codeaurora.org>,
linux-kernel@vger.kernel.org,
"Christopher Covington" <cov@codeaurora.org>,
"Jean-Christophe PLAGNIOL-VILLARD" <plagnioj@jcrosoft.com>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2] ARM: Use udiv/sdiv for __aeabi_{u}idiv library functions
Date: Tue, 12 Nov 2013 14:17:27 +0000 [thread overview]
Message-ID: <52823877.60806@codethink.co.uk> (raw)
In-Reply-To: <20131112140436.GK16735@n2100.arm.linux.org.uk>
On 12/11/13 14:04, Russell King - ARM Linux wrote:
> On Tue, Nov 12, 2013 at 09:01:16AM -0500, Nicolas Pitre wrote:
>> What about this patch which I think is currently your best option. Note
>> it would need to use the facilities from asm/opcodes.h to make it endian
>> agnostic.
>>
>> diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
>> index 6a1b8a81b1..379cffe4ab 100644
>> --- a/arch/arm/kernel/setup.c
>> +++ b/arch/arm/kernel/setup.c
>> @@ -383,6 +383,34 @@ static void __init cpuid_init_hwcaps(void)
>> elf_hwcap |= HWCAP_IDIVT;
>> }
>>
>> + /*
>> + * Patch our division routines with the corresponding opcode
>> + * if the hardware supports it.
>> + */
>> + if (IS_ENABLED(CONFIG_THUMB2_KERNEL) && (elf_hwcap & HWCAP_IDIVT)) {
>> + extern char __aeabi_uidiv, __aeabi_idiv;
>> + u16 *uidiv = (u16 *)&__aeabi_uidiv;
>> + u16 *idiv = (u16 *)&__aeabi_idiv;
>> +
>> + uidiv[0] = 0xfbb0; /* udiv r0, r0, r1 */
>> + uidiv[1] = 0xf0f1;
>> + uidiv[2] = 0x4770; /* bx lr */
>> +
>> + idiv[0] = 0xfb90; /* sdiv r0, r0, r1 */
>> + idiv[1] = 0xf0f1;
>> + idiv[2] = 0x4770; /* bx lr */
>> + } else if (!IS_ENABLED(CONFIG_THUMB2_KERNEL) && (elf_hwcap & HWCAP_IDIVA)) {
>> + extern char __aeabi_uidiv, __aeabi_idiv;
>> + u32 *uidiv = (u32 *)&__aeabi_uidiv;
>> + u32 *idiv = (u32 *)&__aeabi_idiv;
>> +
>> + uidiv[0] = 0xe730f110; /* udiv r0, r0, r1 */
>> + uidiv[1] = 0xe12fff1e; /* bx lr */
>> +
>> + idiv[0] = 0xe710f110; /* sdiv r0, r0, r1 */
>> + idiv[1] = 0xe12fff1e; /* bx lr */
>> + }
>
> What about endianness, and what if XIP is enabled?
I was also going to add a note about endian-ness.
Given these are single instructoins for ARM, is it possible we could
make a table of all the callers and fix them up when we initialise
as we do for the SMP/UP case and for page-offset?
--
Ben Dooks http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
next prev parent reply other threads:[~2013-11-12 14:17 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-08 23:00 [PATCH v2] ARM: Use udiv/sdiv for __aeabi_{u}idiv library functions Stephen Boyd
2013-11-08 23:00 ` Stephen Boyd
2013-11-09 6:46 ` Matt Sealey
2013-11-09 6:46 ` Matt Sealey
2013-11-09 18:20 ` Måns Rullgård
2013-11-09 18:20 ` Måns Rullgård
2013-11-12 1:23 ` Stephen Boyd
2013-11-12 1:23 ` Stephen Boyd
2013-11-10 5:03 ` Nicolas Pitre
2013-11-10 5:03 ` Nicolas Pitre
2013-11-12 2:34 ` Stephen Boyd
2013-11-12 2:34 ` Stephen Boyd
2013-11-12 11:28 ` Måns Rullgård
2013-11-12 11:28 ` Måns Rullgård
2013-11-12 14:01 ` Nicolas Pitre
2013-11-12 14:01 ` Nicolas Pitre
2013-11-12 14:04 ` Russell King - ARM Linux
2013-11-12 14:04 ` Russell King - ARM Linux
2013-11-12 14:16 ` Nicolas Pitre
2013-11-12 14:16 ` Nicolas Pitre
2013-11-12 14:17 ` Ben Dooks [this message]
2013-11-12 14:17 ` Ben Dooks
2013-11-12 14:32 ` Nicolas Pitre
2013-11-12 14:32 ` Nicolas Pitre
2013-11-12 14:40 ` Måns Rullgård
2013-11-12 14:40 ` Måns Rullgård
2013-11-12 14:55 ` Nicolas Pitre
2013-11-12 14:55 ` Nicolas Pitre
2013-11-12 15:20 ` Nicolas Pitre
2013-11-12 15:20 ` Nicolas Pitre
2013-11-12 18:03 ` Måns Rullgård
2013-11-12 18:03 ` Måns Rullgård
2013-11-12 14:22 ` Måns Rullgård
2013-11-12 14:22 ` Måns Rullgård
2013-11-12 14:36 ` Nicolas Pitre
2013-11-12 14:36 ` Nicolas Pitre
2013-11-11 7:46 ` Uwe Kleine-König
2013-11-11 7:46 ` Uwe Kleine-König
2013-11-12 2:35 ` Stephen Boyd
2013-11-12 2:35 ` Stephen Boyd
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=52823877.60806@codethink.co.uk \
--to=ben.dooks@codethink.co.uk \
--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 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.