64bit High Mem kernel

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
untwisted
Posts: 19
Joined: Wed Feb 13, 2008 1:36 pm
Location: Pittsburgh
Contact:

64bit High Mem kernel

Post by untwisted »

Hey all, been lurking waiting to see if there are any questions I could help with, but I think I'm still a bit too new at the 'game' to help much. In any case, if you would be so kind, I have another question on my hands.

I'm trying to move my kernel to high memory via ld script. I have checked out the wiki on how to do it with a 32 bit kernel, but to make the jump long mode we need paging enabled, which means (if I'm understanding it correctly) that the trick won't work for x86_64. I tried to fudge with some linker scripts to place part of our code in low mem, and the rest in high mem, but it doesn't seem to work. I created a new section right before the jump to 64 bit code in my boot.S and tried to load that and everything after it in to high mem, but am getting some relocation errors.

If anyone could point me in the right direction on how to move my kernel it'd be much appreciated :)

Thanks!
Last edited by untwisted on Sat Mar 01, 2008 8:54 pm, edited 1 time in total.
--untwisted
http://www.pittgeeks.org
XOmB exokernel project: http://xomb.org
SpooK
Member
Member
Posts: 260
Joined: Sun Jun 18, 2006 7:21 pm

Post by SpooK »

I think THIS THREAD may assist you.
speal
Member
Member
Posts: 43
Joined: Wed Mar 07, 2007 10:09 am
Location: Minneapolis, Minnesota
Contact:

Post by speal »

I've set up an upper-memory kernel (long mode).

My linker script is here:
http://www.devlime.com/browser/trunk/ke ... /linker.ld

The executable is linked to a physical address of 0x1000000, but a virtual address 0xFFFFFFFF80000000

The booting process (using GRUB) is:

1. Start a 32 bit stub kernel with GRUB, and pass in the 64 bit kernel as as multiboot module
2. Set up a top level page directory (long mode paging) and GDT
3. The 32 bit loader reads modules, copies the kernel to its specified physical address and maps these pages to the specified virtual address range
4. Identity map physical memory up to the top of the stub kernel executable
5. Enable long mode, and then turn on paging to make the long mode switch
6. Do a long jump to another part of the loader, using the 64 bit code segment
7. Jump to the 64 bit kernel's entry address
User avatar
untwisted
Posts: 19
Joined: Wed Feb 13, 2008 1:36 pm
Location: Pittsburgh
Contact:

Post by untwisted »

Thanks for the info! We weren't sure if we could just use the linker script and place our output in two different places or if we'd have to take the route that you went. With limited time we only had a chance to try one of them, and when that failed abysmally I figured I'd come ask before we sat around breaking things for too much longer.

You guys are great! <3
--untwisted
http://www.pittgeeks.org
XOmB exokernel project: http://xomb.org
Post Reply