public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Indu Bhagat <indu.bhagat@oracle.com>
To: Jens Remus <jremus@linux.ibm.com>, binutils@sourceware.org
Cc: Andreas Krebbel <krebbel@linux.ibm.com>
Subject: Re: [RFC PATCH 0/9] s390: Initial support to generate SFrame info from CFI directives in assembler
Date: Fri, 23 Feb 2024 13:16:54 -0800	[thread overview]
Message-ID: <0bcb6731-6ee6-4b05-8a59-4a249197fb58@oracle.com> (raw)
In-Reply-To: <20240223170800.3993092-1-jremus@linux.ibm.com>

Hi Jens,

On 2/23/24 09:07, Jens Remus wrote:
> This patch series adds initial support to the assembler on s390x to
> generate SFrame stack trace information from CFI directives. It is
> largely based on the respective AArch64 support.
> 
> Please be aware that the SFrame support for s390x provided by patch 9
> of this series still has some open issues, which need to be addressed.
> Any ideas or assistance to overcome the current SFrame limitations
> listed below and in the patch description are very welcome.
> 
> Patches 1-8 are generic cleanups and enhancements to the generation
> of SFrame information in the assembler. Patch 9 adds the initial s390x
> support and is purely RFC.
> 
> 
> Patches 1-3 are minor cleanups/enhancements to the existing SFrame
> support on AArch64 and x86 AMD64.
> 
> Patch 4 enables readelf/objdump to dump the SFrame fixed offsets from
> CFA to the frame pointer (FP) and return address (RA).
> 
> Patch 5 enhances an SFrame warning message to print the human readable
> DWARF call frame instruction name.
> 
> Patch 6 and 7 resolve issues that cause the assembler to either generate
> bad SFrame FDE or to silently skip it. Both issues would be triggered by
> s390-specific SFrame error test cases introduced by patch 9.
> 
> Patch 8 adds verbose assembler warning messages when generation of
> SFrame FDE is skipped.
> 

Thanks for fixing issues and enhancing SFrame handling in Binutils.

> Patch 9 adds initial support to the assembler on s390x to generate
> SFrame stack trace information from CFI directives. Due to differences
> in the s390x ELF ABI [1] compared to the AArch64 and x68 AMD64 ELF ABIs
> and the simplified assumptions of the current SFrame format V2 there
> are several unresolved issues (see also patch description):
> 
> - GCC on s390x may save the frame pointer (FP; r11) and/or return
>    address (RA; r14) registers in other registers (e.g. floating-point
>    registers) instead of saving them on the stack. SFrame currently only
>    supports FP/RA tracking on the stack.
>    This can be reproduced by using a small inline assembler statement,
>    that specifies r11 (FP) and/or r14 (RA) as output operand(s). It can
>    also be observed when compiling a minimal C program using GCC without
>    optimizations.
> 
> - The s390x ELF ABI does not specify a frame pointer register number.
>    Currently GCC and clang both mostly use register r11, but GCC can
>    also be observed to use r14. On s390x a compiler may choose about
>    any register number for that purpose and declare it using CFI
>    directives.
>    This can be observed when compiling glibc, as parts of its hand-
>    written assembler uses register r12 as frame pointer.
> 
> - GCC on s390x may copy the return address (RA) from register r14 to
>    another register and even use that to return to the caller.
>    Effectively this is just a specialization of the first bullet.
> 
> If my understanding of the current SFrame format is not wrong I assume
> the following enhancements to SFrame would be required to fully support
> the s390x architecture:
> 
> - Tracking of the CFA base pointer register number specified in CFI
>    directives .cfi_def_cfa and .cfi_def_cfa_register.
> 
> - Tracking of SP, FP, and RA register contents being saved in other
>    registers instead of on the stack, as specified by CFI directive
>    .cfi_register.
> 
> - Both would effectively require support in SFrame to track all of the
>    17 registers specified as saved in the s390x ELF ABI (r6-r13, r15,
>    and f8-f15), since SP, FP, and RA could be saved in one of those and
>    thus would need to be restored during unwinding.
> 

While I am in the process of taking a closer look at the patchset, and 
the requirements of the s390x ABI to see how to best support with 
SFrame, I would like to add here that tracking all of callee-saved 
registers will significantly bloat up the .sframe section.  (As you 
already know, the offsets to recover the registers from stack are stated 
explicitly in the format).  Hence, adapting the SFrame format to track 
all callee-saved registers is not recommended.

> - Potentially optional, if the use in glibc could be removed:
>    Tracking of SP, FP, and RA register contents being CFA+offset, as
>    specified by .cfi_val_offset.
> 
> [1] ELF ABI s390x Supplement:
>      https://github.com/IBM/s390x-abi/releases
> 
> Changes v1 -> v2:
> - Resolved a regression reported by Linaro-TCWG-CI on AArch64 in one of
>    the generic ld SFrame test cases. The test case contained a
>    .cfi_def_cfa directive, specifying a CFA base register number that is
>    not necessarily a SFrame SP/FP register number on all architectures.
>    This caused the changes from patch 6 to skip SFrame FDE generation on
>    AArch64 (and s390x aswell) with a warning, causing the test case to
>    fail.
> 
> Thanks and regards,
> Jens
> 
> Jens Remus (9):
>    x86: Remove unused SFrame CFI RA register variable
>    aarch64: Align SFrame terminology in comments to specs and x86
>    sframe: Enhance comments for SFRAME_CFA_*_REG macros
>    readelf/objdump: Dump SFrame CFA fixed FP and RA offsets
>    gas: Print DWARF call frame insn name in SFrame warning message
>    gas: Skip SFrame FDE if CFI specifies non-FP/SP base register
>    gas: Warn if SFrame FDE is skipped due to non-default return column
>    gas: User readable warnings if SFrame FDE is not generated
>    s390: Initial support to generate .sframe from CFI directives in
>      assembler
> 


  parent reply	other threads:[~2024-02-23 21:16 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-23 17:07 Jens Remus
2024-02-23 17:07 ` [PATCH v2 1/9] x86: Remove unused SFrame CFI RA register variable Jens Remus
2024-02-24  7:38   ` Indu Bhagat
2024-02-26 13:01     ` Jan Beulich
2024-02-26 14:51       ` Jens Remus
2024-02-27  9:08       ` Indu Bhagat
2024-02-27  9:11         ` Jan Beulich
2024-02-26 15:04     ` Jens Remus
2024-02-23 17:07 ` [PATCH v2 2/9] aarch64: Align SFrame terminology in comments to specs and x86 Jens Remus
2024-02-24  7:44   ` Indu Bhagat
2024-02-23 17:07 ` [PATCH v2 3/9] sframe: Enhance comments for SFRAME_CFA_*_REG macros Jens Remus
2024-02-24  7:46   ` Indu Bhagat
2024-02-26 13:51     ` Jan Beulich
2024-02-27  8:53       ` Indu Bhagat
2024-02-27  8:57         ` Jan Beulich
2024-02-27  9:01           ` Indu Bhagat
2024-02-23 17:07 ` [PATCH v2 4/9] readelf/objdump: Dump SFrame CFA fixed FP and RA offsets Jens Remus
2024-02-24  7:48   ` Indu Bhagat
2024-02-23 17:07 ` [PATCH v2 5/9] gas: Print DWARF call frame insn name in SFrame warning message Jens Remus
2024-02-24  7:56   ` Indu Bhagat
2024-02-26 15:37     ` Jens Remus
2024-02-23 17:07 ` [PATCH v2 6/9] gas: Skip SFrame FDE if CFI specifies non-FP/SP base register Jens Remus
2024-02-24  7:57   ` Indu Bhagat
2024-02-23 17:07 ` [PATCH v2 7/9] gas: Warn if SFrame FDE is skipped due to non-default return column Jens Remus
2024-02-24  8:43   ` Indu Bhagat
2024-02-26 16:19     ` Jens Remus
2024-02-23 17:07 ` [PATCH v2 8/9] gas: User readable warnings if SFrame FDE is not generated Jens Remus
2024-02-29  7:39   ` Indu Bhagat
2024-04-09 14:14     ` Jens Remus
2024-02-23 17:08 ` [RFC PATCH 9/9] s390: Initial support to generate .sframe from CFI directives in assembler Jens Remus
2024-02-29  7:01   ` Indu Bhagat
2024-04-09 15:07     ` Jens Remus
2024-02-23 17:27 ` [RFC PATCH 0/9] s390: Initial support to generate SFrame info " Jens Remus
2024-02-23 21:16 ` Indu Bhagat [this message]
2024-04-05 18:26   ` Indu Bhagat
2024-04-09 14:19     ` Jens Remus
  -- strict thread matches above, loose matches on Subject: below --
2024-02-22 16:01 Jens Remus

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=0bcb6731-6ee6-4b05-8a59-4a249197fb58@oracle.com \
    --to=indu.bhagat@oracle.com \
    --cc=binutils@sourceware.org \
    --cc=jremus@linux.ibm.com \
    --cc=krebbel@linux.ibm.com \
    /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: link
Be 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).