From patchwork Thu Mar 4 16:30:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 42243 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 B80CB3AA9C61; Thu, 4 Mar 2021 16:30:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B80CB3AA9C61 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1614875446; bh=fRAlWdAIGbLLdFoq1LM23MH64dnW6ELDPlohBRaT5N0=; 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=wYtvQUt1oCuMy+C3X+WzcLnY2ZhlPsmX7lzm41kdzrDPD0bN6S6iElif1R9Y/bfDF UCfXZmJK5n4vkRwMJ0PB4Z+5ZrxQvN/UZS6nbM0R3Ce+H2ppgIyn3AXiRU/jeTCZIY /qHIpiYH5KRxsEjgD96fYNKYf9LVeWFoA/RWFlBk= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2072.outbound.protection.outlook.com [40.107.22.72]) by sourceware.org (Postfix) with ESMTPS id 1B0123AA7CA4 for ; Thu, 4 Mar 2021 16:30:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1B0123AA7CA4 Received: from AM5PR0202CA0003.eurprd02.prod.outlook.com (2603:10a6:203:69::13) by AS8PR08MB6360.eurprd08.prod.outlook.com (2603:10a6:20b:33e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.19; Thu, 4 Mar 2021 16:30:41 +0000 Received: from AM5EUR03FT015.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:69:cafe::7d) by AM5PR0202CA0003.outlook.office365.com (2603:10a6:203:69::13) 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:30:41 +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 AM5EUR03FT015.mail.protection.outlook.com (10.152.16.132) 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:30:41 +0000 Received: ("Tessian outbound 751bd80b3146:v71"); Thu, 04 Mar 2021 16:30:40 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: cbfed065fda1781c X-CR-MTA-TID: 64aa7808 Received: from 6427d2cf360c.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 8358CE44-2641-4261-A882-5B1733C5613E.1; Thu, 04 Mar 2021 16:30:35 +0000 Received: from EUR01-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 6427d2cf360c.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 04 Mar 2021 16:30:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KgrxbJeWyBzMnpMvZzDZjZ6+/CJ79086q1owHUwb/c3HcZ1lKMsPswgL/rZqIVbcdPeKkL7YnjXyTbiuJPQhhK0jVLPit0PHf1JMarfk3lnNFtFn0afbuxQ2/tO2BiIZ6x87OJcTqYFw3S+yf8a71S/tZ5RECurGskuQ9hevOWQxk5y4xOcSACgXi8QWkkV/g02UoydamsGFVFyqzbz8TlAi2HGA1J82FNKYdUMs793CU1Okm0ad0vXwqvnZ8IGKL+1PvRJCmj8hRd+9x88mwg89GGb4YHx9vSm0z4I5OfbzGQRk+rjcBJq4IPW44rucIO60cNFy6gLm+8SRGmDvQQ== 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=fRAlWdAIGbLLdFoq1LM23MH64dnW6ELDPlohBRaT5N0=; b=Fo0d/De14NFCbdOhfIY0/CeI0QorsSDK8hCHigcZY3KmffIpJ2B1HzuJdom5dkbS9aYGr7RxsYNh8Klb/Sf272LoEfrir1UBNC/xE8+IopnBBzxfsScXt5qOjXyycMsk80uWSCr+GXBQiomlhqY58p4cJdR+L99PWbd6j15VoYEx7cwWz9DmS4NfoIz4zU+c94mpWd9Knqzq63JC3AezRDglTa3cAOtuek2A9DZNJ88xIHuiAp0ngyBqeYW+2VArTRDBrhB40XxZtoZPd2fFd7jNnFZ8L8gGZI8b/kptFdjhIV59UeJHFRtThM3ac305sdMo74ImfYOmqHHm6l1e7Q== 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 PAXPR08MB6381.eurprd08.prod.outlook.com (2603:10a6:102:151::22) 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:30:32 +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:30:32 +0000 To: libc-alpha@sourceware.org, Richard.Earnshaw@arm.com, DJ Delorie Subject: [PATCH 01/16] malloc: Fix a realloc crash with heap tagging [BZ 27468] Date: Thu, 4 Mar 2021 16:30:26 +0000 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.55] X-ClientProxiedBy: LO2P265CA0382.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a3::34) 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 LO2P265CA0382.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a3::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.25 via Frontend Transport; Thu, 4 Mar 2021 16:30:32 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: c9f87a1d-9dd1-4b5b-61e4-08d8df2ada2e X-MS-TrafficTypeDiagnostic: PAXPR08MB6381:|AS8PR08MB6360: 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: ciLWkAZisqT50tfhnMnm+Dgek8TLX0v1KccgBkzjlUq4l/+2vbN0vldTKkqMH5wFmHVAyz6vmB0SQHIg8VXVEHIuH8nZ/QQXOxKmdY9dykwNJCCGH2MuZDiOqNnhd6LTZnwbxObOOtHQX2l78RTh/z70hUDgrHCr2r/TpNqHxFB4lfeVBdx+nGcUnyvOvlrHcL5aybmEiysaFxGHwGQqt/xRgLO24hNK6ShLopi47go1NfrQ8jbkSp86dCcLuhFyFIleE6A/P3W9KtnU9Kq4WzShKJI1xl1xSVt98xlOJmjIpLwf/48Kvk4vFjrw1likYzdlCxQ8JgPXfC8dcCg2Xi2Q7h9+VWy5l7gM/eA5ate56bHyUMbLWFQmT2plR4ruEY3bPrfjp9gl3D8mmspWiDw1ta/Wvz4JM36tIP32fs2h1PBV70vHhlWa+iM8tGXgepxbF3vYPp2YiKvZSQRS9px2EAbp7D5HJieZavVdzGe0TEf+3ryEm7Wfiep47QqFeg2tXM7fWlakCW2yW67lgJbVFZiEET7ydN1lfCSH8mhrGga/Uw4eJ930AJ201N5jBtD0PMDTTZqQ/FyZWc5iXg== 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)(376002)(396003)(39850400004)(346002)(366004)(136003)(66476007)(83380400001)(66556008)(26005)(6666004)(5660300002)(52116002)(66946007)(8936002)(36756003)(6506007)(86362001)(6486002)(8676002)(316002)(2906002)(16526019)(186003)(44832011)(478600001)(6916009)(6512007)(69590400012)(956004)(2616005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 3QuOusQxmYN4U+J8AKtr4eOpkiGa7DkwdICCdGpb9/O2DSOnsnjIspFnAt5POiQZfhvH+jtY4My6BCIsxOK62jzff05XbmIFZwgxvgzzS0qlEkUWJ4dZPptMoUSTXYvxZRD9oox4vEl8Zzqqs5zA8SpFFPsyP7VDmLk/i+BOR6MIoiBwCS09RGX9gZoY9IMsIDI7j0CUyJLdR2PVmzE5SFd3cds6LAP8UAdERpzKJpicHpAYAm2ytT9uo7gBRoUWII7GHadhNRD++zIp5+UY9qPkm4YJdbA14GZSoMkihdw3Yl6DEIKpmaah5Gq+iwM43LmlR/ebylodE0QvmdFz73WAjkZZe4o+HcMuSlcptrcTFuKCqW0+8N5Dp9H4vGZBRQo6lWI12sG912JZQWklAhz3bwXEZBQGMuLYz/B2DIWaSHbL+moIxEoHII+xHrUvEKVNP5XawLmxplU48ROii8pNKXB3S4+xkffHhjDCDNez6rAe1J/IFDgStwI7Akdm4IUvK5CGEyJdTInMmLWAp4gByaCfkZlPuyOapaYrRli5sQ58eYce79ljV0Bsq+p3H6F9AzxAhLFz0qB1SX9i7dNlBoiVTN7d+yF5SrEoEAOsFiwX7iKpbbWv8N6OmGXhucKRSmEiOIbfgQ73OtSLnrRVCdD9S721sThxPy/waXiErcCggRxhBp4jFaZm6daAIgTqPeYBCD94yyFGbKqVsYajpqv3qEbdNVkKti/ndrEilq2t8/Buse9QZdxxK7+7V8iEGBgpcT1/3rv8hIyuWhpLAZqAVwROFIy3I7kEHeQXg81SKggKk9Uch+Gw/hzQTh69LjIa4ckOQMNv0MMEswX9kmFl7/xbXEoE/ElwHPtDlqOoc/k1MqmN6lBs8cXiAckV9o5N6tZ+xVDwFmSS95H+JiqJeh8jSgBb65w4zLNrUYXyKlpb+pkVOrClFY8Ajo6ZhN1yZXcsI07gRXeOKLeCpgDmKZCF8fSf5CHcNSsN5xqjq0R5/8jdPg88lMbgDndgBjBu8HQ1DsAmK9u4mkfjP1VlWJ+vmTk2g/Wtlq9F41W35Pg0RnH0q+e+RKUymszpB8lkafPfrLs3NVnfq2RP6zeCZSWWvENR09FbULGl8WuzhQ7boUPoAWN9zEVJEzJuxnAxi/JV/lGYVX0LXpMV/mRcZjzzN93uF0SIh/7lvTd885INxgbxj8GbnH1dKhoQVdACPQkBeyWS+Fxnan5ntg+EJs1Y945dk6mKA2rRIYSbF6wTaFdu81AAZ8gSgylz4vuFxdVXYYIcyc6T4tJbOHzM60GhTdDzOBlPW8aLgPYIwoBmbwFjpHriIH3e X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6381 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: AM5EUR03FT015.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: d6ed62e0-304e-455d-eb31-08d8df2ad4dc X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: su7tqeiJKLgKuslLyU45KmxhbpfS8yFA1W4+CyjQEb+CICa0eAfAAIhjkTzkGaM2iRmWMAt8V6/e78HMYmy+0mG+a+ELj45UgvEQcAP7MulIK9rDuFjCLiAbN4NW22Q9L2bIo1CWR0hKHIrz/EsEebSIYCAu5/cXxpIkd6Al+CG4yJ/2NYFjhez+UV8U1IORPH59UPi9TKTILVI/eJACDmiwyzQo45gEbxehb9ZJtSK+1DMSjMSZIR6bovV+I3hCUeaA4ZeJyLFjg5PndbrpeDe3wMjp9QkM4YywuJ9ZF3KRV/JQV4sY1rPb+F67mXUqA7Tqd1d8fZ18G+MVmM4fAzT0U7AXI67xcX2wF4xD7l/jpphZJ1Glb0kwhKrTo8kTv/Q4+8Wg3DViXdBH5Va13EtQmVEJ03ph5eRG/cgLIPMYNwGQ30EKTAUPocvhzG8ceXqFYC4BOd7iVhl2Qz8bHFoSDnPfOHEpxrpVHBWYMRecsuX2Sgp2Ncb6gAb1PKRRvQG400GdVJ5tNcKEHdayJu7Qr5oEGGytQfJhWJMUn/TMLjcacWbq2s60MWvxm9hrgRH43WeRfkuPemEfs0St2BxyXHusvG5IqwBLNaAdcN1LL7KFccVFLl/epBgHdLehNkUR2wxB1A0PLzVoIrAfngfyeGxv9I9EUf5zbHG1yuVHrViR1TwwL/JjTFreDoTH 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)(376002)(346002)(39850400004)(396003)(136003)(36840700001)(46966006)(81166007)(36756003)(6862004)(83380400001)(356005)(6512007)(36860700001)(82310400003)(69590400012)(47076005)(82740400003)(2906002)(6506007)(2616005)(956004)(6486002)(8676002)(86362001)(478600001)(8936002)(316002)(5660300002)(26005)(186003)(70586007)(70206006)(44832011)(336012)(6666004)(16526019); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2021 16:30:41.4368 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c9f87a1d-9dd1-4b5b-61e4-08d8df2ada2e 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: AM5EUR03FT015.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6360 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" _int_free must be called with a chunk that has its tag reset. This was missing in a rare case that could crash when heap tagging is enabled: when in a multi-threaded process the current arena runs out of memory during realloc, but another arena still has space to finish the realloc then _int_free was called without clearing the user allocation tags. And another _int_free call site in realloc used the wrong size for the tag clearing: the chunk header of the next chunk was also cleared which in practice is probably not a problem, but logically that belongs to a different chunk so it may cause trouble. Fixes bug 27468. --- malloc/malloc.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/malloc/malloc.c b/malloc/malloc.c index 1f4bbd8edf..10ea6aa441 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -3446,7 +3446,9 @@ __libc_realloc (void *oldmem, size_t bytes) newp = __libc_malloc (bytes); if (newp != NULL) { - memcpy (newp, oldmem, oldsize - SIZE_SZ); + size_t sz = CHUNK_AVAILABLE_SIZE (oldp) - CHUNK_HDR_SZ; + memcpy (newp, oldmem, sz); + (void) TAG_REGION (chunk2rawmem (oldp), sz); _int_free (ar_ptr, oldp, 0); } } @@ -4850,10 +4852,10 @@ _int_realloc(mstate av, mchunkptr oldp, INTERNAL_SIZE_T oldsize, else { void *oldmem = chunk2mem (oldp); + size_t sz = CHUNK_AVAILABLE_SIZE (oldp) - CHUNK_HDR_SZ; newmem = TAG_NEW_USABLE (newmem); - memcpy (newmem, oldmem, - CHUNK_AVAILABLE_SIZE (oldp) - CHUNK_HDR_SZ); - (void) TAG_REGION (chunk2rawmem (oldp), oldsize); + memcpy (newmem, oldmem, sz); + (void) TAG_REGION (chunk2rawmem (oldp), sz); _int_free (av, oldp, 1); check_inuse_chunk (av, newp); return chunk2mem (newp); From patchwork Thu Mar 4 16:30:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 42244 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 343973AAA038; Thu, 4 Mar 2021 16:31:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 343973AAA038 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1614875465; bh=lgOF2jEZOfyXv3wC2+4xOeSOiNQgZstIZs/9PX6NH04=; 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=e8rwmKawsP9mN0XEMrCvYVqZ0tmpKaHNsS/Fx2R/ZhFOje5g/h3PNhkCH56jH1iP6 JWzbbXoNmy67qk9qbk2Eem9YK6N7LskjESM/rDpj9xl5AweEzIVnFCsbvLPuzPQ70u w1Sv1PiilIsVFUMGEi21JA97Nx1ZNvLi+EwTfPXA= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40057.outbound.protection.outlook.com [40.107.4.57]) by sourceware.org (Postfix) with ESMTPS id 491EB388E834 for ; Thu, 4 Mar 2021 16:31:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 491EB388E834 Received: from AM6P192CA0046.EURP192.PROD.OUTLOOK.COM (2603:10a6:209:82::23) by AM9PR08MB6052.eurprd08.prod.outlook.com (2603:10a6:20b:2d5::15) 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:30:58 +0000 Received: from AM5EUR03FT043.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:82:cafe::74) by AM6P192CA0046.outlook.office365.com (2603:10a6:209:82::23) 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:30:57 +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 AM5EUR03FT043.mail.protection.outlook.com (10.152.17.43) 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:30:57 +0000 Received: ("Tessian outbound 751bd80b3146:v71"); Thu, 04 Mar 2021 16:30:57 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: c59f5d82a4a9f704 X-CR-MTA-TID: 64aa7808 Received: from fa5faf1dcc6f.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id DA830374-F7CF-4C0A-90A6-97E359559855.1; Thu, 04 Mar 2021 16:30:52 +0000 Received: from EUR01-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id fa5faf1dcc6f.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 04 Mar 2021 16:30:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I3SKGYJhOXpEoVMkb0GoJ0IN2HktvDcvNBzfYIqZ8pAeQyaXjPwvIxn+4jD4gD+V3MdsU+GatwntNH3EgPXkRcd1hky+2Hvk5A7noQ+3A/fOWtVWeBsp7nr7YR6C/jTeVvYNcaIkrissa+M8cKWmYNWRr4nuJmxxp1BPEOBRngpdDzhdL27wGgpCsLPlUqoLu1sJ5CPuZdJlvwlhioayaVGbIdVQafsm2wotnhfcysA1YJCKtSxUBbV5gpdoirnVAX3TsAdcWr0hqt53u2dSxU9vOqU9AUfdVZM/wnD9IkhOu5EpqmE2dM+ph62FRthbtBWrjmecIURD2OiT6Un9jA== 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=lgOF2jEZOfyXv3wC2+4xOeSOiNQgZstIZs/9PX6NH04=; b=lP/P1nS2hhX1lEKhbX8ZeSTKtDpcwMHkEVucWjZom2WtD1M4RG1Z9jZxEXAuZBe43iwS64Npik7Xj/IwpKkCrjEfplnVmTLvbK7/h6UcI+KYnQNHooBcCt/K1G1/uH+aBrCF5kqSKktoSYCC7NirBRk5Ew+1rK6oEhllFO9TsX5guW5Ug/RehOGP8wlpW18U6wBMaXdidT5GmDaV1p9Y4xIXjsSWIinIhdywEFRCTxqVNisEXeiL+RaNURkEwXD+ILeKVjZqagqpDRiECTadbIeELM4gMVKppcK4R27MsLNYUi/MHuHgodM55u6UZiMyBeLItg/3WzFRfVWK5RzoQw== 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 PAXPR08MB6381.eurprd08.prod.outlook.com (2603:10a6:102:151::22) 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:30:50 +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:30:50 +0000 To: libc-alpha@sourceware.org, Richard.Earnshaw@arm.com, DJ Delorie Subject: [PATCH 02/16] Remove PR_TAGGED_ADDR_ENABLE from sys/prctl.h Date: Thu, 4 Mar 2021 16:30:43 +0000 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.55] X-ClientProxiedBy: LO4P123CA0237.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1a7::8) 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 LO4P123CA0237.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1a7::8) 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:30:50 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 57e40bb7-6416-47aa-e689-08d8df2ae3d5 X-MS-TrafficTypeDiagnostic: PAXPR08MB6381:|AM9PR08MB6052: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8273;OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: AmA38/GHbkyfsKRQiSMZOvb4EJNx5P0jfzL4r9eJPeB1ywvAczIyRjvvDLlIEoT2W4APCX8g4slXe/izFXB8uyoCI+4UbfcZObyGhRmBRj2YgWOCHeYKuZKovhKuafSgYCG2CNx8vZ38Ugpft96LA19weMhBigH+d3FtNPknSa2BX6lGIbMANoCkIG9n18um0fCPWWf2SR1EZiZjUZP1kl3M0qcToqHHhdRbPz866nyGFrLyGhM0Y8AR3Zt7fK1RtyNE0frbiKn+rufQwOl7mpCCYvZ/98itii068PnWheqvur15YdbOvNx857ZFjE4ICcOnLxnQVqCqQyBxeD9GcdzQbTBJssEgM/Pl8C6LDK2D2tj5a+gKwc/DGYj94bBFkeR/JV/N4y4+oGo967SHy6CwXP+RhCrQXsmtLGFfOHk3R2jVZPA+wu1mZAoecSxC+6fq9UKcfmBeqUdC/uHfo6WO+m2T+HWInlBSBplLaZ/7EBf/dF45ia29wJFf+YNXjASYrxB1uKrdXKHVv6+Z9y2zKag4VnBnmM63W5a0/tgSC12xecp7nFGT8y1MggUlAYuH9be04WoBf32ced/owA== 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)(376002)(396003)(39850400004)(346002)(366004)(136003)(66476007)(83380400001)(66556008)(26005)(6666004)(5660300002)(52116002)(66946007)(8936002)(36756003)(6506007)(86362001)(6486002)(8676002)(316002)(2906002)(16526019)(186003)(44832011)(478600001)(6916009)(6512007)(69590400012)(956004)(2616005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: +Otrus0siANFQXkwcLNpMVYCzOX3emfo6sZRc2LEB5ljPCKIvoqi2wiOUNM+yYv8ArM4bMAnReoPLU0p/w07TO4ghnD99ynl2qFl7A1hAQfm6VkUQa6E0cNN726MSdwtUk9m7Wo0A1u5urnsdUDC0LI7mgYd7zEJirriGgC+Hz7oUYCmsXHm+dQWTSsXX0Lr1MbsB+mzlRgBUTy+SG5Sw3ApZ8AfvY6mwCslvmAjx28xQclHBK9WD3iDrXk8lQXWeXH4vs1E8b4xpsEJnD+nsZVwlXafg/XFm3ecbJkXgyt2xScf1w75o+izli6h4ZfwmnMJDObJhdf/5XJfr9YHnaEnEtmzAgQKA+FX+/YzhcYQ0ca5Aa8pQI0RF6H8T62Q4+mc2BsdzCs1smGm8S3MnJazMsH2WGt8eyLK68FQimcs6SQc/TNdDeHZH5yUXLdSuLwrgdlHRRFVVa79yC4mT36MQT/F5qd2VIuGRa74DeFZzVsOugpaDhIL3mk7CaDvPINWC0i3d9g8MFhHwn+Fl5vEN4RhYWX66LxwwvNiNrGPq/jYDs2rd9OF/cVQAjbkdEbRg5AP2pb0kj8LqPFI9zwsCq7vwJbS4JDwAmvda3UZb6LKU/gT4D4WCVtCBt7RvrDK3L+SpDNhXAefcwIoFeoA4QQkbRqqlj3msMdhxuatTzxRDwUWYwg7TzMxPEnQ5tGrZC1HN9219jkjClLEcDzgvS6REgE2/0azV9Euof8Xf/xElrUIifL21SbLM4so2QG/v52C3ThibQ08L2cFz3HV6n6f1iYZ5dLKSESNWt1rNCtUXSHPg3coCG3/6c/dj6FQ2VSqEElP36K5hf9BbaoaZ3ILwCPTMc52yFHtyk1QHoCCDM/LlGYhSQlfXo/KLyZcU3bf/W6O9c3rDUdx2oW9VkiTbsj9Lpa2VwgqiTQPyBIweoSvibhnbRK0bnvr2aIEiRDh3QCkFKrKD6wEEjp4cPQZfbUAC3JQ+q30VTs8HW1XDvhpx7tSKfXKNhzzYW7SyW6lwJzOH9lCh9IGBnwSM0nCPeJGgizk5fh1N5T4UJBMrtHk2nAXZSFn5wqzoMoUuCVcjkZfKPaVqhvNKlIjBrQhBGF9fO2ibmlnuxJytEwjNvZMjkEM+et+kBt7zo5egq7+HVHDLOKII1tmVI6cHnm+ToDa6+zbfCCZw8nW/RaZQ5ytnJr8YRLJwuP6EixaNmcfpieaaU1BvZkv1a4sQSs4JBSX3jJS1HAgppb+vrGw2vK1FVkywtheGwGEJx+4vsb2VzTESxBRyfCdAeHLr04vepBUiqbWS1ciqRFS0oashkrYXudPSSAmzrWN X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6381 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: AM5EUR03FT043.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 9d004a87-52a0-44b8-a8da-08d8df2adf78 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AUEE6Hr/z8favRYkDqkFsuTuonAtbSftCWqxQEWYeCu5wyUuXz6SX1Fa5/YGIlVVbVhEpZGEMbfX67fQPqqznGetERFl+Jg3heGY6ztqhMmX9r+8xHVTT5bpSdI8UHTSff2PcRtjBpQMtvv5IJzFwBtJjR8xRKMKsAbnd6DqNLRocw7+JbjPAzM6yymvAxKZ3HJ9JXRnZEmQgcg3SDLF5oxILGPAk3sNE1nraRb0WNurwYx+T7likeuYCXv4epsKFxc5riGtwFBnJlJTN8nfU234UODSNqZpUdKzM9Zw4WFij/i+8Sozl5bvzI0W5u1FiXJUDNsYlxoZ07eqXN9LL+eF9RAzlCI+Ks53Kuw55Mllr6jDT/jNv3zil/lZZEopl1oNUYpCSfLtu06htJrCXE/mQt7xbZO7c1JgxLGz4tBWOtNBrhksgglhxlUWyEMfHlXjPvJlzaohxEKFp9AJMlKsoPl87Un6Ia+Cu8IfMztHOlp/htAFc6GxFFjkZKM0q27+rPhMCo20zALQb6sn+GM6hUmUdUOFVkAsjGAbtaHMeS7l1XtUvKmNZglqwPayz/mQSNYanjWFYfuW4tmLj/rWy0ja+LoH7h5tvjU2GNYMYRwJFxkraT8cb0g1yKOQnVdrLhS1ElbFA3dg29va2E33/4eE2cwce6JpBt30EGARnoDvaXD+od9VqP/P3xHU 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)(346002)(39850400004)(396003)(136003)(376002)(46966006)(36840700001)(82310400003)(44832011)(47076005)(26005)(336012)(6486002)(70206006)(70586007)(956004)(2616005)(82740400003)(186003)(6862004)(86362001)(316002)(16526019)(6512007)(2906002)(69590400012)(356005)(6666004)(36860700001)(83380400001)(6506007)(8676002)(8936002)(478600001)(5660300002)(36756003)(81166007); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2021 16:30:57.6371 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 57e40bb7-6416-47aa-e689-08d8df2ae3d5 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: AM5EUR03FT043.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR08MB6052 X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, 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-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" The value of PR_TAGGED_ADDR_ENABLE was incorrect in the installed headers and the prctl command macros were missing that are needed for it to be useful (PR_SET_TAGGED_ADDR_CTRL). Linux headers have the definitions since 5.4 so it's widely available, we don't need to repeat these definitions. The remaining definitions are from Linux 5.10. To build glibc with --enable-memory-tagging, Linux 5.4 headers and binutils 2.33.1 or newer is needed. --- sysdeps/unix/sysv/linux/sys/prctl.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/sysdeps/unix/sysv/linux/sys/prctl.h b/sysdeps/unix/sysv/linux/sys/prctl.h index 00817ff0f1..c9048c7cdb 100644 --- a/sysdeps/unix/sysv/linux/sys/prctl.h +++ b/sysdeps/unix/sysv/linux/sys/prctl.h @@ -25,10 +25,6 @@ we're picking up... */ /* Memory tagging control operations (for AArch64). */ -#ifndef PR_TAGGED_ADDR_ENABLE -# define PR_TAGGED_ADDR_ENABLE (1UL << 8) -#endif - #ifndef PR_MTE_TCF_SHIFT # define PR_MTE_TCF_SHIFT 1 # define PR_MTE_TCF_NONE (0UL << PR_MTE_TCF_SHIFT) From patchwork Thu Mar 4 16:31:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 42245 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 C51C63AA9C61; Thu, 4 Mar 2021 16:31:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C51C63AA9C61 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1614875479; bh=hose+zZJ95LUiT3koZgOVz0kDepJeevCD2ZiuEcMo0Q=; 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=VHYTE1YGuhftvZtXXCysawsCiPr7IOpnjYjAA9fzbmFmw+mBS//M25HVb4/Z0oTeF MtmDdt3kvny0BalZ9ht/P8hd9tTNGXtlUx29gUSvH6aXJ/glVqjK2QuRVwWAtGYEA8 +Q4j3sOH9jhQ/9nHjxrTnACaQHbzknFxGK7nHcwI= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60065.outbound.protection.outlook.com [40.107.6.65]) by sourceware.org (Postfix) with ESMTPS id D2AD2388E834 for ; Thu, 4 Mar 2021 16:31:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D2AD2388E834 Received: from AM5PR1001CA0013.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:206:2::26) by AM0PR08MB5361.eurprd08.prod.outlook.com (2603:10a6:208:18d::10) 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:15 +0000 Received: from AM5EUR03FT008.eop-EUR03.prod.protection.outlook.com (2603:10a6:206:2:cafe::47) by AM5PR1001CA0013.outlook.office365.com (2603:10a6:206:2::26) 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:15 +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 AM5EUR03FT008.mail.protection.outlook.com (10.152.16.123) 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:14 +0000 Received: ("Tessian outbound dd71fb35fd76:v71"); Thu, 04 Mar 2021 16:31:14 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: b17278a8abb70124 X-CR-MTA-TID: 64aa7808 Received: from 8511735d0ee6.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id F25F9E83-7CB1-45F2-A6D3-117F6DFE4D21.1; Thu, 04 Mar 2021 16:31:08 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 8511735d0ee6.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 04 Mar 2021 16:31:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mjn/CTZZBm421FWIv3ERkS+avLtSfI4p1brQ0kYKSKzTbDL4FvSpJT9wL3oDde7kfUkEWkTQHaJ/mcb3gHPd5oNdWziVAN8htUoKvzSabc8jgAMOgzDj8zprGA1xqGMFBaUDk0KiXpfonN0QxlQJcqH+d8JDzJrCC1JAz8WX04evWels99Q3e3spciyghdF/Ko+NR4Z/YfGTgkfy+X49hNzvRf7dcxn8hJMxB0EzYV6PhZ6mzYsHTLElHz959yu0nKCmPmkMRxoQ8FQWAClscI57CCepnJnAESw/oLvnoDvUjv9aOb/PQinTvjPdLKIJawkrVOy3coNHe9pEU19C2A== 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=hose+zZJ95LUiT3koZgOVz0kDepJeevCD2ZiuEcMo0Q=; b=UsbFPklZ9quzLijPxUHEn530PRWB2s9/H1EFXrkr20f7IKUJ4v8AtqqyCz9KqITsGWVJj8yZ1AcL6hZE1zYPs1sp+Y9ga4ahaUbtNKRRlZnbRNdfk9SSyHyu7Il4T5n+yVlGVhp9XsMv4vWJy3mBfwF35iYLj6DsJTcraeys3J4PCV4k+r13UuaZz5egWewXxqqbPmOZpLjovkzVRshjNGmqlO/tGJbpguoWx5CTHVTzpRDR4hBuKsb6Y5h1vtfYicur4sBnVk1nVgY9907CQW8tBsPkwL8LW8R+aElgjaEFphjPAgKPyYKKt8tnBlZe0WvUru+ryt2TGAC0HH7yFg== 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 PAXPR08MB6381.eurprd08.prod.outlook.com (2603:10a6:102:151::22) 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:07 +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:07 +0000 To: libc-alpha@sourceware.org, Richard.Earnshaw@arm.com, DJ Delorie Subject: [PATCH 03/16] malloc: Move MTAG_MMAP_FLAGS definition Date: Thu, 4 Mar 2021 16:31:01 +0000 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.55] X-ClientProxiedBy: LO4P123CA0058.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:153::9) 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 LO4P123CA0058.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:153::9) 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:07 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 5323bd48-8131-471c-fcba-08d8df2aedfc X-MS-TrafficTypeDiagnostic: PAXPR08MB6381:|AM0PR08MB5361: 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: AhSi1FgDPFD9EjDDmdx+G+W212hI3ryIrJ69Ac36hCnc7/MT+dn/F0v7mcFXpKk29NTGfeI0/1gIyO8e9iNars3uN+x4UMTVV6io+LFnn1MFAKCEB4dVjRvIGjV8+5I0+IbPZf3WLq8dXkAcjAjTsBKto3HwTURE5hO1FhVj50NuhpjHktJUneGHjpOuaRUGcCRUZXholknX9ArsYjmyBkrEUnsfzVxIFHJPdjNVBNh0jSwCdcJ2zxY3KH2kLytWt/6nmCpgfhtZdEarhyfZ10p32yAHCSnxM5S6qD5DjfBh+JPb+qR5552SjdgXfZTTznoeOgsAOn50voXpNMx75I6GvGq3hFpmTbdP6Ym25TIcYRZQ3nn5ql7x0VLUNsaPK1x6sXmecTMpUBLVx6vMFRfv0+lZRrvYL/zcJQl0kO0YeLY+zlGlTjmYYUVWkqjK8JgEd33hsEqHRToQgnDVUFelUiG6ylEgNRlX14kUp+OcjSbmLgOjB9Uqf8sOu43XM9kv6dCADMHqwgaC3oRgpPtuljYaGH/0m8nim8CBUhVO7TSti8FpEEZ3+8UFtuflMsfSHiGmpKBTbAOPSSmkAA== 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)(376002)(396003)(39850400004)(346002)(366004)(136003)(66476007)(83380400001)(66556008)(26005)(6666004)(5660300002)(52116002)(66946007)(8936002)(36756003)(6506007)(86362001)(6486002)(8676002)(316002)(2906002)(16526019)(186003)(44832011)(478600001)(6916009)(6512007)(69590400012)(956004)(2616005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: JlUS8gRceM+9eC/73g/BugQzAugKJrL3FqcS5N+yWmp6jqFO+YbBXYs5y5rdOPxK/F7pieDvrCjHRN/7X+BwdZ48lRDqnDBZSicIiP5VWT0OhRT902XuEYbiZNcn2fm/KRK9o+rsh3eKLH+IQroD0/tQyMw9PLVNmzfHujb+YgGLp/65LcbV6PLzdH+kxJYJzADAnjdNVK7CMFdPu+S7Yn7TxrFfdqp5N/kVi9zj9o9V+5PM9HyDcXEmPGRAX94FUrfdyEpSBkmFml+dcSxwdl0OhftAxjVxlfjvjYQo5o+z3Bz5hSgxVal/9OGQX6SOpjf91DonBjcRCeMTTU5Zdi+sUul75XI93WzP3iHXKma7wIOMVPNZsjtk/1Y/PA48MRAyFcxgTfzrtL3YZFhRcpxgQwWvfjV43Wrr9TNQX2YtcFhckAnTDuco02SzksyuY+hQ9h/mZO1MF4DnJgVu0Q7k+ddYBUYW5SMKSJqjF5wi0rGo6ynkjyntCXq3SRghm+oj3Yi92vaztZ7BggS/3HNZTuCnHgJJVM+1LfDigtk0/LNuXoBm7AJMCDSvDTNPa4sDItdN2deyXkhrbP5g/25mFweY/aN+8U3HWeWHVuv/umXc3LHUagB0wp8Wj32aPHEeAstD1L2ugpez/OvWvATs+Zx8CM6+K59La3/3TgowTEURgzi28tinbL7IH1ZAZ1ISJiAiMrLSM+68y04XDBYRY2xyovCatKkFjmqqocaTBiLa78qNpVQPytZW8uG290pZWlG2UpY25pMFjkzplZGiXY/oPz4mPVANY4Oa33ujQQTMzgUUYEA05DOMGTF8266PLcwSL5CSb628V5ca0h3vuwJoo71erGctJ8Q0sh0Ku83mkz99P9wji3gTmn/+yM9hLV6s/QxdHAl1vvUNVHiYgggYM2tuGChoHgoNxk01oLOvyUGKhSXMs17Dc1LyggDLATxIUlHRF+lE097iBSrRhbKBKjQBE/Fd9Zv2nknChwlM+BLNJ9TSmpwmOZBfsFskQ4P/XkuNO3snzNEZdIK8MYI3klF9pO7hb/MIrh+iTWQg1yOTjhEyQpV6H2bAP0i9ERfGw4aBoK01fGiUOkUpGuA/jdF4tSXNrHHfB1tY00dx0u/6iz/bmuV3fyqYZ5iVljuTBACQ+rMRzhZy7LITYJfSKVcVcJhQHN+FsFvY1r29MDtYBwt5FiexMnIv39in2324noKg514KGI4PhMZRl9apzP80qt5E7MfvDBszfcnNi6U0WHTc5ciplb3tJap4ev+ci2B3MDCJBu4nJkX6VbG+/0WLvMXXQ75hO/bsYGRmOJbSFQJbbrzqmByo X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6381 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: AM5EUR03FT008.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 4c7e3dec-b345-4a89-6133-08d8df2ae990 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LL+IuVOJ09tLH5hNxXz5vIIRlorRQDBLgDH/be+JfiCcVTox2qgk6A8duH4ninWJxrrjtBty+c5Dh6WtUPfGapHpJEpkb/FeNkykmg5lzNTfDeNpNjKWSkq7JzFso52wKLW8e/qu8kI4JcP4gtZOfmSuNU/54zE7lemsvn6CK1vryosyqjReDpsmz4yHBvEaCf4oFV7A6kwMsm8Av4euIqbl5PYbJo3qlG9MplcJ3/LjQ45kiwQIDsz2bdxshunDZtFK5kCz4DDkkAPlVwtFY9GQJ3HiSTVt2wW1fabciXIz3teYV1GtIl7TJ9hGD/4D6H/dNB9YcKtvfzkr4JU/FduzMg+Qcw2ecXCNPZtgOvXF/1gbIk7jUM96TEe49yPeLkHaipWRP3TCCOBB3q3dFH7yBj7sjlmmpNAfA+WZNneQg8XoBLYqEAjfsjee1mi8tyihwoAJsyefEeMNyQ4kXk1FkUEQpIIm3NVC5j5rOJRITp+vLXzsQiXKBXyltmsLT4P1kj+SJDKYqAj1S1PIiao/Q5ofDRMWdyt0aJTIy13/+khAUApWF7of5utuEMB3ww0d0E6xmsKtrddxahxpegE5c90SUBKZZY4sCmmlUoKMhPepIn0YNz+XATSIYepavAoTV4UznjzgFr0F1L8ZEbQL8OLfuXkyZOsa3EhVcNTZ0KL0Qt+3iXpbUcYu5rOk 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)(39850400004)(396003)(136003)(346002)(376002)(36840700001)(46966006)(956004)(2906002)(47076005)(44832011)(2616005)(8936002)(36756003)(336012)(316002)(6486002)(8676002)(6512007)(478600001)(26005)(82740400003)(186003)(16526019)(83380400001)(356005)(5660300002)(81166007)(6862004)(70586007)(70206006)(6666004)(86362001)(6506007)(82310400003)(36860700001)(69590400012); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2021 16:31:14.6675 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5323bd48-8131-471c-fcba-08d8df2aedfc 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: AM5EUR03FT008.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB5361 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" This is only used internally in malloc.c, the extern declaration was wrong, __mtag_mmap_flags has internal linkage. --- include/malloc.h | 7 ------- malloc/malloc.c | 2 ++ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/include/malloc.h b/include/malloc.h index 7ae08d53d3..b77761f74d 100644 --- a/include/malloc.h +++ b/include/malloc.h @@ -16,11 +16,4 @@ typedef struct malloc_state *mstate; # endif /* !_ISOMAC */ -#ifdef USE_MTAG -extern int __mtag_mmap_flags; -#define MTAG_MMAP_FLAGS __mtag_mmap_flags -#else -#define MTAG_MMAP_FLAGS 0 -#endif - #endif diff --git a/malloc/malloc.c b/malloc/malloc.c index 10ea6aa441..4538a01614 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -463,11 +463,13 @@ static void *(*__tag_region)(void *, size_t) = __default_tag_region; static void *(*__tag_new_usable)(void *) = __default_tag_nop; static void *(*__tag_at)(void *) = __default_tag_nop; +# define MTAG_MMAP_FLAGS __mtag_mmap_flags # define TAG_NEW_MEMSET(ptr, val, size) __tag_new_memset (ptr, val, size) # define TAG_REGION(ptr, size) __tag_region (ptr, size) # define TAG_NEW_USABLE(ptr) __tag_new_usable (ptr) # define TAG_AT(ptr) __tag_at (ptr) #else +# define MTAG_MMAP_FLAGS 0 # define TAG_NEW_MEMSET(ptr, val, size) memset (ptr, val, size) # define TAG_REGION(ptr, size) (ptr) # define TAG_NEW_USABLE(ptr) (ptr) From patchwork Thu Mar 4 16:31:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 42246 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 DD4C63AA8C77; Thu, 4 Mar 2021 16:31:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DD4C63AA8C77 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1614875504; bh=2zT6w33GQ+cnkbvGRG0lElvd2ZX/kHtO0DmvCS6Z+eg=; 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=oGBzfq2rVeVDTt5AvN7y64OwTH4bYFXQGmqcYdbgyZZJe810Ahcw8s9Mad5Umpbso PGlEHbelc0d//HLmazQ9wHa47JCZ1sN6uvzG/0PsFMeGg4q0C3Xzt1OEM1hiC7kLvQ HXIrgIEut1T9lwAufoM17Lr56iK7aJlNwa0mZ2q4= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40045.outbound.protection.outlook.com [40.107.4.45]) by sourceware.org (Postfix) with ESMTPS id 261A8388CC0F for ; Thu, 4 Mar 2021 16:31:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 261A8388CC0F Received: from AM6PR10CA0011.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:89::24) by VI1PR08MB4349.eurprd08.prod.outlook.com (2603:10a6:803:101::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.20; Thu, 4 Mar 2021 16:31:39 +0000 Received: from AM5EUR03FT060.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:89:cafe::9c) by AM6PR10CA0011.outlook.office365.com (2603:10a6:209:89::24) 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:39 +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 AM5EUR03FT060.mail.protection.outlook.com (10.152.16.160) 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:39 +0000 Received: ("Tessian outbound e9089734ffc7:v71"); Thu, 04 Mar 2021 16:31:39 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 95dfe3fa551581a2 X-CR-MTA-TID: 64aa7808 Received: from 45342c252d52.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id CBF191C9-525A-474D-AC71-8B60F9C93B72.1; Thu, 04 Mar 2021 16:31:26 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 45342c252d52.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 04 Mar 2021 16:31:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RKY6KnHxgkqJPNKfURoSE7m22o9CFIT95SurllQSF0wWO0PiyX4xhAqa7lxX+Y42U6JDLdcRsD1nKkhICc3NlLkrY7JgqbWEnml5A+YaiMO/KUSAGjn5zMCLZoOs8GUlC+R3eJUnZjtrMXrNhFrQhXmDqScbZs/C0AJs1RF9PbVF8Nr1dnjkGrny7GlgCFsbiXRBmxVp2sK9UsZfnTozjlcFNil2AkJ3M9Oj7PaXkHO3/0dLAtxjHvavp+JPSMYz5E3nUPxawrYL4HrD/j8ho8G2Dy5YcQ7P5ODipp7/6IOEBSh+UmUU1pKOGbwkPR3pfBDFqdG3z6dsi/UoG4t1Ng== 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=2zT6w33GQ+cnkbvGRG0lElvd2ZX/kHtO0DmvCS6Z+eg=; b=cJ/m33OyTCW3US4Jza5FZ9XbGfwA4BXzlbLaV/A0tjLa+oj9ODr+Axn+zAY9MJyYlXwKYPiiHSfuSo9miQPp27zjTtBmiUEavLlisNft8jwbJecCEgM7RYPMT+yqEUhsrlBNxPQoV4Y30yWJFYov2PtWieMzdmYyCNa4i3HKhySyjwDnJLIzSvOur+3Cfmm63BIiPHMwD0+gnTr0P9zuIU1O3DSfBJz8VMql0m8xkbJlc1RYtjIcGF4pUz/xJej1G33uy3d/exmG9YGfLYuFJRzLSTTTepoV/PpTk2zYMP95FaiMKipKW0dsTZHEg6MJQxr2WWd1SfAApr5RRro8Kg== 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:25 +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:25 +0000 To: libc-alpha@sourceware.org, Richard.Earnshaw@arm.com, DJ Delorie Subject: [PATCH 04/16] malloc: Simplify __mtag_tag_new_usable Date: Thu, 4 Mar 2021 16:31:18 +0000 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.55] X-ClientProxiedBy: LNXP265CA0007.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:5e::19) 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 LNXP265CA0007.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:5e::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.26 via Frontend Transport; Thu, 4 Mar 2021 16:31:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 4d2fb433-1d5a-47b3-5929-08d8df2afccd X-MS-TrafficTypeDiagnostic: PA4PR08MB6205:|VI1PR08MB4349: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8273;OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: H5CPaesBsCwSWdhlcjFaxs34wEGKudMX8pqjncmG+TYmOR4ySvpyXCaZMfAkxjW/Is1hRjCTi+1deutbtEv0rTWIkfKI/vuHMZsBQypCzdRhRrq1/6F4l2ZODLhTRGbfMx+k8ycz/4UaElGWOCq0EkMorDsSZDmVjYDXL7djCyT9mrOFMTObKVI4XBAFeHEdW0FuFV68WdTlPrcz80ThJ0/J0G0VnpkUZ/DRDR/igrchPOG7zruqPBJ8apFZI9uiQDbLZT+cZqE5HnXQJtBkSwKmqhmlvzYv0hvPCeC5D6ZineQw0YtHAI2Wi71VPiHfFS72Baxy2GyIjTvpSZCbt/D/rmXvAjFWdfVWy6SQoMKqwhuS5FW7dpQnMx40VObLl0V947qQ+Y2ydb//CyoQgbYVSiHV3vB0tgIgmUHowAO9c5WTA16KgVGtXFuPe9xw78b3V8dhBkxYd9wDK5dzcEpvPR4LWCyB5nwzacURJyCYLMDbaXi7MmKWEq2XTPnoduKtg07iH84GeXWew4shTcdMBnGgktb2p+Wy1QAaBTqkcn/vHvvCVvKwWRTZIicRhk0hoA39C3nk6/jtc1VlDw== 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)(4744005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: prUPKvIGBbZ87R8CQSVUsiC4UuR0FduUtnvh7yV16xdB3GnjYu25K+4JhwZDifO7AqTXebEPhYoby/13jYbZ/UYS1z+P8eRLSKN2fWzk5yNpTCP7ch/02pq/BsNCltdSv7k3QEWjLagppvTnR6TI1v9uoEgMrZjqBnC46QjTmDncuQ52JJ9u273EGEL9fukggd7W5xSQd76jP4p+hNWHmTGq2xK5Bz3tR8lh6ssQG1usj3nSQ6LL/zWofF5T7HJD2+jGVd2CzzyV7u3y+U7U2P4b+UKtsdJ0/TdEojp62UyYfEdGllowiw20R5DjTTMphwS9XBGueCP+t5sSs48b3TRgEpQK864efYBa+iP40p9tNTTXdVs8El5SyC86rAcUKo0U2mNqQXQM8pnrMZLMCSy8MH3bOSOgKhZnd4LHu5IwQGg2FhAiegjLwkFkmZTVkqVNk1SlKZYU7hqOoP8kY/xg4n9eOmt6pGbQkDTqGmNV7OZAlIIyTE2duzC6VbBkv9KZKkG4Y9Qa/slHlurJjNLcAnfBXs4qx5W4YNTisn/jEmKPZKKP6gtuOhzaqKL4ph4uvUUSH+M9hlqL2lrlrpARlrZ+FVet/SIHFqTie70liLIMInP+iPD7dUdj3oQaySGPOMugudVRJQp7/4GlGkvxgNviUI5G7R7LUyKE9SKMNAJkyY19szwhMmZtbXHY2AIi+6XmVFdoMy0Wo7Ih2CRpPcJ/vl1MtpQ/mYPtP4SBCuXchDO5KB9/NhgX8Y41f9S8Oig18wlFIRkQGQ8NWvLb6BuOSy2T/OCNpA01VUol2GAIBmHOXl3gj5+Vr1qd5G3JcZMUcqyp6qt/vN8m8uxAonrMbalo56xuJ0ycUW/cPe3FRqcJpPMMbwhmDOjSwGlcOhHyp4cv68DFWmyj5VOJ/Adx0wW5WwITB4a/uthdqm3gXBa1HCo6nx+2tZ+8a1WjYYoEB/LfXlzrkcH1k5ShPDtOYNgWPo5cuI8dtJEH3aO5b0pzKLqnHbpEUVWHmCLDt0RizKZj6BTe6iS386A+REgSqYSn9BXjr8l8ZFIZShY6P8iGJZVtjs99wEsvPqU5Wx0kGapKsqyI39nmYsma74KAryb2/ugwkxHuf4L3LcJooi2/sKiz7YdjiblkfqwF/X/YAs52LthUzrjzezVbM4UauXtSXLxsvEnmZbylDPywh2crY+7NOjWi1f2YPKqQxYzFuoW6pwH7d3Z0wHL2aB2eSZYKMth5nCPHAJnAVxjG0ytTfwGTVSLEx35knXGzBEq3mKPJPUHxcSV+JxTXOXDta4DzyC5/0z8W8opcbQlECZvYvK4K2aVhCo6E 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: AM5EUR03FT060.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: a1fb1530-894b-4719-c3fc-08d8df2af43b X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7IHLXhiIRdPE/qCPwqwnBquu/gw9TkywDeBw9iLWvOX+4Po/ChSrtpq4abVCXvmAT39wzeauRKB7QId0O8PvN6ld7O504eX79/JxdHY2q1uh4Z6Jqr3UE6+Qc2HVzKsljsVjFCTMLVuzsyqO7b/3wWSNxU6Uhs6Dffj+mIMzWwaC63NvT0fxSHmlb/uf7GUu+Y3HhBclu5ZChaWxmLPg0/ZGaQIzVqjEPkxmTbTnqnIjsSH+Mv3c81csiuPrbjoWeuiiaPRpAYBRHr0Xq9hQ9NSEQSG01MjERYprjtnAfU1z2dqt99J2WbH3cXYyDBb10dXdADXsp2GlvE51jp9C0nNGLEZkHhfoYte64PHMfIgFpM3IVFOwnVJMwCz947MhKFBxcGOcgzI9kLYhNPrSnNaNhOBg4qiDd0fYalO2ckTzDNawE2W9OADZZOOXTMEMtyfpf0RqyjhvYLbyWt6U6Eqwpf8cL89jqEOW6R50DZnsw+3U1tsAzsHb+GcrJ8EUNnMmTIDUFw3Wiy1urGJ2PdSEAW/zmprSuAe7hUcC5bY0jW34vEge6ZZJRqlP0IFD0t6j32uij9luiI1bYr/ZMcyx0alw5Sa60WJvgTy5MTxyePD3AsB2twiWeN8lYEbGGhnIusT1yOhPbHjp4SlaPjWwMMhUcf8LvAAnDTAHM9xKLEMjdvulYGbH/+v0a8kl 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)(136003)(346002)(396003)(39850400004)(376002)(46966006)(36840700001)(8676002)(36860700001)(6512007)(69590400012)(83380400001)(82740400003)(6486002)(82310400003)(36756003)(44832011)(2616005)(8936002)(956004)(478600001)(6862004)(2906002)(47076005)(186003)(316002)(6666004)(26005)(6506007)(336012)(356005)(86362001)(16526019)(81166007)(4744005)(70206006)(70586007)(5660300002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2021 16:31:39.5282 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4d2fb433-1d5a-47b3-5929-08d8df2afccd 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: AM5EUR03FT060.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB4349 X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, 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-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" The chunk cannot be a dumped one here. The only non-obvious cases are free and realloc which may be called on a dumped area chunk, but in both cases it can be verified that tagging is already avoided for dumped area chunks. --- malloc/arena.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/malloc/arena.c b/malloc/arena.c index bf17be27d4..0777dc70c6 100644 --- a/malloc/arena.c +++ b/malloc/arena.c @@ -298,11 +298,6 @@ __mtag_tag_new_usable (void *ptr) if (ptr) { mchunkptr cp = mem2chunk(ptr); - /* This likely will never happen, but we can't handle retagging - chunks from the dumped main arena. So just return the - existing pointer. */ - if (DUMPED_MAIN_ARENA_CHUNK (cp)) - return ptr; ptr = __libc_mtag_tag_region (__libc_mtag_new_tag (ptr), CHUNK_AVAILABLE_SIZE (cp) - CHUNK_HDR_SZ); } From patchwork Thu Mar 4 16:31:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 42247 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 75D9F3892447; Thu, 4 Mar 2021 16:31:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 75D9F3892447 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1614875516; bh=BoAYnFdLSsOq96ZqNyJwkrnbveQdMIGdKny3wIZH99o=; 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=SQCGKBsvHQgNT7a/W85fViWUU5U3Re9ZhazL16HzbSo6ENWtWFiqxNmflj/T620pm zQeUU3bhdReg4Tp5st3kkkbZRbIpzK4ksiUdVAKB8uz9jiWW1yMaXtd6eNLNmiOqw9 ehKlNmaiEe+m8NaYeyKJMQiN4Q5jLiXvEViDCzsE= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2083.outbound.protection.outlook.com [40.107.20.83]) by sourceware.org (Postfix) with ESMTPS id 61A883887018 for ; Thu, 4 Mar 2021 16:31:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 61A883887018 Received: from AM5PR0202CA0020.eurprd02.prod.outlook.com (2603:10a6:203:69::30) by PR3PR08MB5802.eurprd08.prod.outlook.com (2603:10a6:102:8a::6) 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:49 +0000 Received: from AM5EUR03FT015.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:69:cafe::2a) by AM5PR0202CA0020.outlook.office365.com (2603:10a6:203:69::30) 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:49 +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 AM5EUR03FT015.mail.protection.outlook.com (10.152.16.132) 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:49 +0000 Received: ("Tessian outbound dd71fb35fd76:v71"); Thu, 04 Mar 2021 16:31:48 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: f0ebd91ff4f5cb70 X-CR-MTA-TID: 64aa7808 Received: from 1a548f8db80e.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id D8C6D10F-537D-4E2D-A658-B77AED27D553.1; Thu, 04 Mar 2021 16:31:43 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 1a548f8db80e.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 04 Mar 2021 16:31:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZTE0z8cO+G233wva4hT9QsJvptdtp9ww1hCwVxdsIB4PHSdvRHWHdyo7mTRR2ebRdrnZdNizqjdpE5PjbPLwEu5fdNX6O2QUIlsFMbN0PqX3FMsU+aZlwPWsMipqDUumpN0f09BYXrJfyVarri8j803N7RBGsS4/L+wpidPOoGVY92Fg1Hdsboa/ENlsEraxI6tNuqkbzpNL2BH5dzPDsdSdJphpodHYLdxEQiTpeGr8KfQJUb+O0XkrDUaYFLUHFi6HdOF3hOVd+MDN+6LWC1IFaTxDvaUo/NG1vLNm0DFLZjsCu2wAaWJiztSfZaPcD/qFb4NuWYvFskDlRYxiqw== 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=BoAYnFdLSsOq96ZqNyJwkrnbveQdMIGdKny3wIZH99o=; b=VIUKj45Pcckt5GdgEfytByGsP3dZmEIH5/OJ98fBV5hSLeO0aXSPmtEc/h3wgnVv/6PYfS4jWwtFAviK5hgpjloHGFVp8jtoSzzSd9gX0qjm7uuWdjeS/ZsTMaLBeeioVGq7iOmZNvH2/nKjZR9dWtxt3EZyQLvU6GQklXF6JAPJe8sGu1Agk2n7uCxf0CnExlvHRzrajnPcosewX5QwIseFe4+kDpm9dqHQvxG4DIRqEFk4m+lejuq8sXn4Pvb/FzKDR9wk+LR9Ck5RljHJ4ov48R0sMwPcVgvzsopvBc/Q5t0vZiFUx7SQC2QDVMi0/Lnjfw/hpmpdmclpnWG58A== 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:42 +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:42 +0000 To: libc-alpha@sourceware.org, Richard.Earnshaw@arm.com, DJ Delorie Subject: [PATCH 05/16] malloc: Avoid taggig mmaped memory on free Date: Thu, 4 Mar 2021 16:31:36 +0000 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.55] X-ClientProxiedBy: LO2P265CA0348.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:d::24) 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 LO2P265CA0348.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:d::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.25 via Frontend Transport; Thu, 4 Mar 2021 16:31:42 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 6d317948-4868-496d-b4b7-08d8df2b029a X-MS-TrafficTypeDiagnostic: PA4PR08MB6205:|PR3PR08MB5802: 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: eBDW+LYsl8bvHxZodqmjy6HiSbxsH+fq95YevKiFIyU393LqmIHG1tzfGlHv/4adkisvTvdbFtzPTFp8FvWk0WyKYw9ADvdYdPN0ZlCrx89oNdYaWrE188ih0Nj4KBEhuC2cw4dWSsaJv+eAyJZOn8UbEoLtO4mJKdxXWsQouYDxwDKsbCEa0djCbj5bEjs8OE1d1uI6M5E+O7XcsrMrNgLeU2XJ96Wg0a9mGiWJUF/fL1tduHXw0cGL/ycNo5fhV3c7kTXmqwCofsFumyXt2lhrtWEEPGpGW14pYJZSTPtHtjsMnTdw3uGg2Y+ig+nIs5jVbZeGaFDKBKjRiAUMndSsizoo6mg8UAn0Mh4IV2BhbYXNpxXdc7hAyOb/OQ3MO9RChYe10rWzk0kzvMG/sSv5o84Y2O70/Jj7ZhyYr8fq1OO06HFfa9hxJH0Si1xX/3cwB/ddXE7+uIOFcjn095h4zr4lf0EJF3NDcA+89UBL/o9h+IAGf8+YE599vHiEAUwejMo1U/BKwpLs+v5xgYkojYt/XFPdIOQ7tgapu4ayaffJNHsy4YkDtJ8bbCzQMJ/OGKjZJKM7/zdLXMNQKQ== 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); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: aNNp2mkeUNEMrIJRgmhSkKqOCGdjZV0XohmBMzwrdK3pEQILEE4B46CWGTF4BaxtVpuQm7IuxCqmbImKmR/H0/7P8MfK0tENv/FbXE/l5+0f68lURw3SSrq9K75r87GRrEVIfUyojWieJFhlIs2LqAXlhaY6CFtv+If0tR+ewYgrF2B+phnedIA2hhAGuSYdHO36SHIyJf+p36k/edwsh1mbiOsT/lJPat+TMAtGMNaxwofz4hQbAkjDYli5rrg+pqrSDJaUUiq8Kj4pFta/tRSnbc8aRtcFIu7TtK5WGdTFUJmP0e8DqBefmajiDRfYaTIqOtxR+pcSpVJSl6H+HSaDJH3A13gRqGVg7KoISx1E43Y+jY67zkCbLi9DwTyMqXEAwDXd1Y4U5nvW/A/a3BccMm58/AEKsZZKJvxqobHqv38mnJ8KVzduW5v00PD9M3qZRjiBH5PCMmEJkcCAy3cc1ARS0JfTvvO81zCHOcdkIbvqhWk3XW0Y7n9MkpnY+Rjt9heP2BaMbr/uNOb8I5DMA1PGRlv5vZDKXoBnG5qvFskN+6S76CTYRc5MV+u9XwSGfBj8I84goSGEVPdHDeds4qd5WgkWsevUPvfkSVbpK+203OpxVmXOQhUxlgCeJYpTIGrQWx+2o7gEaNZQtTF24K1ZR5ZHXii8CEF6SZjzA2uUvgicGbOSFC2fUdqdvLD49MxaEBUqFkOrsE0E8u12lnmGwnM7lap3Z2aQwIHjzFm0jJqEUD9FPHPtLPF4VsdvD3J89yNrsXeJl/m01vkpaG4/9cI8cKx53SwV5wUV6WNUXVDtUMv8Uyqm8u+IWG5ufoQaPBOVwoLJN+SAdiigNWJjCgiiywr/VjXtoo5a6MEiI4SFQEHJLKBeyyUkqfUYLS7RMwcc7tvBvTxU9URKOkI+lhOSg0AuRIGgj9XAdG1daXwGt1Y3TIRhekUtYUb8N2u/p638X/HhiXT+aTC6njMdYCfIChR2ECJLQxGhlR3/8rBmgGcIE1GoqpPC9d/s0QPAm/Kk3k3XzeoWjcRKE5/FvYxZF6pWxUlFFgyDDoDKz4lC2JNtOLPk4k7RTTY48FGvwX9cr44wpt/e0i0ZaU5yonSUSQ3eTwbrKCHa0jrRgOQT4BSQ5JXD2YIeLuadCHPiu5i87bRScOUex1o20Q2/+MctlKjc16X2yXagX3YCZ3GP9e+alq1sY5fuWq00mT+9enLEKBz6LV0nnCPmwaFjuhEEd2N4uhsnMN4gPtfUzn40uhikF/QIHHIeU8NPZDGADB2l2yaXthPq8JiP+x7Ppi7ITzXDURLm5KV/EE5TUNf6vQKIxMgQhm86 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: AM5EUR03FT015.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 5dd9c944-2d6b-4c81-450e-08d8df2afe5e X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Hmilt5rcZ3zp0Br0yT1XRiELzMrvhChSCp6V7AXle9ASiL1v64DJyjKHYQgmQwqlzOh8gGe/CCXljrr3hFIdPK9vQB7E0Q8ZSY9Zii5FHlB2Ig9OvQ7jCRBFx0aDD/vp1f50Z+esJ2BC2YyizwDUk14P+Kwb1vETszvtlQ8eZWzoh8Pb+r2zfiTlPP/UnLg6q7DTH1+OIqSonN1/OeyhmU0yJzTFoQ3BSh6B1AyNF7/9ImzsRs1QGSILUnUq5PNIUfatEjQ/7Hx8m5goTX//APbM9mAGcsWgjOmOl7L/VCbsvXTsUpnrMqDz2Ho3rtqZQoodBRBBLXG6Z2/hGq62ML5E6h03xbUQs/brs6OelABFHxHwc9xbwF3/MJytWRAWHcQtX8AVmXLKZNcA/zf8sCO4bKXrkEJj1LlaLW5hoDV5DCj5elVpalGLkrU2cLibqL9Fwx/5I1/FzI7UbaSQ62o7JQhVIYuHCtVjHlJAPzvBCBOYBNTMxxdhuhrNYVvhN8KHdvWGMgp3xWPf6GQbODs81E3Out7ntaeP6POLWqramhlyzzofAuVE1wcvJukFaXDa/SOFEsJ4A2PIWo0VOAwPm6LZNTA3v3kLcOG0L5NoEaoVeMcjOnvs5StpwSRxXPCl6WjPXSbh0wNKZEJ/ISaYA7pgDpmmBkVe/dPSOlvwoBZaX/Y6RskWuy0gDB2o 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)(39850400004)(376002)(346002)(136003)(36840700001)(46966006)(336012)(6506007)(356005)(5660300002)(16526019)(36860700001)(70206006)(70586007)(26005)(6512007)(47076005)(69590400012)(478600001)(36756003)(186003)(82310400003)(81166007)(82740400003)(6862004)(8676002)(2906002)(6666004)(8936002)(316002)(956004)(86362001)(2616005)(83380400001)(6486002)(44832011); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2021 16:31:49.2666 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6d317948-4868-496d-b4b7-08d8df2b029a 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: AM5EUR03FT015.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR08MB5802 X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, 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-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" Either the memory belongs to the dumped area, in which case we don't want to tag (the dumped area has the same tag as malloc internal data so tagging is unnecessary, but chunks there may not have the right alignment for the tag granule), or the memory will be unmapped immediately (and thus tagging is not useful). --- malloc/malloc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/malloc/malloc.c b/malloc/malloc.c index 4538a01614..b4c800bd7f 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -3284,9 +3284,6 @@ __libc_free (void *mem) p = mem2chunk (mem); - /* Mark the chunk as belonging to the library again. */ - (void)TAG_REGION (chunk2rawmem (p), CHUNK_AVAILABLE_SIZE (p) - CHUNK_HDR_SZ); - if (chunk_is_mmapped (p)) /* release mmapped memory. */ { /* See if the dynamic brk/mmap threshold needs adjusting. @@ -3307,6 +3304,10 @@ __libc_free (void *mem) { MAYBE_INIT_TCACHE (); + /* Mark the chunk as belonging to the library again. */ + (void)TAG_REGION (chunk2rawmem (p), + CHUNK_AVAILABLE_SIZE (p) - CHUNK_HDR_SZ); + ar_ptr = arena_for_chunk (p); _int_free (ar_ptr, p, 0); } 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: 42248 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 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 */ From patchwork Thu Mar 4 16:32:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 42249 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 B5DB93AAA08C; Thu, 4 Mar 2021 16:32:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B5DB93AAA08C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1614875552; bh=mYwAwgalaLht6dQxi87bIS67ONOwq/ogUZwcHdoTst8=; 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=c/OYjPEhL1YKQeJhvSHo2xGXcH2c6BNEObqBW25sQRtGhjWkTMf+IMqRk23+pOek4 dhsktIWYhlTD+M8otTcIAE6WOa5TM8c3629yn16uk9uqmHu3fN5FmfXZJPU9W4zSZx g4RNHEg4is0k7LLVJFhQDV7fozz+nZ62ns4lVAzg= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80052.outbound.protection.outlook.com [40.107.8.52]) by sourceware.org (Postfix) with ESMTPS id 11EEE3892447 for ; Thu, 4 Mar 2021 16:32:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 11EEE3892447 Received: from DU2PR04CA0112.eurprd04.prod.outlook.com (2603:10a6:10:230::27) by VI1PR0801MB1711.eurprd08.prod.outlook.com (2603:10a6:800:4e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.20; Thu, 4 Mar 2021 16:32:26 +0000 Received: from DB5EUR03FT042.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:230:cafe::c6) by DU2PR04CA0112.outlook.office365.com (2603:10a6:10:230::27) 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:26 +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 DB5EUR03FT042.mail.protection.outlook.com (10.152.21.123) 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:26 +0000 Received: ("Tessian outbound efd554c08f3f:v71"); Thu, 04 Mar 2021 16:32:26 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: a62ded729909d324 X-CR-MTA-TID: 64aa7808 Received: from 446c17aeb450.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 5D0BE996-64C9-42B2-9E54-0DB884B57CB9.1; Thu, 04 Mar 2021 16:32:19 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 446c17aeb450.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 04 Mar 2021 16:32:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HK8XvCz3VallgfkZWKIbLEK8A8p9G0KDDfO/UES++l4XBnL3gpmxQIAdFlfV0mT0WKIQ5SRQd7RL0Qsh9yG6saD9AVoEmgPLHbrwgRZxMA22woPTNNMe3Du0uFZPLw/YGdNi9zUuyd5e4nbrPwE//8lpXhL4GwwUXBGmE1Ug47/XWCKX4X/mB958YyWw1c88tI8weYvlC1LrCm42zyxeLODCjGvemQX/LsC0Cn42aWwFlenS+s3czvL/ZKrJbC7yYCPfFLEThKEAGhs0ed5UwE+NlsvVDPy4f+NEc5OawQd+cn7jM7MpNVtIqX4nxKZD/CTVNRQyUY8T0jufJOb0SQ== 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=mYwAwgalaLht6dQxi87bIS67ONOwq/ogUZwcHdoTst8=; b=OpPvvKvieB8s0jSwJcPsgwlttkEqB1OoiT9lS3YUKUa8OSwxomKGhwWszZoS1GpQGdWMpBETf634ZC+VM8WPLHp/Gyd41Ec3NxsyX9rYxUQ+lPsfkH1e7Yg4lTe3WqO03qo2mKW5TXpHUdbKHYecGCzR5yRvFi+Ilvdcri/ClxN2YCBTqJliTsRtoeGtAs6OxWWPwT7pyEv0scmKixmX111qnHI0TwBN/Yyg1MISKdJlvYlWFRNLwdx8S83XMlAASsk4OX3yiv8iT6Uumqb4VfSdgYS40XXfuZdQ5hfsPcsDRNIFxi8yFxPX37/MvktCtc63rY0knECZh807V4FReg== 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 PA4PR08MB6064.eurprd08.prod.outlook.com (2603:10a6:102:e2::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.20; Thu, 4 Mar 2021 16:32:17 +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:32:17 +0000 To: libc-alpha@sourceware.org, Richard.Earnshaw@arm.com, DJ Delorie Subject: [PATCH 07/16] malloc: Refactor TAG_ macros to avoid indirection Date: Thu, 4 Mar 2021 16:32:10 +0000 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.55] X-ClientProxiedBy: LO4P123CA0118.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:192::15) 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 LO4P123CA0118.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:192::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.25 via Frontend Transport; Thu, 4 Mar 2021 16:32:16 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 34c1669d-5d83-43f3-b8b9-08d8df2b189a X-MS-TrafficTypeDiagnostic: PA4PR08MB6064:|VI1PR0801MB1711: 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: CNUZafMMFmjSEdRq0PcoPIdELjC0W9VhsHwMe+8JmnLw/ajDuH5KdFqBC+3UqLAlw/ngOFQrjO0+W61EFpIrSYnITeFyRzp2WtbCsL/Do5+iWCF5505PrGmRNNFXkUghQ58G9rgu+aZEklT4Q+zq8oHm57je9lrYd2B2M8IuYrlZyWEzMao3ZeSvP1m+zZb7FvQVn/kPFh48STUOkKrbZNrZPV63+ajle8TacQC7Zv9pbBAhSl9keVvf/YiLLemWRhx2erhP2F9ARXtSkmP16Z1mQ5k2CTRuIsmJah4eNTJvIB13com+a05H6WZ09viNEUqlka99mni+0KO16k01ocZ5oq/7lhn7U9usaebAtDnzPrhsXwnZ86nFVw43H7OoVMetTutJWmZkBWHmoeks65j0V3UWAyxL0T5vWdwpAaiz47wmkhJcRBKZ4B4CnRklSU8OOpNkl1NQorJw6zY+/MomgdNSlrQ6NyzmkDjyFtCxyhODCLMpv5+pUcvFK3BGJLB3jeekje0W1JaajHu02zUgExTN75u6LqjiwOi2Fl6JlPYGdU+AqBObw/gnDL4ibGEc2e8VDpKDEiTfBgBM4A== 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)(39850400004)(376002)(366004)(346002)(136003)(396003)(69590400012)(8676002)(6512007)(30864003)(8936002)(478600001)(6666004)(36756003)(2616005)(52116002)(956004)(86362001)(6916009)(6506007)(5660300002)(26005)(6486002)(316002)(66476007)(66946007)(66556008)(186003)(2906002)(16526019)(44832011)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 2+cF+PrvuifD4aF714Vcs6HCZp4dFH8wmZpVhYm0j8rZcgxjCwGFt8o3c8IGWMaFjiRD+4OoFigwBgXMlfcfRTXh0Gg6r5/AI7of5ot5k/xtSoMafLq/wGIJYtUkckI92b2/geLUxvdFAiQCeCDFkzfWa1xTWVtQQMhlNlptGyCkSnb6ODGaAhEWwwU16SP6AhUxwFi7kgsptLVKM7Klv19Y0a1ehRpOo1ZAB1FZ/Q2xnuseIIa/Cq/Fo9/AedjnLgAWZ9A11bLD48+E8T+AESLiTaMdE2opUUhkq/2ZScUkrZmmCCfqy1RoqpMz6dDAa/zjTRBMMzi23qbvKcqI3PqeeLisD5l6fNGiL+JUcswwCNKipAX1ocBw4tfG7vyDj4ieSysIe92zwraE94Um7KXAyPr5UZ1McKRnAqGk23eI0tH95K5E5U1Cvsu/evJnD9qez2s+HSNsDVMjnVCmkvL8/6ssOMeK5i1LP3lbRIKdQKqcBEVcLNcdps9jxuP5XUuoh7b57kkzHWXik+o+T1mWQ4btDwU0gHCSIjF0Zm3xOA6FA2SCaN07c0e4dVe26ny/IE0SFJ/WqLCV6hMjezMwHzzWKvau8aAKvUwQJSPFWXm1u9p0Ys0fsjlSbezCoNV07+Xlu3Sw7u0uyYw32/TW78cZh8y7lHPW4rdTxdT3m03tEvWOgtT/hFHOyzHsXKvqg7WpQ4oxKJ61UB+e59EYsKXDK3e4UWyxMgnvzKFjWsl6CMQ6xQqRpTV+RJP9hjAwKeN0khF3huYkbXez+bhz2ZV+lzCj/gXrr+29b5K2Ml7EzUePnm4X23jt72bh1qRNwRsILzEG4oMAl+1qZH3BFCgedZwz6Wt7gByjo84d2fq0CAUprO+s/r5diTHbBnvzUfAKuPoZEp58UhH+lXx7BZvNYnFSpGNaulhWKMxu4oGmXr8D/Eoevja7XWDOFVeGVXzkSdbnqQPWd1Y/Mp0ekdfrynRRCY6AYfyhPg/dMElDpuA7hkdEVVz2FJslZet2QIj8prRQzxWa+YOkXOA6FOad+vDgDRb7FcRck0y1A4Km1uGGRLMiiCP96Fohc/YJiucnpNofllHp0shW4Y+l5dYv3y9kQ/dT2uyofQERDYJrWeFs/uodx5Bt2w8kdJrZK7lvHYg2bUR+Tf2Iq9yaD7nUgHwYMOMtpuw9GYR8Xy9Kem+N1U3npldozk6Za3fQHsulf4BfX1lQnb1p57C5MvBqD21dhtpU1kJOZokWsCJpK7hqWNGLE8E7rTBv1R8Agr+MvmIuvVAZfVn2tvA9d7JQ6xH6JGlFOljmNjMFdO67qt1oBbJ4+5vdpos8 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6064 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: DB5EUR03FT042.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 2c078ea3-2529-448b-7a28-08d8df2b12fa X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +f7OU3SWFBoTzvQiMLf0OQpXlPS1l19BxscxStb1IcgQHrphy+ien3A80AJcRBR2Y07lpxKo5nyyYoIOZQVRrfYYX7295sUFFfFjGktt1+xLHymxjxYUVbGfcTXsGf+NZCC8d/b7zmYOwEg8FtOoBHa0ol/MaxMnlEtnjNUYUg2rYjchVYwJHXcUkkdnZ+drJMzB6N0djH+LBd23ydrfDLoAzI3KXTQfJwWYzAy9yuiBOwNffwM+nVHupb76SEd0Ux7tHC3NiO2YuU3IdjdkscHd+l0H1OCaxGtbjKrPJahT9NDCm2/ScKYchTx9gUw/IZv+oqzgSVsrNrogerXKBTEjafUJFLz3Dkw33q8NSBa8mb82BYtOcIr1sBOL5gfzMubCPqhB0/LNRwZ9rzog5+RwCjiBlOsz0sBiEfYmwwXwzLYhGp6j0ElU0VFtpZmzhWSX2JMPOBW2beVyhCKjrcara+/SJniXLUbPPY7JOKk/DXsoWwA5350yTZWCo6aIYrAsEwm36Db1hUhFd+ivP+9yOJSafwL9qmltF+90TnVIwXrlJ3w0MNPLGeEfn0Yn7vr+Ly3Za1LbT0drGffJK71/BFIlbB92K0pYcqJDEC6ALgsIRfA1kU/vjI+tKWKhYJpyH9wKO64Dw4ehiK2cExBhdupj8zyZMeNqonl1UftlQgl9CoHvHoJg4YFqfrIv 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)(39850400004)(136003)(346002)(376002)(46966006)(36840700001)(16526019)(478600001)(83380400001)(2906002)(316002)(356005)(69590400012)(44832011)(26005)(86362001)(36860700001)(81166007)(336012)(82740400003)(6666004)(82310400003)(5660300002)(70206006)(70586007)(6486002)(8936002)(47076005)(36756003)(6862004)(6506007)(30864003)(8676002)(186003)(2616005)(956004)(6512007); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2021 16:32:26.2225 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 34c1669d-5d83-43f3-b8b9-08d8df2b189a 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: DB5EUR03FT042.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB1711 X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, 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-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" This does not change behaviour, just removes one layer of indirection in the internal memory tagging logic. Use tag_ and mtag_ prefixes instead of __tag_ and __mtag_ since these are all symbols with internal linkage, private to malloc.c, so there is no user namespace pollution issue. --- malloc/arena.c | 16 +++++----- malloc/hooks.c | 10 +++--- malloc/malloc.c | 81 +++++++++++++++++++++++-------------------------- 3 files changed, 51 insertions(+), 56 deletions(-) diff --git a/malloc/arena.c b/malloc/arena.c index 0777dc70c6..d0778fea92 100644 --- a/malloc/arena.c +++ b/malloc/arena.c @@ -332,12 +332,12 @@ ptmalloc_init (void) if (__MTAG_SBRK_UNTAGGED) __morecore = __failing_morecore; - __mtag_mmap_flags = __MTAG_MMAP_FLAGS; - __tag_new_memset = __mtag_tag_new_memset; - __tag_region = __libc_mtag_tag_region; - __tag_new_usable = __mtag_tag_new_usable; - __tag_at = __libc_mtag_address_get_tag; - __mtag_granule_mask = ~(size_t)(__MTAG_GRANULE_SIZE - 1); + mtag_mmap_flags = __MTAG_MMAP_FLAGS; + tag_new_memset = __mtag_tag_new_memset; + tag_region = __libc_mtag_tag_region; + tag_new_usable = __mtag_tag_new_usable; + tag_at = __libc_mtag_address_get_tag; + mtag_granule_mask = ~(size_t)(__MTAG_GRANULE_SIZE - 1); } #endif @@ -557,7 +557,7 @@ new_heap (size_t size, size_t top_pad) } } } - if (__mprotect (p2, size, MTAG_MMAP_FLAGS | PROT_READ | PROT_WRITE) != 0) + if (__mprotect (p2, size, mtag_mmap_flags | PROT_READ | PROT_WRITE) != 0) { __munmap (p2, HEAP_MAX_SIZE); return 0; @@ -587,7 +587,7 @@ grow_heap (heap_info *h, long diff) { if (__mprotect ((char *) h + h->mprotect_size, (unsigned long) new_size - h->mprotect_size, - MTAG_MMAP_FLAGS | PROT_READ | PROT_WRITE) != 0) + mtag_mmap_flags | PROT_READ | PROT_WRITE) != 0) return -2; h->mprotect_size = new_size; diff --git a/malloc/hooks.c b/malloc/hooks.c index efec05f0a8..d8e304c31c 100644 --- a/malloc/hooks.c +++ b/malloc/hooks.c @@ -68,7 +68,7 @@ __malloc_check_init (void) tags, so fetch the tag at each location before dereferencing it. */ #define SAFE_CHAR_OFFSET(p,offset) \ - ((unsigned char *) TAG_AT (((unsigned char *) p) + offset)) + ((unsigned char *) tag_at (((unsigned char *) p) + offset)) /* A simple, standard set of debugging hooks. Overhead is `only' one byte per chunk; still this will catch most cases of double frees or @@ -249,7 +249,7 @@ malloc_check (size_t sz, const void *caller) top_check (); victim = _int_malloc (&main_arena, nb); __libc_lock_unlock (main_arena.mutex); - return mem2mem_check (TAG_NEW_USABLE (victim), sz); + return mem2mem_check (tag_new_usable (victim), sz); } static void @@ -280,7 +280,7 @@ free_check (void *mem, const void *caller) else { /* Mark the chunk as belonging to the library again. */ - (void)TAG_REGION (chunk2rawmem (p), CHUNK_AVAILABLE_SIZE (p) + (void)tag_region (chunk2rawmem (p), CHUNK_AVAILABLE_SIZE (p) - CHUNK_HDR_SZ); _int_free (&main_arena, p, 1); __libc_lock_unlock (main_arena.mutex); @@ -375,7 +375,7 @@ invert: __libc_lock_unlock (main_arena.mutex); - return mem2mem_check (TAG_NEW_USABLE (newmem), bytes); + return mem2mem_check (tag_new_usable (newmem), bytes); } static void * @@ -417,7 +417,7 @@ memalign_check (size_t alignment, size_t bytes, const void *caller) top_check (); mem = _int_memalign (&main_arena, alignment, bytes + 1); __libc_lock_unlock (main_arena.mutex); - return mem2mem_check (TAG_NEW_USABLE (mem), bytes); + return mem2mem_check (tag_new_usable (mem), bytes); } #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_25) diff --git a/malloc/malloc.c b/malloc/malloc.c index b4c800bd7f..e5f520267b 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -413,26 +413,26 @@ void *(*__morecore)(ptrdiff_t) = __default_morecore; operations can continue to be used. Support macros are used to do this: - void *TAG_NEW_MEMSET (void *ptr, int, val, size_t size) + void *tag_new_memset (void *ptr, int, val, size_t size) Has the same interface as memset(), but additionally allocates a new tag, colors the memory with that tag and returns a pointer that is correctly colored for that location. The non-tagging version will simply call memset. - void *TAG_REGION (void *ptr, size_t size) + void *tag_region (void *ptr, size_t size) Color the region of memory pointed to by PTR and size SIZE with the color of PTR. Returns the original pointer. - void *TAG_NEW_USABLE (void *ptr) + void *tag_new_usable (void *ptr) Allocate a new random color and use it to color the user region of a chunk; this may include data from the subsequent chunk's header if tagging is sufficiently fine grained. Returns PTR suitably recolored for accessing the memory there. - void *TAG_AT (void *ptr) + void *tag_at (void *ptr) Read the current color of the memory at the address pointed to by PTR (ignoring it's current color) and return PTR recolored to that @@ -455,25 +455,20 @@ __default_tag_nop (void *ptr) return ptr; } -static int __mtag_mmap_flags = 0; -static size_t __mtag_granule_mask = ~(size_t)0; +static int mtag_mmap_flags = 0; +static size_t mtag_granule_mask = ~(size_t)0; -static void *(*__tag_new_memset)(void *, int, size_t) = memset; -static void *(*__tag_region)(void *, size_t) = __default_tag_region; -static void *(*__tag_new_usable)(void *) = __default_tag_nop; -static void *(*__tag_at)(void *) = __default_tag_nop; +static void *(*tag_new_memset)(void *, int, size_t) = memset; +static void *(*tag_region)(void *, size_t) = __default_tag_region; +static void *(*tag_new_usable)(void *) = __default_tag_nop; +static void *(*tag_at)(void *) = __default_tag_nop; -# define MTAG_MMAP_FLAGS __mtag_mmap_flags -# define TAG_NEW_MEMSET(ptr, val, size) __tag_new_memset (ptr, val, size) -# define TAG_REGION(ptr, size) __tag_region (ptr, size) -# define TAG_NEW_USABLE(ptr) __tag_new_usable (ptr) -# define TAG_AT(ptr) __tag_at (ptr) #else -# define MTAG_MMAP_FLAGS 0 -# define TAG_NEW_MEMSET(ptr, val, size) memset (ptr, val, size) -# define TAG_REGION(ptr, size) (ptr) -# define TAG_NEW_USABLE(ptr) (ptr) -# define TAG_AT(ptr) (ptr) +# define mtag_mmap_flags 0 +# define tag_new_memset(ptr, val, size) memset (ptr, val, size) +# define tag_region(ptr, size) (ptr) +# define tag_new_usable(ptr) (ptr) +# define tag_at(ptr) (ptr) #endif #include @@ -1305,8 +1300,8 @@ nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ /* Convert between user mem pointers and chunk pointers, updating any memory tags on the pointer to respect the tag value at that location. */ -#define chunk2mem(p) ((void*)TAG_AT (((char*)(p) + CHUNK_HDR_SZ))) -#define mem2chunk(mem) ((mchunkptr)TAG_AT (((char*)(mem) - CHUNK_HDR_SZ))) +#define chunk2mem(p) ((void *)tag_at (((char*)(p) + CHUNK_HDR_SZ))) +#define mem2chunk(mem) ((mchunkptr)tag_at (((char*)(mem) - CHUNK_HDR_SZ))) /* The smallest possible chunk */ #define MIN_CHUNK_SIZE (offsetof(struct malloc_chunk, fd_nextsize)) @@ -1337,7 +1332,7 @@ nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ #ifdef USE_MTAG #define CHUNK_AVAILABLE_SIZE(p) \ ((chunksize (p) + (chunk_is_mmapped (p) ? 0 : SIZE_SZ)) \ - & __mtag_granule_mask) + & mtag_granule_mask) #else #define CHUNK_AVAILABLE_SIZE(p) \ (chunksize (p) + (chunk_is_mmapped (p) ? 0 : SIZE_SZ)) @@ -1361,7 +1356,7 @@ checked_request2size (size_t req, size_t *sz) __nonnull (1) number. Ideally, this would be part of request2size(), but that must be a macro that produces a compile time constant if passed a constant literal. */ - req = (req + ~__mtag_granule_mask) & __mtag_granule_mask; + req = (req + ~mtag_granule_mask) & mtag_granule_mask; #endif *sz = request2size (req); @@ -2467,7 +2462,7 @@ sysmalloc (INTERNAL_SIZE_T nb, mstate av) if ((unsigned long) (size) > (unsigned long) (nb)) { mm = (char *) (MMAP (0, size, - MTAG_MMAP_FLAGS | PROT_READ | PROT_WRITE, 0)); + mtag_mmap_flags | PROT_READ | PROT_WRITE, 0)); if (mm != MAP_FAILED) { @@ -2665,7 +2660,7 @@ sysmalloc (INTERNAL_SIZE_T nb, mstate av) if ((unsigned long) (size) > (unsigned long) (nb)) { char *mbrk = (char *) (MMAP (0, size, - MTAG_MMAP_FLAGS | PROT_READ | PROT_WRITE, + mtag_mmap_flags | PROT_READ | PROT_WRITE, 0)); if (mbrk != MAP_FAILED) @@ -3221,14 +3216,14 @@ __libc_malloc (size_t bytes) && tcache->counts[tc_idx] > 0) { victim = tcache_get (tc_idx); - return TAG_NEW_USABLE (victim); + return tag_new_usable (victim); } DIAG_POP_NEEDS_COMMENT; #endif if (SINGLE_THREAD_P) { - victim = TAG_NEW_USABLE (_int_malloc (&main_arena, bytes)); + victim = tag_new_usable (_int_malloc (&main_arena, bytes)); assert (!victim || chunk_is_mmapped (mem2chunk (victim)) || &main_arena == arena_for_chunk (mem2chunk (victim))); return victim; @@ -3249,7 +3244,7 @@ __libc_malloc (size_t bytes) if (ar_ptr != NULL) __libc_lock_unlock (ar_ptr->mutex); - victim = TAG_NEW_USABLE (victim); + victim = tag_new_usable (victim); assert (!victim || chunk_is_mmapped (mem2chunk (victim)) || ar_ptr == arena_for_chunk (mem2chunk (victim))); @@ -3305,7 +3300,7 @@ __libc_free (void *mem) MAYBE_INIT_TCACHE (); /* Mark the chunk as belonging to the library again. */ - (void)TAG_REGION (chunk2rawmem (p), + (void)tag_region (chunk2rawmem (p), CHUNK_AVAILABLE_SIZE (p) - CHUNK_HDR_SZ); ar_ptr = arena_for_chunk (p); @@ -3408,7 +3403,7 @@ __libc_realloc (void *oldmem, size_t bytes) reused. There's a performance hit for both us and the caller for doing this, so we might want to reconsider. */ - return TAG_NEW_USABLE (newmem); + return tag_new_usable (newmem); } #endif /* Note the extra SIZE_SZ overhead. */ @@ -3451,7 +3446,7 @@ __libc_realloc (void *oldmem, size_t bytes) { size_t sz = CHUNK_AVAILABLE_SIZE (oldp) - CHUNK_HDR_SZ; memcpy (newp, oldmem, sz); - (void) TAG_REGION (chunk2rawmem (oldp), sz); + (void) tag_region (chunk2rawmem (oldp), sz); _int_free (ar_ptr, oldp, 0); } } @@ -3509,7 +3504,7 @@ _mid_memalign (size_t alignment, size_t bytes, void *address) p = _int_memalign (&main_arena, alignment, bytes); assert (!p || chunk_is_mmapped (mem2chunk (p)) || &main_arena == arena_for_chunk (mem2chunk (p))); - return TAG_NEW_USABLE (p); + return tag_new_usable (p); } arena_get (ar_ptr, bytes + alignment + MINSIZE); @@ -3527,7 +3522,7 @@ _mid_memalign (size_t alignment, size_t bytes, void *address) assert (!p || chunk_is_mmapped (mem2chunk (p)) || ar_ptr == arena_for_chunk (mem2chunk (p))); - return TAG_NEW_USABLE (p); + return tag_new_usable (p); } /* For ISO C11. */ weak_alias (__libc_memalign, aligned_alloc) @@ -3544,7 +3539,7 @@ __libc_valloc (size_t bytes) void *address = RETURN_ADDRESS (0); size_t pagesize = GLRO (dl_pagesize); p = _mid_memalign (pagesize, bytes, address); - return TAG_NEW_USABLE (p); + return tag_new_usable (p); } void * @@ -3569,7 +3564,7 @@ __libc_pvalloc (size_t bytes) rounded_bytes = rounded_bytes & -(pagesize - 1); p = _mid_memalign (pagesize, rounded_bytes, address); - return TAG_NEW_USABLE (p); + return tag_new_usable (p); } void * @@ -3666,7 +3661,7 @@ __libc_calloc (size_t n, size_t elem_size) regardless of MORECORE_CLEARS, so we zero the whole block while doing so. */ #ifdef USE_MTAG - return TAG_NEW_MEMSET (mem, 0, CHUNK_AVAILABLE_SIZE (p) - CHUNK_HDR_SZ); + return tag_new_memset (mem, 0, CHUNK_AVAILABLE_SIZE (p) - CHUNK_HDR_SZ); #else INTERNAL_SIZE_T csz = chunksize (p); @@ -4821,7 +4816,7 @@ _int_realloc(mstate av, mchunkptr oldp, INTERNAL_SIZE_T oldsize, av->top = chunk_at_offset (oldp, nb); set_head (av->top, (newsize - nb) | PREV_INUSE); check_inuse_chunk (av, oldp); - return TAG_NEW_USABLE (chunk2rawmem (oldp)); + return tag_new_usable (chunk2rawmem (oldp)); } /* Try to expand forward into next chunk; split off remainder below */ @@ -4856,9 +4851,9 @@ _int_realloc(mstate av, mchunkptr oldp, INTERNAL_SIZE_T oldsize, { void *oldmem = chunk2mem (oldp); size_t sz = CHUNK_AVAILABLE_SIZE (oldp) - CHUNK_HDR_SZ; - newmem = TAG_NEW_USABLE (newmem); + newmem = tag_new_usable (newmem); memcpy (newmem, oldmem, sz); - (void) TAG_REGION (chunk2rawmem (oldp), sz); + (void) tag_region (chunk2rawmem (oldp), sz); _int_free (av, oldp, 1); check_inuse_chunk (av, newp); return chunk2mem (newp); @@ -4881,7 +4876,7 @@ _int_realloc(mstate av, mchunkptr oldp, INTERNAL_SIZE_T oldsize, { remainder = chunk_at_offset (newp, nb); /* Clear any user-space tags before writing the header. */ - remainder = TAG_REGION (remainder, remainder_size); + remainder = tag_region (remainder, remainder_size); set_head_size (newp, nb | (av != &main_arena ? NON_MAIN_ARENA : 0)); set_head (remainder, remainder_size | PREV_INUSE | (av != &main_arena ? NON_MAIN_ARENA : 0)); @@ -4891,7 +4886,7 @@ _int_realloc(mstate av, mchunkptr oldp, INTERNAL_SIZE_T oldsize, } check_inuse_chunk (av, newp); - return TAG_NEW_USABLE (chunk2rawmem (newp)); + return tag_new_usable (chunk2rawmem (newp)); } /* @@ -5108,7 +5103,7 @@ musable (void *mem) /* The usable space may be reduced if memory tagging is needed, since we cannot share the user-space data with malloc's internal data structure. */ - result &= __mtag_granule_mask; + result &= mtag_granule_mask; #endif return result; } From patchwork Thu Mar 4 16:32:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 42250 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 BFCD93890427; Thu, 4 Mar 2021 16:32:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BFCD93890427 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1614875567; bh=xXECP3YuiNjZTauqIkoJGbj9yaN4LWUgH40dSF8giNM=; 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=hh7ulLs0Cby2L1faSkoQKGjBFAverbIYzkPaTi3TtwMtwFvmz9n1jqJUVyZIigUst EBkBrmlTSV9diWPCLvCpvm9v2pQDcQe3M/7H+TJOr0lBCsP6+8ibPnMX8bndG5GOtz gCJl9LnxvdkU2pwKaMAR2a/A8RvG5TU9mZjnBSik= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80077.outbound.protection.outlook.com [40.107.8.77]) by sourceware.org (Postfix) with ESMTPS id 41049388CC0F for ; Thu, 4 Mar 2021 16:32:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 41049388CC0F Received: from AM6PR10CA0040.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:80::17) by AM0PR08MB4177.eurprd08.prod.outlook.com (2603:10a6:208:132::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.23; Thu, 4 Mar 2021 16:32:42 +0000 Received: from VE1EUR03FT035.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:80:cafe::68) by AM6PR10CA0040.outlook.office365.com (2603:10a6:209:80::17) 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:42 +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 VE1EUR03FT035.mail.protection.outlook.com (10.152.18.110) 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:41 +0000 Received: ("Tessian outbound dd71fb35fd76:v71"); Thu, 04 Mar 2021 16:32:41 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 6de25e08d59a4b57 X-CR-MTA-TID: 64aa7808 Received: from ee5e1b148c14.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id C78B3808-C409-4A2F-B6D1-CDF529F18476.1; Thu, 04 Mar 2021 16:32:36 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id ee5e1b148c14.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 04 Mar 2021 16:32:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hI1k8EZcis0RiGNy6J+bqF9Ui4DN+VaMWuxoavYrSx6rp+yZVt6aljlGrIR2vxYlCeGX+K69Eqk8HY0Vb0rh98yh2N/a477rqf3JdTlD6lhNpw9ynhUceZBpT0wye8meQ0ePXEtltKKCAHg7ORfZZuOGE5F3tQLbOjZ+sD6tFc+Cl7ZYfxX881g2F+vL5+4Zl9i0HaZQdUvlqjO/TJ3QoS8XGcuFA6MpzS8w7MOu1vK3pKsCEHd5IydB/7YLVjhQL66kA2ZtCptAjEzD9PrDflCJtnvc6ZSfEn+knrKSy4mETY7O36PhQ/6FvrPhweqP6h43x9AYKDxibR+Ktla1aw== 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=xXECP3YuiNjZTauqIkoJGbj9yaN4LWUgH40dSF8giNM=; b=I9FaCiZHcotcptvGWlZvh/YlrW0R76TLFSo6TuuTf0qtGfWvNSrjPPDBZK5ry84QOpkf1P6hkjV9DAIJgMc6ZGvVgFQnQzMShBHEbex++zHfSrHzSif1/0zawHj/cYWbKD77GijWyCwoQkxhSqJYLBQNMgF8cRPDcMxyo3Qk1lc2PK9XK4TZBTbH+6XZ+t1Pjf57JtS0yatdg2aUbZXqBh/BthbKqN2hUrn2tw4ztUPpm70L7XPV7o5QwWTxf0vtFX6vGD+j1zMUbXRWphqiRWlvRz47gpj8BNSCs0vjjMvO4lKNRDObz1bZvpKUw/n+/yZzQqX8xYDXFoQ7ChbWMw== 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:32:34 +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:32:34 +0000 To: libc-alpha@sourceware.org, Richard.Earnshaw@arm.com, DJ Delorie Subject: [PATCH 08/16] malloc: Use global flag instead of function pointer dispatch for mtag Date: Thu, 4 Mar 2021 16:32:27 +0000 Message-Id: <8d9711a654bfe7a47ba743ab7e836118f8866f66.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: LO4P123CA0027.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:151::14) 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 LO4P123CA0027.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:151::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.25 via Frontend Transport; Thu, 4 Mar 2021 16:32:34 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 9b934899-ea3d-4e54-bed5-08d8df2b21e2 X-MS-TrafficTypeDiagnostic: PA4PR08MB6205:|AM0PR08MB4177: 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: GbkZCwkbPIz7tGVhlPasdhXhPvso4sL7el24p/pQ2ieDsYLLUUFQpLec6KWCICgLeFUjp2thlIzI5YbbvoZTwinemTiKZw4HWdENp6laL+/dyazW4TJNjJsbMAsYvJyDbiMKLk24D2ayUbled9VYOqxH/CCrxFNy8mIP4KgxsP9r9lozRzvmtqoFrOGGEiL0U3YnV1fmM/AGGColwWXuN4+cS+sQoCUKE4H/P5AKQUhK1UWg4J3wqvYmFXGsnIC93s7P89Mu39FKtzMcufsBZzvAyi+VjTtI6jycmoSRVnkeJAqM+NEc+wKTs65mu0wbZMIX4GE9L99uN3g3+J6Ca4xnXT9QP/epON9OzCiZsj2E83g2Pcz/WjzEQz26zf8Zu2MG7wXSvvyQQniBCumcheaTjvm9+iSbjIz2FE+oMqU4UQVXyx76osqJ2kzzrFT9CJMZl2X0nTebj7zeUy6ddLQ+v+PIdRneaY5hRVXEAU2zWxkBZb3tJPSZqyylSG9vVL9+2E+rFZ+qKptm5QxPxY/DWpUKmNUUAB6gj+KcwmF9/wE6zxR46xlr6Ze4ed0WKEMDN5rFh1//mXyI1Y8x8g== 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); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: j5kvZ7uqYbyFSv8rZ6RHeSrqxmAg6tGl/RHhoU80DpqtubMzsTVXy6N2q3F/42ni7cKrFM87QrNQVnplANsJGeCywQmOQuxh3Kh+MJfixM1JxYfpchzXa/xtr6KZyhHkZ/c2Duib8g0/Qjbthl/Sx63VjNWS3h8CTzqPDpPbnX9DkxItBHJTCJuH4tgtzwiL3OzC1ne8RAuanavXGtofanDbIZ9d9iSJUbYscCBHQtWYb4binMZ6mptUgq1ItJJjUJZq/Icvd8C44NpAe+Kngppj/8JBGc8DPLdwA866cGbDup1wxNz5VdYjiA8ysCIjdz5bNEDpHiao37JdWCFtfzH2j3h1s0VsEPcZ+iyvM6Le8WINBwc7MlKPb+8hqZz51EXq/3olUFXIkyKbjWGS7O3bc6kb8hsHCn4F46ga51NEnfGMmDmBuCAMLKGzF4sTBLZRb91o8yf7+QIeODIbM3z57PGVinDkM53G+QNk/U/dwX6CTTpN8tAxZlq6hYVPxgZbsj9JggpCUrKmwCT+Ju1f2FEx3JU7COcq8jsZIZHbS6wKBrKmuF8ZH3ivmna1+p8/b+4I2ts/RLAh4guLWwSfoopVeLPfScb7YVi9tkn8zCMKh5CjX8ni5v3+xPfwGfTuS7Nqw0amYmwE2b5HiQfKnKzUIR3UBR50xJPVBlPU+9k8qDFtyf2f3GD6Wvh6qqcuGvqFCo1ZKpuBfpN1+BwLvdwRA3LvZ74Eh9gKZBx7JEEOqma8p66sYiiiKNfEPMnvHE/uzgy3RpuoAqx3iZrb+FCvnHAFNFPReFCcbBfzDdpOG4Jr3LIS4aMd2mwlLkpYK3HX23OtLIyum52qoLE1zcR7wfadFKxnd/HZeupj+wDAzjPQAbAGBhc6x8a9Syb08/OLGpfUPBpmXtRI7cMrlOcOPXnwuby1H7G/mJTxDgNfY4AW7p8cIWm7opq99JG77O3qJB8wZnNbrvX+227dvbk05RkXAZhXgLT+/3v9PrUGnA3kCrsd7sX8io9/VTjvbStUw+sJA3biJhwF8h6RXUif2kG2I4LBb5B9zOo9lVED0gOGsjCQTU3rDMFcacqNvhklACF019xdiKXuQdbMMWWTp4oHAzztztw+xyqn5noJ7qukqs9b4ZTgU+koHSZ/oZfcDB06WYuZOV02d08A/KK91kGt3zfmMexFE0UJdN4qnfHklt+ipjEfIVymtnG5WUYPtRr6kjJzILsvdwIkvdsbgzt0bMDk4sqfshVAhxczb38rS9Zta+45mqjXcXbDaFqki2v3d62CayvaJMwVXdS2A+A18E1RAjKymdcc5ZzmvGlATBA9n44AKGaH 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: VE1EUR03FT035.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 63b82db2-8cdf-479c-ae19-08d8df2b1d9b X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9484ugAC3JhaKFXg2mM9K6e6177KA8xun2Q50bp+lQ/NfCs+8OdoSzOuBNpZXx96y794AuWuyQ9C2ZcjoqzuPOV1umOk/avPM5kgsABZywaa/tKRXumjMWiOZ5O9GrHVgjQbp4WByt77gckok2hsEPmCI0fvNAANSmJJ67onKUVrsG1L1Hh8ReB2xSwM5GPstgFh2GA5M/mn78KzTLri5tjko4fvuSf6lKipmgu5nmLdxwViD5p1JTvbwU2Me/O3sRUAncwT/0lXwHoUdFS79zMVmpRB+rxG6GWNb5RJTi+5dy+//8X7G0RnmgshCMvQCz8dGhrPc4Q8m5Yloq1HTrZUIdN+Pfqy8dYeUh4LJe547/5Td/c8e9xgjEHtrFIYStqUk5kPGbT28l5wTlCs1BhuhOv3RNHjl+hTU5+XO20RUUt+05/+x78z8p015c10t/zo81rO9OZ2o2b0WpRGy26rd73nEq5vp7GM1dlNGwHquQqxXbfb/1Cf108ug5lvRIGfWcWia1uVJIpSCSQSwKEKHrDj6p8R36xOJEUYx1pMAB3r+7xY7RM3tJ5an2O0zB3eDUoaWKFwsK0TnPc1UeniLLo84aLVsslQmqMUXBzVkcHtx8F1udPVnv6uCzK5fVN9JoJRXGti1FZqPFxDyIGMxOT5IUZuaqjiSH9c2auQI+4wPYhDQpJyxQ+ZQ+dV 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)(346002)(396003)(39850400004)(136003)(376002)(46966006)(36840700001)(36860700001)(6512007)(478600001)(6506007)(82740400003)(316002)(6666004)(186003)(86362001)(16526019)(6862004)(956004)(44832011)(69590400012)(2906002)(6486002)(5660300002)(8676002)(36756003)(81166007)(2616005)(47076005)(70586007)(83380400001)(70206006)(8936002)(356005)(26005)(336012)(82310400003); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2021 16:32:41.6688 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9b934899-ea3d-4e54-bed5-08d8df2b21e2 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: VE1EUR03FT035.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB4177 X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, 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-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" A flag check can be faster than function pointers because of how branch prediction and speculation works and it can also remove a layer of indirection when there is a mismatch between the malloc internal tag_* api and __libc_mtag_* target hooks. Memory tagging wrapper functions are moved to malloc.c from arena.c and the logic now checks mmap_enabled. The definition of tag_new_usable is moved after chunk related definitions. This refactoring also allows using mtag_enabled checks instead of USE_MTAG ifdefs when memory tagging support only changes code logic when memory tagging is enabled at runtime. --- malloc/arena.c | 33 +--------------------------- malloc/malloc.c | 58 ++++++++++++++++++++++++++++++++----------------- 2 files changed, 39 insertions(+), 52 deletions(-) diff --git a/malloc/arena.c b/malloc/arena.c index d0778fea92..1e83bb66bd 100644 --- a/malloc/arena.c +++ b/malloc/arena.c @@ -287,34 +287,6 @@ extern struct dl_open_hook *_dl_open_hook; libc_hidden_proto (_dl_open_hook); #endif -#ifdef USE_MTAG - -/* Generate a new (random) tag value for PTR and tag the memory it - points to upto the end of the usable size for the chunk containing - it. Return the newly tagged pointer. */ -static void * -__mtag_tag_new_usable (void *ptr) -{ - if (ptr) - { - mchunkptr cp = mem2chunk(ptr); - ptr = __libc_mtag_tag_region (__libc_mtag_new_tag (ptr), - CHUNK_AVAILABLE_SIZE (cp) - CHUNK_HDR_SZ); - } - return ptr; -} - -/* Generate a new (random) tag value for PTR, set the tags for the - memory to the new tag and initialize the memory contents to VAL. - In practice this function will only be called with VAL=0, but we - keep this parameter to maintain the same prototype as memset. */ -static void * -__mtag_tag_new_memset (void *ptr, int val, size_t size) -{ - return __libc_mtag_memset_with_tag (__libc_mtag_new_tag (ptr), val, size); -} -#endif - static void ptmalloc_init (void) { @@ -332,11 +304,8 @@ ptmalloc_init (void) if (__MTAG_SBRK_UNTAGGED) __morecore = __failing_morecore; + mtag_enabled = true; mtag_mmap_flags = __MTAG_MMAP_FLAGS; - tag_new_memset = __mtag_tag_new_memset; - tag_region = __libc_mtag_tag_region; - tag_new_usable = __mtag_tag_new_usable; - tag_at = __libc_mtag_address_get_tag; mtag_granule_mask = ~(size_t)(__MTAG_GRANULE_SIZE - 1); } #endif diff --git a/malloc/malloc.c b/malloc/malloc.c index e5f520267b..caf34843f7 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -441,35 +441,41 @@ void *(*__morecore)(ptrdiff_t) = __default_morecore; */ #ifdef USE_MTAG +static bool mtag_enabled = false; +static int mtag_mmap_flags = 0; +static size_t mtag_granule_mask = ~(size_t)0; +#else +# define mtag_enabled false +# define mtag_mmap_flags 0 +#endif -/* Default implementaions when memory tagging is supported, but disabled. */ -static void * -__default_tag_region (void *ptr, size_t size) +static __always_inline void * +tag_region (void *ptr, size_t size) { + if (__glibc_unlikely (mtag_enabled)) + return __libc_mtag_tag_region (ptr, size); return ptr; } -static void * -__default_tag_nop (void *ptr) +static __always_inline void * +tag_new_memset (void *ptr, int val, size_t size) { - return ptr; + if (__glibc_unlikely (mtag_enabled)) + return __libc_mtag_memset_with_tag (__libc_mtag_new_tag (ptr), val, size); + return memset (ptr, val, size); } -static int mtag_mmap_flags = 0; -static size_t mtag_granule_mask = ~(size_t)0; - -static void *(*tag_new_memset)(void *, int, size_t) = memset; -static void *(*tag_region)(void *, size_t) = __default_tag_region; -static void *(*tag_new_usable)(void *) = __default_tag_nop; -static void *(*tag_at)(void *) = __default_tag_nop; +/* Defined later. */ +static void * +tag_new_usable (void *ptr); -#else -# define mtag_mmap_flags 0 -# define tag_new_memset(ptr, val, size) memset (ptr, val, size) -# define tag_region(ptr, size) (ptr) -# define tag_new_usable(ptr) (ptr) -# define tag_at(ptr) (ptr) -#endif +static __always_inline void * +tag_at (void *ptr) +{ + if (__glibc_unlikely (mtag_enabled)) + return __libc_mtag_address_get_tag (ptr); + return ptr; +} #include @@ -3185,6 +3191,18 @@ tcache_thread_shutdown (void) #endif /* !USE_TCACHE */ +static __always_inline void * +tag_new_usable (void *ptr) +{ + if (__glibc_unlikely (mtag_enabled) && ptr) + { + mchunkptr cp = mem2chunk(ptr); + ptr = __libc_mtag_tag_region (__libc_mtag_new_tag (ptr), + CHUNK_AVAILABLE_SIZE (cp) - CHUNK_HDR_SZ); + } + return ptr; +} + void * __libc_malloc (size_t bytes) { From patchwork Thu Mar 4 16:32:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 42251 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 0A2F8389041C; Thu, 4 Mar 2021 16:33:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0A2F8389041C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1614875590; bh=Lnoe552cAouLjP5568gJPfkZlWj9qINtGzRjt1D/CC4=; 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=Q6vNDhCS96vuRicAMip/M+TDwyCTrnnkHhjJmeC2L4blBsT5ypWtcbD+W6v1Uv0H0 KDhZ/bEyUCBtYNZAa5AB1wQGKKAxZrsWq8UCdSTW+itJXANpWSUyjPkHbeo+pjF2/t hY2JK3Ss/MDqw9YFHWvYkRrvZdpMFpmsRx/NXprs= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20054.outbound.protection.outlook.com [40.107.2.54]) by sourceware.org (Postfix) with ESMTPS id AC3BB389041C for ; Thu, 4 Mar 2021 16:33:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org AC3BB389041C Received: from DB6PR0501CA0038.eurprd05.prod.outlook.com (2603:10a6:4:67::24) by VE1PR08MB5806.eurprd08.prod.outlook.com (2603:10a6:800:1b1::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.19; Thu, 4 Mar 2021 16:33:04 +0000 Received: from DB5EUR03FT051.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:67:cafe::99) by DB6PR0501CA0038.outlook.office365.com (2603:10a6:4:67::24) 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:33:04 +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 DB5EUR03FT051.mail.protection.outlook.com (10.152.21.19) 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:33:04 +0000 Received: ("Tessian outbound 72bd4bdd1f59:v71"); Thu, 04 Mar 2021 16:33:04 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: c75f31cd90f33d4e X-CR-MTA-TID: 64aa7808 Received: from fbd92ac607be.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 7E2353B4-72B8-47EA-AE0E-B400B37A3E86.1; Thu, 04 Mar 2021 16:32:59 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id fbd92ac607be.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 04 Mar 2021 16:32:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SQVebM927si/Jv5Bcu8QNx0uZrvMLfoQsCR1PLypsbshD/GZufxsAAnV5lTMrQedEKwWBGf28h7F9IsdU/MV9JZA/3fhToHmicKBvpzE7SBhoO42tdvZKhnqMbPxN/mN+Ldnulvgax/bTWi/M+uCElZPtIxzeUzvJBuu4+8UI/xDpGStTy/jUR2paWIOaWlODY1nGu6Ng39EQKNAvlkZJ71b0aEze8MKxx9EvD0JyKkJm7OcyF93w1kZYL7U09TX/6mS7K/vo7rMYWz2nTVY2ZZOWwEseuHshCL6HEactvRR9BlwIREOr/9/bDuwCcz/EmMjciTP2wFKWS2wfXt3nQ== 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=Lnoe552cAouLjP5568gJPfkZlWj9qINtGzRjt1D/CC4=; b=HV8kJmb/DH3XG1Tao8PPJPbujVN5dz1tER9aaGdtRjtGCJC8K0uAp0gbf+87xaSZE9SMr3Zs7ExxVX1wu1wnHYOqO9gAqIac5h0dcMYOTZuuXAIhOjFzpUguj3NPDeYpU4mTrAV0G6ZaqujGUAtuSlBH432jIaCCZZsQLvFMJhCcFFaHDATqrpXyQcdB7kbyu/7y8wFV5Ia3TUyCrcPUDIGQnbPVSxFGeKl5Gu4LePeZA/lXRIATsS+a5YFPYmqFv74HVQThp4v9TWvOY7yOUO/yVMQg1gd5TJhMRD1NtswF47oPiLrL+py1xzIe5bpjgcN/h8pdR1w247W5o5vA2Q== 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 PA4PR08MB6064.eurprd08.prod.outlook.com (2603:10a6:102:e2::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.20; Thu, 4 Mar 2021 16:32:57 +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:32:57 +0000 To: libc-alpha@sourceware.org, Richard.Earnshaw@arm.com, DJ Delorie Subject: [PATCH 09/16] malloc: Only support zeroing and not arbitrary memset with mtag Date: Thu, 4 Mar 2021 16:32:45 +0000 Message-Id: <4b85579387c095e4dbcc044042aa0f2dfdbd3a18.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: SN4PR0501CA0043.namprd05.prod.outlook.com (2603:10b6:803:41::20) 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 SN4PR0501CA0043.namprd05.prod.outlook.com (2603:10b6:803:41::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3933.13 via Frontend Transport; Thu, 4 Mar 2021 16:32:56 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 4c8e98da-faff-464a-3e35-08d8df2b2f5d X-MS-TrafficTypeDiagnostic: PA4PR08MB6064:|VE1PR08MB5806: 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: pB17M2XveD2X7icT5th8Qbdpxq4dh/IJBZeEAj1E6MX5fNRAyZvbETvA5kq7lVfa99Zo6dLDUgnrZvNCZ5EY5FcY/8Mw4nhynlfix+oV3j5vIaN1Rg/CtJa/htFSXVLav19NMGvYJPVvPkfMFqKDFjP4z7fuV5etJHNTwqKP6ofVSAn9oFf0vVQn3zxwH7yu+TfPleSSt92x/GPJT/bVnXKA67vyZXadbxtWXcgzVs6+is382Ls6H8Ot7YE26QbF9nNZtSe9CsfZsZq07QIxd44DWbdLyxVOZySI4oC+8m5J8E/MaX/G//ZLKTphhhLRIuUlsIHvTs8X2RC+YhjY2DBYD7Mj8DOGmptOn22MNQ72hdBEry4nMtYz8FBetQIbjaHQ7eyqaU3mq/ZltF8i+WbvLs3i/NdzxFewgDLkPDBe1SleEfJPdS0cLx5+rvtUYJUCoZccEmQtOp88qaqy+2Fu25wmkfZtgq1ooXwq7qc6k+SxGaafNkydCfdK19Rq+97pyMoUIONSgUWYilCsJrNM8i3Ztwhz0Xfltn1dWjM5pmK/T26LkVYEI4JERt17xy676Vz3GP6ydlGr5rNAYA== 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)(39850400004)(376002)(366004)(346002)(136003)(396003)(69590400012)(8676002)(6512007)(8936002)(478600001)(6666004)(36756003)(2616005)(52116002)(956004)(86362001)(6916009)(6506007)(5660300002)(26005)(6486002)(316002)(66476007)(66946007)(66556008)(186003)(2906002)(16526019)(44832011)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: DLxMQas0Sy9kPVXVDisBDZdQSVhrYeRxBKxb5gEmv4FNsJ6099zz9oyiTTOaEWKP82m1bqoJQ/sygaarE6IQG7i6Cr7vkgkwpTjMiGor8TqIwDRHwJih8HLU3rw8Fq/u6skmwrGYtoTR/bqNi1c+IOC4B973VEjILFAjygzRgGXcYCyvAvSwMH5hPNpE4j1o1cqf8epbRQKyhbC9/IBf7ejzSjzw/65xSZUW+EebYa9LCheQR1oFpfGPuSaQtHGcCAWCTqyNa1PuKWn42Icx+NiDKttqkjMVhcumGrMpPtQZI1BqPSQ8Eq4VQMuDMcDVyheunTwxwC2bnnu4mrrZ3tMuOFWEmbIwUwCN0BJnqx/As5hQBpmIQRvizEAPk17U/GzwP8I5RstDvl8SCUkAhiz7cePSHgs6PjUOHn7h0wcW8vNpQKnYxCM2fFsuY4BcG/XhRBb3MgzsguHsO4VlvgniOx5ezZGf4lIwTvWoj1EBi/kzqFOsliKujxMUMbYBbvU3IJnGmvjqeLBFu8eUtDYsj01eXN8rFU8Wbad40hXClGc5AACCbI1obv1nzLaUm+VZ369SmHQ5Jj76lJgWtPmBge3BImonC1p+HqC/OLzPijvb2GTx/Z7RLJsxSULnow+hYtMVrx5zu3c7F4SIeh2nbD+91HUNUd6WcoH0XpPSOkQlmCHwXCZrO73Zb5axVz06DD0U53XMBoatJQ7/zHTqVVTWty9iwX4nQFfMveeqi2a2hJuUMpNRG7IHAh7StiXB/31FlH7kGzf2IGMBfPqPhvcgHnwZCUQ8ahCvKS1QoJ4aaEuIwQIxu+39XKJ9+27xKVpizYaSjv1Ri0LDvew3IyAJm1TFO8keGk5EnhBd/bW54Ee+VwbWdqO3mJrwBMenMO25Uh8rYsWMCwatu6KBq2aDu0qxrreEJl3PSsXImq2l3Yb1JG5WT2jaiSj3cnyT6oUO3TFrbHrmjsdV2fMMp3zs2toLWfifR81NsIHG17+PLoNZPW6IPiMqQaxwsEK+3iqGPlwKNUsYkD877lL3MVuqkO5wvuPIy7vedud34V2qKT0EkCw+D1QgiTroQhq2v5/WhXVFMrL0U7wn0b3nYWPAIAQjbCkjtAsQpHbgtO8pAb4h0aoprDS00kbBPw/MNSTJQaR1QSVwgOfTtTQ7D+tZVLERklid+i06ZUDXZiAXviGBE5vFxagKNxxAVo6Pg78kYgthsnJES5j38L8QIOeNxPQA/U5FN0DmSZ5nak1mlUWyN09g3lOKPHmXFcYYsjdaGgusgGuS/DYALjm2yBuQjPx3NfvtKqMUGwObWt/DsZYKfq2gIaZ6wIeO X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6064 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: DB5EUR03FT051.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 9beb0f51-ac66-49e2-c8a0-08d8df2b2b10 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pSPK5/KuuPUIJx5d8BGJzeMShAQRlQ/yDOjRoyl3q4U4PHP9Syo5AAY/fEkRWJchMXfJI4Dz3GK4FcXBfRmXwRVzCVwgW0LGEXZRDHKqh3tnUwYwmgwJkBNbHju4iM56euT7eZ4CSBDQ2TAJ7qu8DXC6CvLmWvu2g1PM+8Pnl1XdeRVh7W1vDXebmk9bO0JNrDUp8MR/00ph9FyrpJ9/aBHIpr41ZuzSEFEmRmfvdabLnEwFz12ZHEeKOV43deyBP0/LXzuJWyX2gP/UlZitxOY834DqvvTIgKbFV7K7M7hpqUmpqaxVvTDsT+FZeRmQlcetaM+/Pbuj4jeetzp1SZw/+sjKpNaVlYAuwpkUJ5RJVDmRfWRBf5Ysb/EdkLF0Lzy14ym0jxHKCug/pe8XpqFyUbnCgu8tNGLwMPhq8IUV0/Qytshu3E9QKyvS4LOqWBaV7dMkEpfFBAjnjdTtwfafaeSWVarpd4KL2kvEP/hAy1fQJVwx+nnN14e2gKw11paMIS3yvZQxuDbSKbVVyZgdYNKNCQVeAqkiFKmpEz+7QSXoZQCYAQNT0ceyeju5TJ/sjLiB4q9rLpD8dfFzJww22N4r+SQVL7f2gmC/1sYxVnQGq+kk7rRKuuYMtsa2kzPwD+pxsnTbQ5rTeLhkkpNo+/ZdMpFz7Qea/+UjvL1e0waYO4oBm4AT6SpDBN4B 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)(376002)(346002)(39850400004)(136003)(396003)(36840700001)(46966006)(70586007)(82310400003)(69590400012)(6506007)(81166007)(316002)(70206006)(5660300002)(16526019)(8936002)(86362001)(478600001)(186003)(26005)(47076005)(336012)(36860700001)(6512007)(44832011)(6666004)(6486002)(8676002)(83380400001)(82740400003)(6862004)(36756003)(2906002)(2616005)(956004)(356005); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2021 16:33:04.4072 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4c8e98da-faff-464a-3e35-08d8df2b2f5d 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: DB5EUR03FT051.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5806 X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, 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-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" The memset api is suboptimal and does not provide much benefit. Memory tagging only needs a zeroing memset (and only for memory that's sized and aligned to multiples of the tag granule), so change the internal api and the target hooks accordingly. This is to simplify the implementation of the target hook. --- malloc/malloc.c | 17 ++++++++--------- sysdeps/aarch64/Makefile | 2 +- ...g_memset_tag.S => __mtag_tag_zero_region.S} | 18 +++++++----------- sysdeps/aarch64/libc-mtag.h | 4 ++-- sysdeps/generic/libc-mtag.h | 6 +++--- 5 files changed, 21 insertions(+), 26 deletions(-) rename sysdeps/aarch64/{__mtag_memset_tag.S => __mtag_tag_zero_region.S} (82%) diff --git a/malloc/malloc.c b/malloc/malloc.c index caf34843f7..9002d51d7b 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -413,12 +413,11 @@ void *(*__morecore)(ptrdiff_t) = __default_morecore; operations can continue to be used. Support macros are used to do this: - void *tag_new_memset (void *ptr, int, val, size_t size) + void *tag_new_zero_region (void *ptr, size_t size) - Has the same interface as memset(), but additionally allocates a - new tag, colors the memory with that tag and returns a pointer that - is correctly colored for that location. The non-tagging version - will simply call memset. + Allocates a new tag, colors the memory with that tag, zeros the + memory and returns a pointer that is correctly colored for that + location. The non-tagging version will simply call memset with 0. void *tag_region (void *ptr, size_t size) @@ -458,11 +457,11 @@ tag_region (void *ptr, size_t size) } static __always_inline void * -tag_new_memset (void *ptr, int val, size_t size) +tag_new_zero_region (void *ptr, size_t size) { if (__glibc_unlikely (mtag_enabled)) - return __libc_mtag_memset_with_tag (__libc_mtag_new_tag (ptr), val, size); - return memset (ptr, val, size); + return __libc_mtag_tag_zero_region (__libc_mtag_new_tag (ptr), size); + return memset (ptr, 0, size); } /* Defined later. */ @@ -3679,7 +3678,7 @@ __libc_calloc (size_t n, size_t elem_size) regardless of MORECORE_CLEARS, so we zero the whole block while doing so. */ #ifdef USE_MTAG - return tag_new_memset (mem, 0, CHUNK_AVAILABLE_SIZE (p) - CHUNK_HDR_SZ); + return tag_new_zero_region (mem, CHUNK_AVAILABLE_SIZE (p) - CHUNK_HDR_SZ); #else INTERNAL_SIZE_T csz = chunksize (p); diff --git a/sysdeps/aarch64/Makefile b/sysdeps/aarch64/Makefile index d3ab37a40a..259070cfad 100644 --- a/sysdeps/aarch64/Makefile +++ b/sysdeps/aarch64/Makefile @@ -41,7 +41,7 @@ endif ifeq ($(subdir),misc) sysdep_headers += sys/ifunc.h sysdep_routines += __mtag_address_get_tag \ - __mtag_memset_tag \ + __mtag_tag_zero_region \ __mtag_new_tag \ __mtag_tag_region diff --git a/sysdeps/aarch64/__mtag_memset_tag.S b/sysdeps/aarch64/__mtag_tag_zero_region.S similarity index 82% rename from sysdeps/aarch64/__mtag_memset_tag.S rename to sysdeps/aarch64/__mtag_tag_zero_region.S index 3c202888a4..74d398bba5 100644 --- a/sysdeps/aarch64/__mtag_memset_tag.S +++ b/sysdeps/aarch64/__mtag_tag_zero_region.S @@ -20,9 +20,6 @@ #ifdef USE_MTAG -/* Use the same register names and assignments as memset. */ -#include "memset-reg.h" - .arch armv8.5-a .arch_extension memtag @@ -31,16 +28,15 @@ /* FIXME: This is a minimal implementation. We could do much better than this for large values of COUNT. */ -ENTRY(__libc_mtag_memset_with_tag) +#define dstin x0 +#define count x1 +#define dst x2 - 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 +ENTRY(__libc_mtag_tag_zero_region) + mov dst, dstin L(loop): - stgp val, val, [dst], #16 + stzg dst, [dst], #16 subs count, count, 16 bne L(loop) #if 0 @@ -49,5 +45,5 @@ L(loop): ldg dstin, [dstin] // Recover the tag created (might be untagged). #endif ret -END (__libc_mtag_memset_with_tag) +END (__libc_mtag_tag_zero_region) #endif /* USE_MTAG */ diff --git a/sysdeps/aarch64/libc-mtag.h b/sysdeps/aarch64/libc-mtag.h index 979cbb743e..f58402ccf9 100644 --- a/sysdeps/aarch64/libc-mtag.h +++ b/sysdeps/aarch64/libc-mtag.h @@ -39,8 +39,8 @@ 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); +/* Optimized equivalent to __libc_mtag_tag_region followed by memset to 0. */ +void *__libc_mtag_tag_zero_region (void *, size_t); /* Convert address P to a pointer that is tagged correctly for that location. diff --git a/sysdeps/generic/libc-mtag.h b/sysdeps/generic/libc-mtag.h index e8fc236b6c..4743e873f1 100644 --- a/sysdeps/generic/libc-mtag.h +++ b/sysdeps/generic/libc-mtag.h @@ -44,12 +44,12 @@ __libc_mtag_tag_region (void *p, size_t n) return p; } -/* Optimized equivalent to __libc_mtag_tag_region followed by memset. */ +/* Optimized equivalent to __libc_mtag_tag_region followed by memset to 0. */ static inline void * -__libc_mtag_memset_with_tag (void *p, int c, size_t n) +__libc_mtag_tag_zero_region (void *p, size_t n) { __libc_mtag_link_error (); - return memset (p, c, n); + return memset (p, 0, n); } /* Convert address P to a pointer that is tagged correctly for that From patchwork Thu Mar 4 16:33:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 42252 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 0AB203AAA0B4; Thu, 4 Mar 2021 16:33:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0AB203AAA0B4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1614875608; bh=0IqPCVLQxsSVXWmXAeP93g87G4MYn4L/iXccraGKNXA=; 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=EPfx8BtMaSvmjHZuPavBuoxnhv6pR0jewOXtjgtWS7Lnz7KfQG0B17OaDVUC0Dnmy mOk4jQU6IWKNjJ+Clb5Ltzdm22/tfUPm61EPkKzIp9ZSh3ezLrwhtuL7FI4qfMJx/w 6azrHOy+1J/PmDQ0Do6GTyXVwH93B9acjH7cb4Ts= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30041.outbound.protection.outlook.com [40.107.3.41]) by sourceware.org (Postfix) with ESMTPS id 38E873892447 for ; Thu, 4 Mar 2021 16:33:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 38E873892447 Received: from MR2P264CA0085.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:32::25) by HE1PR0802MB2586.eurprd08.prod.outlook.com (2603:10a6:3:df::19) 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:33:22 +0000 Received: from VE1EUR03FT017.eop-EUR03.prod.protection.outlook.com (2603:10a6:500:32:cafe::8) by MR2P264CA0085.outlook.office365.com (2603:10a6:500:32::25) 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:33:22 +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 VE1EUR03FT017.mail.protection.outlook.com (10.152.18.90) 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:33:21 +0000 Received: ("Tessian outbound 751bd80b3146:v71"); Thu, 04 Mar 2021 16:33:21 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 5ba90073cef0226e X-CR-MTA-TID: 64aa7808 Received: from 88727ec62323.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id E6E82AD4-5E9B-4535-BCD3-B7932AFBD0DF.1; Thu, 04 Mar 2021 16:33:16 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 88727ec62323.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 04 Mar 2021 16:33:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JUwJoMp6XI/r0qNm5NixPpChpJ3anjit0w6lNLbjeedZXr5Wi1sXiovoB+/9bvmEaqaqnLavDv3HvixguGqd24NDqwRsgG3Tl7R2ZUDvjYDVMaH8OJe/9ZCR+GardxIlBNyjBZZeqytYLvRZkJn2B49gdlnMgkOu9oIk+fzyGMovCyPXaVeVPwvh9GRls0hc0bgP3SvHGNlfJ8Bv7OwiefmDGNVYe2B9NnCe20gmKR2Skbn0Rr4jH5B/yEntD3EPLgwAy41eKprojpJCw8XaW7/xf45V72ld7DLTWl8w2QIXCvZxHznicpXUKrPNhItjL6p8341X3NyiZkGnP+mA2g== 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=0IqPCVLQxsSVXWmXAeP93g87G4MYn4L/iXccraGKNXA=; b=bwg+SjUBzz412JoUoINPDtcnwZrmRxArWp9Vk9Wz7Uxt54UEwumzpNscuQ30LEkJh+4y2Ka8tIih+3FDGctgNRaXk80Qu6qf/paJnKdyb7+pxhhpK7Q82UnEWfTzK1mGtPPY1mejJxszY7fzzBzkS2hK4xFVBSJm+AKUhyiVVTEzUDAaDE3XodkAVJ71db9QPmpMkn6V1C5s9krrOlzMZe49SBytRrR+cHmvXi1JPQ/lQQhTW2JTs3qzbPjRNRwjDGEiZflmhiTO929kJDx9tHzeekX9ivSTlaUhzZrOvk1qqJAmdPU/pDleqoBkRGu6TRsZ7gD/tF3p5UrojXSkBw== 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 PA4PR08MB6064.eurprd08.prod.outlook.com (2603:10a6:102:e2::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.20; Thu, 4 Mar 2021 16:33:14 +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:33:14 +0000 To: libc-alpha@sourceware.org, Richard.Earnshaw@arm.com, DJ Delorie Subject: [PATCH 10/16] malloc: Change calloc when tagging is disabled Date: Thu, 4 Mar 2021 16:33:08 +0000 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.55] X-ClientProxiedBy: LNXP265CA0072.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:5d::36) 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 LNXP265CA0072.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:5d::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.25 via Frontend Transport; Thu, 4 Mar 2021 16:33:14 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 2374d7b6-c003-47dc-3a52-08d8df2b39df X-MS-TrafficTypeDiagnostic: PA4PR08MB6064:|HE1PR0802MB2586: 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: DDP+1ZTrZRyP9kRTa66DHuDGdY119CidcWBCR7OEIaAICBZaz58gcgXIzfy8BvUyPpw8tHtR3grcBzzAV5odnWlEJOnrsFp6ebZL9bFEt1k2uJ6wrkLDpOsGvSUWnNsi4KTbC+pH1e5yWfrCHG03JETRU59xuww6d3C93+OGKEmqeMEWFGtciNs4acS26Q6b5kJ4DgfUCdrWNA/1hKLPZH3c+tkJZeRorwJX0w9d64eOuR44xSHp4HK6IeEpzyxm0LXdCn0JYfP+wdhEvcxjuIdG+PqNlLk8A/gx1psItgSSvSPK4lo8T358IZLWmoLNA+I6NnH6hTv7vkb2p8TJav3hHv/PxWn0LZQ9yEmEHlKCtKjuB0UFT1rf1WYfqaLhYxu0MlxrKULu1PYIb67x8AoGxTQmY/ZAYV+JweRVzhpphZnsjrMuN2KeKJcvkUJyZTYtRseoVsaWg/a2etvgwiZ/UBSQr7BzR/6xpH65pr96xnhSaUek7aGTHT2W9hTU/cG+/iSVr5bEKl53J7PiSKSPrL8nHiagF5zkOdKue1IpCqx2XfICiRAbl8rUbLUkI40YUFKyMPFJVFhggOYUww== 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)(39850400004)(376002)(366004)(346002)(136003)(396003)(69590400012)(8676002)(6512007)(8936002)(478600001)(6666004)(36756003)(2616005)(52116002)(956004)(86362001)(6916009)(6506007)(5660300002)(26005)(6486002)(316002)(66476007)(66946007)(66556008)(186003)(2906002)(16526019)(44832011)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: oST/mv1UVrbKz3E3IjXnlrjl9uD6XZMThHAaOqKh6GHIlOJxnM/aSrzgO8QomOYswWbb2MNkDp749Nd7/qPcV/fQpB2KJegr6ODblTfAEe0XmYH8L2Kl7Ki7JXID1V1qQ97m2SRV+ld06o3okJVWQW6XfZSXhOW+HRexta2WZvgRJmopW9taZifG8zm19l4l/REC4xZ8LawKzlGFbumb+guMAeS4gzEpaorECLNs3A5JxtuXLvL1ZzSAxidvqnpPDbXfWm84mq1BSj5wTZPQVHIdNsAnPFCJ7PhV//+HE8oHMlXIXzqK+4D9kUxmCNS1dFjG5pG8fMOdd8lvRzwkklB8azprv0tEtCxBvR8grbnYRGvmaGe1bRg87Q6I8UiQk71vEHQoEa8Z43MM9Fi6iYOopNFV9+bQ9fgeGtke0oGWIDUlzxk51FfiBqUQVAfBKNtG9KnLGu+WCKGgWVjvW+9fetmQJJyiUjfSh3uJKA0feFB5fZgM5tm5Z3/Wl8ebXDENeDhuvIuZm6Dn3/s68AYI32Zwl/WW0XCnT90Az6HZfU2eRjC8dEeXlNWNJRPB0pz4r+HwwyIKL+wrqMF8IwEfaNpmNeR2A7xJ7+Y40SCkitLVHGxADRqrbrF6LyYFuCnL4eBLun6q7bjgzm3b8jE8jWBuxfkp0z2PKoiT/4esAja1btBeFq1YQIONgLOZSsh9HMIQ7Uf48pt3uUx/UlR9NX7CKq65k4DM8e15w97tBdI2h0XvniHiGQTqV1YWjHpKxW1yUx1HJejOVTuQifw/+PMe9FQvp5e0E0Fe307ekPdpDaj41cP0+tCl5JyT27d04irtEBpjY+c1Kzwp/4tercab/faVyenwkpYldnRWXLgWs6v0GbnMPBcu3UOFz+ygcVS9yMR/3hB6lz4b40o1mi9zgxq/NTUFHWth9NzWNgqEneuZLrBevWFGUfL+0wX1CaGCg9cHFd+OpO1BxRqNrmTYIb8ETW0aYpZ1x0nmVLlGXQCSrRj4TLu6L5FR910bMvwLZyV4HJ0x1WeR2nyKfUpAw3Zj8ljUC66sSpke65C9TMPCKnWAfSEX0gBJZRMUhM7F1mc16gly3jQ1dwxo82ZSbZLRndQ4bsuk2s7WrP/xSQnEB5Qo6QcazAGa99zHb6azjJGVqyfSnDS/uKkZpH+nTQTqeSCC0bh2St634L5pJZy8m0p7xH1paL1yh4jCvWiCztaRltoYvNa+MbtL1Z2iiA6vyvmwwfYdzBXTufAqXWy6HWuQtebyI3FL2Naxv+1QBS4KfObb1LWznxhkzW5oe7arT2IUHJrkp+afrsnOlE7gUC0UUeLqg+v9 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6064 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: VE1EUR03FT017.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 280326e1-e40e-47b0-322e-08d8df2b3540 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: x4ZuH+yvuKxY1FjZvYEaHx8+Sf2HCB+IIpUL3cTsSHhASQSGiCSxhS7TXwiWzaMARjn3jn0qbXaSonVsT4V9BO5j4nGW8zZ7gjbdIuF+tF2STfSUA3Foz1jCN13lifxvXpC9q2y8VzhyPmLrJz3nKlUezgRqFDq2m5RcnKui4//gd+bwMXvda1DLWjMVmItbBkvJmg1eZ1oArKbiU/P4/KJMngxqnhRvwOo+FcANFxU58vxbyzfhNcy1Xjlqlc6hpEhzdDoD74eXbKQvmch8DF7VoRDyniNgbBN1DvoDmwJgRipsUYVDGZuWkL+kf6JIte9x6l8xgwlZ09v1NT3SYz8pChjpUK0nHjEe//S1RCEgjiZPN444qtyRCpohMPFrC/v1BW+cKdOGPSRqQRaIL9E/h0RfpZ6qNRszPVG6VuQeUFcN41VU27DZPVBb3GzbN58i/ERP5DlBQjZ6GIe+hsdE8UY/HUtbvFc54xYJLZvz8jocBQXVXAE1N7+SZRK1KobJ0zfhy9G2zDa8VqMWHhEuMFyAS6e3DpT7Yxhdnrq/WqBnxiiwpy5pMzgh2y4xGZtO/1jLw3wm0stwEJrinyM/sFZnRjnqbvE7Aa4oD335YDHoQsJJ/mV5icfrvGUobFdSdtUD0O8yCNU50JzKaeLNPcggdvD5purUQs9qvan6wG4yPTzC4DnoyiBT9WL5 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)(39850400004)(396003)(376002)(346002)(136003)(36840700001)(46966006)(36860700001)(336012)(2616005)(6506007)(478600001)(956004)(86362001)(47076005)(5660300002)(69590400012)(36756003)(8676002)(16526019)(70586007)(81166007)(82310400003)(8936002)(83380400001)(6666004)(6512007)(44832011)(70206006)(6486002)(186003)(6862004)(26005)(2906002)(316002)(82740400003)(356005); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2021 16:33:21.8724 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2374d7b6-c003-47dc-3a52-08d8df2b39df 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: VE1EUR03FT017.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0802MB2586 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" When glibc is built with memory tagging support (USE_MTAG) but it is not enabled at runtime (mtag_enabled) then unconditional memset was used even though that can be often avoided. This is for performance when tagging is supported but not enabled. The extra check should have no overhead: tag_new_zero_region already had a runtime check which the compiler can now optimize away. --- malloc/malloc.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/malloc/malloc.c b/malloc/malloc.c index 9002d51d7b..b1ee0f450b 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -3591,11 +3591,9 @@ __libc_calloc (size_t n, size_t elem_size) mchunkptr oldtop; INTERNAL_SIZE_T sz, oldtopsize; void *mem; -#ifndef USE_MTAG unsigned long clearsize; unsigned long nclears; INTERNAL_SIZE_T *d; -#endif ptrdiff_t bytes; if (__glibc_unlikely (__builtin_mul_overflow (n, elem_size, &bytes))) @@ -3674,12 +3672,13 @@ __libc_calloc (size_t n, size_t elem_size) return 0; mchunkptr p = mem2chunk (mem); + /* If we are using memory tagging, then we need to set the tags regardless of MORECORE_CLEARS, so we zero the whole block while doing so. */ -#ifdef USE_MTAG - return tag_new_zero_region (mem, CHUNK_AVAILABLE_SIZE (p) - CHUNK_HDR_SZ); -#else + if (__glibc_unlikely (mtag_enabled)) + return tag_new_zero_region (mem, CHUNK_AVAILABLE_SIZE (p) - CHUNK_HDR_SZ); + INTERNAL_SIZE_T csz = chunksize (p); /* Two optional cases in which clearing not necessary */ @@ -3733,7 +3732,6 @@ __libc_calloc (size_t n, size_t elem_size) } return mem; -#endif } /* From patchwork Thu Mar 4 16:33:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 42253 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 A542F3AAA0AB; Thu, 4 Mar 2021 16:33:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A542F3AAA0AB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1614875628; bh=kBUcnFjZricgm0E4t6EsPdSBCvOWMltky5W3meiCiVk=; 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=KaFzOj4FBLovzt3o6Jhbv8O+pLjwqPnBTHbGCSbquyLLhtfOVITdsD5OPl/lny7Sl DwGgxDk0t9VhOK0jy2t8ZuZHw/nJtF5IwGtGsZ+mIpuISyjCqJ/j3oNsobHnxmEFge S9lYu1sElcJtnq8zBCQmQtKxO+AMD7Nm09o6gdHQ= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on062c.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe1e::62c]) by sourceware.org (Postfix) with ESMTPS id CA3E3389041C for ; Thu, 4 Mar 2021 16:33:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org CA3E3389041C Received: from AM6P191CA0008.EURP191.PROD.OUTLOOK.COM (2603:10a6:209:8b::21) by VI1PR0801MB1886.eurprd08.prod.outlook.com (2603:10a6:800:8b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.20; Thu, 4 Mar 2021 16:33:42 +0000 Received: from VE1EUR03FT011.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:8b:cafe::98) by AM6P191CA0008.outlook.office365.com (2603:10a6:209:8b::21) 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:33:42 +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 VE1EUR03FT011.mail.protection.outlook.com (10.152.18.134) 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:33:41 +0000 Received: ("Tessian outbound 155e15b2e217:v71"); Thu, 04 Mar 2021 16:33:41 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: cbec6ed8ce047976 X-CR-MTA-TID: 64aa7808 Received: from 37c15e2de80a.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id EF7450BB-B3F2-433E-9205-BAF030799083.1; Thu, 04 Mar 2021 16:33:33 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 37c15e2de80a.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 04 Mar 2021 16:33:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DzORoJ9W+t1sgwb1S8Dqii+XoSrQ8OMui4npZm2J/XUeTKOItJsGeaDdnVidqza/JVdgzUQxLEhvm/+/DKqldpsA9bHVIWC6yw+kva7an/zZgc4+XaRy6XQDDS1gtFei8ZSEkjCPvOXTUKrhWqzySjjmXHd/FniGle52W3DUCVaCOM/uAxMPVXDWMLL76vclsUVsSA0Lj5/w50Ur2F25JusSYn0/g4A7dMnq62ybIPlLlg9fqL0j04qSgcGf27NYFWTk2hZFShJZRxhkXjQyMnzFPGmSPllHxEseqoIpkS9EsYd1Y4M/a4zZkFsfmlpFsaquqa4uOQ96Ii9pS29zOg== 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=kBUcnFjZricgm0E4t6EsPdSBCvOWMltky5W3meiCiVk=; b=CLq6hc9xiK5dfNvmLoe90xmztnzBvW/NusZdeQ54pOnA1xGv1cL1eNbQcL+yzNHGwsP73xI5Z5i4eQQhZEoltwdbH/6dhoaBLXpspR4dD7tnmLSr9qxqrdQFS8IWBwCr8GrOs1I2yTAL2C/YoE2lQ7MLi+XqARHbh9KsOPhhsuUDCIlGOtKSYy9lx2hyDYd5aJXcVwjg9Bto7nP2YhWIxGdnG0ZlWNwhwgCpNmBiVMQlHX+EdVzSuBopwoFcUofuq/+zQ1XZdVpZO7qgSSlr77PIQYxvLoh1TUs39ErfLwdtay2wpim40sRWuKtZf+xN9LNxO0uo7FIqq+lO9JPZ+A== 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 PA4PR08MB6064.eurprd08.prod.outlook.com (2603:10a6:102:e2::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.20; Thu, 4 Mar 2021 16:33:31 +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:33:31 +0000 To: libc-alpha@sourceware.org, Richard.Earnshaw@arm.com, DJ Delorie Subject: [PATCH 11/16] malloc: Use branches instead of mtag_granule_mask Date: Thu, 4 Mar 2021 16:33:25 +0000 Message-Id: <93b2191bf171072a519f19e9f8e763af9156213f.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: LO2P123CA0106.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:139::21) 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 LO2P123CA0106.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:139::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.21 via Frontend Transport; Thu, 4 Mar 2021 16:33:31 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 82a70303-a8ed-41a1-0d84-08d8df2b45d8 X-MS-TrafficTypeDiagnostic: PA4PR08MB6064:|VI1PR0801MB1886: 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: N2CDrS+mJYr2UqQ3i4dtLuwZDehNFCy9qinHMW3m+zduR9a6jB4KxyjWZi0yR/YrCQehFOrqqYvrxUNQuSAlY4cFBYPmI6afk1V/aLYKsEGkU5WTEgeuXIgMwCw6to4iNiQd9+wWaOKeUGjt85tLGKePXoHpv+mQ1/hG9/JD/CdFwBJLA9UFKnFSjpGp1L7ek4JO3A1kZIalbIMVGGnjPDWXOEUNk1n7gF7xzLS3XaLljgCQOJ3yvMsX21jnBkrhfXvVMIKJpy5G/CPX0XgpsAn2Ypv8Y9gj9pxUNKoMbyaK8dSFjC15dkd0o/Q6fv4/wIWQO5kCzqr+GuOShJ6YstJiNEJCyL6PQK8TuTzVaIkklqwdZWi6cmxU6XRXJfBYS3i21U5/COdlX5QzMi00yGNxSRzQM9tnjgXcFlDD5TPSrRtEYV0RJADv8l7gr28xErZEPfIpC2otqrHu/KHk6lCx2IO0ESENFyNk28crbycE0B8CcAJM5tQnSI+VQD98ICac+NlTDP+pxYbYOxgHLby70EEhbzq834C31IOLP2l6/asXHnAx9QgPlyG8Dw4hWPjD+Qw8nlTt0RG3DGNf1Q== 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)(39850400004)(376002)(366004)(346002)(136003)(396003)(69590400012)(8676002)(6512007)(8936002)(478600001)(6666004)(36756003)(2616005)(52116002)(956004)(86362001)(6916009)(6506007)(5660300002)(26005)(6486002)(316002)(66476007)(66946007)(66556008)(186003)(2906002)(16526019)(44832011)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: fbjyrtTHKBlqu4vKmUVaDLIiiMmKmquqJESGIhjDn1jyS9BxQRUIzjJkTb0rKLPABEbZb8aW3iFDm1uhOmraY9vdjsS+oH58ZuizoTxRBlu94eycDiG6kWTuRz8bx/PchQ9sg9fedTqBEIJavTGaWZFDvta1Yd53sulWmN/nqQYnvps+hMJ84tglKyParrYqYvOGau9kmZjqydWYk3fX7mzrndyHz34yrULkZ7J6WdV1fbi8SytsFPo5fE94/FAwLwmA8F78HA9/q5H/AabocO4iCZduz64rmDX9cLLfVMPoQL+eAlItc117XBsx0VAGpq6EAS19Wns2xiSRzUw49rSTwaZDwwSY4HUy06holroFh1q8CDBtbOgWt1We+O9kBbGgpCvKHYSPmU0f8d5ZPI/BIBcMDRmY21WIh+AbZp08XRMmraM+8KBYCPteDDZtIm1g4abUubfiBAiuoMq+WWijiOrvjLiAN2uhXJtJF6jNwJuWceh3a8vFVkrIzNq75jk8d7GvhO4NzCCk3bReBxHiGz0mROLcv9Wfq5EFMLtP4/4AFQPY2T9cpgrYhniIEBMgP7wpYrPV4FQZ4+6LE6JmlzFMyTAKgFiKskpmUaJH+FrpVUC6LoAQiWK48aSLxC4U6i/0QwXXs64JQ7KRikNTY27SLOSGd7OHwHItoC6y84xmWc8vReLrpJRIUbF+s1tdeUQps92KYYCleEBykcmLoo2IDPbloaVZXSwdueOMJWevvztpKhYmMFLs639ffsyzVNYcFnA51qAUFAvBN53TnSoXFSsmCyEFldbL9PrYOmqN5dQ4k3A9NnwbshUX6HjHGYBb/yEi9aF0wOR8x+KjHXqyjzrcxRiwuLbfr1l7LtFzgjHsxp3PXT3YGTJLii3MNgpUnbPELmK9R41/DiSwVvp1NchqZSON+QP2+xtPlgM800sxGvXBIky6DLGmYoYCPN7rDQgHY9CNXJe/ijsw+IDO6MfEVgOLVxkAOsuO66CqwaqPfPTdELwqUmW3My2RgN7wmsib2GA/0/mdfTWt+7hTv9yD2Gqr9D3z8sAqCU+6c8zN1qwFT5CtehO8Ld2GH9hQnzg+Ck2bwNHVUaZ8dVzLWVaAvVdBDUWiVL+NTpNBswqKkYqudp8dRBtv73zOt4Jr8IXeo458PeAd3c/8UZeglFf/lYSRhY+7O4vIoLA7uoQZiTQgXUGzf0ecQ/yNaL4OEopq5C+iJU/HNqiKU6ZqG9aVYYG6wrSHkuY2w4VmRHIAf0TsOo1a3oILR2tXHiv6VN215kJbI70muYfFMWv5uDwBVpf1czXSHGillzEY5Z2+K0G0YDo2S77g X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6064 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: VE1EUR03FT011.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 98cddca2-50b5-4bfb-a93c-08d8df2b3f83 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SRTajAeRK/rosDgD21k0qwVgPQyft1afoVGAn0Z4jki2q7+KJgn1qMsuUZX0stQkeos5jvO6pCRZW89yQ25olfegwRKJX9GyNY7ulgMq9ZlDCxSKLqmMURJ2zAiVEx0dUkn00aYNloMsnCtGWjkcsKlq71csmOx0QMvy1ylTvrgsPmXtB7e37z8Mu6/YDXl2nNM34Scf1K8nmfHdQEhiz9Qgxp/x5am3PCCLqEkfC/nrRr11kMTgmAfXAjRvSK3AYgteWeVPlohBIUJ8To7c/cLKXX3kPUMLYYLS8OgTX590iFZHXGLzombPPoa18VssmZWnaaUimaPeXAa77oq0qlXrsy7rffUp+m1ZMb9xeJmeYXppRG36sYvRZLLjTP1gMpO84pue9qkGlb7a2rd6JQeaoAffRSXYxDAFnJuuchNE+BM7dTtB+JCigobbiQjB9iDxHA32mt+22MkqZ33V+pJTgbRkc3pGY99YEZjda4/o1K0GQHyCwon1sLuYdRj7oe8w8GFthNJUTcSrtyahOH8blVT2uP4voneTPCoIzbHwgRp/g2KYLCVqyQuU8dgUsYWHemjj8TMVVD+QVea0rZ2jL0TAuwox39PHOto2UBpsGLkg4dA1wYvZrieZYzX1r6LYqeLt6iZJvcn5Jk8VxoOZ9tExDkd3asS4Db+fIiFLM19s/XF7akTGWk3OSQal 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)(136003)(346002)(376002)(39850400004)(396003)(46966006)(36840700001)(82740400003)(82310400003)(70586007)(70206006)(36756003)(316002)(86362001)(6862004)(356005)(47076005)(83380400001)(81166007)(8676002)(478600001)(8936002)(6506007)(5660300002)(44832011)(16526019)(336012)(69590400012)(2616005)(26005)(956004)(6486002)(36860700001)(2906002)(6512007)(6666004)(186003); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2021 16:33:41.9940 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 82a70303-a8ed-41a1-0d84-08d8df2b45d8 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: VE1EUR03FT011.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB1886 X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, 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" The branches may be better optimized since mtag_enabled is widely used. Granule size larger than a chunk header is not supported since then we cannot have both the chunk header and user area granule aligned. To fix that for targets with large granule, the chunk layout has to change. So code that attempted to handle the granule mask generally was changed. This simplified CHUNK_AVAILABLE_SIZE and the logic in malloc_usable_size. --- malloc/arena.c | 1 - malloc/malloc.c | 34 ++++++++++++++-------------------- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/malloc/arena.c b/malloc/arena.c index 1e83bb66bd..9fbbb38a15 100644 --- a/malloc/arena.c +++ b/malloc/arena.c @@ -306,7 +306,6 @@ ptmalloc_init (void) mtag_enabled = true; mtag_mmap_flags = __MTAG_MMAP_FLAGS; - mtag_granule_mask = ~(size_t)(__MTAG_GRANULE_SIZE - 1); } #endif diff --git a/malloc/malloc.c b/malloc/malloc.c index b1ee0f450b..8854afec88 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -442,7 +442,6 @@ void *(*__morecore)(ptrdiff_t) = __default_morecore; #ifdef USE_MTAG static bool mtag_enabled = false; static int mtag_mmap_flags = 0; -static size_t mtag_granule_mask = ~(size_t)0; #else # define mtag_enabled false # define mtag_mmap_flags 0 @@ -1333,15 +1332,16 @@ nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ((req) + SIZE_SZ + MALLOC_ALIGN_MASK) & ~MALLOC_ALIGN_MASK) /* Available size of chunk. This is the size of the real usable data - in the chunk, plus the chunk header. */ -#ifdef USE_MTAG -#define CHUNK_AVAILABLE_SIZE(p) \ - ((chunksize (p) + (chunk_is_mmapped (p) ? 0 : SIZE_SZ)) \ - & mtag_granule_mask) -#else -#define CHUNK_AVAILABLE_SIZE(p) \ - (chunksize (p) + (chunk_is_mmapped (p) ? 0 : SIZE_SZ)) -#endif + in the chunk, plus the chunk header. Note: If memory tagging is + enabled the layout changes to accomodate the granule size, this is + wasteful for small allocations so not done by default. The logic + does not work if chunk headers are not granule aligned. */ +_Static_assert (__MTAG_GRANULE_SIZE <= CHUNK_HDR_SZ, + "memory tagging is not supported with large granule."); +#define CHUNK_AVAILABLE_SIZE(p) \ + (__MTAG_GRANULE_SIZE > SIZE_SZ && __glibc_unlikely (mtag_enabled) ? \ + chunksize (p) : \ + chunksize (p) + (chunk_is_mmapped (p) ? 0 : SIZE_SZ)) /* Check if REQ overflows when padded and aligned and if the resulting value is less than PTRDIFF_T. Returns TRUE and the requested size or MINSIZE in @@ -1353,7 +1353,6 @@ checked_request2size (size_t req, size_t *sz) __nonnull (1) if (__glibc_unlikely (req > PTRDIFF_MAX)) return false; -#ifdef USE_MTAG /* When using tagged memory, we cannot share the end of the user block with the header for the next chunk, so ensure that we allocate blocks that are rounded up to the granule size. Take @@ -1361,8 +1360,9 @@ checked_request2size (size_t req, size_t *sz) __nonnull (1) number. Ideally, this would be part of request2size(), but that must be a macro that produces a compile time constant if passed a constant literal. */ - req = (req + ~mtag_granule_mask) & mtag_granule_mask; -#endif + if (__glibc_unlikely (mtag_enabled)) + req = (req + (__MTAG_GRANULE_SIZE - 1)) & + ~(size_t)(__MTAG_GRANULE_SIZE - 1); *sz = request2size (req); return true; @@ -5112,14 +5112,8 @@ musable (void *mem) result = chunksize (p) - CHUNK_HDR_SZ; } else if (inuse (p)) - result = chunksize (p) - SIZE_SZ; + result = CHUNK_AVAILABLE_SIZE (p) - CHUNK_HDR_SZ; -#ifdef USE_MTAG - /* The usable space may be reduced if memory tagging is needed, - since we cannot share the user-space data with malloc's internal - data structure. */ - result &= mtag_granule_mask; -#endif return result; } return 0; From patchwork Thu Mar 4 16:33:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 42254 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 3E4493AAA0B4; Thu, 4 Mar 2021 16:34:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3E4493AAA0B4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1614875653; bh=0x6QH0gdG7FbKNEIO+rktMd0OWMCaZlZotP1g1yjI6w=; 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=DSaxy+XoWUrZiFi9lnVv0pco7UEQvv1rFOGLRyByBKYsiI91ek+ZAJu3ZUzvEK+FE 7caCQSEwOyDOeFxgqVBu3GKitCIpgi9hFCMHiRQ7gRn0EVmvfekBAQcV0s1k4hVwss 8lNtB9xDI3wjI8e+IcXaE1NjNOCb849fP6cEorXU= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2077.outbound.protection.outlook.com [40.107.20.77]) by sourceware.org (Postfix) with ESMTPS id 325A9389041C for ; Thu, 4 Mar 2021 16:34:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 325A9389041C Received: from AM6P194CA0103.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:8f::44) by VI1PR0802MB2573.eurprd08.prod.outlook.com (2603:10a6:800:b1::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.20; Thu, 4 Mar 2021 16:34:08 +0000 Received: from AM5EUR03FT007.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:8f:cafe::b6) by AM6P194CA0103.outlook.office365.com (2603:10a6:209:8f::44) 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:34: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 AM5EUR03FT007.mail.protection.outlook.com (10.152.16.145) 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:34:07 +0000 Received: ("Tessian outbound 72bd4bdd1f59:v71"); Thu, 04 Mar 2021 16:34:07 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 113c3f695b541930 X-CR-MTA-TID: 64aa7808 Received: from ade1f1872e22.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 8217145E-A6A8-4D03-B798-FB8B39F66FAE.1; Thu, 04 Mar 2021 16:33:55 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id ade1f1872e22.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 04 Mar 2021 16:33:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gmwrVmhDhdyB//T3kSiba5ZsjcsCv2pUA9o1Y6BKno88o5VCDjbYDQRM9rv3boLg6EdjSEUmK6hqQ7tjtsx/DVvMXYi9PW2L1fGY+Hf6paQLua4bJ2WQU3pCMg40WtqBFVv5Q0Sq5byMEW/s/EpvZDrZ9WR8R3qGN0xAVJQCTNSwSP7/DmmEOyoSFSmgL2500tGrQgqpCttwc1+rhS2iu9qSofAATYgvlcxKsuxsPXt3TRMrYGV9kVvjTd0Km8GnumnvYKLkuczxYaYWQkLpzBbMNDhrbUjAf+xKnm5hJuYloUuhFJPaQXTrHUIuI+hiAiegXY2LzQO/ePdfsXkM9A== 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=0x6QH0gdG7FbKNEIO+rktMd0OWMCaZlZotP1g1yjI6w=; b=LQnzfxGlixH9dmdK7WgOQvuufgiJEb9jiwI+ouExIdXxgyslUWTCAwWVUwfzJ8fZL8aqIU4CxIjkgqMuzez4WLWnST0tv4BmhN9gkFujjTmavjYUtLdmdNFbDrJ9TranPvAu7aojynglMKHExH6MIo2UakNFpOxG8V31LItWYSvKtl7OttzqLJ0FRcIYXh9c60F/QySZvMtsf/iYMY874N+4JZTqfxMC5Nj0z2ZnJhnHLjMq8M5snjwAzgzYj4sYvbVuePOKhn9r35lL5hRXV79SdD8VX85flWfkNpOAXmZBBQ9HLx5EYRP73VfAZBWO4+qw4vhKYTmJeYLxbsQ5Wg== 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 PA4PR08MB6064.eurprd08.prod.outlook.com (2603:10a6:102:e2::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.20; Thu, 4 Mar 2021 16:33:54 +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:33:54 +0000 To: libc-alpha@sourceware.org, Richard.Earnshaw@arm.com, DJ Delorie Subject: [PATCH 12/16] malloc: Use mtag_enabled instead of USE_MTAG Date: Thu, 4 Mar 2021 16:33:42 +0000 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.55] X-ClientProxiedBy: SN4PR0501CA0082.namprd05.prod.outlook.com (2603:10b6:803:22::20) 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 SN4PR0501CA0082.namprd05.prod.outlook.com (2603:10b6:803:22::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3933.16 via Frontend Transport; Thu, 4 Mar 2021 16:33:52 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 6fb5957d-014a-4b85-2b7b-08d8df2b5542 X-MS-TrafficTypeDiagnostic: PA4PR08MB6064:|VI1PR0802MB2573: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:9508;OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: x3wkPQ4KDYfOtAsWjZVjsfl1RfV3dlvZCBKSyLDC7sVM7RKMbcNpsZJ9qzvzSVJx2An4MTHtx9yb62ZPVk+2l79rSY7XzyOfNKquiwWrEgwqH1U4z6D17xCgPgCb9UOqMeWh9y9Ep0PVhL+ukVqXyKFzGlr5SII5bE/vL3DLyWrCwPuxJ5N9MmvrMx9nv+kDhztPB6m8Xpxh/3XRrZNfaKPAuMzQH/m9IwOcOi4RC0LgVSviTTOXfDV2ZEFeIPyZUNTpB+yh2coTfyw4NcB2+3Spk2ynYx/1KiDt0cTGYOqwdko/b+wpmfyTpWvzByhzmseB0bcZ113AbM4XdAg00P/kCvtQGiJOsq0u5AIMojt2wE1lz6nWTe2W86+aGKSihyD2NP/+367cKeiaZydmYXOS76/CPCOv4O91wjCJY+YJzg4iCyqAiMBBPM3IsMSO5C6LcbFdS7Yh4pjKRrmxePQW8gWGyldaEuk9R3DfyVqfSYMut11kd/ls/rEPezFpH3mHvUk3ZVgsQoFHkgYd1QyhPaYrAAo9/T+DxmysyRQJ2VAwZTyN6+v0VZYNpOTD5B2Xgii5PU4E4J6LY8GXyw== 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)(396003)(136003)(346002)(366004)(376002)(39850400004)(66556008)(66946007)(66476007)(5660300002)(6506007)(26005)(6486002)(316002)(83380400001)(16526019)(2906002)(186003)(44832011)(6666004)(36756003)(8676002)(6512007)(69590400012)(8936002)(478600001)(956004)(86362001)(6916009)(2616005)(52116002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: V/kQSfFF1qQ8ge8PO07EqlvhFfDPlKJohoY7TLvpzmTy4xoQPJ7UYojylVPT2xTn4NW867pB9Rm6AVrZ0q5+xmkfAW0VYLtCjZwOQWD4/19H5Y9sDeljzFsSvfStyH/iBpOl6pRV6PfZCYk+5K2Rfw5bXqXnCUAnIKXpDDJk7i/dBH1MuKgoNCN2KPL9sj3FsQZPsrme7yUDlsK5ilo68wNvtHa/5NJxBGzDZHNrYBduNIKTvSAqatvSnyArCGHJbvg+SfX1Kez+/J1bvLZfFgxVXHN4v1isjeychtsp1XIjKmN7tDqMrNfFP9L8dtTMiDcIKVRC+pf1gj+z52ZM9X1veCNNBJB9ATCbm/5Jo3Ix84F02IRFmtP35677kuNK5rWRf6v48fY9y1bDVEUxx6y894d6vkBbxFk9fmsooDbSJXoVvEhqbJkva+RkExFtuFiZ6CeO0A/KYwEngGxH+gr6dJm4KRSEQXvy5MeZFFKr0WdX9O48JlIU9l+HLrb2q4K/hio0Qd+lipRuqHlil0UEh+t0uRGFXZAMcb0gpB4TrAZ8JfE7q2LIf8e943KFADcEfIp8/1YMLWssYxQcR5L+EGpIN5cSTEvEYdCjjJQDR7ubEHwkj91bdYexjRCrAPNCAWMLbRyB/ra3RydqUb3wUAkwtHk2iXKHephq7ZZzNS9rzodmkVOCR15eGz396/3EwargAf0rr4UfkAEpHbAc3d+0kthXBGWZFE2euPk81gD/oL04c7R4qQBQJCoeujEHDwg/WEfnzK2Y7N3lvGvrWqAkJgddeDhGbMFJjnqYHjG+WxB2HAuR9eIa86swYTomSPXMPY1Iv0NeyKD144B0JFOS3Q1ZscigWOLTLFvG0h5gu9v70WTW/XYPogT0Y7T9sKO8ThrR6wP2AAdcdPSjsIbg/yPeOK+++Nr06kSKnHR3fDseDvpbGkZiafXyrffm9KMhdU+E4Ia1fctVzIP4WEuTeleNfHMK+2G6v71UuekFM/mUjatE606liziK3Ik/ilUlGPA2Ks1tD4SBWsYpo0/sLmfLip4uF06R8ni0fBg10O48edPENiM7O8yArbdynQglOxfQ68myQusWYHOWcWCeSdWX9uHNk3nM5hHyS05QOpqBQ8pYHNHSh8yLcnY7tGJPU5qm8ae8m2r1z3XNlqA9TPT3cA22g8HxL7bzE9EOCzi7KAS/pzpAAU2+sUYR5EWSowiS/Qrk+1G35n5INZKykmr2483Em9f8aBCQugqmtch/tb8Ntj0lJCf5tBEpcMNNUjHmG3m+GuuMz3ikcxyIzGSBAakMBdC3DAj8hJTv6e1E3M9kpRH+ka0t X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6064 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: AM5EUR03FT007.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 307c66c0-2820-414c-4670-08d8df2b4cd6 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zahZONi9zseGfu9+QH4GO8OY6fsq5mhW0OpFO1PKRiV1thxUujF4IoyrysLt5WprUO0ghWt0MTegdgDJgCISQyRV3EXR6CMkdaUcUjjx82evEKepKV7K5QpQfuLT9n5akiuTkGzsuNQXPI6Se3gOMv2imC5sW0l2p04HA80jVWPdXSeY5KLTbH5aZadyAtJkU17kaY6Dl4yJHUhg4vtnBbvVICziEmUG5GCkkNKARVdNgrn9eomqWJDyKoDs82H3FGOOfdgzbnlu6kNJGjQB3Ra600RzQGm1btRmY6FpPdt2EwLzBvsZo3//apfJ81b9MZukpcJ+gK+LvEnW6EKlsjZevzqL04MKhhyAyF9hhLzM1zN1Haw0wdldPpO1vEBBvieI4MtCb9VHtAF2/jdwgH6rcHecDX2QTra1XsLpAj7LQyDR3y4ExroHbLdYIljk2mOdzZO5DIUMtu5RgYQhCYFLvqW4txCGWOcoDJflEABgHakkFSvulKLWriefgAWB/tfQRgzmkiUeyqGBqqjhkDxHEnk6MM3fyocWRa55gyhmPDODna+8LqkXBziggqg6c0eVPtmEEufYY2hPWllEbPGfWlR/a8YTNDA4r5QFzCIe1bipqQusLeVtozy+C6TsiayPZIhJmTnqrKC+hXKrltVZdTQRID2qZxsfNTIlsckbbQDHjwDaowsL/Dhvw0wx 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)(39850400004)(136003)(396003)(376002)(346002)(46966006)(36840700001)(70206006)(70586007)(81166007)(6862004)(82740400003)(478600001)(356005)(36860700001)(6506007)(83380400001)(69590400012)(2906002)(82310400003)(47076005)(26005)(36756003)(86362001)(8936002)(6512007)(316002)(6486002)(6666004)(2616005)(336012)(44832011)(956004)(8676002)(186003)(16526019)(5660300002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2021 16:34:07.8873 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6fb5957d-014a-4b85-2b7b-08d8df2b5542 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: AM5EUR03FT007.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0802MB2573 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 the runtime check where possible: it should not cause slow down in the !USE_MTAG case since then mtag_enabled is constant false, but it allows compiling the tagging logic so it's less likely to break or diverge when developers only test the !USE_MTAG case. --- malloc/hooks.c | 10 ++++------ malloc/malloc.c | 10 ++++------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/malloc/hooks.c b/malloc/hooks.c index d8e304c31c..9474e199c3 100644 --- a/malloc/hooks.c +++ b/malloc/hooks.c @@ -262,11 +262,10 @@ free_check (void *mem, const void *caller) int err = errno; -#ifdef USE_MTAG /* Quickly check that the freed pointer matches the tag for the memory. This gives a useful double-free detection. */ - *(volatile char *)mem; -#endif + if (__glibc_unlikely (mtag_enabled)) + *(volatile char *)mem; __libc_lock_lock (main_arena.mutex); p = mem2chunk_check (mem, NULL); @@ -310,11 +309,10 @@ realloc_check (void *oldmem, size_t bytes, const void *caller) return NULL; } -#ifdef USE_MTAG /* Quickly check that the freed pointer matches the tag for the memory. This gives a useful double-free detection. */ - *(volatile char *)oldmem; -#endif + if (__glibc_unlikely (mtag_enabled)) + *(volatile char *)oldmem; __libc_lock_lock (main_arena.mutex); const mchunkptr oldp = mem2chunk_check (oldmem, &magic_p); diff --git a/malloc/malloc.c b/malloc/malloc.c index 8854afec88..2d96bb085c 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -3286,11 +3286,10 @@ __libc_free (void *mem) if (mem == 0) /* free(0) has no effect */ return; -#ifdef USE_MTAG /* Quickly check that the freed pointer matches the tag for the memory. This gives a useful double-free detection. */ - *(volatile char *)mem; -#endif + if (__glibc_unlikely (mtag_enabled)) + *(volatile char *)mem; int err = errno; @@ -3352,11 +3351,10 @@ __libc_realloc (void *oldmem, size_t bytes) if (oldmem == 0) return __libc_malloc (bytes); -#ifdef USE_MTAG /* Perform a quick check to ensure that the pointer's tag matches the memory's tag. */ - *(volatile char*) oldmem; -#endif + if (__glibc_unlikely (mtag_enabled)) + *(volatile char*) oldmem; /* chunk corresponding to oldmem */ const mchunkptr oldp = mem2chunk (oldmem); From patchwork Thu Mar 4 16:34:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 42255 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 9B1163AAA0AB; Thu, 4 Mar 2021 16:34:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9B1163AAA0AB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1614875665; bh=NYR6xRXlklh3NrZmSiYqxtKI8RiI4hCuXCze+3SYQYc=; 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=KR9ok+LhsexeT7HimJteNxdmxY9DNJH86MsPmTbWMAheOz7m6wmNngVUH63Jor33B kR5sUrrhi+81ovqpL8XWGq6KGRtHgcmIW6bw7WWfFU+iA1e/qqCreR5i5ONIdJxznw v/870IMtwXMn7CX+TIwwsFQhAeMmhUHTXkDVlIeg= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70059.outbound.protection.outlook.com [40.107.7.59]) by sourceware.org (Postfix) with ESMTPS id F1B11389041C for ; Thu, 4 Mar 2021 16:34:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org F1B11389041C Received: from AM5PR0402CA0023.eurprd04.prod.outlook.com (2603:10a6:203:90::33) by AS8PR08MB6919.eurprd08.prod.outlook.com (2603:10a6:20b:39e::10) 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:34:19 +0000 Received: from VE1EUR03FT006.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:90:cafe::49) by AM5PR0402CA0023.outlook.office365.com (2603:10a6:203:90::33) 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:34:19 +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 VE1EUR03FT006.mail.protection.outlook.com (10.152.18.116) 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:34:18 +0000 Received: ("Tessian outbound 155e15b2e217:v71"); Thu, 04 Mar 2021 16:34:18 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: ecde818e72690a46 X-CR-MTA-TID: 64aa7808 Received: from 41e3babd368c.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id B8EE7D73-8E10-43D1-8636-E8133CB7FC0C.1; Thu, 04 Mar 2021 16:34:13 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 41e3babd368c.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 04 Mar 2021 16:34:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Zu/dVvx9csWZZX9BrhuFKLcBXTs6BXa6MnbVfLm1wxUDN3y5N15PfAnyyNaEAdCcRG2hXTMzvEqR206d1Gf0qZXhc+oKADxCFq8jnvgDevsiWserKuYo/mcuzQ4nfsIuVzu1KQJp1dAozjEOGcin4X+zH4TynubTboCvOgbY/yTAFZFXotx5F8MhXYDrrywxo+tRjzwt/QaSsD2X3LtQconmSvYawDLlnOyeUBxJ21OLTGQkLk5MLcdP4ft86WYED4zEEv9RRVzEST6nkjF74Mdv8M4hn8a4L0l9pxEZ1bPLEWru7W/ubegFG8W2ithbnBdkIEs2lnR6sWI4VfBSsg== 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=NYR6xRXlklh3NrZmSiYqxtKI8RiI4hCuXCze+3SYQYc=; b=A5vvyv7d1gz8jBOaIMFwFnrs4haxIg1PJFE+faLEKtCAmT/7l5YLYeGJAPOAGlPTZ9T1UhBvYN6PHaYYLMXkLqvRHyxry1MZIyv/4M3WMuF6QEYDF2QrYvlt/PP7DC8N9OEZsExphdCkJ3abD7xUtEPOBtRe0/z0aKsp1YrwBKSRfX4yAhBroJxEnJX1t7mntM2CYmJXOiRKC359BiEkC8jgXlAiMzpZLDhhqBEM0JbXzknJdjqd6voHSjee7oUeK19isSJyKH9uNmKq12aLl+8qRtfI/Yni1dyGgQflYPXUQtpdJUDnW7wyN1hvzf+WxFyoak5TBrnHQr2pWMD/7g== 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 PA4PR08MB6064.eurprd08.prod.outlook.com (2603:10a6:102:e2::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.20; Thu, 4 Mar 2021 16:34:11 +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:34:11 +0000 To: libc-alpha@sourceware.org, Richard.Earnshaw@arm.com, DJ Delorie Subject: [PATCH 13/16] aarch64: inline __libc_mtag_address_get_tag Date: Thu, 4 Mar 2021 16:34:05 +0000 Message-Id: <5ebbc6850c22874c46958177c759464c3bec34ce.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: LO2P265CA0501.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:13b::8) 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 LO2P265CA0501.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:13b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.25 via Frontend Transport; Thu, 4 Mar 2021 16:34:11 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 8e609ed5-223c-4a73-0f7e-08d8df2b5bcb X-MS-TrafficTypeDiagnostic: PA4PR08MB6064:|AS8PR08MB6919: 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: EgXdLiun5Mn4XNWofWRv57LtW38GaZxgAVzBa+WFV+wLa6+AYtrOC4GzpSML8b51h5dKrhem2k3FeBHuy2vAKjvuNzFB7mj4HDP72v9e735do21LRBqd80PR2J4FCODlTat5PC7r67aGYAA6eJKvucKRg0er340QDC53jap7BQsuJ0aDRgK8JU6djGUv0qNxsU+NQ+OceNAdaHU7uKbWu3CSq0pYCqptAXMPb3KqJ2pXXccR/aIpOR47WyW0AR0lKoQdFWjIQZw6XQS5IpJvqfeDjLAR9+Mu7aIMATJPnBOjLD+CwwK+j3qDpc3Ce/1+m14ZmP9cqYzRjWnQ9D9LFWdykycFAzLjdmHyu0GwU2Q/NyKGhWTH1usughMeMVQvhRbZJpj/0fOmBIxCcvIF7S5VvbrzuKdOYQ6ikqGJe1bqNdx5YUhcD2enbq4R3F1kM1rb8ukPJux8WQSzstdWSnSyKh101rLRunihBug2EJxhx4WOgZMr9IrcG/9d3u7bIHc0HwNhjlkp75yF3+WoUWFmDSOeN8YfjwQvUdckbnzXM6+HU2HDmN/w6XB3ZHYlOOIfneSRPQ7QMOR2mFvFARas6uaQ6/HfyNWyTaq4BASHxeTBLimWUlvSAr8UzZQN8KyKXhMgoie0uQZzU2nvyWHTkqYnmuFHeyf40c6b8WTtUkk0A5p/bsyMFKzdJ5/F 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)(396003)(136003)(346002)(366004)(376002)(39850400004)(66556008)(66946007)(66476007)(5660300002)(6506007)(26005)(6486002)(316002)(83380400001)(16526019)(2906002)(186003)(44832011)(6666004)(36756003)(8676002)(6512007)(69590400012)(8936002)(478600001)(956004)(86362001)(6916009)(2616005)(52116002)(2004002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: wETEVAA1ylGCw6T7PGTl1sdVxa9+7ArGn2QlPapaEIq3z3mG3932DMS4yW07gC822kUAGniLJgX1Q/AjoPAbBt+IQHOUo6txkT4M6rzmG/W62mbSii092zRvkpA7ARPMSrQTDMzDB9tFFdDfjF2ue1twL1Su99UvsCfwo4mvmHAaLWKDAApi2BKe0UbBQhUEGBx1qofczNfzxj2sboAnCCJ74joJzCSWU43umrFNYFOt8uijrNah6LdPEHnCX4edNVOTGupmwr1JMoDE/wv7ftrFhYE8h3Lkqrwjni31QQdAVkmvANZyWMyG1eNpqGlB9LwhP1/EXNU+YtwlQcSAq1LrNORcZiFdny10zOzXwq3tYLaaKeZXVky9k/K6dKMWyZXwNM0uMCHUQuRsjUko0wbLmCRVYlbt+ZtCupp3fCAxEkNdRo4ZxgOWxX6WiTnGscLYeRcW1ZGMu0zTISkJLpVe3MmknL63dYB8SeFokF3DcgZmfepZv5FJ3rzQR6lo3nXPKz+Ige9R4o05GjDAx19o3gWITYAX1hvr5ujOS3eDXOMm3jY35BEIK07qGQ/oKYlQGXkQY2cjni51u8PL/7DGJT7gqgfRTQBuVFg3bcljUwZHBJvW0TJoRF81BGNkUmLT1cx2oc8Hl5x9PBSgK7JSVB2YOhSBLYUN3I2Nz9+DDjqKsh7r4y13fjmdVRK5E3pg8wuEptXkpT7pd/OoQxnWnQWZjPBWk7H8YrZrjexYDEHBD/NBJYrt0oV4Y8nHZdKrTBLAqdw1tpYJI4Z0N60jASqHmmQYXUgux2z/XqtV9hVy364ipeHS2p8K302GDF19xfZ7tNRedBIn9cbHkfBUPFZYlIFlgZIZFMzi/Kpua0KkG+Dic+LeK6CmLNOchkfm4Ppw9lADhIX5QZhjdWtSaVb4/Bhda6uVc5fRFFm98vnVU34qi3eJYvagTXK5dzRojoMcbgzMrM4P2xGQ71FoXFsQ+e7eOBrKrK/EVAqcGuzyYoK0jS3Larf/tuOBKvINinkydNT/furTsARW4xji0709oZIQSsgCoEgJKUiK6qOSiU4XR10KNKuoa9qEnClcffOrihXkLohBl+7sUIq6pF7Ib+CcgnNcukHNzrT4gpoqSO9qJVxjsWPyvvIK1dpVjVd/Maif4g+znWRWEO9HZCiQ9hm3mFkvAzzk81247jekx+GaOLFY9R446nD8dGAgNADQ+y0p7vV28fKlPT/7i16yR5FVaxIeesSlIT8URBJis2BQtoegrCEq5nMZWrLNtabSp4jV7PfLT2D6bbN53s1e+2CBBwQT3sNsAT08GZR253ht8EoAUfQSMq8r X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6064 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: VE1EUR03FT006.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 1ff5b586-9e8e-4ec3-e852-08d8df2b5736 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kkK2SFtHOaYzOh/vvdbQ3fHYbTW6ftVX0OFAIvjwiuBhwy3TMMG2m5n9SmGqP/sfH1ByWqjaEjLbv5MTg7OTopZ96Ckbwm7P7/8wq4xMiLelaY91JnPmH8BJ9wR95VYnK8qrQcljjRdlTNCYLSkzym0NPBfkpKmtDCySjRSapKRJ5TjAsoIsAK6pEXVtVnCrHum8+YaJCc60CA35dIemB0EkuEeP2zcvZuIZCdf6Z8xFvOvXsAXBPRIS/Zbm9gTVcg2NM93EoKlxW9lbPGvmmI4qPHbD+hd90uTQgWQ8bc3QYkCiGuKy6P4Ac+6wRzHn06yeT0egkkvnFBqz6wUoFrsPnvl78xl7hkw8QTbi/80lw7XFJK9w5lllt5Uozj3sBHUxmb8Y8b4rpKSX3h0p0P4/ZHZa1g9WoYQnfhMGeVjXtRtCiQNy8xVaWjPuShl/24U1nV+4j/nicFMd1wiFsJeY3SLUZTa7AExEtQglz3+I4VXyT7o3mCTxOSbfwlwsnXjw1NcBx++fM1K1k3tkMTwI5rmp/NzgXYVqMNbTUQxzqu47W+cdwNrIadMxjeBtVHS4pQGNvQ60++9LkrieH2cnP5mo6sWR0bgS/TtLWkjDkPOaHUPxBeCs4QzAtkFdu+VNuI/ijaqL4RfbloLJXbk65u8lW0DOOPr1EmY5esPBCra3WBhLi7A1+SDiWHGc0lh9sKc6iYzLfed1vf/KTGRoMDD9b63H/RNNmb/IdJpUmyjIjdImFXNMcSs+kCB11q3KxZRgTE230u3BYAIR6kF/YStagOQUV7vcvHeFaUE= 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)(39850400004)(396003)(346002)(376002)(136003)(36840700001)(46966006)(36860700001)(36756003)(69590400012)(82740400003)(2616005)(5660300002)(956004)(336012)(16526019)(186003)(6666004)(26005)(82310400003)(478600001)(316002)(8676002)(8936002)(44832011)(83380400001)(2906002)(6486002)(6862004)(47076005)(6506007)(6512007)(86362001)(81166007)(356005)(70206006)(70586007)(2004002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2021 16:34:18.8247 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8e609ed5-223c-4a73-0f7e-08d8df2b5bcb 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: VE1EUR03FT006.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6919 X-Spam-Status: No, score=-14.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_SHORT, 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" This is a common operation when heap tagging is enabled, so inline the instruction instead of using an extern call. The .inst directive is used instead of the name of the instruction (or acle intrinsics) because malloc.c is not compiled for armv8.5-a+memtag architecture, runtime cpu support detection is used. Prototypes are removed from the comments as they were not always correct. --- sysdeps/aarch64/Makefile | 3 +-- sysdeps/aarch64/__mtag_address_get_tag.S | 32 ------------------------ sysdeps/aarch64/libc-mtag.h | 14 +++++++---- 3 files changed, 10 insertions(+), 39 deletions(-) delete mode 100644 sysdeps/aarch64/__mtag_address_get_tag.S diff --git a/sysdeps/aarch64/Makefile b/sysdeps/aarch64/Makefile index 259070cfad..5d594debea 100644 --- a/sysdeps/aarch64/Makefile +++ b/sysdeps/aarch64/Makefile @@ -40,8 +40,7 @@ endif ifeq ($(subdir),misc) sysdep_headers += sys/ifunc.h -sysdep_routines += __mtag_address_get_tag \ - __mtag_tag_zero_region \ +sysdep_routines += __mtag_tag_zero_region \ __mtag_new_tag \ __mtag_tag_region diff --git a/sysdeps/aarch64/__mtag_address_get_tag.S b/sysdeps/aarch64/__mtag_address_get_tag.S deleted file mode 100644 index eab6c49285..0000000000 --- a/sysdeps/aarch64/__mtag_address_get_tag.S +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright (C) 2020-2021 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/libc-mtag.h b/sysdeps/aarch64/libc-mtag.h index f58402ccf9..da1b6be776 100644 --- a/sysdeps/aarch64/libc-mtag.h +++ b/sysdeps/aarch64/libc-mtag.h @@ -35,17 +35,21 @@ #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) */ + that are multiples of __MTAG_GRANULE_SIZE. Size cannot be zero. */ void *__libc_mtag_tag_region (void *, size_t); /* Optimized equivalent to __libc_mtag_tag_region followed by memset to 0. */ void *__libc_mtag_tag_zero_region (void *, 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 *); + location. */ +static __always_inline void * +__libc_mtag_address_get_tag (void *p) +{ + register void *x0 asm ("x0") = p; + asm (".inst 0xd9600000 /* ldg x0, [x0] */" : "+r" (x0)); + return x0; +} /* Assign a new (random) tag to a pointer P (does not adjust the tag on the memory addressed). From patchwork Thu Mar 4 16:34:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 42256 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 356933AAA0C3; Thu, 4 Mar 2021 16:34:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 356933AAA0C3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1614875682; bh=unaaHVtpWmyJPnwjowhK0XBzn/zX5wGcj/kO7pOpHAQ=; 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=TE88KEKiDAt07IT3kPjbVcrNJkaKUIv7pfOp1FLYKueSgj4+DxcIee/k3sOV2xZZn 2RgkHNF65DFJ54iKuL93s+YqYpfX49c8O5CtotLzK+kOk60yunzrze+FJE9XNFvIIV G2/0k7b9hLX9fQZPS5/9TWkgHS/63QgbWkqvh0nY= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-eopbgr130048.outbound.protection.outlook.com [40.107.13.48]) by sourceware.org (Postfix) with ESMTPS id B716D389041C for ; Thu, 4 Mar 2021 16:34:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B716D389041C Received: from AS8PR04CA0108.eurprd04.prod.outlook.com (2603:10a6:20b:31e::23) by VI1PR0802MB2334.eurprd08.prod.outlook.com (2603:10a6:800:9d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.23; Thu, 4 Mar 2021 16:34:36 +0000 Received: from VE1EUR03FT024.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:31e:cafe::24) by AS8PR04CA0108.outlook.office365.com (2603:10a6:20b:31e::23) 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:34:36 +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 VE1EUR03FT024.mail.protection.outlook.com (10.152.18.87) 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:34:35 +0000 Received: ("Tessian outbound dd71fb35fd76:v71"); Thu, 04 Mar 2021 16:34:35 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: be8fdb4b4cfb3830 X-CR-MTA-TID: 64aa7808 Received: from d3fea6626d10.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 0BFBE5A8-25AE-48DB-9E53-C3CEF37E6407.1; Thu, 04 Mar 2021 16:34:29 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id d3fea6626d10.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 04 Mar 2021 16:34:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Jwe2aR1+jlzBgf9dzlfB6wTrwreGJlKJRu3CJJ8KWVjOMzNp4dxK+pqAtC+HGF9olzSn0+2NUSIti3GqZCbXj9bmmr9142XSno++qATU3T4//IZabEl2dq034BnbfdWoSuul83o7RJ8JDFkcMNXMyOxmlyscFvbhaxhk76L2/2ZQOM+UZeGICb8xyjzCLrNaVbwnFqZ6habdQkg8bqJnEudIndUy+XOdfcUypITP3TWUqKrPdQZyiO7i9TyWQvGGPupfmhTGKwZe3j0vMa+yGs7lF+JebvxGkrZqMOnnsP5rAFda7fbQw1xQUyZEKez0NJsl55Vg9GcW2V1yLTgQ+A== 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=unaaHVtpWmyJPnwjowhK0XBzn/zX5wGcj/kO7pOpHAQ=; b=buTIFzgqjjb0J8Jmo1da1M8FY3JYciVA/qwXdbm9BwOCv6INVgthciP5AMJ/1SF41NiWQr3/YFt8LhHmq5b/bumvMXFWntJVsWtJ7SOLvF35AWNUnENk6hTEx7IE/0EgiqPkX2sKbG76MRlyrjcQf81lC9WXuVSr+8TE0tZMuQySLE9qjmMis5bTN1UhWprFVSgh+OJjdtSL1MdZ4ZC5j0jlAl/r5+ZViKMcjTn29GuMmrkfFHPKK3xwKoNOlAfIuVbuLmE7yM9OUtDxXLrhh6nRVve/Q1AgSNH/tVW6vk+Psu2MW9nLE/tf5lj3nXAzIur6u30K2P06ONpB7HoVCw== 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 PAXPR08MB6480.eurprd08.prod.outlook.com (2603:10a6:102:155::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.19; Thu, 4 Mar 2021 16:34:28 +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:34:28 +0000 To: libc-alpha@sourceware.org, Richard.Earnshaw@arm.com, DJ Delorie Subject: [PATCH 14/16] aarch64: inline __libc_mtag_new_tag Date: Thu, 4 Mar 2021 16:34:22 +0000 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.55] X-ClientProxiedBy: LNXP265CA0029.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:5c::17) 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 LNXP265CA0029.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:5c::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.25 via Frontend Transport; Thu, 4 Mar 2021 16:34:28 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 3fe5a2e5-ba8b-4e2b-c6ba-08d8df2b660d X-MS-TrafficTypeDiagnostic: PAXPR08MB6480:|VI1PR0802MB2334: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8273;OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: IvjiudYGvOI/TVNwleBilucyP0dp1a91EojJC1HEYY2OYdscXOZzxr21KlqQAwrOB6uzuYFrocIFFWfsQVrj1df37qH4r5RC8z5y+7gHD4/fB5Z8XoTSOyvAA1kPAarMAOEYu5z2gO+6iNFTeMzC04f7IpySYoa5UJJS3DwEXDXnz++HlewyDguugFqg6V7ym4GQL+RbT0L12cHy1LZvO0RzweOep82yQoguDTxLynLGtYhqow3qYsNbE7GkzJ2gSlP2DvTfROOHjhJ0JUbsDuXRsLVR7zlZ7DeW/VbOgzJcLotH4fL8AAtpjRMnhAsDKwqYBLcLE7qlg3ZxdP7KEQETOaHPAz9Pkfr36TvrtxbZoh6D3s4Hxc5W0/GAqIS+C2EeV4fbrALV6tMdI25OrmW0x1/DDt4VWGB8ElzJBgJK4xafTl1Ope9jbyAB0vZjnfQ+fl/fVRsO2mtG5s0kdMR36LkfXQQ00H1/Ie/E1Zhfpav+x+8mGckzhd85Lufvm+EprinMejvUym7v4regoB499mTYVa5Q5NIna+BPJ6BTdr/iKSKvG/cKYYe7SvWDiTrQ+vZWFaXi1RHl0yDskAjQoO39sWHG6uYal3e1oawiqZRBNJOpbuBg0vagroVRBcvjuyvgxZg2IORVWGmr72ivd4XDQxF4ofYHxtoa8GUBsqwmSQAfz29JKcA/Rkgo 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)(396003)(39850400004)(346002)(376002)(366004)(6512007)(2906002)(2616005)(956004)(6916009)(316002)(83380400001)(69590400012)(16526019)(66946007)(6506007)(8676002)(36756003)(5660300002)(6486002)(86362001)(44832011)(52116002)(6666004)(8936002)(26005)(186003)(478600001)(66556008)(66476007)(2004002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: TlQ//8Ky23mip3GhwOE7zW3Kr1r6ZVU5X60unZFJq8oBdbNHqyl3YRu3jy87p8Iy/02P9Fbwv+5cC3mHHRWeUtnVco0Hqfx05TktLPJT8qIlOqPEAc1jOUbNSXUQpQhqgZnDU3T2WWpnYPJqjvFhsKHF+x+qd9Fbe3W9Se8iAr2OhOkRaiQcyV/lLK+EuPif1SY56jqLUy23Y480Jjx0rGPsHad0w1aoCZMZuTDKRcSdjnTQb3idPj7rM2AtZ7nsFRXwFLBtClOzllHoqTSASn+IGb9C/S4sbxVFxoDsr8/d4e0q+N/K37jYaexRJpfdv6M+sVP3aZvXHge9abBIR+5OUcLvVs1nCIpYvdp5AZHkPp+CRIhkR6aYVoPI9blWyRlW8AJAfDEBbb8w9QTWRKbybM6j8k9T8V7g4rZF3EaTb/FsYkM09JQ+KDNiKe/O84qmy0Q9/2NPTf/oqf89y2lleQpRxg2sVGGXa0b12Ae/ajHFLZk+7adsUgyCzUG9J3OjC/KaX/YY/6MiggXsJ2gyai59Xte0Yg+WJttWefZshVp9Fu60EEHgaKNTXXUVn4ZNFlDj4mB+QVwD1HrE9HgcT0QaIiQBVripvlVsd3STjDsCvdlEeCCEPv/osA4RtXJh2ty+vnxeBAa1syEmmXGgCOivmIFsmFRJ/oFoD/vOEeyOh0ZUv02fokxi6N3Ix4v/M7ZdrRtn2NJHtSd2ejXUIjB3+ub60lev0KDUcMnJ7DRiqsIZNOPAoHGuThT8ZjRLEYSfLHxkNnadElJ7gbNWPo1DG2t7SbxDTLX4NgO3wI1IO8aLi3Htx7kxnnIaFkuQtclFNZj/Xq1jmfFo/hEOIl9UgdmmV3IO7JfDF+hcPIit/LV9tWQ+LNy86GaXfskAd6S721qKGB1sAOhUxTXJZ6h9JEA7/lj0CVbY1kaMrGlTmrTmCtKUhYPiyeqDIx1avJEAGrJwBo00th+GyXFkJAfsPl8FP/opNoR0xAWZ5a+odqADnOw5STNIbHcuUaacFscZvYqoRnjfAcgNexEMilC05DQd5XulsA+paZAvub9yeiRG76k/z0Qki2Q1qdgLOB4xKLTcRYCeM0iuEZbDqssnfeX0/MaPcnrm9CQO6BT/ZeWFqXYVI/lqul+WdAmuuj8ZCxIOax3o5dEXzCtoMrr4VNv551Omeaok1B2vPqG8fKoMOQnBSL+hv9tEQgVYy6WIy2Y1OksV107SENUffcufaF9pl2UTeWo5izrUfkR1ICttodzl2pw6/qCPh/M93rxk2DlW+3HrgmI1iKdRA0DotIHbxDMyJOXHFG99/EDohie9QbMMK2nsxbGj X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6480 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: VE1EUR03FT024.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: a8e9a598-8615-4dd4-d2a3-08d8df2b6162 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bYJEQKnEXQhKYgz/kKL+bmbeRzJpl8hm6QnAZXzF1rHXFg+DYouMiEjvkhWp22FzFIl8hg4tJLrJv5TShCGa0EhqEsTDUFvS919kHnriZm0neLc3hZ7ccnWdqLaZ6ITCUi8zbkTfV8VsHlot9/xdVgaDkPbJrEf6gVq7maSeYNtkcdp37nEJb/xUEewzIMuVvbeY/jQTHqtgQiEbiS07ZoqbsfOPXbYLimKAquBI0NTo78zNW5TsA55lzVrGnobCLGd2HB8czEWavJguuF1NFD7Kem8SRsJFtCI5et+GB713NfSGr8/H3tSRIIGe8dPHwNmW3YoX9fZpBBjc4DbxfzSoFAj+r1/S53DPbHbG7QOpW5qcfjF6k29s2WpELR9fVBPws7YpF86hOSpOosIw+VgtreoMqNVhB5R6I/gaMf9T/pEuPlqmy0xXIXIabsQYGRKLoMXz4Nv/Cdun66LCW9n/DjF5m9lZ+pVhVGZJDTPMrn/K/mh9/fIMgKHMmV7z22yRODeT1Cb+1FRXeGkRyJnG+JSVe9Mm/8xzlUr9q+CrnQEQOTDtmLJ/Pm5Kf17jgUSK+ukPknkx+Wya8zPQHyZoUuY29kJaj+oerYD5+KHlDwcGnibIDkesNiwNo7XlBuWFbc4BS3HLscHcoQAw1oKhqeJarpRUGjc2xogcFsqZgy30BlKZ0aUsBZ+/isDMa7Upk3X+g4ola9IjmaXovOmHyqYSM05S/1JpZVaNB2p+Hwb2huCwBYEZ7u009bGTOkS2seAm83XSVjbhNaH9CMThgZ60wrtbZv0sISs/Gog= 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)(376002)(396003)(39850400004)(346002)(136003)(36840700001)(46966006)(36860700001)(6512007)(82740400003)(36756003)(69590400012)(8676002)(356005)(86362001)(6862004)(70586007)(83380400001)(8936002)(6666004)(81166007)(2906002)(478600001)(70206006)(82310400003)(47076005)(316002)(6506007)(186003)(44832011)(16526019)(336012)(5660300002)(956004)(26005)(6486002)(2616005)(2004002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2021 16:34:35.9992 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3fe5a2e5-ba8b-4e2b-c6ba-08d8df2b660d 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: VE1EUR03FT024.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0802MB2334 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-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" This is a common operation when heap tagging is enabled, so inline the instructions instead of using an extern call. --- sysdeps/aarch64/Makefile | 1 - sysdeps/aarch64/__mtag_new_tag.S | 37 -------------------------------- sysdeps/aarch64/libc-mtag.h | 14 +++++++++--- 3 files changed, 11 insertions(+), 41 deletions(-) delete mode 100644 sysdeps/aarch64/__mtag_new_tag.S diff --git a/sysdeps/aarch64/Makefile b/sysdeps/aarch64/Makefile index 5d594debea..1099f1d657 100644 --- a/sysdeps/aarch64/Makefile +++ b/sysdeps/aarch64/Makefile @@ -41,7 +41,6 @@ endif ifeq ($(subdir),misc) sysdep_headers += sys/ifunc.h sysdep_routines += __mtag_tag_zero_region \ - __mtag_new_tag \ __mtag_tag_region endif diff --git a/sysdeps/aarch64/__mtag_new_tag.S b/sysdeps/aarch64/__mtag_new_tag.S deleted file mode 100644 index 72c1aded4c..0000000000 --- a/sysdeps/aarch64/__mtag_new_tag.S +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright (C) 2020-2021 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/libc-mtag.h b/sysdeps/aarch64/libc-mtag.h index da1b6be776..7588c6de9e 100644 --- a/sysdeps/aarch64/libc-mtag.h +++ b/sysdeps/aarch64/libc-mtag.h @@ -52,9 +52,17 @@ __libc_mtag_address_get_tag (void *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*) */ -void *__libc_mtag_new_tag (void *); + the memory addressed). */ +static __always_inline void * +__libc_mtag_new_tag (void *p) +{ + register void *x0 asm ("x0") = p; + register unsigned long x1 asm ("x1"); + /* Guarantee that the new tag is not the same as now. */ + asm (".inst 0x9adf1401 /* gmi x1, x0, xzr */\n" + ".inst 0x9ac11000 /* irg x0, x0, x1 */" : "+r" (x0), "=r" (x1)); + return x0; +} #endif /* USE_MTAG */ From patchwork Thu Mar 4 16:34:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 42257 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 2D9183AAA0C5; Thu, 4 Mar 2021 16:34:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2D9183AAA0C5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1614875698; bh=x63UrQJbnN7ggisiq1fBWiYUb5wWDCQ9XiL1E7RWdZ0=; 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=dXCmirWVBWyvVD/O1FLnTWwPXsrvF4/en8zdATUadZ6TqBfxiugh/cIySTLPbdUzs WXHs3F2rkg+uB+s+yCIrw2PxI+Hh/54HzMQ1cJc6CwtcvdP8zbLU84wXwCKP5pixRc ipxRYXjlz75V48GRhUiQrlrVLjNd6htbHZt6i++s= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80089.outbound.protection.outlook.com [40.107.8.89]) by sourceware.org (Postfix) with ESMTPS id 0366B3AAA0B4 for ; Thu, 4 Mar 2021 16:34:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0366B3AAA0B4 Received: from MRXP264CA0015.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:15::27) by DB9PR08MB6714.eurprd08.prod.outlook.com (2603:10a6:10:2a4::18) 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:34:52 +0000 Received: from VE1EUR03FT062.eop-EUR03.prod.protection.outlook.com (2603:10a6:500:15:cafe::3a) by MRXP264CA0015.outlook.office365.com (2603:10a6:500:15::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.23 via Frontend Transport; Thu, 4 Mar 2021 16:34:52 +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 VE1EUR03FT062.mail.protection.outlook.com (10.152.18.252) 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:34:51 +0000 Received: ("Tessian outbound efd554c08f3f:v71"); Thu, 04 Mar 2021 16:34:51 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 0e2284d6beaa5322 X-CR-MTA-TID: 64aa7808 Received: from c00f180731ce.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 67CC4DC0-2DFF-4E26-8CB4-71C84BB25575.1; Thu, 04 Mar 2021 16:34:46 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id c00f180731ce.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 04 Mar 2021 16:34:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OLdqvxSwgri+N1mAC4bXQc2FhQV/2NwBsLolhe+dVWc9oPvc1Bb268TVA5E223xerTvHN0r74SyDwIOSxDZ+GZoY2e4Fb9OEbKrbI2kh7TqaC1LSmPokMd/ZsIRKKbhVmQWyBQloRppfZUlMBYRc4IUX6S4mzUibl48nqfW+5tni2zgTKpVUZqFGrgOAm9L+gyuLtl+OwKdD6vR6RzgvLjnnhDJcFxtBKUiRBaanNiVVeyAmuUE2ZzaVOiPfFTkRH2YSfpVA8oF47hSGtAu+ELw/45ViW6vyXRUNjySVkr0MnL1/MDB+inJnBd/djRfCYwZyZsXQmE+iuZ7p5slKOg== 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=x63UrQJbnN7ggisiq1fBWiYUb5wWDCQ9XiL1E7RWdZ0=; b=SX8oAWgYY95xop4BjINd3pItMQQd81z9+Lg3wH3CaT3lF8FaiO42Z4bDp0BRB+AQqZQ/K+lY2dNUCqiws4TkBSxSryLMkv43FFRJ5NlHlLtPEOfkQZy4ZCa1iZYgvplJwmI6QztwWOuS2wJXGxwgqeuo94EQuFI3o9pz6YeIs2F7hE/Zs7S2gpKd42FXuGPNMPqTa722iaTk2wBzJLDZ7lg3f1zgQ1GFSbCXQJs0Kca6oEni4Gfqdyfw7EqVFBLkNRRi4+YSCDyMYArn98GloQuelxNvJGDOnwqAwe/UDZ7SsXrxeG1cQshcZ7UL3KPEsTtcJIY35Fodrm2PotTb+A== 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 PAXPR08MB6480.eurprd08.prod.outlook.com (2603:10a6:102:155::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.19; Thu, 4 Mar 2021 16:34:45 +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:34:45 +0000 To: libc-alpha@sourceware.org, Richard.Earnshaw@arm.com, DJ Delorie Subject: [PATCH 15/16] aarch64: Optimize __libc_mtag_tag_region Date: Thu, 4 Mar 2021 16:34:39 +0000 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.55] X-ClientProxiedBy: LO4P123CA0225.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1a6::14) 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 LO4P123CA0225.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1a6::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.25 via Frontend Transport; Thu, 4 Mar 2021 16:34:45 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 468d0d95-c654-4f9a-b2b9-08d8df2b6f8c X-MS-TrafficTypeDiagnostic: PAXPR08MB6480:|DB9PR08MB6714: 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: XC4YotCNAmXqM8yZ54wioMCjmD/405nAe81oPo86bqNSD8nP1I67CTZeH3BntEiVUC7KUXXR2r83o/HIwH+ZkwC6KHTRRCjcmkP3yInd4+soy9QWvBJUVjD4epYvQHkPa3qIC5+d2Vt0y4PZY8J3zF43ZDVkYoet09sZh801GXdHV2zO61linoLh8Hyo/PmJPczvMmSqgIcY0roUhHSuOz9VZzCtrI6NIEUy8dMYZvZAMYMd26q72W9c2khtVa6I1yQOiOwxD1tT9Vq95sOGVcvgi0BS3zi3foEFEyuKANxPIUohAlGQRCS/av43rbM+zziiSjMhmBe2oVe1YOp3Wd7aRFzC/edozBlxNRGONwL6JqRI5y43+YTT4kL9a0hyMnU0UBVNAApzQFVQofJc+Y9A80QnUadEWPU+A8865ij3zyD/8ARaQ8ejACKfDK3Lcn586SezzfKvLUg2h+NOGQ5YYu5Y36Vu87YCht23nXvUOSsglztMG2hLt/UNykLdf/GiLsVAYLSHdAl/xXGOH/VLPk32jPeio1K+T/jrnlBWHtdmfxrROjwvQpNJXauJbyZGjKdkAqjhf4TfNC34og== 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)(396003)(39850400004)(346002)(376002)(366004)(6512007)(2906002)(2616005)(956004)(6916009)(316002)(83380400001)(69590400012)(16526019)(66946007)(6506007)(8676002)(36756003)(5660300002)(6486002)(86362001)(44832011)(52116002)(6666004)(8936002)(26005)(186003)(478600001)(66556008)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: P5FQaNlE74L4+U5nItXiwiT6MVoAgK6oMKf9i9qEDljeLy38DgwzgmMyzsPrr5htiw/538v2Jn54JsTkmRtREcY8uJ/zxCf7xjN02VNyx8jmcaofYq4Y+e1O6SkvyKhQYyhg5JfFrFo6rngc9c+BJFZMokWHH0A4XroxnSJ9EnAyJA4EG7PqrCYjelwsT0+4osX9YTL5U1UjZNJfAjsbzDAihLdNDaMKwuET30RhhOEZqS9mYfd30HO8bFCfj624rzpOvDBmudJdPzlLIaQsQlP4GAjIrnFB/gWnr/uhT1+qeKfRoZq5Jls/0zMJLIIKQS3yOKBbWfoj3ZnFX+dBGOqdY0C0D4d+KkQJMUDJijN7jybKI9PBdivhwNhSr7wp+uhrpesWOz9fJ7a76sdM4kHIra6rax4Jw4SJQfMNWiCh5OH2ByBIG49gu/UT2yoTkAm2pe3j+QXau7U+gpxZYVUmB4VIzQvOOJ4SY8fi6c9ymKLqbG0rxmFfm8gFjvqXNqTXGIf1QIaiBi4+mXtRexXlo0Xphbtb4eAsOlpICgGfGdpwO16qo0sSjSHn2LAwwWjo9wkA36Twqc5ElESznZwuWchdwCRTBIprYN1cwNzj5COGZLmoCKskyDkelEImQUg2p/8K7vMmIm+6+KdON+NuT7kGZ14qEu1F12S3OVBUYtLz8pu8KEUCj3P1VdRlfuqrMwAKwGOJMbKTDpQqu0GryE84mspTqSGhfeeJ6knE6I5iz9RFkI/cjOmBnpqucQZlc1T8Vh6V4i6Rne3OTheI9YKAUPCu+kG+3625iL+B/nM3lLMu8Bvyt5ny/w4WlVkqukVQpPQaLcI3XCvLddIuDClqCehDal71w7XSImQjlwFBNusi5YdHwr2VPZX1Vu6kVTD7vOFgQnY9ur3WnsF7p7vNhc0lgCxIuj68tXObmh9AfJ1zZZho/vECCgCLcYoCnYwMg1/M6o+fPm65m0X4tkYqravGryMnSp8aLCfRV7B2e09FvYZV5wVrpotp4I14yDjgXA1kgjP/mokZCoo9GqjHMnzPK249++mo87m+Bttmibb6vKKQtCfBRm6X9fDhaOLSRRy9TC6BnjsItanpRn8H5F0zUZFauNY7OW4ZXN8/1XGJCA5gRg+72jZVDrjWsI4DWRB5GlRW6jZ8iMuyvBBDz+S+VEgGTbBzNvGuqOpaE3rLT67/zj8ny4Vr3gldHGaonRAHyBLNb0IA34iurGS7DqI+xj/LHsaITQxaWLBBMOASPKs5nP3l64apvlkv9oy6DBeqJZcUk9MApGMBhSToFEVB6p8pZ6IufkJD8NsjZhvVc7IAwgOPvxu2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6480 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: VE1EUR03FT062.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: d0f001d3-778c-48fd-ffe6-08d8df2b6b73 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: P/pRRO2eG9QpQvDfvi3p2ptFBeCyxS1bbrkMwv4PzFAsn+o7RirJ8+w/WrZaC1FasQW07HEIxG5I0pH/49HRRq5aQ/PEaVGa71R0/KBkLR7BD/kOfjLoAPkmVSO0V0Re5yKn7m4a+JMeohydc4KZ6tctWxFBw3BEibEGanvKuUbpcPp98ACz+YklCOH+WYKCg8v74Vw5ZQsEJhTw5oMokUrtcy0Qc568G2QbUX9ogJv7oV6s5y038uUrzmw5dkqDZOLYGFknTistXOdDTGxOF7m3jJSbXaiqQn5lXhZqtrLX9+ORy2XcRuThQlDLoXQgpxKiJSyiJoDsWhKGidlOI0XCayV1uChlW0cyEl9r7svQygpb/4O9zA9ecslxwiUhjYF5H1iyj/KZJTs/nrOOSWnt6ic7c7qhWU9BKMNpenKhK0Bxd3qOC4PCFHvVlf708Gme9RvrPos1Lge3ejZdHJPVn71u7tna05kK9sBx7KN9u6ROEH8b2K6ctljQY8U0K3hLYTlfAto2OdC1/V46+CwWRFJGQ6S3BE8+QQQXdM7TAEh9SqSf23jWplTndTIOdaeBlBN0PBP3BGUUkbOhxMOwSMg3jDwg8jguTHaZLi9RxQkdM1KbdkIfL/Q5a+SJfopqdEjoYgi1ke/gIFlRZRQifeshKUgk2ZSyvaGcfTSN5rZJmSvDIvRV5qyL3NhZ 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)(39850400004)(346002)(136003)(396003)(376002)(46966006)(36840700001)(82740400003)(2906002)(6512007)(956004)(86362001)(8676002)(2616005)(70206006)(26005)(83380400001)(356005)(82310400003)(8936002)(336012)(70586007)(6666004)(6506007)(36860700001)(186003)(47076005)(69590400012)(316002)(36756003)(44832011)(6862004)(6486002)(81166007)(478600001)(16526019)(5660300002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2021 16:34:51.9695 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 468d0d95-c654-4f9a-b2b9-08d8df2b6f8c 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: VE1EUR03FT062.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB6714 X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, 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-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" This is a target hook for memory tagging, the original was a naive implementation. The optimized version relies on "dc gva" to tag 64 bytes at a time for large allocations and optimizes small cases without adding too many branches. This was not benchmarked on real cpu, but expected to be faster than the naive implementation. --- sysdeps/aarch64/__mtag_tag_region.S | 98 +++++++++++++++++++++++------ 1 file changed, 80 insertions(+), 18 deletions(-) diff --git a/sysdeps/aarch64/__mtag_tag_region.S b/sysdeps/aarch64/__mtag_tag_region.S index 9a8a3ffb60..cae0c8f121 100644 --- a/sysdeps/aarch64/__mtag_tag_region.S +++ b/sysdeps/aarch64/__mtag_tag_region.S @@ -20,32 +20,94 @@ #ifdef USE_MTAG -/* Use the same register names and assignments as memset. */ - +/* Assumptions: + * + * ARMv8-a, AArch64, MTE, LP64 ABI. + * + * Interface contract: + * Address is 16 byte aligned and size is multiple of 16. + * Returns the passed pointer. + * The memory region may remain untagged if tagging is not enabled. + */ .arch armv8.5-a .arch_extension memtag -/* NB, only supported on variants with 64-bit pointers. */ +#define dstin x0 +#define count x1 +#define dst x2 +#define dstend x3 +#define tmp x4 +#define zva_val x4 + +ENTRY (__libc_mtag_tag_region) + PTR_ARG (0) + SIZE_ARG (1) + + add dstend, dstin, count -/* FIXME: This is a minimal implementation. We could do better than - this for larger values of COUNT. */ + cmp count, 96 + b.hi L(set_long) -#define dstin x0 -#define count x1 -#define dst x2 + tbnz count, 6, L(set96) -ENTRY_ALIGN(__libc_mtag_tag_region, 6) + /* Set 0, 16, 32, or 48 bytes. */ + lsr tmp, count, 5 + add tmp, dstin, tmp, lsl 4 + cbz count, L(end) + stg dstin, [dstin] + stg dstin, [tmp] + stg dstin, [dstend, -16] +L(end): + ret + + .p2align 4 + /* Set 64..96 bytes. Write 64 bytes from the start and + 32 bytes from the end. */ +L(set96): + st2g dstin, [dstin] + st2g dstin, [dstin, 32] + st2g dstin, [dstend, -32] + ret - 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). + .p2align 4 + /* Size is > 96 bytes. */ +L(set_long): + cmp count, 160 + b.lo L(no_zva) + +#ifndef SKIP_ZVA_CHECK + mrs zva_val, dczid_el0 + and zva_val, zva_val, 31 + cmp zva_val, 4 /* ZVA size is 64 bytes. */ + b.ne L(no_zva) #endif + st2g dstin, [dstin] + st2g dstin, [dstin, 32] + bic dst, dstin, 63 + sub count, dstend, dst /* Count is now 64 too large. */ + sub count, count, 128 /* Adjust count and bias for loop. */ + + .p2align 4 +L(zva_loop): + add dst, dst, 64 + dc gva, dst + subs count, count, 64 + b.hi L(zva_loop) + st2g dstin, [dstend, -64] + st2g dstin, [dstend, -32] ret + +L(no_zva): + sub dst, dstin, 32 /* Dst is biased by -32. */ + sub count, count, 64 /* Adjust count for loop. */ +L(no_zva_loop): + st2g dstin, [dst, 32] + st2g dstin, [dst, 64]! + subs count, count, 64 + b.hi L(no_zva_loop) + st2g dstin, [dstend, -64] + st2g dstin, [dstend, -32] + ret + END (__libc_mtag_tag_region) #endif /* USE_MTAG */ From patchwork Thu Mar 4 16:34:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 42258 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 D739A3AAA0D4; Thu, 4 Mar 2021 16:35:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D739A3AAA0D4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1614875734; bh=4uZEUyPD4xQFCJseLHLSd7Qw52xc/t/Qo+IQGDIkPec=; 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=gHta4vJ+4VLDKnOaVy/+XvtucIaO9LpcRaE5H2SZjSMG9Va12lxGK9TnCw0Pmayjs kPw98w3ObpLlk7N5TC6VYYKw9K4C1WIQkoe10i6HnDyrP4W1sum+OHNz74A11rY4Yi X0qaVqW+LpJkpVwodS+5e9hk9m1uqIZ6NBphkjR4= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50060.outbound.protection.outlook.com [40.107.5.60]) by sourceware.org (Postfix) with ESMTPS id A1373386F46E for ; Thu, 4 Mar 2021 16:35:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A1373386F46E Received: from AM6P194CA0108.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:8f::49) by DB6PR0801MB1749.eurprd08.prod.outlook.com (2603:10a6:4:3b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.19; Thu, 4 Mar 2021 16:35:28 +0000 Received: from AM5EUR03FT007.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:8f:cafe::c6) by AM6P194CA0108.outlook.office365.com (2603:10a6:209:8f::49) 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:35:28 +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 AM5EUR03FT007.mail.protection.outlook.com (10.152.16.145) 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:35:27 +0000 Received: ("Tessian outbound 72bd4bdd1f59:v71"); Thu, 04 Mar 2021 16:35:26 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 043cbbc893124910 X-CR-MTA-TID: 64aa7808 Received: from 6040653d020c.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id F40A11D7-59D6-4256-832E-EAB8AC6C593B.1; Thu, 04 Mar 2021 16:35:12 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 6040653d020c.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 04 Mar 2021 16:35:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eApdy0WDYIJSJmyeKPBEf98ULS8onHP7nwhbasdAkGp7zzsNCOs7L074H8r0JaVNihb+5S1PkxDD4V1iAVwtg6zGCI4S5Y6bML7HKkJEO8i6frhDBHgIsoLvSquXUkzfo+RecmpOlfk8ilrcE73XvU85vo84ZjEB60zoP2Y+/c3vtiw84TqQA7id7Dd0nGQGVwgjAk7BvlfOk9et8lcIkA6y4iWAlAQAXXYf1O/DV6vK/acTLqWhVJuLcHQcfLudZpgml9r/n3mCfSrgLkk0l04ZiefuWNcolsyx2BvVLr0nToFU+PBzIsf+SAwvnWdhDWkFfn7DBYkuEZOVoRXyfA== 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=4uZEUyPD4xQFCJseLHLSd7Qw52xc/t/Qo+IQGDIkPec=; b=Xrox5qE+afsFjG9JlOzSSihjAvKS4pyre6UXOJAy00d6aRi7Q95sAhznS/XKh/Oh9i2qQV1Zzv9xojmIT3EKMsnBPXVHSPGWHZwAkmal8zOYzcrZ0+ezDk7yKHDa/deOtbGON79HXeaL45wXAPjHN+TRjMRiiJ5BzAxn6+U8e+pCfzjWKVnBWIUiIniPeCJoCXaahyUTdxa7Kc8tS8spl4KgMu7yxhNqDizW6+YhatW4l31q3QkPyIbRu6vUWx+J4HaEDJ32g7WlBrcUljjgp3GzXr9QioOddlZqO8XwUYUDA7cn94iYHsr/2wseiZP/iW/IqS3QD0qZZLesSljClg== 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 PAXPR08MB6574.eurprd08.prod.outlook.com (2603:10a6:102:12d::20) 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:35:02 +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:35:02 +0000 To: libc-alpha@sourceware.org, Richard.Earnshaw@arm.com, DJ Delorie Subject: [PATCH 16/16] aarch64: Optimize __libc_mtag_tag_zero_region Date: Thu, 4 Mar 2021 16:34:56 +0000 Message-Id: <8d06a578d4431a8bfb2f424ec60fa442041a1173.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: LNXP265CA0079.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:76::19) 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 LNXP265CA0079.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:76::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.23 via Frontend Transport; Thu, 4 Mar 2021 16:35:02 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: cff06c59-74b3-444c-a993-08d8df2b8499 X-MS-TrafficTypeDiagnostic: PAXPR08MB6574:|DB6PR0801MB1749: 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: ozfvQFrOhsVaxCfpbb6UyEB1e/JtGAqU9ymjyvWIYPMyaceJt2uYuUeeNd6d29uQg4sdrM84n9tmG6TwBpID7VJN9rbVBfVxW9TMvsa8i+FhGJdNGH6dMwRIdVZX12Yvd+qMlZJhCZzU0uxB9DkV74XNngc+t79W9GMIQnnZ7ZyjVubGLjaKUOx3T6s0+cGNHrhyzuLAMuRKpAltFM1vY0fc82KxCsapqElprSYhQS8bWsrsWCLw1SB2wSl0911W7EoFHj2nTVtCY7/IjwpXPxqn5/T6NmefYQ+0Sqipa9sr7Rlc7MAVsYNGwU9rwktQ46niZSIaHJkzali8hYDzldWTBKKvuGCmzBR4EkiAhFb9O3/m6O690V1QZrouh4cdBA0BbRB9RL4IyzyufLvSLR0KokzrtDH1sF1K56n2+cErpcu++FUXGzpGp30pD45+uuQKN+0r1zh4zJAws5IJpc/x9QEK8ztVYQgXp+mH6HQGSaxxTzyCmwKjjkool/L6RgoD/E1DOeplWe2rasq9wi6pQRlkpYTk1J/1Dp44kRDgTcMCgaMb/qRuFKb7m2dWXKJyyl9fu0mVhxitEL5hbw== 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)(136003)(346002)(376002)(396003)(39850400004)(69590400012)(86362001)(66556008)(83380400001)(6666004)(478600001)(36756003)(6486002)(6916009)(44832011)(8936002)(2906002)(2616005)(316002)(6512007)(186003)(16526019)(52116002)(5660300002)(26005)(956004)(66476007)(66946007)(8676002)(6506007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: T8K8cOCCTSaGdp9PeDDbhTabrmvW4bPZWatd1ntYaFnS/Hupa9BqmAJaCsr2V6lPfpK9c3Ruz6wjkjH6IfUUxPA3J4rFFJOl7UxmE1VXdsN5z9VbjCwkVrLNPguz1DDZUczb5iFPlvFjJhoTlrn4w8XgXw8vjBXssnqjHsP/lQzjLaTaDQYfXPYlhfeQsUaND3y/5wV1jC0cvFvU7DALzpvxVSTA5mj/OxNZz8eeKSkBEnEjTpIGYSQxChlZWyHUadxY7GcdVo5w0Ms0bm0gKBdpL8Owckabh/ZVHcvpBGAedbf74S65NwOYag8n5zVxbcsm2fKXP9fYdSId6Ctttx4c73LLe4Er41DF04E5xpkH/KLOQfrppcvxOqJmuKXub7+zIyxP9ESjXHofmN9fq2Qk3UrlZkq9cFjuUaQotIjKITJGOrFyyJ3AJiy9/enWwK3zpFnmmuZDFwvsUsYyy2WFoTcgQJ7Cx4cbDK+lEZ2ujmXyLZELDSmTwDK6Y3DqRo6ADAf7NBbtKb8ysHCCECn1uIHWmkE5mXfVJFRdNWuEWSADujFdGP7pu7RPvUn0Gix+6KF62XN0QS7kKNRy38ayuvtCw8ZCCq0yhoXm6E6W1gtQLJKYOfnaOxvJWYfLBYvjivcASAQqF+t/L/wMce++xhny1cvisRZNgW8onwfV+HVPmLoo7hJs5DwH84cVtTeM4gykDBA7fllzuRP0x6/fQean4teH3xwTafjDg2VlZO+VafCPGGXXaDb5Fi/aopfYeFk4wxDbYczO6BsTF+6mCzRk0GKeZ3X9Hg7CqO5Nl9YWR9jz5HkYIfrJVqHMuUUSGTnzpRheEFvKiOGfBi2S0YB29wwq+33eklFfQWqkZ9I27LcdOOLX/W7WSBgvtNTfyFOzg9iXRxy4ozg690dZd4lVYAu/qSs/os4VK+XSknk2cgdUIaU4mRTzI6esSjLUwUry2ofhNjEjmhm/RlDWAb0+nzlWCgWo+jLm1YmDSJPc2x6OKD2JK5FVjtezPgK6PYJIQMDmiN/bXH8OKJ8wq3pvJOXYDmj/V45u3EeXZ+fcNaQKpgSXr4bKMUL6TQTSjrPLMr5HWcjVxmWgk5AHR//zE7+qFjAh0bL5upNZLfQzMOMwGKqz17GqZRDWmd4z4yjtWlI8U9IsMX4dh5x/eFxlyJxi8Z1t6LtS06W/K4zzFj2CzRRu2mmKJl5ZNBBPYEy48ou5m9oZPVL6d4O52n78W/fHzarYcZB8rc08BfRwUcz+PnQ6vW7Y95PTBXEdu5RdpBtWNRKtiZheUXNcy/4In6ZiLcf9eLqiJ6DK8751764QKHfWX88BXfaz X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6574 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: AM5EUR03FT007.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 1f9bc9ba-5565-4c5d-36d8-08d8df2b7588 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: y9lpeEcdcF/I28k3R6Ol9q1EhOe7j2zTyTDfwTqCubVcqpD4saXwN4DiwkAtzeXZ8gINDRW8ZmVI0Oy3XaBAl5XZoisIwJaGqQl/7aOFNnqXKwYqTI0guDIFsc8OsVKm/FhMtXSDT5xD7xPjJw4dXfs28Azabqj40xgtaKDVhxn51yCv9NsobEuCd+MLtC1TFEGkd8UYiRNxgRwGcib12a1YjY8At4ovhIq2CXYYxxk7P6aOR1N8e8PIHYdtK/SAsbVDbj/V5srfU5yrz4t5v6gtL45WdVme6z6dITRffrTFXTrqTPDsMNmYveviZhwe6M0LOAbUdGFhstwuS4+f+9S2qL8/mBrj4mguPhl8GkMN0jxk290Q1xDOzqx4X27bkSnQd6lNwt4VKsEDnV/8CRE16FDn00zZLdb5O/C9YfGzSCFOtxxiGzzIyrGTm8fz3VjcX0TZABD+2dCzPDWEtE9twwLJIuJfMYZcpst12xHOpYzpVLSitPrSiaHhwzQ7RRHi3E8jkI+U0n/81Cg/fm/nc36oX+/DqRgG42kRC4WSvI2ZgQ+jbFooGhopct2Po1JflpEUozKWs5fNBO/US3ojs6cXMwkO1wlhW8lC00KdBHT369VHRfJuQBOTJkMMPlkRUcTbjICeG6kBTyOH4pVhEl/WugxrNPWZT4i0F1mIwQyZm/iH0OhJSuBMm0DO 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)(39850400004)(396003)(376002)(346002)(136003)(36840700001)(46966006)(82310400003)(6512007)(69590400012)(356005)(36860700001)(36756003)(81166007)(47076005)(82740400003)(83380400001)(86362001)(8676002)(44832011)(70206006)(6486002)(70586007)(6506007)(2616005)(956004)(186003)(16526019)(6666004)(2906002)(336012)(26005)(8936002)(316002)(478600001)(5660300002)(6862004); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2021 16:35:27.3536 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cff06c59-74b3-444c-a993-08d8df2b8499 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: AM5EUR03FT007.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB1749 X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, 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-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" This is a target hook for memory tagging, the original was a naive implementation. Uses the same algorithm as __libc_mtag_tag_region, but with instructions that also zero the memory. This was not benchmarked on real cpu, but expected to be faster than the naive implementation. --- sysdeps/aarch64/__mtag_tag_zero_region.S | 96 ++++++++++++++++++++---- 1 file changed, 80 insertions(+), 16 deletions(-) diff --git a/sysdeps/aarch64/__mtag_tag_zero_region.S b/sysdeps/aarch64/__mtag_tag_zero_region.S index 74d398bba5..7d955fbd0c 100644 --- a/sysdeps/aarch64/__mtag_tag_zero_region.S +++ b/sysdeps/aarch64/__mtag_tag_zero_region.S @@ -20,30 +20,94 @@ #ifdef USE_MTAG +/* Assumptions: + * + * ARMv8-a, AArch64, MTE, LP64 ABI. + * + * Interface contract: + * Address is 16 byte aligned and size is multiple of 16. + * Returns the passed pointer. + * The memory region may remain untagged if tagging is not enabled. + */ .arch armv8.5-a .arch_extension memtag -/* NB, only supported on variants with 64-bit pointers. */ +#define dstin x0 +#define count x1 +#define dst x2 +#define dstend x3 +#define tmp x4 +#define zva_val x4 -/* FIXME: This is a minimal implementation. We could do much better than - this for large values of COUNT. */ +ENTRY (__libc_mtag_tag_zero_region) + PTR_ARG (0) + SIZE_ARG (1) -#define dstin x0 -#define count x1 -#define dst x2 + add dstend, dstin, count -ENTRY(__libc_mtag_tag_zero_region) + cmp count, 96 + b.hi L(set_long) - mov dst, dstin -L(loop): - stzg 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). + tbnz count, 6, L(set96) + + /* Set 0, 16, 32, or 48 bytes. */ + lsr tmp, count, 5 + add tmp, dstin, tmp, lsl 4 + cbz count, L(end) + stzg dstin, [dstin] + stzg dstin, [tmp] + stzg dstin, [dstend, -16] +L(end): + ret + + .p2align 4 + /* Set 64..96 bytes. Write 64 bytes from the start and + 32 bytes from the end. */ +L(set96): + stz2g dstin, [dstin] + stz2g dstin, [dstin, 32] + stz2g dstin, [dstend, -32] + ret + + .p2align 4 + /* Size is > 96 bytes. */ +L(set_long): + cmp count, 160 + b.lo L(no_zva) + +#ifndef SKIP_ZVA_CHECK + mrs zva_val, dczid_el0 + and zva_val, zva_val, 31 + cmp zva_val, 4 /* ZVA size is 64 bytes. */ + b.ne L(no_zva) #endif + stz2g dstin, [dstin] + stz2g dstin, [dstin, 32] + bic dst, dstin, 63 + sub count, dstend, dst /* Count is now 64 too large. */ + sub count, count, 128 /* Adjust count and bias for loop. */ + + .p2align 4 +L(zva_loop): + add dst, dst, 64 + dc gzva, dst + subs count, count, 64 + b.hi L(zva_loop) + stz2g dstin, [dstend, -64] + stz2g dstin, [dstend, -32] ret + +L(no_zva): + sub dst, dstin, 32 /* Dst is biased by -32. */ + sub count, count, 64 /* Adjust count for loop. */ +L(no_zva_loop): + stz2g dstin, [dst, 32] + stz2g dstin, [dst, 64]! + subs count, count, 64 + b.hi L(no_zva_loop) + stz2g dstin, [dstend, -64] + stz2g dstin, [dstend, -32] + ret + END (__libc_mtag_tag_zero_region) #endif /* USE_MTAG */