public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
From: Robin Holt <holt@sgi.com>
To: linux-ia64@vger.kernel.org
Subject: Re: [PATCH] get_wchan on running task sometimes MCAs the machine.
Date: Fri, 18 May 2007 18:35:20 +0000	[thread overview]
Message-ID: <20070518183520.GA9217@lnx-holt.americas.sgi.com> (raw)
In-Reply-To: <20070517111651.GA760@lnx-holt.americas.sgi.com>

On Thu, May 17, 2007 at 10:02:45PM -0500, Robin Holt wrote:
> On Thu, May 17, 2007 at 08:16:55AM -0600, David Mosberger-Tang wrote:
> > On 5/17/07, Keith Owens <kaos@sgi.com> wrote:
> > 
> > >David Mosberger
> > >reckons that unwind should never cause an error, maybe we should be
> > >looking at adding more checks to the unwind code to cope with spurious
> > >addresses?
> > 
> > That's correct.  If the unwinder causes MCAs, it's broken.  Robin, can
> > you look into why the memory-access safety-checks in the unwinder
> > aren't sufficient to avoid the MCAs you're seeing?
> 
> I don't think it got very far at all.
> 
> The task in question is calling get_wchan on itself.  It is at
> >> px *(task_struct *)0xe003819a00000000 | grep ksp
>                 ksp = 0xe003819a00007900
> >> px 0xe003819a00007900 + 16
> 0xe003819a00007910
> >> px *(switch_stack *)0xe003819a00007910 | grep bsp
>         ar_bspstore = 0xe003819a00000000
> 
> 
> Here we start to run into difficulties.  ar_bspstore is the same address
> as our task_struct.  info->regstk.top = 0xe003819a00000000 which leads
> to unw_init_frame_info calculating info->bsp = 0xe0038199ffffff30
> which is near the addresses causing problems (0xe0038199ffffff80 and
> 0xe0038199ffffffe0).  Notice it is in the page before our task_struct.

I think I have everything figured out now.  Address range for our tasks
switch stack is 0xe001849a00007910 to 0xe001849a00007b20.

Or unw_frame_info structure allocated by get_wchan() on the memory stack
happens to reside at 0xe001849a00007b20 to 0xe001849a00007ce8.

Assume we are in get_wchan and r12 = 0xe001849a00007b20.  We take
an interrupt.  The switch stack gets allocated on the memory stack in
the address ranges above.  Upon return from the interrupt, we proceed
to call unw_init_from_blocked_task() which called unw_init_frame_info().

unw_init_frame_info does:
0xa000000100041aa0 <unw_init_frame_info>:         [MMI]       alloc r36=ar.pfs,9,6,0
0xa000000100041aa6 <unw_init_frame_info+0x6>:                 adds r12=-16,r12
0xa000000100041aac <unw_init_frame_info+0xc>:                 mov r35°
0xa000000100041ab0 <unw_init_frame_info+0x10>:    [MII]       nop.m 0x0
0xa000000100041ab6 <unw_init_frame_info+0x16>:                mov r38=r32;;
0xa000000100041abc <unw_init_frame_info+0x1c>:                adds r9\x16,r12
0xa000000100041ac0 <unw_init_frame_info+0x20>:    [MMI]       mov r39=r0
0xa000000100041ac6 <unw_init_frame_info+0x26>:                nop.m 0x0
0xa000000100041acc <unw_init_frame_info+0x2c>:                mov r40E6;;
0xa000000100041ad0 <unw_init_frame_info+0x30>:    [MIB]       st8 [r9]=r33

which ends up placing r33 (struct task_struct *) onto the stack at
exactly the location of the no longer valid switch_stack struct pointed
to by this threads ->ksp.

This comes down to we need to take an interrupt in get_wchan when called
on our own task between the time when r12 is updated to allocate the
unw_frame_info structure and when unw_init_from_blocked_task() is called.

Seeing how that is only a few instructions, I would expect this to be
a fairly small window of opportunity.

I am going to submit two patches.  One which improves the error checking
in the unwind functions.  The other is essentially the patch I produced
yesterday.

Thanks,
Robin

  parent reply	other threads:[~2007-05-18 18:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-17 11:16 [PATCH] get_wchan on running task sometimes MCAs the machine Robin Holt
2007-05-17 11:38 ` Keith Owens
2007-05-17 13:00 ` Robin Holt
2007-05-17 13:05 ` Keith Owens
2007-05-17 14:16 ` David Mosberger-Tang
2007-05-18  3:02 ` Robin Holt
2007-05-18 18:23 ` David Mosberger-Tang
2007-05-18 18:35 ` Robin Holt [this message]
2007-05-18 23:01 ` Luck, Tony
2007-05-19  2:08 ` Robin Holt
2007-05-19  2:26 ` David Mosberger-Tang
2007-05-23  3:32 ` Nick Piggin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070518183520.GA9217@lnx-holt.americas.sgi.com \
    --to=holt@sgi.com \
    --cc=linux-ia64@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox