grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
From: Andrei Borzenkov <arvidjaar@gmail.com>
To: The development of GNU GRUB <grub-devel@gnu.org>,
	Lennart Sorensen <lsorense@csclub.uwaterloo.ca>
Subject: Re: "Illegal Instruction" error in grub_script_comments
Date: Thu, 20 Oct 2016 20:34:51 +0300	[thread overview]
Message-ID: <a58beafb-4650-5ab2-a7f8-84a0a972dbda@gmail.com> (raw)
In-Reply-To: <909472052.9545840.1476891128586.JavaMail.zimbra@redhat.com>

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
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
> 



      parent reply	other threads:[~2016-10-20 17:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-17 18:34 "Illegal Instruction" error in grub_script_comments tedheadster
2016-10-17 22:32 ` Colin Watson
2016-10-18 19:12 ` Lennart Sorensen
2016-10-19 15:32   ` Matthew Whitehead
2016-10-19 19:06     ` Lennart Sorensen
2016-10-19 19:16       ` Matthew Whitehead
2016-10-31  3:17       ` Matthew Whitehead
2016-10-20 17:34     ` Andrei Borzenkov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a58beafb-4650-5ab2-a7f8-84a0a972dbda@gmail.com \
    --to=arvidjaar@gmail.com \
    --cc=grub-devel@gnu.org \
    --cc=lsorense@csclub.uwaterloo.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).