Re: DS register question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It seems that this is the case in kernel 2.4.
I glimpse kernel 2.6 in which the SAVE_ALL macro is:
#define SAVE_ALL
  ...
 movl $(__USER_DS), %edx; \
movl %edx, %ds; \
movl %edx, %es;
It seems that DS saves the user data segment.

On 2/7/07, Mulyadi Santosa <mulyadi.santosa@xxxxxxxxx> wrote:
Hi...
> How DS register changes when switching between user mode/kernel mode and
> switching between tasks/processes in x86?
> Can somebody explain to me or give me some hints?
Check arch/i386/kernel/entry.S. There, you'll see something like these:
ENTRY(system_call)
        pushl %eax                      # save orig_eax
        SAVE_ALL

it means, after saving original EAX content, it calls SAVE_ALL macro.
Inside this macro, it does:
movl $(__KERNEL_DS),%edx
movl %edx,%ds; \
movl %edx,%es;

that will assign kernel data segment to DS register

When the system call is about to finish, once again kernel will do:
restore_all:
        RESTORE_ALL
the above macro will do lots of popping from stack, including:
popl %ds
so it restores the original DS content.

When doing task switching, IIRC DS stays still....because all task
basically share the same global GDT and memory segmentation model is
flat. Perhaps the exception happens when LDT is used. Please check
__switch_to() in arch/i386/kernel/process.c and switch_to macro in
include/asm-i386/system.h

regards,

Mulyadi



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux