From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00066.outbound.protection.outlook.com [40.107.0.66]) by sourceware.org (Postfix) with ESMTPS id C0B65385DC14 for ; Mon, 21 Dec 2020 12:45:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C0B65385DC14 Received: from AM0PR10CA0086.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:15::39) by VI1PR08MB5421.eurprd08.prod.outlook.com (2603:10a6:803:132::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3676.25; Mon, 21 Dec 2020 12:45:13 +0000 Received: from AM5EUR03FT061.eop-EUR03.prod.protection.outlook.com (2603:10a6:208:15:cafe::86) by AM0PR10CA0086.outlook.office365.com (2603:10a6:208:15::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3676.29 via Frontend Transport; Mon, 21 Dec 2020 12:45:13 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; sourceware.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;sourceware.org; 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; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT061.mail.protection.outlook.com (10.152.16.247) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3676.22 via Frontend Transport; Mon, 21 Dec 2020 12:45:13 +0000 Received: ("Tessian outbound fc5cc0046d61:v71"); Mon, 21 Dec 2020 12:45:12 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 63295efcfb4a414e X-CR-MTA-TID: 64aa7808 Received: from 2ba3f51c1f0d.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id F6CC5075-0D73-45F8-BD56-8739680980EE.1; Mon, 21 Dec 2020 12:44:56 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 2ba3f51c1f0d.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 21 Dec 2020 12:44:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ta795tenchxPPPdivQ/nvEZOJtAe53f8YfN9No07X5NiUL2xv8ovgSUjYVZdjNvVeCrRI/GvpjfD+f9S025B6JgTw+NVsr6/ADZ5W5yaViTmTGnPunGOI2Equ9nemeiUR+BjYQ4Uc6Zc3AZ9DVLB4ewBhzFb8FceAMviW2XpnJx022zTaX5PF88zH6i3lAMES2Xw31IhyhuFF2hCOILLAYPa2//ew2rlR+il/3jfqNwFrij2Z/2/PqDvdDyuuNFlP4pHswlAvKfo9QFbNH7fz5Xs3k0S3/HDwNDiiVB3/HHUsPOu9fl6R0Jd7AaHY9yfrucVgmnCeFHVFJSc2yo3lA== 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-SenderADCheck; bh=3mPjNLkLV54zRejHOBvdwLXM5m7oWybdVYfyIKt2fc4=; b=ZZjpq1PKb827JCFLiMJbuRDh659nun0JlmykJUQw7mNCaS2AjbxcwJ1tx3t7BoHK2M3hHmS2lIfqZ1+DoRRYZGHA+YKH6icmNgK2k3nlw3w0aLQgCkdygkiH3eMuxy+G5RX+SKtyz7i5JQIvMbhOfdNQQQUAvLmMDyYYlKUxqRFEnZuLOH0g7HQAE7IjiYeYgP1EwOyV755lsFPEfVy0B+gH6lD9xyLmwbJ42FcYsdYfUJQymjU2jiDto1OXFUC6ErQCiAn0bitH9K4+i6wOa0VE5kdUWa61OJ8Y8nAM1htXCCt0Ip6tO18TbAqODqfW7QUgNhMONmFbt0yM9/32kw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none Authentication-Results-Original: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=arm.com; Received: from PA4PR08MB6320.eurprd08.prod.outlook.com (2603:10a6:102:e5::9) by PA4PR08MB6288.eurprd08.prod.outlook.com (2603:10a6:102:f3::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3676.31; Mon, 21 Dec 2020 12:44:54 +0000 Received: from PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::9d96:26c8:4904:40a3]) by PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::9d96:26c8:4904:40a3%3]) with mapi id 15.20.3676.033; Mon, 21 Dec 2020 12:44:54 +0000 Date: Mon, 21 Dec 2020 12:44:52 +0000 From: Szabolcs Nagy To: Richard Earnshaw Cc: libc-alpha@sourceware.org, dj@redhat.com Subject: Re: [PATCH v4 6/6] aarch64: Add aarch64-specific files for memory tagging support Message-ID: <20201221124452.GB720@arm.com> References: <20201218192957.11035-1-rearnsha@arm.com> <20201218192957.11035-7-rearnsha@arm.com> Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20201218192957.11035-7-rearnsha@arm.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-Originating-IP: [217.140.106.54] X-ClientProxiedBy: LO2P265CA0002.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:62::14) To PA4PR08MB6320.eurprd08.prod.outlook.com (2603:10a6:102:e5::9) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from arm.com (217.140.106.54) by LO2P265CA0002.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:62::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3676.28 via Frontend Transport; Mon, 21 Dec 2020 12:44:54 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: be6a2d0b-868f-47e0-cd88-08d8a5ae4284 X-MS-TrafficTypeDiagnostic: PA4PR08MB6288:|VI1PR08MB5421: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8882;OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: ILK//oabXIYU4vdwP3b+EdSrPQEaDDcOUb45Gr7SOro/uw/aKTfA3yZInvcgRRuuuaF9ZdMp3y8a4r4E8mv6GLICscWNgMDU0ZE9yDKdKGq+Z4VrPf7aBVIZjIr7IsHQspin69Q2spnw4Maqm0KTMcDGGPFeXg7/QrSGW6dFvnlzUlJdRdtOw8+enC+M/YtsL1FOMB7/kLOXzMlO+51lQU7Bvusy+zcQoMyxmMT7nV2Y1RnYzJQFzT17fEBQUK65vpM7aagaJB8gLcmXKO+fQB6a11pq0DUHzD9utcFlZgreXPQgmBnCtWeGltItn60sk/oFi1zGrORhu1AflN8/RB94bVRNnvwX/9PJd5TO0VY/ONSxbiFkpWdq1I8I9DwudTrKYIsi9ME1FAgn+pDxPlduBLzqIZ1ziULDNDnheYHyQyofiINVKLGA+8MOZCAQLaXaAL4OTzLjaJcA5nx/VQftXU6Ct4g7H+SA00yFWIfw1Goh21ld5kCRdBE6B7gZTLjJFzZ0m7d2tKVQ18I34w== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PA4PR08MB6320.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(396003)(39860400002)(136003)(376002)(346002)(316002)(66946007)(33656002)(26005)(2616005)(44832011)(36756003)(55016002)(1076003)(8936002)(8676002)(86362001)(2906002)(8886007)(66556008)(5660300002)(66476007)(16526019)(52116002)(6636002)(6862004)(30864003)(4326008)(186003)(37006003)(956004)(7696005)(478600001)(2004002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?cGJNN3hsekduV2xmTVVmRWhvVVk3RXF3QkdudG8vVUJycVQ0WVB0RTBCQ09S?= =?utf-8?B?Rll4ZG9TblZFd2ZjWTVjQUZiaWFQWEN2UHNoaTVWcnhkRGpKMDVYZEdJQ05z?= =?utf-8?B?R1FMMmMzMkV6eEpNSENHQWtZQU1VYk81NFM3VVBVcjRjTEtsd1N2NVVaYlZr?= =?utf-8?B?Q0ltL3U3bHNQU0ptSVc0ZitUN1F2dWZSSkJlUnJSdW9IWDExNmUvaWwzMDdV?= =?utf-8?B?eEVMa0pibVZuTHhLazIydFJIbXV2VkJscllEZjdxeURLeWtNWUd1ZVU5eklJ?= =?utf-8?B?RWdlb1JCbWIvZlROYU1UVXNGWmNoSHpUakFZbTc0UTY2MkgvTEJCbEk4SVcv?= =?utf-8?B?YUp6cGYycVZOMnc2RFVtQ2FVYzZyZVUySncwWGxsZ2Q0cHpRdUZnSEx2MDJ6?= =?utf-8?B?akxlNDdsSlVZdDh5L1ZHVkNZZWt0bHBWV2QvUlo4WXJINW96dm5vclFobS9s?= =?utf-8?B?bUdiT3k1cWNJU1ZnRzZrRHErRDRqa256bXBMQnNzSTFjRnZoMVdtbDR5alY5?= =?utf-8?B?NlhaZjVSWUJVTkpVd0l0NWg3ZEdMTkhiM2ZwN2ZKSHJibkhndURpUlpxcnB4?= =?utf-8?B?MWx3enV1Nk1kWXVoOXQ0M0wrRzBYVCs5M0V3c3FwczZDczdGaGdvYlNORUQ0?= =?utf-8?B?OUhHNFZTVTkwVFlpYkZydkE0VVRlTWs3bUVlcE15YU1vZnlsOFdpNThEUEhE?= =?utf-8?B?Y3h0cDZkWTFXNmZ4SG1vaTBCN1AveVZ6aW9UcUYvUDM4bTFrUVAzRkdSUEor?= =?utf-8?B?Tm1vUFh0cHBKMmREL3JBT2drVCtzci9HbEg1WkpzQzFKUktIUVBjNTZlaTFp?= =?utf-8?B?N2RIMW5tajA1U1VNTGlrTG1ncS9FaHphaGl0eGVpc1Q4RTQ2NytxV1FpMFpT?= =?utf-8?B?akdXTWh4UC8xU0svckhUVlhLcXUrL2hLZDhBVjRGbCtDWWJPWTB4d09Rb3VJ?= =?utf-8?B?QS91UEtXK3BNVW5Pc09HYmowQXhxb3pZaDRTTmFqQVlsNkEyMXMvUWJRQlh3?= =?utf-8?B?cjQ0T05DWkJZTDNXRGhlempWTnF1WnQvK1pEcWtkT2FVR05YSnVBQ1kvc0tO?= =?utf-8?B?ajY3bnc1MFVIOG12M0lWRnJxcE9TSld6cUZVWVpZZ210YkhTR0RzZWNBdHJ0?= =?utf-8?B?UVZXQW8zNFlRbGc1a2JydlBINTUxZGgybVF1bjZwdlIrMm0vTi9ocmdYaWQ2?= =?utf-8?B?U2dJdG9Nb1ViYWpnNVpRaGgxK1kwRUphbHg1bGJaSUswK2JSVCtFVXRqc210?= =?utf-8?B?RmtibW0xa1N0Z01pamFEdHNGUWVzL1Z3NEZYUUF6cUtUVGphUXFQekNraWdL?= =?utf-8?Q?ZC/0Knr2HoC1mcmUmuhO1OrsRXn/Qtclwx?= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6288 Original-Authentication-Results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT061.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 0b8958bb-943e-45f3-64d4-08d8a5ae376e X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xLJNdtKzcG38XRp+8nSY89Tz41m3shTIWNSKa9UXiMf74lO15+JgAgaBrFr84SB3tkL77BAhYVMfI261c1/ZOZGNM1RK0WvklFQG4ptZSZ70nbgTJC9nbGSKt0y69gVos5j5+LZD/AJloB70C43HIQTBDeUddhljJhJJoXz2WeInX44qwJky2ePBgUHvRiofqPIS+J+pge0t2SL2e6mAmWrQhKUX+L3pESlmRVUdTQopzszyWSav8WvBaQvIw7ndLGz4nA34KxnUXElFXnThRkIwHdkD1rzHF/6obgDkYSPwfcr09vMzFeSAH9dWNhjDcArqxBCaaGcObY2TfqPfwij50gkE41XvU4FazfpkbEIf16sx0o2dMUyJsFUWO/LcQnfmQieumpAINEs6PFenlbL56eSwYXA7oYI7gcXmA84FED6r5ktCDkT/yLNCjBknAxga+MIy6rsS3zlLEWg/1jNcc8jc1ux3KJg6faRvyuYtdoQamM1auCAGd+Ql7lD+zJcl1JUZykE2LJ/YR6xoVra4VZqL8TlBodIg+tJzyPO1m/FPnLsQr9nR3zuK1X6V 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:(4636009)(39860400002)(396003)(346002)(136003)(376002)(46966005)(1076003)(26005)(70206006)(47076004)(478600001)(4326008)(36756003)(30864003)(8886007)(81166007)(316002)(8936002)(82740400003)(356005)(956004)(70586007)(44832011)(6862004)(82310400003)(55016002)(107886003)(33656002)(2616005)(7696005)(6636002)(37006003)(8676002)(2906002)(186003)(86362001)(16526019)(5660300002)(336012)(2004002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2020 12:45:13.0987 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: be6a2d0b-868f-47e0-cd88-08d8a5ae4284 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: AM5EUR03FT061.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB5421 X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_SHORT, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Dec 2020 12:45:20 -0000 The 12/18/2020 19:29, Richard Earnshaw wrote: > This final patch provides the architecture-specific implementation of > the memory-tagging support hooks for aarch64. i see some gnu style issues in libc-mtag.h otherwise it looks ok. Reviewed-by: Szabolcs Nagy > --- > sysdeps/aarch64/Makefile | 5 +++ > sysdeps/aarch64/__mtag_address_get_tag.S | 32 +++++++++++++ > sysdeps/aarch64/__mtag_memset_tag.S | 53 ++++++++++++++++++++++ > sysdeps/aarch64/__mtag_new_tag.S | 37 +++++++++++++++ > sysdeps/aarch64/__mtag_tag_region.S | 51 +++++++++++++++++++++ > sysdeps/aarch64/libc-mtag.h | 57 ++++++++++++++++++++++++ > 6 files changed, 235 insertions(+) > create mode 100644 sysdeps/aarch64/__mtag_address_get_tag.S > create mode 100644 sysdeps/aarch64/__mtag_memset_tag.S > create mode 100644 sysdeps/aarch64/__mtag_new_tag.S > create mode 100644 sysdeps/aarch64/__mtag_tag_region.S > create mode 100644 sysdeps/aarch64/libc-mtag.h > > diff --git a/sysdeps/aarch64/Makefile b/sysdeps/aarch64/Makefile > index d8e06d27b2..d3ab37a40a 100644 > --- a/sysdeps/aarch64/Makefile > +++ b/sysdeps/aarch64/Makefile > @@ -40,4 +40,9 @@ endif > > ifeq ($(subdir),misc) > sysdep_headers += sys/ifunc.h > +sysdep_routines += __mtag_address_get_tag \ > + __mtag_memset_tag \ > + __mtag_new_tag \ > + __mtag_tag_region > + > endif > diff --git a/sysdeps/aarch64/__mtag_address_get_tag.S b/sysdeps/aarch64/__mtag_address_get_tag.S > new file mode 100644 > index 0000000000..4ffe884c95 > --- /dev/null > +++ b/sysdeps/aarch64/__mtag_address_get_tag.S > @@ -0,0 +1,32 @@ > +/* Copyright (C) 2020 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 > + > +#ifdef USE_MTAG > +#define ptr x0 > + > + .arch armv8.5-a > + .arch_extension memtag > + > +ENTRY (__libc_mtag_address_get_tag) > + > + ldg ptr, [ptr] > + ret > +END (__libc_mtag_address_get_tag) > +#endif /* USE_MTAG */ > diff --git a/sysdeps/aarch64/__mtag_memset_tag.S b/sysdeps/aarch64/__mtag_memset_tag.S > new file mode 100644 > index 0000000000..6f78d91b79 > --- /dev/null > +++ b/sysdeps/aarch64/__mtag_memset_tag.S > @@ -0,0 +1,53 @@ > +/* Copyright (C) 2020 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 > + > +#ifdef USE_MTAG > + > +/* Use the same register names and assignments as memset. */ > +#include "memset-reg.h" > + > + .arch armv8.5-a > + .arch_extension memtag > + > +/* NB, only supported on variants with 64-bit pointers. */ > + > +/* FIXME: This is a minimal implementation. We could do much better than > + this for large values of COUNT. */ > + > +ENTRY(__libc_mtag_memset_with_tag) > + > + and valw, valw, 255 > + orr valw, valw, valw, lsl 8 > + orr valw, valw, valw, lsl 16 > + orr val, val, val, lsl 32 > + mov dst, dstin > + > +L(loop): > + stgp val, val, [dst], #16 > + subs count, count, 16 > + bne L(loop) > +#if 0 > + /* This is not currently needed, since for now we are only called > + to tag memory that is taggable. */ > + ldg dstin, [dstin] // Recover the tag created (might be untagged). > +#endif > + ret > +END (__libc_mtag_memset_with_tag) > +#endif /* USE_MTAG */ > diff --git a/sysdeps/aarch64/__mtag_new_tag.S b/sysdeps/aarch64/__mtag_new_tag.S > new file mode 100644 > index 0000000000..663e3a484f > --- /dev/null > +++ b/sysdeps/aarch64/__mtag_new_tag.S > @@ -0,0 +1,37 @@ > +/* Copyright (C) 2020 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 > + > +#ifdef USE_MTAG > + > + .arch armv8.5-a > + .arch_extension memtag > + > +/* NB, only supported on variants with 64-bit pointers. */ > + > +#define ptr x0 > +#define xset x1 > + > +ENTRY(__libc_mtag_new_tag) > + // Guarantee that the new tag is not the same as now. > + gmi xset, ptr, xzr > + irg ptr, ptr, xset > + ret > +END (__libc_mtag_new_tag) > +#endif /* USE_MTAG */ > diff --git a/sysdeps/aarch64/__mtag_tag_region.S b/sysdeps/aarch64/__mtag_tag_region.S > new file mode 100644 > index 0000000000..7af4f0fa0a > --- /dev/null > +++ b/sysdeps/aarch64/__mtag_tag_region.S > @@ -0,0 +1,51 @@ > +/* Copyright (C) 2020 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 > + > +#ifdef USE_MTAG > + > +/* Use the same register names and assignments as memset. */ > + > + .arch armv8.5-a > + .arch_extension memtag > + > +/* NB, only supported on variants with 64-bit pointers. */ > + > +/* FIXME: This is a minimal implementation. We could do better than > + this for larger values of COUNT. */ > + > +#define dstin x0 > +#define count x1 > +#define dst x2 > + > +ENTRY_ALIGN(__libc_mtag_tag_region, 6) > + > + mov dst, dstin > +L(loop): > + stg dst, [dst], #16 > + subs count, count, 16 > + bne L(loop) > +#if 0 > + /* This is not currently needed, since for now we are only called > + to tag memory that is taggable. */ > + ldg dstin, [dstin] // Recover the tag created (might be untagged). > +#endif > + ret > +END (__libc_mtag_tag_region) > +#endif /* USE_MTAG */ > diff --git a/sysdeps/aarch64/libc-mtag.h b/sysdeps/aarch64/libc-mtag.h > new file mode 100644 > index 0000000000..0e9b63e95b > --- /dev/null > +++ b/sysdeps/aarch64/libc-mtag.h > @@ -0,0 +1,57 @@ > +/* libc-internal interface for tagged (colored) memory support. > + Copyright (C) 2020 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 > + . */ > + > +#ifndef _AARCH64_LIBC_MTAG_H > +#define _AARCH64_LIBC_MTAG_H 1 > + > +#ifndef USE_MTAG > +/* Generic bindings for systems that do not support memory tagging. */ > +#include_next "libc-mtag.h" > +#else > + > +/* Used to ensure additional alignment when objects need to have distinct > + tags. */ > +#define __MTAG_GRANULE_SIZE 16 > + > +/* Non-zero if memory obtained via morecore (sbrk) is not tagged. */ > +#define __MTAG_SBRK_UNTAGGED 1 > + > +/* Extra flags to pass to mmap to get tagged pages. */ > +#define __MTAG_MMAP_FLAGS PROT_MTE > + > +/* Set the tags for a region of memory, which must have size and alignment > + that are multiples of __MTAG_GRANULE_SIZE. Size cannot be zero. > + void *__libc_mtag_tag_region (const void *, size_t) */ > +void *__libc_mtag_tag_region (void *, size_t); > + > +/* Optimized equivalent to __libc_mtag_tag_region followed by memset. */ > +void *__libc_mtag_memset_with_tag(void *, int, size_t); > + > +/* Convert address P to a pointer that is tagged correctly for that > + location. > + void *__libc_mtag_address_get_tag (void*) */ > +void *__libc_mtag_address_get_tag(void *); > + > +/* Assign a new (random) tag to a pointer P (does not adjust the tag on > + the memory addressed). > + void *__libc_mtag_new_tag (void*) */ > +void *__libc_mtag_new_tag(void *); missing spaces before ( > + > +#endif /* USE_MTAG */ > + > +#endif /* _AARCH64_LIBC_MTAG_H */