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