Grub incorrectly assumes that an old kernel has 4 setup sectors even if "setup_sects" field at offset 0x1F1 in kernel image isn't 0. (see /usr/src/linux/Documentation/i386/boot.txt) This isn't very important today... but I expect that the standard kernel boot protocol is respected! The fix should be trivial: file "grub-0.94/stage2/boot.c" remove the offending line else { /* Your kernel is quite old... */ lh->cl_magic = LINUX_CL_MAGIC; lh->cl_offset = LINUX_CL_OFFSET; setup_sects = LINUX_DEFAULT_SETUP_SECTS; <------- OFFENDING LINE linux_data_real_addr = (char *) LINUX_OLD_REAL_MODE_ADDR; } /* If SETUP_SECTS is not set, set it to the default (4). */ if (! setup_sects) setup_sects = LINUX_DEFAULT_SETUP_SECTS; Reproducible: Always Steps to Reproduce: 1. 2. 3.
Created attachment 40080 [details, diff] fix Grub for old kernels
By "old" how "old" do you mean?! I haven't been able to find a kernel old enough that gcc-3.4 will compile to test this! Any chance you can provide me with a version number or similar for one?
Very OLD ;-) (from /usr/src/linux/Documentation/i386/boot.txt) ----------------- Old kernels: zImage/Image support only. Some very early kernels may not even support a command line. Protocol 2.00: (Kernel 1.3.73) Added bzImage and initrd support, as well as a formalized way to communicate between the boot loader and the kernel. setup.S made relocatable, although the traditional setup area still assumed writable. ----------------- so every kernel before 1.3.73 ;-) I don't want to run so old kernels, of course, so the problem isn't for Linux! I've found it because I've written a very small and stupid kernel that respects the Linux/i386 boot protocol (OLD version)... it boots with LILO but GRUB incorrectly assumes that it has 4 setup sectors and so it doesn't work! There is a standard and every boot loader MUST respect it! LILO does, GRUB doesn't (due to a programming error IMHO). The fix I've already posted is trivial and correct, why don't apply it? (and send it to GRUB people, of course) If you want to TEST if an OLD kernel boots use my one: http://ornati.altervista.org/pablox-0.05-testing13.tar.gz Everything you need is explained in README, but you can just do: $ tar xzf pablox-0.05-testing13.tar.gz $ cd pablox $ make dep $ make now use the file IMAGE as a normal kernel image. Bye
Yeah, there IS a standard. It's called multiboot, and the Linux kernel doesn't respect it :-P Just by way of advice, I'd advise you to research the multiboot standard. Certainly all the *BSD kernels and the GNU Hurd kernel respect said standard. It's a good one, and it works. The Linux kernel "standard" is not really a standard. That said, this *is* a relatively trivial fix. However, to suggest that I know enough about the potential implications of this to apply it without going asking the people really in charge of grub first would be silly. So this patch is pending a reply from upstream.
That piece of code is only used with the Linux Kernel boot protocol and it doesn't affect anyone else, so my patch should be safe... Anyway I agree to wait for upstream reply. Bye
Well I would be inclined to agree, but I don't know if that bit, for example, works with versions of Linux kernel that aren't less than 1.3.73 but are, for example, less than 2.0.0. That said, it does look "wrong" to me, and your patch looks right. But upstream is king, I'm afraid.
"Documentation/i386/boot.txt" says: "For backwards compatibility, if the setup_sects field contains 0, the real value is 4." This means that some (not all) OLD kernels set it to 0 even if they have 4 setup sectors... and ALL the others set it to the value they want. After a quick search I've discovered some things: 1) the table in the end of the boot sector described by "Documentation/i386/boot.txt" was introduced somewhere between 1.0.0 and 1.1.0. 2) in the 1.1.0 table there isn't any "setup_sects" field, so it is automatically filled with 0 and that kernel has 4 setup sectors (this is the reason of the backwards compatibility rule). 3) somewhere between 1.1.0 and 1.2.0 the "setup_sects" field was introduced and it is correctly setted to the number of setup sectors... Anyway it seems that ALL kernels have 4 setup sectors... so GRUB, even ignoring that value for OLD kernels and using 4 instead, doesn't break any version at all! It breaks only PabloX ;-) Bye
The link I've posted to PabloX: "http://ornati.altervista.org/pablox-0.05-testing13.tar.gz" doesn't work in my browser (redirection) so if someone wants to try PabloX go to my home: http://ornati.altervista.org/ and download from it.
I've sent the patch upstream and the maintainers assure me they'll make sure you aren't breaking anything; if you indeed aren't, this will be in grub-0.96. If you are breaking things, it won't. Simple as that! :-)