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.
I tried to bring my AMD64 kernel into higher half (at 0xFFFFFF0000000000) using the following build script (Don't complain about the .text64 stuff, GRUB2 did not detect my kernel with the multiboot header
outside of .text):
As you see, I have two different loader binaries: loader32 and loader64. While the first sets up long mode and far jumps into the 64 bit loader (which is in lower half two), the latter one calls the kernel's main function. But I can't even get to this point: Booting the kernel GRUB dies with the following error message:
free magic is broken at 0x100100: 0x6db08fa4
That's kind of strange, as the lower memory part ends at 0x1000e4, and there's actually no 0x6db08fa4 in my kernel (at least not on a DWORD boundary)... Has someone of you guys already experienced this issue?
Your multiboot header looks perfectly fine to me, so I don't think that's the problem...
According to the GRUB 2 sources, this error message in generated in GRUB's (heap) memory management functions (grub_real_malloc, grub_free, grub_mm_dump_free) and indicates that some data structure has been corrupted. I guess that really should not happen unless your RAM is broken or your GRUB version is buggy. Which GRUB version are you using? Have you tested your kernel with GRUB Legacy / a different version?
I'm using some GRUB2 stage2 loader I've compiled on myself as an eltorito payload for a ISO9660. I don't know the exact version (is it mentioned somewhere in the files?) but its only a few months old. I've compiled the loader with these modules:
biosdisk terminal iso9660 mmap multiboot boot normal halt sleep
I haven't tried with GRUB Legacy, because this in an 64 bit kernel (I didn't know about the patch), but i'm currently thinking about switching back to it, loading a 32 bit kernel, which loads the 64 bit one as a module after the switch to long mode and the mapping of the higher half... Quite strange it did work out with GRUB2 when I was linking the kernel to the lower one.