Page 1 of 1

64 Bit Kernel With Grub

Posted: Tue Feb 12, 2008 5:01 pm
by os.hacker64
My understanding is that GRUB will load an ELF64 kernel into long mode is this correct?

Posted: Tue Feb 12, 2008 5:24 pm
by ucosty
Not as far as I'm aware.

Posted: Tue Feb 12, 2008 5:28 pm
by os.hacker64
How do the 64 bit Linuxes do it?

Posted: Tue Feb 12, 2008 5:31 pm
by ucosty
Some sort of stub, no doubt.

Posted: Wed Feb 13, 2008 1:17 am
by xyzzy
Grub will enter it in 32-bit protected mode. It's up to you to write some 32-bit ASM code in that will get you into long mode.

Posted: Wed Feb 13, 2008 2:58 am
by bluecode
Grub woun't load a elf64 file either. At least not unpatched.

Posted: Wed Feb 13, 2008 3:01 am
by AJ
I tackle this by loading a 32 bit elf second stage boot loader as the 'kernel' in GRUB. The actual kernel is loaded as a module, which my 32 bit elf loader relocates.

Cheers,
Adam

Posted: Wed Feb 13, 2008 3:36 am
by ucosty
I should also mention that Linux kernel images are treated as a special case by GRUB as they're not multiboot compliant.

Posted: Wed Feb 13, 2008 6:57 am
by binutils
grub-32 loads linux_kernel which is compiled by pure-64 gcc, i.e. 64bit kernel.
But, grub-32 itself doesn't compiled by pure-64 gcc, ATM.
Better off to try lilo.

Posted: Wed Feb 13, 2008 7:21 am
by xyzzy
binutils wrote:grub-32 loads linux_kernel which is compiled by pure-64 gcc, i.e. 64bit kernel.
GRUB puts any Linux kernel it loads on x86, regardless of whether it's 32-bit or 64-bit, in 16-bit real-mode. Therefore, Linux still has some 16-bit real mode startup code on both i386 and x86_64, with some extra code for x86_64 to get it into long mode.

Posted: Wed Feb 13, 2008 7:39 am
by binutils
AlexExtreme wrote:
binutils wrote:grub-32 loads linux_kernel which is compiled by pure-64 gcc, i.e. 64bit kernel.
GRUB puts any Linux kernel it loads on x86, regardless of whether it's 32-bit or 64-bit, in 16-bit real-mode. Therefore, Linux still has some 16-bit real mode startup code on both i386 and x86_64, with some extra code for x86_64 to get it into long mode.
weird, gnu grub is in real-mode? i thought it is protected-mode.
lilo is ofcourse real-mode, it depend on bin86.

Posted: Wed Feb 13, 2008 7:41 am
by bluecode
binutils wrote:weird, gnu grub is in real-mode? i thought it is protected-mode.
grub does not just support multiboot.

Posted: Wed Feb 13, 2008 7:44 am
by xyzzy
Linux has always been started in real-mode on i386 and x86_64. AFAIK Grub does run in 32-bit pmode, but it definitely drops back to 16-bit real mode when loading a Linux kernel