From patchwork Tue Feb 15 17:07:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 12747369 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EC9B0C433F5 for ; Tue, 15 Feb 2022 17:10:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=cQ74AqfsAIKNZ1dD+Cz9520Wp40q4CdFIaGEgpZ2Z6k=; b=KzpQmqv8K31L3r u23mj2Y7rXzVoQvPsgHI1iEo8/pEpdA7favcKqIH/vccnN/0Ve6VgpIj+brJo8euvY6z0LDBEOki5 GqyiRPuiEx5WuJfsU2wJVRom0JY0H97Yl64hXHVGqStBJ0FB6M6lt8O/Vyjqxp2pLgFr9IN/zrlPi DDSr7ZOwVfNCIjNzqkyaztMFWMl90YM7n4sPQNOKyYj2dp03CvmQ672EgJ4DLiLUW1n1Xi2xxm0P0 CcP0dJYqWaoJjMu+uYtLyQ8OsDHU4/Kk/N3lBLZmZoqaQIkpWmE6TJYVeoDrXIcYFuTrsP4nnsMlQ 4ob8UgXB9ATt99+z5pmA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nK1JN-003pow-Fu; Tue, 15 Feb 2022 17:08:21 +0000 Received: from mail-db8eur05on20604.outbound.protection.outlook.com ([2a01:111:f400:7e1a::604] helo=EUR05-DB8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nK1Iy-003piL-DP for linux-arm-kernel@lists.infradead.org; Tue, 15 Feb 2022 17:08:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7St+6tdKDAQvSf6DF+e7xpaqGJKLB2tp9iBvCw0PqRk=; b=CxArne4SG+ivZUXptlfTAk/7PClniazL89YmWDCXSIK3R05K3D0ikcsvQxnrn/kueOFig32Rg62JTvtfG1Zaa5mM3U80AUSSkjoyPai3atM2c5thzZLFAZRD89Ont06R/v8tKWnU91ebu09yTs2LMSwjYlp6PXUsuIXy/G+8WMU= Received: from AM6P195CA0016.EURP195.PROD.OUTLOOK.COM (2603:10a6:209:81::29) by VI1PR08MB5405.eurprd08.prod.outlook.com (2603:10a6:803:12f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11; Tue, 15 Feb 2022 17:07:51 +0000 Received: from AM5EUR03FT047.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:81:cafe::a0) by AM6P195CA0016.outlook.office365.com (2603:10a6:209:81::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.14 via Frontend Transport; Tue, 15 Feb 2022 17:07:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT047.mail.protection.outlook.com (10.152.16.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11 via Frontend Transport; Tue, 15 Feb 2022 17:07:50 +0000 Received: ("Tessian outbound 1f399c739551:v113"); Tue, 15 Feb 2022 17:07:50 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 7ec87b82db7ed525 X-CR-MTA-TID: 64aa7808 Received: from 78b22c12bee9.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id A4307632-81D1-4187-83F7-2EC65B202359.1; Tue, 15 Feb 2022 17:07:43 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 78b22c12bee9.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 15 Feb 2022 17:07:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fNHEoM3EcL0nvfJSMX9psllkxuCz8AGUu5r7QoQ8kPGKTgt/WJcG0F21NwkO8ULQ0AX3Yh0pGp2v5enFm9q+Suul/dCqboWQeFVB3JW4o4rmh4dXaiwc8fJwdJ5KsyyW6btxRxIjG3qEbMrBzvwuRnZdP5Bp9Jwx1Pr3PxCVikAie8w4SC7zii9Y4fB18LULJ3qMKJGR10B4kNVugow2MXqGnccchIVWDW6twjCdamnEumPufFhi3GA9K3B8qVHxvZf3ZqpmZbM539XKh8CEFcvq+rNqYHrkjJAhCvMCMLEtRduCztpNZVtwLoBC6yJt2+naCUu8ktRGHxbqmqaH2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7St+6tdKDAQvSf6DF+e7xpaqGJKLB2tp9iBvCw0PqRk=; b=Q5ih0PRWj3VZy71lsG5KDN/UkVklG+D1U/pDkhCs/H0nCGg8CQdQBPwkrF8jBMFayZn6myVxgc3jCNYisI8qYjSNND7w1s1vgALAbpLRJbRCAgSQUTIhX5fiZDPoTbOLQCrNCx/vSWZO4+h4wKoKvyA6nsFiDQXkZ3RGMpHUuvtdz40ZHHpjjieFJUBKoaHJAsWt3tCWJOG1NemCGUUUTY5ajSB9CfcT6FPJGGOzqwl4D6ABAobDloWxbDqrB0laZyCYv6dPP/RxWVMtNpq3cjIPmi2+zTrgVv0pQ6+5eOlfeyQ+23I5k6rgtqpcSw88ze4/38lrItsSGZ6Xqd4BiQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7St+6tdKDAQvSf6DF+e7xpaqGJKLB2tp9iBvCw0PqRk=; b=CxArne4SG+ivZUXptlfTAk/7PClniazL89YmWDCXSIK3R05K3D0ikcsvQxnrn/kueOFig32Rg62JTvtfG1Zaa5mM3U80AUSSkjoyPai3atM2c5thzZLFAZRD89Ont06R/v8tKWnU91ebu09yTs2LMSwjYlp6PXUsuIXy/G+8WMU= Received: from AM6PR05CA0027.eurprd05.prod.outlook.com (2603:10a6:20b:2e::40) by VE1PR08MB5261.eurprd08.prod.outlook.com (2603:10a6:803:10d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.17; Tue, 15 Feb 2022 17:07:40 +0000 Received: from AM5EUR03FT011.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:2e:cafe::e4) by AM6PR05CA0027.outlook.office365.com (2603:10a6:20b:2e::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.14 via Frontend Transport; Tue, 15 Feb 2022 17:07:39 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; Received: from nebula.arm.com (40.67.248.234) by AM5EUR03FT011.mail.protection.outlook.com (10.152.16.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4975.11 via Frontend Transport; Tue, 15 Feb 2022 17:07:38 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Tue, 15 Feb 2022 17:07:42 +0000 Received: from e124191.cambridge.arm.com (10.1.197.45) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2308.20 via Frontend Transport; Tue, 15 Feb 2022 17:07:42 +0000 From: Joey Gouly To: CC: , , , , , Subject: [PATCH v1 1/3] arm64: lib: Import latest version of Arm Optimized Routines' strcmp Date: Tue, 15 Feb 2022 17:07:21 +0000 Message-ID: <20220215170723.21266-2-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220215170723.21266-1-joey.gouly@arm.com> References: <20220215170723.21266-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: a47cfc6e-8ec7-487b-f996-08d9f0a5b2cf X-MS-TrafficTypeDiagnostic: VE1PR08MB5261:EE_|AM5EUR03FT047:EE_|VI1PR08MB5405:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:5236;OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: iHNOPrESG4/5LEDhkrC2KXxA8a2IbcX3ImlZBQRgiVwlHaAqXIhB+2W1tTUx9v2gfJXykCKPA8RwIESBEpCjjmpik6SV+aj7qLBKlz9YCprDF9xjUkDHkhzxLTqM2AVdmrNK/vRDF9EAppuOh2vUS9LLqhaFlxrNjq3NAEawNfRzeGXJkFksXFUR85ulFPcFU4UoXQS7Ku01JWm4ioGLiaOuukTz1Egp1cMpIdFFkJkwRTr64WY3z7o3msXtpk/JauyHa7d+0Vp1F/4vl5iyPI8z5UkQadiRFFBGZ5RGQ+bMUHcJ64PL/n1GrxQtZIQ6ImfeyvvCPdpjKQ/hZZZ/iSR/4G0Tzhi6vcdnTtFMADxOFfClvzMUxEKtL4yxZl+4qnIF1VUlu+Lbs2BQ8p8kkxTG9OwfAYWrPZzfetnfMC3z5Q3nMzosvzFy4BCGB1ZTHNEZRo2KFLJG0ctfCv0PTBi80JzPyt8kCC2TxCh5S2JGSe8WpUN0D65GZOwtjxH39kXjoj4JVK+a1Rzs9boEEmTxgoQyBKKQiiOHWzsoZc5HZ3b3AD/OGUazJzEu3EUl/4neP3q3VGjlWVooUvrcaWiYeE1ckq15Sx+ugH3yUvZjxd8Wzs/45MxGdyyRi1jvgA37NpC2/HqOTKXnjp/6eOYr4hcYo8UxNgsFo8a7xxnptGnXTh+3mut2e1iICd0Wykpb/snACv0gxB4PgrIo2T8MtSJ44IP8ZfQBYTBFO/e5GKhU9dESs8kbICBXvSFt39LEeg+3QgWcQfOxn1sRrHHM67D6/fUmbY0J7+eVHc6VS+BzvwOTYnilcGpt9r0WqYWJQ0nGlgSWZtIMEo5KJGJhfmXwuYgs2sWo8Wpjm2oKnx+Y68w75wAl1vBqAh5DZXjOC4UGdr9aFOOBZSqBRUKNEHZFkPxwh09tpinPGos= X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:nebula.arm.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(966005)(36756003)(7696005)(2906002)(6916009)(6666004)(316002)(44832011)(4326008)(2616005)(86362001)(508600001)(54906003)(8936002)(1076003)(5660300002)(336012)(426003)(186003)(8676002)(70206006)(70586007)(82310400004)(26005)(356005)(40460700003)(36860700001)(47076005)(83380400001)(81166007)(17423001)(156123004)(36900700001)(357404004); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5261 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT047.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: eab01dcf-6a5d-46cb-ceec-08d9f0a5ab9c X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eSVTNo8j7oeHEj/CguDMPexwziq7+nAmWxm7ceSB+x3fgh4GXsEV8rpQDKs1bbrt71UFA9tb4pgH1cwzP4UR4Dt7IUQdQWCUbc3gxOuAWKvGeagPjEciFGmmjQ0qLWU9Xo6rzWM64IVEFyS6ByVVTGI4T/hUtHEpKuipLwhSE5WewlXsWjuBSM005DTiuzBm+otymLnBzgOe5DT+0SE/YOJ5/ivXjPV5U7ZV0YVNuc5fex866y3hRFjWcffi5gv2CHQbI3/Ll/EyDqfdqGbmYapYGQNM4agCQ7KLTaMeB5flI8/xEDR/s0NlvQwpEIO6FLOqbSIFEhAdfVGw+0ZMy/f0vegLqNNSn/WcLdHwcvoLo2HZOD4IgmlGyw11ke0BuNt+mEx3KvQ6K8fR8bWuksvFrd94y+OWH4LVwvXZUZEhHSnotfxQq/LcVrzJOFsEjh+4meOpWAUnbjCsfwdy0G1QsiISrgOMEGP+v7QcudzC7s77Ksez6o7lyZSzP9aCWcr7IS3u68r7SIrGp87RLljS7otkVmBAxblEKvhS2VR2SMmkPAirmpnWZDNgXlG8Qa7LbGhsH81yR+S0Erv2cyKfebUtf12X/WSuYBQ6Hf6OBfpSM5by5jqhWZ3y8c4nfj3z0SRCmQbBEuigSjlpB0eQ+nsva2/x9ei4ipaAk39fVZlbN5+GaWH2rCNgFvCIUBbp2WR9kpixQf8CGHREwmagU2w2hhehmV0RxmREfRhaNexq4koDdNOmhpmzg6T6TNBtmeDVXncbo8VmrKhJ22Wmre2WvKKtj5mkwvEiO1q2e/kPBsGNNM+LCe8PSNUQPYPZbDkuAqjJ59Bmv1/KyTh88iu2S4oc4AWg6IjxCWLsNFOcT7oMD2GItwpRIJp/ 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:(13230001)(4636009)(36840700001)(46966006)(40470700004)(6916009)(186003)(336012)(316002)(966005)(508600001)(426003)(36756003)(81166007)(54906003)(26005)(86362001)(1076003)(8936002)(83380400001)(4326008)(8676002)(40460700003)(44832011)(2906002)(70586007)(70206006)(6666004)(82310400004)(5660300002)(2616005)(47076005)(36860700001)(7696005)(107886003)(17423001)(156123004)(357404004); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2022 17:07:50.9186 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a47cfc6e-8ec7-487b-f996-08d9f0a5b2cf 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: AM5EUR03FT047.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB5405 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220215_090756_680164_28E4DAF7 X-CRM114-Status: GOOD ( 15.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Import the latest version of the Arm Optimized Routines strcmp function based on the upstream code of string/aarch64/strcmp.S at commit 189dfefe37d5 from: https://github.com/ARM-software/optimized-routines This latest version includes MTE support. Signed-off-by: Joey Gouly Cc: Robin Murphy Cc: Mark Rutland Cc: Catalin Marinas Cc: Will Deacon --- arch/arm64/lib/strcmp.S | 238 +++++++++++++++++++++------------------- 1 file changed, 126 insertions(+), 112 deletions(-) diff --git a/arch/arm64/lib/strcmp.S b/arch/arm64/lib/strcmp.S index 83bcad72ec97..758de77afd2f 100644 --- a/arch/arm64/lib/strcmp.S +++ b/arch/arm64/lib/strcmp.S @@ -1,9 +1,9 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * Copyright (c) 2012-2021, Arm Limited. + * Copyright (c) 2012-2022, Arm Limited. * * Adapted from the original at: - * https://github.com/ARM-software/optimized-routines/blob/afd6244a1f8d9229/string/aarch64/strcmp.S + * https://github.com/ARM-software/optimized-routines/blob/189dfefe37d54c5b/string/aarch64/strcmp.S */ #include @@ -11,161 +11,175 @@ /* Assumptions: * - * ARMv8-a, AArch64 + * ARMv8-a, AArch64. + * MTE compatible. */ #define L(label) .L ## label #define REP8_01 0x0101010101010101 #define REP8_7f 0x7f7f7f7f7f7f7f7f -#define REP8_80 0x8080808080808080 -/* Parameters and result. */ #define src1 x0 #define src2 x1 #define result x0 -/* Internal variables. */ #define data1 x2 #define data1w w2 #define data2 x3 #define data2w w3 #define has_nul x4 #define diff x5 +#define off1 x5 #define syndrome x6 -#define tmp1 x7 -#define tmp2 x8 -#define tmp3 x9 -#define zeroones x10 -#define pos x11 - - /* Start of performance-critical section -- one 64B cache line. */ - .align 6 +#define tmp x6 +#define data3 x7 +#define zeroones x8 +#define shift x9 +#define off2 x10 + +/* On big-endian early bytes are at MSB and on little-endian LSB. + LS_FW means shifting towards early bytes. */ +#ifdef __AARCH64EB__ +# define LS_FW lsl +#else +# define LS_FW lsr +#endif + +/* NUL detection works on the principle that (X - 1) & (~X) & 0x80 + (=> (X - 1) & ~(X | 0x7f)) is non-zero iff a byte is zero, and + can be done in parallel across the entire word. + Since carry propagation makes 0x1 bytes before a NUL byte appear + NUL too in big-endian, byte-reverse the data before the NUL check. */ + + SYM_FUNC_START_WEAK_PI(strcmp) - eor tmp1, src1, src2 - mov zeroones, #REP8_01 - tst tmp1, #7 + sub off2, src2, src1 + mov zeroones, REP8_01 + and tmp, src1, 7 + tst off2, 7 b.ne L(misaligned8) - ands tmp1, src1, #7 - b.ne L(mutual_align) - /* NUL detection works on the principle that (X - 1) & (~X) & 0x80 - (=> (X - 1) & ~(X | 0x7f)) is non-zero iff a byte is zero, and - can be done in parallel across the entire word. */ + cbnz tmp, L(mutual_align) + + .p2align 4 + L(loop_aligned): - ldr data1, [src1], #8 - ldr data2, [src2], #8 + ldr data2, [src1, off2] + ldr data1, [src1], 8 L(start_realigned): - sub tmp1, data1, zeroones - orr tmp2, data1, #REP8_7f - eor diff, data1, data2 /* Non-zero if differences found. */ - bic has_nul, tmp1, tmp2 /* Non-zero if NUL terminator. */ +#ifdef __AARCH64EB__ + rev tmp, data1 + sub has_nul, tmp, zeroones + orr tmp, tmp, REP8_7f +#else + sub has_nul, data1, zeroones + orr tmp, data1, REP8_7f +#endif + bics has_nul, has_nul, tmp /* Non-zero if NUL terminator. */ + ccmp data1, data2, 0, eq + b.eq L(loop_aligned) +#ifdef __AARCH64EB__ + rev has_nul, has_nul +#endif + eor diff, data1, data2 orr syndrome, diff, has_nul - cbz syndrome, L(loop_aligned) - /* End of performance-critical section -- one 64B cache line. */ - L(end): -#ifndef __AARCH64EB__ +#ifndef __AARCH64EB__ rev syndrome, syndrome rev data1, data1 - /* The MS-non-zero bit of the syndrome marks either the first bit - that is different, or the top bit of the first zero byte. - Shifting left now will bring the critical information into the - top bits. */ - clz pos, syndrome rev data2, data2 - lsl data1, data1, pos - lsl data2, data2, pos - /* But we need to zero-extend (char is unsigned) the value and then - perform a signed 32-bit subtraction. */ - lsr data1, data1, #56 - sub result, data1, data2, lsr #56 - ret -#else - /* For big-endian we cannot use the trick with the syndrome value - as carry-propagation can corrupt the upper bits if the trailing - bytes in the string contain 0x01. */ - /* However, if there is no NUL byte in the dword, we can generate - the result directly. We can't just subtract the bytes as the - MSB might be significant. */ - cbnz has_nul, 1f - cmp data1, data2 - cset result, ne - cneg result, result, lo - ret -1: - /* Re-compute the NUL-byte detection, using a byte-reversed value. */ - rev tmp3, data1 - sub tmp1, tmp3, zeroones - orr tmp2, tmp3, #REP8_7f - bic has_nul, tmp1, tmp2 - rev has_nul, has_nul - orr syndrome, diff, has_nul - clz pos, syndrome - /* The MS-non-zero bit of the syndrome marks either the first bit - that is different, or the top bit of the first zero byte. +#endif + clz shift, syndrome + /* The most-significant-non-zero bit of the syndrome marks either the + first bit that is different, or the top bit of the first zero byte. Shifting left now will bring the critical information into the top bits. */ - lsl data1, data1, pos - lsl data2, data2, pos + lsl data1, data1, shift + lsl data2, data2, shift /* But we need to zero-extend (char is unsigned) the value and then perform a signed 32-bit subtraction. */ - lsr data1, data1, #56 - sub result, data1, data2, lsr #56 + lsr data1, data1, 56 + sub result, data1, data2, lsr 56 ret -#endif + + .p2align 4 L(mutual_align): /* Sources are mutually aligned, but are not currently at an alignment boundary. Round down the addresses and then mask off - the bytes that preceed the start point. */ - bic src1, src1, #7 - bic src2, src2, #7 - lsl tmp1, tmp1, #3 /* Bytes beyond alignment -> bits. */ - ldr data1, [src1], #8 - neg tmp1, tmp1 /* Bits to alignment -64. */ - ldr data2, [src2], #8 - mov tmp2, #~0 -#ifdef __AARCH64EB__ - /* Big-endian. Early bytes are at MSB. */ - lsl tmp2, tmp2, tmp1 /* Shift (tmp1 & 63). */ -#else - /* Little-endian. Early bytes are at LSB. */ - lsr tmp2, tmp2, tmp1 /* Shift (tmp1 & 63). */ -#endif - orr data1, data1, tmp2 - orr data2, data2, tmp2 + the bytes that precede the start point. */ + bic src1, src1, 7 + ldr data2, [src1, off2] + ldr data1, [src1], 8 + neg shift, src2, lsl 3 /* Bits to alignment -64. */ + mov tmp, -1 + LS_FW tmp, tmp, shift + orr data1, data1, tmp + orr data2, data2, tmp b L(start_realigned) L(misaligned8): /* Align SRC1 to 8 bytes and then compare 8 bytes at a time, always - checking to make sure that we don't access beyond page boundary in - SRC2. */ - tst src1, #7 - b.eq L(loop_misaligned) + checking to make sure that we don't access beyond the end of SRC2. */ + cbz tmp, L(src1_aligned) L(do_misaligned): - ldrb data1w, [src1], #1 - ldrb data2w, [src2], #1 - cmp data1w, #1 - ccmp data1w, data2w, #0, cs /* NZCV = 0b0000. */ + ldrb data1w, [src1], 1 + ldrb data2w, [src2], 1 + cmp data1w, 0 + ccmp data1w, data2w, 0, ne /* NZCV = 0b0000. */ b.ne L(done) - tst src1, #7 + tst src1, 7 b.ne L(do_misaligned) -L(loop_misaligned): - /* Test if we are within the last dword of the end of a 4K page. If - yes then jump back to the misaligned loop to copy a byte at a time. */ - and tmp1, src2, #0xff8 - eor tmp1, tmp1, #0xff8 - cbz tmp1, L(do_misaligned) - ldr data1, [src1], #8 - ldr data2, [src2], #8 - - sub tmp1, data1, zeroones - orr tmp2, data1, #REP8_7f - eor diff, data1, data2 /* Non-zero if differences found. */ - bic has_nul, tmp1, tmp2 /* Non-zero if NUL terminator. */ +L(src1_aligned): + neg shift, src2, lsl 3 + bic src2, src2, 7 + ldr data3, [src2], 8 +#ifdef __AARCH64EB__ + rev data3, data3 +#endif + lsr tmp, zeroones, shift + orr data3, data3, tmp + sub has_nul, data3, zeroones + orr tmp, data3, REP8_7f + bics has_nul, has_nul, tmp + b.ne L(tail) + + sub off1, src2, src1 + + .p2align 4 + +L(loop_unaligned): + ldr data3, [src1, off1] + ldr data2, [src1, off2] +#ifdef __AARCH64EB__ + rev data3, data3 +#endif + sub has_nul, data3, zeroones + orr tmp, data3, REP8_7f + ldr data1, [src1], 8 + bics has_nul, has_nul, tmp + ccmp data1, data2, 0, eq + b.eq L(loop_unaligned) + + lsl tmp, has_nul, shift +#ifdef __AARCH64EB__ + rev tmp, tmp +#endif + eor diff, data1, data2 + orr syndrome, diff, tmp + cbnz syndrome, L(end) +L(tail): + ldr data1, [src1] + neg shift, shift + lsr data2, data3, shift + lsr has_nul, has_nul, shift +#ifdef __AARCH64EB__ + rev data2, data2 + rev has_nul, has_nul +#endif + eor diff, data1, data2 orr syndrome, diff, has_nul - cbz syndrome, L(loop_misaligned) b L(end) L(done): From patchwork Tue Feb 15 17:07:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 12747370 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9E918C433EF for ; Tue, 15 Feb 2022 17:10:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=URhjIocg/v3vX1xMHZ/WZLlZPwjYmydnmFkkwnkeeaI=; b=iH0zXJDRkGSMJB 1sWsT+axj/pkL2l6AmXTW4CatO0R3Sq88c8C9FG/UKUTQ8OPMVd/evrK2rgxi7TiSkfg0Mk9asHMa fNXM++oVV/RfaWXB85XfdWlR8SWaTKn+JY4e8o0cN2ALACDOdaVTvyFCwaCiFXhFMv64Yc+KQepKn i5Nz8/rfAFnKUKVzrbewb6/7hXibkVmagc+LfCzSkYfdEdFgwuv/eIFl//S5oEZaG2CJTRXCNGW+w ZhnWYXA+rhY5zqKJ2fCVQnhMD+97GkpTgvY4u7uQhwtTZJS7TT4onbPnLQpPMbaOwo4Zfin4IakXX g5t67l3GiOw3vEpkNUSw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nK1Ja-003ptA-R4; Tue, 15 Feb 2022 17:08:35 +0000 Received: from mail-he1eur04on0611.outbound.protection.outlook.com ([2a01:111:f400:fe0d::611] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nK1Iy-003piK-Ti for linux-arm-kernel@lists.infradead.org; Tue, 15 Feb 2022 17:08:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DSceSedckHVuGQDyA/AN2uzhWfucWsvHhIF0uLhkRo8=; b=xFfUJZ5y/nXG7AezNJDjea9RvlyEtNi/m49lIRJ6v2UoTdPjJIZuejUWsDqYDEAIWXVmxq8OqyW3nsxoXfW0UNe8tQs5HBlazzD83mA9rkjG/qGPUtu23Jekyh49IL7k0xFeFd/zENOHCIpaTJ/5irPkyC3XJxRs/jF2fFR0klg= Received: from DB8P191CA0010.EURP191.PROD.OUTLOOK.COM (2603:10a6:10:130::20) by PR2PR08MB5225.eurprd08.prod.outlook.com (2603:10a6:101:1c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.17; Tue, 15 Feb 2022 17:07:50 +0000 Received: from DB5EUR03FT003.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:130:cafe::e9) by DB8P191CA0010.outlook.office365.com (2603:10a6:10:130::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.12 via Frontend Transport; Tue, 15 Feb 2022 17:07:50 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT003.mail.protection.outlook.com (10.152.20.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11 via Frontend Transport; Tue, 15 Feb 2022 17:07:50 +0000 Received: ("Tessian outbound 741ca6c82739:v113"); Tue, 15 Feb 2022 17:07:50 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 3601649839c718bf X-CR-MTA-TID: 64aa7808 Received: from 3e3df595a1b6.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id C2F9A8A4-71F3-4E37-BEF3-9CE3652A5F0B.1; Tue, 15 Feb 2022 17:07:43 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 3e3df595a1b6.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 15 Feb 2022 17:07:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QKewBvgumWSczDILeQWBMxG74ItvVz8OBzPXj7J9gV1i8vsQn3tHuCvJ9qiDD7Pa62pW6V8X6JotwW3pgLBesv4cOcLGBAAnOT8J1f9jhlMnVRr8gWDGrZlMunw+nwSR3Bqi6fE3NvaR+XxtS13tgV0Z0EncVxVvi0wEMaDhTd3lV6u4YvmXiv7oGNKGuJkpNI5le+Kvbr+jYkixkx702PPtb48xdDiVJ0hz/u2U0iuEQTVpyCLTmyQNKStew0ryXtfTysNyiBWYLoXKcCx3TfPL3EFB0gRAaOrdaPJm8s926+6dmvnIrwLD/mZuQq6Nh1hBhTP3UcjG7pZZGYn8Ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=DSceSedckHVuGQDyA/AN2uzhWfucWsvHhIF0uLhkRo8=; b=hY3WmACnlZrQJkWPd5jbkNi+PHhhixJLwDia0tKbUuq+JsolH41D2xTvgDymIlui68SpuOFQXE0KNcCzsJN5di+4Rae8s10v9Ihwf76hGp+vnoE+l4ZjfZuHuqZDWrLOiaTYk5RcW4LxPF0R/hS9+mc/8y/qiPzr9KM1fjpI3WjvhaVk7MdWJJv5UJTZ2WPahelNjbXNmERJs8W/bDa2r7uG6WkjI7QeWLZMaJJiHX0NZGVHS+jLROKaCPFSSu53GZG5PwavF8E1jHQaBgmfH3XCLfPRtLtqmg7pSt4MJAmXjIgkBKelMOZzI38Djt8dB7zVR4tPO/1vApnlCr/l9Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DSceSedckHVuGQDyA/AN2uzhWfucWsvHhIF0uLhkRo8=; b=xFfUJZ5y/nXG7AezNJDjea9RvlyEtNi/m49lIRJ6v2UoTdPjJIZuejUWsDqYDEAIWXVmxq8OqyW3nsxoXfW0UNe8tQs5HBlazzD83mA9rkjG/qGPUtu23Jekyh49IL7k0xFeFd/zENOHCIpaTJ/5irPkyC3XJxRs/jF2fFR0klg= Received: from AM6PR05CA0014.eurprd05.prod.outlook.com (2603:10a6:20b:2e::27) by AM6PR08MB4582.eurprd08.prod.outlook.com (2603:10a6:20b:8f::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.12; Tue, 15 Feb 2022 17:07:42 +0000 Received: from AM5EUR03FT011.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:2e:cafe::ec) by AM6PR05CA0014.outlook.office365.com (2603:10a6:20b:2e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.14 via Frontend Transport; Tue, 15 Feb 2022 17:07:41 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; Received: from nebula.arm.com (40.67.248.234) by AM5EUR03FT011.mail.protection.outlook.com (10.152.16.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4975.11 via Frontend Transport; Tue, 15 Feb 2022 17:07:41 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Tue, 15 Feb 2022 17:07:42 +0000 Received: from e124191.cambridge.arm.com (10.1.197.45) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2308.20 via Frontend Transport; Tue, 15 Feb 2022 17:07:42 +0000 From: Joey Gouly To: CC: , , , , , Subject: [PATCH v1 2/3] arm64: lib: Import latest version of Arm Optimized Routines' strncmp Date: Tue, 15 Feb 2022 17:07:22 +0000 Message-ID: <20220215170723.21266-3-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220215170723.21266-1-joey.gouly@arm.com> References: <20220215170723.21266-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: 0af925d4-591f-434a-2e38-08d9f0a5b24e X-MS-TrafficTypeDiagnostic: AM6PR08MB4582:EE_|DB5EUR03FT003:EE_|PR2PR08MB5225:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:4125;OLM:4125; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: K54h73AkRKPsyg+0OPwjm/cjlMWN0OMAeL8SRTd/3Qr3RVpbCPvPyJsIIGfzfOUQwNQvPRaW1dz2n2dkr9rZ8VK150QDBuKkEejFKgNa62WHRQQsZTKbRA/vtiVecucjRec6Y8prSKzNE0o2SU1zvCju0S0h3w3JGQMTCEYX8Cl2eaU4cFLWPQ39DrnFCXAxU7JOKOs0KodveyvappHwQLRo36grafyld0E5ixxEAlfYpU9TRrPyMj6XpbyG6t1ND7awtMoDpkaQLc3jYprjv/0tMoFjSCdCUQhsMqM4LaFhIkh1xqsFiAw6t1Gczi67/9ta4dLvy0TJDwSZnEe9QHo1oE1dD3Ufh/WAmgpyOfBoVCXLMuSLwXhnKMYJCyQimYE05WJvQEceziSjle/jmiGelkGZMgMCDn+6519rQQVqZzfNd48fC+8ZNg5q2lzNNViha9b5hHbpCtlHTMTk7Uwkdflrju4LX6S54kW7eJWyPlABFk/SiQwAjH+d8Wr6z02aOtgCC9DT5tCzV56T/LUINa5x1UcadXCrf8iF+brzy38HmT87VYczGvUwcx6a+JVEquhz4W2XkqGw72uUI6FKKbHeGUgr+mq1ZJgKXyUIdoiTsiTY5PYblylLgsnlCK7QF1BREmCLVNM/oiBwhrd+jiHxpVz5MV0bB2uxRB+R/um9ASLibfVf5RAzS50s2XKh9gdomhg3C5umnJN2VgM6fFQ7ZmlYEh/dQXbJQv5qkJTrB1z6lL4qkOpjwRhLG3KjQ6a75JBFOFJtQJ2NMPxuq0LJMlBv2OXJHa9GzlZKobbQZ/F3WwuYHb9oCQhAagXPaySo7mMCowF0S4W9UQU1WcqeXNGkn4PrHO+AiLi90rCW6Kk52+s6BOmCTAQrKBO6E5bMnxWoTVpOkNJ6ww== X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:nebula.arm.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(36860700001)(7696005)(36756003)(44832011)(2616005)(508600001)(86362001)(6666004)(40460700003)(6916009)(966005)(54906003)(336012)(426003)(1076003)(26005)(186003)(316002)(5660300002)(83380400001)(82310400004)(81166007)(47076005)(30864003)(8936002)(8676002)(70586007)(70206006)(4326008)(356005)(2906002)(17423001)(156123004)(36900700001)(357404004); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4582 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT003.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 6d76380d-3145-4696-dade-08d9f0a5ad42 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wU7rARPe99cNvxcn4jfzXTylOWMq6ciKU8HbEBOT/JMn6hKqvB8ROM/V3dtno02zxKD26qMDkfh7/PVy3ODaU8aJwbi156mJ82kwY5aKpapNIGFmQD0pamXmO/pthdbjcOsuO6CV4Cg1DpR4QH5FGvk765u1MXyNVvy2t1gcgP+TnmOs4D2T2sXY3XMeEyFkOZ65Fp9PpiV9rsMcAhLFjNl9IzIdm1/HjbTsn/pTWVa4N+bxLRBrNff90IGfYNLe79FehD9daZNKyYue6OuE6ArIQ5Jo/v2fYsREwstBs416YDkGLZAnSKAlblr9A+BAbvWKRRe9W70DiCW6ZdFixKJBgIbJ8Vc1a8wYybpIahawlWKRirocj8K0i6n3DWaRfWEZ6hn7p0ajDILoAsjCPTFEt5it7Q6VVysvJPCu5SsNCSIwakhCrcHzO3EjYiXFmLghY2RqJDPbBUb8fQkO+Y1e2qTJ4nolEmlZToKipIvJCTstl5Q/O5lFlqW5RFoqGD85alZW7H1OUm752X5LSP5AbzNq96K+odye11h0lUfKkiEovxpgm0zYCDM8wUK9eqj/hGNBCibD0Rb1ZXYbmnblROPaEwYHIFkIElETpHbFKQUmY9PZRZFGje13F/lmMxlOK9a+O6Ko/L2fbbERbn3kXp54MLfYx2+Hb+Ugf+uPdERX3ewxz0KCMn0ZUigQbwTkGKMMm/VWhs/BNTH+Lq1n4XihTVgNpOwAADJjufzsmGxTmTd3gMNzXS1fLHTlTMZ5Z+nCH6ang5CNKDClAXJCA0cERme230H4cDuwLV3z4CD2qGuoSDdip0khovf/UhdxGU+pueeloqALeo21cpLxOAjw+7y+7VJ04h+lXgbhV3uGxqjQf5igYTQuuH9J 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:(13230001)(4636009)(46966006)(36840700001)(40470700004)(26005)(5660300002)(44832011)(107886003)(81166007)(186003)(82310400004)(36756003)(86362001)(7696005)(83380400001)(30864003)(4326008)(2906002)(8936002)(8676002)(1076003)(316002)(40460700003)(508600001)(47076005)(36860700001)(426003)(336012)(2616005)(70586007)(70206006)(6666004)(6916009)(966005)(54906003)(17423001)(156123004)(357404004); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2022 17:07:50.1217 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0af925d4-591f-434a-2e38-08d9f0a5b24e 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: DB5EUR03FT003.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR2PR08MB5225 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220215_090757_222682_EC823AD7 X-CRM114-Status: GOOD ( 15.04 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Import the latest version of the Arm Optimized Routines strncmp function based on the upstream code of string/aarch64/strncmp.S at commit 189dfefe37d5 from: https://github.com/ARM-software/optimized-routines This latest version includes MTE support. Signed-off-by: Joey Gouly Cc: Robin Murphy Cc: Mark Rutland Cc: Catalin Marinas Cc: Will Deacon --- arch/arm64/lib/strncmp.S | 234 +++++++++++++++++++++++---------------- 1 file changed, 141 insertions(+), 93 deletions(-) diff --git a/arch/arm64/lib/strncmp.S b/arch/arm64/lib/strncmp.S index e42bcfcd37e6..a4884b97e9a8 100644 --- a/arch/arm64/lib/strncmp.S +++ b/arch/arm64/lib/strncmp.S @@ -1,9 +1,9 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * Copyright (c) 2013-2021, Arm Limited. + * Copyright (c) 2013-2022, Arm Limited. * * Adapted from the original at: - * https://github.com/ARM-software/optimized-routines/blob/e823e3abf5f89ecb/string/aarch64/strncmp.S + * https://github.com/ARM-software/optimized-routines/blob/189dfefe37d54c5b/string/aarch64/strncmp.S */ #include @@ -11,14 +11,14 @@ /* Assumptions: * - * ARMv8-a, AArch64 + * ARMv8-a, AArch64. + * MTE compatible. */ #define L(label) .L ## label #define REP8_01 0x0101010101010101 #define REP8_7f 0x7f7f7f7f7f7f7f7f -#define REP8_80 0x8080808080808080 /* Parameters and result. */ #define src1 x0 @@ -39,10 +39,24 @@ #define tmp3 x10 #define zeroones x11 #define pos x12 -#define limit_wd x13 -#define mask x14 -#define endloop x15 +#define mask x13 +#define endloop x14 #define count mask +#define offset pos +#define neg_offset x15 + +/* Define endian dependent shift operations. + On big-endian early bytes are at MSB and on little-endian LSB. + LS_FW means shifting towards early bytes. + LS_BK means shifting towards later bytes. + */ +#ifdef __AARCH64EB__ +#define LS_FW lsl +#define LS_BK lsr +#else +#define LS_FW lsr +#define LS_BK lsl +#endif SYM_FUNC_START_WEAK_PI(strncmp) cbz limit, L(ret0) @@ -52,9 +66,6 @@ SYM_FUNC_START_WEAK_PI(strncmp) and count, src1, #7 b.ne L(misaligned8) cbnz count, L(mutual_align) - /* Calculate the number of full and partial words -1. */ - sub limit_wd, limit, #1 /* limit != 0, so no underflow. */ - lsr limit_wd, limit_wd, #3 /* Convert to Dwords. */ /* NUL detection works on the principle that (X - 1) & (~X) & 0x80 (=> (X - 1) & ~(X | 0x7f)) is non-zero iff a byte is zero, and @@ -64,56 +75,52 @@ L(loop_aligned): ldr data1, [src1], #8 ldr data2, [src2], #8 L(start_realigned): - subs limit_wd, limit_wd, #1 + subs limit, limit, #8 sub tmp1, data1, zeroones orr tmp2, data1, #REP8_7f eor diff, data1, data2 /* Non-zero if differences found. */ - csinv endloop, diff, xzr, pl /* Last Dword or differences. */ + csinv endloop, diff, xzr, hi /* Last Dword or differences. */ bics has_nul, tmp1, tmp2 /* Non-zero if NUL terminator. */ ccmp endloop, #0, #0, eq b.eq L(loop_aligned) /* End of main loop */ - /* Not reached the limit, must have found the end or a diff. */ - tbz limit_wd, #63, L(not_limit) - - /* Limit % 8 == 0 => all bytes significant. */ - ands limit, limit, #7 - b.eq L(not_limit) - - lsl limit, limit, #3 /* Bits -> bytes. */ - mov mask, #~0 -#ifdef __AARCH64EB__ - lsr mask, mask, limit -#else - lsl mask, mask, limit -#endif - bic data1, data1, mask - bic data2, data2, mask - - /* Make sure that the NUL byte is marked in the syndrome. */ - orr has_nul, has_nul, mask - -L(not_limit): +L(full_check): +#ifndef __AARCH64EB__ orr syndrome, diff, has_nul - -#ifndef __AARCH64EB__ + add limit, limit, 8 /* Rewind limit to before last subs. */ +L(syndrome_check): + /* Limit was reached. Check if the NUL byte or the difference + is before the limit. */ rev syndrome, syndrome rev data1, data1 - /* The MS-non-zero bit of the syndrome marks either the first bit - that is different, or the top bit of the first zero byte. - Shifting left now will bring the critical information into the - top bits. */ clz pos, syndrome rev data2, data2 lsl data1, data1, pos + cmp limit, pos, lsr #3 lsl data2, data2, pos /* But we need to zero-extend (char is unsigned) the value and then perform a signed 32-bit subtraction. */ lsr data1, data1, #56 sub result, data1, data2, lsr #56 + csel result, result, xzr, hi ret #else + /* Not reached the limit, must have found the end or a diff. */ + tbz limit, #63, L(not_limit) + add tmp1, limit, 8 + cbz limit, L(not_limit) + + lsl limit, tmp1, #3 /* Bits -> bytes. */ + mov mask, #~0 + lsr mask, mask, limit + bic data1, data1, mask + bic data2, data2, mask + + /* Make sure that the NUL byte is marked in the syndrome. */ + orr has_nul, has_nul, mask + +L(not_limit): /* For big-endian we cannot use the trick with the syndrome value as carry-propagation can corrupt the upper bits if the trailing bytes in the string contain 0x01. */ @@ -134,10 +141,11 @@ L(not_limit): rev has_nul, has_nul orr syndrome, diff, has_nul clz pos, syndrome - /* The MS-non-zero bit of the syndrome marks either the first bit - that is different, or the top bit of the first zero byte. + /* The most-significant-non-zero bit of the syndrome marks either the + first bit that is different, or the top bit of the first zero byte. Shifting left now will bring the critical information into the top bits. */ +L(end_quick): lsl data1, data1, pos lsl data2, data2, pos /* But we need to zero-extend (char is unsigned) the value and then @@ -159,22 +167,12 @@ L(mutual_align): neg tmp3, count, lsl #3 /* 64 - bits(bytes beyond align). */ ldr data2, [src2], #8 mov tmp2, #~0 - sub limit_wd, limit, #1 /* limit != 0, so no underflow. */ -#ifdef __AARCH64EB__ - /* Big-endian. Early bytes are at MSB. */ - lsl tmp2, tmp2, tmp3 /* Shift (count & 63). */ -#else - /* Little-endian. Early bytes are at LSB. */ - lsr tmp2, tmp2, tmp3 /* Shift (count & 63). */ -#endif - and tmp3, limit_wd, #7 - lsr limit_wd, limit_wd, #3 - /* Adjust the limit. Only low 3 bits used, so overflow irrelevant. */ - add limit, limit, count - add tmp3, tmp3, count + LS_FW tmp2, tmp2, tmp3 /* Shift (count & 63). */ + /* Adjust the limit and ensure it doesn't overflow. */ + adds limit, limit, count + csinv limit, limit, xzr, lo orr data1, data1, tmp2 orr data2, data2, tmp2 - add limit_wd, limit_wd, tmp3, lsr #3 b L(start_realigned) .p2align 4 @@ -197,13 +195,11 @@ L(done): /* Align the SRC1 to a dword by doing a bytewise compare and then do the dword loop. */ L(try_misaligned_words): - lsr limit_wd, limit, #3 - cbz count, L(do_misaligned) + cbz count, L(src1_aligned) neg count, count and count, count, #7 sub limit, limit, count - lsr limit_wd, limit, #3 L(page_end_loop): ldrb data1w, [src1], #1 @@ -214,48 +210,100 @@ L(page_end_loop): subs count, count, #1 b.hi L(page_end_loop) -L(do_misaligned): - /* Prepare ourselves for the next page crossing. Unlike the aligned - loop, we fetch 1 less dword because we risk crossing bounds on - SRC2. */ - mov count, #8 - subs limit_wd, limit_wd, #1 - b.lo L(done_loop) -L(loop_misaligned): - and tmp2, src2, #0xff8 - eor tmp2, tmp2, #0xff8 - cbz tmp2, L(page_end_loop) + /* The following diagram explains the comparison of misaligned strings. + The bytes are shown in natural order. For little-endian, it is + reversed in the registers. The "x" bytes are before the string. + The "|" separates data that is loaded at one time. + src1 | a a a a a a a a | b b b c c c c c | . . . + src2 | x x x x x a a a a a a a a b b b | c c c c c . . . + + After shifting in each step, the data looks like this: + STEP_A STEP_B STEP_C + data1 a a a a a a a a b b b c c c c c b b b c c c c c + data2 a a a a a a a a b b b 0 0 0 0 0 0 0 0 c c c c c + The bytes with "0" are eliminated from the syndrome via mask. + + Align SRC2 down to 16 bytes. This way we can read 16 bytes at a + time from SRC2. The comparison happens in 3 steps. After each step + the loop can exit, or read from SRC1 or SRC2. */ +L(src1_aligned): + /* Calculate offset from 8 byte alignment to string start in bits. No + need to mask offset since shifts are ignoring upper bits. */ + lsl offset, src2, #3 + bic src2, src2, #0xf + mov mask, -1 + neg neg_offset, offset ldr data1, [src1], #8 - ldr data2, [src2], #8 - sub tmp1, data1, zeroones - orr tmp2, data1, #REP8_7f - eor diff, data1, data2 /* Non-zero if differences found. */ - bics has_nul, tmp1, tmp2 /* Non-zero if NUL terminator. */ - ccmp diff, #0, #0, eq - b.ne L(not_limit) - subs limit_wd, limit_wd, #1 - b.pl L(loop_misaligned) + ldp tmp1, tmp2, [src2], #16 + LS_BK mask, mask, neg_offset + and neg_offset, neg_offset, #63 /* Need actual value for cmp later. */ + /* Skip the first compare if data in tmp1 is irrelevant. */ + tbnz offset, 6, L(misaligned_mid_loop) -L(done_loop): - /* We found a difference or a NULL before the limit was reached. */ - and limit, limit, #7 - cbz limit, L(not_limit) - /* Read the last word. */ - sub src1, src1, 8 - sub src2, src2, 8 - ldr data1, [src1, limit] - ldr data2, [src2, limit] - sub tmp1, data1, zeroones - orr tmp2, data1, #REP8_7f +L(loop_misaligned): + /* STEP_A: Compare full 8 bytes when there is enough data from SRC2.*/ + LS_FW data2, tmp1, offset + LS_BK tmp1, tmp2, neg_offset + subs limit, limit, #8 + orr data2, data2, tmp1 /* 8 bytes from SRC2 combined from two regs.*/ + sub has_nul, data1, zeroones eor diff, data1, data2 /* Non-zero if differences found. */ - bics has_nul, tmp1, tmp2 /* Non-zero if NUL terminator. */ - ccmp diff, #0, #0, eq - b.ne L(not_limit) + orr tmp3, data1, #REP8_7f + csinv endloop, diff, xzr, hi /* If limit, set to all ones. */ + bic has_nul, has_nul, tmp3 /* Non-zero if NUL byte found in SRC1. */ + orr tmp3, endloop, has_nul + cbnz tmp3, L(full_check) + + ldr data1, [src1], #8 +L(misaligned_mid_loop): + /* STEP_B: Compare first part of data1 to second part of tmp2. */ + LS_FW data2, tmp2, offset +#ifdef __AARCH64EB__ + /* For big-endian we do a byte reverse to avoid carry-propagation + problem described above. This way we can reuse the has_nul in the + next step and also use syndrome value trick at the end. */ + rev tmp3, data1 + #define data1_fixed tmp3 +#else + #define data1_fixed data1 +#endif + sub has_nul, data1_fixed, zeroones + orr tmp3, data1_fixed, #REP8_7f + eor diff, data2, data1 /* Non-zero if differences found. */ + bic has_nul, has_nul, tmp3 /* Non-zero if NUL terminator. */ +#ifdef __AARCH64EB__ + rev has_nul, has_nul +#endif + cmp limit, neg_offset, lsr #3 + orr syndrome, diff, has_nul + bic syndrome, syndrome, mask /* Ignore later bytes. */ + csinv tmp3, syndrome, xzr, hi /* If limit, set to all ones. */ + cbnz tmp3, L(syndrome_check) + + /* STEP_C: Compare second part of data1 to first part of tmp1. */ + ldp tmp1, tmp2, [src2], #16 + cmp limit, #8 + LS_BK data2, tmp1, neg_offset + eor diff, data2, data1 /* Non-zero if differences found. */ + orr syndrome, diff, has_nul + and syndrome, syndrome, mask /* Ignore earlier bytes. */ + csinv tmp3, syndrome, xzr, hi /* If limit, set to all ones. */ + cbnz tmp3, L(syndrome_check) + + ldr data1, [src1], #8 + sub limit, limit, #8 + b L(loop_misaligned) + +#ifdef __AARCH64EB__ +L(syndrome_check): + clz pos, syndrome + cmp pos, limit, lsl #3 + b.lo L(end_quick) +#endif L(ret0): mov result, #0 ret - SYM_FUNC_END_PI(strncmp) EXPORT_SYMBOL_NOHWKASAN(strncmp) From patchwork Tue Feb 15 17:07:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 12747368 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 84471C433F5 for ; Tue, 15 Feb 2022 17:09:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=AtlgIWvMrMoOURXg98UpzIs9XPc5HAnCaIWcB6s79uA=; b=m/7PJCKZgL6Lcf 8tTFMS2IDxe8wSxHI026e0OC1dtHZnmtxjusGx8QrdAuTl87ol3iGZQmMJHPS8g5UD2zlqSMjwc3Q PjS5q/oZn0Un6las5EZFEb/lM2Q0I2BrK5M8mTqmL0vVLcmJzke4rzXzeLtFHzQT23dBLGT/HETtn e3gsoQ8aRG2Et56xIejTSQswDwhsz1nIMiV3Q3XuUZKcQ3sFIpEI8BQlAAjkHGPRKqxuRNXfa/sxQ XSlIwg21SUc72ga6iJZoOcUtYZf8/05sTQ8VJ7kbH/DKJfqe6jUk7Q17xRaSA+H7o4xCWWBPVYnUq l4fWMsKRO/ZyAJ6CsdUw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nK1J6-003plP-MN; Tue, 15 Feb 2022 17:08:04 +0000 Received: from mail-db3eur04on0607.outbound.protection.outlook.com ([2a01:111:f400:fe0c::607] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nK1Iz-003piO-0B for linux-arm-kernel@lists.infradead.org; Tue, 15 Feb 2022 17:08:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0fs8d+LsBei1lc6GMcq1ofTM9odkyhcGFcTO4pCOVMg=; b=eByIVSh4N1YnjQ/k83GxUkFp5Pbz7gmvDwDbAqycLAa0rA4ralWBqiXw5wbB1sUc7ufhI2H7hzQjMXQpEZr5IAdf9BS0k8+gaoWWFvxUXYhR5JiJhjzcbNalg0egguTejhfhHBhcRu/YFh8hhs0f4D30gkh14b04bqrFc2dw1Js= Received: from DB6PR07CA0171.eurprd07.prod.outlook.com (2603:10a6:6:43::25) by DU0PR08MB7463.eurprd08.prod.outlook.com (2603:10a6:10:356::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11; Tue, 15 Feb 2022 17:07:50 +0000 Received: from DB5EUR03FT007.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:43:cafe::b) by DB6PR07CA0171.outlook.office365.com (2603:10a6:6:43::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.6 via Frontend Transport; Tue, 15 Feb 2022 17:07:50 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT007.mail.protection.outlook.com (10.152.20.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11 via Frontend Transport; Tue, 15 Feb 2022 17:07:50 +0000 Received: ("Tessian outbound 18e50a6f0513:v113"); Tue, 15 Feb 2022 17:07:50 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: d490cd566c84371e X-CR-MTA-TID: 64aa7808 Received: from 6426f54f9945.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id C4E3BBDE-D3DA-41D8-84B8-7F6D5B18BE59.1; Tue, 15 Feb 2022 17:07:44 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 6426f54f9945.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 15 Feb 2022 17:07:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FfjcxW5bBbAh1665WRvqiZG45YVoWgIFx7Codw3T+bmIBZJc2ap30I04XHJDPb4EwWCQlOYL5JWD5UEmyN7ZjrxmpgjwABMGGDlLv3YDW+BpgdVMGygzcCguVbg/ZQ0psfilI+WNwJnYCRhOKY5gBi0NCJYOnSS1o2wHz8+a7ComAiJpY7C/Yw9Ccdp0JbJi9q5v3Z/DUmXaK1xXM88Dq51IhVHhnhv6ACpW5q+htfkzjENdgTEnkhjgOLKx8UUQ8nN8JzdS52P5KL6xK2PfeGOYH87BHng8VbsXq2UVLlBZDv6RReYVKD5oSABwc3Lmn02bR/Ni2yGSxyxKW9aC2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=0fs8d+LsBei1lc6GMcq1ofTM9odkyhcGFcTO4pCOVMg=; b=iD403IelqMOlQRDtUlw25clq8Omzt2qx7kPsGSwnh5ZmLIRygMGEeLLJrQhnV3r9/2G+nbdAHXoWLTOj+Hqbr7VrXGvjPps14jPuumKvpbI04KtiuNeWsWAWvpNIEUsLW7MJg3CMv+aKh8tsLpmlDjqohbBaicE6TJu3Sp7cPG9Un5xP/8fd96NjrgTcpTduBf47WsRrDdM6lWv32iD+T54AqgJRS4LPYPpjjxi+o5bFb9uviq1+rBarnSauczJEynd67MhlrlZPnF68P1y2xTLWxbT8RLlzfMLv2xqPfhYFT6w6Atxoj52YibvYbJwAYSKfAaKfmb5cEvmbl52lPg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0fs8d+LsBei1lc6GMcq1ofTM9odkyhcGFcTO4pCOVMg=; b=eByIVSh4N1YnjQ/k83GxUkFp5Pbz7gmvDwDbAqycLAa0rA4ralWBqiXw5wbB1sUc7ufhI2H7hzQjMXQpEZr5IAdf9BS0k8+gaoWWFvxUXYhR5JiJhjzcbNalg0egguTejhfhHBhcRu/YFh8hhs0f4D30gkh14b04bqrFc2dw1Js= Received: from AM6PR05CA0030.eurprd05.prod.outlook.com (2603:10a6:20b:2e::43) by AM9PR08MB6756.eurprd08.prod.outlook.com (2603:10a6:20b:30d::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.14; Tue, 15 Feb 2022 17:07:43 +0000 Received: from AM5EUR03FT011.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:2e:cafe::96) by AM6PR05CA0030.outlook.office365.com (2603:10a6:20b:2e::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.14 via Frontend Transport; Tue, 15 Feb 2022 17:07:43 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; Received: from nebula.arm.com (40.67.248.234) by AM5EUR03FT011.mail.protection.outlook.com (10.152.16.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4975.11 via Frontend Transport; Tue, 15 Feb 2022 17:07:42 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Tue, 15 Feb 2022 17:07:43 +0000 Received: from e124191.cambridge.arm.com (10.1.197.45) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2308.20 via Frontend Transport; Tue, 15 Feb 2022 17:07:43 +0000 From: Joey Gouly To: CC: , , , , , Subject: [PATCH v1 3/3] Revert "arm64: Mitigate MTE issues with str{n}cmp()" Date: Tue, 15 Feb 2022 17:07:23 +0000 Message-ID: <20220215170723.21266-4-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220215170723.21266-1-joey.gouly@arm.com> References: <20220215170723.21266-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: 033f33cc-b43d-4ebe-3a2f-08d9f0a5b2b2 X-MS-TrafficTypeDiagnostic: AM9PR08MB6756:EE_|DB5EUR03FT007:EE_|DU0PR08MB7463:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:843;OLM:843; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: Dn2qAvp6WaC3426Y1TK6xZZ9664jTxU4Bx+18Wxsee3cj8esfTeorE4XPTDqL2ZouWkFbjJuHrcogDk8Xu/ZrMKV/LG4msY/BTIo1C5YU50lYEvL6FNeIe7eoXDDXFaaUtl6W52VMtc4xxllbudTOOoGrP2+QK5AXTzXYPZzq3wh1v0tYoI633qd2JjMDX2kYoAklp4kMslNv/OYEPJCg1qwH16+n04nkpDOKrnKV6g1W/NMgjsXFZaWhjdbSqddMlTqdpSozyLBfO045SJeFem+odej54LSM7N41QFMR0uypv25OL99w/SCS2K+je60EgEyy5uNSAU3h2mAr4NabsARMfouknmxNWIW1Td/awHF2P3tVO3QjODRpCKNUlyHVLnZ3BjAtIDFB2TCCi14pgibfkOd0zjOtILy8EwWEq/HcRXZ1elgm9JMQQqf17lnEf418khjHbBwsvzfJzNRCbeNNo1K/LlJYGnm+dPucFpU+FJWprzb8pRr5EsgvlrpIZlWb2S2R6FlnZqc0JJS9UIiDqe/2TRpxLSAnU0qOhqejYwFMtGHxS7rD+Athu96Roe9nsuraRkT1Jwo6dbbp92BlSCjOLtHQDCfURPEZQU90LIXre2ut5bDBFcqSEga8BHZiWmVTlU6osUWBakPoZwEz6uTX1Ddqr3i6QwxsQUkmgmW9Rc7M4ookWAc2TuloK4e9ZbqTmGc904iXoYATA== X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:nebula.arm.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230001)(4636009)(36840700001)(40470700004)(46966006)(2616005)(8676002)(8936002)(36756003)(86362001)(82310400004)(4326008)(70206006)(70586007)(2906002)(44832011)(40460700003)(426003)(83380400001)(47076005)(1076003)(26005)(186003)(336012)(5660300002)(36860700001)(7696005)(356005)(508600001)(81166007)(316002)(54906003)(6916009)(6666004)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR08MB6756 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT007.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 25ad0ca9-4f6e-4a61-25e6-08d9f0a5ae0b X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: J1v3nltDmq1t61lcPz9MpK3zE6cE2gzTVhaMVBpSg7OBBCmvev8qRYm1bAbPomCY8x2Gd7FS8GJTWAVZ1goz3kMwx3IrwFpqwx5DWB1rEeJy4bpn43R2uaSzq+CXiRMufKmS+did8pbpAbfWKdNArwCuI2f2N1Yn15CZ+VdE7guxBLgtvXspnHY7Zd83GxNzMIpJhA9tjp1ietwTfcq7MboEahooeHu1EjB9pCusDBE3GHpZQX0Y5uXC9077FW1XzsgHUkFrlE/zvHhkpQzoTGYCwR2jjPtd1xBjyvOKWwWFmMr2Huc8Tfjw7DJYP2WI7jdMKU2Cb5ajY2Z/URdCANpp7i8XabgykTBQelKJjblJFRxJTRdPdkSKWbHd7ExG8YnkuraLEwPE1JvPvQPVM2nlY5gkrhDRpPt3zBiMWg9jcyGnoCBKg8VHvMJGjQmn95enD1H+Lj8Mz5nxA6XsW+xohqri8vFGnzOvC4cMIycGXp3NFFrvUaH3i7oauB+gKnqhq5VgGnhaSAt6iUTvdnCDw9GrtGRRI8tH8ehC7X+dSc8aQb5StyGfZgOdctTYMfbDg50BEf2CLqsHmddh5sJjL97To7lAY8852j4ce5XYaYTQRxqghASwWxLbqM2fGGFZvvQUAX0FsR5GqQray9apjNm+2qUI1ULLWw++mmQClfNq1+q2KjRN71q5tzpV 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:(13230001)(4636009)(40470700004)(36840700001)(46966006)(82310400004)(2906002)(2616005)(5660300002)(186003)(26005)(81166007)(36860700001)(47076005)(36756003)(44832011)(83380400001)(426003)(336012)(1076003)(107886003)(4326008)(70586007)(70206006)(508600001)(6666004)(7696005)(86362001)(8936002)(54906003)(316002)(8676002)(40460700003)(6916009); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2022 17:07:50.7845 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 033f33cc-b43d-4ebe-3a2f-08d9f0a5b2b2 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: DB5EUR03FT007.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB7463 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220215_090757_150932_24302789 X-CRM114-Status: GOOD ( 10.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This reverts commit 59a68d4138086c015ab8241c3267eec5550fbd44. Now that the str{n}cmp functions have been updated to handle MTE properly, the workaround to use the generic functions is no longer needed. Signed-off-by: Joey Gouly Cc: Robin Murphy Cc: Mark Rutland Cc: Catalin Marinas Cc: Will Deacon --- arch/arm64/include/asm/assembler.h | 5 ----- arch/arm64/include/asm/string.h | 2 -- arch/arm64/lib/strcmp.S | 2 +- arch/arm64/lib/strncmp.S | 2 +- 4 files changed, 2 insertions(+), 9 deletions(-) diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h index e8bd0af0141c..8df412178efb 100644 --- a/arch/arm64/include/asm/assembler.h +++ b/arch/arm64/include/asm/assembler.h @@ -535,11 +535,6 @@ alternative_endif #define EXPORT_SYMBOL_NOKASAN(name) EXPORT_SYMBOL(name) #endif -#ifdef CONFIG_KASAN_HW_TAGS -#define EXPORT_SYMBOL_NOHWKASAN(name) -#else -#define EXPORT_SYMBOL_NOHWKASAN(name) EXPORT_SYMBOL_NOKASAN(name) -#endif /* * Emit a 64-bit absolute little endian symbol reference in a way that * ensures that it will be resolved at build time, even when building a diff --git a/arch/arm64/include/asm/string.h b/arch/arm64/include/asm/string.h index 95f7686b728d..3a3264ff47b9 100644 --- a/arch/arm64/include/asm/string.h +++ b/arch/arm64/include/asm/string.h @@ -12,13 +12,11 @@ extern char *strrchr(const char *, int c); #define __HAVE_ARCH_STRCHR extern char *strchr(const char *, int c); -#ifndef CONFIG_KASAN_HW_TAGS #define __HAVE_ARCH_STRCMP extern int strcmp(const char *, const char *); #define __HAVE_ARCH_STRNCMP extern int strncmp(const char *, const char *, __kernel_size_t); -#endif #define __HAVE_ARCH_STRLEN extern __kernel_size_t strlen(const char *); diff --git a/arch/arm64/lib/strcmp.S b/arch/arm64/lib/strcmp.S index 758de77afd2f..e6815a3dd265 100644 --- a/arch/arm64/lib/strcmp.S +++ b/arch/arm64/lib/strcmp.S @@ -187,4 +187,4 @@ L(done): ret SYM_FUNC_END_PI(strcmp) -EXPORT_SYMBOL_NOHWKASAN(strcmp) +EXPORT_SYMBOL_NOKASAN(strcmp) diff --git a/arch/arm64/lib/strncmp.S b/arch/arm64/lib/strncmp.S index a4884b97e9a8..bc195cb86693 100644 --- a/arch/arm64/lib/strncmp.S +++ b/arch/arm64/lib/strncmp.S @@ -306,4 +306,4 @@ L(ret0): mov result, #0 ret SYM_FUNC_END_PI(strncmp) -EXPORT_SYMBOL_NOHWKASAN(strncmp) +EXPORT_SYMBOL_NOKASAN(strncmp)