From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on2057.outbound.protection.outlook.com [40.107.14.57]) by sourceware.org (Postfix) with ESMTPS id 04DE03858D1E for ; Mon, 9 Jan 2023 19:30:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 04DE03858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Zpq6VhXeGYkuP5DZLWUi9FYdYtC4aA/fRtqO7srEHFA=; b=u1XLhGptduBvsLR4Cs229ge5JeDwebGFjOTDBCI7534fpfL2CS6qwmOg1AD/n5XtrGckniC781FmssxDluTLrNXeZ713Fse/yKmm89stcNR5/yayleyp8ioBr2XshzVR5fFSivXDCjkWdgbwYY1aDS2mEbU9IWPJ/25Rkqnq4Bw= Received: from AS9PR06CA0160.eurprd06.prod.outlook.com (2603:10a6:20b:45c::23) by PAWPR08MB9968.eurprd08.prod.outlook.com (2603:10a6:102:35b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Mon, 9 Jan 2023 19:30:16 +0000 Received: from VI1EUR03FT032.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:45c:cafe::ac) by AS9PR06CA0160.outlook.office365.com (2603:10a6:20b:45c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18 via Frontend Transport; Mon, 9 Jan 2023 19:30:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VI1EUR03FT032.mail.protection.outlook.com (100.127.145.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18 via Frontend Transport; Mon, 9 Jan 2023 19:30:15 +0000 Received: ("Tessian outbound 6e565e48ed4a:v132"); Mon, 09 Jan 2023 19:30:15 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 02090887315dc4d3 X-CR-MTA-TID: 64aa7808 Received: from 4f61443b3d64.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 31037ABC-9FAE-45FE-8EA7-DB95F5882DFE.1; Mon, 09 Jan 2023 19:30:08 +0000 Received: from EUR02-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 4f61443b3d64.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 09 Jan 2023 19:30:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PUMD7YJ+lq3s6V1zXp/+YKQMnvOCKBNc13OKWwBXYF31BITAF15h6dhZJHPOwu4jBeK6gWNZiVdCc8KfJZHYuW9LiikySlz2UseMaR5poLTvzb7alumVdIATbkfGqDS5kYCFM+NCvELFuNlm4ozOgzY+qm8Cj9ZiLnscij4t4wIeUwiVO7/YLBInHElKi/lAp+NST6fkVoKLdK6svxy2ZrY07/NiWUR95xEB7AaMmgnBBE9gPRV7dE22IJ8fi2WWn4CCsv59whGNp871ya8sk36LwTWcn4/i3Zzy3Lue5jdBZUxGAqX2A/gYcpo0frX2qre1tbR/73cQdE4WfkeTdw== 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=Zpq6VhXeGYkuP5DZLWUi9FYdYtC4aA/fRtqO7srEHFA=; b=anmkL8eHfFwWdo7Ghl+nfq9/OIdjt4eCSr4DwVu2AO1M4JedVlYHOuDRemhA2AAwiBlYD2CO7Ij18DFCyZi/sGBx3S8suSXsEzsrmfl3cRxFLVXWL0efAOZU7KdjnmbuajVOU14FfmaewC1NMTwZovJoW6dT4rwYfPhpokGyAbDFsPeB9EqOeumI4OaqAUq45MdV2PTjVruPSE4DAiAczSP/SYnOCnNB55vgnjtHY2PiO24ae1G+MCoGezeuQHu+JnkrO+REWJa0GdZwt39h4iAFfbMQ2VMFhJfDleOEr6PZJhBEem20X3xRN90dvWr4/OyYPK/Fd64js4rdyozUHw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Zpq6VhXeGYkuP5DZLWUi9FYdYtC4aA/fRtqO7srEHFA=; b=u1XLhGptduBvsLR4Cs229ge5JeDwebGFjOTDBCI7534fpfL2CS6qwmOg1AD/n5XtrGckniC781FmssxDluTLrNXeZ713Fse/yKmm89stcNR5/yayleyp8ioBr2XshzVR5fFSivXDCjkWdgbwYY1aDS2mEbU9IWPJ/25Rkqnq4Bw= Received: from DB7PR02CA0026.eurprd02.prod.outlook.com (2603:10a6:10:52::39) by PAVPR08MB9795.eurprd08.prod.outlook.com (2603:10a6:102:31f::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Mon, 9 Jan 2023 19:30:06 +0000 Received: from DBAEUR03FT065.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:52:cafe::d7) by DB7PR02CA0026.outlook.office365.com (2603:10a6:10:52::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18 via Frontend Transport; Mon, 9 Jan 2023 19:30:06 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; pr=C Received: from nebula.arm.com (40.67.248.234) by DBAEUR03FT065.mail.protection.outlook.com (100.127.142.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5986.18 via Frontend Transport; Mon, 9 Jan 2023 19:30:06 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Mon, 9 Jan 2023 19:30:04 +0000 Received: from e125768 (10.2.78.50) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16 via Frontend Transport; Mon, 9 Jan 2023 19:30:04 +0000 Date: Mon, 9 Jan 2023 19:30:00 +0000 Message-ID: From: "Victor L. Do Nascimento" To: CC: Subject: [PATCH v5a 8/8] newlib: libc: setjmp M-profile PACBTI-enablement MIME-Version: 1.0 Content-Type: text/plain X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT065:EE_|PAVPR08MB9795:EE_|VI1EUR03FT032:EE_|PAWPR08MB9968:EE_ X-MS-Office365-Filtering-Correlation-Id: b4144fd4-20ea-4b37-a877-08daf277ef84 x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 5E8UOsozD+UWM6twu86zaW/vWbnSPkKxUS4xlhGWPW5//+K3Uo88BE8XQDrHFSSK2Iy02/Kc5a1LHI+bgNAh93lfzOf/60nXVsGCtRzyLT5fkHAxZJqkLrNt+dzwSYUQ7LbqGLei5Vw6qe2vswxpbuetWd+vTW+v7TyDySbhnIaoXPYvy3AMQP58FXkuoxxyN/dwIDW7g/CXeYEHb844pzLwG/MWtwkrjzq2zLmEf+8jK2HohRKVYpnfzyCvKC4wwAEkUj7SF6CyFV+af4EBt3b+BuJ7q+k+DKw5L7cb6AmHQokJbYjp48CLsOjg5rxppCUfh+2t+kiO/03alYdG8h5SEYL9mIVhL82XtmmXzwEKX1lXmS0TIrIPsQ/iTF7uY0XH0TLk7AgxDJsaWaTJLMKRRVEH1AxQXypfnYm22D/lAwFP14WPZzMbISScHsHRArUuiedRIhn8ZKqbNXpOKud4V4bLI/1fzqQPU3Z4besxKXQXq7TGld880cltfVWcAAzAcoKn6y4v9fJtm2LeZFRZif3SJRI100d9K29vVRUHJsnmTPIU+njTShMf20KbWO0OOnmzSVjL8EuQXuDgY+YUJa7iHsDgSaxXZiJL1z3u9QImEOkIOlQElhGnxvFddQHwBOSTspg35N+dxJ1ksE0SI+C91p7v/8hSv0wXlFFH0p3yD1T8JNurYiULg28Hg8bE7AkTGS/FuZhpRSyLvp0gSJ7Ek1QkTIvBuP7LSZM= X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(346002)(376002)(39860400002)(396003)(136003)(451199015)(46966006)(36840700001)(6916009)(356005)(82310400005)(41300700001)(478600001)(2906002)(316002)(82740400003)(6666004)(36860700001)(4326008)(83380400001)(336012)(8676002)(4743002)(186003)(26005)(40480700001)(86362001)(5660300002)(36756003)(2616005)(81166007)(70206006)(70586007)(47076005)(426003)(8936002)(42413004)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAVPR08MB9795 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VI1EUR03FT032.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: d148df9e-f5cf-412d-0ed3-08daf277e9c4 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uKLRHIl0FwIT4gQGM1MywJX1jpGa65hMI2aZHTxdIEjx1KN6Wey69i/BYpU9EmTXQfko/0D+X9gXzTS9smCTfkSr4Dx0GqxXk6dbZhVAWJTHrZM/YjFm2RvmG7YMMzVbCK3VRQOZFuLZv7TYOXGCYct/Qkv7Yy3W5mW/YZth0C/KAti4N7OPFLoT8WuRtaGdzIC7qgAhotTcjWJ1wkYZdELJbJTz5pNNLVyV/ocDux0zsXs/G6sr0U5hIkX3vhC8RHGqMH3f2EEIvA3FyPm2Kc4bJMJGKNJk5giyIOkpzwtOupxzPYBShSOffg7OqOmNBVUVMIwFLE+k5BAXRDMoXseA/zevvszDAOLLhTAZLYvbpxFS3RJrgKYC1C+w+viBCQdcKxqt70gKirnrmUYWceDbekA+yQ6obU/8yu0QOlkF0gZLYYnS6bKmIE0DkhDGdGJhAmj7gjEW0aKnZAMLLlT5c6AOBaX8uSTevESRy4kkauHrn/EioBEVmnLjHjDkez445Yv77mxWHpHAUVCifdpvijU1i2Yrlwj6IVYN6CfJCinItcwZ+0L9IzFnAJFxI1lAI44WzQfT2Bd/I5a4pE3Kk5bMrbBFQ+vXLYtpaT8PsikyI6TLr+SYHRKDqHfgE4qVdpScPTorPA8GI3mJNLmbFUV27cn2f3f/z+r3dR6P8jr7Izw+Q+i/YB8SGatGpHKUw2WR/erfEBvvATiVwslyfCdgOFWCjXtBQQWu1y0= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230022)(4636009)(346002)(376002)(39860400002)(136003)(396003)(451199015)(46966006)(40470700004)(36840700001)(36756003)(4326008)(6916009)(70206006)(40460700003)(86362001)(8676002)(70586007)(41300700001)(81166007)(82740400003)(36860700001)(6666004)(4743002)(82310400005)(26005)(478600001)(186003)(5660300002)(8936002)(2906002)(316002)(40480700001)(426003)(336012)(83380400001)(47076005)(2616005)(42413004);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jan 2023 19:30:15.8731 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b4144fd4-20ea-4b37-a877-08daf277ef84 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: VI1EUR03FT032.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR08MB9968 X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,GIT_PATCH_0,KAM_DMARC_NONE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,TXREP,UNPARSEABLE_RELAY 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: This patch revision provides the following improvements to proposed patch implementation: * Load ip directly when restoring PAC code from stack for authentication in longjmp epilogue. * Improve code readability by defining the REGS_SAVE_SIZE macro to map onto the otherwise obscure 104 constant used in str/ldr instructions. Add function prologue/epilogue to conditionally add BTI landing pads and/or PAC code generation & authentication instructions depending on compilation flags. --- newlib/libc/machine/arm/setjmp.S | 43 ++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/newlib/libc/machine/arm/setjmp.S b/newlib/libc/machine/arm/setjmp.S index d814afea8..820230458 100644 --- a/newlib/libc/machine/arm/setjmp.S +++ b/newlib/libc/machine/arm/setjmp.S @@ -22,6 +22,11 @@ #define SIZE(x) #endif +/* Jump buffer allocation sizes. */ +#define CORE_REGS_SAVE_SIZE 40 +#define FP_REGS_SAVE_SIZE 64 +#define REGS_SAVE_SIZE (CORE_REGS_SAVE_SIZE + FP_REGS_SAVE_SIZE) + /* Arm/Thumb interworking support: The interworking scheme expects functions to use a BX instruction @@ -155,6 +160,8 @@ SYM (.arm_start_of.\name): .align 2 MODE .globl SYM (\name) + .fnstart + .cfi_startproc TYPE (\name) SYM (\name): PROLOGUE \name @@ -162,6 +169,8 @@ SYM (\name): .macro FUNC_END name RET + .cfi_endproc + .fnend SIZE (\name) .endm @@ -171,6 +180,21 @@ SYM (\name): FUNC_START setjmp +#if __ARM_FEATURE_PAC_DEFAULT +# if __ARM_FEATURE_BTI_DEFAULT + pacbti ip, lr, sp +# else + pac ip, lr, sp +# endif /* __ARM_FEATURE_BTI_DEFAULT */ + mov r3, ip + str r3, [r0, #REGS_SAVE_SIZE] + .cfi_register 143, 12 +#else +# if __ARM_FEATURE_BTI_DEFAULT + bti +# endif /* __ARM_FEATURE_BTI_DEFAULT */ +#endif /* __ARM_FEATURE_PAC_DEFAULT */ + /* Save all the callee-preserved registers into the jump buffer. */ #ifdef __thumb2__ mov ip, sp @@ -184,6 +208,10 @@ SYM (\name): /* When setting up the jump buffer return 0. */ mov r0, #0 +#if __ARM_FEATURE_PAC_DEFAULT + mov ip, r3 + aut ip, lr, sp +#endif /* __ARM_FEATURE_PAC_DEFAULT */ FUNC_END setjmp @@ -193,6 +221,16 @@ SYM (\name): FUNC_START longjmp +#if __ARM_FEATURE_BTI_DEFAULT + bti +#endif /* __ARM_FEATURE_BTI_DEFAULT */ + +#if __ARM_FEATURE_PAC_DEFAULT + /* Keep original jmpbuf address for retrieving pac-code + for authentication. */ + mov r2, r0 +#endif /* __ARM_FEATURE_PAC_DEFAULT */ + /* If we have stack extension code it ought to be handled here. */ /* Restore the registers, retrieving the state when setjmp() was called. */ @@ -212,5 +250,10 @@ SYM (\name): it eq moveq r0, #1 +#if __ARM_FEATURE_PAC_DEFAULT + ldr ip, [r2, #REGS_SAVE_SIZE] + aut ip, lr, sp +#endif /* __ARM_FEATURE_PAC_DEFAULT */ + FUNC_END longjmp #endif -- 2.36.1