Hi Jan,

Looks like the following patch from Oleg has not been checked in ptrace 
testsuite yet.

Thanks,
CAI Qian

----- "Oleg Nesterov" <o...@redhat.com> wrote:

> On 12/09, Oleg Nesterov wrote:
> >
> > Cai, Ananth, thank you.
> >
> > So. I think we can forget about the possible kernel problems (and
> > in any case we can rule out utrace).
> >
> > The test-case just wrong and should be fixed. The tracee can't execute
> > the function descriptor in data section, that is why it gets SIGSEGV.
> >
> > > while the '.func_name' is the text address.
> >
> > tried to change the code to
> >
> >     REGS_ACCESS (regs, nip) = (unsigned long) .raise_sigusr2
> >
> > but gcc doesn't like this ;)
> >
> > > (See
> > > handle_rt_signal64 in arch/powerpc/kernel/signal_64.c and
> > > kprobe_lookup_name in arch/powerpc/include/asm/kprobes.h.
> >
> > Thanks... looking at handle_rt_signal64(), looks like we should
> > also set regs->gpr[2] = funct_desc_ptr->toc if we change regs->nip
> >
> >
> > I hope someone who understand powerpc could fix the test-case ;)
> 
> Yes, I verified the patch below fixes step-jump-cont.c on
> ibm-js20-02.lab.bos.redhat.com.
> 
> Oleg.
> 
> --- step-jump-cont.c~ 2009-12-09 12:17:04.367733643 -0500
> +++ step-jump-cont.c  2009-12-09 13:12:50.708535770 -0500
> @@ -153,12 +153,19 @@ raise_sigusr2 (void)
>    assert (0);
>  }
>  
> +typedef struct {
> +        unsigned long entry;
> +        unsigned long toc;
> +        unsigned long env;
> +} func_descr_t;
> +
>  int main (void)
>  {
>    long l;
>    int status;
>    pid_t pid;
>    REGS_TYPE (regs);
> +  func_descr_t *fp;
>  
>    setbuf (stdout, NULL);
>    atexit (cleanup);
> @@ -214,7 +221,12 @@ int main (void)
>  #elif defined __x86_64__
>    REGS_ACCESS (regs, rip) = (unsigned long) raise_sigusr2;
>  #elif defined __powerpc__
> -  REGS_ACCESS (regs, nip) = (unsigned long) raise_sigusr2;
> +
> +  fp = (void*)raise_sigusr2;
> +
> +  REGS_ACCESS(regs, nip)    = fp->entry;
> +  REGS_ACCESS(regs, gpr[2]) = fp->toc;
> +
>  #else
>  # error "Check outer #ifdef"
>  #endif

Reply via email to