No description
e96e785580
While testing the 86-DOS lDebug [1] booting from GRUB2, newer versions of the debugger would fail to load when booted using GRUB's freedos command. The behaviour observed in a qemu i386 machine was that the ROM-BIOS's boot load would start anew, instead of loading the selected debugger as kernel. It came to light that there was a size limit: Kernel files that were 58880 bytes (E600h) long or shorter succeeded to boot, while files that were 64000 bytes or longer failed in the manner described. Eventually it turned out that the relocator16 stub succeeded whenever it was placed completely within the first 64 KiB of the Low Memory Area. The chunk for the relocator is allocated with a minimum address of 0x8010 and a maximum address just below 0xA0000 [2]. That means if the kernel is, for instance, E600h bytes long, then the kernel will be allocated memory starting at 00600h (the fixed FreeDOS kernel load address) up to E600h + 00600h = 0EC00h, which leaves 1400h (5120) bytes for the relocator to stay in the first 64 KiB. If the kernel is 64000 bytes (FA00h) long, then the relocator must go to FA00h + 00600h = 10000h at least which is outside the first 64 KiB. The problem is that the relocator16 initialises the DS register with a "pseudo real mode" descriptor, which is defined with a segment limit of 64 KiB and a segment base of zero. After that, the relocator addressed parts of itself (implicitly) using the DS register, with an offset from ESI, which holds the linear address of the relocator's base [3]. With the larger kernel files this would lead to accessing data beyond the 64 KiB segment limit, presumably leading to a fault and perhaps a subsequent triple-fault or such. This patch fixes the relocator to set the segment base of the descriptors to the base address of the relocator; then, the subsequent accesses to the relocator's variables are done without the ESI register as an index. This does not interfere with the relocator's or its target's normal operation; the segment limits are still loaded with 64 KiB and all the segment bases are subsequently reset by the relocator anyway. Current versions of the debugger to test are uploaded to [4]. The file ldebugnh.com (LZ4-compressed and built with -D_EXTHELP=0) at 58368 bytes loads successfully, whereas ldebug.com at 64000 bytes fails. Loading one of these files requires setting root to a FAT FS partition and using the freedos command to specify the file as kernel: set root='(hd0,msdos1)' freedos /ldebug.com boot Booting the file using the multiboot command (which uses a WIP entrypoint of the debugger) works, as it does not use GRUB's relocator16 but instead includes a loader in the kernel itself, which drops it back to 86 Mode. [1]: https://hg.ulukai.org/ecm/ldebug [2]: http://git.savannah.gnu.org/cgit/grub.git/tree/grub-core/lib/i386/relocator.c?id=495781f5ed1b48bf27f16c53940d6700c181c74c#n127 [3]: http://git.savannah.gnu.org/cgit/grub.git/tree/grub-core/lib/i386/relocator16.S?id=495781f5ed1b48bf27f16c53940d6700c181c74c#n97 [4]: https://ulukai.org/ecm/lDebug-5479a7988d21-nohelp.zip Signed-off-by: C. Masloch <pushbx@ulukai.org> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com> |
||
---|---|---|
asm-tests | ||
conf | ||
docs | ||
grub-core | ||
include | ||
po | ||
tests | ||
themes/starfield | ||
unicode | ||
util | ||
.gitattributes | ||
.gitignore | ||
.travis.yml | ||
acinclude.m4 | ||
AUTHORS | ||
autogen.sh | ||
bootstrap | ||
bootstrap.conf | ||
BUGS | ||
ChangeLog-2015 | ||
config.h.in | ||
configure.ac | ||
COPYING | ||
coreboot.cfg | ||
geninit.sh | ||
gentpl.py | ||
INSTALL | ||
linguas.sh | ||
Makefile.am | ||
Makefile.util.def | ||
NEWS | ||
README | ||
THANKS | ||
TODO |
This is GRUB 2, the second version of the GRand Unified Bootloader. GRUB 2 is rewritten from scratch to make GNU GRUB cleaner, safer, more robust, more powerful, and more portable. See the file NEWS for a description of recent changes to GRUB 2. See the file INSTALL for instructions on how to build and install the GRUB 2 data and program files. Please visit the official web page of GRUB 2, for more information. The URL is <http://www.gnu.org/software/grub/grub.html>. More extensive documentation is available in the Info manual, accessible using 'info grub' after building and installing GRUB 2. There are a number of important user-visible differences from the first version of GRUB, now known as GRUB Legacy. For a summary, please see: info grub Introduction 'Changes from GRUB Legacy'