Changing the CPL...

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
dr_watts

Changing the CPL...

Post by dr_watts »

I have been having a recent problem involving some task switch tests...  

Attempting a task switch to ring 0 is no problem, ring 3 however is currently a big problem:

We are using x86-64 hardware, which has no far jump instructions in 64-bit mode.
Instead, we setup what would be the return stack from an interrupt.  This should switch the cpl, setup the stack, and load the new RIP (64-bit IP) for a process.  This faults when we do an iretq,  with simics showing the last reads as to the GDT.  Our GP handler reports an error code of 0x10, our CS selector index in the GDT.  

All we want to complete is a switch to ring 3 from ring 0 so we can test interrupts and the like.

Other than setting up a GDT with a Code 64 Ring 3 selector, loading new page tables, and ireting from our stack, we are doing nothing.  Also, the code works just fine switching inside ring 0.  Any ideas?
Post Reply