diff mbox series

powerpc64le/power9: guard power9 strcmp against rtld usage [BZ# 25905]

Message ID 20200501203219.8738-1-murphyp@linux.vnet.ibm.com
State New
Headers show
Series powerpc64le/power9: guard power9 strcmp against rtld usage [BZ# 25905] | expand

Commit Message

Paul E. Murphy May 1, 2020, 8:32 p.m. UTC
strcmp is used while resolving PLT references.  Vector registers
should not be used during this.  The P9 strcmp makes heavy use of
vector registers, so it should be avoided in rtld.

This prevents quiet vector register corruption when glibc is configured
with --disable-multi-arch and --with-cpu=power9.  This can be seen with
test-float64x-compat_totalordermag during the first call into
totalordermagf64x@GLIBC_2.27.

Add a guard to fallback to the power8 implementation when building
power9 strcmp for libraries other than libc.
---
 sysdeps/powerpc/powerpc64/le/power9/strcmp.S | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Adhemerval Zanella May 4, 2020, 12:26 p.m. UTC | #1
On 01/05/2020 17:32, Paul E. Murphy via Libc-alpha wrote:
> strcmp is used while resolving PLT references.  Vector registers
> should not be used during this.  The P9 strcmp makes heavy use of
> vector registers, so it should be avoided in rtld.
> 
> This prevents quiet vector register corruption when glibc is configured
> with --disable-multi-arch and --with-cpu=power9.  This can be seen with
> test-float64x-compat_totalordermag during the first call into
> totalordermagf64x@GLIBC_2.27.
> 
> Add a guard to fallback to the power8 implementation when building
> power9 strcmp for libraries other than libc.

The more usual way and it has the advantages of decouple the generic
implementation and make it more explicit is to add a new rtld-strcmp.S
file:

$ cat sysdeps/powerpc/powerpc64/le/power9/rtld-strcmp.S
#include <sysdeps/powerpc/powerpc64/power8/strcmp.S>


> ---
>  sysdeps/powerpc/powerpc64/le/power9/strcmp.S | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/sysdeps/powerpc/powerpc64/le/power9/strcmp.S b/sysdeps/powerpc/powerpc64/le/power9/strcmp.S
> index 412a13599d..b29ea7c020 100644
> --- a/sysdeps/powerpc/powerpc64/le/power9/strcmp.S
> +++ b/sysdeps/powerpc/powerpc64/le/power9/strcmp.S
> @@ -17,6 +17,11 @@
>     <https://www.gnu.org/licenses/>.  */
>  #include <sysdep.h>
>  
> +#if !IS_IN(libc)
> +/* Fallback to P8 which does not use vector regs for rtld.  */
> +#include <sysdeps/powerpc/powerpc64/power8/strcmp.S>
> +#else
> +
>  #ifndef STRCMP
>  # define STRCMP strcmp
>  #endif
> @@ -262,3 +267,5 @@ L(pagecross_nullfound):
>  	b	L(pagecross_retdiff)
>  END (STRCMP)
>  libc_hidden_builtin_def (strcmp)
> +
> +#endif
>
diff mbox series

Patch

diff --git a/sysdeps/powerpc/powerpc64/le/power9/strcmp.S b/sysdeps/powerpc/powerpc64/le/power9/strcmp.S
index 412a13599d..b29ea7c020 100644
--- a/sysdeps/powerpc/powerpc64/le/power9/strcmp.S
+++ b/sysdeps/powerpc/powerpc64/le/power9/strcmp.S
@@ -17,6 +17,11 @@ 
    <https://www.gnu.org/licenses/>.  */
 #include <sysdep.h>
 
+#if !IS_IN(libc)
+/* Fallback to P8 which does not use vector regs for rtld.  */
+#include <sysdeps/powerpc/powerpc64/power8/strcmp.S>
+#else
+
 #ifndef STRCMP
 # define STRCMP strcmp
 #endif
@@ -262,3 +267,5 @@  L(pagecross_nullfound):
 	b	L(pagecross_retdiff)
 END (STRCMP)
 libc_hidden_builtin_def (strcmp)
+
+#endif