Enhance tst-xmmymm.sh to detect zmm register usage in ld.so

Message ID 20140911173002.GJ14885@spoyarek.pnq.redhat.com
State Superseded
Headers

Commit Message

Siddhesh Poyarekar Sept. 11, 2014, 5:30 p.m. UTC
  Hi,

2d63a517e4084ec80403cd9f278690fa8b676cc4 added support to save and
restore zmm register in the dynamic linker, but did not enhance
test-xmmymm.sh to detect accidental usage of these registers.  The
patch below adds that check.

Tested on x86_64 by injecting an instruction into dl-runtime.os.

Siddhesh

	* sysdeps/x86/tst-xmmymm.sh: Check for zmm register usage.
  

Comments

H.J. Lu Sept. 11, 2014, 6 p.m. UTC | #1
On Thu, Sep 11, 2014 at 10:30 AM, Siddhesh Poyarekar
<siddhesh@redhat.com> wrote:
> Hi,
>
> 2d63a517e4084ec80403cd9f278690fa8b676cc4 added support to save and
> restore zmm register in the dynamic linker, but did not enhance
> test-xmmymm.sh to detect accidental usage of these registers.  The
> patch below adds that check.
>
> Tested on x86_64 by injecting an instruction into dl-runtime.os.
>
> Siddhesh
>
>         * sysdeps/x86/tst-xmmymm.sh: Check for zmm register usage.
>
> diff --git a/sysdeps/x86/tst-xmmymm.sh b/sysdeps/x86/tst-xmmymm.sh
> index 69ddb58..fe37328 100755
> --- a/sysdeps/x86/tst-xmmymm.sh
> +++ b/sysdeps/x86/tst-xmmymm.sh
> @@ -1,5 +1,5 @@
>  #! /bin/bash
> -# Make sure no code in ld.so uses xmm/ymm registers on x86-64.
> +# Make sure no code in ld.so uses xmm/ymm/zmm registers on x86-64.
>  # Copyright (C) 2009-2014 Free Software Foundation, Inc.
>  # This file is part of the GNU C Library.
>
> @@ -80,12 +80,12 @@ echo "object files needed: $tocheck"
>  cp /dev/null "$tmp"
>  for f in $tocheck; do
>    $OBJDUMP -d "$objpfx"../*/"$f" |
> -  awk 'BEGIN { last="" } /^[[:xdigit:]]* <[_[:alnum:]]*>:$/ { fct=substr($2, 2, length($2)-3) } /,%[xy]mm[[:digit:]]*$/ { if (last != fct) { print fct; last=fct} }' |
> +  awk 'BEGIN { last="" } /^[[:xdigit:]]* <[_[:alnum:]]*>:$/ { fct=substr($2, 2, length($2)-3) } /,%[xyz]mm[[:digit:]]*$/ { if (last != fct) { print fct; last=fct} }' |
>    while read fct; do
>      if test "$fct" = "_dl_runtime_profile" -o "$fct" = "_dl_x86_64_restore_sse"; then
>        continue;
>      fi
> -    echo "function $fct in $f modifies xmm/ymm" >> "$tmp"
> +    echo "function $fct in $f modifies xmm/ymm/zmm" >> "$tmp"
>      result=1
>    done
>  done

Looks good to me.

Thanks.
  
Carlos O'Donell Sept. 11, 2014, 7:39 p.m. UTC | #2
On 09/11/2014 01:30 PM, Siddhesh Poyarekar wrote:
> Hi,
> 
> 2d63a517e4084ec80403cd9f278690fa8b676cc4 added support to save and
> restore zmm register in the dynamic linker, but did not enhance
> test-xmmymm.sh to detect accidental usage of these registers.  The
> patch below adds that check.
> 
> Tested on x86_64 by injecting an instruction into dl-runtime.os.
> 
> Siddhesh
> 
> 	* sysdeps/x86/tst-xmmymm.sh: Check for zmm register usage.
> 
> diff --git a/sysdeps/x86/tst-xmmymm.sh b/sysdeps/x86/tst-xmmymm.sh
> index 69ddb58..fe37328 100755
> --- a/sysdeps/x86/tst-xmmymm.sh
> +++ b/sysdeps/x86/tst-xmmymm.sh
> @@ -1,5 +1,5 @@
>  #! /bin/bash
> -# Make sure no code in ld.so uses xmm/ymm registers on x86-64.
> +# Make sure no code in ld.so uses xmm/ymm/zmm registers on x86-64.
>  # Copyright (C) 2009-2014 Free Software Foundation, Inc.
>  # This file is part of the GNU C Library.
>  
> @@ -80,12 +80,12 @@ echo "object files needed: $tocheck"
>  cp /dev/null "$tmp"
>  for f in $tocheck; do
>    $OBJDUMP -d "$objpfx"../*/"$f" |
> -  awk 'BEGIN { last="" } /^[[:xdigit:]]* <[_[:alnum:]]*>:$/ { fct=substr($2, 2, length($2)-3) } /,%[xy]mm[[:digit:]]*$/ { if (last != fct) { print fct; last=fct} }' |
> +  awk 'BEGIN { last="" } /^[[:xdigit:]]* <[_[:alnum:]]*>:$/ { fct=substr($2, 2, length($2)-3) } /,%[xyz]mm[[:digit:]]*$/ { if (last != fct) { print fct; last=fct} }' |
>    while read fct; do
>      if test "$fct" = "_dl_runtime_profile" -o "$fct" = "_dl_x86_64_restore_sse"; then
>        continue;
>      fi
> -    echo "function $fct in $f modifies xmm/ymm" >> "$tmp"
> +    echo "function $fct in $f modifies xmm/ymm/zmm" >> "$tmp"
>      result=1
>    done
>  done

Please rename to tst-zmmxmmymm.sh and commit, otherwise it still
looks like it only checks for xmmymm, and that's misleading.

Cheers,
Carlos.
  
Carlos O'Donell Sept. 11, 2014, 8:01 p.m. UTC | #3
On 09/11/2014 03:39 PM, Carlos O'Donell wrote:
> On 09/11/2014 01:30 PM, Siddhesh Poyarekar wrote:
>> Hi,
>>
>> 2d63a517e4084ec80403cd9f278690fa8b676cc4 added support to save and
>> restore zmm register in the dynamic linker, but did not enhance
>> test-xmmymm.sh to detect accidental usage of these registers.  The
>> patch below adds that check.
>>
>> Tested on x86_64 by injecting an instruction into dl-runtime.os.
>>
>> Siddhesh
>>
>> 	* sysdeps/x86/tst-xmmymm.sh: Check for zmm register usage.

[BZ #16194]

c.
  
Carlos O'Donell Sept. 11, 2014, 8:08 p.m. UTC | #4
On 09/11/2014 03:39 PM, Carlos O'Donell wrote:
> Please rename to tst-zmmxmmymm.sh and commit, otherwise it still
> looks like it only checks for xmmymm, and that's misleading.

I meant tst-xmmymmzmm.sh.

c.
  
Andreas Schwab Sept. 12, 2014, 7:30 a.m. UTC | #5
"Carlos O'Donell" <carlos@redhat.com> writes:

> On 09/11/2014 03:39 PM, Carlos O'Donell wrote:
>> Please rename to tst-zmmxmmymm.sh and commit, otherwise it still
>> looks like it only checks for xmmymm, and that's misleading.
>
> I meant tst-xmmymmzmm.sh.

tst-register-use.sh

Andreas.
  

Patch

diff --git a/sysdeps/x86/tst-xmmymm.sh b/sysdeps/x86/tst-xmmymm.sh
index 69ddb58..fe37328 100755
--- a/sysdeps/x86/tst-xmmymm.sh
+++ b/sysdeps/x86/tst-xmmymm.sh
@@ -1,5 +1,5 @@ 
 #! /bin/bash
-# Make sure no code in ld.so uses xmm/ymm registers on x86-64.
+# Make sure no code in ld.so uses xmm/ymm/zmm registers on x86-64.
 # Copyright (C) 2009-2014 Free Software Foundation, Inc.
 # This file is part of the GNU C Library.
 
@@ -80,12 +80,12 @@  echo "object files needed: $tocheck"
 cp /dev/null "$tmp"
 for f in $tocheck; do
   $OBJDUMP -d "$objpfx"../*/"$f" |
-  awk 'BEGIN { last="" } /^[[:xdigit:]]* <[_[:alnum:]]*>:$/ { fct=substr($2, 2, length($2)-3) } /,%[xy]mm[[:digit:]]*$/ { if (last != fct) { print fct; last=fct} }' |
+  awk 'BEGIN { last="" } /^[[:xdigit:]]* <[_[:alnum:]]*>:$/ { fct=substr($2, 2, length($2)-3) } /,%[xyz]mm[[:digit:]]*$/ { if (last != fct) { print fct; last=fct} }' |
   while read fct; do
     if test "$fct" = "_dl_runtime_profile" -o "$fct" = "_dl_x86_64_restore_sse"; then
       continue;
     fi
-    echo "function $fct in $f modifies xmm/ymm" >> "$tmp"
+    echo "function $fct in $f modifies xmm/ymm/zmm" >> "$tmp"
     result=1
   done
 done