From patchwork Sat Dec 17 06:41:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Indu Bhagat X-Patchwork-Id: 34193 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp1382672wrn; Fri, 16 Dec 2022 22:44:14 -0800 (PST) X-Google-Smtp-Source: AA0mqf4EHY0x0IjvDuQyaq87tF6ebFahw4Ak/r4+QRiZbcYIdBT5soqh/PANJMixukwqgDZDe9+L X-Received: by 2002:a05:6402:f24:b0:46d:ca42:2e59 with SMTP id i36-20020a0564020f2400b0046dca422e59mr34850540eda.11.1671259454147; Fri, 16 Dec 2022 22:44:14 -0800 (PST) Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id n11-20020a05640205cb00b00477e889f2a6si878979edx.53.2022.12.16.22.44.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Dec 2022 22:44:14 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=aJ8kZsoq; arc=fail (signature failed); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F194138AEB7E for ; Sat, 17 Dec 2022 06:43:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F194138AEB7E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1671259383; bh=SXjgn0LLxdaZFhMewXEQ4u+5W0GlDqDwiXvvWeKdTP8=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=aJ8kZsoqGytvtRrO9BER9VtCGQaPYHXJIP2+86PkFzlM+QBUfMgp8pcl74V2g2yee A7bnOSYHXD1SfNbb0d1OUTmmBa5LALwIrEpO5vDM2Y0/V64qtnwG7z5MPMy46sMPx8 ZksYmgFtiHUFitxkJM3Op5D0rt7/SkWvq48mt4ik= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by sourceware.org (Postfix) with ESMTPS id E8C3138A9096 for ; Sat, 17 Dec 2022 06:41:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E8C3138A9096 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BH4WoDu007226 for ; Sat, 17 Dec 2022 06:41:50 GMT Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3mh6tqr2b0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 17 Dec 2022 06:41:49 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2BH588ob012661 for ; Sat, 17 Dec 2022 06:41:49 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2171.outbound.protection.outlook.com [104.47.55.171]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3mh471e3ev-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 17 Dec 2022 06:41:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YUT1GjqnIh+5gioDoJTgGnezVjVzz9PJz+gX0vFfW9m+cnxj/XQV+LyW0d/rIMm8tM4E3xHtqdqQsYjr2N0wWYWdGhS/ZCgP414lVXzHOzFNlXFCVXLdBiCbHEguk9vuXpmswPu4CaR4sWOZVChrg41qaFu7qaAt92nKqKhJ7z8TDWzTtrpsLieV8M55kZ0vH6Rq5gR9Y8QkMc8dxUlD2Q6fNq8sonFvhkctcmgalPEVZv1X9RdBOE0pyAPIDlboA66OT9QnLHDYreyaPqSeI4uHmJUw0Ga6z0xvb/zLZbRZCsVNcRB36Mrzp1cB+BrBmz8x1OeaBZsjfe0mFmEgXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=SXjgn0LLxdaZFhMewXEQ4u+5W0GlDqDwiXvvWeKdTP8=; b=hXc/N+5nD34aqLSdAEsxUPmUIdQIDg3CO6GmqZ646OeYYIAcTtK04to050jt4GWVi45LUqekx7aJywzDl1y2dgz5Yvn47zYnnfs+tqecIIAt+KMqEYDytGfV5PEi1FMzzuVJPSKoCEAy1I+wcR8lD5pqATs6s2YznoYP0B1DMSant6Z2Di+OazcT17FgdKqeALzc/ebebr456AjUVllnOazajasgjd+LlOnY768fT/MgQQtAKzuF+F6rgA0133oXH1qiF+6ipLchP9VnYyX3ph+2rsRbdI5CMh0gPeH+rxEqb1EiWl77tB7mYq2RV/TQLSn5IOn3YEVQZsWl96oUUg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none Received: from MWHPR1001MB2158.namprd10.prod.outlook.com (2603:10b6:301:2d::17) by BN0PR10MB5285.namprd10.prod.outlook.com (2603:10b6:408:12e::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.18; Sat, 17 Dec 2022 06:41:47 +0000 Received: from MWHPR1001MB2158.namprd10.prod.outlook.com ([fe80::ee70:1952:4416:1bdc]) by MWHPR1001MB2158.namprd10.prod.outlook.com ([fe80::ee70:1952:4416:1bdc%5]) with mapi id 15.20.5924.012; Sat, 17 Dec 2022 06:41:47 +0000 To: binutils@sourceware.org Cc: Indu Bhagat Subject: [COMMITTED, V2 1/6] sframe.h: add support for .cfi_negate_ra_state Date: Fri, 16 Dec 2022 22:41:23 -0800 Message-Id: <20221217064128.11326-2-indu.bhagat@oracle.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221217064128.11326-1-indu.bhagat@oracle.com> References: <20221217064128.11326-1-indu.bhagat@oracle.com> X-ClientProxiedBy: MW2PR16CA0030.namprd16.prod.outlook.com (2603:10b6:907::43) To MWHPR1001MB2158.namprd10.prod.outlook.com (2603:10b6:301:2d::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWHPR1001MB2158:EE_|BN0PR10MB5285:EE_ X-MS-Office365-Filtering-Correlation-Id: 7110e9b9-0700-4f03-a815-08dadff9c4ca X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cr1ts2xOYJpKd4R2QZN3kDRHuJaXF8PgLOeqbzWZuBMlYv20QBYbk808rOfrTGrJ5FSU07pVNjiOOljlF/3QoNJpSYatA1sfjubNUC/NsW1OEwdtdbpfZuG+7KlqnrhaOFIrvDpuupTH0/M7P6X5Tfsarq7RaCk+mNcCotnjGbwIHr+LbZhy6EToD2JUPUn2woduc6j4mojjyUwJ+Q46Z/h2JUQACALTjUmOSk4D1s2sNtc7SMNsm/X19uD3hZa+gzrGPlgYF17I+Pf0d9NVJm/vZdUWr3hK3e6l2a5EccTumwHda1ehcClLUvTrnn163IoebG9nvyK+gTcutdJJAS2PGjq9WEadx4L9V9Ed09PLORI0ayUJ/dw7qUDeU27cUhEDZRzqN5Otrwl9V4FhiXjlvScKGDwgO0HBSbRcIzhmTOl5SEoj9aFZO7ww9jpR6HOcOu+3ffQkBAy2r93qTmHxSMM0y/5tiPvvzkQOD+uf7oZWaK3JLHI+77ILJZ/jUHb4et13FA/fb6CibRYF9J3hYwAd227Nu31ooVTRVNd3DlA7AwUxUkE52C9X1UCyv0jhNTdMyZOALlhFbjK+1iMiZI5rSDRHxuZ0e4ZZUvlIdqXsSrPC1gXJ3ctWuwmiiYlMbjC5ToEdaaSLgqp0RZYtscwWrbYuvBDfDKf17+TvhKAG1qqa/x81jOPi2Rfy45eQ6UQkXIlcKfd9famqgg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR1001MB2158.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(376002)(136003)(396003)(366004)(346002)(39860400002)(451199015)(83380400001)(2906002)(38100700002)(8936002)(1076003)(186003)(66556008)(2616005)(41300700001)(66946007)(6916009)(36756003)(316002)(66476007)(6512007)(86362001)(8676002)(6486002)(4326008)(5660300002)(6506007)(44832011)(6666004)(107886003)(478600001)(142923001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fTNuJktMBvhk0/9kZPHxJTKQHXnfgxjs9TN58V8EvIv9vWcsn3hscvX9k52CuBgj9oEXQbuH9A2EmDistRKlASMhK3K1/ypLR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sYCtvlOzd5laxjdzPFlpMayaDdLXd1I0ncOfkeHzzgbyS4ObgfiWPhemFpBuTZrLF+ovc6Tt2Y3u/lKjSEJ845xeYlvAwe+JrhcUWIgQAbtbVJgf1CQMDeOhnVDLj3EmW9n3RbbX5oMgDXYFHVJnfZGKycveSiiNpJQMnt0P2yGPG9WrmQpe9cn7pOuqHLqg0JO4IuFjZpGSIKHkdCDCRTmnXjDCCeWeYav9FH1BBjpDDDWpv2NEOcWKrQfYZ48tMbbmAHg8qtA23Sm8TpKPo1BQ78F22gsR2iG3oeb5RGkNTaGTRXLPqTdsCIBrQMg5lgDJZ4CSu59O1vi5/Xjxew37XaojySS6q0NI4kuzosMZfI+uk7FMAMWYKSinH7uHhqq/4u8TR6aP0manBy1S9OTYhOQ8/wsnWJK7yUqew/82z6kjgFRIPnTy9hAP14i5U2cEkzmPoDyaDoGItdoeb1yF9Qg= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7110e9b9-0700-4f03-a815-08dadff9c4ca X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2158.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2022 06:41:46.9687 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Slp2HmDjqbSTHnjPdXrhlGbgN9JzXNX35RctjDQrJLoAU3M5sRFd2Jrr62rhA225KQs3EJfQ7ShVM4NrKEcgdw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB5285 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-17_01,2022-12-15_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 suspectscore=0 adultscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212170057 X-Proofpoint-GUID: CXkdudZ_yuLu_5ExcB4w9of_4YadOzL9 X-Proofpoint-ORIG-GUID: CXkdudZ_yuLu_5ExcB4w9of_4YadOzL9 X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, 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 X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Indu Bhagat via Binutils From: Indu Bhagat Reply-To: Indu Bhagat Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752442553516621471?= X-GMAIL-MSGID: =?utf-8?q?1752442553516621471?= [No Changes in V2] Use the last remaining bit in the 'SFrame FRE info' word to store whether the RA is signed/unsigned with PAC authorization code: this bit is named as the "mangled RA" bit. This bit is still unused for x86-64. The behaviour of the mangled-RA info bit in SFrame format closely follows the behaviour of DW_CFA_AARCH64_negate_ra_state in DWARF. During unwinding, whenever an SFrame FRE with non-zero "mangled RA" bit is encountered, it means the upper bits of the return address contain Pointer Authentication code. The unwinder, hence, must use appropriate means to restore LR correctly in such cases. include/ChangeLog: * sframe.h (SFRAME_V1_FRE_INFO_UPDATE_MANGLED_RA_P): New macro. (SFRAME_V1_FRE_MANGLED_RA_P): Likewise. --- include/sframe.h | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/include/sframe.h b/include/sframe.h index 03a2d75dfd3..b2bd41a724e 100644 --- a/include/sframe.h +++ b/include/sframe.h @@ -227,11 +227,12 @@ typedef struct sframe_fre_info - 2 bits: information about size of the offsets (S) in bytes. Valid values are SFRAME_FRE_OFFSET_1B, SFRAME_FRE_OFFSET_2B, SFRAME_FRE_OFFSET_4B - - 1 bit: Unused. - ----------------------------------------------------------------------- - | Unused | Size of offsets | Number of offsets | base_reg | - ----------------------------------------------------------------------- - 8 7 5 1 0 + - 1 bit: Mangled RA state bit (aarch64 only). + ---------------------------------------------------------------------------------- + | Mangled-RA (aarch64) | Size of offsets | Number of offsets | base_reg | + | Unused (amd64) | | | | + ---------------------------------------------------------------------------------- + 8 7 5 1 0 */ uint8_t fre_info; @@ -239,13 +240,19 @@ typedef struct sframe_fre_info /* Macros to compose and decompose FRE info. */ +/* Note: Set mangled_ra_p to zero by default. */ #define SFRAME_V1_FRE_INFO(base_reg_id, offset_num, offset_size) \ - ((((offset_size) & 0x3) << 5) | (((offset_num) & 0xf) << 1) | \ - ((base_reg_id) & 0x1)) + (((0 & 0x1) << 7) | (((offset_size) & 0x3) << 5) | \ + (((offset_num) & 0xf) << 1) | ((base_reg_id) & 0x1)) + +/* Set the mangled_ra_p bit as indicated. */ +#define SFRAME_V1_FRE_INFO_UPDATE_MANGLED_RA_P(mangled_ra_p, fre_info) \ + ((((mangled_ra_p) & 0x1) << 7) | ((fre_info) & 0x7f)) #define SFRAME_V1_FRE_CFA_BASE_REG_ID(data) ((data) & 0x1) #define SFRAME_V1_FRE_OFFSET_COUNT(data) (((data) >> 1) & 0xf) -#define SFRAME_V1_FRE_OFFSET_SIZE(data) (((data) >> 5) & 0x3) +#define SFRAME_V1_FRE_OFFSET_SIZE(data) (((data) >> 5) & 0x3) +#define SFRAME_V1_FRE_MANGLED_RA_P(data) (((data) >> 7) & 0x1) /* SFrame Frame Row Entry definitions.