lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 12 Nov 2013 14:04:36 +0000
From:	Russell King - ARM Linux <linux@....linux.org.uk>
To:	Nicolas Pitre <nicolas.pitre@...aro.org>
Cc:	Stephen Boyd <sboyd@...eaurora.org>,
	linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
	Jean-Christophe PLAGNIOL-VILLARD <plagnioj@...osoft.com>,
	Christopher Covington <cov@...eaurora.org>,
	Måns Rullgård <mans@...sr.com>,
	Rob Herring <robherring2@...il.com>
Subject: Re: [PATCH v2] ARM: Use udiv/sdiv for __aeabi_{u}idiv library
	functions

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?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ