From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1bwwCL-0001og-4S for mharc-grub-devel@gnu.org; Wed, 19 Oct 2016 15:06:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54092) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bwwCJ-0001lq-DJ for grub-devel@gnu.org; Wed, 19 Oct 2016 15:06:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bwwCF-00015Z-En for grub-devel@gnu.org; Wed, 19 Oct 2016 15:06:43 -0400 Received: from caffeine.csclub.uwaterloo.ca ([129.97.134.17]:48768) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bwwCF-000159-BM for grub-devel@gnu.org; Wed, 19 Oct 2016 15:06:39 -0400 Received: by caffeine.csclub.uwaterloo.ca (Postfix, from userid 20367) id EA214C0260; Wed, 19 Oct 2016 15:06:36 -0400 (EDT) Date: Wed, 19 Oct 2016 15:06:36 -0400 To: Matthew Whitehead Cc: The development of GNU GRUB Subject: Re: "Illegal Instruction" error in grub_script_comments Message-ID: <20161019190636.GJ20428@csclub.uwaterloo.ca> References: <20161018191208.GF20428@csclub.uwaterloo.ca> <909472052.9545840.1476891128586.JavaMail.zimbra@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <909472052.9545840.1476891128586.JavaMail.zimbra@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) From: lsorense@csclub.uwaterloo.ca (Lennart Sorensen) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 129.97.134.17 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Oct 2016 19:06:44 -0000 On Wed, Oct 19, 2016 at 11:32:08AM -0400, Matthew Whitehead wrote: > 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? I don't think that's likely to make a difference. The cpuid and rdtsc instructions are supposed to be protected by a check for whether cpuid is a valid instruction, so it should never try to run them unless that isn't working. Would be interesting to see the failing test run under gdb in case it can point to what instruction is illegal and on what line. -- Len Sorensen