Question

When using sysenter to make a system call (switch execution from ring 3 to ring 0), this is how CS and SS are set:

CS = IA32_SYSENTER_CS
SS = IA32_SYSENTER_CS + 8

In whatever I have read from various sources, there is no mention of setting the data segment register (DS). Why is DS not changed when using sysenter ? For accessing any data, will the old value of DS be used ?

(I'm fairly new to this, so please point out any mistakes I may have made in understanding this)

Was it helpful?

Solution

ds and the other data segment registers are not changed automatically because they do not need to be. sysenter was designed to be as simple as possible, so that it would execute as quickly as possible. As part of this, many things are not done, including updating most segment registers and saving a return address. If the operating system needs these things to be done, it must make any changes manually.

It is entirely possible that the segment registers don't need to be changed. If the operating system is running in 64-bit mode, most segmentation is unused, so changing ds would not be necessary. For any mode, if the requested operation is simple, it might not require anything which involves accesses outside of the stack, so ds would again be unused.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top