NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: NetBSD/i386 7.0 hangs booting 486



In article <CALX=d=fnLJ1ci_WULJ==nhOUx+=wraDSOYhiEN+huA3Z9fw9eA%mail.gmail.com@localhost>,
Felix Deichmann  <m4j0rd0m0%gmail.com@localhost> wrote:
>2015-11-22 17:12 GMT+01:00 Felix Deichmann <m4j0rd0m0%gmail.com@localhost>:
>> Maybe a fix in __get_cpuid() could be as simple as:
>>
>> -  if (__get_cpuid_max (__ext, 0) < __level)
>> +  if (__get_cpuid_max (__ext, 0) <= __level)
>
>Hm no, this will break all machines except those without cpuid of course.
>
>The problem seems to be that the over-all logic, return types etc. in
>cpuid.h is focused on "*which* cpuid level, starting at 0, does the
>CPU support?", but doesn't ask "does the CPU support cpuid *at all*?".
>

I think you nailed it... The problem is:

http://nxr.netbsd.org/xref/src/external/gpl3/gcc/dist/libgcc/config/i386/cpuinfo.c#284

And the fix could be something like:

Index: cpuid.h
===================================================================
RCS file: /cvsroot/src/external/gpl3/gcc/dist/gcc/config/i386/cpuid.h,v
retrieving revision 1.1.1.2
diff -u -u -r1.1.1.2 cpuid.h
--- cpuid.h	1 Mar 2014 08:43:18 -0000	1.1.1.2
+++ cpuid.h	22 Nov 2015 16:57:48 -0000
@@ -259,8 +259,9 @@
 	     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);

Of course the llvm version needs to be fixed too, since it doesn't check
at all:

http://nxr.netbsd.org/xref/src/external/bsd/llvm/dist/clang/lib/Headers/cpuid.h#174

christos



Home | Main Index | Thread Index | Old Index