about summary refs log tree commit diff
path: root/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
diff options
context:
space:
mode:
authorAnton Blanchard <anton@ozlabs.org>2021-07-27 15:47:50 +1000
committerTulio Magno Quites Machado Filho <tuliom@linux.ibm.com>2021-08-06 16:09:59 -0300
commitf2a15dd668913c5a1388ba7e1131b25162b2ea75 (patch)
tree0502041dd1875008f263ec0655b304acea5ff398 /sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
parente4ca6de1bc5e4ba3f94cf0c501a293c5bc827b10 (diff)
downloadglibc-f2a15dd668913c5a1388ba7e1131b25162b2ea75.tar.gz
glibc-f2a15dd668913c5a1388ba7e1131b25162b2ea75.tar.xz
glibc-f2a15dd668913c5a1388ba7e1131b25162b2ea75.zip
powerpc64: Check cacheline size before using optimised memset routines
A number of optimised memset routines assume the cacheline size is 128B,
so we better check before using them.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
Diffstat (limited to 'sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c')
-rw-r--r--sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
index 32564c8f1f..a3fdcd43bd 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
@@ -35,6 +35,9 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
 
   unsigned long int hwcap = GLRO(dl_hwcap);
   unsigned long int hwcap2 = GLRO(dl_hwcap2);
+#ifdef SHARED
+  int cacheline_size = GLRO(dl_cache_line_size);
+#endif
 
   /* hwcap contains only the latest supported ISA, the code checks which is
      and fills the previous supported ones.  */
@@ -90,16 +93,21 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
 	      IFUNC_IMPL_ADD (array, i, memset,
 			      hwcap2 & PPC_FEATURE2_ARCH_3_1
 			      && hwcap2 & PPC_FEATURE2_HAS_ISEL
-			      && hwcap & PPC_FEATURE_HAS_VSX,
+			      && hwcap & PPC_FEATURE_HAS_VSX
+			      && cacheline_size == 128,
 			      __memset_power10)
 #endif
-	      IFUNC_IMPL_ADD (array, i, memset, hwcap2 & PPC_FEATURE2_ARCH_2_07,
+	      IFUNC_IMPL_ADD (array, i, memset, hwcap2 & PPC_FEATURE2_ARCH_2_07
+			      && cacheline_size == 128,
 			      __memset_power8)
-	      IFUNC_IMPL_ADD (array, i, memset, hwcap & PPC_FEATURE_ARCH_2_06,
+	      IFUNC_IMPL_ADD (array, i, memset, hwcap & PPC_FEATURE_ARCH_2_06
+			      && cacheline_size == 128,
 			      __memset_power7)
-	      IFUNC_IMPL_ADD (array, i, memset, hwcap & PPC_FEATURE_ARCH_2_05,
+	      IFUNC_IMPL_ADD (array, i, memset, hwcap & PPC_FEATURE_ARCH_2_05
+			      && cacheline_size == 128,
 			      __memset_power6)
-	      IFUNC_IMPL_ADD (array, i, memset, hwcap & PPC_FEATURE_POWER4,
+	      IFUNC_IMPL_ADD (array, i, memset, hwcap & PPC_FEATURE_POWER4
+			      && cacheline_size == 128,
 			      __memset_power4)
 	      IFUNC_IMPL_ADD (array, i, memset, 1, __memset_ppc))