From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id C348C3885C0A for ; Thu, 1 Jul 2021 14:56:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C348C3885C0A Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 161EY0wc110723 for ; Thu, 1 Jul 2021 10:56:54 -0400 Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 39hepr2mdh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 01 Jul 2021 10:56:53 -0400 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 161ErwNn006476 for ; Thu, 1 Jul 2021 14:56:51 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma04fra.de.ibm.com with ESMTP id 39duv8ha3y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 01 Jul 2021 14:56:51 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 161Et6FU26870088 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 1 Jul 2021 14:55:06 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C3E484C058; Thu, 1 Jul 2021 14:56:47 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9CADE4C04E; Thu, 1 Jul 2021 14:56:47 +0000 (GMT) Received: from li-ab9d22cc-354d-11b2-a85c-e984af76f811.ibm.com (unknown [9.145.168.60]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 1 Jul 2021 14:56:47 +0000 (GMT) Subject: Re: [PATCH] s390: Fix MEMCHR_Z900_G5 ifunc-variant if n>=0x80000000 [BZ #28024] To: Stefan Liebler , GNU C Library References: <20210629093728.2335496-1-stli@linux.ibm.com> From: Stefan Liebler Message-ID: Date: Thu, 1 Jul 2021 16:56:47 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 In-Reply-To: <20210629093728.2335496-1-stli@linux.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: G5gGuHYfOsL38VHaRwgfiGONy4WyNOeW X-Proofpoint-GUID: G5gGuHYfOsL38VHaRwgfiGONy4WyNOeW Content-Transfer-Encoding: 7bit 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-07-01_08:2021-07-01, 2021-07-01 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 priorityscore=1501 bulkscore=0 phishscore=0 mlxlogscore=945 malwarescore=0 impostorscore=0 adultscore=0 clxscore=1015 mlxscore=0 lowpriorityscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107010090 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-List-Received-Date: Thu, 01 Jul 2021 14:56:56 -0000 On 29/06/2021 11:37, Stefan Liebler wrote: > 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 > Committed and closed the bugzilla.