From owner-freebsd-arm@FreeBSD.ORG Mon Apr 6 19:18:17 2015 Return-Path: Delivered-To: freebsd-arm@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 9B635A78 for ; Mon, 6 Apr 2015 19:18:17 +0000 (UTC) Received: from kanar.ci0.org (kanar.ci0.org [IPv6:2001:bc8:35e6::1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 359B47D8 for ; Mon, 6 Apr 2015 19:18:16 +0000 (UTC) Received: from kanar.ci0.org (pluxor@localhost [127.0.0.1]) by kanar.ci0.org (8.14.8/8.14.8) with ESMTP id t36JHxlV064171; Mon, 6 Apr 2015 21:17:59 +0200 (CEST) (envelope-from mlfbsd@kanar.ci0.org) Received: (from mlfbsd@localhost) by kanar.ci0.org (8.14.8/8.14.8/Submit) id t36JHxEI064170; Mon, 6 Apr 2015 21:17:59 +0200 (CEST) (envelope-from mlfbsd) Date: Mon, 6 Apr 2015 21:17:59 +0200 From: Olivier Houchard To: John-Mark Gurney Subject: Re: remove broken lib/libc/arm/string/memcpy_xscale.S Message-ID: <20150406191759.GA64102@ci0.org> References: <20150405015245.GO51048@funkthat.com> <20150406171248.GV51048@funkthat.com> <20150406174130.GA63423@ci0.org> <20150406190901.GW51048@funkthat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150406190901.GW51048@funkthat.com> User-Agent: Mutt/1.5.23 (2014-03-12) Cc: freebsd-arm@FreeBSD.org X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Apr 2015 19:18:17 -0000 On Mon, Apr 06, 2015 at 12:09:01PM -0700, John-Mark Gurney wrote: > Olivier Houchard wrote this message on Mon, Apr 06, 2015 at 19:41 +0200: > > On Mon, Apr 06, 2015 at 10:12:48AM -0700, John-Mark Gurney wrote: > > > Warner Losh wrote this message on Mon, Apr 06, 2015 at 09:58 -0600: > > > > > On Apr 4, 2015, at 7:52 PM, John-Mark Gurney wrote: > > > > > > > > > > I would like to remove this file as it does not implement our defined > > > > > memcpy. Per POSIX, overlapping regions passed to memcpy is undefined > > > > > behavior. We have defined it to have the same symatics as memmove. > > > > > > > > > > Sample test program: > > > > > #include > > > > > #include > > > > > > > > > > char bufa[512] = "this is a test buffer that should be copied fine."; > > > > > int > > > > > main() > > > > > { > > > > > > > > > > memcpy(&bufa[10], &bufa[0], strlen(&bufa[10])); > > > > > printf("%s\n", bufa); > > > > > > > > > > return 0; > > > > > } > > > > > > > > > > Output on amd64 HEAD: > > > > > this is a this is a test buffer that should be co > > > > > > > > > > Output on old armv4 from 9.x: > > > > > this is a this is a thst buffethst bufhould beufh > > > > > > > > > > If you just look at the file, it is clear that the implementation does > > > > > not adjust the copy direction based upon pointers. We imported the > > > > > code from NetBSD, and NetBSD does apparently require memcpy's arguments > > > > > to be non-overlapping. > > > > > > > > > > I'll remove the file shortly unless someone can prove to me that all > > > > > uses of memcpy in our tree do not depend upon our defined behavior > > > > > per memcpy(3)'s man page. > > > > > > > > Any chance you can fix this implementation instead? > > > > > > I don't know arm assembly well enough, nor do I have the time to fix > > > it.. I am willing to test any implementations as I have access to > > > hardware... > > > > > > I guess I should add a test to verify that memcpy behavese like memmove > > > to our test suite... > > > > > > > I think the bug is in the manpage, not the code, and we should fix it the way > > NetBSD did. > > Have you audited all of our code base to confirm that such a change > will not break anything? The man page has been like this since r1573, > so it's very possible that code has been written to depend upon this > behavior... > No. But I doubt anybody decided to rely on an implementation detail described in the "BUGS" section, written 25 years ago, to warn people NOT to do this. If we do, well it's a bug, and it doesn't matter if it's in the manpage or not. Both NetBSD and OpenBSD got ride of those bits, and so should we. Olivier