https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68491

            Bug ID: 68491
           Summary: libgcc calls __get_cpuid with 0 level breaks on early
                    athlon.
           Product: gcc
           Version: 4.8.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libgcc
          Assignee: unassigned at gcc dot gnu.org
          Reporter: christos at zoulas dot com
  Target Milestone: ---

http://nxr.netbsd.org/xref/src/external/gpl3/gcc/dist/libgcc/config/i386/cpuinfo.c#284
calls __get_cpuid with 0 level, then we end up in:
http://nxr.netbsd.org/xref/src/external/gpl3/gcc/dist/gcc/config/i386/cpuid.h#263
and end up calling __cpuid even though __get_cpuid_max returns 0. This breaks
on early i486 processors that don't have the cpuid instruction and we end up
getting SIGILL. Our fix is to explicitly check for 0 to prevent that:

             unsigned int *__ecx, unsigned int *__edx)
 {
   unsigned int __ext = __level & 0x80000000;
+  unsigned int __maxlevel = __get_cpuid_max (__ext, 0);

-  if (__get_cpuid_max (__ext, 0) < __level)
+  if (__maxlevel == 0 || __maxlevel < __level)
     return 0;

   __cpuid (__level, *__eax, *__ebx, *__ecx, *__edx);

Reply via email to