From patchwork Fri Dec 8 16:32:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 81753 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7819B38582AD for ; Fri, 8 Dec 2023 16:32:37 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2042.outbound.protection.outlook.com [40.107.6.42]) by sourceware.org (Postfix) with ESMTPS id E4ABC385840D for ; Fri, 8 Dec 2023 16:32:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E4ABC385840D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E4ABC385840D Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.6.42 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1702053143; cv=pass; b=xpIdmcN2KmzvAH3lPdekptzTqNqK6hnCINE2qmYHB7W4HK9OJhTWbyRYD88UvfYsK4NhAg8EYDB1MVmhB9SNmu8JD6rdSZRlxO+JQ/QrpLdDzR8QT+mHqs3HEuEc869jb+VILA33Zim/TKN15F7W6RjabguT6U6z+09TQe1WA38= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1702053143; c=relaxed/simple; bh=2ce0y9UASpil5WSBghNDc7Gw7gvyVuJJfwn5G35/TbE=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=hTEqdLkBw1mvapR5joj+yDIDE57/dzCEDiaDUy5Mu/PEe4gbItPzGmRfDjQ9pe/osS0Kc+hWzuAPf7qqC8i5ARA5oAjFBBm4puchtsgFPoyYCLGFB4+ni/h0b/KA9shpWGfQJ66NnRDcUx6+jkQPEmuVx3FKkP2AF87a6rwT0ao= ARC-Authentication-Results: i=3; server2.sourceware.org ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=grAljNJRHX2kA7rJC7OWHhtW2zVhxlJHFaLnBBCRsK+S1sxe9nqLkDLcpDuM5MRD7FNGdaFJNf8CGezVzxqS3xN5qnch4Vv0EQ84vHyuWJ7m9LMuiv9LUIHs2gJwaSZgKebm8DNWe6ZzR78ClDxNNHkqS/omIR9WbGxY/ihjTB0936g6PTYD+GmKqsMGbF5j6+B6QyfJyl2pNYke6eVIv5sY3ajQhf5/Wue4c8hf7Ng9rt+lD+HLSVECd9EkgGSx4EbgwuCGm4ze9sjzPGfRzeP/OZ66bdYhHN82voIrkDXIC+WB7pw7qdj96PVEK+9KqFQ8HZfwhpoGIK4ZUDDS3A== ARC-Message-Signature: i=2; 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=s1DhtTz0eUDx8tL4lGL4WFffgxnqnXXoPaQfyyS1tGs=; b=JCgFm11I3xOTAWQy0Xwb3k+NrNK4E/X15fAOFtlEFrTU659HHDX837/lKPd0+L6MPbbqKZZ5KbXwzErlT+GKo9vtar7Guyb4By2+Jkk0LEzHnzt8ymHgiA2UZDF0lxgwCYW6WMxGG+F4KqhKaA/II0hay87m4QtZDbbg0oYEmJKbthgGWTsqO/fMpdR9U5iRYdblVlx3dQ4ufOeUv4J73zUQ7nI2hYWecYD5WawflNgZMiX/SFxQp0ZnYIenUxgEd0e4+fzbNOgwbm6aiIFteIuy/0YQUOYidaNabYbg68+OsK9NAUebv6ppSWOCtb5Vn8MLofewQdbqHeD3mAT5rA== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1, 1, smtp.mailfrom=arm.com] dmarc=[1, 1, header.from=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=s1DhtTz0eUDx8tL4lGL4WFffgxnqnXXoPaQfyyS1tGs=; b=oNJ8RmlalCxwuBhmSYqC/l2KoVRkGvpEMR+sRnmjgWy91TX/Fa1DvkpMqb4hnfDWOKqaWG036qzjaX8UXR7Ewc+QRWNKpXgCh+aeFYISWyjyYvzgmDzJnCNOLszSG+eS59WNX2uSX1wzG+TgLldyj7Q385dIgUsLPiTlM8Flruk= Received: from DU2PR04CA0290.eurprd04.prod.outlook.com (2603:10a6:10:28c::25) by PAXPR08MB6477.eurprd08.prod.outlook.com (2603:10a6:102:12d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.28; Fri, 8 Dec 2023 16:32:19 +0000 Received: from DB1PEPF0003922F.eurprd03.prod.outlook.com (2603:10a6:10:28c:cafe::f2) by DU2PR04CA0290.outlook.office365.com (2603:10a6:10:28c::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.28 via Frontend Transport; Fri, 8 Dec 2023 16:32:19 +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 DB1PEPF0003922F.mail.protection.outlook.com (10.167.8.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.20 via Frontend Transport; Fri, 8 Dec 2023 16:32:19 +0000 Received: ("Tessian outbound 8289ea11ec17:v228"); Fri, 08 Dec 2023 16:32:19 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 4b4a27001a140dbb X-CR-MTA-TID: 64aa7808 Received: from 19076b281716.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id A73AE4CF-F255-4AB9-9F7A-49C27C804724.1; Fri, 08 Dec 2023 16:32:12 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 19076b281716.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 08 Dec 2023 16:32:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GSi0B5cktpHe+NWYzqBaDVsjiOwIlYTkMrAcTMVeQ6oSq+6KqrNW49gIakH7hoUcorl6Y34gt5CQfiXICekU/b5luipTwaTYQRWuFo6c6ThigGB7VbEL27eTUTqoQ4gB8RW6raHCyG7K2H8NiB86Yi+DonVCB2Z27rSyWTYKOc9xnCSL7070rOw8YLfgvqeTv+t8qFwDP8kGaYXul3QDN15EwT6GLc+nr8SEp8KaTURP5I23TEWEkQ+PhVwHVyUmLaQjP1AXvtSyiMOnjNLCxrXlXpbsfCrYFNec3vAR+Z5HqN1T5cnFbx9nwzrx6TpNtGCpylwXZJlkHIh2OMONsw== 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=s1DhtTz0eUDx8tL4lGL4WFffgxnqnXXoPaQfyyS1tGs=; b=ESOP87nn6iBHzMEziBzPkvelB0mBAUdJsbbmb54Z/rMIZdWs963QCmt71P94hsL23Lq4k4p9dyatuDyKTTq6KiChjcBrpQvjyXwYdnFmPdy4EOztKZ4J7UyYofp7ApIPN6m3e2oiqR9CDLc24ANpJbN0jxSORtyI9cIEhsXDnP7t5CtFvpfchFFP5xvDC0lbKX6VFMAMWbxn599DAdyZEEpBnu/wC9DGtIdiBcOcPk9iutVY8DLkVqU0h1Ds1jtSlgu/p3PilTZ/bMvtatdh2h0doNWEwpbF2U0PpVhIpgqsmAoXEu3GN1OQCd5hwBTUVNHc+QAKvZ5FEzKU4bS12Q== 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 (0) 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=s1DhtTz0eUDx8tL4lGL4WFffgxnqnXXoPaQfyyS1tGs=; b=oNJ8RmlalCxwuBhmSYqC/l2KoVRkGvpEMR+sRnmjgWy91TX/Fa1DvkpMqb4hnfDWOKqaWG036qzjaX8UXR7Ewc+QRWNKpXgCh+aeFYISWyjyYvzgmDzJnCNOLszSG+eS59WNX2uSX1wzG+TgLldyj7Q385dIgUsLPiTlM8Flruk= Received: from AS9PR06CA0425.eurprd06.prod.outlook.com (2603:10a6:20b:49e::15) by DU2PR08MB7376.eurprd08.prod.outlook.com (2603:10a6:10:2f4::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.28; Fri, 8 Dec 2023 16:32:08 +0000 Received: from AMS0EPF000001B6.eurprd05.prod.outlook.com (2603:10a6:20b:49e:cafe::e8) by AS9PR06CA0425.outlook.office365.com (2603:10a6:20b:49e::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.28 via Frontend Transport; Fri, 8 Dec 2023 16:32:07 +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 AMS0EPF000001B6.mail.protection.outlook.com (10.167.16.170) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7068.20 via Frontend Transport; Fri, 8 Dec 2023 16:32:07 +0000 Received: from AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) 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.32; Fri, 8 Dec 2023 16:32:06 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Fri, 8 Dec 2023 16:32:06 +0000 Received: from armchair.cambridge.arm.com (10.2.80.71) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.32 via Frontend Transport; Fri, 8 Dec 2023 16:32:06 +0000 From: Szabolcs Nagy To: Subject: [PATCH 1/4] aarch64: Add SME runtime support Date: Fri, 8 Dec 2023 16:32:06 +0000 Message-ID: <10fee36792ba4cc90d0476e4dd23671e3bbf0bed.1702051831.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AMS0EPF000001B6:EE_|DU2PR08MB7376:EE_|DB1PEPF0003922F:EE_|PAXPR08MB6477:EE_ X-MS-Office365-Filtering-Correlation-Id: e49f70e7-4ffc-4d10-6eeb-08dbf80b3f43 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: esqnAmvEOmvZWKout+wDRPONOWrfGQUVz3PAjOb8MbXg4k9icv5tHNGQHf30qSOhc9oCRrGqonz880Pc18SaTJ9XGckd2/epArTX/qZC2Q8+Vmj9mByote1Tf+S6Y0A1kfVq+p6/5kWxNvqsP3HSAvVPkL9CboHgp7B44iIJVDu0WOsZvuuxDJw0K2xg/RmFkh7cGumWaUMztavfG9fKABPY7ehCCPtwntfyK3GsebzUo4iN+lPeqDA6NMWpJ8MXL+QANRmYWdBrt1LkFh1qjIFyHmjSF0SBGvhvDh8+mFaVPGhSBk3btrjoUNYapBZz5wnFsd+mcioM2qkVaBMHvAABT2SthB0y3plnxc5QteaTxX9Ec2CEuBXBKdbuWCov97b4/OjdN+G2bRijkI3ioAlWOiGL253n6J7fGuKeNU5jRuaZWOiYxr8Fmn1huVKVlSgj745Tey6SI5GDPhzjitaW4o+GFTlatQeilmcu0A7GiUJxRPRcxPfz2NuFwLSmfIYD7BJde8rGC5Ubr4U3BUCZjjnPXe3/OVHiMGL7Uye6TKCFct+Bhee5WT8Xib1SbkigXdrZ93NQEEZ8Acxu1YDZikxfTB9Ke0Z8HvJOlZmAdLn5A03Sj6r+sk2CXyFXKATT4rPteLUnkYojseyjTcpwIqAJJL6dtGj96JCkZcLBsrDIrl9Yuc/QcdZicn7yUhpLJRZ/FWpEMYCtbcfbueHNV/wAOUfwBEzdGE/hX31OkhxUInoRuPrPzeqdItPK 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:(13230031)(4636009)(39850400004)(346002)(136003)(376002)(396003)(230922051799003)(186009)(1800799012)(82310400011)(451199024)(64100799003)(36840700001)(46966006)(356005)(81166007)(82740400003)(47076005)(83380400001)(40480700001)(336012)(26005)(2616005)(426003)(36860700001)(36756003)(41300700001)(2906002)(7696005)(70586007)(44832011)(6916009)(70206006)(316002)(5660300002)(478600001)(86362001)(8936002)(8676002)(2004002)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR08MB7376 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB1PEPF0003922F.eurprd03.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 212846f8-e308-47d1-13ef-08dbf80b386f X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UFyUgXXXcSNdrKPn93S+IOorC0bu+zqBcquFQBWpwOyst1w8xh5JKb6Jnw//bnMQJu4wDtnHDgDxpZb9qCG2eQ99ZgFIeyMFq7n+eggnc5nYHNkJdKZsQMaFxrdjPGtzp2SUH7VrXEImvoWm2EuUzr0kPdXWBtImlz0kXRO4G7kUU3MebtgXupNJpi9LHyAbN5EutXVCQkZlaS7fqnoJLrwFfsrjR/GupQJ68t8wK4nxihIiiSjAChJMPG9w5aBxfQwERaOyv7oIgh8YjVeTjh9l+Fa1JJPTXttiBJDSyui5Zd5Olp8IKCPp5BzHHCrEoQiFiH5Aut3MI/GQPrfXk176e8qJEy8fKbTL1bZovA4junOzIpgOIwI7pQvuztbrnDi7/6swtoYvwfQHD9ShjuejDC68e44VcN4xLVjVnLRYM2JiKuoPp31nIoavsG+OCpdqyTKMNi/WBVKd5akoo0WXe8PL9pSLaLHyvAAdM05vXGhTJ93LoIW6HYETxRF6YezqOI1aPjggXichH0iWeRhYPKYnSoKo2pxrb4iM0jkpaAHu6A26SBGNbJbQgp6qNXg4iEY/V9LoCXPrTAfT6AjWI7cGwFC8VyJ1d2k3RrCroMh1HsyxJdM2vmaLYJPug5hwhIZCqfaH6Gtt+RAJ5uOrz73LBfwR1JYXMsMkmPc2e3ZPaxALhBrURgtxuViYu1oqW8FRqTWzd62IMOmEPHXGe9XhixdgWxoy/jiFcgyMDkNaHWc7TiGd32u/Ytza 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:(13230031)(4636009)(346002)(376002)(136003)(39860400002)(396003)(230922051799003)(64100799003)(451199024)(82310400011)(1800799012)(186009)(46966006)(40470700004)(36840700001)(70206006)(70586007)(47076005)(81166007)(36860700001)(6916009)(316002)(40460700003)(82740400003)(2906002)(83380400001)(86362001)(2616005)(36756003)(26005)(40480700001)(44832011)(8676002)(478600001)(8936002)(7696005)(41300700001)(336012)(426003)(5660300002)(2004002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2023 16:32:19.2769 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e49f70e7-4ffc-4d10-6eeb-08dbf80b3f43 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: DB1PEPF0003922F.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6477 X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY, URIBL_BLACK 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: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org The runtime support routines for the call ABI of the Scalable Matrix Extension (SME) are mostly in libgcc. Since libc.so cannot depend on libgcc_s.so have an implementation of __arm_za_disable in libc for libc internal use in longjmp and similar APIs. __libc_arm_za_disable follows the same PCS rules as __arm_za_disable, but it's a hidden symbol so it does not need variant PCS marking. Using __libc_fatal instead of abort because it can print a message and works in ld.so too. But for now we don't need SME routines in ld.so. To check the SME HWCAP in asm, we need the _dl_hwcap2 member offset in _rtld_global_ro in the shared libc.so, while in libc.a the _dl_hwcap2 object is accessed. Reviewed-by: Adhemerval Zanella --- sysdeps/aarch64/Makefile | 10 ++- sysdeps/aarch64/__arm_za_disable.S | 112 ++++++++++++++++++++++++ sysdeps/aarch64/rtld-global-offsets.sym | 10 +++ 3 files changed, 129 insertions(+), 3 deletions(-) create mode 100644 sysdeps/aarch64/__arm_za_disable.S create mode 100644 sysdeps/aarch64/rtld-global-offsets.sym diff --git a/sysdeps/aarch64/Makefile b/sysdeps/aarch64/Makefile index 6a9559e5f5..9d8844d9c8 100644 --- a/sysdeps/aarch64/Makefile +++ b/sysdeps/aarch64/Makefile @@ -48,7 +48,9 @@ endif endif ifeq ($(subdir),csu) -gen-as-const-headers += tlsdesc.sym +gen-as-const-headers += \ + tlsdesc.sym \ + rtld-global-offsets.sym endif ifeq ($(subdir),gmon) @@ -62,8 +64,10 @@ endif ifeq ($(subdir),misc) sysdep_headers += sys/ifunc.h -sysdep_routines += __mtag_tag_zero_region \ - __mtag_tag_region +sysdep_routines += \ + __mtag_tag_zero_region \ + __mtag_tag_region \ + __arm_za_disable endif ifeq ($(subdir),malloc) diff --git a/sysdeps/aarch64/__arm_za_disable.S b/sysdeps/aarch64/__arm_za_disable.S new file mode 100644 index 0000000000..f9e2d942f2 --- /dev/null +++ b/sysdeps/aarch64/__arm_za_disable.S @@ -0,0 +1,112 @@ +/* Libc internal support routine for SME. + Copyright (C) 2023 Free Software Foundation, Inc. + + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + . */ + +#include +#include + +#define HWCAP2_SME_BIT 23 + +/* Disable ZA. Call ABI: + - Private ZA, streaming-compatible. + - x0-x13, x19-x29, sp and fp regs are call preserved. + - On return tpidr2_el0 = 0, ZA = 0. + - Takes no argument. + - Does not return a value. + - Can abort on failure (then registers are not preserved). */ + +ENTRY (__libc_arm_za_disable) + + /* Check if SME is available. */ +#ifdef SHARED + /* In libc.so. */ + adrp x14, :got:_rtld_global_ro + ldr x14, [x14, :got_lo12:_rtld_global_ro] + ldr x14, [x14, GLRO_DL_HWCAP2_OFFSET] +#else + /* In libc.a, may be PIC. */ + adrp x14, _dl_hwcap2 + ldr x14, [x14, :lo12:_dl_hwcap2] +#endif + tbz x14, HWCAP2_SME_BIT, L(end) + + .inst 0xd53bd0ae /* mrs x14, tpidr2_el0 */ + cbz x14, L(end) + + /* check reserved bytes. */ + ldrh w15, [x14, 10] + ldr w16, [x14, 12] + orr w15, w15, w16 + cbnz w15, L(fail) + + ldr x16, [x14] + cbz x16, L(end) + ldrh w17, [x14, 8] + cbz w17, L(end) + + /* x14: tpidr2, x15: 0, + x16: za_save_buffer, x17: num_za_save_slices. */ + +L(save_loop): + .inst 0xe1206200 /* str za[w15, 0], [x16] */ + .inst 0xe1206201 /* str za[w15, 1], [x16, 1, mul vl] */ + .inst 0xe1206202 /* str za[w15, 2], [x16, 2, mul vl] */ + .inst 0xe1206203 /* str za[w15, 3], [x16, 3, mul vl] */ + .inst 0xe1206204 /* str za[w15, 4], [x16, 4, mul vl] */ + .inst 0xe1206205 /* str za[w15, 5], [x16, 5, mul vl] */ + .inst 0xe1206206 /* str za[w15, 6], [x16, 6, mul vl] */ + .inst 0xe1206207 /* str za[w15, 7], [x16, 7, mul vl] */ + .inst 0xe1206208 /* str za[w15, 8], [x16, 8, mul vl] */ + .inst 0xe1206209 /* str za[w15, 9], [x16, 9, mul vl] */ + .inst 0xe120620a /* str za[w15, 10], [x16, 10, mul vl] */ + .inst 0xe120620b /* str za[w15, 11], [x16, 11, mul vl] */ + .inst 0xe120620c /* str za[w15, 12], [x16, 12, mul vl] */ + .inst 0xe120620d /* str za[w15, 13], [x16, 13, mul vl] */ + .inst 0xe120620e /* str za[w15, 14], [x16, 14, mul vl] */ + .inst 0xe120620f /* str za[w15, 15], [x16, 15, mul vl] */ + add w15, w15, 16 + .inst 0x04305a10 /* addsvl x16, x16, 16 */ + cmp w17, w15 + bhi L(save_loop) + .inst 0xd51bd0bf /* msr tpidr2_el0, xzr */ + .inst 0xd503447f /* smstop za */ +L(end): + ret +L(fail): +#if HAVE_AARCH64_PAC_RET + PACIASP + cfi_window_save +#endif + stp x29, x30, [sp, -32]! + cfi_adjust_cfa_offset (32) + cfi_rel_offset (x29, 0) + cfi_rel_offset (x30, 8) + mov x29, sp + .inst 0x04e0e3f0 /* cntd x16 */ + str x16, [sp, 16] + cfi_rel_offset (46, 16) + .inst 0xd503467f /* smstop */ + adrp x0, L(msg) + add x0, x0, :lo12:L(msg) + bl HIDDEN_JUMPTARGET (__libc_fatal) +END (__libc_arm_za_disable) + + .section .rodata + .align 3 +L(msg): + .string "FATAL: __libc_arm_za_disable failed.\n" diff --git a/sysdeps/aarch64/rtld-global-offsets.sym b/sysdeps/aarch64/rtld-global-offsets.sym new file mode 100644 index 0000000000..23cdaf7d9e --- /dev/null +++ b/sysdeps/aarch64/rtld-global-offsets.sym @@ -0,0 +1,10 @@ +#define SHARED 1 + +#include + +#define GLRO_offsetof(name) offsetof (struct rtld_global_ro, _##name) + +-- Offsets of _rtld_global_ro in libc.so + +GLRO_DL_HWCAP_OFFSET GLRO_offsetof (dl_hwcap) +GLRO_DL_HWCAP2_OFFSET GLRO_offsetof (dl_hwcap2)