From patchwork Tue Jun 29 09:37:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1498261 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=u7th9BrU; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GDfYG207Qz9sWX for ; Tue, 29 Jun 2021 19:38:26 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 09E343971C38 for ; Tue, 29 Jun 2021 09:38:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 09E343971C38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1624959504; bh=yEaQiGpUQFEY8/nUwer6WG6q62V87895p7T2UG43GY0=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=u7th9BrUgosXmHVBssXdMRxyxHBRrf5qnH4omRHlEzlsDkHlbmK1LwKzWZjRfireu TTgBfab78ts5kCmhg2CqHN59OFtp83g2aAgPwnBvTGFQ5v7AXqRukjt8Db9zb9SKcT HwmjjWmwKLf5Rd+BXyJ3tZU0BsVDMW+oN8SAX7Pk= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id A41B7396E851 for ; Tue, 29 Jun 2021 09:37:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A41B7396E851 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 15T9XAIN195237 for ; Tue, 29 Jun 2021 05:37:36 -0400 Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 39fygyanp4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 29 Jun 2021 05:37:36 -0400 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 15T9Rn4a001325 for ; Tue, 29 Jun 2021 09:37:34 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma04ams.nl.ibm.com with ESMTP id 39duv8h6pc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 29 Jun 2021 09:37:34 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 15T9ZwXe37028318 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Jun 2021 09:35:58 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5BA72A40E7; Tue, 29 Jun 2021 09:37:31 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3940DA40E1; Tue, 29 Jun 2021 09:37:31 +0000 (GMT) Received: from t35lp56.lnxne.boe (unknown [9.152.108.100]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 29 Jun 2021 09:37:31 +0000 (GMT) To: libc-alpha@sourceware.org Subject: [PATCH] s390: Fix MEMCHR_Z900_G5 ifunc-variant if n>=0x80000000 [BZ #28024] Date: Tue, 29 Jun 2021 11:37:28 +0200 Message-Id: <20210629093728.2335496-1-stli@linux.ibm.com> X-Mailer: git-send-email 2.31.1 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: epnfwvXmrdluYS2YIApYix4fooymW9hj X-Proofpoint-ORIG-GUID: epnfwvXmrdluYS2YIApYix4fooymW9hj X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-06-29_05:2021-06-25, 2021-06-29 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 mlxlogscore=560 mlxscore=0 clxscore=1015 impostorscore=0 adultscore=0 spamscore=0 lowpriorityscore=41 bulkscore=41 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2106290067 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP 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: Stefan Liebler via Libc-alpha From: Stefan Liebler Reply-To: Stefan Liebler Cc: Stefan Liebler Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" On s390 (31bit), the pointer to the first byte after s always wraps around with n >= 0x80000000 and can lead to stop searching before end of s. Thus this patch just use NULL as byte after s in this case and the srst instruction stops searching with "not found" when wrapping around from top address to zero. This is observable with testcase string/test-memchr starting with commit "String: Add overflow tests for strnlen, memchr, and strncat [BZ #27974]" https://sourceware.org/git/?p=glibc.git;a=commit;h=da5a6fba0febbfc90896ce1b2eb75c6d8a88a72d --- sysdeps/s390/memchr-z900.S | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sysdeps/s390/memchr-z900.S b/sysdeps/s390/memchr-z900.S index 90b8a32dd6..72fd9e023f 100644 --- a/sysdeps/s390/memchr-z900.S +++ b/sysdeps/s390/memchr-z900.S @@ -44,12 +44,25 @@ ENTRY(MEMCHR_Z900_G5) LGHI %r0,0xff NGR %r0,%r3 LGR %r1,%r2 +# if ! defined __s390x__ + tmlh %r4,32768 + jo 3f /* Jump away if n >= 0x80000000 */ +# endif la %r2,0(%r4,%r1) 0: srst %r2,%r1 jo 0b brc 13,1f SLGR %r2,%r2 1: br %r14 +# if ! defined __s390x__ + /* On s390 (31bit), the pointer to the first byte after s (stored in + r2) always wraps around with n >= 0x80000000 and can lead to stop + searching before end of s. Thus just use r2=0 in this case. + If r2 < r1, the srst instruction stops searching with cc=2 "not + found" when wrapping around from top address to zero. */ +3: SLGR %r2,%r2 + j 0b +# endif END(MEMCHR_Z900_G5) # if ! HAVE_MEMCHR_IFUNC