Page 1 of 1
Jump to Long Mode Segment
Posted: Fri Nov 02, 2007 8:32 am
by AJ
Hi,
I am not there with the implementation yet, but am thinking about the design of the second-stage boot loader for my 64 bit OS. This is probably a simple yes/no answer, but can I do the following from 64-bit
compatiblity mode:
Code: Select all
jmp [long mode segment]:[64 bit offset]
or will I have to initially jump to a 32 bit offset to enable long mode and do a
second jump to a 64 bit offset once long mode is enabled?
Thanks for any help,
Adam
Re: Jump to Long Mode Segment
Posted: Fri Nov 02, 2007 10:40 am
by Brendan
Hi,
AJ wrote:I am not there with the implementation yet, but am thinking about the design of the second-stage boot loader for my 64 bit OS. This is probably a simple yes/no answer, but can I do the following from 64-bit
compatiblity mode:
Code: Select all
jmp [long mode segment]:[64 bit offset]
Simple answer is "no" - a (32-bit or 16-bit) compatability code segment in long mode can't use REX prefixes, and therefore can't use 64-bit addressing.
The more complex answer would be that you might be able to fake it by doing a SYSCALL (without any SYSRET) or a software interrupt (without any IRET), where the target code removes anything the CPU pushed on the stack. This is probably more hassle than it's worth though...
Cheers,
Brendan
Posted: Mon Nov 05, 2007 5:52 am
by AJ
Hi,
As I hadn't used syscall/sysret before, I was a little unsure about what to do here. For anyone else trying the same thing, I have just implemented the syscall mechanism to call my kernel which is at 0xF000000000 from 32 bit code and it works very nicely.
Thanks Brendan,
Adam