public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
* Unwind bug on out of line code called from leaf functions
@ 2003-11-27  0:12 Keith Owens
  2003-11-27  0:32 ` David Mosberger
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Keith Owens @ 2003-11-27  0:12 UTC (permalink / raw)
  To: linux-ia64

ia64_spinlock_contention_pre3_4 has

        .save ar.pfs, r0        // this code effectively has a zero frame size

If ia64_spinlock_contention_pre3_4 is called from a leaf function,
takes an interrupt and you unwind through the contenion code, the
unwind steps are

  pt_regs.cr_ifs
  ia64_spinlock_contention_pre3_4, ar.pfs = 0
  leaf function, no unwind data, ar.pfs is unchanged and stays at 0!

There is no problem when ia64_spinlock_contention_pre3_4 is called from
a non-leaf function.  The non-leaf function has unwind data which
resets ar.pfs, the problem only occurs when the caller of the out of
line code has no unwind data and is using .

I have hacked kdb to recognise that it is unwinding the caller of the
out of line code and force ar.pfs to pt_regs.ar_pfs.  That is the
correct value for leaf functions.  The unwind data for non-leaf
functions will override this default value of ar.pfs.

I know that gcc 3.4 overcomes this problem by saving ar.pfs in leaf
functions and using br.call.  However we need a fix for gcc in the
current distributions, even with gcc 3.4 we may wish to use out of line
code that does not save ar.pfs in the future.

We need a generic fix for unwinding through out of line code called
from leaf functions and not using br.call.  The obvious solution is to
flag all out of line code with an unwind abi field and have the common
unwind code reset ar.pfs.  Can I use .unwabi 3, 'o' for out of line?


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Unwind bug on out of line code called from leaf functions
  2003-11-27  0:12 Unwind bug on out of line code called from leaf functions Keith Owens
@ 2003-11-27  0:32 ` David Mosberger
  2003-11-27  1:12 ` Keith Owens
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: David Mosberger @ 2003-11-27  0:32 UTC (permalink / raw)
  To: linux-ia64

>>>>> On Thu, 27 Nov 2003 11:12:18 +1100, Keith Owens <kaos@sgi.com> said:

  Keith> I know that gcc 3.4 overcomes this problem by saving ar.pfs
  Keith> in leaf functions and using br.call.  However we need a fix
  Keith> for gcc in the current distributions,

Sounds reasonable.

  Keith> even with gcc 3.4 we may wish to use out of line code that
  Keith> does not save ar.pfs in the future.

That would need a some solid argument!

  Keith> We need a generic fix for unwinding through out of line code
  Keith> called from leaf functions and not using br.call.  The
  Keith> obvious solution is to flag all out of line code with an
  Keith> unwind abi field and have the common unwind code reset
  Keith> ar.pfs.  Can I use .unwabi 3, 'o' for out of line?

The .unwabi directive isn't appropriate for that.  If you want such a
feature, please push it through the ABI committee to get it officially
supported.  I've said that before, I think.

	--david

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Unwind bug on out of line code called from leaf functions
  2003-11-27  0:12 Unwind bug on out of line code called from leaf functions Keith Owens
  2003-11-27  0:32 ` David Mosberger
@ 2003-11-27  1:12 ` Keith Owens
  2003-11-27  1:34 ` David Mosberger
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Keith Owens @ 2003-11-27  1:12 UTC (permalink / raw)
  To: linux-ia64

On Wed, 26 Nov 2003 16:32:00 -0800, 
David Mosberger <davidm@napali.hpl.hp.com> wrote:
>>>>>> On Thu, 27 Nov 2003 11:12:18 +1100, Keith Owens <kaos@sgi.com> said:
>  Keith> We need a generic fix for unwinding through out of line code
>  Keith> called from leaf functions and not using br.call.  The
>  Keith> obvious solution is to flag all out of line code with an
>  Keith> unwind abi field and have the common unwind code reset
>  Keith> ar.pfs.  Can I use .unwabi 3, 'o' for out of line?
>
>The .unwabi directive isn't appropriate for that.  If you want such a
>feature, please push it through the ABI committee to get it officially
>supported.  I've said that before, I think.

I disagree, unwabi is exactly what we need for this.  The out of line
code is peculiar to Linux, and uses the Linux pt_regs to get the real
ar.pfs.  .unwabi 3,i indicates a Linux interrupt frame with all state
in pt_regs, .unwabi 3,o indicates a Linux out of line frame with
pt_regs.ar_pfs containing the real ar.pfs.  If unwabi 3,i is valid then
so is unwabi 3,o.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Unwind bug on out of line code called from leaf functions
  2003-11-27  0:12 Unwind bug on out of line code called from leaf functions Keith Owens
  2003-11-27  0:32 ` David Mosberger
  2003-11-27  1:12 ` Keith Owens
@ 2003-11-27  1:34 ` David Mosberger
  2003-11-27  4:28 ` David Mosberger
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: David Mosberger @ 2003-11-27  1:34 UTC (permalink / raw)
  To: linux-ia64

>>>>> On Thu, 27 Nov 2003 12:12:56 +1100, Keith Owens <kaos@sgi.com> said:

  Keith> On Wed, 26 Nov 2003 16:32:00 -0800, 
  Keith> David Mosberger <davidm@napali.hpl.hp.com> wrote:
  >>>>>>> On Thu, 27 Nov 2003 11:12:18 +1100, Keith Owens <kaos@sgi.com> said:
  Keith> We need a generic fix for unwinding through out of line code
  Keith> called from leaf functions and not using br.call.  The
  Keith> obvious solution is to flag all out of line code with an
  Keith> unwind abi field and have the common unwind code reset
  Keith> ar.pfs.  Can I use .unwabi 3, 'o' for out of line?

  >> The .unwabi directive isn't appropriate for that.  If you want such a
  >> feature, please push it through the ABI committee to get it officially
  >> supported.  I've said that before, I think.

  Keith> I disagree, unwabi is exactly what we need for this.  The out
  Keith> of line code is peculiar to Linux, and uses the Linux pt_regs
  Keith> to get the real ar.pfs.  .unwabi 3,i indicates a Linux
  Keith> interrupt frame with all state in pt_regs, .unwabi 3,o
  Keith> indicates a Linux out of line frame with pt_regs.ar_pfs
  Keith> containing the real ar.pfs.  If unwabi 3,i is valid then so
  Keith> is unwabi 3,o.

If you want to support out-of-line code, do it right or don't it at
all.  There is no chance in hell I'm going to accept such hacks and I
also won't bother supporting such gross hacks in libunwind.  EOD.

	--david

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Unwind bug on out of line code called from leaf functions
  2003-11-27  0:12 Unwind bug on out of line code called from leaf functions Keith Owens
                   ` (2 preceding siblings ...)
  2003-11-27  1:34 ` David Mosberger
@ 2003-11-27  4:28 ` David Mosberger
  2003-11-27  6:52 ` Jim Wilson
  2003-12-11  1:21 ` David Mosberger
  5 siblings, 0 replies; 7+ messages in thread
From: David Mosberger @ 2003-11-27  4:28 UTC (permalink / raw)
  To: linux-ia64

I forgot to mention this:

>>>>> On Thu, 27 Nov 2003 11:12:18 +1100, Keith Owens <kaos@sgi.com> said:

  Keith> I know that gcc 3.4 overcomes this problem by saving ar.pfs
  Keith> in leaf functions and using br.call.

gcc-3.3.2 also can handle ar.pfs clobbers, so we may just want to
update the kernel code to be a bit more premissive and not insist on
>= gcc-3.4.  I'm not exactly sure though when this got fixed, so
somebody would have to look into that first.

	--david

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Unwind bug on out of line code called from leaf functions
  2003-11-27  0:12 Unwind bug on out of line code called from leaf functions Keith Owens
                   ` (3 preceding siblings ...)
  2003-11-27  4:28 ` David Mosberger
@ 2003-11-27  6:52 ` Jim Wilson
  2003-12-11  1:21 ` David Mosberger
  5 siblings, 0 replies; 7+ messages in thread
From: Jim Wilson @ 2003-11-27  6:52 UTC (permalink / raw)
  To: linux-ia64

On Wed, 2003-11-26 at 20:28, David Mosberger wrote:
> gcc-3.3.2 also can handle ar.pfs clobbers, so we may just want to
> update the kernel code to be a bit more premissive and not insist on
> >= gcc-3.4.  I'm not exactly sure though when this got fixed, so
> somebody would have to look into that first.

The patch is in gcc-3.3.0.  See Richard Henderson's 2003-04-26 ia64
change in gcc.  However, that patch resulted in an ICE in some other
cases, and unnecessary saves/restores of ar.pfs, see gcc PR 10681.  The
patch for that is in gcc-3.3.1.  See Richard Henderson's 2003-06-26
change in gcc.

It would be reasonable to just check for >= gcc-3.3 for use of this
feature.  I wouldn't recommend using gcc-3.3.0 though.
-- 
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Unwind bug on out of line code called from leaf functions
  2003-11-27  0:12 Unwind bug on out of line code called from leaf functions Keith Owens
                   ` (4 preceding siblings ...)
  2003-11-27  6:52 ` Jim Wilson
@ 2003-12-11  1:21 ` David Mosberger
  5 siblings, 0 replies; 7+ messages in thread
From: David Mosberger @ 2003-12-11  1:21 UTC (permalink / raw)
  To: linux-ia64

>>>>> On 26 Nov 2003 22:52:50 -0800, Jim Wilson <wilson@specifixinc.com> said:

  Jim> On Wed, 2003-11-26 at 20:28, David Mosberger wrote:

  >> gcc-3.3.2 also can handle ar.pfs clobbers, so we may just want to
  >> update the kernel code to be a bit more premissive and not insist
  >> on >= gcc-3.4.  I'm not exactly sure though when this got fixed,
  >> so somebody would have to look into that first.

  Jim> The patch is in gcc-3.3.0.  See Richard Henderson's 2003-04-26
  Jim> ia64 change in gcc.  However, that patch resulted in an ICE in
  Jim> some other cases, and unnecessary saves/restores of ar.pfs, see
  Jim> gcc PR 10681.  The patch for that is in gcc-3.3.1.  See Richard
  Jim> Henderson's 2003-06-26 change in gcc.

  Jim> It would be reasonable to just check for >= gcc-3.3 for use of
  Jim> this feature.  I wouldn't recommend using gcc-3.3.0 though.

OK, I'm changing the kernel now to check for >= gcc-3.3.

Thanks!

	--david

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2003-12-11  1:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-11-27  0:12 Unwind bug on out of line code called from leaf functions Keith Owens
2003-11-27  0:32 ` David Mosberger
2003-11-27  1:12 ` Keith Owens
2003-11-27  1:34 ` David Mosberger
2003-11-27  4:28 ` David Mosberger
2003-11-27  6:52 ` Jim Wilson
2003-12-11  1:21 ` David Mosberger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox