title: why linux kernel don't restore all register when using sysenter/sysexit?
body: <p>In linux kernel 2.6.11,
  when use sysenter to do the system call,
  it is almost the same as init 0x80, using save_all to push all register on the kernel stack, but after the call is finished,
  if relevant flag is not set, we use sysexit to return, but not restore all registers which have been saved on stack.</p>
  
  <h2>some system call may change register value, why don't we need to resotre all registers</h2>
  
  <p>I've read corresponding i386 doc, it says </p>
  
  <p>"All registers on the Intel386 are global and thus visible to both a calling and a called function. Registers %ebp, %ebx, %edi, %esi and %esp "belong" to the calling function. In other words, a called function must preserve these  registers’ values for its caller. Remaining registers "belong" to the called function. If a calling function wants to preserve such a register value across a function call, it must save the value in its local stack frame."</p>
  
  <p>So it's glibc wrapper function's responsibility to do the preservation work, and I've read some glibc code to make sure of it.
  So it make sense that when using sysenter/sysexit to do the system call,
  we first push %ebp,%edx,%ecx on user stack
  because %edx and %ecx are not in preservation registers, we need to restore them later after finishing system call
  and we also use %ebp to save user stack pointer before call system service routine, so we need to restore it to pass parameter</p>