[syslinux] Is it possible to chainload EXTLINUX from GRUB?

Gavin D. Smith gds24 at cam.ac.uk
Tue Oct 24 16:01:08 PDT 2006


On Oct 24 2006, H. Peter Anvin wrote:

>Gavin D. Smith wrote:
>>> You're assuming that just because GRUB and LILO can be loaded that it 
>>> is all done correctly.  GRUB and LILO might not rely on, for example, 
>>> the DS:SI pointer (given their design methodology I would almost 
>>> assume they don't.)
>>>
>>> For debugging, I would run this in an simulator and set a breakpoint 
>>> at 0:7C00h.  This will be hit several times, one of which will be 
>>> EXTLINUX entry; at this point examine the registers, and the memory 
>>> pointed to by DS:SI (16 bytes) and ES:DI (64 bytes or so.)
>>>
>>>     -hpa
>>>
>> 
>> Well I finally managed to create a disk image for use in a simulator and 
>> have managed to recreate the behaviour. I can indeed view these 
>> registers, however I don't know how to interpret these registers or the 
>> memory to which they point. If I knew what they were meant to contain 
>> then I would know that GRUB was at fault and could complain to them. I 
>> can send terminal logs to this list to show the contents of these 
>> registers if that would be helpful.
>> 
>
>Yes, please.
>
>The registers are supposed to have the following values:
>
>DL is supposed to have the drive number.
>DS:SI is supposed to point to the 16-byte partition entry, which 
>typically should be located in memory between address 0x600 and 0x800.
>ES:DI is supposed to point to the $PnP header.
>
>	-hpa
>

Here we go. The following is chainloading extlinux on a primary partition, 
which succeeds.

#####################
bash# bochs
00000000000i[APIC?] local apic in  initializing
========================================================================
                        Bochs x86 Emulator 2.3
              Build from CVS snapshot on August 27, 2006 
======================================================================== 
00000000000i[ ] LTDL_LIBRARY_PATH not set. using compile time default 
'/usr/local/lib/bochs/plugins' 00000000000i[ ] BXSHARE not set. using 
compile time default '/usr/local/share/bochs' 00000000000i[ ] reading 
configuration from bochsrc 00000000000e[ ] bochsrc: ips directive is 
DEPRECATED (use cpu directive parameter 'ips'). 
------------------------------ Bochs Configuration: Main Menu 
------------------------------

This is the Bochs Configuration Interface, where you can describe the
machine that you want to simulate.  Bochs has already searched for a
configuration file (typically called bochsrc.txt) and loaded it if it
could be found.  When you are satisfied with the configuration, go
ahead and start the simulation.

You can also start bochs with the -q option to skip these menus.

1. Restore factory default configuration
2. Read options from...
3. Edit options
4. Save options to...
5. Restore the Bochs state from...
6. Begin simulation
7. Quit now

Please choose one: [6] 00000000000i[ ] lt_dlhandle is 0x83172d8 
00000000000i[PLGIN] loaded plugin libbx_x.la 00000000000i[ ] installing x 
module as the Bochs GUI 00000000000i[ ] using log file bochsout.txt Next at 
t=0 (0) [0xfffffff0] f000:fff0 (unk. ctxt): jmp far f000:e05b ; ea5be000f0 
<bochs:1> b 0:0x7c00 <bochs:2> c (0) Breakpoint 1, 0x00007c00 in ?? () Next 
at t=1034557 (0) [0x00007c00] 0000:7c00 (unk. ctxt): jmp .+0x0049 
(0x00007c4b) ; eb49 <bochs:3> c ---------------(select item in GRUB) (0) 
Breakpoint 1, 0x00007c00 in ?? () Next at t=184772978 (0) [0x00007c00] 
0000:7c00 (unk. ctxt): jmp .+0x0058 (0x00007c5a) ; eb58 <bochs:4> r eax: 
0x0 0 ecx: 0x0 0 edx: 0x80 128 ebx: 0x20f60 135008 esp: 0x1ff4 8180 ebp: 
0x1ff0 8176 esi: 0x7ce 1998 edi: 0x53e54 343636 eip: 0x7c00 eflags 0x246 
cs: 0x0 ss: 0x0 ds: 0x0 es: 0x0 fs: 0x0 gs: 0x0 <bochs:5> xp /16b ds:si 
[bochs]: 0x000007ce <bogus+ 0>: 0x80 0x00 0x01 0x20 0x83 0x03 0x20 0x3f 
0x000007d6 <bogus+ 8>: 0x00 0x10 0x00 0x00 0x00 0x10 0x00 0x00 <bochs:6> xp 
/64b es:di [bochs]: 0x00003e54 <bogus+ 0>: 0xd1 0x09 0xc1 0x74 0x08 0x8b 
0xbd 0x74 0x00003e5c <bogus+ 8>: 0xff 0xff 0xff 0xeb 0x16 0x8b 0x85 0x6c 
0x00003e64 <bogus+ 16>: 0xff 0xff 0xff 0x8b 0xbd 0x68 0xff 0xff 0x00003e6c 
<bogus+ 24>: 0xff 0x0f 0xaf 0xf8 0x0f 0xaf 0xbd 0x70 0x00003e74 <bogus+ 
32>: 0xff 0xff 0xff 0x8d 0x46 0x08 0x50 0x8d 0x00003e7c <bogus+ 40>: 0x46 
0x04 0x50 0x56 0xff 0x75 0x08 0xe8 0x00003e84 <bogus+ 48>: 0xd6 0xe5 0xff 
0xff 0x83 0xc4 0x10 0x85 0x00003e8c <bogus+ 56>: 0xc0 0x75 0x43 0x85 0xff 
0x75 0x0c 0x8b <bochs:9> c ----------- and I get the extlinux prompt 
=====================


The following is where the problem is, chainloading extlinux on a logical 
partition.

=====================
bash# bochs
00000000000i[APIC?] local apic in  initializing
========================================================================
                        Bochs x86 Emulator 2.3
              Build from CVS snapshot on August 27, 2006 
======================================================================== 
00000000000i[ ] LTDL_LIBRARY_PATH not set. using compile time default 
'/usr/local/lib/bochs/plugins' 00000000000i[ ] BXSHARE not set. using 
compile time default '/usr/local/share/bochs' 00000000000i[ ] reading 
configuration from bochsrc 00000000000e[ ] bochsrc: ips directive is 
DEPRECATED (use cpu directive parameter 'ips'). 
------------------------------ Bochs Configuration: Main Menu 
------------------------------

This is the Bochs Configuration Interface, where you can describe the
machine that you want to simulate.  Bochs has already searched for a
configuration file (typically called bochsrc.txt) and loaded it if it
could be found.  When you are satisfied with the configuration, go
ahead and start the simulation.

You can also start bochs with the -q option to skip these menus.

1. Restore factory default configuration
2. Read options from...
3. Edit options
4. Save options to...
5. Restore the Bochs state from...
6. Begin simulation
7. Quit now

Please choose one: [6] 00000000000i[ ] lt_dlhandle is 0x83172d8 
00000000000i[PLGIN] loaded plugin libbx_x.la 00000000000i[ ] installing x 
module as the Bochs GUI 00000000000i[ ] using log file bochsout.txt Next at 
t=0 (0) [0xfffffff0] f000:fff0 (unk. ctxt): jmp far f000:e05b ; ea5be000f0 
<bochs:1> b 0:0x7c00 <bochs:2> c (0) Breakpoint 1, 0x00007c00 in ?? () Next 
at t=997053 (0) [0x00007c00] 0000:7c00 (unk. ctxt): jmp .+0x0049 
(0x00007c4b) ; eb49 <bochs:3> c -------------(select item in GRUB) (0) 
Breakpoint 1, 0x00007c00 in ?? () Next at t=281365770 (0) [0x00007c00] 
0000:7c00 (unk. ctxt): jmp .+0x0058 (0x00007c5a) ; eb58 <bochs:4> r eax: 
0x0 0 ecx: 0x0 0 edx: 0x80 128 ebx: 0x20f60 135008 esp: 0x1ff4 8180 ebp: 
0x1ff0 8176 esi: 0x7be 1982 edi: 0x53e54 343636 eip: 0x7c00 eflags 0x246 
cs: 0x0 ss: 0x0 ds: 0x0 es: 0x0 fs: 0x0 gs: 0x0 <bochs:5> xp /16b ds:si 
[bochs]: 0x000007be <bogus+ 0>: 0x80 0x01 0x01 0x60 0x83 0x03 0x20 0x7e 
0x000007c6 <bogus+ 8>: 0x20 0x00 0x00 0x00 0x60 0x0f 0x00 0x00 <bochs:6> xp 
/64b es:di [bochs]: 0x00003e54 <bogus+ 0>: 0xd1 0x09 0xc1 0x74 0x08 0x8b 
0xbd 0x74 0x00003e5c <bogus+ 8>: 0xff 0xff 0xff 0xeb 0x16 0x8b 0x85 0x6c 
0x00003e64 <bogus+ 16>: 0xff 0xff 0xff 0x8b 0xbd 0x68 0xff 0xff 0x00003e6c 
<bogus+ 24>: 0xff 0x0f 0xaf 0xf8 0x0f 0xaf 0xbd 0x70 0x00003e74 <bogus+ 
32>: 0xff 0xff 0xff 0x8d 0x46 0x08 0x50 0x8d 0x00003e7c <bogus+ 40>: 0x46 
0x04 0x50 0x56 0xff 0x75 0x08 0xe8 0x00003e84 <bogus+ 48>: 0xd6 0xe5 0xff 
0xff 0x83 0xc4 0x10 0x85 0x00003e8c <bogus+ 56>: 0xc0 0x75 0x43 0x85 0xff 
0x75 0x0c 0x8b <bochs:7> c -------- whereupon extlinux displays the "Boot 
error" message. =======================

Hope you can make sense of some of this!

(Extra infomation, which may be of interest:)
=======================
bash# sfdisk -l -uS c.img
Disk c.img: cannot get geometry

Disk c.img: 0 cylinders, 0 heads, 0 sectors/track
Warning: The partition table looks like it was made
  for C/H/S=*/4/32 (instead of 0/0/0).
For this listing I'll assume that geometry.
Units = sectors of 512 bytes, counting from 0

   Device Boot    Start       End   #sectors  Id  System
   c.img1            32      4095       4064  83  Linux
   c.img2          4096      8191       4096  83  Linux
   c.img3          8192     12287       4096  83  Linux
   c.img4         12288     16383       4096   5  Extended
   c.img5         12320     16255       3936  83  Linux
bash# cat bochsrc
megs: 32
romimage: file=$BXSHARE/BIOS-bochs-latest, address=0xf0000
vgaromimage: file=$BXSHARE/VGABIOS-lgpl-latest
vga: extension=vbe
#floppya: 1_44=a.img, status=inserted
#floppyb: 1_44=b.img, status=inserted
ata0-master: type=disk, path=c.img, cylinders=64, heads=16, spt=16
boot: c
log: bochsout.txt
mouse: enabled=0
ips: 15000000
vga_update_interval: 150000
bash# 
========================





More information about the Syslinux mailing list