23 /* this struct defines the way the registers are stored on the
24 stack during a system call. */
25
26 struct pt_regs {
27 long ebx;
28 long ecx;
29 long edx;
30 long esi;
31 long edi;
32 long ebp;
33 long eax;
34 int xds;
35 int xes;
36 long orig_eax;
37 long eip;
38 int xcs;
39 long eflags;
40 long esp;
41 int xss;
42 };
《understanding the linux kernel》中说 struct pt_regs中前9个是存放通过SAVE_ALL压入的寄存器值。 orig_eax存放的是IRQ number. 后面的几个是处理器自动压入的寄存器值。
我不明白的是: xds xes xcs xss等是什么寄存器? 他们与edx ecs 等有什么区别? 而且类型还不一样。
哪位能解释一下。
答:是段寄存器,类型其实是一样的
保存断点现场:在内核栈中保存中断处理程序将要用到的所有cpu寄存器的内容叫保护断点现场。这时调用宏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;
movl %dx,%ds;
movl %dx,%es;
注意到这个宏没有保存EFLAGS,CS,EIP,SS和ESP寄存器,原因是这些寄存器在CPU响应中断是已被cpu自动保存了。在宏的最后,把内核数据段的选择符装入ds和es段寄存器。