From patchwork Thu Mar 4 16:31:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 1447438 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=xNoSeBnp; dkim-atps=neutral Received: from sourceware.org (unknown [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DrxGm0l1pz9sWX for ; Fri, 5 Mar 2021 03:32:16 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 21A9B388CC0F; Thu, 4 Mar 2021 16:32:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 21A9B388CC0F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1614875534; bh=miH5eAg0gS5bk/R9zVq5oOh5646P5rV4pKWOiLMNFsg=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=xNoSeBnpQanYEPilPiyAJ2ff9W2fW3iYCTgq8CJEj33oxJtUEQckHxXVzjP+NS+f4 hdEbR07BSDA7dbT/LAZ4oMEi03g+A26R80Fs09ygleDCeqRnsjwroNIbYFaW5QMozU 8uMtXGvT7CnOVrDkMPguPnZ4iPr9hND86/1Mb4UM= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20083.outbound.protection.outlook.com [40.107.2.83]) by sourceware.org (Postfix) with ESMTPS id C0AC7388CC0F for ; Thu, 4 Mar 2021 16:32:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C0AC7388CC0F Received: from AM6P192CA0081.EURP192.PROD.OUTLOOK.COM (2603:10a6:209:8d::22) by VI1PR0801MB1920.eurprd08.prod.outlook.com (2603:10a6:800:8f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.28; Thu, 4 Mar 2021 16:32:08 +0000 Received: from AM5EUR03FT025.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:8d:cafe::4f) by AM6P192CA0081.outlook.office365.com (2603:10a6:209:8d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.17 via Frontend Transport; Thu, 4 Mar 2021 16:32:08 +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 AM5EUR03FT025.mail.protection.outlook.com (10.152.16.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.17 via Frontend Transport; Thu, 4 Mar 2021 16:32:06 +0000 Received: ("Tessian outbound dd71fb35fd76:v71"); Thu, 04 Mar 2021 16:32:06 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: cd03fd257c40f666 X-CR-MTA-TID: 64aa7808 Received: from 6d992058a4d4.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id A6FAAF38-FA2B-41FA-B1EF-7300B1BF44F1.1; Thu, 04 Mar 2021 16:32:00 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 6d992058a4d4.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 04 Mar 2021 16:32:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KN9DnTxySZCsKzyZwR4ibP9Ph3Cmc2D0RtPIu2I5VBVfpsGqWtYOEQl0uhYAqUB7/mznRKxPEwz+MYEC0Fje+gX0dsrlTm5U/Kchweih1ff8E7JBvhc3tUhqhfjP+zsu9w9MUCfXOHfuZPnYxYhHd2lP4/YYFKJPEyLcF8Pvq1Ke9GhVIK3xZTmGKX4EIJjFsLH+wd1mXoWfqIx+hhaBbXX35D8KTl12H/HX6Sj/kIhlMT3eY6JUR4f+NhnFK/QQ6FEvM0i1ZtZZsIf4f53RPQ1mjBybzYNjS9Y+MhD/R4qaA38jPDJOtZitEiTgwfB1LtXVPHGtqPmg7Q2fhWpXiQ== 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=miH5eAg0gS5bk/R9zVq5oOh5646P5rV4pKWOiLMNFsg=; b=hUlSFWhhmZ41LhKsUBGYvHsEO4atNQCWYnP1WaHM2RP8NG5bDUNK7y6Y+gl3PK8uL2aI5E0XRj9SCKzBL5NpRvQvNwrNpejzbmp/4xfAG4prZEV9LBlspuQDBgKNBEItdRs8xvUpl1VTwQTFz7seDRPyfSVO9wYpxREhvF5AIiL2kNinCsAZc+kzKLWqJCFyovINk+/yOfW4omOHr/UphQltju3k4s4gbijl5sk710NlQ2N/AXBpTzHhS/8wFDFRvbwR06oJCGc5mEw7I2KqqWhnggEM2S7jQt09jZPzRsKTnImf9iLWe39vJdqmvJRN9UQL4Gbo5WVwtLzbs5mdpg== 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: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=arm.com; Received: from PA4PR08MB6320.eurprd08.prod.outlook.com (2603:10a6:102:e5::9) by PA4PR08MB6205.eurprd08.prod.outlook.com (2603:10a6:102:e6::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.17; Thu, 4 Mar 2021 16:31:59 +0000 Received: from PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::60f0:3773:69b8:e336]) by PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::60f0:3773:69b8:e336%2]) with mapi id 15.20.3912.021; Thu, 4 Mar 2021 16:31:59 +0000 To: libc-alpha@sourceware.org, Richard.Earnshaw@arm.com, DJ Delorie Subject: [PATCH 06/16] malloc: Ensure the generic mtag hooks are not used Date: Thu, 4 Mar 2021 16:31:53 +0000 Message-Id: <0c6c9c0a9ba50b7caf05366c2a42ecd79b75c455.1614874816.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.55] X-ClientProxiedBy: LO2P123CA0067.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1::31) To PA4PR08MB6320.eurprd08.prod.outlook.com (2603:10a6:102:e5::9) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (217.140.106.55) by LO2P123CA0067.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.17 via Frontend Transport; Thu, 4 Mar 2021 16:31:59 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 26bc0625-bd43-4699-01fc-08d8df2b0d1f X-MS-TrafficTypeDiagnostic: PA4PR08MB6205:|VI1PR0801MB1920: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:10000;OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: qiPkBokCIIy5+eLH0okOxK6K4K/NNA23qPU3TA16AkmwRnWMWuyL3Il8FNu2Oduyp8mu0HBhm0EGkf6sMsw9+uv9XGovz3IZgcHTzwIN8bEsa1/PsQm7kJeBff8FGyWE8SH2zEdAders86Guo9WjD7wvvH+0IvBgR37H1pdsQtr3batQg/GaIhBh928aiTq1qlCBvvtM6O05NhIHgprg42Efkm+x+yz3BsSkKBP/esBnXr/owf75HWIZIbO9GqOhN5gRHVUkV/OvLC3FK3NZFLMFwCewwNOOwUHoYZ4qx02ThTwz7xA5M944JrmZAG8g6kVj39b4RiOLoFYBYGoYYIwtsKR3F5mTrVUVJSyhtblBaWm11iiztEE62h3zGCXuUmJmThE6RL3c6kTpIXYOiA5uxgm7ndZtXb3sJTmbcphRM8p/T0MF96EWIzfMelelob7n0GY9HQyzAmVeIsSODGaeBRiR1uRRFB7Y070P3uFS09zkHUb0lS3006Ag8vrY1bup6lpKel8CagUZd1EELJ5Lo1nLg6yIPb35xhXDoNkA4QxWUjnVB3G5t4POffgW/BUK6ZxerUbbUIQETrPcsKWYsVIIep4zUy4CXbNUA9I= 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)(136003)(376002)(346002)(396003)(366004)(39850400004)(6916009)(86362001)(956004)(52116002)(2616005)(44832011)(6512007)(316002)(69590400012)(26005)(66556008)(66476007)(186003)(66946007)(6506007)(16526019)(478600001)(6486002)(2906002)(6666004)(8936002)(36756003)(83380400001)(5660300002)(8676002)(41533002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: A/zvrJStu+1r+4Tyky8SHQVX1pcBJNcdN62thVjc0bjuGkwpdKXFk/qCyyAXNA6h4HxeVy1MCtt0WPX+vFNidtX2BEQ0jvI2eekkOUzLHq2eezuwZvmunMyC4zAdFDCsuDkbalXLvF6KdpkOXXyNIhmHXCExMuS7ykCUk+CSJs9inMwyjhx7Af6Ow/dhqzDHb4ADhJ1DEcQ2CpdhYlp9UzgHLUZx2tgm3t6z5ctsY9y1/M3XouUpdeGR6prgrWAdgFzrB9DMk6KvAVWjWoIdMNL2PyDNBopErpBwIPMWhJV4uMRkWX2hWdd6YKAGJ+Vpjg5QtyBmeROKCIYRQX4sL/ewW38AP+P92qVXHRL38FU+u9WNmm1cXi6h3ZGAZ3qaqRPhaXyjVjubSRlmXvhI/zqCK+ezYo9oJ/mo852kdcJH5/UkHVzAujhkjBfkrOQTSrEU9o6OyCuMtgo6eGnQTUFdKwZj4FAa6azVMMHA35d4ynVYyK5mGJVsT8yBX8xGAElbURfE047Dqjzo5NGH3lc4vAoQ9pYXaIN7bbVBi+GPoyzat6yDM/6Wl2dguATavnMu7COmZcgAsbNv8ZbiLFiQTKoQNnoJlOE07TZpJTAJurkfo85Z5wPZ6DF8AoM1m/u/QXD6XqNz0kDZjCG4rVPliCGSEcPVb9o//h9qXOes92fdfv0Vq1Cllo5ojRPKYw9kVMZdczKkgGvTPsMRPwKvlG8s/DO36n8wILF1wSrQCTUc7+TiTx1BrMHRbgZwAIKRBAVepjm210SvEbHZ9rgPo9/dX3ziZuu/cqLtFyittysEAguywY5j7Oc4or3kbG9TfA9zebRK/SAHnlMoXaCoegvricnF+IidsSt7LQDV9nylCeKMkUl6kp/odMMRNvsUEe17avvP1HYprIoZ2Pt2qx4DFyrFCqYwPfKTrB++Q44EcjVnnVjFIarnLtdUQTtvhCjpq9sL+AJwXDiYAy/3AGVDnB5pwW223bw1YJXnUPYs98U3lA6PRN4fq6bcRU0ewRoIaqZoRenJnD/kFdJpjNXFMJuvDe5/E1BTEJMwZRXoAFzRHtApMwLyRimnIr1N173bOmCpPjU7ukhYiM7Kp4VGBNLxkt3CSMnq+3ogz2Mo1Jpew/On6DaFGmqIpZff9bxIEbJ3EBGDZAlTCR80NkqLv6Ygx1SPqYiy7to2I9MXM9rj2pnsztgg0PbwvfDJ/IY0BsQ9tjE4jvHk6uMf9RmHo66UCHc0cZV9MxLzJJDub4lMgDya0orqswaNk4B456N14e73kGGHU3IdE8DZREFjV/1MS8iIUS47EjhbhLNazvPyBXTQOZOdDseN X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6205 Original-Authentication-Results: sourceware.org; dkim=none (message not signed) header.d=none; sourceware.org; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT025.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 47df1771-3d01-4043-4755-08d8df2b087d X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YykPB5Q/Az89P8Kk3qzqvnLppg7bLjGiG+mmrsEkPD3PB4oI2H/Tx9Be++x/VYHEEL2cXuLCe09OGZ8LSR1BfcrJmnyN/DANG77HjQJG3V5jxNyn3i+6wj8IvHm9lXMcfMaseiJLxz2UuFoGOJr/GAFjm/OjLnuBTl+oZrXJdhN1qwvYKIxDKsMtT4IYNyhQCGRhFkX9gNsDG37hLfpVOn9wH9CBEAjheKhsxvlRm+xv45XK1Gcs/oU8P3mHO1Lin51Mph1dRUqNGrPrOnmYezhIyQldhXsBI7LeoKZOJ7NFvAN4O6aeHZ1Afvbem69MbKqj3L7HwPUQynNHDDCb8Mb3p05X+Z6DooUriwypC50fWS/yq48ekN/fsTKhhRSjZ9rYbd6zQsaqHflDvHRVT7z1A2mI2UzIuU8sbDYehWsgWAuIbiAJ3bHyRZQKXADvXATgyR2Y7F5luxFR6AFnOhrYUAfABuoAvML/pebMsipbH9O6nexrez6dddhtSvRGknunpUzQdQktt/9TDeNA6nCjspXNqldHPEV0raBDS7hHKtRETSzVJqGeVuugGj6vGo9N8P9aNbA6UwA7OBz3sibn7RgPVoDhDrgWyyGGw86VBlooba73zGJXV/wwl11J5TCPPLhSxx5g1rV+1/UbNs3Fde1zDEE/lpmIWxf1IsEFOAhKoTxXTRwdsQJ4d7CgOcg13YTl4OXJfoHTmcClkA== 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)(396003)(136003)(346002)(376002)(39850400004)(36840700001)(46966006)(956004)(6512007)(5660300002)(16526019)(2616005)(336012)(70586007)(8936002)(6862004)(2906002)(70206006)(8676002)(44832011)(69590400012)(36860700001)(478600001)(83380400001)(81166007)(82310400003)(82740400003)(356005)(6506007)(6486002)(47076005)(316002)(86362001)(36756003)(26005)(186003)(6666004)(41533002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2021 16:32:06.9069 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 26bc0625-bd43-4699-01fc-08d8df2b0d1f 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: AM5EUR03FT025.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB1920 X-Spam-Status: No, score=-14.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, 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-Patchwork-Original-From: Szabolcs Nagy via Libc-alpha From: Szabolcs Nagy Reply-To: Szabolcs Nagy Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Use inline functions instead of macros, because macros can cause unused variable warnings and type conversion issues. We assume these functions may appear in the code but only in dead code paths (hidden by a runtime check), so it's important that they can compile with correct types, but if they are actually used that should be an error. Currently the hooks are only used when USE_MTAG is true which only happens on aarch64 and then the aarch64 specific code is used not this generic header. However followup refactoring will allow the hooks to be used with !USE_MTAG. Note: the const qualifier in the comment was wrong: changing tags is a write operation. --- sysdeps/generic/libc-mtag.h | 41 ++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/sysdeps/generic/libc-mtag.h b/sysdeps/generic/libc-mtag.h index 1a866cdc0c..e8fc236b6c 100644 --- a/sysdeps/generic/libc-mtag.h +++ b/sysdeps/generic/libc-mtag.h @@ -31,22 +31,43 @@ /* Extra flags to pass to mmap() to request a tagged region of memory. */ #define __MTAG_MMAP_FLAGS 0 +/* Memory tagging target hooks are only called when memory tagging is + enabled at runtime. The generic definitions here must not be used. */ +void __libc_mtag_link_error (void); + /* 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) */ -#define __libc_mtag_tag_region(p, s) (p) + that are multiples of __MTAG_GRANULE_SIZE. Size cannot be zero. */ +static inline void * +__libc_mtag_tag_region (void *p, size_t n) +{ + __libc_mtag_link_error (); + return p; +} /* Optimized equivalent to __libc_mtag_tag_region followed by memset. */ -#define __libc_mtag_memset_with_tag memset +static inline void * +__libc_mtag_memset_with_tag (void *p, int c, size_t n) +{ + __libc_mtag_link_error (); + return memset (p, c, n); +} /* Convert address P to a pointer that is tagged correctly for that - location. - void *__libc_mtag_address_get_tag (void*) */ -#define __libc_mtag_address_get_tag(p) (p) + location. */ +static inline void * +__libc_mtag_address_get_tag (void *p) +{ + __libc_mtag_link_error (); + return p; +} /* Assign a new (random) tag to a pointer P (does not adjust the tag on - the memory addressed). - void *__libc_mtag_new_tag (void*) */ -#define __libc_mtag_new_tag(p) (p) + the memory addressed). */ +static inline void * +__libc_mtag_new_tag (void *p) +{ + __libc_mtag_link_error (); + return p; +} #endif /* _GENERIC_LIBC_MTAG_H */