<br>
<br><tt><font size=2>crash-utility-bounces@redhat.com wrote on 27/09/2007
17:13:45:<br>
<br>
> Richard J Moore wrote:<br>
> > <br>
> > crash-utility-bounces@redhat.com wrote on 27/09/2007 15:45:21:<br>
> > <br>
> >  > Richard J Moore wrote:<br>
> >  ><br>
> >  > > On looking at the code in entry.S at page_fault
and the other <br>
> > exception<br>
> >  > > entry points I see no attempt to save regs to
create a pt_regs struct.<br>
> >  > > The fact that do_page_fault takes pt_regs as
the first arg is a <br>
> > hack to<br>
> >  > > get at CS:EIP and SS:ESP at the time of exception.<br>
> >  ><br>
> >  > KPROBE_ENTRY(page_fault)<br>
> >  >    RING0_EC_FRAME<br>
> >  >    pushl $do_page_fault<br>
> >  >    CFI_ADJUST_CFA_OFFSET 4<br>
> >  >    ALIGN<br>
> >  > error_code:<br>
> >  >    /* the function address is in %fs's slot
on the stack */<br>
> >  >    pushl %es<br>
> >  >    CFI_ADJUST_CFA_OFFSET 4<br>
> >  >    /*CFI_REL_OFFSET es, 0*/<br>
> >  >    pushl %ds<br>
> >  >    CFI_ADJUST_CFA_OFFSET 4<br>
> >  >    /*CFI_REL_OFFSET ds, 0*/<br>
> >  >    pushl %eax<br>
> >  >    CFI_ADJUST_CFA_OFFSET 4<br>
> >  >    CFI_REL_OFFSET eax, 0<br>
> >  >    pushl %ebp<br>
> >  >    CFI_ADJUST_CFA_OFFSET 4<br>
> >  >    CFI_REL_OFFSET ebp, 0<br>
> >  >    pushl %edi<br>
> >  >    CFI_ADJUST_CFA_OFFSET 4<br>
> >  >    CFI_REL_OFFSET edi, 0<br>
> >  >    pushl %esi<br>
> >  >    CFI_ADJUST_CFA_OFFSET 4<br>
> >  >    CFI_REL_OFFSET esi, 0<br>
> >  >    pushl %edx<br>
> >  >    CFI_ADJUST_CFA_OFFSET 4<br>
> >  >    CFI_REL_OFFSET edx, 0<br>
> >  >    pushl %ecx<br>
> >  >    CFI_ADJUST_CFA_OFFSET 4<br>
> >  >    CFI_REL_OFFSET ecx, 0<br>
> >  >    pushl %ebx<br>
> >  >    CFI_ADJUST_CFA_OFFSET 4<br>
> >  >    CFI_REL_OFFSET ebx, 0<br>
> >  >    cld<br>
> >  >    pushl %fs<br>
> >  >    CFI_ADJUST_CFA_OFFSET 4<br>
> >  >    /*CFI_REL_OFFSET fs, 0*/<br>
> >  >    movl $(__KERNEL_PERCPU), %ecx<br>
> >  >    movl %ecx, %fs<br>
> >  >    UNWIND_ESPFIX_STACK<br>
> >  >    popl %ecx<br>
> >  >    CFI_ADJUST_CFA_OFFSET -4<br>
> >  >    /*CFI_REGISTER es, ecx*/<br>
> >  >    movl PT_FS(%esp), %edi    
 # get the function address<br>
> >  >    movl PT_ORIG_EAX(%esp), %edx   #
get the error code<br>
> >  >    movl $-1, PT_ORIG_EAX(%esp)   #
no syscall to restart<br>
> >  >    mov  %ecx, PT_FS(%esp)<br>
> >  >    /*CFI_REL_OFFSET fs, ES*/<br>
> >  >    movl $(__USER_DS), %ecx<br>
> >  >    movl %ecx, %ds<br>
> >  >    movl %ecx, %es<br>
> >  >    movl %esp,%eax        
# pt_regs pointer<br>
> >  >    call *%edi<br>
> >  >    jmp ret_from_exception<br>
> >  >    CFI_ENDPROC<br>
> >  > KPROBE_END(page_fault)<br>
> >  ><br>
> > <br>
> > Dave, it looks like error_code: has been change relatively recently.
My <br>
> > source starts:<br>
> > error_code:<br>
> >         pushl %ds<br>
> >         pushl %eax<br>
> >         xorl  %eax,%eax<br>
> >         pushl %ebp<br>
> >        <br>
> > and so on. Clearly not a valid pt_regs struct.<br>
> > The source I'm working with is from FC5. On your version of the
kernel <br>
> > only the ERR, SS and ESP would be invalid.<br>
> > What tree is yours taken from?<br>
> > <br>
> <br>
> My example was from upstream 2.6.22-5.  RHEL5 (2.6.18-based)<br>
> is slightly different, as the "error_code:" chunk is located<br>
> in the "divide_error" entry point, but like 2.6.22-5, all
of<br>
> the other exceptions jmp to it.<br>
> <br>
> But even your code is creating the remainder of the pt_regs<br>
> after the essential registers laid down by the hardware<br>
> exception mechanism, by pushing the remaining registers,<br>
> "upwards" towards the beginning of the structure:<br>
> <br>
> struct pt_regs {<br>
>          long ebx;<br>
>          long ecx;<br>
>          long edx;<br>
>          long esi;<br>
>          long edi;<br>
>          long ebp;<br>
>          long eax;<br>
>          int  xds;<br>
>          int  xes;<br>
>          long orig_eax;<br>
>          long eip;<br>
>          int  xcs;<br>
>          long eflags;<br>
>          long esp;<br>
>          int  xss;<br>
> };<br>
> <br>
> Right?<br>
> <br>
> Dave<br>
> </font></tt>
<br>
<br><tt><font size=2>I don't think so. Am I misreading this:</font></tt>
<br>
<br><tt><font size=2>we take a page fault at ring 0. The cpu pushes eflags,
cs, eip, error-code</font></tt>
<br><tt><font size=2>we enter the kernel at:</font></tt>
<br><tt><font size=2>ENTRY(page_fault)</font></tt>
<br><tt><font size=2>        pushl $do_page_fault</font></tt>
<br><tt><font size=2>        jmp error_code</font></tt>
<br>
<br><tt><font size=2>we have errror code in orig_eax</font></tt>
<br>
<br>
<br><tt><font size=2>error_code:</font></tt>
<br><tt><font size=2>        pushl %ds</font></tt>
<br><tt><font size=2>        pushl %eax</font></tt>
<br><tt><font size=2>        xorl %eax, %eax</font></tt>
<br><tt><font size=2>        pushl %ebp</font></tt>
<br><tt><font size=2>        pushl %edi</font></tt>
<br><tt><font size=2>        pushl %esi</font></tt>
<br><tt><font size=2>        pushl %edx</font></tt>
<br><tt><font size=2>        decl %eax  
               
     # eax = -1</font></tt>
<br><tt><font size=2>        pushl %ecx</font></tt>
<br><tt><font size=2>        pushl %ebx</font></tt>
<br><tt><font size=2>        cld</font></tt>
<br><tt><font size=2>        pushl %es</font></tt>
<br><tt><font size=2>        UNWIND_ESPFIX_STACK</font></tt>
<br><tt><font size=2>        popl %ecx</font></tt>
<br><tt><font size=2>        movl ES(%esp),
%edi                #
get the function address</font></tt>
<br><tt><font size=2>        movl ORIG_EAX(%esp),
%edx        # get the error code</font></tt>
<br><tt><font size=2>        movl %eax, ORIG_EAX(%esp)</font></tt>
<br><tt><font size=2>        movl %ecx, ES(%esp)</font></tt>
<br><tt><font size=2>        movl $(__USER_DS),
%ecx</font></tt>
<br><tt><font size=2>        movl %ecx, %ds</font></tt>
<br><tt><font size=2>        movl %ecx, %es</font></tt>
<br><tt><font size=2>        movl %esp,%eax
               
       # pt_regs pointer</font></tt>
<br><tt><font size=2>        call *%edi</font></tt>
<br><tt><font size=2>        jmp ret_from_exception</font></tt>
<br>
<br>
<br><tt><font size=2>Aren't we sorting ds in the pt_regs.ES ? and therefore
one register out?</font></tt>
<br>
<br><tt><font size=2>Maybe I'm missing something?</font></tt>
<br>
<br><tt><font size=2>Richard</font></tt>
<br><tt><font size=2><br>
> <br>
> <br>
> --<br>
> Crash-utility mailing list<br>
> Crash-utility@redhat.com<br>
> </font></tt><a href="https://www.redhat.com/mailman/listinfo/crash-utility"><tt><font size=2>https://www.redhat.com/mailman/listinfo/crash-utility</font></tt></a><tt><font size=2><br>
</font></tt><font size=3 face="sans-serif"><br>
</font>
<br><font size=3 face="sans-serif"><br>
</font>
<hr><font size=2 face="sans-serif"><br>
<i><br>
</i></font>
<p><font size=2 face="sans-serif"><i>Unless stated otherwise above:<br>
IBM United Kingdom Limited - Registered in England and Wales with number
741598. <br>
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6
3AU</i></font>
<p><font size=2 face="sans-serif"><br>
</font><font size=3 face="sans-serif"><br>
</font>
<br>
<br><font size=3 face="sans-serif"><br>
</font>