Subject: Re: Run 'usermode-agent' cause kernel panic on Powerpc

From: Benjamin Herrenschmidt <[email-masked]>
Date: Thu, 09 Dec 2010 14:26:20 +1100

On Wed, 2010-12-08 at 09:20 +0800, xufeng zhang wrote:

> > I believe it would have such an impact.  I don't see that user-mode
> > debugging would be enabled at all.
> >
> > Maybe something like this untested patch:
> >
> > diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
> > index 84906d3..0e7d1cf 100644
> > --- a/arch/powerpc/kernel/process.c
> > +++ b/arch/powerpc/kernel/process.c
> > @@ -323,6 +323,13 @@ static void set_debug_reg_defaults(struct thread_struct *thread)
> >
> >   static void prime_debug_regs(struct thread_struct *thread)
> >   {
> > +	/*
> > +	 * If we're setting up debug events for user space, make sure they
> > +	 * don't fire in kernel space before we get to user space
> > +	 */
> > +	if (thread->dbcr0&  DBCR0_IDM)
> > +		mtmsr(mfmsr()&  ~MSR_DE);
> > +
> >   	mtspr(SPRN_IAC1, thread->iac1);
> >   	mtspr(SPRN_IAC2, thread->iac2);
> >   #if CONFIG_PPC_ADV_DEBUG_IACS>  2
> >
> >    
> Thanks for your reply, Dave, I know where the problem is.

So is there a kernel bug we need to fix ?

Cheers,
Ben.