public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/95571] New: xtensa stack unwinding doesn't work well with asynchronous register spilling
@ 2020-06-08  7:25 jcmvbkbc at gcc dot gnu.org
  2020-06-08  7:33 ` [Bug target/95571] " jcmvbkbc at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: jcmvbkbc at gcc dot gnu.org @ 2020-06-08  7:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95571

            Bug ID: 95571
           Summary: xtensa stack unwinding doesn't work well with
                    asynchronous register spilling
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jcmvbkbc at gcc dot gnu.org
  Target Milestone: ---

Xtensa architecture with variable register windows store registers of the
spilled register windows in two separate locations: registers a0-a3 of the
current function caller are stored right below the stack pointer of current
function in the location known as a base save area, and the registers a4-a7 (or
a4-a11) are stored in the top of the caller's stack frame in a location known
as an extra save area, right under the base save area of is own caller. To
spill or restore registers a4-a7/a11 of the function its caller stack pointer
is used to find its extra save area.

Interrupt handlers on bare metal xtensa targets spill registers of all active
register windows in the interrupted code except the current topmost window.

Stack unwinding code for xtensa copies base save area of the context being
installed into the base save area under the _Unwind_RaiseException stack
pointer so that return from _Unwind_RaiseException reload registers of that
context. However when it happens in a function called from
_Unwind_RaiseException an interrupt can spill registers of the
_Unwind_RaiseException to its extra save area. The location of this area is
lost once base save area under the _Unwind_RaiseException stack pointer is
overwritten resulting in bogus values being reloaded into registers a4-a7
usually resulting in a crash.

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

* [Bug target/95571] xtensa stack unwinding doesn't work well with asynchronous register spilling
  2020-06-08  7:25 [Bug target/95571] New: xtensa stack unwinding doesn't work well with asynchronous register spilling jcmvbkbc at gcc dot gnu.org
@ 2020-06-08  7:33 ` jcmvbkbc at gcc dot gnu.org
  2020-06-08  8:07 ` jcmvbkbc at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: jcmvbkbc at gcc dot gnu.org @ 2020-06-08  7:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95571

--- Comment #1 from jcmvbkbc at gcc dot gnu.org ---
Created attachment 48699
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48699&action=edit
minimal reproducer

Reproducer spills active register windows in a substitute memcpy as could be
done by an interrupt handler.

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

* [Bug target/95571] xtensa stack unwinding doesn't work well with asynchronous register spilling
  2020-06-08  7:25 [Bug target/95571] New: xtensa stack unwinding doesn't work well with asynchronous register spilling jcmvbkbc at gcc dot gnu.org
  2020-06-08  7:33 ` [Bug target/95571] " jcmvbkbc at gcc dot gnu.org
@ 2020-06-08  8:07 ` jcmvbkbc at gcc dot gnu.org
  2020-06-09  1:44 ` cvs-commit at gcc dot gnu.org
  2020-06-09  1:49 ` jcmvbkbc at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jcmvbkbc at gcc dot gnu.org @ 2020-06-08  8:07 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95571

jcmvbkbc at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #48699|0                           |1
        is obsolete|                            |

--- Comment #2 from jcmvbkbc at gcc dot gnu.org ---
Created attachment 48701
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48701&action=edit
minimal reproducer

Correct reproducer version.

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

* [Bug target/95571] xtensa stack unwinding doesn't work well with asynchronous register spilling
  2020-06-08  7:25 [Bug target/95571] New: xtensa stack unwinding doesn't work well with asynchronous register spilling jcmvbkbc at gcc dot gnu.org
  2020-06-08  7:33 ` [Bug target/95571] " jcmvbkbc at gcc dot gnu.org
  2020-06-08  8:07 ` jcmvbkbc at gcc dot gnu.org
@ 2020-06-09  1:44 ` cvs-commit at gcc dot gnu.org
  2020-06-09  1:49 ` jcmvbkbc at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-06-09  1:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95571

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Max Filippov <jcmvbkbc@gcc.gnu.org>:

https://gcc.gnu.org/g:1d9921cbdc732e1a7fc66b9c24a6dfa9625bd4c0

commit r11-1078-g1d9921cbdc732e1a7fc66b9c24a6dfa9625bd4c0
Author: Max Filippov <jcmvbkbc@gmail.com>
Date:   Sat Jun 6 05:06:04 2020 -0700

    xtensa: libgcc: fix PR target/95571

    Rewrite uw_install_context without function calls to avoid register
    spilling in _Unwind_RaiseException during return context installation.

    2020-06-08  Max Filippov  <jcmvbkbc@gmail.com>
    gcc/testsuite/
            * g++.target/xtensa/pr95571.C: New test.
            * g++.target/xtensa/xtensa.exp: New testsuite.

    libgcc/
            * config/xtensa/unwind-dw2-xtensa.c (uw_install_context): Merge
            with uw_install_context_1.

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

* [Bug target/95571] xtensa stack unwinding doesn't work well with asynchronous register spilling
  2020-06-08  7:25 [Bug target/95571] New: xtensa stack unwinding doesn't work well with asynchronous register spilling jcmvbkbc at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2020-06-09  1:44 ` cvs-commit at gcc dot gnu.org
@ 2020-06-09  1:49 ` jcmvbkbc at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jcmvbkbc at gcc dot gnu.org @ 2020-06-09  1:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95571

jcmvbkbc at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #4 from jcmvbkbc at gcc dot gnu.org ---
Fix committed to the gcc master.

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

end of thread, other threads:[~2020-06-09  1:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-08  7:25 [Bug target/95571] New: xtensa stack unwinding doesn't work well with asynchronous register spilling jcmvbkbc at gcc dot gnu.org
2020-06-08  7:33 ` [Bug target/95571] " jcmvbkbc at gcc dot gnu.org
2020-06-08  8:07 ` jcmvbkbc at gcc dot gnu.org
2020-06-09  1:44 ` cvs-commit at gcc dot gnu.org
2020-06-09  1:49 ` jcmvbkbc at gcc dot gnu.org

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).