From owner-freebsd-arch@FreeBSD.ORG Sat Oct 6 17:39:42 2012 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5E1EF106564A; Sat, 6 Oct 2012 17:39:42 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id E81888FC0C; Sat, 6 Oct 2012 17:39:41 +0000 (UTC) Received: from skuns.kiev.zoral.com.ua (localhost [127.0.0.1]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id q96HdeAA037645; Sat, 6 Oct 2012 20:39:40 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5) with ESMTP id q96HdSZD097497; Sat, 6 Oct 2012 20:39:28 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5/Submit) id q96HdQ79097496; Sat, 6 Oct 2012 20:39:26 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 6 Oct 2012 20:39:26 +0300 From: Konstantin Belousov To: Peter Wemm Message-ID: <20121006173926.GT35915@deviant.kiev.zoral.com.ua> References: <506C385C.3020400@FreeBSD.org> <86a9w1kq94.fsf@ds4.des.no> <20121005133616.GP35915@deviant.kiev.zoral.com.ua> <201210051141.16147.jhb@freebsd.org> <20121006072636.V978@besplex.bde.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="ubEh+iSFTuEFLNSo" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.0 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: Garrett Cooper , Andriy Gapon , freebsd-arch@freebsd.org, Dag-Erling Sm??rgrav , Dimitry Andric Subject: Re: x86 boot code build X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Oct 2012 17:39:42 -0000 --ubEh+iSFTuEFLNSo Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Oct 06, 2012 at 12:28:37AM -0700, Peter Wemm wrote: > On Fri, Oct 5, 2012 at 3:44 PM, Bruce Evans wrote: > [..] > > Here are results of a current run of old test code: on core2 > > (ref10-i386): results only for a data size of 4K (for much smaller > > sizes, simple methods are best, and for much larger sizes, all > > reasonable methods are limited by the speed of main memory and cache > > overheads, and all reasonable methods have the same speed, except ones > > using movnt* are faster since they bypass the caches): >=20 > A while ago I experimented with switching 32 bit binaries into 64 bit > mode while running under a 64 bit OS for things like data copies. The > differences between 32 and 64 bit used to be substantial for the > dumber data copy methods. And of course the overheads of getting into > and out of 64 bit mode at the time was prohibitive on an Intel > processor (compared to an AMD). >=20 > Short version to explain the concept: >=20 > bcopy64: > pushl %ebx > pushl %esi > pushl %edi > call base > base: > popl %esi > movl %esi,%edx > addl $to64-base,%edx > pushl $43 /* $GSEL(GUCODE_SEL, SEL_UPL) */ > pushl %edx > lretl > .code64 > to64: > movq %rsi,%r9 > addq $to32-base,%r9 > movq 16(%rsp),%rsi /* src */ > movq 24(%rsp),%rdi /* dst */ > movq 32(%rsp),%rdx /* len */ > [... 64 bit bcopy trimmed...] >=20 > 2: > /* Jump back to 32 bit code segment */ > pushq $27 /* GSEL(GUCODE32_UPL, SEL_UPL) */ > pushq %r9 > lretq > .code32 > .p2align 4 > to32: > popl %edi > popl %esi > popl %ebx > ret >=20 > Of course, this requires regular i386 code running on an amd64 kernel. > At the time it was quite safe because signal delivery would reset %cs > to deliver signals in 32 bit mode and all 64 bits of all registers > were context switched, even for a 32 bit application. This is still true. We always set %cs, %ss, %ds and %es for the signal handlers, as well as save the full 64bit register file. The recent linuxish x32 ABI might be relevant for what you tried to do. If only they did not mandated bastardized kernel ABI. --ubEh+iSFTuEFLNSo Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAlBwbM4ACgkQC3+MBN1Mb4hpKgCgre87/SRosswkltWnRFKVU2/z 3bEAoNB+j9b8M9B3E4yS2QZfcPIFIeIU =8sW5 -----END PGP SIGNATURE----- --ubEh+iSFTuEFLNSo--