* [PATCH 3/3] xtensa: fix _Unwind_GetCFA
2015-08-17 22:00 [PATCH 0/3] xtensa: libgcc: fixes for stack unwinding Max Filippov
@ 2015-08-17 22:00 ` Max Filippov
2015-08-18 1:10 ` augustine.sterling
2015-08-17 22:00 ` [PATCH 1/3] xtensa: reimplement register spilling Max Filippov
2015-08-17 22:42 ` [PATCH 2/3] xtensa: use unwind-dw2-fde-dip instead of unwind-dw2-fde Max Filippov
2 siblings, 1 reply; 8+ messages in thread
From: Max Filippov @ 2015-08-17 22:00 UTC (permalink / raw)
To: gcc-patches; +Cc: linux-xtensa, Sterling Augustine, Max Filippov
Returning context->cfa in _Unwind_GetCFA makes CFA point one stack frame
higher than what was actually used by code at context->ra. This results
in invalid CFA value in signal frames and premature unwinding completion
in forced unwinding used by uClibc NPTL thread cancellation.
Returning context->sp from _Unwind_GetCFA makes all CFA values valid and
matching code that used them.
2015-08-18 Max Filippov <jcmvbkbc@gmail.com>
libgcc/
* config/xtensa/unwind-dw2-xtensa.c (_Unwind_GetCFA): Return
context->sp instead of context->cfa.
---
libgcc/config/xtensa/unwind-dw2-xtensa.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libgcc/config/xtensa/unwind-dw2-xtensa.c b/libgcc/config/xtensa/unwind-dw2-xtensa.c
index 82b0e63..8e579c7 100644
--- a/libgcc/config/xtensa/unwind-dw2-xtensa.c
+++ b/libgcc/config/xtensa/unwind-dw2-xtensa.c
@@ -130,7 +130,7 @@ _Unwind_GetGR (struct _Unwind_Context *context, int index)
_Unwind_Word
_Unwind_GetCFA (struct _Unwind_Context *context)
{
- return (_Unwind_Ptr) context->cfa;
+ return (_Unwind_Ptr) context->sp;
}
/* Overwrite the saved value for register INDEX in CONTEXT with VAL. */
--
1.8.1.4
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/3] xtensa: reimplement register spilling
2015-08-17 22:00 [PATCH 0/3] xtensa: libgcc: fixes for stack unwinding Max Filippov
2015-08-17 22:00 ` [PATCH 3/3] xtensa: fix _Unwind_GetCFA Max Filippov
@ 2015-08-17 22:00 ` Max Filippov
2015-08-18 0:50 ` augustine.sterling
2015-08-17 22:42 ` [PATCH 2/3] xtensa: use unwind-dw2-fde-dip instead of unwind-dw2-fde Max Filippov
2 siblings, 1 reply; 8+ messages in thread
From: Max Filippov @ 2015-08-17 22:00 UTC (permalink / raw)
To: gcc-patches; +Cc: linux-xtensa, Sterling Augustine, Max Filippov
Spilling windowed registers in userspace is much easier, more portable,
less error-prone and equally effective as in kernel. Now that register
spilling syscall is considered obsolete in the xtensa linux kernel
replace it with CALL12 followed by series of ENTRY in libgcc.
2015-08-18 Max Filippov <jcmvbkbc@gmail.com>
libgcc/
* config/xtensa/lib2funcs.S (__xtensa_libgcc_window_spill): Use
CALL12 followed by series of ENTRY to spill windowed registers.
(__xtensa_nonlocal_goto): Call __xtensa_libgcc_window_spill
instead of making linux spill syscall.
---
libgcc/config/xtensa/lib2funcs.S | 30 +++++++++++++++++++++++-------
1 file changed, 23 insertions(+), 7 deletions(-)
diff --git a/libgcc/config/xtensa/lib2funcs.S b/libgcc/config/xtensa/lib2funcs.S
index 4d451c8..ef0703f 100644
--- a/libgcc/config/xtensa/lib2funcs.S
+++ b/libgcc/config/xtensa/lib2funcs.S
@@ -34,10 +34,29 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
.global __xtensa_libgcc_window_spill
.type __xtensa_libgcc_window_spill,@function
__xtensa_libgcc_window_spill:
- entry sp, 32
- movi a2, 0
- syscall
+ entry sp, 48
+#if XCHAL_NUM_AREGS > 16
+ call12 1f
+ retw
+ .align 4
+1:
+ .rept (XCHAL_NUM_AREGS - 24) / 12
+ _entry sp, 48
+ mov a12, a0
+ .endr
+ _entry sp, 16
+#if XCHAL_NUM_AREGS % 12 == 0
+ mov a4, a4
+#elif XCHAL_NUM_AREGS % 12 == 4
+ mov a8, a8
+#elif XCHAL_NUM_AREGS % 12 == 8
+ mov a12, a12
+#endif
retw
+#else
+ mov a8, a8
+ retw
+#endif
.size __xtensa_libgcc_window_spill, .-__xtensa_libgcc_window_spill
#endif
@@ -61,10 +80,7 @@ __xtensa_nonlocal_goto:
entry sp, 32
/* Flush registers. */
- mov a5, a2
- movi a2, 0
- syscall
- mov a2, a5
+ call8 __xtensa_libgcc_window_spill
/* Because the save area for a0-a3 is stored one frame below
the one identified by a2, the only way to restore those
--
1.8.1.4
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 0/3] xtensa: libgcc: fixes for stack unwinding
@ 2015-08-17 22:00 Max Filippov
2015-08-17 22:00 ` [PATCH 3/3] xtensa: fix _Unwind_GetCFA Max Filippov
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Max Filippov @ 2015-08-17 22:00 UTC (permalink / raw)
To: gcc-patches; +Cc: linux-xtensa, Sterling Augustine, Max Filippov
Hi Sterling,
these three patches fix bits of xtensa libgcc related to stack unwinding.
They fix a number of uClibc-ng NPTL thread cancellation and cleanup tests,
particularly uClibc-ng 1.0.5 tests
nptl/tst-cancelx4,
nptl/tst-cancelx16,
nptl/tst-cancelx18,
nptl/tst-cancelx20,
nptl/tst-cancelx21,
nptl/tst-cleanupx1,
nptl/tst-cleanupx3,
nptl/tst-oncex3,
nptl/tst-oncex4.
Max Filippov (3):
xtensa: reimplement register spilling
xtensa: use unwind-dw2-fde-dip instead of unwind-dw2-fde
xtensa: fix _Unwind_GetCFA
libgcc/config/xtensa/lib2funcs.S | 30 +++++++++++++++++++++++-------
libgcc/config/xtensa/t-windowed | 2 +-
libgcc/config/xtensa/unwind-dw2-xtensa.c | 2 +-
3 files changed, 25 insertions(+), 9 deletions(-)
--
1.8.1.4
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/3] xtensa: use unwind-dw2-fde-dip instead of unwind-dw2-fde
2015-08-17 22:00 [PATCH 0/3] xtensa: libgcc: fixes for stack unwinding Max Filippov
2015-08-17 22:00 ` [PATCH 3/3] xtensa: fix _Unwind_GetCFA Max Filippov
2015-08-17 22:00 ` [PATCH 1/3] xtensa: reimplement register spilling Max Filippov
@ 2015-08-17 22:42 ` Max Filippov
2015-08-18 0:51 ` augustine.sterling
2 siblings, 1 reply; 8+ messages in thread
From: Max Filippov @ 2015-08-17 22:42 UTC (permalink / raw)
To: gcc-patches; +Cc: linux-xtensa, Sterling Augustine, Max Filippov
This allows having exception cleanup code in binaries that don't
register their unwind tables.
2015-08-18 Max Filippov <jcmvbkbc@gmail.com>
libgcc/
* config/xtensa/t-windowed (LIB2ADDEH): Replace unwind-dw2-fde
with unwind-dw2-fde-dip.
---
libgcc/config/xtensa/t-windowed | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libgcc/config/xtensa/t-windowed b/libgcc/config/xtensa/t-windowed
index 7d9e9db..a99156c 100644
--- a/libgcc/config/xtensa/t-windowed
+++ b/libgcc/config/xtensa/t-windowed
@@ -1,2 +1,2 @@
LIB2ADDEH = $(srcdir)/config/xtensa/unwind-dw2-xtensa.c \
- $(srcdir)/unwind-dw2-fde.c $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c
+ $(srcdir)/unwind-dw2-fde-dip.c $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c
--
1.8.1.4
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] xtensa: reimplement register spilling
2015-08-17 22:00 ` [PATCH 1/3] xtensa: reimplement register spilling Max Filippov
@ 2015-08-18 0:50 ` augustine.sterling
2015-08-18 3:05 ` Max Filippov
0 siblings, 1 reply; 8+ messages in thread
From: augustine.sterling @ 2015-08-18 0:50 UTC (permalink / raw)
To: Max Filippov; +Cc: gcc-patches, linux-xtensa
On Mon, Aug 17, 2015 at 2:59 PM, Max Filippov <jcmvbkbc@gmail.com> wrote:
> 2015-08-18 Max Filippov <jcmvbkbc@gmail.com>
> libgcc/
> * config/xtensa/lib2funcs.S (__xtensa_libgcc_window_spill): Use
> CALL12 followed by series of ENTRY to spill windowed registers.
> (__xtensa_nonlocal_goto): Call __xtensa_libgcc_window_spill
> instead of making linux spill syscall.
Approved.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/3] xtensa: use unwind-dw2-fde-dip instead of unwind-dw2-fde
2015-08-17 22:42 ` [PATCH 2/3] xtensa: use unwind-dw2-fde-dip instead of unwind-dw2-fde Max Filippov
@ 2015-08-18 0:51 ` augustine.sterling
0 siblings, 0 replies; 8+ messages in thread
From: augustine.sterling @ 2015-08-18 0:51 UTC (permalink / raw)
To: Max Filippov; +Cc: gcc-patches, linux-xtensa
On Mon, Aug 17, 2015 at 2:59 PM, Max Filippov <jcmvbkbc@gmail.com> wrote:
> This allows having exception cleanup code in binaries that don't
> register their unwind tables.
>
> 2015-08-18 Max Filippov <jcmvbkbc@gmail.com>
> libgcc/
> * config/xtensa/t-windowed (LIB2ADDEH): Replace unwind-dw2-fde
> with unwind-dw2-fde-dip.
Approved.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] xtensa: fix _Unwind_GetCFA
2015-08-17 22:00 ` [PATCH 3/3] xtensa: fix _Unwind_GetCFA Max Filippov
@ 2015-08-18 1:10 ` augustine.sterling
0 siblings, 0 replies; 8+ messages in thread
From: augustine.sterling @ 2015-08-18 1:10 UTC (permalink / raw)
To: Max Filippov; +Cc: gcc-patches, linux-xtensa
On Mon, Aug 17, 2015 at 2:59 PM, Max Filippov <jcmvbkbc@gmail.com> wrote:
> 2015-08-18 Max Filippov <jcmvbkbc@gmail.com>
> libgcc/
> * config/xtensa/unwind-dw2-xtensa.c (_Unwind_GetCFA): Return
> context->sp instead of context->cfa.
Approved.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] xtensa: reimplement register spilling
2015-08-18 0:50 ` augustine.sterling
@ 2015-08-18 3:05 ` Max Filippov
0 siblings, 0 replies; 8+ messages in thread
From: Max Filippov @ 2015-08-18 3:05 UTC (permalink / raw)
To: augustine.sterling; +Cc: gcc-patches, linux-xtensa
On Tue, Aug 18, 2015 at 3:50 AM, augustine.sterling@gmail.com
<augustine.sterling@gmail.com> wrote:
> On Mon, Aug 17, 2015 at 2:59 PM, Max Filippov <jcmvbkbc@gmail.com> wrote:
>> 2015-08-18 Max Filippov <jcmvbkbc@gmail.com>
>> libgcc/
>> * config/xtensa/lib2funcs.S (__xtensa_libgcc_window_spill): Use
>> CALL12 followed by series of ENTRY to spill windowed registers.
>> (__xtensa_nonlocal_goto): Call __xtensa_libgcc_window_spill
>> instead of making linux spill syscall.
>
> Approved.
Applied whole series to trunk. Thank you!
-- Max
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2015-08-18 1:10 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-17 22:00 [PATCH 0/3] xtensa: libgcc: fixes for stack unwinding Max Filippov
2015-08-17 22:00 ` [PATCH 3/3] xtensa: fix _Unwind_GetCFA Max Filippov
2015-08-18 1:10 ` augustine.sterling
2015-08-17 22:00 ` [PATCH 1/3] xtensa: reimplement register spilling Max Filippov
2015-08-18 0:50 ` augustine.sterling
2015-08-18 3:05 ` Max Filippov
2015-08-17 22:42 ` [PATCH 2/3] xtensa: use unwind-dw2-fde-dip instead of unwind-dw2-fde Max Filippov
2015-08-18 0:51 ` augustine.sterling
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).