Page 1 of 1

Syscalls and privilege levels

Posted: Sun Feb 22, 2004 11:29 pm
by mr. x
Hello.
I'm wondering, how are these syscalls working?
The only way for a user app to communicate with the kernel is through software interrupts.

Second, privilege levels. How do I set which level I want? How do I disable things like hlt?

Re:Syscalls and privilege levels

Posted: Mon Feb 23, 2004 5:14 am
by Pype.Clicker
things like 'hlt' and 'cli' are automatically disabled at level>0.
You can 'select' the required PL by entering a code segment that has that PL in its descriptor.

In order to go to a more-priviledged segment, you need either to call an INT nn or to use a Call Gate ... to go to a less-priviledged segment, you need to fake a 'return' from one of the latter events ...

Re:Syscalls and privilege levels

Posted: Mon Feb 23, 2004 5:24 am
by Candy
mr. x wrote: Hello.
I'm wondering, how are these syscalls working?
The only way for a user app to communicate with the kernel is through software interrupts.
On newer processors, try searching for SYSENTER / SYSCALL in the manuals. Allows fast calls within a certain environment.

Re:Syscalls and privilege levels

Posted: Mon Feb 23, 2004 1:42 pm
by mr. x
I've seen that I need a TSS to have two PL stacks, kernel stack and user stack.
I can't find any information about how to set a TSS up, does someone have a link to any?
A link to a page describing callgates would be nice too.

Re:Syscalls and privilege levels

Posted: Tue Feb 24, 2004 2:52 am
by Candy
mr. x wrote: I've seen that I need a TSS to have two PL stacks, kernel stack and user stack.
I can't find any information about how to set a TSS up, does someone have a link to any?
A link to a page describing callgates would be nice too.
Intel Manuals, AMD Manuals both describe this. Look for "Hardware task switching" or "TSS" or under "LTR" for references.

Re:Syscalls and privilege levels

Posted: Tue Feb 24, 2004 3:59 am
by ineo
I've read the intel docs about SYSENTER/SYSEXIT, but I can't figure how to define entry points. Do you have any experience of it ? How should I do it ? Do I have to use some kind of library that will be loaded at a given place ?
Furthermore do you know if it is easy to port to non-x86 architecture (I didn't find something similar on the ultrasparc, however I'm no expert) ?

Re:Syscalls and privilege levels

Posted: Tue Feb 24, 2004 4:51 am
by Candy
ineo wrote: I've read the intel docs about SYSENTER/SYSEXIT, but I can't figure how to define entry points. Do you have any experience of it ? How should I do it ? Do I have to use some kind of library that will be loaded at a given place ?
Unfortunately my TRAMP-module is in the fridge (it's not being worked on) so I can't say I have experience with it. The docs say though that you can use RDMSR and WRMSR on the three registers that it uses to define the segments and both the EIP and ESP entry values. You can try to run this on bochs, but as I've tried PAE (which is just as supported officially) I can tell you that there's a damn high chance that it still doesn't work. Real CPU's should work though.