From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 751373858C78 for ; Fri, 12 Apr 2024 16:37:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 751373858C78 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 751373858C78 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712939836; cv=none; b=dJRSyswZ8UWP+QlXEt1JQQZM8GqWgRGjlBm7/xRz6sb1cJNOorLx1XUS5Y6OjEVx/wD6LePXt8m5gwIjf5FF1Y7caIddqGyLTGrdwC+YuluGWlj5tqvwezkfjUo2RxDHocCyjQXdo/VGY/9GbJzLoOgLHXUzM0NqN+OWvwRhalg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712939836; c=relaxed/simple; bh=ez/o8lfe00fXS82hvmurLVTLudKq4IdTO5nXcr1DapE=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=iQWp3wIujjiY+SISCjKNTViW9fXW2dYrzgeDfiWfEyhkBvTdTjpB7cJHN/86zzHHiNvRbtDpP5kUPj8HqD2YroCdvTiZKCO7CgX+X+oQc6l53XJnwR6+IbIUOCWmkz8dgYCOet+V6OXkJb3TyqFLlTB/GjnlRT3fGVJ7W//txT0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0353724.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43CFxCkg010171; Fri, 12 Apr 2024 16:36:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : content-transfer-encoding : mime-version; s=pp1; bh=+p2f6zzGPSP3LkoWRT3wKThuOC8DIXeCrqVFnh4T49U=; b=NoSAaf65/WtSxcVAlZwHL9Ys3u8vRwZvRmA7y76LRDsH+h4C820OEgwvvjkFHTgNt8UG SK5V2chcZpQMzEOEzcTbKShPtyCMVaiXdye2fURdsDrD3fkqgqFqKIZpXF13kCHO3NNF QHS+LlzE/thZZEeL33h6FL37WWIps6Z8vUqS7T4d/sK/hN0W8LCc1+v/Hf0tdIetQSDY C+IvxWCBkNFo8mM7gpx7RK6xcdKHi5cBdDGnf66/T6JFgQ9H1hm8ffRTtiWAlMkPUsGr Xg6TTakbh/uPPY7iW2uHEggUdyUh8FeK37E2y5TNHdj1M+giVqFmtmtvjn9shLZUeVcu /w== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3xf5gugefr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Apr 2024 16:36:34 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 43CEsq9P029889; Fri, 12 Apr 2024 16:36:33 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3xbj7mttfm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Apr 2024 16:36:33 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 43CGaRqZ29229752 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Apr 2024 16:36:29 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6905320043; Fri, 12 Apr 2024 16:36:27 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4734920040; Fri, 12 Apr 2024 16:36:27 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 12 Apr 2024 16:36:27 +0000 (GMT) From: Jens Remus To: binutils@sourceware.org, Indu Bhagat Cc: Jens Remus , Andreas Krebbel Subject: [RFC PATCH v3 0/2] s390: Initial support to generate SFrame info from CFI directives in assembler Date: Fri, 12 Apr 2024 18:36:23 +0200 Message-Id: <20240412163625.965517-1-jremus@linux.ibm.com> X-Mailer: git-send-email 2.40.1 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: LilA8ccSyjCp5QmoZYa9Bf1VIEnyumC7 X-Proofpoint-ORIG-GUID: LilA8ccSyjCp5QmoZYa9Bf1VIEnyumC7 Content-Transfer-Encoding: 8bit X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-12_12,2024-04-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 bulkscore=0 phishscore=0 adultscore=0 impostorscore=0 clxscore=1015 lowpriorityscore=0 priorityscore=1501 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404120120 X-Spam-Status: No, score=-6.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: As suggested by Indu I have split my RFC V2 patch series to add initial support to generate SFrame information on s390x into: 1. A separate series consisting of all the generic preparatory cleanups, enhancements, and fixes to the generation of SFrame information in the assembler: "[PATCH v3 00/15] sframe: Enhancements to SFrame info generation". 2. This RFC series on top with the actual "s390: Initial support to generate SFrame info from CFI directives in assembler" Since the original patch series was at V2 I am sending both as V3. 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 patches 1 and 2 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. Patch 1 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. GCC only does so in leaf-functions. That are functions that do not call any other functions. Therefore they are guaranteed to only ever be the topmost function on the call stack. This is addressed by patch 2, which extends SFrame with limited support to represent FP/RA saved in another register on s390x. - The s390x ELF ABI does not designate a frame pointer register number. Currently GCC and clang mostly use register r11. This could be addressed by designating r11 as frame-pointer register in the s390x ELF ABI in a SFrame compatibility section. - GCC GCC be observed to use r14 as frame-pointer register in the stack clash protector in the function prologue. This guarantees that the function is toplevel on the call stack during this non-default frame- pointer use. This could be addressed by changing GCC to use the "default" frame- pointer register r11. Another option would be to extend SFrame with limited support to track a non-SP/FP CFA base register number on s390x. - Glibc uses non-default frame-pointer register r12 in two instances. This most likely can be addressed by chaning glibc to use the default frame-pointer register r11 instead. - Glibc mcount() / fentry() use non-default return-adress register r0. This cannot be changed, but the use of Linux Kernel perf together with profiling can be documented as incompatible on s390x. - 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 and is addressed by patch 2. - GCC may produce code and CFI where the FP is saved on the stack while the RA is not. SFrame currently cannot represent this. See the respective patch in my separate preparatory patch series. This can be addressed by enhancing SFrame to represent this case. I will send two alternative options to achieve this as RFC soon. Patch 2 (new) extends SFrame with limited support to represent FP/RA saved in another register on s390x. Functions may use this only while they are the toplevel function on the call stack. That is for instance in leaf-functions and in the function prologue and epilogue. [1] ELF ABI s390x Supplement: https://github.com/IBM/s390x-abi/releases Changes v3 -> v2: - New patch as noted above and in the patch notes. 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 (2): s390: Initial support to generate .sframe from CFI directives in assembler s390: SFrame track FP/RA saved in register gas/config/tc-s390.c | 55 +++++++++++++++++++ gas/config/tc-s390.h | 31 +++++++++++ gas/gen-sframe.c | 37 ++++++++++++- .../gas/cfi-sframe/cfi-sframe-s390-1.d | 23 ++++++++ .../gas/cfi-sframe/cfi-sframe-s390-1.s | 37 +++++++++++++ .../gas/cfi-sframe/cfi-sframe-s390-2.d | 23 ++++++++ .../gas/cfi-sframe/cfi-sframe-s390-2.s | 37 +++++++++++++ .../gas/cfi-sframe/cfi-sframe-s390-3.d | 22 ++++++++ .../gas/cfi-sframe/cfi-sframe-s390-3.s | 15 +++++ .../gas/cfi-sframe/cfi-sframe-s390-4.d | 21 +++++++ .../gas/cfi-sframe/cfi-sframe-s390-4.s | 6 ++ .../gas/cfi-sframe/cfi-sframe-s390-err-1.d | 15 +++++ .../gas/cfi-sframe/cfi-sframe-s390-err-1.s | 37 +++++++++++++ .../gas/cfi-sframe/cfi-sframe-s390-err-2.d | 15 +++++ .../gas/cfi-sframe/cfi-sframe-s390-err-2.s | 37 +++++++++++++ .../gas/cfi-sframe/cfi-sframe-s390-err-4.d | 15 +++++ .../gas/cfi-sframe/cfi-sframe-s390-err-4.s | 5 ++ .../gas/cfi-sframe/cfi-sframe-s390-err-5.d | 15 +++++ .../gas/cfi-sframe/cfi-sframe-s390-err-5.s | 22 ++++++++ .../gas/cfi-sframe/cfi-sframe-s390-err-6.d | 15 +++++ .../gas/cfi-sframe/cfi-sframe-s390-err-6.s | 15 +++++ gas/testsuite/gas/cfi-sframe/cfi-sframe.exp | 16 +++++- include/sframe.h | 7 ++- libsframe/doc/sframe-spec.texi | 8 ++- libsframe/sframe-dump.c | 22 +++++++- 25 files changed, 542 insertions(+), 9 deletions(-) create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-s390-1.d create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-s390-1.s create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-s390-2.d create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-s390-2.s create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-s390-3.d create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-s390-3.s create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-s390-4.d create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-s390-4.s create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-s390-err-1.d create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-s390-err-1.s create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-s390-err-2.d create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-s390-err-2.s create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-s390-err-4.d create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-s390-err-4.s create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-s390-err-5.d create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-s390-err-5.s create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-s390-err-6.d create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-s390-err-6.s -- 2.40.1