> > I was looking at the SAVE_ALL code for kernel 2.6. > I am confused why SAVE_ALL restores __USER_DS to ds and es ? > > #define SAVE_ALL \ > cld; \ > pushl %fs; \ > pushl %es; \ > pushl %ds; \ > pushl %eax; \ > pushl %ebp; \ > pushl %edi; \ > pushl %esi; \ > pushl %edx; \ > pushl %ecx; \ > pushl %ebx; \ > movl $(__USER_DS), %edx; \ <---- why __USER_DS ? > movl %edx, %ds; \ > movl %edx, %es; \ > movl $(__KERNEL_PDA), %edx; \ > movl %edx, %fs > > > If you look at the linux 2.4, it restores __KERNEL_DS in SAVE_ALL. > #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; \ <-- __KERNEL_DS is restored here. > movl %edx,%ds; \ > movl %edx,%es; > > Does anyone know why do we restore __USER_DS on context switch from user to > kernel instead of __KERNEL_DS ?
since Linux doesn't use segmentation , all the segment descriptor values are the same. So I think it doesn't matter what selector value you load in DS, ES etc. Though I don't know the real reason for why __USER_DS is used instead of __KERNEL_DS take care, -Joel
