Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1274635

Re: [RFC/PATCH 3/3] ARM: Replace calls to __aeabi_{u}idiv with udiv/sdiv instructions

From Måns Rullgård <mans@mansr.com>
Newsgroups linux.kernel
Subject Re: [RFC/PATCH 3/3] ARM: Replace calls to __aeabi_{u}idiv with udiv/sdiv instructions
Date 2015-11-21 13:00 +0100
Message-ID <qxeZI-4Mi-5@gated-at.bofh.it> (permalink)
References <qx5a1-6MK-1@gated-at.bofh.it> <qx5a1-6MK-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Stephen Boyd <sboyd@codeaurora.org> writes:

> +static int module_patch_aeabi_uidiv(unsigned long loc, const Elf32_Sym *sym)
> +{
> +	extern char __aeabi_uidiv[], __aeabi_idiv[];
> +	unsigned long udiv_addr = (unsigned long)__aeabi_uidiv;
> +	unsigned long sdiv_addr = (unsigned long)__aeabi_idiv;
> +	unsigned int udiv_insn, sdiv_insn, mask;
> +
> +	if (IS_ENABLED(CONFIG_THUMB2_KERNEL)) {
> +		mask = HWCAP_IDIVT;
> +		udiv_insn = __opcode_to_mem_thumb32(0xfbb0f0f1);
> +		sdiv_insn = __opcode_to_mem_thumb32(0xfb90f0f1);
> +	} else {
> +		mask = HWCAP_IDIVA;
> +		udiv_insn = __opcode_to_mem_arm(0xe730f110);
> +		sdiv_insn = __opcode_to_mem_arm(0xe710f110);
> +	}
> +
> +	if (elf_hwcap & mask) {
> +		if (sym->st_value == udiv_addr) {
> +			*(u32 *)loc = udiv_insn;
> +			return 1;
> +		} else if (sym->st_value == sdiv_addr) {
> +			*(u32 *)loc = sdiv_insn;
> +			return 1;
> +		}
> +	}
> +
> +	return 0;
> +}

[...]

> +static void __init patch_aeabi_uidiv(void)
> +{
> +	extern unsigned long *__start_udiv_loc[], *__stop_udiv_loc[];
> +	extern unsigned long *__start_idiv_loc[], *__stop_idiv_loc[];
> +	unsigned long **p;
> +	unsigned int udiv_insn, sdiv_insn, mask;
> +
> +	if (IS_ENABLED(CONFIG_THUMB2_KERNEL)) {
> +		mask = HWCAP_IDIVT;
> +		udiv_insn = __opcode_to_mem_thumb32(0xfbb0f0f1);
> +		sdiv_insn = __opcode_to_mem_thumb32(0xfb90f0f1);
> +	} else {
> +		mask = HWCAP_IDIVA;
> +		udiv_insn = __opcode_to_mem_arm(0xe730f110);
> +		sdiv_insn = __opcode_to_mem_arm(0xe710f110);
> +	}
> +
> +	if (elf_hwcap & mask) {
> +		for (p = __start_udiv_loc; p < __stop_udiv_loc; p++) {
> +			unsigned long *inst = *p;
> +			*inst = udiv_insn;
> +		}
> +		for (p = __start_idiv_loc; p < __stop_idiv_loc; p++) {
> +			unsigned long *inst = *p;
> +			*inst = sdiv_insn;
> +		}
> +	}
> +}

These functions are rather similar.  Perhaps they could be combined
somehow.

-- 
Måns Rullgård
mans@mansr.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library functions Stephen Boyd <sboyd@codeaurora.org> - 2015-11-21 02:30 +0100
  [RFC/PATCH 2/3] recordmcount: Record locations of __aeabi_{u}idiv() calls on ARM Stephen Boyd <sboyd@codeaurora.org> - 2015-11-21 02:30 +0100
    Re: [RFC/PATCH 2/3] recordmcount: Record locations of  __aeabi_{u}idiv() calls on ARM Russell King - ARM Linux <linux@arm.linux.org.uk> - 2015-11-21 11:20 +0100
      Re: [RFC/PATCH 2/3] recordmcount: Record locations of  __aeabi_{u}idiv() calls on ARM Steven Rostedt <rostedt@goodmis.org> - 2015-11-23 22:00 +0100
      Re: [RFC/PATCH 2/3] recordmcount: Record locations of  __aeabi_{u}idiv() calls on ARM Stephen Boyd <sboyd@codeaurora.org> - 2015-11-23 22:00 +0100
        Re: [RFC/PATCH 2/3] recordmcount: Record locations of  __aeabi_{u}idiv() calls on ARM Russell King - ARM Linux <linux@arm.linux.org.uk> - 2015-11-23 22:10 +0100
          Re: [RFC/PATCH 2/3] recordmcount: Record locations of  __aeabi_{u}idiv() calls on ARM Stephen Boyd <sboyd@codeaurora.org> - 2015-11-23 22:20 +0100
            Re: [RFC/PATCH 2/3] recordmcount: Record locations of  __aeabi_{u}idiv() calls on ARM Russell King - ARM Linux <linux@arm.linux.org.uk> - 2015-11-23 22:40 +0100
              Re: [RFC/PATCH 2/3] recordmcount: Record locations of  __aeabi_{u}idiv() calls on ARM Stephen Boyd <sboyd@codeaurora.org> - 2015-11-24 02:10 +0100
  [RFC/PATCH 1/3] scripts: Allow recordmcount to be used without tracing enabled Stephen Boyd <sboyd@codeaurora.org> - 2015-11-21 02:30 +0100
  [RFC/PATCH 3/3] ARM: Replace calls to __aeabi_{u}idiv with udiv/sdiv instructions Stephen Boyd <sboyd@codeaurora.org> - 2015-11-21 02:30 +0100
    Re: [RFC/PATCH 3/3] ARM: Replace calls to __aeabi_{u}idiv with udiv/sdiv instructions Måns Rullgård <mans@mansr.com> - 2015-11-21 13:00 +0100
      Re: [RFC/PATCH 3/3] ARM: Replace calls to __aeabi_{u}idiv with  udiv/sdiv instructions Stephen Boyd <sboyd@codeaurora.org> - 2015-11-23 22:00 +0100
        Re: [RFC/PATCH 3/3] ARM: Replace calls to __aeabi_{u}idiv with udiv/sdiv instructions Måns Rullgård <mans@mansr.com> - 2015-11-23 22:00 +0100
          Re: [RFC/PATCH 3/3] ARM: Replace calls to __aeabi_{u}idiv with  udiv/sdiv instructions Stephen Boyd <sboyd@codeaurora.org> - 2015-11-23 22:20 +0100
  Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library functions Måns Rullgård <mans@mansr.com> - 2015-11-21 21:50 +0100
    Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library functions Arnd Bergmann <arnd@arndb.de> - 2015-11-21 22:10 +0100
      Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library functions Måns Rullgård <mans@mansr.com> - 2015-11-21 23:20 +0100
        Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library functions Arnd Bergmann <arnd@arndb.de> - 2015-11-22 00:20 +0100
          Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library functions Arnd Bergmann <arnd@arndb.de> - 2015-11-22 00:30 +0100
            Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library functions Peter Maydell <peter.maydell@linaro.org> - 2015-11-22 14:40 +0100
              Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library functions Arnd Bergmann <arnd@arndb.de> - 2015-11-22 20:30 +0100
                Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library functions Måns Rullgård <mans@mansr.com> - 2015-11-22 20:40 +0100
                Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library  functions Russell King - ARM Linux <linux@arm.linux.org.uk> - 2015-11-22 20:50 +0100
                Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library functions Arnd Bergmann <arnd@arndb.de> - 2015-11-22 21:00 +0100
                Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library  functions Russell King - ARM Linux <linux@arm.linux.org.uk> - 2015-11-22 21:10 +0100
                Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library functions Arnd Bergmann <arnd@arndb.de> - 2015-11-22 21:40 +0100
                Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library functions Måns Rullgård <mans@mansr.com> - 2015-11-22 21:50 +0100
                Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library functions Arnd Bergmann <arnd@arndb.de> - 2015-11-22 22:20 +0100
                Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library  functions Nicolas Pitre <nicolas.pitre@linaro.org> - 2015-11-23 03:40 +0100
                Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library functions Arnd Bergmann <arnd@arndb.de> - 2015-11-23 09:20 +0100
                Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv  library functions Christopher Covington <cov@codeaurora.org> - 2015-11-23 15:20 +0100
                Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library functions Arnd Bergmann <arnd@arndb.de> - 2015-11-23 16:40 +0100
                Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library  functions Stephen Boyd <sboyd@codeaurora.org> - 2015-11-23 21:40 +0100
                Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library functions Arnd Bergmann <arnd@arndb.de> - 2015-11-23 22:30 +0100
                Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library  functions Stephen Boyd <sboyd@codeaurora.org> - 2015-11-23 22:40 +0100
                Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library functions Arnd Bergmann <arnd@arndb.de> - 2015-11-23 23:00 +0100
                Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library  functions Stephen Boyd <sboyd@codeaurora.org> - 2015-11-24 00:20 +0100
                Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library functions Arnd Bergmann <arnd@arndb.de> - 2015-11-24 11:20 +0100
                Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library functions Måns Rullgård <mans@mansr.com> - 2015-11-24 13:20 +0100
                Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library functions Arnd Bergmann <arnd@arndb.de> - 2015-11-24 14:50 +0100
                Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library  functions Stephen Boyd <sboyd@codeaurora.org> - 2015-11-25 03:00 +0100
                Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library functions Arnd Bergmann <arnd@arndb.de> - 2015-11-25 08:30 +0100
                Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library  functions Stephen Boyd <sboyd@codeaurora.org> - 2015-11-24 01:20 +0100
                Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library  functions Stephen Boyd <sboyd@codeaurora.org> - 2015-11-24 10:00 +0100
                Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library functions Arnd Bergmann <arnd@arndb.de> - 2015-11-24 11:40 +0100
                Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library  functions Russell King - ARM Linux <linux@arm.linux.org.uk> - 2015-11-24 11:50 +0100
                Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library functions Måns Rullgård <mans@mansr.com> - 2015-11-24 13:20 +0100
                Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library functions Måns Rullgård <mans@mansr.com> - 2015-11-24 13:30 +0100
                Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library functions Måns Rullgård <mans@mansr.com> - 2015-11-24 15:10 +0100
                Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library  functions Russell King - ARM Linux <linux@arm.linux.org.uk> - 2015-11-24 15:10 +0100
                Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library  functions Russell King - ARM Linux <linux@arm.linux.org.uk> - 2015-11-24 13:30 +0100
                Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library  functions Russell King - ARM Linux <linux@arm.linux.org.uk> - 2015-11-24 11:50 +0100
                Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library  functions Stephen Boyd <sboyd@codeaurora.org> - 2015-11-24 21:10 +0100
                Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library  functions Russell King - ARM Linux <linux@arm.linux.org.uk> - 2015-11-24 21:40 +0100
                Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library functions Arnd Bergmann <arnd@arndb.de> - 2015-11-24 22:20 +0100
                Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library  functions Russell King - ARM Linux <linux@arm.linux.org.uk> - 2015-11-24 11:40 +0100
  Re: [RFC/PATCH 0/3] ARM: Use udiv/sdiv for __aeabi_{u}idiv library functions Arnd Bergmann <arnd@arndb.de> - 2015-11-21 21:50 +0100

csiph-web