[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v1 1/1] arm64: Fix strrchr() matching of null terminator


  • To: Julien Grall <julien@xxxxxxx>
  • From: "Edgar E. Iglesias" <edgar.iglesias@xxxxxxx>
  • Date: Tue, 19 May 2026 17:28:20 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=HLxL1355H4oAxjE+x6aGUjZQyn+L6Reedm8G67kkc8I=; b=E+VgaPJGDdIcipm8w8vYKjp4q6yMLcqXTyOP/0cJ6qlJyPyrj1NUhiY+cQ3ktLAb7NT2EXXXNR3RY4l02eTCpouVw6B7AEqY8757XYf6YMmVMAbvgkPWhNJBTtAa7NEaYf46u9jyM3TSFh3Cx29GVcReoShy/cWDWVMlPFEu1stJ3/5COavgALtO/d1XxtHvJj+En04oXJVSoFoKsgv+WBRV3joVphe8wRD97+wnxLbNlKt6dA36Sno3IxlUwVLBQSuh+nZL7lIl7iyuMFMhhNu0G/CaL9QtdKk9kjSevIUVwmca4jff35eZAPmLwM3EOzfSKlF/Sk4BH4ncrZmwPA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MV03DHUdzvs0GnxqS4AXJx2sXPMeVh2+IlkReacGVyMvEwc3Ae/hR5F1cVEHROO/+dGYR8NIyi8SCYFh1LJPxY0ZjscthC5GIdTy4OQsWi5D6ikoyyXMj7h8wpYF2whCtXxuAP+wjG3NWz5ulbxZyOIKIMA/gQf2pQGRZiQUoDPVeG4tte7hGpWAoUrGfIkai0AE7hHlnPI0KtjcOe96Gef4ton+hyMkS8+04A6y4EhS3aLGrp0JqS68GHaq3g0OO1zU2QTtnccIpSdbBvRlHf+UnxbFKS1c3F1oB0AVX7OnKiV3uV5ImvFlCG86eiSu0Zh1X4QCWocPWoTf0aFMsA==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=amd.com header.i="@amd.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Cc: Jan Beulich <jbeulich@xxxxxxxx>, sstabellini@xxxxxxxxxx, bertrand.marquis@xxxxxxx, michal.orzel@xxxxxxx, Volodymyr_Babchuk@xxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Tue, 19 May 2026 15:28:39 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Tue, May 19, 2026 at 08:47:17AM +0100, Julien Grall wrote:
> Hi Edgar and Jan,
> 
> On 19/05/2026 07:40, Jan Beulich wrote:
> > On 19.05.2026 01:43, Edgar E. Iglesias wrote:
> > > The generic Xen strrchr() implementation returns a pointer to the string
> > > terminator when searching for '\0', matching the standard C semantics.
> >>>> The ARM64 assembly version stopped as soon as it loaded the terminator
> and
> > > returned the previous match pointer instead.  This made strrchr("", '\0')
> > > return NULL.
> > 
> > I wonder though: Why would one pass '\0' to strrchr()? If you want to find
> > the end of a string, more efficient (at least in the general case) options
> > exist (strchr(), memchr(), strlen()).
> 
> +1 I am interested to know the use-case for this change. Is this for
> compliance or real issue? If the latter, can we add some details.
> 
> It might also be worth to write a selftest to avoid any regression (in
> particular if we decide to diverge from Linux).
> 
> > 
> > > Compare the loaded byte against the requested character before deciding
> > > whether to stop at the terminator, so the terminator itself can be 
> > > returned
> > > when it is the requested character.
> > 
> > Nit: "..., so a pointer to the terminator ...".
> > 
> > > Fixes: 42c4eb6a83 ("xen: arm64: assembly optimised mem* and str*")
> > > Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xxxxxxx>
> > 
> > Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
> > 
> > However, the function having come from Linux, imo the patch wants to go to
> > Linux (ideally first, but at the very least also).
> 
> We are trying to keep the core implementation in lib the same as linux (see
> arch/arm/README.LinuxPrimitives). I would prefer if this is also first
> committed to Linux and then backported.
>

Sounds good, thanks!




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.