@@ -113,7 +113,7 @@ endif
endif
# Need -Uarm for gcc < 3.x
-KBUILD_CFLAGS +=$(CFLAGS_ABI) $(CFLAGS_THUMB2) $(arch-y) $(tune-y) $(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,)) -msoft-float -Uarm
+KBUILD_CFLAGS +=$(CFLAGS_ABI) $(CFLAGS_THUMB2) $(arch-y) $(tune-y) $(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,)) -msoft-float -Uarm -include asm/divhack.h
KBUILD_AFLAGS +=$(CFLAGS_ABI) $(AFLAGS_THUMB2) $(arch-y) $(tune-y) -include asm/unified.h -msoft-float
CHECKFLAGS += -D__arm__
new file mode 100644
@@ -0,0 +1,23 @@
+__asm__ (".macro dobl tgt \n"
+ " .ifc \\tgt, __aeabi_idiv \n"
+ " .L.sdiv.\\@: \n"
+ " .pushsection .sdiv_tab.init, \"a\", %progbits \n"
+ " .word .L.sdiv.\\@ \n"
+ " .popsection \n"
+ " .endif \n"
+ " .ifc \\tgt, __aeabi_uidiv \n"
+ " .L.udiv.\\@: \n"
+ " .pushsection .udiv_tab.init, \"a\", %progbits \n"
+ " .word .L.udiv.\\@ \n"
+ " .popsection \n"
+ " .endif \n"
+ " bl \\tgt \n"
+ ".endm \n"
+ ".macro defbl \n"
+ " .macro bl tgt \n"
+ " .purgem bl \n"
+ " dobl \\tgt \n"
+ " defbl \n"
+ " .endm \n"
+ ".endm \n"
+ "defbl \n");
@@ -375,6 +375,18 @@ static void __init cpuid_init_hwcaps(void)
case 1:
elf_hwcap |= HWCAP_IDIVT;
}
+
+ if (!IS_ENABLED(CONFIG_THUMB2_KERNEL) && (elf_hwcap & HWCAP_IDIVA)) {
+ extern u32 __sdiv_tab_start, __sdiv_tab_end;
+ extern u32 __udiv_tab_start, __udiv_tab_end;
+ u32 *div;
+
+ for (div = &__sdiv_tab_start; div < &__sdiv_tab_end; div++)
+ *(u32 *)*div = 0xe710f110;
+
+ for (div = &__udiv_tab_start; div < &__udiv_tab_end; div++)
+ *(u32 *)*div = 0xe730f110;
+ }
}
static void __init feat_v6_fixup(void)
@@ -176,6 +176,8 @@ SECTIONS
CON_INITCALL
SECURITY_INITCALL
INIT_RAM_FS
+ __sdiv_tab_start = .; *(.sdiv_tab.init); __sdiv_tab_end = .;
+ __udiv_tab_start = .; *(.udiv_tab.init); __udiv_tab_end = .;
}
#ifndef CONFIG_XIP_KERNEL
.exit.data : {