Hello,
to circumvent the problems I had with GRUB2 loading my AMD64 kernel, I decided to write a small loader binary in 32 bits that resides in the lower half, does the long mode readying stuff, loads the kernel ELF64 binary that is attached as a multiboot1 module and jump to its entry point.
Although the last point on the list might sound simplest, its actually the one I have most of the problems with. To jump to the 64 bit higher half entry point address (somewhere near 0xFFFFFF000000000), I planned to far jump to a 64 bit realm in the loader itself, that performs the jump to the actual entry point. My problem is to embed this 64 bit realm into my elf32 kernel. I tried the following approach, but it did not work out (machine resetting):
Code:
; mov rax, [0x1002]
; Entry point address QWORD is stored at 0x1002
db 0x48
db 0x8b
db 0x04
db 0x25
db 0x02
db 0x10
db 0x00
; Spacer
db 0x0
; jmp rax
db 0xff
db 0xe0
It's not a really clean approach and I really don't know how to debug the code above, so is there any way of jumping to this high entry point address besides of making the binary elf64 itself (GRUB Legacy, unpatched, and I want it to stay this way) and linking the 64 bit realm to it or adding another module that contains just these few bytes of 64 bit code?