Unwind bug on out of line code called from leaf functions
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?
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Keith Owens
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
Quoted 10 lines · David Mosberger
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Keith Owens
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.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Keith Owens
Keith> On Wed, 26 Nov 2003 16:32:00 -0800,
Quoted 1 line · Keith> David Mosberger <[email protected]> wrote:
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Keith Owens
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?
Quoted 3 lines
Quoted 3 lines
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
I forgot to mention this:
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Keith Owens
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
Quoted 1 line
= gcc-3.4. I'm not exactly sure though when this got fixed, so
somebody would have to look into that first.
--david
Quoted 4 lines · David Mosberger
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
Quoted 1 line
= 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.
Signature · 1 line
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Jim Wilson
Quoted 4 lines · David Mosberger
Quoted 4 lines
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