SYSCALL/SYSRET Questions
Posted: Fri Nov 20, 2009 3:59 pm
Hi
Has anyone successfully implemented SYSCALL/SYSRET fastcall as the syscall mechinism in their OS?
I'm struggling to find a sensible way to use them. The obvious problem of not switching to the kernel stack is a pain. In an SMP system it isn't fun to find the kernel stack... without a stack... and would lead to a lot of uglyness in the syscall entry point. I can't just map the per thread kernel stack in a predefined location as all my threads in the same process to share the same PML4.
I read an old posting on a linux kernel development list where two developers were discussing SYSCALL/SYSRET. They mentioned changing the CS after a SYSCALL and before the SYSRET (ie. the thread being preempted while in the kernel) caused the processor to set some internal flag and raise a GP fault. You couldn't then iret to a different thread. Surely this can't be true?
With more googling I found a presentation that mentions a hidden part of the GS register available to use as a pointer to the kernel stack when using SYSCALL. Anyone know anything about this?
A software interrupt is looking better by the minute...
Has anyone successfully implemented SYSCALL/SYSRET fastcall as the syscall mechinism in their OS?
I'm struggling to find a sensible way to use them. The obvious problem of not switching to the kernel stack is a pain. In an SMP system it isn't fun to find the kernel stack... without a stack... and would lead to a lot of uglyness in the syscall entry point. I can't just map the per thread kernel stack in a predefined location as all my threads in the same process to share the same PML4.
I read an old posting on a linux kernel development list where two developers were discussing SYSCALL/SYSRET. They mentioned changing the CS after a SYSCALL and before the SYSRET (ie. the thread being preempted while in the kernel) caused the processor to set some internal flag and raise a GP fault. You couldn't then iret to a different thread. Surely this can't be true?
With more googling I found a presentation that mentions a hidden part of the GS register available to use as a pointer to the kernel stack when using SYSCALL. Anyone know anything about this?
A software interrupt is looking better by the minute...