GRUB2 fails to load kernel in bochs and VirtualBox

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
farlepet
Posts: 13
Joined: Sun Dec 30, 2012 12:52 pm

GRUB2 fails to load kernel in bochs and VirtualBox

Post by farlepet »

Hello,

I am using GRUB2 to boot my kernel, and this always works in qemu. But when I use bochs or VirtualBox, it only works if its built for x86. If I build it for x86_64, it doesn't successfully load the kernel.

Using `debug=all` this is what GRUB2 stalls at:

Code: Select all

kern/dl.c:619: module name: relocator
kern/dl.c:620: init function: 0x0
kern/disk.c:196: Opening `hd96'...
kern/fs.c:56: Detecting iso9660...
kern/disk.c:295: Closing `hd96'.
kern/dl.c:572: module at 0x1f6db30, size 0x8e8
kern/dl.c:596: relocating to 0x1f6ebc0
kern/dl.c:560: flushing 0x6fe bytes at 0x1f6e490
kern/dl.c:619: module name: lsapm
kern/dl.c:620: init function: 0x1f6e664
kern/disk.c:196: Opening `hd96'...
kern/fs.c:56: Detecting iso9660...
kern/disk.c:295: Closing `hd96'.
kern/dl.c:572: module at 0x1f6b0f0, size 0x26d0
kern/dl.c:596: relocating to 0x1f6e3f0
kern/dl.c:560: flushing 0x24bb bytes at 0x1f52890
kern/dl.c:619: module name: acpi
kern/dl.c:620: init function: 0x1f53862
kern/dl.c:560: flushing 0x31cf bytes at 0x1f6a5f0
kern/dl.c:619: module name: multiboot2
kern/dl.c:620: init function: 0x1f6b184
kern/disk.c:196: Opening `hd96'...
kern/fs.c:56: Detecting iso9660...
lib/relocator.c:115: relocators_size=7
And the last lines of output from bochs:

Code: Select all

00017896941i[BIOS ] Booting from 07c0:0000
00017905792i[MEM0 ] allocate_block: block=0x1 used 0x3 of 0x20
00048688780i[MEM0 ] allocate_block: block=0x1e used 0x4 of 0x20
Does anyone know what is happening/if I did anything wrong? I will provide boot code if needed, but it SEEMS as if it doesn't even make it to that point at all.

Any help on this problem would be greatly appreciated.
Lambda OS:
GitHub: https://github.com/farlepet
bigorenski
Posts: 14
Joined: Thu May 09, 2013 5:51 pm

Re: GRUB2 fails to load kernel in bochs and VirtualBox

Post by bigorenski »

Try using a 32bit bootstrap for your 64bit code.
User avatar
farlepet
Posts: 13
Joined: Sun Dec 30, 2012 12:52 pm

Re: GRUB2 fails to load kernel in bochs and VirtualBox

Post by farlepet »

You do mean start in 32-bit mode and then jump into 64-bit mode, correct? If so, I already do that. GRUB will always hand control to the kernel in 32-bit mode regardless of the bittiness of the ELF, correct?
Lambda OS:
GitHub: https://github.com/farlepet
Post Reply