public inbox for gdb-prs@sourceware.org help / color / mirror / Atom feed
From: "tomas.vanek at fbl dot cz" <sourceware-bugzilla@sourceware.org> To: gdb-prs@sourceware.org Subject: [Bug tdep/29716] New: Arm v8 M-profile FNC_RETURN unwinder uses wrong stack Date: Fri, 21 Oct 2022 20:59:16 +0000 [thread overview] Message-ID: <bug-29716-4717@http.sourceware.org/bugzilla/> (raw) https://sourceware.org/bugzilla/show_bug.cgi?id=29716 Bug ID: 29716 Summary: Arm v8 M-profile FNC_RETURN unwinder uses wrong stack Product: gdb Version: HEAD Status: UNCONFIRMED Severity: minor Priority: P2 Component: tdep Assignee: unassigned at sourceware dot org Reporter: tomas.vanek at fbl dot cz Target Milestone: --- Discovered on STM32L552 with Cortex-M33, should be same for all ARMv8-M devices with the security extension. A secure code runs in thread mode and uses MSP_S because CONTROL_S bit SPSEL = 0 A non-secure function is called from secure code. Command 'backtrace' does not show the correct stack frames: (gdb) bt #0 NonSecureFc () #1 <signal handler called> #2 0x00000000 in ?? () Backtrace stopped: previous frame identical to this frame (corrupt stack?) The problem is in arm-tdep.c:3394, function arm_m_exception_cache (), block if (fnc_return): ULONGEST xpsr = get_frame_register_unsigned (this_frame, ARM_PS_REGNUM); if ((xpsr & 0xff) != 0) /* Handler mode: This is the mode that exceptions are handled in. */ arm_cache_switch_prev_sp (cache, tdep, tdep->m_profile_msp_s_regnum); else /* Thread mode: This is the normal mode that programs run in. */ arm_cache_switch_prev_sp (cache, tdep, tdep->m_profile_psp_s_regnum); This code does not comply Arm®v8-M Architecture Reference Manual B3.8 Stack pointer IDMLS "In Thread mode, CONTROL.SPSEL determines whether the PE uses the main or process stack" and uses process stack regardless of SPSEL. The test should check SPSEL bit of CONTROL_S register. Unfortunately the current arm-tdep is not aware of this register, we need to look up the register number in arm_gdbarch_init(). Moreover stack unwinders probably do not keep track of CONTROL_S updates. Even if we neglect usually very seldom updates of SPSEL and use the value from the innermost frame we have better chance to see correct stack frames. -- You are receiving this mail because: You are on the CC list for the bug.
next reply other threads:[~2022-10-21 20:59 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-10-21 20:59 tomas.vanek at fbl dot cz [this message] 2022-10-29 10:47 ` [Bug tdep/29716] " tomas.vanek at fbl dot cz 2022-10-29 15:43 ` tomas.vanek at fbl dot cz 2022-11-04 15:36 ` torbjorn.svensson at st dot com 2022-11-04 18:01 ` tomas.vanek at fbl dot cz 2022-11-04 18:24 ` tomas.vanek at fbl dot cz 2022-11-04 20:54 ` tomas.vanek at fbl dot cz 2022-11-05 9:50 ` tomas.vanek at fbl dot cz
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=bug-29716-4717@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=gdb-prs@sourceware.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: linkBe 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; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).