What can go wrong on long mode activation ?
Posted: Sun Jun 13, 2010 5:54 am
Hello everyone !
I run an assembly snippet heavily inspired from AMD's code which theoretically
1/Checks long mode availability
2/Sets PAE bit
3/Loads the right CR3 value
4/Sets LME bit
5/Grabs CR0's value, sets bit 31 ("PG"), puts it back in CR0, then long jumps at 64-bit code entry point.
And which practically
1/Checks long mode availability
2/Sets PAE bit
3/Loads the right CR3 value
4/Sets LME bit
5/Triple faults
I'm not ready to give up and ask if somebody may have a look at my code yet, I just want to know in exactly which circumstances an exception (most likely #GP) may be triggered at step 5.
AMD mentions the following :
Apart from that, other options could be...
1/I jump in an NX section
-> No. The section of memory is not NX
2/My page table is not properly identity-mapped or there's something else fundamentally wrong in the way I create it
-> No, at least not as far as I can tell
...and ?
Could someone provide me with a more extensive list of everything which can go wrong during long mode activation ?
I run an assembly snippet heavily inspired from AMD's code which theoretically
1/Checks long mode availability
2/Sets PAE bit
3/Loads the right CR3 value
4/Sets LME bit
5/Grabs CR0's value, sets bit 31 ("PG"), puts it back in CR0, then long jumps at 64-bit code entry point.
And which practically
1/Checks long mode availability
2/Sets PAE bit
3/Loads the right CR3 value
4/Sets LME bit
5/Triple faults
I'm not ready to give up and ask if somebody may have a look at my code yet, I just want to know in exactly which circumstances an exception (most likely #GP) may be triggered at step 5.
AMD mentions the following :
Not likely, since LME & PAE are both set.If ((EFER.LME=1) & (CR4.PAE=0) then #GP(0)
Not likely either. I did not check the GRUB-provided segments, but why should a dirty old bootloader from the 32-bit era set CS.L ?If ((EFER.LME=1) & (CS.L=1)) then #GP(0)
Apart from that, other options could be...
1/I jump in an NX section
-> No. The section of memory is not NX
2/My page table is not properly identity-mapped or there's something else fundamentally wrong in the way I create it
-> No, at least not as far as I can tell
...and ?
Could someone provide me with a more extensive list of everything which can go wrong during long mode activation ?