Results 1 to 6 of 6
CPU - Intel x86
Quick Question....
In Linux the only segment register used are %cs, %ss and %ds and these are represented with
the macros __KERNEL_CS, __KERNEL_DS, __USER_CS, __USER_DS (intel ...
- 03-17-2009 #1
es register what do you do?
CPU - Intel x86
Quick Question....
In Linux the only segment register used are %cs, %ss and %ds and these are represented with
the macros __KERNEL_CS, __KERNEL_DS, __USER_CS, __USER_DS (intel 32 bit). Now
I have no problems with this concept and I understand how the %cs, %ss and %ds registers
switch between user to kernel and back again...what I do have problems understanding is the %es register
and how it fits into this picture as you can see in this code snippet from a entry.S file the %es register
is not only saved it is loaded with the __KERNEL_DS value....Thank-you for any replies Gerard4143
Code:#define SAVE_ALL \ cld; \ pushl %es; \ pushl %ds; \ pushl %eax; \ pushl %ebp; \ pushl %edi; \ pushl %esi; \ pushl %edx; \ pushl %ecx; \ pushl %ebx; \ movl $(__KERNEL_DS),%edx; \ movl %edx,%ds; \ movl %edx,%es;
Make mine Arch Linux
- 03-20-2009 #2Just Joined!
- Join Date
- Mar 2009
- Location
- Norway
- Posts
- 52
AFAIK, there are 6 segment regs, but only 3 have a dedicated purpose (cs, ds and ss). The remaining 3 (es, fs, gs) can be used for whatever you like, basically. So, no macro has been defined to save/restore or get the contents of these, but the kernel must handle it anyway.
As to why SAVE_ALL only handles es, I do not really know. According to the great book (UTLK 3rd ed), es is used 'for pointers to user data structures (the kernel explicitly uses the es register)'
Did this answer your question?
- 03-20-2009 #3
- 03-20-2009 #4
- 03-20-2009 #5Just Joined!
- Join Date
- Mar 2009
- Location
- Norway
- Posts
- 52
by user data structures, I mean what UTLK said

Section 2.3.* Segmentation in Linux
Try asking this on kernelnewbies, lots of skilled aspiring (and seasoned) hackers there
- 03-20-2009 #6


Reply With Quote

