grub-devel
[Top][All Lists]
Advanced

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

Re: "Illegal Instruction" error in grub_script_comments


From: Andrei Borzenkov
Subject: Re: "Illegal Instruction" error in grub_script_comments
Date: Thu, 20 Oct 2016 20:34:51 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0

19.10.2016 18:32, Matthew Whitehead пишет:
> Lennart,
>   I think I found the problem. I don't know what kernel.img does, but I'm 
> guessing it is an essential part of grub2, loading after the 1st and 2nd 
> stage loaders? I disassembled the binary using 'objdump -D -b binary -m i386 
> kernel.img' and found several cases both of rdtsc and cpuid. Both of these 
> instructions do not exist on first generation 80486 cpus. Here they are, and 
> I've attached the full disassembly output.
> 
>     53a0:       85 c0                   test   %eax,%eax
>     53a2:       74 6f                   je     0x5413
>     53a4:       b8 01 00 00 00          mov    $0x1,%eax
>     53a9:       0f a2                   cpuid
>     53ab:       80 e2 10                and    $0x10,%dl
>     53ae:       74 63                   je     0x5413
>     53b0:       31 c0                   xor    %eax,%eax
>     53b2:       0f a2                   cpuid
>     53b4:       0f 31                   rdtsc
>     53b6:       a3 48 67 01 00          mov    %eax,0x16748
>     53bb:       89 15 4c 67 01 00       mov    %edx,0x1674c
>     53c1:       31 c0                   xor    %eax,%eax
>     53c3:       0f a2                   cpuid
>     53c5:       0f 31                   rdtsc
>     53c7:       89 c6                   mov    %eax,%esi
>     53c9:       b8 ff ff 00 00          mov    $0xffff,%eax
>     53ce:       89 d7                   mov    %edx,%edi
>     53d0:       e8 83 00 00 00          call   0x5458
>     53d5:       31 c0                   xor    %eax,%eax
>     53d7:       0f a2                   cpuid
>     53d9:       0f 31                   rdtsc
>     53db:       89 45 e0                mov    %eax,-0x20(%ebp)
>     53de:       8b 4d e0                mov    -0x20(%ebp),%ecx
> ...
>     5439:       31 c0                   xor    %eax,%eax
>     543b:       0f a2                   cpuid
>     543d:       0f 31                   rdtsc
>     543f:       8b 0d 50 67 01 00       mov    0x16750,%ecx
>     5445:       6a 00                   push   $0x0
>     5447:       e8 8f dc ff ff          call   0x30db
> 
> How can we adjust the makefiles to include -march=i486 or something similar?
> 

This code is likely grub_cpu_is_tsc_supported() (see
include/grub/i386/tsc.h) which *is* protected by
grub_cpu_is_cpuid_supported(). Can you test if this function yields
wrong result in your case (just compile it separately)?

> - Matthew
> 
> 
> 
> _______________________________________________
> Grub-devel mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/grub-devel
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]