8a984d
commit 17a73a6d8b4c46f3e87fc53c7c25fa7cec01d707
8a984d
Author: Raoni Fassina Firmino <raoni@linux.ibm.com>
8a984d
Date:   Mon May 3 16:59:35 2021 -0300
8a984d
8a984d
    powerpc64le: Fix ifunc selection for memset, memmove, bzero and bcopy
8a984d
    
8a984d
    The hwcap2 check for the aforementioned functions should check for
8a984d
    both PPC_FEATURE2_ARCH_3_1 and PPC_FEATURE2_HAS_ISEL but was
8a984d
    mistakenly checking for any one of them, enabling isa 3.1 version of
8a984d
    the functions in incompatible processors, like POWER8.
8a984d
    
8a984d
    Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
8a984d
8a984d
diff --git a/sysdeps/powerpc/powerpc64/multiarch/bcopy.c b/sysdeps/powerpc/powerpc64/multiarch/bcopy.c
8a984d
index 705fef33d4e57557..3c6528e5dbccfdbd 100644
8a984d
--- a/sysdeps/powerpc/powerpc64/multiarch/bcopy.c
8a984d
+++ b/sysdeps/powerpc/powerpc64/multiarch/bcopy.c
8a984d
@@ -28,10 +28,10 @@ extern __typeof (bcopy) __bcopy_power10 attribute_hidden;
8a984d
 
8a984d
 libc_ifunc (bcopy,
8a984d
 #ifdef __LITTLE_ENDIAN__
8a984d
-	     hwcap2 & (PPC_FEATURE2_ARCH_3_1 |
8a984d
-		       PPC_FEATURE2_HAS_ISEL)
8a984d
-	     && (hwcap & PPC_FEATURE_HAS_VSX)
8a984d
-	     ? __bcopy_power10 :
8a984d
+	    (hwcap2 & PPC_FEATURE2_ARCH_3_1
8a984d
+	     && hwcap2 & PPC_FEATURE2_HAS_ISEL
8a984d
+	     && hwcap & PPC_FEATURE_HAS_VSX)
8a984d
+	    ? __bcopy_power10 :
8a984d
 #endif
8a984d
             (hwcap & PPC_FEATURE_HAS_VSX)
8a984d
             ? __bcopy_power7
8a984d
diff --git a/sysdeps/powerpc/powerpc64/multiarch/bzero.c b/sysdeps/powerpc/powerpc64/multiarch/bzero.c
8a984d
index 4ce98e324d12a31e..b08b381b4a3999f1 100644
8a984d
--- a/sysdeps/powerpc/powerpc64/multiarch/bzero.c
8a984d
+++ b/sysdeps/powerpc/powerpc64/multiarch/bzero.c
8a984d
@@ -33,7 +33,8 @@ extern __typeof (bzero) __bzero_power10 attribute_hidden;
8a984d
 
8a984d
 libc_ifunc (__bzero,
8a984d
 # ifdef __LITTLE_ENDIAN__
8a984d
-	    (hwcap2 & (PPC_FEATURE2_ARCH_3_1 | PPC_FEATURE2_HAS_ISEL)
8a984d
+	    (hwcap2 & PPC_FEATURE2_ARCH_3_1
8a984d
+	     && hwcap2 & PPC_FEATURE2_HAS_ISEL
8a984d
 	     && hwcap & PPC_FEATURE_HAS_VSX)
8a984d
 	    ? __bzero_power10 :
8a984d
 # endif
8a984d
diff --git a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
8a984d
index 11532f77d4d03b2a..6e36659d1903448a 100644
8a984d
--- a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
8a984d
+++ b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
8a984d
@@ -75,9 +75,9 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
8a984d
   IFUNC_IMPL (i, name, memmove,
8a984d
 #ifdef __LITTLE_ENDIAN__
8a984d
 	      IFUNC_IMPL_ADD (array, i, memmove,
8a984d
-			      hwcap2 & (PPC_FEATURE2_ARCH_3_1 |
8a984d
-					PPC_FEATURE2_HAS_ISEL)
8a984d
-			      && (hwcap & PPC_FEATURE_HAS_VSX),
8a984d
+			      hwcap2 & PPC_FEATURE2_ARCH_3_1
8a984d
+			      && hwcap2 & PPC_FEATURE2_HAS_ISEL
8a984d
+			      && hwcap & PPC_FEATURE_HAS_VSX,
8a984d
 			      __memmove_power10)
8a984d
 #endif
8a984d
 	      IFUNC_IMPL_ADD (array, i, memmove, hwcap & PPC_FEATURE_HAS_VSX,
8a984d
@@ -88,8 +88,8 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
8a984d
   IFUNC_IMPL (i, name, memset,
8a984d
 #ifdef __LITTLE_ENDIAN__
8a984d
 	      IFUNC_IMPL_ADD (array, i, memset,
8a984d
-			      hwcap2 & (PPC_FEATURE2_ARCH_3_1 |
8a984d
-					PPC_FEATURE2_HAS_ISEL)
8a984d
+			      hwcap2 & PPC_FEATURE2_ARCH_3_1
8a984d
+			      && hwcap2 & PPC_FEATURE2_HAS_ISEL
8a984d
 			      && hwcap & PPC_FEATURE_HAS_VSX,
8a984d
 			      __memset_power10)
8a984d
 #endif
8a984d
@@ -196,8 +196,8 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
8a984d
   IFUNC_IMPL (i, name, bzero,
8a984d
 #ifdef __LITTLE_ENDIAN__
8a984d
 	      IFUNC_IMPL_ADD (array, i, bzero,
8a984d
-			      hwcap2 & (PPC_FEATURE2_ARCH_3_1 |
8a984d
-					PPC_FEATURE2_HAS_ISEL)
8a984d
+			      hwcap2 & PPC_FEATURE2_ARCH_3_1
8a984d
+			      && hwcap2 & PPC_FEATURE2_HAS_ISEL
8a984d
 			      && hwcap & PPC_FEATURE_HAS_VSX,
8a984d
 			      __bzero_power10)
8a984d
 #endif
8a984d
@@ -215,9 +215,9 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
8a984d
   IFUNC_IMPL (i, name, bcopy,
8a984d
 #ifdef __LITTLE_ENDIAN__
8a984d
 	      IFUNC_IMPL_ADD (array, i, bcopy,
8a984d
-			      hwcap2 & (PPC_FEATURE2_ARCH_3_1 |
8a984d
-					PPC_FEATURE2_HAS_ISEL)
8a984d
-			      && (hwcap & PPC_FEATURE_HAS_VSX),
8a984d
+			      hwcap2 & PPC_FEATURE2_ARCH_3_1
8a984d
+			      && hwcap2 & PPC_FEATURE2_HAS_ISEL
8a984d
+			      && hwcap & PPC_FEATURE_HAS_VSX,
8a984d
 			      __bcopy_power10)
8a984d
 #endif
8a984d
 	      IFUNC_IMPL_ADD (array, i, bcopy, hwcap & PPC_FEATURE_HAS_VSX,
8a984d
diff --git a/sysdeps/powerpc/powerpc64/multiarch/memmove.c b/sysdeps/powerpc/powerpc64/multiarch/memmove.c
8a984d
index 2fd7b6d309e4bedd..27895faad0cab40e 100644
8a984d
--- a/sysdeps/powerpc/powerpc64/multiarch/memmove.c
8a984d
+++ b/sysdeps/powerpc/powerpc64/multiarch/memmove.c
8a984d
@@ -36,10 +36,10 @@ extern __typeof (__redirect_memmove) __memmove_power10 attribute_hidden;
8a984d
 
8a984d
 libc_ifunc (__libc_memmove,
8a984d
 #ifdef __LITTLE_ENDIAN__
8a984d
-	     hwcap2 & (PPC_FEATURE2_ARCH_3_1 |
8a984d
-		       PPC_FEATURE2_HAS_ISEL)
8a984d
-	     && (hwcap & PPC_FEATURE_HAS_VSX)
8a984d
-	     ? __memmove_power10 :
8a984d
+	    (hwcap2 & PPC_FEATURE2_ARCH_3_1
8a984d
+	     && hwcap2 & PPC_FEATURE2_HAS_ISEL
8a984d
+	     && hwcap & PPC_FEATURE_HAS_VSX)
8a984d
+	    ? __memmove_power10 :
8a984d
 #endif
8a984d
 		     (hwcap & PPC_FEATURE_HAS_VSX)
8a984d
 		     ? __memmove_power7
8a984d
diff --git a/sysdeps/powerpc/powerpc64/multiarch/memset.c b/sysdeps/powerpc/powerpc64/multiarch/memset.c
8a984d
index 4c97622c7d7eb8aa..685623ae870a0725 100644
8a984d
--- a/sysdeps/powerpc/powerpc64/multiarch/memset.c
8a984d
+++ b/sysdeps/powerpc/powerpc64/multiarch/memset.c
8a984d
@@ -41,7 +41,8 @@ extern __typeof (__redirect_memset) __memset_power10 attribute_hidden;
8a984d
    ifunc symbol properly.  */
8a984d
 libc_ifunc (__libc_memset,
8a984d
 # ifdef __LITTLE_ENDIAN__
8a984d
-	    (hwcap2 & (PPC_FEATURE2_ARCH_3_1 | PPC_FEATURE2_HAS_ISEL)
8a984d
+	    (hwcap2 & PPC_FEATURE2_ARCH_3_1
8a984d
+	     && hwcap2 & PPC_FEATURE2_HAS_ISEL
8a984d
 	     && hwcap & PPC_FEATURE_HAS_VSX)
8a984d
 	    ? __memset_power10 :
8a984d
 # endif