grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Whitehead <mwhitehe@redhat.com>
To: Lennart Sorensen <lsorense@csclub.uwaterloo.ca>
Cc: The development of GNU GRUB <grub-devel@gnu.org>
Subject: Re: "Illegal Instruction" error in grub_script_comments
Date: Wed, 19 Oct 2016 11:32:08 -0400 (EDT)	[thread overview]
Message-ID: <909472052.9545840.1476891128586.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <20161018191208.GF20428@csclub.uwaterloo.ca>

[-- Attachment #1: Type: text/plain, Size: 2086 bytes --]

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?

- Matthew


[-- Attachment #2: kernel.dis --]
[-- Type: application/vnd.mobius.dis, Size: 540582 bytes --]

  reply	other threads:[~2016-10-19 20:20 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 [this message]
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

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=909472052.9545840.1476891128586.JavaMail.zimbra@redhat.com \
    --to=mwhitehe@redhat.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).