64 Bit Kernel With Grub

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
os.hacker64
Member
Member
Posts: 149
Joined: Mon Feb 11, 2008 4:43 pm
Location: Limbo City,Afterlife

64 Bit Kernel With Grub

Post by os.hacker64 »

My understanding is that GRUB will load an ELF64 kernel into long mode is this correct?
User avatar
ucosty
Member
Member
Posts: 271
Joined: Tue Aug 08, 2006 7:43 am
Location: Sydney, Australia

Post by ucosty »

Not as far as I'm aware.
The cake is a lie | rackbits.com
User avatar
os.hacker64
Member
Member
Posts: 149
Joined: Mon Feb 11, 2008 4:43 pm
Location: Limbo City,Afterlife

Post by os.hacker64 »

How do the 64 bit Linuxes do it?
User avatar
ucosty
Member
Member
Posts: 271
Joined: Tue Aug 08, 2006 7:43 am
Location: Sydney, Australia

Post by ucosty »

Some sort of stub, no doubt.
The cake is a lie | rackbits.com
xyzzy
Member
Member
Posts: 391
Joined: Wed Jul 25, 2007 8:45 am
Libera.chat IRC: aejsmith
Location: London, UK
Contact:

Post 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.
User avatar
bluecode
Member
Member
Posts: 202
Joined: Wed Nov 17, 2004 12:00 am
Location: Germany
Contact:

Post by bluecode »

Grub woun't load a elf64 file either. At least not unpatched.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post 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
User avatar
ucosty
Member
Member
Posts: 271
Joined: Tue Aug 08, 2006 7:43 am
Location: Sydney, Australia

Post by ucosty »

I should also mention that Linux kernel images are treated as a special case by GRUB as they're not multiboot compliant.
The cake is a lie | rackbits.com
User avatar
binutils
Member
Member
Posts: 214
Joined: Thu Apr 05, 2007 6:07 am

Post 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.
xyzzy
Member
Member
Posts: 391
Joined: Wed Jul 25, 2007 8:45 am
Libera.chat IRC: aejsmith
Location: London, UK
Contact:

Post 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.
User avatar
binutils
Member
Member
Posts: 214
Joined: Thu Apr 05, 2007 6:07 am

Post 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.
User avatar
bluecode
Member
Member
Posts: 202
Joined: Wed Nov 17, 2004 12:00 am
Location: Germany
Contact:

Post by bluecode »

binutils wrote:weird, gnu grub is in real-mode? i thought it is protected-mode.
grub does not just support multiboot.
xyzzy
Member
Member
Posts: 391
Joined: Wed Jul 25, 2007 8:45 am
Libera.chat IRC: aejsmith
Location: London, UK
Contact:

Post 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
Post Reply