From patchwork Thu Nov 9 11:04:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Kozlov X-Patchwork-Id: 1861930 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=synopsys.com header.i=@synopsys.com header.a=rsa-sha256 header.s=pfptdkimsnps header.b=cLRvPANT; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=synopsys.com header.i=@synopsys.com header.a=rsa-sha256 header.s=mail header.b=W0aLdxAp; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=uclibc-ng.org (client-ip=2a00:1828:2000:679::23; helo=helium.openadk.org; envelope-from=devel-bounces@uclibc-ng.org; receiver=patchwork.ozlabs.org) Received: from helium.openadk.org (helium.openadk.org [IPv6:2a00:1828:2000:679::23]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SQzch3WpGz1yRF for ; Thu, 9 Nov 2023 22:04:52 +1100 (AEDT) Received: from helium.openadk.org (localhost [IPv6:::1]) by helium.openadk.org (Postfix) with ESMTP id 631743520EE1; Thu, 9 Nov 2023 12:04:47 +0100 (CET) Authentication-Results: helium.openadk.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=synopsys.com header.i=@synopsys.com header.a=rsa-sha256 header.s=pfptdkimsnps header.b=cLRvPANT; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=synopsys.com header.i=@synopsys.com header.a=rsa-sha256 header.s=mail header.b=W0aLdxAp; dkim-atps=neutral Received: from mx0a-00230701.pphosted.com (mx0a-00230701.pphosted.com [148.163.156.19]) by helium.openadk.org (Postfix) with ESMTPS id 661DB3520E13 for ; Thu, 9 Nov 2023 12:04:43 +0100 (CET) Received: from pps.filterd (m0098571.ppops.net [127.0.0.1]) by mx0a-00230701.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3A97PcqS008983 for ; Thu, 9 Nov 2023 03:04:41 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=synopsys.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=pfptdkimsnps; bh=BbG0R3YX8UtWsPqlxJr3/sv0qGyUjtVW+fKWUGQiXXs=; b=cLRvPANTNkXHmpiSs8dGODY9b+q06L311ZH0CT2E8Ogm81f2ZD3Ddn9Db9yL3+G1+GZw OcgQzAWmNLZ2I8NNEXks6J8V76mz7UqIGlTl1FFmKLvHfua33lL92ndfxJiBCtNn6ef7 WxSs46NXGykCxHolvKXHIPNW0+SQ34OyirMCKGkTwliTXhvOauuw9Cg99UG8YugCsRK9 YxGNWE9sNIoLGOpFUZWH72QXUd9xfpiZQ6VkFaWh1N3ub52kYrKaJdxrgAueXD8Wr4I9 FaCnlyBIyJLI0BuJcBYOf8M29ucWZQH5ik1qHf7mcsUCP9RXi/0fo4jvOt+n2s1wV4Qp GA== Received: from smtprelay-out1.synopsys.com (smtprelay-out1.synopsys.com [149.117.73.133]) by mx0a-00230701.pphosted.com (PPS) with ESMTPS id 3u7w1psc2c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 09 Nov 2023 03:04:41 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1699527881; bh=wYqmmpPFZgcw18q78abSeutZBudyLQLfA1lJ5t4cY2k=; h=From:To:Cc:Subject:Date:From; b=W0aLdxApciljJRs0A1uCJFifEAiQ/EeGQQ23bwFJhpDan5dufJdEKJtGgnfJRvM4n 8roabVJhJQhTJK/1BgxaaauD924F+cYFE6b6mDKSQ6U8r3BQN1GPSY6scNVq6DVfHd pM1WOwtwbCQgAbVq29gvPUIg2frUrUWSjVsd81zUPv/R84fszoVwgJ1lXH7XbVCIyP Uz/GwKwZes8sRmduU8jSE3NwIyD/Pqnf7AoHD9lUFoRIEm1WProwA+Q18MMfpH9Q+M 7KeiFyLYdDZlryW9eQNkaWQbJ1YRIy311R04V8UL031ZRsfsS9F2HGMXKfRPYdoqLa QFCrnsYKdiCsw== Received: from mailhost.synopsys.com (sv2-mailhost2.synopsys.com [10.205.2.134]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) client-signature RSA-PSS (2048 bits)) (Client CN "mailhost.synopsys.com", Issuer "SNPSica2" (verified OK)) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id EDBC6401C8 for ; Thu, 9 Nov 2023 11:04:40 +0000 (UTC) Received: from SNPS-o0WHuHJU73.internal.synopsys.com (snps-o0whuhju73.internal.synopsys.com [10.116.105.164]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client did not present a certificate) by mailhost.synopsys.com (Postfix) with ESMTPSA id 67AD1A00A1; Thu, 9 Nov 2023 11:04:38 +0000 (UTC) X-SNPS-Relay: synopsys.com From: Pavel Kozlov To: devel@uclibc-ng.org Date: Thu, 9 Nov 2023 15:04:29 +0400 Message-Id: <20231109110429.23443-1-kozlov@synopsys.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: 6-rcs4SidZNNegeTlH6YHms82FGlJLE2 X-Proofpoint-GUID: 6-rcs4SidZNNegeTlH6YHms82FGlJLE2 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-09_09,2023-11-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_active_cloned_notspam policy=outbound_active_cloned score=0 lowpriorityscore=0 malwarescore=0 suspectscore=0 adultscore=0 mlxlogscore=691 clxscore=1015 phishscore=0 impostorscore=0 mlxscore=0 bulkscore=0 spamscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311090081 Message-ID-Hash: 5G4SF4OOH6RRVU6HOHDWSBPKFKXIQPS4 X-Message-ID-Hash: 5G4SF4OOH6RRVU6HOHDWSBPKFKXIQPS4 X-MailFrom: Pavel.Kozlov@synopsys.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Alexey Brodkin , Pavel Kozlov X-Mailman-Version: 3.3.3 Precedence: list Subject: [uclibc-ng-devel] [PATCH] arc: remove read ahead in asm strcmp code for ARCHS List-Id: uClibc-ng Development Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Pavel Kozlov Remove read ahead in the per-word compare loop as it can cause a segmentation fault in certain circumstances (when a string crosses a page boundary). For baremetal this relaxed approach is suitable but in Linux with MMU we should be more restrictive. Signed-off-by: Pavel Kozlov --- libc/string/arc/strcmp.S | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/libc/string/arc/strcmp.S b/libc/string/arc/strcmp.S index 3f64ac421acc..48d2d7ec1d83 100644 --- a/libc/string/arc/strcmp.S +++ b/libc/string/arc/strcmp.S @@ -103,23 +103,21 @@ ENTRY(strcmp) brne r2, 0, @.Lcharloop ;;; s1 and s2 are word aligned - ld.ab r2, [r0, 4] mov_s r12, 0x01010101 ror r11, r12 .align 4 .LwordLoop: + ld.ab r2, [r0, 4] + sub r4, r2, r12 ld.ab r3, [r1, 4] ;; Detect NULL char in str1 - sub r4, r2, r12 - ld.ab r5, [r0, 4] bic r4, r4, r2 and r4, r4, r11 brne.d.nt r4, 0, .LfoundNULL ;; Check if the read locations are the same cmp r2, r3 - beq.d .LwordLoop - mov.eq r2, r5 + beq .LwordLoop ;; A match is found, spot it out #ifdef __LITTLE_ENDIAN__