From owner-svn-src-head@FreeBSD.ORG Wed Jan 5 01:16:35 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 1233) id A48331065672; Wed, 5 Jan 2011 01:16:35 +0000 (UTC) Date: Wed, 5 Jan 2011 01:16:35 +0000 From: Alexander Best To: Dimitry Andric Message-ID: <20110105011635.GA4952@freebsd.org> References: <201101042051.p04KpSGk054564@svn.freebsd.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="YiEDa0DAkWCtVeE4" Content-Disposition: inline In-Reply-To: <201101042051.p04KpSGk054564@svn.freebsd.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r216977 - in head/libexec/rtld-elf: amd64 i386 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jan 2011 01:16:35 -0000 --YiEDa0DAkWCtVeE4 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue Jan 4 11, Dimitry Andric wrote: > Author: dim > Date: Tue Jan 4 20:51:28 2011 > New Revision: 216977 > URL: http://svn.freebsd.org/changeset/base/216977 > > Log: > On amd64 and i386, tell the compiler to refrain from generating SSE, > 3DNow, MMX and floating point instructions in rtld-elf. > > Otherwise, _rtld_bind() (and whatever it calls) could possibly clobber > function arguments that are passed in SSE/3DNow/MMX/FP registers, > usually floating point values. This can happen, for example, when clang > generates SSE code for memset() or memcpy() calls. the sorting order for these flags seems to be: -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 see 'grep -R "\-no-sse" /usr/src'. maybe the sorting order should stay consistent? also what's the status of clang? will these flags make sure that newer cpu extension won't be activated? i checked contrib/llvm/tools/clang/include/clang/Driver/Options.td and clang has support for: -m3dnowa -mssse3 -msse4a -msse4 -msse4_1 -msse4_2 -maes -mavx since these extensions only get set in a hand full of files maybe special cases for CC == clang can be added. also maybe you could have a look at the attached patch. i sent this to hackers@ and nobody objected, but nobody wanted to commit the patch unfortunately. cheers. alex > > One symptom of this is sshd dying early on amd64 with "PRNG not seeded", > which is ultimately caused by libcrypto.so.6 calling RAND_add() with a > double parameter. That parameter is passed via %xmm0, which gets wiped > out by an SSE memset() in _rtld_bind(). > > Reviewed by: kib, kan > > Modified: > head/libexec/rtld-elf/amd64/Makefile.inc > head/libexec/rtld-elf/i386/Makefile.inc > > Modified: head/libexec/rtld-elf/amd64/Makefile.inc > ============================================================================== > --- head/libexec/rtld-elf/amd64/Makefile.inc Tue Jan 4 20:38:52 2011 (r216976) > +++ head/libexec/rtld-elf/amd64/Makefile.inc Tue Jan 4 20:51:28 2011 (r216977) > @@ -1,5 +1,6 @@ > # $FreeBSD$ > > +CFLAGS+= -mno-sse -mno-sse2 -mno-sse3 -mno-mmx -mno-3dnow -msoft-float > # Uncomment this to build the dynamic linker as an executable instead > # of a shared library: > #LDSCRIPT= ${.CURDIR}/${MACHINE_CPUARCH}/elf_rtld.x > > Modified: head/libexec/rtld-elf/i386/Makefile.inc > ============================================================================== > --- head/libexec/rtld-elf/i386/Makefile.inc Tue Jan 4 20:38:52 2011 (r216976) > +++ head/libexec/rtld-elf/i386/Makefile.inc Tue Jan 4 20:51:28 2011 (r216977) > @@ -1,5 +1,6 @@ > # $FreeBSD$ > > +CFLAGS+= -mno-sse -mno-sse2 -mno-sse3 -mno-mmx -mno-3dnow -msoft-float > # Uncomment this to build the dynamic linker as an executable instead > # of a shared library: > #LDSCRIPT= ${.CURDIR}/${MACHINE_CPUARCH}/elf_rtld.x -- a13x --YiEDa0DAkWCtVeE4 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="sse2.diff" diff --git a/sys/boot/i386/boot2/Makefile b/sys/boot/i386/boot2/Makefile index b91a43b..39ef619 100644 --- a/sys/boot/i386/boot2/Makefile +++ b/sys/boot/i386/boot2/Makefile @@ -3,7 +3,7 @@ .include # XXX: clang can compile the boot code just fine, but boot2 gets too big -CC:=${CC:C/^(.*\/)?clang$/gcc/1} +#CC:=${CC:C/^(.*\/)?clang$/gcc/1} FILES= boot boot1 boot2 @@ -31,7 +31,6 @@ CFLAGS= -Os \ -fno-unit-at-a-time \ -mno-align-long-strings \ -mrtd \ - -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 \ -D${BOOT2_UFS} \ -DFLAGS=${BOOT_BOOT1_FLAGS} \ -DSIOPRT=${BOOT_COMCONSOLE_PORT} \ diff --git a/sys/boot/i386/gptboot/Makefile b/sys/boot/i386/gptboot/Makefile index a0fad61..452b100 100644 --- a/sys/boot/i386/gptboot/Makefile +++ b/sys/boot/i386/gptboot/Makefile @@ -26,7 +26,6 @@ CFLAGS= -DBOOTPROG=\"gptboot\" \ -fno-unit-at-a-time \ -mno-align-long-strings \ -mrtd \ - -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 \ -DGPT \ -D${GPTBOOT_UFS} \ -DSIOPRT=${BOOT_COMCONSOLE_PORT} \ diff --git a/sys/boot/i386/gptzfsboot/Makefile b/sys/boot/i386/gptzfsboot/Makefile index 30a5fc7..7f5f287 100644 --- a/sys/boot/i386/gptzfsboot/Makefile +++ b/sys/boot/i386/gptzfsboot/Makefile @@ -23,7 +23,6 @@ CFLAGS= -DBOOTPROG=\"gptzfsboot\" \ -fno-unit-at-a-time \ -mno-align-long-strings \ -mrtd \ - -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 \ -DGPT -DBOOT2 \ -DSIOPRT=${BOOT_COMCONSOLE_PORT} \ -DSIOFMT=${B2SIOFMT} \ diff --git a/sys/boot/i386/zfsboot/Makefile b/sys/boot/i386/zfsboot/Makefile index 10616e4..38e8a9f 100644 --- a/sys/boot/i386/zfsboot/Makefile +++ b/sys/boot/i386/zfsboot/Makefile @@ -24,7 +24,6 @@ CFLAGS= -DBOOTPROG=\"zfsboot\" \ -fno-unit-at-a-time \ -mno-align-long-strings \ -mrtd \ - -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 \ -DBOOT2 \ -DFLAGS=${BOOT_BOOT1_FLAGS} \ -DSIOPRT=${BOOT_COMCONSOLE_PORT} \ diff --git a/sys/boot/pc98/boot2/Makefile b/sys/boot/pc98/boot2/Makefile index dfd8607..035b5dd 100644 --- a/sys/boot/pc98/boot2/Makefile +++ b/sys/boot/pc98/boot2/Makefile @@ -28,7 +28,6 @@ CFLAGS= -Os \ -fno-unit-at-a-time \ -mno-align-long-strings \ -mrtd \ - -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 \ -D${BOOT2_UFS} \ -DFLAGS=${BOOT_BOOT1_FLAGS} \ -DSIOPRT=${BOOT_COMCONSOLE_PORT} \ --YiEDa0DAkWCtVeE4--