* "Illegal Instruction" error in grub_script_comments @ 2016-10-17 18:34 tedheadster 2016-10-17 22:32 ` Colin Watson 2016-10-18 19:12 ` Lennart Sorensen 0 siblings, 2 replies; 8+ messages in thread From: tedheadster @ 2016-10-17 18:34 UTC (permalink / raw) To: grub-devel; +Cc: Matthew Whitehead [-- Attachment #1: Type: text/plain, Size: 1320 bytes --] I am building the older grub2-1.98+20100804 under the similarly old Debian 'squeeze' distribution. However, I bet the error persists with newer version. This is because I am building it on a true Intel 80486 and I don't thing the compiler is building for the correct architecture. Here is the output: ./config.status --file=-:tests/grub_script_dollar.in | sed -e 's,@pkglib_DATA@,efiemu32.o efiemu64.o moddep.lst command.lst fs.lst partmap.lst parttool.lst handler.lst vi\ deo.lst crypto.lst terminal.lst,g' > grub_script_dollar chmod +x grub_script_dollar ./config.status --file=-:tests/grub_script_comments.in | sed -e 's,@pkglib_DATA@,efiemu32.o efiemu64.o moddep.lst command.lst fs.lst partmap.lst parttool.lst handler.lst \ video.lst crypto.lst terminal.lst,g' > grub_script_comments chmod +x grub_script_comments Illegal instruction ./grub_script_echo1: GRUB and BASH outputs did not match (see diff -u /tmp/tmp.tP7l8uR3SD /tmp/tmp.wYCFOK2zor) make[2]: *** [check] Error 1 make[2]: Leaving directory `/root/grub2-1.98+20100804/build/grub-pc' dh_auto_test: make -j1 check returned exit code 2 make[1]: *** [build/stamps/build-grub-pc] Error 29 make[1]: Leaving directory `/root/grub2-1.98+20100804' make: *** [build] Error 2 Is there a file I can modify to pass in -march=i486 or something similar? - Matthew [-- Attachment #2: Type: text/html, Size: 1771 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: "Illegal Instruction" error in grub_script_comments 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 1 sibling, 0 replies; 8+ messages in thread From: Colin Watson @ 2016-10-17 22:32 UTC (permalink / raw) To: grub-devel On Mon, Oct 17, 2016 at 02:34:16PM -0400, tedheadster wrote: > I am building the older grub2-1.98+20100804 under the similarly old Debian > 'squeeze' distribution. However, I bet the error persists with newer > version. This is because I am building it on a true Intel 80486 and I don't > thing the compiler is building for the correct architecture. If it is in fact the lack of an -march= option that's at fault, then that was fixed in 2.02~beta1: http://git.savannah.gnu.org/cgit/grub.git/commit/?id=02663ee9d9cae806f90518bc4c89d31ae11b84e4 (You may be best simply setting TARGET_CFLAGS='-march=i386 -Os' in the environment when running configure, rather than trying to regenerate configure with that patch.) If that doesn't do it, then it may be something more involved such as hand-written non-486-compatible assembly somewhere, which won't be cured by a compiler option. GRUB is mostly in C, but something running at the level of a boot loader does tend to need at least a little bit of assembly to get itself going. -- Colin Watson [cjwatson@ubuntu.com] ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: "Illegal Instruction" error in grub_script_comments 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 1 sibling, 1 reply; 8+ messages in thread From: Lennart Sorensen @ 2016-10-18 19:12 UTC (permalink / raw) To: The development of GNU GRUB; +Cc: Matthew Whitehead On Mon, Oct 17, 2016 at 02:34:16PM -0400, tedheadster wrote: > I am building the older grub2-1.98+20100804 under the similarly old Debian > 'squeeze' distribution. However, I bet the error persists with newer > version. This is because I am building it on a true Intel 80486 and I don't > thing the compiler is building for the correct architecture. Here is the > output: > > ./config.status --file=-:tests/grub_script_dollar.in | sed -e > 's,@pkglib_DATA@,efiemu32.o efiemu64.o moddep.lst command.lst fs.lst > partmap.lst parttool.lst handler.lst vi\ > deo.lst crypto.lst terminal.lst,g' > grub_script_dollar > chmod +x grub_script_dollar > > ./config.status --file=-:tests/grub_script_comments.in | sed -e > 's,@pkglib_DATA@,efiemu32.o efiemu64.o moddep.lst command.lst fs.lst > partmap.lst parttool.lst handler.lst \ > video.lst crypto.lst terminal.lst,g' > grub_script_comments > chmod +x grub_script_comments > > Illegal instruction > > ./grub_script_echo1: GRUB and BASH outputs did not match (see diff -u > /tmp/tmp.tP7l8uR3SD /tmp/tmp.wYCFOK2zor) > make[2]: *** [check] Error 1 > make[2]: Leaving directory `/root/grub2-1.98+20100804/build/grub-pc' > dh_auto_test: make -j1 check returned exit code 2 > make[1]: *** [build/stamps/build-grub-pc] Error 29 > make[1]: Leaving directory `/root/grub2-1.98+20100804' > make: *** [build] Error 2 > > Is there a file I can modify to pass in -march=i486 or something similar? Well I tried installing squeeze in a qemu VM emulating a 486. It worked fine there. But qemu is emulating a 486DX4, which supports CPUID. If your 486 is older if probably does not have the CPUID instruction. The place grub is blowing up appears to be the test suite which uses qemu-system-i386. So my suspicion is that it is actually qemu crashing, not grub, and that your best bet would be to just not run the test suite. The compile almost certainly worked fine. Simply uninstalling qemu whould make it not try to run the test based on the debian/rules file, although debian/control considers qemu a built dependancy. So you probably have to use -d with dpkg-builcpackage to make it ignore the missing dependancy. Or edit debian/rules and simply set the with_check variable to no. I can't find anything that says if qemu should run on an older 486, probably since those usually didn't have enough memory to make that worth the bother and they are too slow. Maybe no one had ever tried it before. -- Len Sorensen ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: "Illegal Instruction" error in grub_script_comments 2016-10-18 19:12 ` Lennart Sorensen @ 2016-10-19 15:32 ` Matthew Whitehead 2016-10-19 19:06 ` Lennart Sorensen 2016-10-20 17:34 ` Andrei Borzenkov 0 siblings, 2 replies; 8+ messages in thread From: Matthew Whitehead @ 2016-10-19 15:32 UTC (permalink / raw) To: Lennart Sorensen; +Cc: The development of GNU GRUB [-- 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 --] ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: "Illegal Instruction" error in grub_script_comments 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 1 sibling, 2 replies; 8+ messages in thread From: Lennart Sorensen @ 2016-10-19 19:06 UTC (permalink / raw) To: Matthew Whitehead; +Cc: The development of GNU GRUB 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 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: "Illegal Instruction" error in grub_script_comments 2016-10-19 19:06 ` Lennart Sorensen @ 2016-10-19 19:16 ` Matthew Whitehead 2016-10-31 3:17 ` Matthew Whitehead 1 sibling, 0 replies; 8+ messages in thread From: Matthew Whitehead @ 2016-10-19 19:16 UTC (permalink / raw) To: Lennart Sorensen; +Cc: The development of GNU GRUB Lennart, tell me how can I run this under gdb and I'll find where the exception is. I'm pretty sure I cannot do it while the system is booting from disk, but is there a userland way to do it? - Matthew ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: "Illegal Instruction" error in grub_script_comments 2016-10-19 19:06 ` Lennart Sorensen 2016-10-19 19:16 ` Matthew Whitehead @ 2016-10-31 3:17 ` Matthew Whitehead 1 sibling, 0 replies; 8+ messages in thread From: Matthew Whitehead @ 2016-10-31 3:17 UTC (permalink / raw) To: Lennart Sorensen; +Cc: The development of GNU GRUB Lennart, I was able to make some progress installing GRUB and Legacy GRUB onto my ancient 80486 computer. Right now I have Legacy GRUB installed as the primary boot loader on the MBR. From there I can boot GRUB via 'kernel /grub2/core.img'. However, once I try to load a kernel it reports "cannot allocate real mode pages". lsmmap reports "base_addr - 0x100000, length = 0x3fffc00, type = 0x1". What can I do to debug this further? - Matthew ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: "Illegal Instruction" error in grub_script_comments 2016-10-19 15:32 ` Matthew Whitehead 2016-10-19 19:06 ` Lennart Sorensen @ 2016-10-20 17:34 ` Andrei Borzenkov 1 sibling, 0 replies; 8+ messages in thread From: Andrei Borzenkov @ 2016-10-20 17:34 UTC (permalink / raw) To: The development of GNU GRUB, Lennart Sorensen 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 > ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2016-10-31 3:17 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 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).