This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/14059] New: HAS_FMA4 check needs to also check for AVX


http://sourceware.org/bugzilla/show_bug.cgi?id=14059

             Bug #: 14059
           Summary: HAS_FMA4 check needs to also check for AVX
           Product: glibc
           Version: 2.15
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: unassigned@sourceware.org
        ReportedBy: jwestfall@surrealistic.net
                CC: drepper.fsp@gmail.com
    Classification: Unclassified


Hi

In number of the sysdeps/x86_64/fpu/multiarch/*.c files there is code like this


libm_ifunc (__ieee754_exp,
            HAS_FMA4 ? __ieee754_exp_fma4
            : (HAS_AVX ? __ieee754_exp_avx : __ieee754_exp_sse2));

The HAS_FMA4 check is only looking at the FMA4 bit from cpuid() to determine if
it runs the fma4 version of the function, but fma4 instructions are dependent
on avx instructions.  This can result in the following invalid opcode if avx
isn't available.

(gdb) exec-file python-dbg
(gdb) run
Starting program: /usr/bin/python-dbg
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Python 2.7.3 (default, Apr 20 2012, 22:01:19)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print test

Program received signal SIGILL, Illegal instruction.
__ieee754_exp_fma4 (x=-0.5) at ../sysdeps/ieee754/dbl-64/e_exp.c:63
63 ../sysdeps/ieee754/dbl-64/e_exp.c: No such file or directory.
(gdb) bt
#0 __ieee754_exp_fma4 (x=-0.5) at ../sysdeps/ieee754/dbl-64/e_exp.c:63
#1 0x000000000058509f in ?? ()
#2 0x00000000009bde80 in ?? ()
#3 0x0000000100c52a10 in ?? ()
#4 0x0000000000417380 in ?? ()
#5 0x00000000009d2970 in ?? ()
#6 0x0000000000000000 in ?? ()
(gdb) info address __ieee754_exp_fma4
Symbol "__ieee754_exp_fma4" is a function at address 0x7ffff6cc35f0.
(gdb) disassemble 0x7ffff6cc35f0,+30
Dump of assembler code from 0x7ffff6cc35f0 to 0x7ffff6cc360e:
   0x00007ffff6cc35f0 <__ieee754_exp_fma4+0>: push %rbp
   0x00007ffff6cc35f1 <__ieee754_exp_fma4+1>: mov %rsp,%rbp
   0x00007ffff6cc35f4 <__ieee754_exp_fma4+4>: and $0xffffffffffffffe0,%rsp
   0x00007ffff6cc35f8 <__ieee754_exp_fma4+8>: add $0x10,%rsp
=> 0x00007ffff6cc35fc <__ieee754_exp_fma4+12>: vmovsd %xmm0,-0x20(%rsp)
   0x00007ffff6cc3602 <__ieee754_exp_fma4+18>: mov -0x20(%rsp),%rax
   0x00007ffff6cc3607 <__ieee754_exp_fma4+23>: mov %rax,%rcx
   0x00007ffff6cc360a <__ieee754_exp_fma4+26>: shr $0x20,%rcx


thanks
jim

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]