Erwan Velu wrote:> Hey,
>
> Gert reported me that cpuidtest.c32 reports weird stuff.
> After looking at it, I found a potential bug when the cpu vendor isn't
> detected from an exisiting list. That will be easy to fix, that's not
> the purpose of this mail.
>
> When investigating why the vendor was wrong, I found that a very old
> commit in the 4.0 branch generates unexpected results when calling
> cpuid().
>
> This commit changes the cpuid() calls and got elected by my bisect as
> the faulty commit
>
http://git.kernel.org/?p=boot/syslinux/syslinux.git;a=commitdiff;h=04e7c2784dd3fd45090d1ddb31905dd7a9b921a3;hp=24ffb34fcff5b50b56d987e18dcf519e278c771e
>
> My asm skill sux that much than I don't have any clue on the
> reason/potential fix.
>
> At least, the generated garbage shows off other bugs that have to be
> fixed too ;o)
>
> Any ideas ?
>
> Cheers,
> Erwan,
The cpuid() code
static inline void cpuid(uint32_t op, uint32_t * eax, uint32_t * ebx,
uint32_t * ecx, uint32_t * edx)
{
asm("pushl %%ebx ; cpuid ; movl %%ebx,%0 ; popl
%%ebx":"=a"(*eax), "=SD"(*ebx), "=c"(*ecx),
"=d"(*edx)
: "a"(op));
}
gets compiled to
00160d5f: ( ): push ebx ; 53
00160d60: ( ): cpuid ; 0fa2
00160d62: ( ): mov eax, ebx ; 89d8
00160d64: ( ): pop ebx ; 5b
00160d65: ( ): mov ebp, edi ; 89fd
00160d67: ( ): mov edi, dword ptr ss:[esp] ; 8b3c24
00160d6a: ( ): mov dword ptr ds:[edi+8], eax ; 894708
00160d6d: ( ): mov dword ptr ds:[edi+40], ebp ; 896f28
00160d70: ( ): mov dword ptr ds:[esi+8], ecx ; 894e08
00160d73: ( ): mov dword ptr ds:[esi+4], edx ; 895604
eax gets trashed with the content of ebx. Unfortunatelly i am no good at gcc
inline assembly either.
Sebastian