From owner-svn-src-head@freebsd.org Tue Nov 10 21:50:09 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 34A724653E8; Tue, 10 Nov 2020 21:50:09 +0000 (UTC) (envelope-from brooks@spindle.one-eyed-alien.net) Received: from spindle.one-eyed-alien.net (spindle.one-eyed-alien.net [199.48.129.229]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4CW1k83Qlfz3Cjx; Tue, 10 Nov 2020 21:50:08 +0000 (UTC) (envelope-from brooks@spindle.one-eyed-alien.net) Received: by spindle.one-eyed-alien.net (Postfix, from userid 3001) id B9CE13C0199; Tue, 10 Nov 2020 21:50:07 +0000 (UTC) Date: Tue, 10 Nov 2020 21:50:07 +0000 From: Brooks Davis To: Matthew Macy Cc: src-committers , svn-src-all , svn-src-head Subject: Re: svn commit: r367577 - in head: share/mk sys/conf tools/build/options Message-ID: <20201110215007.GD1959@spindle.one-eyed-alien.net> References: <202011101915.0AAJFEWf059408@repo.freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="V88s5gaDVPzZ0KCq" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) X-Rspamd-Queue-Id: 4CW1k83Qlfz3Cjx X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of brooks@spindle.one-eyed-alien.net has no SPF policy when checking 199.48.129.229) smtp.mailfrom=brooks@spindle.one-eyed-alien.net X-Spamd-Result: default: False [0.10 / 15.00]; ARC_NA(0.00)[]; FORGED_SENDER(0.30)[brooks@freebsd.org,brooks@spindle.one-eyed-alien.net]; FREEFALL_USER(0.00)[brooks]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; NEURAL_SPAM_SHORT(1.00)[0.997]; NEURAL_HAM_LONG(-1.00)[-1.000]; TAGGED_RCPT(0.00)[]; MIME_GOOD(-0.20)[multipart/signed,text/plain]; DMARC_NA(0.00)[freebsd.org]; AUTH_NA(1.00)[]; NEURAL_SPAM_MEDIUM(1.00)[1.000]; SPAMHAUS_ZRD(0.00)[199.48.129.229:from:127.0.2.255]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TO_DN_ALL(0.00)[]; SIGNED_PGP(-2.00)[]; FREEMAIL_TO(0.00)[gmail.com]; RCVD_COUNT_ZERO(0.00)[0]; R_SPF_NA(0.00)[no SPF record]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; ASN(0.00)[asn:36236, ipnet:199.48.128.0/22, country:US]; FROM_NEQ_ENVFROM(0.00)[brooks@freebsd.org,brooks@spindle.one-eyed-alien.net]; MAILMAN_DEST(0.00)[svn-src-all,svn-src-head]; RBL_DBL_DONT_QUERY_IPS(0.00)[199.48.129.229:from] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.34 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: Tue, 10 Nov 2020 21:50:09 -0000 --V88s5gaDVPzZ0KCq Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Sorry about that. I've fixed it in r367579. -- Brooks On Tue, Nov 10, 2020 at 12:46:45PM -0800, Matthew Macy wrote: > These flags aren't defined by default when building external kernel modul= es: >=20 > gmake[2]: Entering directory '/usr/home/matt/devel/ZoF/module' > env -u MAKEFLAGS make -C /home/matt/devel/ZoF/module -f Makefile.bsd -w > make[3]: Entering directory `/home/matt/devel/ZoF/module' > make[3]: "/usr/home/matt/devel/freebsd/sys/conf/kern.mk" line 233: > Malformed conditional (${MK_INIT_ALL_ZERO} =3D=3D "yes") > make[3]: Fatal errors encountered -- cannot continue > make[3]: stopped in /home/matt/devel/ZoF/module > gmake[2]: *** [Makefile:53: modules-FreeBSD] Error 1 > gmake[2]: Leaving directory '/usr/home/matt/devel/ZoF/module' >=20 > On Tue, Nov 10, 2020 at 11:15 AM Brooks Davis wrote: > > > > Author: brooks > > Date: Tue Nov 10 19:15:13 2020 > > New Revision: 367577 > > URL: https://svnweb.freebsd.org/changeset/base/367577 > > > > Log: > > Support initializing stack variables on function entry > > > > There are two options: > > - WITH_INIT_ALL_ZERO: Zero all variables on the stack. > > - WITH_INIT_ALL_PATTERN: Initialize variables with well-defined patt= erns. > > > > The exact pattern are a compiler implementation detail and vary by ty= pe. > > They are somewhat documented in the LLVM commit message: > > https://reviews.llvm.org/rL349442 > > I've used WITH_INIT_ALL_* to match Microsoft's InitAll feature rather > > than naming them after the LLVM specific compiler flags. > > > > In a range of consumer products, options like these are used in > > both debug and production builds with debugs builds using patterns > > (intended to provoke crashes on use of uninitialized values) and > > production using zeros (deemed more likely to lead to harmless > > misbehavior or NULL-pointer dereferences). > > > > Reviewed by: emaste > > Obtained from: CheriBSD > > Sponsored by: DARPA > > Differential Revision: https://reviews.freebsd.org/D27131 > > > > Added: > > head/tools/build/options/WITH_INIT_ALL_PATTERN (contents, props cha= nged) > > head/tools/build/options/WITH_INIT_ALL_ZERO (contents, props change= d) > > Modified: > > head/share/mk/bsd.compiler.mk > > head/share/mk/bsd.lib.mk > > head/share/mk/bsd.opts.mk > > head/share/mk/bsd.prog.mk > > head/sys/conf/kern.mk > > > > Modified: head/share/mk/bsd.compiler.mk > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D > > --- head/share/mk/bsd.compiler.mk Tue Nov 10 19:09:35 2020 = (r367576) > > +++ head/share/mk/bsd.compiler.mk Tue Nov 10 19:15:13 2020 = (r367577) > > @@ -24,6 +24,7 @@ > > # - c++11: supports full (or nearly full) C++11 programming enviro= nment. > > # - retpoline: supports the retpoline speculative execution vulnerabil= ity > > # mitigation. > > +# - init-all: supports stack variable initialization. > > # > > # These variables with an X_ prefix will also be provided if XCC is se= t. > > # > > @@ -214,7 +215,7 @@ ${X_}COMPILER_FEATURES=3D c++11 c++14 > > ${X_}COMPILER_FEATURES+=3D c++17 > > .endif > > .if ${${X_}COMPILER_TYPE} =3D=3D "clang" > > -${X_}COMPILER_FEATURES+=3D retpoline > > +${X_}COMPILER_FEATURES+=3D retpoline init-all > > .endif > > > > .else > > > > Modified: head/share/mk/bsd.lib.mk > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D > > --- head/share/mk/bsd.lib.mk Tue Nov 10 19:09:35 2020 (r36757= 6) > > +++ head/share/mk/bsd.lib.mk Tue Nov 10 19:15:13 2020 (r36757= 7) > > @@ -85,6 +85,25 @@ LDFLAGS+=3D -Wl,-zretpolineplt > > .endif > > .endif > > > > +# Initialize stack variables on function entry > > +.if ${MK_INIT_ALL_ZERO} =3D=3D "yes" > > +.if ${COMPILER_FEATURES:Minit-all} > > +CFLAGS+=3D -ftrivial-auto-var-init=3Dzero \ > > + -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from= -clang > > +CXXFLAGS+=3D -ftrivial-auto-var-init=3Dzero \ > > + -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from= -clang > > +.else > > +.warning InitAll (zeros) requested but not support by compiler > > +.endif > > +.elif ${MK_INIT_ALL_PATTERN} =3D=3D "yes" > > +.if ${COMPILER_FEATURES:Minit-all} > > +CFLAGS+=3D -ftrivial-auto-var-init=3Dpattern > > +CXXFLAGS+=3D -ftrivial-auto-var-init=3Dpattern > > +.else > > +.warning InitAll (pattern) requested but not support by compiler > > +.endif > > +.endif > > + > > .if ${MK_DEBUG_FILES} !=3D "no" && empty(DEBUG_FLAGS:M-g) && \ > > empty(DEBUG_FLAGS:M-gdwarf*) > > CFLAGS+=3D ${DEBUG_FILES_CFLAGS} > > > > Modified: head/share/mk/bsd.opts.mk > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D > > --- head/share/mk/bsd.opts.mk Tue Nov 10 19:09:35 2020 (r36757= 6) > > +++ head/share/mk/bsd.opts.mk Tue Nov 10 19:15:13 2020 (r36757= 7) > > @@ -71,6 +71,8 @@ __DEFAULT_NO_OPTIONS =3D \ > > BIND_NOW \ > > CCACHE_BUILD \ > > CTF \ > > + INIT_ALL_PATTERN \ > > + INIT_ALL_ZERO \ > > INSTALL_AS_USER \ > > PIE \ > > RETPOLINE \ > > @@ -84,6 +86,10 @@ __DEFAULT_DEPENDENT_OPTIONS =3D \ > > > > > > .include > > + > > +.if ${MK_INIT_ALL_PATTERN} =3D=3D "yes" && ${MK_INIT_ALL_ZERO} =3D=3D = "yes" > > +.error WITH_INIT_ALL_PATTERN and WITH_INIT_ALL_ZERO are mutually exclu= sive. > > +.endif > > > > # > > # Supported NO_* options (if defined, MK_* will be forced to "no", > > > > Modified: head/share/mk/bsd.prog.mk > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D > > --- head/share/mk/bsd.prog.mk Tue Nov 10 19:09:35 2020 (r36757= 6) > > +++ head/share/mk/bsd.prog.mk Tue Nov 10 19:15:13 2020 (r36757= 7) > > @@ -60,6 +60,25 @@ LDFLAGS+=3D -Wl,-zretpolineplt > > .endif > > .endif > > > > +# Initialize stack variables on function entry > > +.if ${MK_INIT_ALL_ZERO} =3D=3D "yes" > > +.if ${COMPILER_FEATURES:Minit-all} > > +CFLAGS+=3D -ftrivial-auto-var-init=3Dzero \ > > + -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from= -clang > > +CXXFLAGS+=3D -ftrivial-auto-var-init=3Dzero \ > > + -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from= -clang > > +.else > > +.warning InitAll (zeros) requested but not support by compiler > > +.endif > > +.elif ${MK_INIT_ALL_PATTERN} =3D=3D "yes" > > +.if ${COMPILER_FEATURES:Minit-all} > > +CFLAGS+=3D -ftrivial-auto-var-init=3Dpattern > > +CXXFLAGS+=3D -ftrivial-auto-var-init=3Dpattern > > +.else > > +.warning InitAll (pattern) requested but not support by compiler > > +.endif > > +.endif > > + > > .if ${MACHINE_CPUARCH} =3D=3D "riscv" && ${LINKER_FEATURES:Mriscv-rela= xations} =3D=3D "" > > CFLAGS +=3D -mno-relax > > .endif > > > > Modified: head/sys/conf/kern.mk > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D > > --- head/sys/conf/kern.mk Tue Nov 10 19:09:35 2020 (r36757= 6) > > +++ head/sys/conf/kern.mk Tue Nov 10 19:15:13 2020 (r36757= 7) > > @@ -228,6 +228,24 @@ CFLAGS+=3D -mretpoline > > .endif > > > > # > > +# Initialize stack variables on function entry > > +# > > +.if ${MK_INIT_ALL_ZERO} =3D=3D "yes" > > +.if ${COMPILER_FEATURES:Minit-all} > > +CFLAGS+=3D -ftrivial-auto-var-init=3Dzero \ > > + -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from= -clang > > +.else > > +.warning InitAll (zeros) requested but not support by compiler > > +.endif > > +.elif ${MK_INIT_ALL_PATTERN} =3D=3D "yes" > > +.if ${COMPILER_FEATURES:Minit-all} > > +CFLAGS+=3D -ftrivial-auto-var-init=3Dpattern > > +.else > > +.warning InitAll (pattern) requested but not support by compiler > > +.endif > > +.endif > > + > > +# > > # Add -gdwarf-2 when compiling -g. The default starting in clang v3.4 > > # and gcc 4.8 is to generate DWARF version 4. However, our tools don't > > # cope well with DWARF 4, so force it to genereate DWARF2, which they > > > > Added: head/tools/build/options/WITH_INIT_ALL_PATTERN > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D > > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > > +++ head/tools/build/options/WITH_INIT_ALL_PATTERN Tue Nov 10 19:1= 5:13 2020 (r367577) > > @@ -0,0 +1,5 @@ > > +.\" $FreeBSD$ > > +Set to build the base system or kernel with stack variables initialize= d to > > +.Pq compiler defined > > +debugging patterns on function entry. > > +This option requires the clang compiler. > > > > Added: head/tools/build/options/WITH_INIT_ALL_ZERO > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D > > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > > +++ head/tools/build/options/WITH_INIT_ALL_ZERO Tue Nov 10 19:15:13 202= 0 (r367577) > > @@ -0,0 +1,4 @@ > > +.\" $FreeBSD$ > > +Set to build the base system or kernel with stack variables initialized > > +to zero on function entry. > > +This option requires that the clang compiler be used. >=20 --V88s5gaDVPzZ0KCq Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAEBAgAGBQJfqwsOAAoJEKzQXbSebgfAwj0H/3WkVjGcexHVNAzAmxyvjJ0+ A75eGFyYwA2Lqbuykq/zGeenKjboOvuM292r363w6Gc9Qz87nHvf1tCXWNlR9qrk PE5uMOKzyEwP/oJgpToI04gt/cYvsD634+EiNRiOaSzkLti3JdEQQU8W7NBf+JqO CdrNx9/yt1gIkep3dlyLt6S/JHRW7CUqOZx2gTYwdzWDLvuKzHBDZqDSx0Wk+svk LqYfHaeLeNo7pY2xVoTek2aYACfewjhD9TOApG/hzWv0HYCO2USLCqeIUO2bjpU0 DXdsMJFl6VCuIa2ag7NFXdvLiV5jmbl1gOIER8hSi6ieQUXDucOq2YALA02Ahco= =uDFQ -----END PGP SIGNATURE----- --V88s5gaDVPzZ0KCq--