From owner-svn-src-head@freebsd.org Sun Dec 18 00:44:44 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BF258C71D15; Sun, 18 Dec 2016 00:44:44 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 75CB4228; Sun, 18 Dec 2016 00:44:44 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBI0ihsk072198; Sun, 18 Dec 2016 00:44:43 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBI0ihWr072197; Sun, 18 Dec 2016 00:44:43 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612180044.uBI0ihWr072197@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Sun, 18 Dec 2016 00:44:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310196 - head/usr.sbin/bsnmpd/modules/snmp_bridge X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Sun, 18 Dec 2016 00:44:44 -0000 Author: ngie Date: Sun Dec 18 00:44:43 2016 New Revision: 310196 URL: https://svnweb.freebsd.org/changeset/base/310196 Log: Fix some minor typos with begemotBridgeTpLearnedEntryDiscards and begemotBridgeTpMaxAddresses Bump LAST-UPDATED for the MIB, per the change MFC after: 1 week Modified: head/usr.sbin/bsnmpd/modules/snmp_bridge/BEGEMOT-BRIDGE-MIB.txt Modified: head/usr.sbin/bsnmpd/modules/snmp_bridge/BEGEMOT-BRIDGE-MIB.txt ============================================================================== --- head/usr.sbin/bsnmpd/modules/snmp_bridge/BEGEMOT-BRIDGE-MIB.txt Sun Dec 18 00:39:04 2016 (r310195) +++ head/usr.sbin/bsnmpd/modules/snmp_bridge/BEGEMOT-BRIDGE-MIB.txt Sun Dec 18 00:44:43 2016 (r310196) @@ -41,7 +41,7 @@ IMPORTS FROM BEGEMOT-MIB; begemotBridge MODULE-IDENTITY - LAST-UPDATED "200708060000Z" + LAST-UPDATED "201612170000Z" ORGANIZATION "Sofia University St. Kliment Ohridski" CONTACT-INFO " Shteryana Shopova @@ -56,6 +56,9 @@ begemotBridge MODULE-IDENTITY E-Mail: syrinx@FreeBSD.org" DESCRIPTION "The Begemot MIB for managing bridge interfaces." + REVISION "201612170000Z" + DESCRIPTION + "Address some minor typos and grammar mistakes." REVISION "200708060000Z" DESCRIPTION "Third revision adds begemotBridgeBasePortPrivate @@ -856,7 +859,7 @@ begemotBridgeTpLearnedEntryDiscards OBJE DESCRIPTION "The total number of Forwarding Database entries that would have been learnt, but have been discarded due to Forwarding - Address Table having reached it's maximum entries limit." + Address Table having reached its maximum entries limit." ::= { begemotBridgeTpEntry 1 } begemotBridgeTpAgingTime OBJECT-TYPE @@ -874,7 +877,7 @@ begemotBridgeTpMaxAddresses OBJECT-TYPE MAX-ACCESS read-write STATUS current DESCRIPTION - "The maximum number of entires that this bridge can + "The maximum number of entries that this bridge can learn in its Forwarding Address Table and use for making forwarding decisions." ::= { begemotBridgeTpEntry 3 } From owner-svn-src-head@freebsd.org Sun Dec 18 01:52:18 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5739EC71192; Sun, 18 Dec 2016 01:52:18 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 19BEA1260; Sun, 18 Dec 2016 01:52:18 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBI1qHK5099022; Sun, 18 Dec 2016 01:52:17 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBI1qHJr099019; Sun, 18 Dec 2016 01:52:17 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201612180152.uBI1qHJr099019@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sun, 18 Dec 2016 01:52:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310197 - in head/tools/tools/locale: . etc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Sun, 18 Dec 2016 01:52:18 -0000 Author: bapt Date: Sun Dec 18 01:52:16 2016 New Revision: 310197 URL: https://svnweb.freebsd.org/changeset/base/310197 Log: Prepare import of CLDR v30.3 and unicode 9.0.0 Upstream kk_Cyrl_KZ has been renamed kk_KZ Upstream mn_Cyrl_MN has been renamed mn_MN For ru_RU: the default currency for unicode is now ₽ which is not mapped to other encoding, add charmaps entries to be able to generate them Modified: head/tools/tools/locale/Makefile head/tools/tools/locale/etc/charmaps.xml head/tools/tools/locale/etc/unicode.conf Modified: head/tools/tools/locale/Makefile ============================================================================== --- head/tools/tools/locale/Makefile Sun Dec 18 00:44:43 2016 (r310196) +++ head/tools/tools/locale/Makefile Sun Dec 18 01:52:16 2016 (r310197) @@ -118,7 +118,7 @@ BASE_LOCALES_OF_INTEREST?= \ nb_NO nl_BE nl_NL nn_NO pl_PL pt_BR pt_PT ro_RO \ ru_RU se_FI se_NO sk_SK sl_SI sv_FI sv_SE tr_TR \ uk_UA \ - kk_Cyrl_KZ mn_Cyrl_MN sr_Cyrl_RS sr_Latn_RS \ + kk_KZ mn_MN sr_Cyrl_RS sr_Latn_RS \ zh_Hans_CN zh_Hant_HK zh_Hant_TW \ bn_IN gu_IN or_IN ta_IN te_IN kn_IN ml_IN si_LK \ th_TH lo_LA bo_IN my_MM pa_Guru_IN ka_GE chr_US \ Modified: head/tools/tools/locale/etc/charmaps.xml ============================================================================== --- head/tools/tools/locale/etc/charmaps.xml Sun Dec 18 00:44:43 2016 (r310196) +++ head/tools/tools/locale/etc/charmaps.xml Sun Dec 18 01:52:16 2016 (r310197) @@ -117,7 +117,6 @@ encoding="SJIS eucJP" countries="JP" /> + + + + Modified: head/tools/tools/locale/etc/unicode.conf ============================================================================== --- head/tools/tools/locale/etc/unicode.conf Sun Dec 18 00:44:43 2016 (r310196) +++ head/tools/tools/locale/etc/unicode.conf Sun Dec 18 01:52:16 2016 (r310197) @@ -1,2 +1,4 @@ -cldr ~/unicode/cldr/27.0.1 -unidata ~/unicode/UNIDATA/8.0.0 +# $FreeBSD$ + +cldr ~/unicode/cldr/30.0.3 +unidata ~/unicode/UNIDATA/9.0.0 From owner-svn-src-head@freebsd.org Sun Dec 18 02:02:34 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CF5CFC71629; Sun, 18 Dec 2016 02:02:34 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 9F07D1A50; Sun, 18 Dec 2016 02:02:34 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBI22XmX005423; Sun, 18 Dec 2016 02:02:33 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBI22XCu005422; Sun, 18 Dec 2016 02:02:33 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201612180202.uBI22XCu005422@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sun, 18 Dec 2016 02:02:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310198 - head/tools/tools/locale/tools X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Sun, 18 Dec 2016 02:02:34 -0000 Author: bapt Date: Sun Dec 18 02:02:33 2016 New Revision: 310198 URL: https://svnweb.freebsd.org/changeset/base/310198 Log: Simplify extraction of static collation definition Modified: head/tools/tools/locale/tools/extract-colldef.awk Modified: head/tools/tools/locale/tools/extract-colldef.awk ============================================================================== --- head/tools/tools/locale/tools/extract-colldef.awk Sun Dec 18 01:52:16 2016 (r310197) +++ head/tools/tools/locale/tools/extract-colldef.awk Sun Dec 18 02:02:33 2016 (r310198) @@ -5,14 +5,8 @@ BEGIN { print "# from CLDR project data, obtained from http://cldr.unicode.org/" print "# -----------------------------------------------------------------------------" } -$1 == "comment_char" { print $0 } -$1 == "escape_char" { print $0 } -$1 == "LC_COLLATE" { - print $0 - while (getline line) { - print line - if (line == "END LC_COLLATE") { - break - } - } -} +$1 == "comment_char" { print } +$1 == "escape_char" { print } +$1 == "LC_COLLATE" { doprint = 1 } +doprint == 1 { print } +$1 == "END" && $2 == "LC_COLLATE" { exit 0 } From owner-svn-src-head@freebsd.org Sun Dec 18 03:08:47 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7A661C8499E; Sun, 18 Dec 2016 03:08:47 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail108.syd.optusnet.com.au (mail108.syd.optusnet.com.au [211.29.132.59]) by mx1.freebsd.org (Postfix) with ESMTP id 026BB9A3; Sun, 18 Dec 2016 03:08:47 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from besplex.bde.org (c122-106-153-191.carlnfd1.nsw.optusnet.com.au [122.106.153.191]) by mail108.syd.optusnet.com.au (Postfix) with ESMTPS id CD1141A0706; Sun, 18 Dec 2016 14:08:36 +1100 (AEDT) Date: Sun, 18 Dec 2016 14:08:35 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Dimitry Andric cc: David Chisnall , Baptiste Daroussin , "Conrad E. Meyer" , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r310138 - head/lib/libc/stdio In-Reply-To: <0BDD9ECA-AF91-4CA7-AA5D-DC7AD36AE531@FreeBSD.org> Message-ID: <20161218134740.L955@besplex.bde.org> References: <201612160144.uBG1ipjW016736@repo.freebsd.org> <20161216193128.wgskqt4vc44vdd7o@ivaldir.etoilebsd.net> <00BFA847-B26A-453A-87DB-D5A55C1FAA38@FreeBSD.org> <0BDD9ECA-AF91-4CA7-AA5D-DC7AD36AE531@FreeBSD.org> MIME-Version: 1.0 X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.2 cv=cZeiljLM c=1 sm=1 tr=0 a=Tj3pCpwHnMupdyZSltBt7Q==:117 a=Tj3pCpwHnMupdyZSltBt7Q==:17 a=nlC_4_pT8q9DhB4Ho9EA:9 a=6I5d2MoRAAAA:8 a=NMMmldDwOF9AJvgmeHMA:9 a=45ClL6m2LaAA:10 a=IjZwj45LgO3ly-622nXo:22 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Sun, 18 Dec 2016 03:08:47 -0000 On Sat, 17 Dec 2016, Dimitry Andric wrote: > On 17 Dec 2016, at 12:46, David Chisnall wrote: >> >> On 16 Dec 2016, at 19:31, Baptiste Daroussin wrote: >>> >>> Other than that, it makes more difficult to use vanilla gcc with out us= erland. >>> and it is adding more complexity to be able to build freebsd from a non= freebsd >>> system which some people are working on. >> >> Why? You=E2=80=99ll get some spurious warnings about printf, but that= =E2=80=99s all. > > Unfortunately, we compile large parts of the tree with -Werror. Thus, > "spurious warnings" will break the build, leaving the user two options: > disabling -Wformat warnings, or disabling -Werror altogether, neither of > which are very recommendable. > > As far as I know, there is no -Wno-error-on-undefined-printf-specifiers. > It would also be hard to implement, since after any undefined specifiers > have been encountered, you cannot reason about the following ones > anymore either. > > IMHO, if people want to use non-standard specifiers, let them define > their own almost_printf_but_not_quite() functions, and forgo any format > checking. That would be worse than breaking format checking for the selected set of printf()s. It gives even more unportability. %b is a BSDism that would be detected at compile time on systems without support for %b in printf(). almost_printf_but_not_quite() is a FreeBSDism that would be detected at compile time on systems without the function. Using it breaks portability even to other BSD systems including previous versions of FreeBSD. People who want to use non-standard specifiers added support to check them the compiler. Bruce From owner-svn-src-head@freebsd.org Sun Dec 18 04:11:14 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 36E82C8644C; Sun, 18 Dec 2016 04:11:14 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 11A9AC8E; Sun, 18 Dec 2016 04:11:13 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBI4BDng057417; Sun, 18 Dec 2016 04:11:13 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBI4BDML057416; Sun, 18 Dec 2016 04:11:13 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201612180411.uBI4BDML057416@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sun, 18 Dec 2016 04:11:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310199 - head/tools/tools/locale/tools X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Sun, 18 Dec 2016 04:11:14 -0000 Author: bapt Date: Sun Dec 18 04:11:13 2016 New Revision: 310199 URL: https://svnweb.freebsd.org/changeset/base/310199 Log: Better handle posix names for locales Modified: head/tools/tools/locale/tools/finalize Modified: head/tools/tools/locale/tools/finalize ============================================================================== --- head/tools/tools/locale/tools/finalize Sun Dec 18 02:02:33 2016 (r310198) +++ head/tools/tools/locale/tools/finalize Sun Dec 18 04:11:13 2016 (r310199) @@ -41,20 +41,29 @@ AWKCMD="/## PLACEHOLDER/ { \ # Rename the sources with 3 components name into the POSIX version of the name using @modifier cd $old +pwd for i in *_*_*.*.src; do + if [ "$i" = "*_*_*.*.src" ]; then + break + fi oldname=${i%.*} nname=`echo $oldname | awk '{ split($0, a, "_"); print a[1]"_"a[3]"@"a[2];} '` - mv -i ${oldname}.src ${nname}.src + mv -f ${oldname}.src ${nname}.src + sed -i '' -e "s/${oldname}/${nname}/g" Makefile + COLLATIONS_SPECIAL=$(echo ${COLLATIONS_SPECIAL} | sed -e "s/${oldname}/${nname}/g") done - sed -i '' -Ee "s/([a-zA-Z]{2})_([a-zA-Z]+)_([a-zA-Z]{2}).([a-zA-Z0-9-]+)/\1_\3.\4@\2/g" ${old}/Makefile # For variable without @modifier ambiguity do not keep the @modifier for i in *@*.src; do + if [ "$i" = "*@*.src" ]; then + break + fi oldname=${i%.*} shortname=${oldname%@*} - if [ $(ls ${shortname}@* | wc -l) -eq 1 -a ! -f ${shortname}.src ] ; then - mv -i $i ${shortname}.src - sed -i '' -e "s/${oldname}/${shortname}/g" ${old}/Makefile + if [ $(ls ${shortname}@* | wc -l) -eq 1 ] ; then + mv -f $i ${shortname}.src + sed -i '' -e "s/${oldname}/${shortname}/g" Makefile + COLLATIONS_SPECIAL=$(echo ${COLLATIONS_SPECIAL} | sed -e "s/${oldname}/${shortname}/g") fi done @@ -63,16 +72,19 @@ for i in *@Latn.src; do if [ "$i" = "*@Latn.src" ]; then break fi - mv ${i} ${i%@*}@latin.src + mv -f ${i} ${i%@*}@latin.src + sed -i '' -e "s/${i%.*}/${i%@*}@latin/g" Makefile + COLLATIONS_SPECIAL=$(echo ${COLLATIONS_SPECIAL} | sed -e "s/${i%.*}/${i%@*}@latin/g") done - sed -i '' -e "s/@Latn/@latin/g" ${old}/Makefile + for i in *@Cyrl.src; do if [ "$i" = "*@Cyrl.src" ]; then break fi - mv ${i} ${i%@*}@cyrillic.src + mv -f ${i} ${i%@*}@cyrillic.src + sed -i '' -e "s/${i%.*}/${i%@*}@cyrillic/g" Makefile + COLLATIONS_SPECIAL=$(echo ${COLLATIONS_SPECIAL} | sed -e "s/${i%.*}/${i%@*}@cyrillic/g") done - sed -i '' -e "s/@Cyrl/@cyrillic/g" ${old}/Makefile # On locales with multiple modifiers rename the "default" version without the @modifier default_locales="sr_RS@cyrillic" @@ -83,8 +95,8 @@ for i in ${default_locales}; do if [ "$l" = "${localename}.*@${mod}.src" ]; then break fi - mv ${l} ${l%@*}.src - sed -i '' -e "s/${l%.*}/${l%@*}/g" ${old}/Makefile + mv -f ${l} ${l%@*}.src + sed -i '' -e "s/${l%.*}/${l%@*}/g" Makefile done done cd - @@ -146,13 +158,12 @@ then done echo "" >> ${TEMP4} for enc in ${COLLATIONS_SPECIAL}; do - nname=`echo $enc | sed -e 's/_Hans//g'` - sed -i '' "/^.*${nname}$/d" ${TEMP4} - echo "LOCALES+= ${nname}" >> ${TEMP4} + sed -i '' "/^.*${enc}$/d" ${TEMP4} + echo "LOCALES+= ${enc}" >> ${TEMP4} done keep=$(cat ${TEMP} | awk '{ print $2 }') - for original in ${keep} + for original in ${keep} ${COLLATIONS_SPECIAL} do cp ${old}/${original}.src ${new}/ done From owner-svn-src-head@freebsd.org Sun Dec 18 04:12:46 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 95E0AC86559; Sun, 18 Dec 2016 04:12:46 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 6559110B4; Sun, 18 Dec 2016 04:12:46 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBI4CjEf058338; Sun, 18 Dec 2016 04:12:45 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBI4CjhI058337; Sun, 18 Dec 2016 04:12:45 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201612180412.uBI4CjhI058337@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sun, 18 Dec 2016 04:12:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310200 - head/tools/tools/locale X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Sun, 18 Dec 2016 04:12:46 -0000 Author: bapt Date: Sun Dec 18 04:12:45 2016 New Revision: 310200 URL: https://svnweb.freebsd.org/changeset/base/310200 Log: In order to prepare cldr v30.0.3 and unicode 9.0.0, more locales are removed from automatic mapping from unicode as their encoding does not supports new characters available in unicode Modified: head/tools/tools/locale/Makefile Modified: head/tools/tools/locale/Makefile ============================================================================== --- head/tools/tools/locale/Makefile Sun Dec 18 04:11:13 2016 (r310199) +++ head/tools/tools/locale/Makefile Sun Dec 18 04:12:45 2016 (r310200) @@ -31,8 +31,16 @@ COLLATION_SPECIAL?= \ nb_NO ISO8859-1 \ nb_NO ISO8859-15 \ sk_SK ISO8859-2 \ + sr_Latn_RS ISO8859-2 \ + sr_Cyrl_RS ISO8859-5 \ zh_Hans_CN GB2312 \ zh_Hans_CN eucCN \ + zh_Hant_TW Big5 \ + zh_Hans_CN GB18030 \ + zh_Hans_CN GBK \ + ja_JP eucJP \ + nn_NO ISO8859-15 \ + nn_NO ISO8859-1 .for area enc in ${COLLATION_SPECIAL} COLLATIONS_SPECIAL_ENV+= ${area}.${enc} @@ -91,7 +99,7 @@ build-colldef: static-colldef static-colldef: .for area enc in ${COLLATION_SPECIAL} - awk -f tools/extract-colldef.awk ${CLDRDIR}/posix/${area}.${enc}.src > colldef/${area}.${enc}.src + awk -f tools/extract-colldef.awk ${CLDRDIR}/posix/${area}.${enc}.src > colldef.draft/${area}.${enc}.src .endfor transfer-rollup: From owner-svn-src-head@freebsd.org Sun Dec 18 04:17:14 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F2193C866AB; Sun, 18 Dec 2016 04:17:14 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 9688E135B; Sun, 18 Dec 2016 04:17:14 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBI4HDJm058567; Sun, 18 Dec 2016 04:17:13 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBI4HDDL058563; Sun, 18 Dec 2016 04:17:13 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201612180417.uBI4HDDL058563@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sun, 18 Dec 2016 04:17:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310201 - in head: share/colldef share/ctypedef share/monetdef share/msgdef share/numericdef tools/tools/locale/etc tools/tools/locale/etc/final-maps X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Sun, 18 Dec 2016 04:17:15 -0000 Author: bapt Date: Sun Dec 18 04:17:13 2016 New Revision: 310201 URL: https://svnweb.freebsd.org/changeset/base/310201 Log: Update locales cldr to v30.0.3 and unicode to 9.0.0 MFC after: 1 month Relnotes: yes Added: head/share/colldef/fr_CA.UTF-8.src (contents, props changed) head/share/colldef/ja_JP.eucJP.src (contents, props changed) head/share/colldef/nn_NO.ISO8859-1.src (contents, props changed) head/share/colldef/nn_NO.ISO8859-15.src (contents, props changed) head/share/colldef/nn_NO.UTF-8.src (contents, props changed) head/share/colldef/sr_RS.ISO8859-2.src (contents, props changed) head/share/colldef/sr_RS.ISO8859-5.src (contents, props changed) head/share/colldef/sr_RS.UTF-8.src (contents, props changed) head/share/colldef/sr_RS.UTF-8@latin.src (contents, props changed) head/share/colldef/zh_CN.GB18030.src (contents, props changed) head/share/colldef/zh_CN.GBK.src (contents, props changed) head/share/colldef/zh_TW.Big5.src (contents, props changed) head/share/ctypedef/ja_JP.eucJP.src (contents, props changed) head/share/ctypedef/zh_CN.eucCN.src (contents, props changed) head/share/monetdef/nl_BE.UTF-8.src (contents, props changed) head/tools/tools/locale/etc/final-maps/map.CP949 - copied unchanged from r303786, head/tools/tools/locale/etc/final-maps/map.eucKR Deleted: head/share/colldef/hr_HR.UTF-8.src head/share/colldef/nb_NO.UTF-8.src head/share/ctypedef/ja_JP.SJIS.src head/share/ctypedef/zh_CN.GB18030.src head/share/monetdef/be_BY.CP1251.src head/share/monetdef/lv_LV.ISO8859-13.src head/share/monetdef/lv_LV.UTF-8.src head/share/monetdef/ru_RU.CP1251.src head/share/msgdef/he_IL.UTF-8.src head/share/numericdef/hy_AM.UTF-8.src Modified: head/share/colldef/Makefile head/share/colldef/af_ZA.UTF-8.src head/share/colldef/am_ET.UTF-8.src head/share/colldef/ar_SA.UTF-8.src head/share/colldef/be_BY.UTF-8.src head/share/colldef/ca_AD.UTF-8.src head/share/colldef/cs_CZ.ISO8859-2.src head/share/colldef/cs_CZ.UTF-8.src head/share/colldef/da_DK.ISO8859-1.src head/share/colldef/da_DK.ISO8859-15.src head/share/colldef/da_DK.UTF-8.src head/share/colldef/el_GR.UTF-8.src head/share/colldef/en_US.UTF-8.src head/share/colldef/es_MX.UTF-8.src head/share/colldef/et_EE.UTF-8.src head/share/colldef/fi_FI.UTF-8.src head/share/colldef/he_IL.UTF-8.src head/share/colldef/hi_IN.UTF-8.src head/share/colldef/hr_HR.ISO8859-2.src head/share/colldef/hu_HU.ISO8859-2.src head/share/colldef/hu_HU.UTF-8.src head/share/colldef/hy_AM.UTF-8.src head/share/colldef/is_IS.UTF-8.src head/share/colldef/ja_JP.UTF-8.src head/share/colldef/kk_KZ.UTF-8.src head/share/colldef/ko_KR.UTF-8.src head/share/colldef/lt_LT.UTF-8.src head/share/colldef/lv_LV.UTF-8.src head/share/colldef/nb_NO.ISO8859-1.src head/share/colldef/nb_NO.ISO8859-15.src head/share/colldef/pl_PL.UTF-8.src head/share/colldef/ro_RO.UTF-8.src head/share/colldef/ru_RU.UTF-8.src head/share/colldef/se_NO.UTF-8.src head/share/colldef/sk_SK.ISO8859-2.src head/share/colldef/sk_SK.UTF-8.src head/share/colldef/sl_SI.UTF-8.src head/share/colldef/sv_SE.UTF-8.src head/share/colldef/tr_TR.UTF-8.src head/share/colldef/uk_UA.UTF-8.src head/share/colldef/zh_CN.GB2312.src head/share/colldef/zh_CN.UTF-8.src head/share/colldef/zh_CN.eucCN.src head/share/colldef/zh_TW.UTF-8.src head/share/ctypedef/Makefile head/share/ctypedef/be_BY.CP1131.src head/share/ctypedef/ca_IT.ISO8859-1.src head/share/ctypedef/en_US.ISO8859-1.src head/share/ctypedef/en_US.UTF-8.src head/share/ctypedef/hi_IN.ISCII-DEV.src head/share/ctypedef/uk_UA.CP1251.src head/share/monetdef/Makefile head/share/monetdef/ar_AE.UTF-8.src head/share/monetdef/ar_EG.UTF-8.src head/share/monetdef/ar_JO.UTF-8.src head/share/monetdef/ar_QA.UTF-8.src head/share/monetdef/ar_SA.UTF-8.src head/share/monetdef/be_BY.CP1131.src head/share/monetdef/be_BY.ISO8859-5.src head/share/monetdef/be_BY.UTF-8.src head/share/monetdef/bg_BG.CP1251.src head/share/monetdef/bg_BG.UTF-8.src head/share/monetdef/es_AR.UTF-8.src head/share/monetdef/es_CR.UTF-8.src head/share/monetdef/hu_HU.ISO8859-2.src head/share/monetdef/hu_HU.UTF-8.src head/share/monetdef/hy_AM.ARMSCII-8.src head/share/monetdef/hy_AM.UTF-8.src head/share/monetdef/ru_RU.CP866.src head/share/monetdef/ru_RU.ISO8859-5.src head/share/monetdef/ru_RU.KOI8-R.src head/share/monetdef/ru_RU.UTF-8.src head/share/monetdef/sl_SI.UTF-8.src head/share/monetdef/tr_TR.ISO8859-9.src head/share/monetdef/tr_TR.UTF-8.src head/share/monetdef/zh_CN.GB2312.src head/share/monetdef/zh_CN.GBK.src head/share/monetdef/zh_CN.UTF-8.src head/share/monetdef/zh_CN.eucCN.src head/share/monetdef/zh_TW.Big5.src head/share/monetdef/zh_TW.UTF-8.src head/share/msgdef/Makefile head/share/msgdef/ja_JP.SJIS.src head/share/msgdef/ja_JP.UTF-8.src head/share/msgdef/ja_JP.eucJP.src head/share/msgdef/tr_TR.ISO8859-9.src head/share/msgdef/tr_TR.UTF-8.src head/share/numericdef/Makefile head/tools/tools/locale/etc/common.UTF-8.src (contents, props changed) head/tools/tools/locale/etc/final-maps/map.GB2312 head/tools/tools/locale/etc/final-maps/map.UTF-8 (contents, props changed) Modified: head/share/colldef/Makefile ============================================================================== --- head/share/colldef/Makefile Sun Dec 18 04:12:45 2016 (r310200) +++ head/share/colldef/Makefile Sun Dec 18 04:17:13 2016 (r310201) @@ -23,9 +23,9 @@ LOCALES+= en_US.UTF-8 LOCALES+= es_MX.UTF-8 LOCALES+= et_EE.UTF-8 LOCALES+= fi_FI.UTF-8 +LOCALES+= fr_CA.UTF-8 LOCALES+= he_IL.UTF-8 LOCALES+= hi_IN.UTF-8 -LOCALES+= hr_HR.UTF-8 LOCALES+= hu_HU.UTF-8 LOCALES+= hy_AM.UTF-8 LOCALES+= is_IS.UTF-8 @@ -34,13 +34,15 @@ LOCALES+= kk_KZ.UTF-8 LOCALES+= ko_KR.UTF-8 LOCALES+= lt_LT.UTF-8 LOCALES+= lv_LV.UTF-8 -LOCALES+= nb_NO.UTF-8 +LOCALES+= nn_NO.UTF-8 LOCALES+= pl_PL.UTF-8 LOCALES+= ro_RO.UTF-8 LOCALES+= ru_RU.UTF-8 LOCALES+= se_NO.UTF-8 LOCALES+= sk_SK.UTF-8 LOCALES+= sl_SI.UTF-8 +LOCALES+= sr_RS.UTF-8 +LOCALES+= sr_RS.UTF-8@latin LOCALES+= sv_SE.UTF-8 LOCALES+= tr_TR.UTF-8 LOCALES+= uk_UA.UTF-8 @@ -52,7 +54,6 @@ LOCALES_MAPPED+= af_ZA.UTF-8 af_ZA.ISO88 LOCALES_MAPPED+= be_BY.UTF-8 be_BY.ISO8859-5 LOCALES_MAPPED+= be_BY.UTF-8 be_BY.CP1251 LOCALES_MAPPED+= be_BY.UTF-8 be_BY.CP1131 -LOCALES_MAPPED+= ru_RU.UTF-8 sr_RS.ISO8859-5 LOCALES_MAPPED+= ru_RU.UTF-8 ru_RU.KOI8-R LOCALES_MAPPED+= ru_RU.UTF-8 ru_RU.ISO8859-5 LOCALES_MAPPED+= ru_RU.UTF-8 ru_RU.CP866 @@ -66,13 +67,9 @@ LOCALES_MAPPED+= ca_AD.UTF-8 ca_ES.ISO88 LOCALES_MAPPED+= ca_AD.UTF-8 ca_ES.ISO8859-1 LOCALES_MAPPED+= ca_AD.UTF-8 ca_AD.ISO8859-15 LOCALES_MAPPED+= ca_AD.UTF-8 ca_AD.ISO8859-1 -LOCALES_MAPPED+= en_US.UTF-8 sr_RS.UTF-8@latin -LOCALES_MAPPED+= en_US.UTF-8 sr_RS.ISO8859-2 LOCALES_MAPPED+= en_US.UTF-8 pt_PT.ISO8859-15 LOCALES_MAPPED+= en_US.UTF-8 pt_PT.ISO8859-1 LOCALES_MAPPED+= en_US.UTF-8 pt_BR.ISO8859-1 -LOCALES_MAPPED+= en_US.UTF-8 nn_NO.ISO8859-15 -LOCALES_MAPPED+= en_US.UTF-8 nn_NO.ISO8859-1 LOCALES_MAPPED+= en_US.UTF-8 nl_NL.ISO8859-15 LOCALES_MAPPED+= en_US.UTF-8 nl_NL.ISO8859-1 LOCALES_MAPPED+= en_US.UTF-8 nl_BE.ISO8859-15 @@ -85,8 +82,6 @@ LOCALES_MAPPED+= en_US.UTF-8 fr_FR.ISO88 LOCALES_MAPPED+= en_US.UTF-8 fr_FR.ISO8859-1 LOCALES_MAPPED+= en_US.UTF-8 fr_CH.ISO8859-15 LOCALES_MAPPED+= en_US.UTF-8 fr_CH.ISO8859-1 -LOCALES_MAPPED+= en_US.UTF-8 fr_CA.ISO8859-15 -LOCALES_MAPPED+= en_US.UTF-8 fr_CA.ISO8859-1 LOCALES_MAPPED+= en_US.UTF-8 fr_BE.ISO8859-15 LOCALES_MAPPED+= en_US.UTF-8 fr_BE.ISO8859-1 LOCALES_MAPPED+= en_US.UTF-8 eu_ES.ISO8859-15 @@ -128,12 +123,14 @@ LOCALES_MAPPED+= et_EE.UTF-8 et_EE.ISO88 LOCALES_MAPPED+= et_EE.UTF-8 et_EE.ISO8859-1 LOCALES_MAPPED+= fi_FI.UTF-8 fi_FI.ISO8859-15 LOCALES_MAPPED+= fi_FI.UTF-8 fi_FI.ISO8859-1 +LOCALES_MAPPED+= fr_CA.UTF-8 fr_CA.ISO8859-15 +LOCALES_MAPPED+= fr_CA.UTF-8 fr_CA.ISO8859-1 LOCALES_MAPPED+= hi_IN.UTF-8 hi_IN.ISCII-DEV +LOCALES_MAPPED+= sr_RS.UTF-8@latin hr_HR.UTF-8 LOCALES_MAPPED+= hy_AM.UTF-8 hy_AM.ARMSCII-8 LOCALES_MAPPED+= is_IS.UTF-8 is_IS.ISO8859-15 LOCALES_MAPPED+= is_IS.UTF-8 is_IS.ISO8859-1 LOCALES_MAPPED+= ja_JP.UTF-8 ja_JP.SJIS -LOCALES_MAPPED+= ja_JP.UTF-8 ja_JP.eucJP LOCALES_MAPPED+= ko_KR.UTF-8 ko_KR.eucKR LOCALES_MAPPED+= lt_LT.UTF-8 lt_LT.ISO8859-13 LOCALES_MAPPED+= lv_LV.UTF-8 lv_LV.ISO8859-13 @@ -148,9 +145,6 @@ LOCALES_MAPPED+= tr_TR.UTF-8 tr_TR.ISO88 LOCALES_MAPPED+= uk_UA.UTF-8 uk_UA.KOI8-U LOCALES_MAPPED+= uk_UA.UTF-8 uk_UA.ISO8859-5 LOCALES_MAPPED+= uk_UA.UTF-8 uk_UA.CP1251 -LOCALES_MAPPED+= zh_CN.UTF-8 zh_CN.GBK -LOCALES_MAPPED+= zh_CN.UTF-8 zh_CN.GB18030 -LOCALES_MAPPED+= zh_TW.UTF-8 zh_TW.Big5 LOCALES+= cs_CZ.ISO8859-2 LOCALES+= da_DK.ISO8859-1 @@ -160,8 +154,16 @@ LOCALES+= hu_HU.ISO8859-2 LOCALES+= nb_NO.ISO8859-1 LOCALES+= nb_NO.ISO8859-15 LOCALES+= sk_SK.ISO8859-2 +LOCALES+= sr_RS.ISO8859-2 +LOCALES+= sr_RS.ISO8859-5 LOCALES+= zh_CN.GB2312 LOCALES+= zh_CN.eucCN +LOCALES+= zh_TW.Big5 +LOCALES+= zh_CN.GB18030 +LOCALES+= zh_CN.GBK +LOCALES+= ja_JP.eucJP +LOCALES+= nn_NO.ISO8859-15 +LOCALES+= nn_NO.ISO8859-1 SAME+= ar_SA.UTF-8 ar_QA.UTF-8 @@ -169,7 +171,6 @@ SAME+= ar_SA.UTF-8 ar_MA.UTF-8 SAME+= ar_SA.UTF-8 ar_JO.UTF-8 SAME+= ar_SA.UTF-8 ar_EG.UTF-8 SAME+= ar_SA.UTF-8 ar_AE.UTF-8 -SAME+= ru_RU.UTF-8 sr_RS.UTF-8 SAME+= ru_RU.UTF-8 mn_MN.UTF-8 SAME+= ru_RU.UTF-8 bg_BG.UTF-8 SAME+= ca_AD.UTF-8 ca_IT.UTF-8 @@ -177,14 +178,12 @@ SAME+= ca_AD.UTF-8 ca_FR.UTF-8 SAME+= ca_AD.UTF-8 ca_ES.UTF-8 SAME+= en_US.UTF-8 pt_PT.UTF-8 SAME+= en_US.UTF-8 pt_BR.UTF-8 -SAME+= en_US.UTF-8 nn_NO.UTF-8 SAME+= en_US.UTF-8 nl_NL.UTF-8 SAME+= en_US.UTF-8 nl_BE.UTF-8 SAME+= en_US.UTF-8 it_IT.UTF-8 SAME+= en_US.UTF-8 it_CH.UTF-8 SAME+= en_US.UTF-8 fr_FR.UTF-8 SAME+= en_US.UTF-8 fr_CH.UTF-8 -SAME+= en_US.UTF-8 fr_CA.UTF-8 SAME+= en_US.UTF-8 fr_BE.UTF-8 SAME+= en_US.UTF-8 eu_ES.UTF-8 SAME+= en_US.UTF-8 en_ZA.UTF-8 @@ -202,6 +201,7 @@ SAME+= en_US.UTF-8 de_AT.UTF-8 SAME+= es_MX.UTF-8 es_ES.UTF-8 SAME+= es_MX.UTF-8 es_CR.UTF-8 SAME+= es_MX.UTF-8 es_AR.UTF-8 +SAME+= nn_NO.UTF-8 nb_NO.UTF-8 SAME+= se_NO.UTF-8 se_FI.UTF-8 SAME+= sv_SE.UTF-8 sv_FI.UTF-8 SAME+= zh_TW.UTF-8 zh_HK.UTF-8 Modified: head/share/colldef/af_ZA.UTF-8.src ============================================================================== --- head/share/colldef/af_ZA.UTF-8.src Sun Dec 18 04:12:45 2016 (r310200) +++ head/share/colldef/af_ZA.UTF-8.src Sun Dec 18 04:17:13 2016 (r310201) @@ -42,7 +42,6 @@ collating-symbol collating-symbol collating-symbol collating-symbol -collating-symbol collating-symbol collating-symbol collating-symbol @@ -76,36 +75,36 @@ collating-symbol collating-symbol collating-symbol collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol collating-symbol collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol collating-symbol collating-symbol collating-symbol @@ -139,6 +138,7 @@ collating-symbol collating-symbol collating-symbol collating-symbol +collating-symbol collating-symbol collating-symbol collating-symbol @@ -312,6 +312,8 @@ collating-symbol collating-symbol collating-symbol collating-symbol +collating-symbol +collating-symbol collating-symbol collating-symbol collating-symbol @@ -471,14 +473,14 @@ collating-symbol collating-symbol collating-symbol collating-symbol -collating-symbol -collating-symbol -collating-symbol +collating-symbol +collating-symbol +collating-symbol collating-symbol +collating-symbol +collating-symbol collating-symbol collating-symbol -collating-symbol -collating-symbol collating-symbol collating-symbol collating-symbol @@ -489,6 +491,10 @@ collating-symbol collating-symbol collating-symbol collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol order_start forward;forward;forward;forward @@ -526,7 +532,6 @@ order_start forward;forward;forward;forw - @@ -560,36 +565,36 @@ order_start forward;forward;forward;forw - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + @@ -623,6 +628,7 @@ order_start forward;forward;forward;forw + @@ -796,6 +802,8 @@ order_start forward;forward;forward;forw + + @@ -955,14 +963,14 @@ order_start forward;forward;forward;forw - - - + + + + + - - @@ -973,6 +981,10 @@ order_start forward;forward;forward;forw + + + + * assignment of characters to weights @@ -1018,36 +1030,36 @@ order_start forward;forward;forward;forw ;;; ;;; ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; ;;; ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; ;;; ;;; ;;; @@ -1147,7 +1159,7 @@ order_start forward;forward;forward;forw "";"";""; "";"";""; "";"";""; - "";"";""; + "";"";""; ;;; ;;; ;;; @@ -1193,6 +1205,8 @@ order_start forward;forward;forward;forw ;;; ;;; ;;; + ;;; + ;;; ;;; ;;; ;;; @@ -1528,7 +1542,8 @@ order_start forward;forward;forward;forw "";"";""; ;;; ;;; - ;;; + ;;; + ;;; ;;; ;;; ;;; @@ -1558,7 +1573,8 @@ order_start forward;forward;forward;forw ;;; ;;; ;;; - ;;; + ;;; + ;;; ;;; ;;; ;;; @@ -1621,8 +1637,8 @@ order_start forward;forward;forward;forw ;"";""; ;"";""; ;"";""; - ;"";""; - ;"";""; + ;"";""; + ;"";""; "";"";""; "";"";""; "";"";""; @@ -1846,23 +1862,26 @@ order_start forward;forward;forward;forw ;;; ;;; ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;;

;;;

;;;

;;;

@@ -2252,6 +2271,7 @@ order_start forward;forward;forward;forw ;;; ;;; ;;; + ;;; ;;; ;;; ;;; @@ -2344,52 +2364,56 @@ order_start forward;forward;forward;forw ;;; ;;; ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; UNDEFINED IGNORE;IGNORE;IGNORE;... order_end Modified: head/share/colldef/am_ET.UTF-8.src ============================================================================== --- head/share/colldef/am_ET.UTF-8.src Sun Dec 18 04:12:45 2016 (r310200) +++ head/share/colldef/am_ET.UTF-8.src Sun Dec 18 04:17:13 2016 (r310201) @@ -13,13 +13,13 @@ LC_COLLATE collating-symbol collating-symbol -collating-symbol -collating-symbol +collating-symbol +collating-symbol +collating-symbol collating-symbol collating-symbol -collating-symbol collating-symbol -collating-symbol +collating-symbol collating-symbol collating-symbol collating-symbol @@ -46,51 +46,51 @@ collating-symbol collating-symbol collating-symbol collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol collating-symbol collating-symbol collating-symbol collating-symbol collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol collating-symbol -collating-symbol +collating-symbol collating-symbol collating-symbol collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol collating-symbol collating-symbol collating-symbol @@ -176,20 +176,20 @@ collating-symbol collating-symbol collating-symbol collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol -collating-symbol collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol collating-symbol collating-symbol collating-symbol @@ -351,13 +351,13 @@ order_start forward;forward;forward;forw - - + + + - - + @@ -384,51 +384,51 @@ order_start forward;forward;forward;forw - - - - - - - - - - + + + + + + + + + + - - - - - - - + + + + + + + - - - - - - + + + + + + - + - - - - - - - - - - + + + + + + + + + + @@ -514,20 +514,20 @@ order_start forward;forward;forward;forw - - - - - - - - - - - - - + + + + + + + + + + + + + @@ -712,9 +712,9 @@ order_start forward;forward;forward;forw IGNORE;IGNORE;IGNORE; IGNORE;IGNORE;IGNORE; IGNORE;IGNORE;IGNORE; - IGNORE;"";""; - IGNORE;"";""; - IGNORE;"";""; + IGNORE;"";""; + IGNORE;"";""; + IGNORE;"";""; ;;; ;;; ;;; @@ -736,23 +736,23 @@ order_start forward;forward;forward;forw ;;; ;;; ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; + ;;; ;;; ;;; "";;""; @@ -765,24 +765,24 @@ order_start forward;forward;forward;forw "";;""; "";;""; "";;""; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; - ;;; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@freebsd.org Sun Dec 18 05:31:55 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A8BDAC8609E; Sun, 18 Dec 2016 05:31:55 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 6AFA01FAA; Sun, 18 Dec 2016 05:31:55 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBI5VsE9090666; Sun, 18 Dec 2016 05:31:54 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBI5VsIa090665; Sun, 18 Dec 2016 05:31:54 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612180531.uBI5VsIa090665@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Sun, 18 Dec 2016 05:31:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310202 - head/contrib/bsnmp/lib X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Sun, 18 Dec 2016 05:31:55 -0000 Author: ngie Date: Sun Dec 18 05:31:54 2016 New Revision: 310202 URL: https://svnweb.freebsd.org/changeset/base/310202 Log: Clean up trailing and leading whitespace Fix variable type alignment in snmp_dialog(..) MFC after: 1 week Modified: head/contrib/bsnmp/lib/snmpclient.c Modified: head/contrib/bsnmp/lib/snmpclient.c ============================================================================== --- head/contrib/bsnmp/lib/snmpclient.c Sun Dec 18 04:17:13 2016 (r310201) +++ head/contrib/bsnmp/lib/snmpclient.c Sun Dec 18 05:31:54 2016 (r310202) @@ -8,7 +8,7 @@ * * Author: Harti Brandt * Kendy Kutzner - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -17,7 +17,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -1236,23 +1236,23 @@ snmp_send_packet(struct snmp_pdu * pdu) return (-1); } - pdu->request_id = snmp_next_reqid(&snmp_client); + pdu->request_id = snmp_next_reqid(&snmp_client); - b.asn_ptr = buf; - b.asn_len = snmp_client.txbuflen; - if (snmp_pdu_encode(pdu, &b)) { + b.asn_ptr = buf; + b.asn_len = snmp_client.txbuflen; + if (snmp_pdu_encode(pdu, &b)) { seterr(&snmp_client, "%s", strerror(errno)); free(buf); return (-1); } - if (snmp_client.dump_pdus) - snmp_pdu_dump(pdu); + if (snmp_client.dump_pdus) + snmp_pdu_dump(pdu); - if ((ret = send(snmp_client.fd, buf, b.asn_ptr - buf, 0)) == -1) { + if ((ret = send(snmp_client.fd, buf, b.asn_ptr - buf, 0)) == -1) { seterr(&snmp_client, "%s", strerror(errno)); free(buf); - return (-1); + return (-1); } free(buf); @@ -1269,7 +1269,7 @@ snmp_timeout(void * listentry_ptr) #if 0 warnx("snmp request %i timed out, attempt (%i/%i)", - listentry->reqid, listentry->retrycount, snmp_client.retries); + listentry->reqid, listentry->retrycount, snmp_client.retries); #endif listentry->retrycount++; @@ -1314,7 +1314,7 @@ snmp_pdu_send(struct snmp_pdu *pdu, snmp listentry->callback = func; listentry->arg = arg; listentry->retrycount=1; - listentry->timeout_id = + listentry->timeout_id = snmp_client.timeout_start(&snmp_client.timeout, snmp_timeout, listentry); @@ -1463,7 +1463,7 @@ snmp_receive_packet(struct snmp_pdu *pdu return (+1); } -static int +static int snmp_deliver_packet(struct snmp_pdu * resp) { struct sent_pdu *listentry; @@ -1548,7 +1548,7 @@ ok_getnext(const struct snmp_pdu * req, &resp->bindings[i].var)) { if (i != 0) warnx("SNMP GETNEXT: inconsistent table " - "response"); + "response"); return (0); } if (resp->version != SNMP_V1 && @@ -1654,7 +1654,7 @@ ok_set(const struct snmp_pdu * req, cons /* * Simple checks for response PDUs against request PDUs. Return values: 1=ok, - * 0=nosuchname or similar, -1=failure, -2=no response at all + * 0=nosuchname or similar, -1=failure, -2=no response at all */ int snmp_pdu_check(const struct snmp_pdu *req, @@ -1681,12 +1681,12 @@ snmp_pdu_check(const struct snmp_pdu *re int snmp_dialog(struct snmp_v1_pdu *req, struct snmp_v1_pdu *resp) { - u_int i; - int32_t reqid; - int ret; - struct timeval tv = snmp_client.timeout; + struct timeval tv = snmp_client.timeout; struct timeval end; struct snmp_pdu pdu; + u_int i; + int32_t reqid; + int ret; /* * Make a copy of the request and replace the syntaxes by NULL @@ -1698,11 +1698,11 @@ snmp_dialog(struct snmp_v1_pdu *req, str for (i = 0; i < pdu.nbindings; i++) pdu.bindings[i].syntax = SNMP_SYNTAX_NULL; } - - for (i = 0; i <= snmp_client.retries; i++) { + + for (i = 0; i <= snmp_client.retries; i++) { (void)gettimeofday(&end, NULL); timeradd(&end, &snmp_client.timeout, &end); - if ((reqid = snmp_send_packet(&pdu)) == -1) + if ((reqid = snmp_send_packet(&pdu)) == -1) return (-1); for (;;) { (void)gettimeofday(&tv, NULL); @@ -1717,16 +1717,16 @@ snmp_dialog(struct snmp_v1_pdu *req, str if (reqid == resp->request_id) return (0); /* not for us */ - (void)snmp_deliver_packet(resp); + (void)snmp_deliver_packet(resp); } if (ret < 0 && errno == EPIPE) /* stream closed */ return (-1); } - } + } errno = ETIMEDOUT; seterr(&snmp_client, "retry count exceeded"); - return (-1); + return (-1); } int From owner-svn-src-head@freebsd.org Sun Dec 18 05:36:05 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 756A4C861EF; Sun, 18 Dec 2016 05:36:05 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 451216C2; Sun, 18 Dec 2016 05:36:05 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBI5a4DK091013; Sun, 18 Dec 2016 05:36:04 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBI5a4Ci091012; Sun, 18 Dec 2016 05:36:04 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612180536.uBI5a4Ci091012@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Sun, 18 Dec 2016 05:36:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310203 - head/usr.sbin/bsnmpd/tools/bsnmptools X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Sun, 18 Dec 2016 05:36:05 -0000 Author: ngie Date: Sun Dec 18 05:36:04 2016 New Revision: 310203 URL: https://svnweb.freebsd.org/changeset/base/310203 Log: Clean up parse_ip(..) - Clean up trailing whitespace - Fix variable alignment MFC after: 1 week Modified: head/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c Modified: head/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c ============================================================================== --- head/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c Sun Dec 18 05:31:54 2016 (r310202) +++ head/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c Sun Dec 18 05:36:04 2016 (r310203) @@ -603,9 +603,9 @@ parse_oid_string(struct snmp_toolinfo *s static int32_t parse_ip(struct snmp_value * value, char * val) { - uint32_t v; - int32_t i; char *endptr, *str; + int32_t i; + uint32_t v; str = val; for (i = 0; i < 4; i++) { @@ -617,8 +617,8 @@ parse_ip(struct snmp_value * value, char str = endptr + 1; value->v.ipaddress[i] = (uint8_t) v; } - value->syntax = SNMP_SYNTAX_IPADDRESS; + return (0); } From owner-svn-src-head@freebsd.org Sun Dec 18 08:31:03 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 42ACAC86A6F; Sun, 18 Dec 2016 08:31:03 +0000 (UTC) (envelope-from jchandra@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 F09BB18BE; Sun, 18 Dec 2016 08:31:02 +0000 (UTC) (envelope-from jchandra@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBI8V2XZ059889; Sun, 18 Dec 2016 08:31:02 GMT (envelope-from jchandra@FreeBSD.org) Received: (from jchandra@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBI8V1VZ059886; Sun, 18 Dec 2016 08:31:01 GMT (envelope-from jchandra@FreeBSD.org) Message-Id: <201612180831.uBI8V1VZ059886@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jchandra set sender to jchandra@FreeBSD.org using -f From: "Jayachandran C." Date: Sun, 18 Dec 2016 08:31:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310204 - in head/sys: arm/arm arm64/arm64 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Sun, 18 Dec 2016 08:31:03 -0000 Author: jchandra Date: Sun Dec 18 08:31:01 2016 New Revision: 310204 URL: https://svnweb.freebsd.org/changeset/base/310204 Log: Initialize GIC[DR]_IGROUPRn registers for GICv3 In case where GICD_CTLR.DS is 1, the IGROUPR registers are RW in non-secure state and has to be initialized to 1 for the corresponding interrupts to be delivered as Group 1 interrupts. Update gic_v3_dist_init() and gic_v3_redist_init() to initialize GICD_IGROUPRn and GICR_IGROUPRn respectively to address this. The registers can be set unconditionally since the writes are ignored in non-secure state when GICD_CTLR.DS is 0. This fixes the hang on boot seen when running qemu-system-aarch64 with machine virt,gic-version=3 Modified: head/sys/arm/arm/gic_common.h head/sys/arm64/arm64/gic_v3.c head/sys/arm64/arm64/gic_v3_reg.h Modified: head/sys/arm/arm/gic_common.h ============================================================================== --- head/sys/arm/arm/gic_common.h Sun Dec 18 05:36:04 2016 (r310203) +++ head/sys/arm/arm/gic_common.h Sun Dec 18 08:31:01 2016 (r310204) @@ -66,6 +66,7 @@ __BUS_ACCESSOR(gic, bus, GIC, BUS, u_int #define GICD_IIDR_IMPL(x) \ (((x) & GICD_IIDR_IMPL_MASK) >> GICD_IIDR_IMPL_SHIFT) #define GICD_IGROUPR(n) (0x0080 + (((n) >> 5) * 4)) /* v1 ICDISER */ +#define GICD_I_PER_IGROUPRn 32 #define GICD_ISENABLER(n) (0x0100 + (((n) >> 5) * 4)) /* v1 ICDISER */ #define GICD_I_MASK(n) (1ul << ((n) & 0x1f)) #define GICD_I_PER_ISENABLERn 32 Modified: head/sys/arm64/arm64/gic_v3.c ============================================================================== --- head/sys/arm64/arm64/gic_v3.c Sun Dec 18 05:36:04 2016 (r310203) +++ head/sys/arm64/arm64/gic_v3.c Sun Dec 18 08:31:01 2016 (r310204) @@ -1040,6 +1040,10 @@ gic_v3_dist_init(struct gic_v3_softc *sc /* * 2. Configure the Distributor */ + /* Set all SPIs to be Group 1 Non-secure */ + for (i = GIC_FIRST_SPI; i < sc->gic_nirqs; i += GICD_I_PER_IGROUPRn) + gic_d_write(sc, 4, GICD_IGROUPR(i), 0xFFFFFFFF); + /* Set all global interrupts to be level triggered, active low. */ for (i = GIC_FIRST_SPI; i < sc->gic_nirqs; i += GICD_I_PER_ICFGRn) gic_d_write(sc, 4, GICD_ICFGR(i), 0x00000000); @@ -1206,6 +1210,10 @@ gic_v3_redist_init(struct gic_v3_softc * if (err != 0) return (err); + /* Configure SGIs and PPIs to be Group1 Non-secure */ + gic_r_write(sc, 4, GICR_SGI_BASE_SIZE + GICR_IGROUPR0, + 0xFFFFFFFF); + /* Disable SPIs */ gic_r_write(sc, 4, GICR_SGI_BASE_SIZE + GICR_ICENABLER0, GICR_I_ENABLER_PPI_MASK); Modified: head/sys/arm64/arm64/gic_v3_reg.h ============================================================================== --- head/sys/arm64/arm64/gic_v3_reg.h Sun Dec 18 05:36:04 2016 (r310203) +++ head/sys/arm64/arm64/gic_v3_reg.h Sun Dec 18 08:31:01 2016 (r310204) @@ -194,6 +194,7 @@ #define GICR_VLPI_BASE_SIZE PAGE_SIZE_64K #define GICR_RESERVED_SIZE PAGE_SIZE_64K +#define GICR_IGROUPR0 (0x0080) #define GICR_ISENABLER0 (0x0100) #define GICR_ICENABLER0 (0x0180) #define GICR_I_ENABLER_SGI_MASK (0x0000FFFF) From owner-svn-src-head@freebsd.org Sun Dec 18 09:32:24 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 81296C85541; Sun, 18 Dec 2016 09:32:24 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 50F02199F; Sun, 18 Dec 2016 09:32:24 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBI9WNFI087470; Sun, 18 Dec 2016 09:32:23 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBI9WNiE087469; Sun, 18 Dec 2016 09:32:23 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201612180932.uBI9WNiE087469@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 18 Dec 2016 09:32:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310205 - head/sys/amd64/amd64 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Sun, 18 Dec 2016 09:32:24 -0000 Author: kib Date: Sun Dec 18 09:32:23 2016 New Revision: 310205 URL: https://svnweb.freebsd.org/changeset/base/310205 Log: Fix typo. Remove spurious blank line. MFC after: 3 days Modified: head/sys/amd64/amd64/trap.c Modified: head/sys/amd64/amd64/trap.c ============================================================================== --- head/sys/amd64/amd64/trap.c Sun Dec 18 08:31:01 2016 (r310204) +++ head/sys/amd64/amd64/trap.c Sun Dec 18 09:32:23 2016 (r310205) @@ -914,7 +914,7 @@ amd64_syscall(struct thread *td, int tra } KASSERT(PCB_USER_FPU(td->td_pcb), - ("System call %s returing with kernel FPU ctx leaked", + ("System call %s returning with kernel FPU ctx leaked", syscallname(td->td_proc, sa.code))); KASSERT(td->td_pcb->pcb_save == get_pcb_user_save_td(td), ("System call %s returning with mangled pcb_save", @@ -923,7 +923,6 @@ amd64_syscall(struct thread *td, int tra ("System call %s returning with leaked invl_gen %lu", syscallname(td->td_proc, sa.code), td->td_md.md_invl_gen.gen)); - syscallret(td, error, &sa); /* From owner-svn-src-head@freebsd.org Sun Dec 18 11:15:32 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 57B7FC8681A; Sun, 18 Dec 2016 11:15:32 +0000 (UTC) (envelope-from jchandra@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 27183F68; Sun, 18 Dec 2016 11:15:32 +0000 (UTC) (envelope-from jchandra@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBIBFVI4027870; Sun, 18 Dec 2016 11:15:31 GMT (envelope-from jchandra@FreeBSD.org) Received: (from jchandra@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBIBFV3P027869; Sun, 18 Dec 2016 11:15:31 GMT (envelope-from jchandra@FreeBSD.org) Message-Id: <201612181115.uBIBFV3P027869@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jchandra set sender to jchandra@FreeBSD.org using -f From: "Jayachandran C." Date: Sun, 18 Dec 2016 11:15:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310206 - head/sys/arm64/conf X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Sun, 18 Dec 2016 11:15:32 -0000 Author: jchandra Date: Sun Dec 18 11:15:31 2016 New Revision: 310206 URL: https://svnweb.freebsd.org/changeset/base/310206 Log: Add virtio_pci to GENERIC arm64 conf virtio_pci was missing from the GENERIC arm64 configuration, while other virtio devices are present. Adding it will allow us to boot the GENERIC kernel on QEMU with virtio storage and networking. Modified: head/sys/arm64/conf/GENERIC Modified: head/sys/arm64/conf/GENERIC ============================================================================== --- head/sys/arm64/conf/GENERIC Sun Dec 18 09:32:23 2016 (r310205) +++ head/sys/arm64/conf/GENERIC Sun Dec 18 11:15:31 2016 (r310206) @@ -101,6 +101,7 @@ device al_udma # Universal DMA # VirtIO support device virtio +device virtio_pci device virtio_mmio device virtio_blk device vtnet From owner-svn-src-head@freebsd.org Sun Dec 18 13:57:26 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 59883C85271; Sun, 18 Dec 2016 13:57:26 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 32AF11F6D; Sun, 18 Dec 2016 13:57:26 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBIDvPCv095199; Sun, 18 Dec 2016 13:57:25 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBIDvOSl095186; Sun, 18 Dec 2016 13:57:24 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201612181357.uBIDvOSl095186@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Sun, 18 Dec 2016 13:57:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310225 - in head/sys/boot: common efi/loader i386/loader mips/beri/loader ofw/common pc98/loader powerpc/kboot powerpc/ps3 sparc64/loader uboot/common userboot/userboot X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Sun, 18 Dec 2016 13:57:26 -0000 Author: emaste Date: Sun Dec 18 13:57:23 2016 New Revision: 310225 URL: https://svnweb.freebsd.org/changeset/base/310225 Log: Reduce boot loader version string duplication Instead of repeating "%s, Revision %s" "(%s %s)" in each loader, just create the full version string in vers.c Reviewed by: bapt MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D8823 Modified: head/sys/boot/common/interp_forth.c head/sys/boot/common/newvers.sh head/sys/boot/efi/loader/main.c head/sys/boot/i386/loader/main.c head/sys/boot/mips/beri/loader/loader.h head/sys/boot/mips/beri/loader/main.c head/sys/boot/ofw/common/main.c head/sys/boot/pc98/loader/main.c head/sys/boot/powerpc/kboot/main.c head/sys/boot/powerpc/ps3/main.c head/sys/boot/sparc64/loader/main.c head/sys/boot/uboot/common/main.c head/sys/boot/userboot/userboot/main.c Modified: head/sys/boot/common/interp_forth.c ============================================================================== --- head/sys/boot/common/interp_forth.c Sun Dec 18 13:48:28 2016 (r310224) +++ head/sys/boot/common/interp_forth.c Sun Dec 18 13:57:23 2016 (r310225) @@ -33,7 +33,7 @@ __FBSDID("$FreeBSD$"); #include "bootstrap.h" #include "ficl.h" -extern char bootprog_rev[]; +extern unsigned bootprog_rev; /* #define BFORTH_DEBUG */ @@ -277,8 +277,7 @@ bf_init(const char *rc) /* Export some version numbers so that code can detect the loader/host version */ ficlSetEnv(bf_sys, "FreeBSD_version", __FreeBSD_version); - ficlSetEnv(bf_sys, "loader_version", - (bootprog_rev[0] - '0') * 10 + (bootprog_rev[2] - '0')); + ficlSetEnv(bf_sys, "loader_version", bootprog_rev); /* try to load and run init file if present */ if (rc == NULL) Modified: head/sys/boot/common/newvers.sh ============================================================================== --- head/sys/boot/common/newvers.sh Sun Dec 18 13:48:28 2016 (r310224) +++ head/sys/boot/common/newvers.sh Sun Dec 18 13:57:23 2016 (r310225) @@ -40,8 +40,6 @@ u=${USER-root} h=${HOSTNAME-`hostname`} #r=`head -n 6 $1 | tail -n 1 | awk -F: ' { print $1 } '` r=`awk -F: ' /^[0-9]\.[0-9]+:/ { print $1; exit }' $1` -echo "char bootprog_name[] = \"FreeBSD/${3} ${2}\";" > $tempfile -echo "char bootprog_rev[] = \"${r}\";" >> $tempfile -echo "char bootprog_date[] = \"${t}\";" >> $tempfile -echo "char bootprog_maker[] = \"${u}@${h}\";" >> $tempfile +echo "char bootprog_info[] = \"FreeBSD/${3} ${2}, Revision ${r}\\n(${t} ${u}@${h})\\n\";" > $tempfile +echo "unsigned bootprog_rev = ${r%%.*}${r##*.};" >> $tempfile mv $tempfile vers.c Modified: head/sys/boot/efi/loader/main.c ============================================================================== --- head/sys/boot/efi/loader/main.c Sun Dec 18 13:48:28 2016 (r310224) +++ head/sys/boot/efi/loader/main.c Sun Dec 18 13:57:23 2016 (r310225) @@ -50,10 +50,7 @@ __FBSDID("$FreeBSD$"); #include "loader_efi.h" -extern char bootprog_name[]; -extern char bootprog_rev[]; -extern char bootprog_date[]; -extern char bootprog_maker[]; +extern char bootprog_info[]; #ifdef BOOT_FORTH /* @@ -409,9 +406,7 @@ main(int argc, CHAR16 *argv[]) printf("EFI Firmware: %S (rev %d.%02d)\n", ST->FirmwareVendor, ST->FirmwareRevision >> 16, ST->FirmwareRevision & 0xffff); - printf("\n"); - printf("%s, Revision %s\n", bootprog_name, bootprog_rev); - printf("(%s, %s)\n", bootprog_maker, bootprog_date); + printf("\n%s", bootprog_info); /* * Disable the watchdog timer. By default the boot manager sets Modified: head/sys/boot/i386/loader/main.c ============================================================================== --- head/sys/boot/i386/loader/main.c Sun Dec 18 13:48:28 2016 (r310224) +++ head/sys/boot/i386/loader/main.c Sun Dec 18 13:57:23 2016 (r310225) @@ -77,7 +77,7 @@ static void i386_zfs_probe(void); #endif /* from vers.c */ -extern char bootprog_name[], bootprog_rev[], bootprog_date[], bootprog_maker[]; +extern char bootprog_info[]; /* XXX debugging */ extern char end[]; @@ -215,9 +215,7 @@ main(void) /* detect PCI BIOS for future reference */ biospci_detect(); - printf("\n"); - printf("%s, Revision %s\n", bootprog_name, bootprog_rev); - printf("(%s, %s)\n", bootprog_maker, bootprog_date); + printf("\n%s", bootprog_info); extract_currdev(); /* set $currdev and $loaddev */ setenv("LINES", "24", 1); /* optional */ Modified: head/sys/boot/mips/beri/loader/loader.h ============================================================================== --- head/sys/boot/mips/beri/loader/loader.h Sun Dec 18 13:48:28 2016 (r310224) +++ head/sys/boot/mips/beri/loader/loader.h Sun Dec 18 13:57:23 2016 (r310225) @@ -58,7 +58,6 @@ extern struct bootinfo boot2_bootinfo; int md_load64(char *args, vm_offset_t *modulep); /* vers.c */ -extern char bootprog_name[], bootprog_rev[]; -extern char bootprog_date[], bootprog_maker[]; +extern char bootprog_info[]; #endif /* !_BOOT_LOADER_H_ */ Modified: head/sys/boot/mips/beri/loader/main.c ============================================================================== --- head/sys/boot/mips/beri/loader/main.c Sun Dec 18 13:48:28 2016 (r310224) +++ head/sys/boot/mips/beri/loader/main.c Sun Dec 18 13:57:23 2016 (r310225) @@ -144,9 +144,7 @@ main(int argc, char *argv[], char *envv[ } extract_currdev(bootinfop); - printf("\n"); - printf("%s, Revision %s\n", bootprog_name, bootprog_rev); - printf("(%s, %s)\n", bootprog_maker, bootprog_date); + printf("\n%s", bootprog_info); #if 0 printf("bootpath=\"%s\"\n", bootpath); #endif Modified: head/sys/boot/ofw/common/main.c ============================================================================== --- head/sys/boot/ofw/common/main.c Sun Dec 18 13:48:28 2016 (r310224) +++ head/sys/boot/ofw/common/main.c Sun Dec 18 13:57:23 2016 (r310225) @@ -36,10 +36,7 @@ __FBSDID("$FreeBSD$"); struct arch_switch archsw; /* MI/MD interface boundary */ extern char end[]; -extern char bootprog_name[]; -extern char bootprog_rev[]; -extern char bootprog_date[]; -extern char bootprog_maker[]; +extern char bootprog_info[]; u_int32_t acells, scells; @@ -127,9 +124,7 @@ main(int (*openfirm)(void *)) if (devsw[i]->dv_init != NULL) (devsw[i]->dv_init)(); - printf("\n"); - printf("%s, Revision %s\n", bootprog_name, bootprog_rev); - printf("(%s, %s)\n", bootprog_maker, bootprog_date); + printf("\n%s", bootprog_info); printf("Memory: %lldKB\n", memsize() / 1024); OF_getprop(chosen, "bootpath", bootpath, 64); Modified: head/sys/boot/pc98/loader/main.c ============================================================================== --- head/sys/boot/pc98/loader/main.c Sun Dec 18 13:48:28 2016 (r310224) +++ head/sys/boot/pc98/loader/main.c Sun Dec 18 13:57:23 2016 (r310225) @@ -66,7 +66,7 @@ static void isa_outb(int port, int valu void exit(int code); /* from vers.c */ -extern char bootprog_name[], bootprog_rev[], bootprog_date[], bootprog_maker[]; +extern char bootprog_info[]; /* XXX debugging */ extern char end[]; @@ -186,9 +186,7 @@ main(void) initial_bootinfo->bi_extmem = bios_extmem / 1024; } - printf("\n"); - printf("%s, Revision %s\n", bootprog_name, bootprog_rev); - printf("(%s, %s)\n", bootprog_maker, bootprog_date); + printf("\n%s", bootprog_info); extract_currdev(); /* set $currdev and $loaddev */ setenv("LINES", "24", 1); /* optional */ Modified: head/sys/boot/powerpc/kboot/main.c ============================================================================== --- head/sys/boot/powerpc/kboot/main.c Sun Dec 18 13:48:28 2016 (r310224) +++ head/sys/boot/powerpc/kboot/main.c Sun Dec 18 13:57:23 2016 (r310225) @@ -38,10 +38,7 @@ __FBSDID("$FreeBSD$"); struct arch_switch archsw; extern void *_end; -extern char bootprog_name[]; -extern char bootprog_rev[]; -extern char bootprog_date[]; -extern char bootprog_maker[]; +extern char bootprog_info[]; int kboot_getdev(void **vdev, const char *devspec, const char **path); ssize_t kboot_copyin(const void *src, vm_offset_t dest, const size_t len); @@ -119,9 +116,7 @@ main(int argc, const char **argv) archsw.arch_autoload = kboot_autoload; archsw.arch_loadaddr = kboot_loadaddr; - printf("\n"); - printf("%s, Revision %s\n", bootprog_name, bootprog_rev); - printf("(%s, %s)\n", bootprog_maker, bootprog_date); + printf("\n%s", bootprog_info); setenv("currdev", bootdev, 1); setenv("loaddev", bootdev, 1); Modified: head/sys/boot/powerpc/ps3/main.c ============================================================================== --- head/sys/boot/powerpc/ps3/main.c Sun Dec 18 13:48:28 2016 (r310224) +++ head/sys/boot/powerpc/ps3/main.c Sun Dec 18 13:57:23 2016 (r310225) @@ -41,10 +41,7 @@ __FBSDID("$FreeBSD$"); struct arch_switch archsw; extern void *_end; -extern char bootprog_name[]; -extern char bootprog_rev[]; -extern char bootprog_date[]; -extern char bootprog_maker[]; +extern char bootprog_info[]; int ps3_getdev(void **vdev, const char *devspec, const char **path); ssize_t ps3_copyin(const void *src, vm_offset_t dest, const size_t len); @@ -133,9 +130,7 @@ main(void) archsw.arch_readin = ps3_readin; archsw.arch_autoload = ps3_autoload; - printf("\n"); - printf("%s, Revision %s\n", bootprog_name, bootprog_rev); - printf("(%s, %s)\n", bootprog_maker, bootprog_date); + printf("\n%s", bootprog_info); printf("Memory: %lldKB\n", maxmem / 1024); env_setenv("currdev", EV_VOLATILE, ps3_fmtdev(&currdev), Modified: head/sys/boot/sparc64/loader/main.c ============================================================================== --- head/sys/boot/sparc64/loader/main.c Sun Dec 18 13:48:28 2016 (r310224) +++ head/sys/boot/sparc64/loader/main.c Sun Dec 18 13:57:23 2016 (r310225) @@ -75,7 +75,7 @@ __FBSDID("$FreeBSD$"); #include "libofw.h" #include "dev_net.h" -extern char bootprog_name[], bootprog_rev[], bootprog_date[], bootprog_maker[]; +extern char bootprog_info[]; enum { HEAPVA = 0x800000, @@ -891,9 +891,7 @@ main(int (*openfirm)(void *)) env_setenv("loaddev", EV_VOLATILE, bootpath, env_noset, env_nounset); - printf("\n"); - printf("%s, Revision %s\n", bootprog_name, bootprog_rev); - printf("(%s, %s)\n", bootprog_maker, bootprog_date); + printf("\n%s", bootprog_info); printf("bootpath=\"%s\"\n", bootpath); /* Give control to the machine independent loader code. */ Modified: head/sys/boot/uboot/common/main.c ============================================================================== --- head/sys/boot/uboot/common/main.c Sun Dec 18 13:48:28 2016 (r310224) +++ head/sys/boot/uboot/common/main.c Sun Dec 18 13:57:23 2016 (r310225) @@ -62,10 +62,7 @@ struct device_type { }; extern char end[]; -extern char bootprog_name[]; -extern char bootprog_rev[]; -extern char bootprog_date[]; -extern char bootprog_maker[]; +extern char bootprog_info[]; extern unsigned char _etext[]; extern unsigned char _edata[]; @@ -431,9 +428,7 @@ main(int argc, char **argv) cons_probe(); printf("Compatible U-Boot API signature found @%p\n", sig); - printf("\n"); - printf("%s, Revision %s\n", bootprog_name, bootprog_rev); - printf("(%s, %s)\n", bootprog_maker, bootprog_date); + printf("\n%s", bootprog_info); printf("\n"); dump_sig(sig); Modified: head/sys/boot/userboot/userboot/main.c ============================================================================== --- head/sys/boot/userboot/userboot/main.c Sun Dec 18 13:48:28 2016 (r310224) +++ head/sys/boot/userboot/userboot/main.c Sun Dec 18 13:57:23 2016 (r310225) @@ -51,10 +51,7 @@ static int userboot_zfs_found; struct loader_callbacks *callbacks; void *callbacks_arg; -extern char bootprog_name[]; -extern char bootprog_rev[]; -extern char bootprog_date[]; -extern char bootprog_maker[]; +extern char bootprog_info[]; static jmp_buf jb; struct arch_switch archsw; /* MI/MD interface boundary */ @@ -101,9 +98,7 @@ loader_main(struct loader_callbacks *cb, */ cons_probe(); - printf("\n"); - printf("%s, Revision %s\n", bootprog_name, bootprog_rev); - printf("(%s, %s)\n", bootprog_maker, bootprog_date); + printf("\n%s", bootprog_info); #if 0 printf("Memory: %ld k\n", memsize() / 1024); #endif From owner-svn-src-head@freebsd.org Sun Dec 18 14:04:18 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6F455C85561; Sun, 18 Dec 2016 14:04:18 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 3ECC66A3; Sun, 18 Dec 2016 14:04:18 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBIE4H7N099363; Sun, 18 Dec 2016 14:04:17 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBIE4HlC099362; Sun, 18 Dec 2016 14:04:17 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201612181404.uBIE4HlC099362@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sun, 18 Dec 2016 14:04:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310226 - head/tools/tools/locale X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Sun, 18 Dec 2016 14:04:18 -0000 Author: bapt Date: Sun Dec 18 14:04:17 2016 New Revision: 310226 URL: https://svnweb.freebsd.org/changeset/base/310226 Log: Disable timedef generation, cldr data are too far from freebsd extensions Modified: head/tools/tools/locale/Makefile Modified: head/tools/tools/locale/Makefile ============================================================================== --- head/tools/tools/locale/Makefile Sun Dec 18 13:57:23 2016 (r310225) +++ head/tools/tools/locale/Makefile Sun Dec 18 14:04:17 2016 (r310226) @@ -18,7 +18,7 @@ PASSON= CLDRDIR="${CLDRDIR}" UNIDATADIR ETCDIR= ${.CURDIR}/etc -KNOWN= monetdef numericdef msgdef timedef colldef ctypedef +KNOWN= monetdef numericdef msgdef colldef ctypedef # timedef TYPES?= ${KNOWN} LOCALE_DESTDIR?= /tmp/generated-locales/ From owner-svn-src-head@freebsd.org Sun Dec 18 14:10:26 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 05344C85765; Sun, 18 Dec 2016 14:10:26 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 C8C6198C; Sun, 18 Dec 2016 14:10:25 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBIEAOCN099629; Sun, 18 Dec 2016 14:10:24 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBIEAORg099628; Sun, 18 Dec 2016 14:10:24 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201612181410.uBIEAORg099628@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sun, 18 Dec 2016 14:10:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310227 - head/tools/tools/locale X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Sun, 18 Dec 2016 14:10:26 -0000 Author: bapt Date: Sun Dec 18 14:10:24 2016 New Revision: 310227 URL: https://svnweb.freebsd.org/changeset/base/310227 Log: Document the fact that cldr tools are not working by default and should be rebuilt Modified: head/tools/tools/locale/README Modified: head/tools/tools/locale/README ============================================================================== --- head/tools/tools/locale/README Sun Dec 18 14:04:17 2016 (r310226) +++ head/tools/tools/locale/README Sun Dec 18 14:10:24 2016 (r310227) @@ -6,13 +6,18 @@ Tools needed: java, perl, devel/p5-Tie-I textproc/p5-XML-Parser fetch cldr data from: http://cldr.unicode.org -extract in a directory ~/unicode/cldr/v27.0.1 for example +extract in a directory ~/unicode/cldr/v30.0.3 for example fetch unidata from http://www.unicode.org/Public/zipped/ (latest version) -extract in a directory ~/unicode/UNIDATA/8.0.0 for example +extract in a directory ~/unicode/UNIDATA/9.0.0 for example + +Note that the prebuilt cldr tools are not working on freebsd, it needs to +be rebuilt: +cd $CLDRDIR/tools/java +ant build either modify tools/tools/locales/etc/unicode.conf or export variables: -CLDRDIR="~/unicode/cldr/v27.0.1" -UNIDATADIR="~/unicode/UNIDATA/8.0.0" +CLDRDIR="~/unicode/cldr/v30.0.3" +UNIDATADIR="~/unicode/UNIDATA/9.0.0" run: make POSIX From owner-svn-src-head@freebsd.org Sun Dec 18 14:54:23 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6238FC879C0; Sun, 18 Dec 2016 14:54:23 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 2349CD49; Sun, 18 Dec 2016 14:54:23 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBIEsMRX019616; Sun, 18 Dec 2016 14:54:22 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBIEsKkd019602; Sun, 18 Dec 2016 14:54:20 GMT (envelope-from manu@FreeBSD.org) Message-Id: <201612181454.uBIEsKkd019602@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Sun, 18 Dec 2016 14:54:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310229 - in head/sys: arm/at91 arm/broadcom/bcm2835 arm/freescale/vybrid arm/lpc arm/samsung/exynos arm/ti dev/spibus dev/xilinx mips/atheros mips/atheros/ar531x mips/mediatek mips/rt305x X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Sun, 18 Dec 2016 14:54:23 -0000 Author: manu Date: Sun Dec 18 14:54:20 2016 New Revision: 310229 URL: https://svnweb.freebsd.org/changeset/base/310229 Log: ofw_spi: Parse property for the SPI mode and CS polarity. As cs is stored in a uint32_t, use the last bit to store the active high flag as it's unlikely that we will have that much CS. Reviewed by: loos MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D8614 Modified: head/sys/arm/at91/at91_spi.c head/sys/arm/broadcom/bcm2835/bcm2835_spi.c head/sys/arm/freescale/vybrid/vf_spi.c head/sys/arm/lpc/lpc_spi.c head/sys/arm/samsung/exynos/exynos5_spi.c head/sys/arm/ti/ti_spi.c head/sys/dev/spibus/ofw_spibus.c head/sys/dev/spibus/spibusvar.h head/sys/dev/xilinx/axi_quad_spi.c head/sys/mips/atheros/ar531x/ar5315_spi.c head/sys/mips/atheros/ar71xx_spi.c head/sys/mips/mediatek/mtk_spi_v1.c head/sys/mips/mediatek/mtk_spi_v2.c head/sys/mips/rt305x/rt305x_spi.c Modified: head/sys/arm/at91/at91_spi.c ============================================================================== --- head/sys/arm/at91/at91_spi.c Sun Dec 18 14:31:11 2016 (r310228) +++ head/sys/arm/at91/at91_spi.c Sun Dec 18 14:54:20 2016 (r310229) @@ -301,6 +301,8 @@ at91_spi_transfer(device_t dev, device_t /* get the proper chip select */ spibus_get_cs(child, &cs); + cs &= ~SPIBUS_CS_HIGH; + sc = device_get_softc(dev); i = 0; Modified: head/sys/arm/broadcom/bcm2835/bcm2835_spi.c ============================================================================== --- head/sys/arm/broadcom/bcm2835/bcm2835_spi.c Sun Dec 18 14:31:11 2016 (r310228) +++ head/sys/arm/broadcom/bcm2835/bcm2835_spi.c Sun Dec 18 14:54:20 2016 (r310229) @@ -433,6 +433,9 @@ bcm_spi_transfer(device_t dev, device_t /* Get the proper chip select for this child. */ spibus_get_cs(child, &cs); + + cs &= ~SPIBUS_CS_HIGH; + if (cs > 2) { device_printf(dev, "Invalid chip select %d requested by %s\n", cs, Modified: head/sys/arm/freescale/vybrid/vf_spi.c ============================================================================== --- head/sys/arm/freescale/vybrid/vf_spi.c Sun Dec 18 14:31:11 2016 (r310228) +++ head/sys/arm/freescale/vybrid/vf_spi.c Sun Dec 18 14:54:20 2016 (r310229) @@ -262,6 +262,8 @@ spi_transfer(device_t dev, device_t chil /* get the proper chip select */ spibus_get_cs(child, &cs); + cs &= ~SPIBUS_CS_HIGH; + /* Command */ spi_txrx(sc, cmd->tx_cmd, cmd->rx_cmd, cmd->tx_cmd_sz, cs); Modified: head/sys/arm/lpc/lpc_spi.c ============================================================================== --- head/sys/arm/lpc/lpc_spi.c Sun Dec 18 14:31:11 2016 (r310228) +++ head/sys/arm/lpc/lpc_spi.c Sun Dec 18 14:54:20 2016 (r310229) @@ -147,6 +147,8 @@ lpc_spi_transfer(device_t dev, device_t spibus_get_cs(child, &cs); + cs &= ~SPIBUS_CS_HIGH; + /* Set CS active */ lpc_gpio_set_state(child, cs, 0); Modified: head/sys/arm/samsung/exynos/exynos5_spi.c ============================================================================== --- head/sys/arm/samsung/exynos/exynos5_spi.c Sun Dec 18 14:31:11 2016 (r310228) +++ head/sys/arm/samsung/exynos/exynos5_spi.c Sun Dec 18 14:54:20 2016 (r310229) @@ -204,6 +204,8 @@ spi_transfer(device_t dev, device_t chil /* get the proper chip select */ spibus_get_cs(child, &cs); + cs &= ~SPIBUS_CS_HIGH; + /* Command */ spi_txrx(sc, cmd->tx_cmd, cmd->rx_cmd, cmd->tx_cmd_sz, cs); Modified: head/sys/arm/ti/ti_spi.c ============================================================================== --- head/sys/arm/ti/ti_spi.c Sun Dec 18 14:31:11 2016 (r310228) +++ head/sys/arm/ti/ti_spi.c Sun Dec 18 14:54:20 2016 (r310229) @@ -457,6 +457,9 @@ ti_spi_transfer(device_t dev, device_t c /* Get the proper chip select for this child. */ spibus_get_cs(child, &cs); + + cs &= ~SPIBUS_CS_HIGH; + if (cs > sc->sc_numcs) { device_printf(dev, "Invalid chip select %d requested by %s\n", cs, device_get_nameunit(child)); Modified: head/sys/dev/spibus/ofw_spibus.c ============================================================================== --- head/sys/dev/spibus/ofw_spibus.c Sun Dec 18 14:31:11 2016 (r310228) +++ head/sys/dev/spibus/ofw_spibus.c Sun Dec 18 14:54:20 2016 (r310229) @@ -80,6 +80,7 @@ ofw_spibus_attach(device_t dev) phandle_t child; pcell_t clock, paddr; device_t childdev; + uint32_t mode = SPIBUS_MODE_NONE; sc->dev = dev; @@ -103,6 +104,24 @@ ofw_spibus_attach(device_t dev) } /* + * Try to get the cpol/cpha mode + */ + if (OF_hasprop(child, "spi-cpol")) + mode = SPIBUS_MODE_CPOL; + if (OF_hasprop(child, "spi-cpha")) { + if (mode == SPIBUS_MODE_CPOL) + mode = SPIBUS_MODE_CPOL_CPHA; + else + mode = SPIBUS_MODE_CPHA; + } + + /* + * Try to get the CS polarity + */ + if (OF_hasprop(child, "spi-cs-high")) + paddr |= SPIBUS_CS_HIGH; + + /* * Get the maximum clock frequency for device, zero means * use the default bus speed. */ @@ -120,6 +139,7 @@ ofw_spibus_attach(device_t dev) continue; dinfo->opd_dinfo.cs = paddr; dinfo->opd_dinfo.clock = clock; + dinfo->opd_dinfo.mode = mode; if (ofw_bus_gen_setup_devinfo(&dinfo->opd_obdinfo, child) != 0) { free(dinfo, M_DEVBUF); Modified: head/sys/dev/spibus/spibusvar.h ============================================================================== --- head/sys/dev/spibus/spibusvar.h Sun Dec 18 14:31:11 2016 (r310228) +++ head/sys/dev/spibus/spibusvar.h Sun Dec 18 14:54:20 2016 (r310229) @@ -46,6 +46,8 @@ struct spibus_ivar uint32_t clock; }; +#define SPIBUS_CS_HIGH (1U << 31) + enum { SPIBUS_IVAR_CS, /* chip select that we're on */ SPIBUS_IVAR_MODE, /* SPI mode (0-3) */ Modified: head/sys/dev/xilinx/axi_quad_spi.c ============================================================================== --- head/sys/dev/xilinx/axi_quad_spi.c Sun Dec 18 14:31:11 2016 (r310228) +++ head/sys/dev/xilinx/axi_quad_spi.c Sun Dec 18 14:54:20 2016 (r310229) @@ -193,6 +193,8 @@ spi_transfer(device_t dev, device_t chil /* get the proper chip select */ spibus_get_cs(child, &cs); + cs &= ~SPIBUS_CS_HIGH; + /* Assert CS */ reg = READ4(sc, SPI_SSR); reg &= ~(1 << cs); Modified: head/sys/mips/atheros/ar531x/ar5315_spi.c ============================================================================== --- head/sys/mips/atheros/ar531x/ar5315_spi.c Sun Dec 18 14:31:11 2016 (r310228) +++ head/sys/mips/atheros/ar531x/ar5315_spi.c Sun Dec 18 14:54:20 2016 (r310229) @@ -166,6 +166,8 @@ ar5315_spi_transfer(device_t dev, device spibus_get_cs(child, &cs); + cs &= ~SPIBUS_CS_HIGH; + /* Open SPI controller interface */ ar5315_spi_chip_activate(sc, cs); Modified: head/sys/mips/atheros/ar71xx_spi.c ============================================================================== --- head/sys/mips/atheros/ar71xx_spi.c Sun Dec 18 14:31:11 2016 (r310228) +++ head/sys/mips/atheros/ar71xx_spi.c Sun Dec 18 14:54:20 2016 (r310229) @@ -212,6 +212,8 @@ ar71xx_spi_transfer(device_t dev, device spibus_get_cs(child, &cs); + cs &= ~SPIBUS_CS_HIGH; + ar71xx_spi_chip_activate(sc, cs); KASSERT(cmd->tx_cmd_sz == cmd->rx_cmd_sz, Modified: head/sys/mips/mediatek/mtk_spi_v1.c ============================================================================== --- head/sys/mips/mediatek/mtk_spi_v1.c Sun Dec 18 14:31:11 2016 (r310228) +++ head/sys/mips/mediatek/mtk_spi_v1.c Sun Dec 18 14:54:20 2016 (r310229) @@ -231,6 +231,8 @@ mtk_spi_transfer(device_t dev, device_t spibus_get_cs(child, &cs); + cs &= ~SPIBUS_CS_HIGH; + if (cs != 0) /* Only 1 CS */ return (ENXIO); Modified: head/sys/mips/mediatek/mtk_spi_v2.c ============================================================================== --- head/sys/mips/mediatek/mtk_spi_v2.c Sun Dec 18 14:31:11 2016 (r310228) +++ head/sys/mips/mediatek/mtk_spi_v2.c Sun Dec 18 14:54:20 2016 (r310229) @@ -236,6 +236,8 @@ mtk_spi_transfer(device_t dev, device_t spibus_get_cs(child, &cs); + cs &= ~SPIBUS_CS_HIGH; + if (cs != 0) /* Only 1 CS */ return (ENXIO); Modified: head/sys/mips/rt305x/rt305x_spi.c ============================================================================== --- head/sys/mips/rt305x/rt305x_spi.c Sun Dec 18 14:31:11 2016 (r310228) +++ head/sys/mips/rt305x/rt305x_spi.c Sun Dec 18 14:54:20 2016 (r310229) @@ -226,6 +226,8 @@ rt305x_spi_transfer(device_t dev, device spibus_get_cs(child, &cs); + cs &= ~SPIBUS_CS_HIGH; + if (cs != 0) /* Only 1 CS */ return (ENXIO); From owner-svn-src-head@freebsd.org Sun Dec 18 15:02:51 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6D8D3C87D6B; Sun, 18 Dec 2016 15:02:51 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 35E1C1396; Sun, 18 Dec 2016 15:02:51 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBIF2o3g023449; Sun, 18 Dec 2016 15:02:50 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBIF2o4a023448; Sun, 18 Dec 2016 15:02:50 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201612181502.uBIF2o4a023448@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sun, 18 Dec 2016 15:02:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310230 - head/sys/cam/scsi X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Sun, 18 Dec 2016 15:02:51 -0000 Author: mav Date: Sun Dec 18 15:02:50 2016 New Revision: 310230 URL: https://svnweb.freebsd.org/changeset/base/310230 Log: Don't treat informational exceptions (warnings and impending failures) a.k.a. SCSI SMART events as errors. Log them to console and continue. MFC after: 2 weeks Modified: head/sys/cam/scsi/scsi_all.c Modified: head/sys/cam/scsi/scsi_all.c ============================================================================== --- head/sys/cam/scsi/scsi_all.c Sun Dec 18 14:54:20 2016 (r310229) +++ head/sys/cam/scsi/scsi_all.c Sun Dec 18 15:02:50 2016 (r310230) @@ -1233,58 +1233,58 @@ static struct asc_table_entry asc_table[ { SST(0x0A, 0x00, SS_FATAL | ENOSPC, "Error log overflow") }, /* DTLPWROMAEBKVF */ - { SST(0x0B, 0x00, SS_RDEF, + { SST(0x0B, 0x00, SS_NOP | SSQ_PRINT_SENSE, "Warning") }, /* DTLPWROMAEBKVF */ - { SST(0x0B, 0x01, SS_RDEF, + { SST(0x0B, 0x01, SS_NOP | SSQ_PRINT_SENSE, "Warning - specified temperature exceeded") }, /* DTLPWROMAEBKVF */ - { SST(0x0B, 0x02, SS_RDEF, + { SST(0x0B, 0x02, SS_NOP | SSQ_PRINT_SENSE, "Warning - enclosure degraded") }, /* DTLPWROMAEBKVF */ - { SST(0x0B, 0x03, SS_RDEF, /* XXX TBD */ + { SST(0x0B, 0x03, SS_NOP | SSQ_PRINT_SENSE, "Warning - background self-test failed") }, /* DTLPWRO AEBKVF */ - { SST(0x0B, 0x04, SS_RDEF, /* XXX TBD */ + { SST(0x0B, 0x04, SS_NOP | SSQ_PRINT_SENSE, "Warning - background pre-scan detected medium error") }, /* DTLPWRO AEBKVF */ - { SST(0x0B, 0x05, SS_RDEF, /* XXX TBD */ + { SST(0x0B, 0x05, SS_NOP | SSQ_PRINT_SENSE, "Warning - background medium scan detected medium error") }, /* DTLPWROMAEBKVF */ - { SST(0x0B, 0x06, SS_RDEF, /* XXX TBD */ + { SST(0x0B, 0x06, SS_NOP | SSQ_PRINT_SENSE, "Warning - non-volatile cache now volatile") }, /* DTLPWROMAEBKVF */ - { SST(0x0B, 0x07, SS_RDEF, /* XXX TBD */ + { SST(0x0B, 0x07, SS_NOP | SSQ_PRINT_SENSE, "Warning - degraded power to non-volatile cache") }, /* DTLPWROMAEBKVF */ - { SST(0x0B, 0x08, SS_RDEF, /* XXX TBD */ + { SST(0x0B, 0x08, SS_NOP | SSQ_PRINT_SENSE, "Warning - power loss expected") }, /* D */ - { SST(0x0B, 0x09, SS_RDEF, /* XXX TBD */ + { SST(0x0B, 0x09, SS_NOP | SSQ_PRINT_SENSE, "Warning - device statistics notification available") }, /* DTLPWROMAEBKVF */ - { SST(0x0B, 0x0A, SS_RDEF, /* XXX TBD */ + { SST(0x0B, 0x0A, SS_NOP | SSQ_PRINT_SENSE, "Warning - High critical temperature limit exceeded") }, /* DTLPWROMAEBKVF */ - { SST(0x0B, 0x0B, SS_RDEF, /* XXX TBD */ + { SST(0x0B, 0x0B, SS_NOP | SSQ_PRINT_SENSE, "Warning - Low critical temperature limit exceeded") }, /* DTLPWROMAEBKVF */ - { SST(0x0B, 0x0C, SS_RDEF, /* XXX TBD */ + { SST(0x0B, 0x0C, SS_NOP | SSQ_PRINT_SENSE, "Warning - High operating temperature limit exceeded") }, /* DTLPWROMAEBKVF */ - { SST(0x0B, 0x0D, SS_RDEF, /* XXX TBD */ + { SST(0x0B, 0x0D, SS_NOP | SSQ_PRINT_SENSE, "Warning - Low operating temperature limit exceeded") }, /* DTLPWROMAEBKVF */ - { SST(0x0B, 0x0E, SS_RDEF, /* XXX TBD */ + { SST(0x0B, 0x0E, SS_NOP | SSQ_PRINT_SENSE, "Warning - High citical humidity limit exceeded") }, /* DTLPWROMAEBKVF */ - { SST(0x0B, 0x0F, SS_RDEF, /* XXX TBD */ + { SST(0x0B, 0x0F, SS_NOP | SSQ_PRINT_SENSE, "Warning - Low citical humidity limit exceeded") }, /* DTLPWROMAEBKVF */ - { SST(0x0B, 0x10, SS_RDEF, /* XXX TBD */ + { SST(0x0B, 0x10, SS_NOP | SSQ_PRINT_SENSE, "Warning - High operating humidity limit exceeded") }, /* DTLPWROMAEBKVF */ - { SST(0x0B, 0x11, SS_RDEF, /* XXX TBD */ + { SST(0x0B, 0x11, SS_NOP | SSQ_PRINT_SENSE, "Warning - Low operating humidity limit exceeded") }, /* T R */ { SST(0x0C, 0x00, SS_RDEF, @@ -2613,253 +2613,259 @@ static struct asc_table_entry asc_table[ { SST(0x5C, 0x02, SS_RDEF, "Spindles not synchronized") }, /* DTLPWROMAEBKVF */ - { SST(0x5D, 0x00, SS_RDEF, + { SST(0x5D, 0x00, SS_NOP | SSQ_PRINT_SENSE, "Failure prediction threshold exceeded") }, /* R B */ - { SST(0x5D, 0x01, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x01, SS_NOP | SSQ_PRINT_SENSE, "Media failure prediction threshold exceeded") }, /* R */ - { SST(0x5D, 0x02, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x02, SS_NOP | SSQ_PRINT_SENSE, "Logical unit failure prediction threshold exceeded") }, /* R */ - { SST(0x5D, 0x03, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x03, SS_NOP | SSQ_PRINT_SENSE, "Spare area exhaustion prediction threshold exceeded") }, /* D B */ - { SST(0x5D, 0x10, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x10, SS_NOP | SSQ_PRINT_SENSE, "Hardware impending failure general hard drive failure") }, /* D B */ - { SST(0x5D, 0x11, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x11, SS_NOP | SSQ_PRINT_SENSE, "Hardware impending failure drive error rate too high") }, /* D B */ - { SST(0x5D, 0x12, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x12, SS_NOP | SSQ_PRINT_SENSE, "Hardware impending failure data error rate too high") }, /* D B */ - { SST(0x5D, 0x13, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x13, SS_NOP | SSQ_PRINT_SENSE, "Hardware impending failure seek error rate too high") }, /* D B */ - { SST(0x5D, 0x14, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x14, SS_NOP | SSQ_PRINT_SENSE, "Hardware impending failure too many block reassigns") }, /* D B */ - { SST(0x5D, 0x15, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x15, SS_NOP | SSQ_PRINT_SENSE, "Hardware impending failure access times too high") }, /* D B */ - { SST(0x5D, 0x16, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x16, SS_NOP | SSQ_PRINT_SENSE, "Hardware impending failure start unit times too high") }, /* D B */ - { SST(0x5D, 0x17, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x17, SS_NOP | SSQ_PRINT_SENSE, "Hardware impending failure channel parametrics") }, /* D B */ - { SST(0x5D, 0x18, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x18, SS_NOP | SSQ_PRINT_SENSE, "Hardware impending failure controller detected") }, /* D B */ - { SST(0x5D, 0x19, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x19, SS_NOP | SSQ_PRINT_SENSE, "Hardware impending failure throughput performance") }, /* D B */ - { SST(0x5D, 0x1A, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x1A, SS_NOP | SSQ_PRINT_SENSE, "Hardware impending failure seek time performance") }, /* D B */ - { SST(0x5D, 0x1B, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x1B, SS_NOP | SSQ_PRINT_SENSE, "Hardware impending failure spin-up retry count") }, /* D B */ - { SST(0x5D, 0x1C, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x1C, SS_NOP | SSQ_PRINT_SENSE, "Hardware impending failure drive calibration retry count") }, /* D B */ - { SST(0x5D, 0x20, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x1D, SS_NOP | SSQ_PRINT_SENSE, + "Hardware impending failure power loss protection circuit") }, + /* D B */ + { SST(0x5D, 0x20, SS_NOP | SSQ_PRINT_SENSE, "Controller impending failure general hard drive failure") }, /* D B */ - { SST(0x5D, 0x21, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x21, SS_NOP | SSQ_PRINT_SENSE, "Controller impending failure drive error rate too high") }, /* D B */ - { SST(0x5D, 0x22, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x22, SS_NOP | SSQ_PRINT_SENSE, "Controller impending failure data error rate too high") }, /* D B */ - { SST(0x5D, 0x23, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x23, SS_NOP | SSQ_PRINT_SENSE, "Controller impending failure seek error rate too high") }, /* D B */ - { SST(0x5D, 0x24, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x24, SS_NOP | SSQ_PRINT_SENSE, "Controller impending failure too many block reassigns") }, /* D B */ - { SST(0x5D, 0x25, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x25, SS_NOP | SSQ_PRINT_SENSE, "Controller impending failure access times too high") }, /* D B */ - { SST(0x5D, 0x26, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x26, SS_NOP | SSQ_PRINT_SENSE, "Controller impending failure start unit times too high") }, /* D B */ - { SST(0x5D, 0x27, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x27, SS_NOP | SSQ_PRINT_SENSE, "Controller impending failure channel parametrics") }, /* D B */ - { SST(0x5D, 0x28, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x28, SS_NOP | SSQ_PRINT_SENSE, "Controller impending failure controller detected") }, /* D B */ - { SST(0x5D, 0x29, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x29, SS_NOP | SSQ_PRINT_SENSE, "Controller impending failure throughput performance") }, /* D B */ - { SST(0x5D, 0x2A, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x2A, SS_NOP | SSQ_PRINT_SENSE, "Controller impending failure seek time performance") }, /* D B */ - { SST(0x5D, 0x2B, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x2B, SS_NOP | SSQ_PRINT_SENSE, "Controller impending failure spin-up retry count") }, /* D B */ - { SST(0x5D, 0x2C, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x2C, SS_NOP | SSQ_PRINT_SENSE, "Controller impending failure drive calibration retry count") }, /* D B */ - { SST(0x5D, 0x30, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x30, SS_NOP | SSQ_PRINT_SENSE, "Data channel impending failure general hard drive failure") }, /* D B */ - { SST(0x5D, 0x31, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x31, SS_NOP | SSQ_PRINT_SENSE, "Data channel impending failure drive error rate too high") }, /* D B */ - { SST(0x5D, 0x32, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x32, SS_NOP | SSQ_PRINT_SENSE, "Data channel impending failure data error rate too high") }, /* D B */ - { SST(0x5D, 0x33, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x33, SS_NOP | SSQ_PRINT_SENSE, "Data channel impending failure seek error rate too high") }, /* D B */ - { SST(0x5D, 0x34, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x34, SS_NOP | SSQ_PRINT_SENSE, "Data channel impending failure too many block reassigns") }, /* D B */ - { SST(0x5D, 0x35, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x35, SS_NOP | SSQ_PRINT_SENSE, "Data channel impending failure access times too high") }, /* D B */ - { SST(0x5D, 0x36, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x36, SS_NOP | SSQ_PRINT_SENSE, "Data channel impending failure start unit times too high") }, /* D B */ - { SST(0x5D, 0x37, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x37, SS_NOP | SSQ_PRINT_SENSE, "Data channel impending failure channel parametrics") }, /* D B */ - { SST(0x5D, 0x38, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x38, SS_NOP | SSQ_PRINT_SENSE, "Data channel impending failure controller detected") }, /* D B */ - { SST(0x5D, 0x39, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x39, SS_NOP | SSQ_PRINT_SENSE, "Data channel impending failure throughput performance") }, /* D B */ - { SST(0x5D, 0x3A, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x3A, SS_NOP | SSQ_PRINT_SENSE, "Data channel impending failure seek time performance") }, /* D B */ - { SST(0x5D, 0x3B, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x3B, SS_NOP | SSQ_PRINT_SENSE, "Data channel impending failure spin-up retry count") }, /* D B */ - { SST(0x5D, 0x3C, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x3C, SS_NOP | SSQ_PRINT_SENSE, "Data channel impending failure drive calibration retry count") }, /* D B */ - { SST(0x5D, 0x40, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x40, SS_NOP | SSQ_PRINT_SENSE, "Servo impending failure general hard drive failure") }, /* D B */ - { SST(0x5D, 0x41, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x41, SS_NOP | SSQ_PRINT_SENSE, "Servo impending failure drive error rate too high") }, /* D B */ - { SST(0x5D, 0x42, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x42, SS_NOP | SSQ_PRINT_SENSE, "Servo impending failure data error rate too high") }, /* D B */ - { SST(0x5D, 0x43, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x43, SS_NOP | SSQ_PRINT_SENSE, "Servo impending failure seek error rate too high") }, /* D B */ - { SST(0x5D, 0x44, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x44, SS_NOP | SSQ_PRINT_SENSE, "Servo impending failure too many block reassigns") }, /* D B */ - { SST(0x5D, 0x45, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x45, SS_NOP | SSQ_PRINT_SENSE, "Servo impending failure access times too high") }, /* D B */ - { SST(0x5D, 0x46, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x46, SS_NOP | SSQ_PRINT_SENSE, "Servo impending failure start unit times too high") }, /* D B */ - { SST(0x5D, 0x47, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x47, SS_NOP | SSQ_PRINT_SENSE, "Servo impending failure channel parametrics") }, /* D B */ - { SST(0x5D, 0x48, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x48, SS_NOP | SSQ_PRINT_SENSE, "Servo impending failure controller detected") }, /* D B */ - { SST(0x5D, 0x49, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x49, SS_NOP | SSQ_PRINT_SENSE, "Servo impending failure throughput performance") }, /* D B */ - { SST(0x5D, 0x4A, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x4A, SS_NOP | SSQ_PRINT_SENSE, "Servo impending failure seek time performance") }, /* D B */ - { SST(0x5D, 0x4B, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x4B, SS_NOP | SSQ_PRINT_SENSE, "Servo impending failure spin-up retry count") }, /* D B */ - { SST(0x5D, 0x4C, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x4C, SS_NOP | SSQ_PRINT_SENSE, "Servo impending failure drive calibration retry count") }, /* D B */ - { SST(0x5D, 0x50, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x50, SS_NOP | SSQ_PRINT_SENSE, "Spindle impending failure general hard drive failure") }, /* D B */ - { SST(0x5D, 0x51, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x51, SS_NOP | SSQ_PRINT_SENSE, "Spindle impending failure drive error rate too high") }, /* D B */ - { SST(0x5D, 0x52, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x52, SS_NOP | SSQ_PRINT_SENSE, "Spindle impending failure data error rate too high") }, /* D B */ - { SST(0x5D, 0x53, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x53, SS_NOP | SSQ_PRINT_SENSE, "Spindle impending failure seek error rate too high") }, /* D B */ - { SST(0x5D, 0x54, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x54, SS_NOP | SSQ_PRINT_SENSE, "Spindle impending failure too many block reassigns") }, /* D B */ - { SST(0x5D, 0x55, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x55, SS_NOP | SSQ_PRINT_SENSE, "Spindle impending failure access times too high") }, /* D B */ - { SST(0x5D, 0x56, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x56, SS_NOP | SSQ_PRINT_SENSE, "Spindle impending failure start unit times too high") }, /* D B */ - { SST(0x5D, 0x57, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x57, SS_NOP | SSQ_PRINT_SENSE, "Spindle impending failure channel parametrics") }, /* D B */ - { SST(0x5D, 0x58, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x58, SS_NOP | SSQ_PRINT_SENSE, "Spindle impending failure controller detected") }, /* D B */ - { SST(0x5D, 0x59, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x59, SS_NOP | SSQ_PRINT_SENSE, "Spindle impending failure throughput performance") }, /* D B */ - { SST(0x5D, 0x5A, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x5A, SS_NOP | SSQ_PRINT_SENSE, "Spindle impending failure seek time performance") }, /* D B */ - { SST(0x5D, 0x5B, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x5B, SS_NOP | SSQ_PRINT_SENSE, "Spindle impending failure spin-up retry count") }, /* D B */ - { SST(0x5D, 0x5C, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x5C, SS_NOP | SSQ_PRINT_SENSE, "Spindle impending failure drive calibration retry count") }, /* D B */ - { SST(0x5D, 0x60, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x60, SS_NOP | SSQ_PRINT_SENSE, "Firmware impending failure general hard drive failure") }, /* D B */ - { SST(0x5D, 0x61, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x61, SS_NOP | SSQ_PRINT_SENSE, "Firmware impending failure drive error rate too high") }, /* D B */ - { SST(0x5D, 0x62, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x62, SS_NOP | SSQ_PRINT_SENSE, "Firmware impending failure data error rate too high") }, /* D B */ - { SST(0x5D, 0x63, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x63, SS_NOP | SSQ_PRINT_SENSE, "Firmware impending failure seek error rate too high") }, /* D B */ - { SST(0x5D, 0x64, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x64, SS_NOP | SSQ_PRINT_SENSE, "Firmware impending failure too many block reassigns") }, /* D B */ - { SST(0x5D, 0x65, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x65, SS_NOP | SSQ_PRINT_SENSE, "Firmware impending failure access times too high") }, /* D B */ - { SST(0x5D, 0x66, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x66, SS_NOP | SSQ_PRINT_SENSE, "Firmware impending failure start unit times too high") }, /* D B */ - { SST(0x5D, 0x67, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x67, SS_NOP | SSQ_PRINT_SENSE, "Firmware impending failure channel parametrics") }, /* D B */ - { SST(0x5D, 0x68, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x68, SS_NOP | SSQ_PRINT_SENSE, "Firmware impending failure controller detected") }, /* D B */ - { SST(0x5D, 0x69, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x69, SS_NOP | SSQ_PRINT_SENSE, "Firmware impending failure throughput performance") }, /* D B */ - { SST(0x5D, 0x6A, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x6A, SS_NOP | SSQ_PRINT_SENSE, "Firmware impending failure seek time performance") }, /* D B */ - { SST(0x5D, 0x6B, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x6B, SS_NOP | SSQ_PRINT_SENSE, "Firmware impending failure spin-up retry count") }, /* D B */ - { SST(0x5D, 0x6C, SS_RDEF, /* XXX TBD */ + { SST(0x5D, 0x6C, SS_NOP | SSQ_PRINT_SENSE, "Firmware impending failure drive calibration retry count") }, + /* D B */ + { SST(0x5D, 0x73, SS_NOP | SSQ_PRINT_SENSE, + "Media impending failure endurance limit met") }, /* DTLPWROMAEBKVF */ - { SST(0x5D, 0xFF, SS_RDEF, + { SST(0x5D, 0xFF, SS_NOP | SSQ_PRINT_SENSE, "Failure prediction threshold exceeded (false)") }, /* DTLPWRO A K */ { SST(0x5E, 0x00, SS_RDEF, From owner-svn-src-head@freebsd.org Sun Dec 18 15:21:39 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9E2DDC865DC; Sun, 18 Dec 2016 15:21:39 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 6AFF137F; Sun, 18 Dec 2016 15:21:39 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBIFLc0k030384; Sun, 18 Dec 2016 15:21:38 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBIFLcB3030383; Sun, 18 Dec 2016 15:21:38 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201612181521.uBIFLcB3030383@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Sun, 18 Dec 2016 15:21:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310232 - head/sys/dev/mlx4/mlx4_ib X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Sun, 18 Dec 2016 15:21:39 -0000 Author: dim Date: Sun Dec 18 15:21:38 2016 New Revision: 310232 URL: https://svnweb.freebsd.org/changeset/base/310232 Log: After r310171, the kernel version of sscanf() has format string checking enabled. This results in a -Werror warning in mlx4ib: sys/dev/mlx4/mlx4_ib/mlx4_ib_sysfs.c:90:22: error: format specifies type 'unsigned long long *' but the argument has type 'u64 *' (aka 'unsigned long *') [-Werror,-Wformat] sscanf(buf, "%llx", &sysadmin_ag_val); ~~~~ ^~~~~~~~~~~~~~~~ Change sysadmin_ag_val to unsigned long long to avoid the warning. Reviewed by: hselasky MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D8831 Modified: head/sys/dev/mlx4/mlx4_ib/mlx4_ib_sysfs.c Modified: head/sys/dev/mlx4/mlx4_ib/mlx4_ib_sysfs.c ============================================================================== --- head/sys/dev/mlx4/mlx4_ib/mlx4_ib_sysfs.c Sun Dec 18 15:10:08 2016 (r310231) +++ head/sys/dev/mlx4/mlx4_ib/mlx4_ib_sysfs.c Sun Dec 18 15:21:38 2016 (r310232) @@ -79,7 +79,7 @@ static ssize_t store_admin_alias_guid(st container_of(attr, struct mlx4_ib_iov_sysfs_attr, dentry); struct mlx4_ib_iov_port *port = mlx4_ib_iov_dentry->ctx; struct mlx4_ib_dev *mdev = port->dev; - u64 sysadmin_ag_val; + unsigned long long sysadmin_ag_val; record_num = mlx4_ib_iov_dentry->entry_num / 8; guid_index_in_rec = mlx4_ib_iov_dentry->entry_num % 8; From owner-svn-src-head@freebsd.org Sun Dec 18 16:37:58 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 52E60C875A9 for ; Sun, 18 Dec 2016 16:37:58 +0000 (UTC) (envelope-from ed@nuxi.nl) Received: from mail-yb0-x22d.google.com (mail-yb0-x22d.google.com [IPv6:2607:f8b0:4002:c09::22d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1CD201479 for ; Sun, 18 Dec 2016 16:37:57 +0000 (UTC) (envelope-from ed@nuxi.nl) Received: by mail-yb0-x22d.google.com with SMTP id v132so51758889yba.0 for ; Sun, 18 Dec 2016 08:37:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuxi-nl.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=V9VPVfZ2/rS2BlPLwsEc2Kj12IW23+dGaopDD6ExIJU=; b=DfzHuFIj5hOE/Xpcd1O/oeRFEB2KuwHWzf7tJ8BOukxYzWF1n785kVDxaO2denZxEA 2C3K/6M1UjbPvV9N3n4mUoD/fOQz9cawuNrXoBYPnv5tNsyQHBsicUSn+g8xqcwmRPeo 9dZTLeBEibccE3n7cScDkZzNGZmcQh6ZRJO+yb03Nbqf/4AyJD1+EG5nYerqkAbJAz7i c7Shcu08GMw254twkXaQ9ME/9dkZImnEnFRP61WBDbTGfhnYDWMMgIzpADOHuE/Ei2M4 gdzd6uC713EXk70thYTvdvDOuGixtJ1FDg38GucD7yxkXi1vunTHEjvbNFjVe4cC22r1 EQBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=V9VPVfZ2/rS2BlPLwsEc2Kj12IW23+dGaopDD6ExIJU=; b=EiPbG+lENODcYpvEFUpnQzzuf8xAgjHRwvA5k2UoC/cw/5gdM2LKqnOJoWLPIKziii 8N7Rgrfx2xIO6y4cjXiQfm3a3LyoEJIsrTHKYTQiG+EsS3m8NhtfVnw+OpIgjuxglafT ivLkCP9QE+Tla/NWveDjAcCdvQjSFqS1t9xJlBELjMp1iNndm83HKPCLosNNNbV1SlUq 6hvFjDXOuD+jI7bkJgU/sQT0uRRI1V92aLFlyNffgZGj5UnyGae5QnzL3N7HSyuZUCXu QCQZIKCOkai52jibvSpFOaWbvinG6jO3THJPuw8GeN8eooDQ6u+M1w8q2kHTpLgD6X7q 0PJA== X-Gm-Message-State: AIkVDXKezeeMcrRJghQshPlgglkIdlW8No8maOOByEzh0JALZHkKtgVvH6lBBWkB4F/P4UD0jyuJr7oV6tqpyA== X-Received: by 10.37.163.33 with SMTP id d30mr2300ybi.54.1482079077048; Sun, 18 Dec 2016 08:37:57 -0800 (PST) MIME-Version: 1.0 Received: by 10.129.2.139 with HTTP; Sun, 18 Dec 2016 08:37:26 -0800 (PST) In-Reply-To: <201612181521.uBIFLcB3030383@repo.freebsd.org> References: <201612181521.uBIFLcB3030383@repo.freebsd.org> From: Ed Schouten Date: Sun, 18 Dec 2016 17:37:26 +0100 Message-ID: Subject: Re: svn commit: r310232 - head/sys/dev/mlx4/mlx4_ib To: Dimitry Andric Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Sun, 18 Dec 2016 16:37:58 -0000 2016-12-18 16:21 GMT+01:00 Dimitry Andric : > Modified: head/sys/dev/mlx4/mlx4_ib/mlx4_ib_sysfs.c > ============================================================================== > --- head/sys/dev/mlx4/mlx4_ib/mlx4_ib_sysfs.c Sun Dec 18 15:10:08 2016 (r310231) > +++ head/sys/dev/mlx4/mlx4_ib/mlx4_ib_sysfs.c Sun Dec 18 15:21:38 2016 (r310232) > @@ -79,7 +79,7 @@ static ssize_t store_admin_alias_guid(st > container_of(attr, struct mlx4_ib_iov_sysfs_attr, dentry); > struct mlx4_ib_iov_port *port = mlx4_ib_iov_dentry->ctx; > struct mlx4_ib_dev *mdev = port->dev; > - u64 sysadmin_ag_val; > + unsigned long long sysadmin_ag_val; > > record_num = mlx4_ib_iov_dentry->entry_num / 8; > guid_index_in_rec = mlx4_ib_iov_dentry->entry_num % 8; Looking at the code, the intent is that an actual 64-bit integer is parsed; not an unsigned long long. What's wrong with using inttypes.h's SCNx64? -- Ed Schouten Nuxi, 's-Hertogenbosch, the Netherlands KvK-nr.: 62051717 From owner-svn-src-head@freebsd.org Sun Dec 18 16:49:23 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F1FE1C87952; Sun, 18 Dec 2016 16:49:22 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from tensor.andric.com (tensor.andric.com [IPv6:2001:7b8:3a7:1:2d0:b7ff:fea0:8c26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "tensor.andric.com", Issuer "COMODO RSA Domain Validation Secure Server CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id BA439910; Sun, 18 Dec 2016 16:49:22 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from [IPv6:2001:7b8:3a7::584d:b4f3:ff81:8b6c] (unknown [IPv6:2001:7b8:3a7:0:584d:b4f3:ff81:8b6c]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id A97D53F4D3; Sun, 18 Dec 2016 17:49:19 +0100 (CET) Content-Type: multipart/signed; boundary="Apple-Mail=_9BFE0C23-B76B-4587-880F-2EE1087660E7"; protocol="application/pgp-signature"; micalg=pgp-sha1 Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Subject: Re: svn commit: r310232 - head/sys/dev/mlx4/mlx4_ib From: Dimitry Andric In-Reply-To: Date: Sun, 18 Dec 2016 17:49:07 +0100 Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Message-Id: References: <201612181521.uBIFLcB3030383@repo.freebsd.org> To: Ed Schouten X-Mailer: Apple Mail (2.3124) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Sun, 18 Dec 2016 16:49:23 -0000 --Apple-Mail=_9BFE0C23-B76B-4587-880F-2EE1087660E7 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii On 18 Dec 2016, at 17:37, Ed Schouten wrote: >=20 > 2016-12-18 16:21 GMT+01:00 Dimitry Andric : >> Modified: head/sys/dev/mlx4/mlx4_ib/mlx4_ib_sysfs.c >> = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=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/dev/mlx4/mlx4_ib/mlx4_ib_sysfs.c Sun Dec 18 15:10:08 = 2016 (r310231) >> +++ head/sys/dev/mlx4/mlx4_ib/mlx4_ib_sysfs.c Sun Dec 18 15:21:38 = 2016 (r310232) >> @@ -79,7 +79,7 @@ static ssize_t store_admin_alias_guid(st >> container_of(attr, struct mlx4_ib_iov_sysfs_attr, = dentry); >> struct mlx4_ib_iov_port *port =3D mlx4_ib_iov_dentry->ctx; >> struct mlx4_ib_dev *mdev =3D port->dev; >> - u64 sysadmin_ag_val; >> + unsigned long long sysadmin_ag_val; >>=20 >> record_num =3D mlx4_ib_iov_dentry->entry_num / 8; >> guid_index_in_rec =3D mlx4_ib_iov_dentry->entry_num % 8; >=20 > Looking at the code, the intent is that an actual 64-bit integer is > parsed; not an unsigned long long. What's wrong with using > inttypes.h's SCNx64? That is how I originally submitted it in the review, though with , as it is most often used in kernel sources. However, see Hans's comment in the review here: https://reviews.freebsd.org/D8831#182872 I don't mind either way. -Dimitry --Apple-Mail=_9BFE0C23-B76B-4587-880F-2EE1087660E7 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.30 iEYEARECAAYFAlhWvg8ACgkQsF6jCi4glqNdGACgqVHhTleeOATnuSWQbK+kIaE0 ti8AoJhwK0REdVCFsAEzsQ1v+GFsWJ5z =WPK8 -----END PGP SIGNATURE----- --Apple-Mail=_9BFE0C23-B76B-4587-880F-2EE1087660E7-- From owner-svn-src-head@freebsd.org Sun Dec 18 20:56:16 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 07C0CC87AED; Sun, 18 Dec 2016 20:56:16 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 B022110CD; Sun, 18 Dec 2016 20:56:15 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBIKuEYD070796; Sun, 18 Dec 2016 20:56:14 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBIKuElT070792; Sun, 18 Dec 2016 20:56:14 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201612182056.uBIKuElT070792@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 18 Dec 2016 20:56:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310234 - head/sys/vm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Sun, 18 Dec 2016 20:56:16 -0000 Author: kib Date: Sun Dec 18 20:56:14 2016 New Revision: 310234 URL: https://svnweb.freebsd.org/changeset/base/310234 Log: Improve vm_object_scan_all_shadowed() to also check swap backing objects. As noted in the removed comment, it is possible and not prohibitively costly to look up the swap blocks for the given page index. Implement a swap_pager_find_least() function to do that, and use it to iterate simultaneously over both backing object page queue and swap allocations when looking for shadowed pages. Testing shows that number of new succesful scans, enabled by this addition, is small but non-zero. When worked out, the change both further reduces the depth of the shadow object chain, and frees unused but allocated swap and memory. Suggested and reviewed by: alc Tested by: pho (previous version) Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Modified: head/sys/vm/swap_pager.c head/sys/vm/swap_pager.h head/sys/vm/vm_object.c Modified: head/sys/vm/swap_pager.c ============================================================================== --- head/sys/vm/swap_pager.c Sun Dec 18 20:40:22 2016 (r310233) +++ head/sys/vm/swap_pager.c Sun Dec 18 20:56:14 2016 (r310234) @@ -2013,6 +2013,44 @@ swp_pager_meta_ctl(vm_object_t object, v } /* + * Returns the least page index which is greater than or equal to the + * parameter pindex and for which there is a swap block allocated. + * Returns object's size if the object's type is not swap or if there + * are no allocated swap blocks for the object after the requested + * pindex. + */ +vm_pindex_t +swap_pager_find_least(vm_object_t object, vm_pindex_t pindex) +{ + struct swblock **pswap, *swap; + vm_pindex_t i, j, lim; + int idx; + + VM_OBJECT_ASSERT_LOCKED(object); + if (object->type != OBJT_SWAP || object->un_pager.swp.swp_bcount == 0) + return (object->size); + + mtx_lock(&swhash_mtx); + for (j = pindex; j < object->size; j = lim) { + pswap = swp_pager_hash(object, j); + lim = rounddown2(j + SWAP_META_PAGES, SWAP_META_PAGES); + if (lim > object->size) + lim = object->size; + if ((swap = *pswap) != NULL) { + for (idx = j & SWAP_META_MASK, i = j; i < lim; + i++, idx++) { + if (swap->swb_pages[idx] != SWAPBLK_NONE) + goto found; + } + } + } + i = object->size; +found: + mtx_unlock(&swhash_mtx); + return (i); +} + +/* * System call swapon(name) enables swapping on device name, * which must be in the swdevsw. Return EBUSY * if already swapping on this device. Modified: head/sys/vm/swap_pager.h ============================================================================== --- head/sys/vm/swap_pager.h Sun Dec 18 20:40:22 2016 (r310233) +++ head/sys/vm/swap_pager.h Sun Dec 18 20:56:14 2016 (r310234) @@ -79,6 +79,7 @@ extern int swap_pager_avail; struct xswdev; int swap_dev_info(int name, struct xswdev *xs, char *devname, size_t len); void swap_pager_copy(vm_object_t, vm_object_t, vm_pindex_t, int); +vm_pindex_t swap_pager_find_least(vm_object_t object, vm_pindex_t pindex); void swap_pager_freespace(vm_object_t, vm_pindex_t, vm_size_t); void swap_pager_swap_init(void); int swap_pager_isswapped(vm_object_t, struct swdevt *); Modified: head/sys/vm/vm_object.c ============================================================================== --- head/sys/vm/vm_object.c Sun Dec 18 20:40:22 2016 (r310233) +++ head/sys/vm/vm_object.c Sun Dec 18 20:56:14 2016 (r310234) @@ -1436,36 +1436,40 @@ vm_object_scan_all_shadowed(vm_object_t { vm_object_t backing_object; vm_page_t p, pp; - vm_pindex_t backing_offset_index, new_pindex; + vm_pindex_t backing_offset_index, new_pindex, pi, ps; VM_OBJECT_ASSERT_WLOCKED(object); VM_OBJECT_ASSERT_WLOCKED(object->backing_object); backing_object = object->backing_object; - /* - * Initial conditions: - * - * We do not want to have to test for the existence of swap - * pages in the backing object. XXX but with the new swapper this - * would be pretty easy to do. - */ - if (backing_object->type != OBJT_DEFAULT) + if (backing_object->type != OBJT_DEFAULT && + backing_object->type != OBJT_SWAP) return (false); - backing_offset_index = OFF_TO_IDX(object->backing_object_offset); + pi = backing_offset_index = OFF_TO_IDX(object->backing_object_offset); + p = vm_page_find_least(backing_object, pi); + ps = swap_pager_find_least(backing_object, pi); - for (p = TAILQ_FIRST(&backing_object->memq); p != NULL; - p = TAILQ_NEXT(p, listq)) { - new_pindex = p->pindex - backing_offset_index; + /* + * Only check pages inside the parent object's range and + * inside the parent object's mapping of the backing object. + */ + for (;; pi++) { + if (p != NULL && p->pindex < pi) + p = TAILQ_NEXT(p, listq); + if (ps < pi) + ps = swap_pager_find_least(backing_object, pi); + if (p == NULL && ps >= backing_object->size) + break; + else if (p == NULL) + pi = ps; + else + pi = MIN(p->pindex, ps); - /* - * Ignore pages outside the parent object's range and outside - * the parent object's mapping of the backing object. - */ - if (p->pindex < backing_offset_index || - new_pindex >= object->size) - continue; + new_pindex = pi - backing_offset_index; + if (new_pindex >= object->size) + break; /* * See if the parent has the page or if the parent's object From owner-svn-src-head@freebsd.org Sun Dec 18 22:24:05 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3E424C875C7; Sun, 18 Dec 2016 22:24:05 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 0D4671D28; Sun, 18 Dec 2016 22:24:04 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBIMO4Ij007342; Sun, 18 Dec 2016 22:24:04 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBIMO41Z007341; Sun, 18 Dec 2016 22:24:04 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201612182224.uBIMO41Z007341@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Sun, 18 Dec 2016 22:24:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310236 - head/sys/boot/common X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Sun, 18 Dec 2016 22:24:05 -0000 Author: emaste Date: Sun Dec 18 22:24:04 2016 New Revision: 310236 URL: https://svnweb.freebsd.org/changeset/base/310236 Log: Renumber license clauses to avoid skipping #3 Modified: head/sys/boot/common/newvers.sh Modified: head/sys/boot/common/newvers.sh ============================================================================== --- head/sys/boot/common/newvers.sh Sun Dec 18 20:59:24 2016 (r310235) +++ head/sys/boot/common/newvers.sh Sun Dec 18 22:24:04 2016 (r310236) @@ -14,7 +14,7 @@ # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# 4. Neither the name of the University nor the names of its contributors +# 3. Neither the name of the University nor the names of its contributors # may be used to endorse or promote products derived from this software # without specific prior written permission. # From owner-svn-src-head@freebsd.org Mon Dec 19 07:02:59 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EFC37C878AE; Mon, 19 Dec 2016 07:02:59 +0000 (UTC) (envelope-from sepherosa@gmail.com) Received: from mail-vk0-x243.google.com (mail-vk0-x243.google.com [IPv6:2607:f8b0:400c:c05::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id AF67D6DE; Mon, 19 Dec 2016 07:02:59 +0000 (UTC) (envelope-from sepherosa@gmail.com) Received: by mail-vk0-x243.google.com with SMTP id l126so12871025vkh.0; Sun, 18 Dec 2016 23:02:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=A3+z2/uJNRMi8lw6ufAyvTNiBxWxdGMoLLxYsD8hR2s=; b=VnAz8k//4fado4WOKz7b3d+XrcrNTvsrzRV0YOrVHVgleM5ljiGXEv2h7wR0Gz4Ee5 AdeCXaejS7wzaBQ5yuc+NovOq0qbQeyuMCcYsFbB3f5w3MwEVItQuDDbAyIe8J/IT35/ LqBrlkbF47u29iOFXIrJG/8AdDapEdKIztAMk3dsQSa/Q6xj0ANSlgkvD8Ol1xG81iSQ aV0ZUj8VzjJe1pQzEU22HDbJobzkn3MAg1C5izSKzpt/qoXV3p3w265CSPsjtecdppQr 55hnPS9I4SyvQewMipec09ixmq6oJ/1EJTFs86+Nfk5i8ClBiLK4mc1qkVKQigUkxycb DAKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=A3+z2/uJNRMi8lw6ufAyvTNiBxWxdGMoLLxYsD8hR2s=; b=tTUpifyG3/XPmfTME7WxjIM365KBr1r6dFtetilIjaMbcXw9hlkeSg/3CtO8xiqjtx I66wJl8mHCEqKGxv7MOq1KFllET2rrn9pK8VDTbAvV3ac8/+0I3iDeCJ/LVLBAq7eeOx +RYOgTIjZ/Iyp/p+CmDcpmAbX4QfegBexUsk4Xki5z9epYxuue4DHalfxNEv0iCpXUhR Zv4kfs7NzFDAushLvWXzbGe6ykpb2CSNFA1nwAFFAZevys2HvpRcCQxct80Q916XgYaL +88lNrtZsxVnA0tlvlhglahPIOLv8smp2QC8JaqjNkiOczcoBth5E2xpiOa0azB6iGKv j82A== X-Gm-Message-State: AIkVDXIaXWAlKB/ykvGMyD+juApfro7qAE/6k3vtVIC26smIu/1qDsTX/hVyTTDznE4Yd4yptUXEcMwySWv+GA== X-Received: by 10.31.168.7 with SMTP id r7mr5320361vke.148.1482130978422; Sun, 18 Dec 2016 23:02:58 -0800 (PST) MIME-Version: 1.0 Received: by 10.176.5.198 with HTTP; Sun, 18 Dec 2016 23:02:57 -0800 (PST) In-Reply-To: <201612161949.uBGJnMol059217@repo.freebsd.org> References: <201612161949.uBGJnMol059217@repo.freebsd.org> From: Sepherosa Ziehau Date: Mon, 19 Dec 2016 15:02:57 +0800 Message-ID: Subject: Re: svn commit: r310171 - head/sys/sys To: Dimitry Andric Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 07:03:00 -0000 The following patch unbreaks the LINT builds on amd64 for me after this commit: https://people.freebsd.org/~sephe/geom_sscanf.diff Please review it. Thanks, sephe On Sat, Dec 17, 2016 at 3:49 AM, Dimitry Andric wrote: > Author: dim > Date: Fri Dec 16 19:49:22 2016 > New Revision: 310171 > URL: https://svnweb.freebsd.org/changeset/base/310171 > > Log: > Add __scanflike attributes to the kernel's sscanf() and vsscanf() > declarations. This should help to catch future mismatches between > format strings and arguments. > > MFC after: 1 week > > Modified: > head/sys/sys/systm.h > > Modified: head/sys/sys/systm.h > ============================================================================== > --- head/sys/sys/systm.h Fri Dec 16 19:09:57 2016 (r310170) > +++ head/sys/sys/systm.h Fri Dec 16 19:49:22 2016 (r310171) > @@ -227,8 +227,8 @@ int vsnprintf(char *, size_t, const char > int vsnrprintf(char *, size_t, int, const char *, __va_list) __printflike(4, 0); > int vsprintf(char *buf, const char *, __va_list) __printflike(2, 0); > int ttyprintf(struct tty *, const char *, ...) __printflike(2, 3); > -int sscanf(const char *, char const *, ...) __nonnull(1) __nonnull(2); > -int vsscanf(const char *, char const *, __va_list) __nonnull(1) __nonnull(2); > +int sscanf(const char *, char const *, ...) __nonnull(1) __nonnull(2) __scanflike(2, 3); > +int vsscanf(const char *, char const *, __va_list) __nonnull(1) __nonnull(2) __scanflike(2, 0); > long strtol(const char *, char **, int) __nonnull(1); > u_long strtoul(const char *, char **, int) __nonnull(1); > quad_t strtoq(const char *, char **, int) __nonnull(1); > _______________________________________________ > svn-src-all@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/svn-src-all > To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org" -- Tomorrow Will Never Die From owner-svn-src-head@freebsd.org Mon Dec 19 07:40:47 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7171BC871DD; Mon, 19 Dec 2016 07:40:47 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 3211C1C94; Mon, 19 Dec 2016 07:40:47 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBJ7ektI034656; Mon, 19 Dec 2016 07:40:46 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBJ7ekkY034652; Mon, 19 Dec 2016 07:40:46 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201612190740.uBJ7ekkY034652@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 19 Dec 2016 07:40:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310239 - in head: lib/libc/x86/sys sys/dev/hyperv/vmbus/amd64 sys/sys sys/x86/include X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 07:40:47 -0000 Author: sephe Date: Mon Dec 19 07:40:45 2016 New Revision: 310239 URL: https://svnweb.freebsd.org/changeset/base/310239 Log: hyperv: Implement userspace gettimeofday(2) with Hyper-V reference TSC This 6 times gettimeofday performance, as measured by tools/tools/syscall_timing Reviewed by: kib MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8789 Modified: head/lib/libc/x86/sys/__vdso_gettc.c head/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c head/sys/sys/vdso.h head/sys/x86/include/vdso.h Modified: head/lib/libc/x86/sys/__vdso_gettc.c ============================================================================== --- head/lib/libc/x86/sys/__vdso_gettc.c Mon Dec 19 00:28:04 2016 (r310238) +++ head/lib/libc/x86/sys/__vdso_gettc.c Mon Dec 19 07:40:45 2016 (r310239) @@ -45,6 +45,10 @@ __FBSDID("$FreeBSD$"); #include #include #include +#ifdef __amd64__ +#include +#include +#endif #include "libc_private.h" static void @@ -144,6 +148,67 @@ __vdso_init_hpet(uint32_t u) _close(fd); } +#ifdef __amd64__ + +#define HYPERV_REFTSC_DEVPATH "/dev/" HYPERV_REFTSC_DEVNAME + +/* + * NOTE: + * We use 'NULL' for this variable to indicate that initialization + * is required. And if this variable is 'MAP_FAILED', then Hyper-V + * reference TSC can not be used, e.g. in misconfigured jail. + */ +static struct hyperv_reftsc *hyperv_ref_tsc; + +static void +__vdso_init_hyperv_tsc(void) +{ + int fd; + + fd = _open(HYPERV_REFTSC_DEVPATH, O_RDONLY); + if (fd < 0) { + /* Prevent the caller from re-entering. */ + hyperv_ref_tsc = MAP_FAILED; + return; + } + hyperv_ref_tsc = mmap(NULL, sizeof(*hyperv_ref_tsc), PROT_READ, + MAP_SHARED, fd, 0); + _close(fd); +} + +static int +__vdso_hyperv_tsc(struct hyperv_reftsc *tsc_ref, u_int *tc) +{ + uint64_t disc, ret, tsc, scale; + uint32_t seq; + int64_t ofs; + + while ((seq = atomic_load_acq_int(&tsc_ref->tsc_seq)) != 0) { + scale = tsc_ref->tsc_scale; + ofs = tsc_ref->tsc_ofs; + + lfence_mb(); + tsc = rdtsc(); + + /* ret = ((tsc * scale) >> 64) + ofs */ + __asm__ __volatile__ ("mulq %3" : + "=d" (ret), "=a" (disc) : + "a" (tsc), "r" (scale)); + ret += ofs; + + atomic_thread_fence_acq(); + if (tsc_ref->tsc_seq == seq) { + *tc = ret; + return (0); + } + + /* Sequence changed; re-sync. */ + } + return (ENOSYS); +} + +#endif /* __amd64__ */ + #pragma weak __vdso_gettc int __vdso_gettc(const struct vdso_timehands *th, u_int *tc) @@ -165,6 +230,14 @@ __vdso_gettc(const struct vdso_timehands return (ENOSYS); *tc = *(volatile uint32_t *)(hpet_dev_map + HPET_MAIN_COUNTER); return (0); +#ifdef __amd64__ + case VDSO_TH_ALGO_X86_HVTSC: + if (hyperv_ref_tsc == NULL) + __vdso_init_hyperv_tsc(); + if (hyperv_ref_tsc == MAP_FAILED) + return (ENOSYS); + return (__vdso_hyperv_tsc(hyperv_ref_tsc, tc)); +#endif default: return (ENOSYS); } Modified: head/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c ============================================================================== --- head/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c Mon Dec 19 00:28:04 2016 (r310238) +++ head/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c Mon Dec 19 07:40:45 2016 (r310239) @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -52,18 +53,20 @@ struct hyperv_reftsc_ctx { struct hyperv_dma tsc_ref_dma; }; +static uint32_t hyperv_tsc_vdso_timehands( + struct vdso_timehands *, + struct timecounter *); + static d_open_t hyperv_tsc_open; static d_mmap_t hyperv_tsc_mmap; static struct timecounter hyperv_tsc_timecounter = { .tc_get_timecount = NULL, /* based on CPU vendor. */ - .tc_poll_pps = NULL, .tc_counter_mask = 0xffffffff, .tc_frequency = HYPERV_TIMER_FREQ, .tc_name = "Hyper-V-TSC", .tc_quality = 3000, - .tc_flags = 0, - .tc_priv = NULL + .tc_fill_vdso_timehands = hyperv_tsc_vdso_timehands, }; static struct cdevsw hyperv_tsc_cdevsw = { @@ -117,6 +120,18 @@ hyperv_tsc_mmap(struct cdev *dev __unuse return (0); } +static uint32_t +hyperv_tsc_vdso_timehands(struct vdso_timehands *vdso_th, + struct timecounter *tc __unused) +{ + + vdso_th->th_algo = VDSO_TH_ALGO_X86_HVTSC; + vdso_th->th_x86_shift = 0; + vdso_th->th_x86_hpet_idx = 0; + bzero(vdso_th->th_res, sizeof(vdso_th->th_res)); + return (1); +} + #define HYPERV_TSC_TIMECOUNT(fence) \ static u_int \ hyperv_tsc_timecount_##fence(struct timecounter *tc) \ Modified: head/sys/sys/vdso.h ============================================================================== --- head/sys/sys/vdso.h Mon Dec 19 00:28:04 2016 (r310238) +++ head/sys/sys/vdso.h Mon Dec 19 07:40:45 2016 (r310239) @@ -54,6 +54,8 @@ struct vdso_timekeep { #define VDSO_TK_VER_CURR VDSO_TK_VER_1 #define VDSO_TH_ALGO_1 0x1 #define VDSO_TH_ALGO_2 0x2 +#define VDSO_TH_ALGO_3 0x3 +#define VDSO_TH_ALGO_4 0x4 #ifndef _KERNEL Modified: head/sys/x86/include/vdso.h ============================================================================== --- head/sys/x86/include/vdso.h Mon Dec 19 00:28:04 2016 (r310238) +++ head/sys/x86/include/vdso.h Mon Dec 19 07:40:45 2016 (r310239) @@ -39,6 +39,7 @@ #define VDSO_TH_ALGO_X86_TSC VDSO_TH_ALGO_1 #define VDSO_TH_ALGO_X86_HPET VDSO_TH_ALGO_2 +#define VDSO_TH_ALGO_X86_HVTSC VDSO_TH_ALGO_3 /* Hyper-V ref. TSC */ #ifdef _KERNEL #ifdef COMPAT_FREEBSD32 From owner-svn-src-head@freebsd.org Mon Dec 19 09:28:14 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5C34DC86271; Mon, 19 Dec 2016 09:28:14 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 131E0AE1; Mon, 19 Dec 2016 09:28:14 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBJ9SDnS078378; Mon, 19 Dec 2016 09:28:13 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBJ9SDFc078376; Mon, 19 Dec 2016 09:28:13 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201612190928.uBJ9SDFc078376@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 19 Dec 2016 09:28:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310242 - head/sys/dev/usb X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 09:28:14 -0000 Author: hselasky Date: Mon Dec 19 09:28:12 2016 New Revision: 310242 URL: https://svnweb.freebsd.org/changeset/base/310242 Log: Defer USB enumeration until the SI_SUB_KICK_SCHEDULER is executed to avoid boot panics in conjunction with the recently added EARLY_AP_STARTUP feature. The panics happen due to using kernel facilities like callouts too early. Tested by: jhb @ MFC after: 1 week Modified: head/sys/dev/usb/usb_hub.c head/sys/dev/usb/usb_process.c Modified: head/sys/dev/usb/usb_hub.c ============================================================================== --- head/sys/dev/usb/usb_hub.c Mon Dec 19 07:48:04 2016 (r310241) +++ head/sys/dev/usb/usb_hub.c Mon Dec 19 09:28:12 2016 (r310242) @@ -2261,6 +2261,11 @@ usb_needs_explore(struct usb_bus *bus, u DPRINTF("\n"); + if (cold != 0) { + DPRINTF("Cold\n"); + return; + } + if (bus == NULL) { DPRINTF("No bus pointer!\n"); return; @@ -2326,6 +2331,26 @@ usb_needs_explore_all(void) } /*------------------------------------------------------------------------* + * usb_needs_explore_init + * + * This function will ensure that the USB controllers are not enumerated + * until the "cold" variable is cleared. + *------------------------------------------------------------------------*/ +static void +usb_needs_explore_init(void *arg) +{ + /* + * The cold variable should be cleared prior to this function + * being called: + */ + if (cold == 0) + usb_needs_explore_all(); + else + DPRINTFN(-1, "Cold variable is still set!\n"); +} +SYSINIT(usb_needs_explore_init, SI_SUB_KICK_SCHEDULER, SI_ORDER_SECOND, usb_needs_explore_init, NULL); + +/*------------------------------------------------------------------------* * usb_bus_power_update * * This function will ensure that all USB devices on the given bus are Modified: head/sys/dev/usb/usb_process.c ============================================================================== --- head/sys/dev/usb/usb_process.c Mon Dec 19 07:48:04 2016 (r310241) +++ head/sys/dev/usb/usb_process.c Mon Dec 19 09:28:12 2016 (r310242) @@ -455,14 +455,15 @@ usb_proc_drain(struct usb_process *up) up->up_csleep = 0; cv_signal(&up->up_cv); } +#ifndef EARLY_AP_STARTUP /* Check if we are still cold booted */ - if (cold) { USB_THREAD_SUSPEND(up->up_ptr); printf("WARNING: A USB process has " "been left suspended\n"); break; } +#endif cv_wait(&up->up_cv, up->up_mtx); } /* Check if someone is waiting - should not happen */ From owner-svn-src-head@freebsd.org Mon Dec 19 09:40:12 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2A464C8661F; Mon, 19 Dec 2016 09:40:12 +0000 (UTC) (envelope-from rpokala@mac.com) Received: from mr11p00im-asmtp003.me.com (mr11p00im-asmtp003.me.com [17.110.69.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0EC5012CD; Mon, 19 Dec 2016 09:40:12 +0000 (UTC) (envelope-from rpokala@mac.com) Received: from process-dkim-sign-daemon.mr11p00im-asmtp003.me.com by mr11p00im-asmtp003.me.com (Oracle Communications Messaging Server 7.0.5.38.0 64bit (built Feb 26 2016)) id <0OIF00300BWVNJ00@mr11p00im-asmtp003.me.com>; Mon, 19 Dec 2016 08:39:56 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mac.com; s=4d515a; t=1482136796; bh=MtVuqjl3AT7wgrtdIY0AEZjpCpyxf57iyFl24/W5b3k=; h=Date:Subject:From:To:Message-id:MIME-version:Content-type; b=lPs8JhtXLqRyuDUNwtV4d4AMN1H2KYOQX16lvlOas/R5Ejjdgrf97wF2T7tb0tLan nEudVgJq0+Mrhdt+P4t/gngjK0zYJbGFufD8TXdcvQ98dZtWL9YGQo12VvcAZU0WKV jK7ybFX+sDfPL+LxFN3Nx0wLhEnOOrcZnfa7537VfcE69ccdl5F2ZZAJr3yoixPkyZ cVYkVB6xEyqDHQw2a2F+cgv0PgGNUBiSoOYSHTnCzAhqGg56DZ9pgJm1kTLBcYRjGY YkBkt+bukYo9DUhwBo2QCJNGdn1fPWr7R9QqFUCGZCdEimCH26mEQDzar0Ca4d/elo /BMXcFUBolQ6g== Received: from [192.168.1.4] (c-67-188-225-23.hsd1.ca.comcast.net [67.188.225.23]) by mr11p00im-asmtp003.me.com (Oracle Communications Messaging Server 7.0.5.38.0 64bit (built Feb 26 2016)) with ESMTPSA id <0OIF007S6C2IUQ30@mr11p00im-asmtp003.me.com>; Mon, 19 Dec 2016 08:39:55 +0000 (GMT) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-12-19_06:,, signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 clxscore=1034 suspectscore=2 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1603290000 definitions=main-1612190140 User-Agent: Microsoft-MacOutlook/f.1d.0.161209 Date: Mon, 19 Dec 2016 00:39:54 -0800 Subject: Re: svn commit: r310171 - head/sys/sys From: Ravi Pokala Sender: "Pokala, Ravi" To: Sepherosa Ziehau , Dimitry Andric Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Message-id: <9BD5034F-55A6-48F6-A391-A0877FF49702@panasas.com> Thread-topic: svn commit: r310171 - head/sys/sys References: <201612161949.uBGJnMol059217@repo.freebsd.org> In-reply-to: MIME-version: 1.0 Content-type: text/plain; charset=UTF-8 Content-transfer-encoding: 7bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 09:40:12 -0000 -----Original Message----- > From: on behalf of Sepherosa Ziehau > Date: 2016-12-18, Sunday at 23:02 > To: Dimitry Andric > Cc: , , > Subject: Re: svn commit: r310171 - head/sys/sys > > The following patch unbreaks the LINT builds on amd64 for me after this commit: > https://people.freebsd.org/~sephe/geom_sscanf.diff Wouldn't it be better to use the SCN macros? -Ravi (rpokala@) > Please review it. > > Thanks, > sephe > > > On Sat, Dec 17, 2016 at 3:49 AM, Dimitry Andric wrote: >> Author: dim >> Date: Fri Dec 16 19:49:22 2016 >> New Revision: 310171 >> URL: https://svnweb.freebsd.org/changeset/base/310171 >> >> Log: >> Add __scanflike attributes to the kernel's sscanf() and vsscanf() >> declarations. This should help to catch future mismatches between >> format strings and arguments. >> >> MFC after: 1 week >> >> Modified: >> head/sys/sys/systm.h >> >> Modified: head/sys/sys/systm.h >> ============================================================================== >> --- head/sys/sys/systm.h Fri Dec 16 19:09:57 2016 (r310170) >> +++ head/sys/sys/systm.h Fri Dec 16 19:49:22 2016 (r310171) >> @@ -227,8 +227,8 @@ int vsnprintf(char *, size_t, const char >> int vsnrprintf(char *, size_t, int, const char *, __va_list) __printflike(4, 0); >> int vsprintf(char *buf, const char *, __va_list) __printflike(2, 0); >> int ttyprintf(struct tty *, const char *, ...) __printflike(2, 3); >> -int sscanf(const char *, char const *, ...) __nonnull(1) __nonnull(2); >> -int vsscanf(const char *, char const *, __va_list) __nonnull(1) __nonnull(2); >> +int sscanf(const char *, char const *, ...) __nonnull(1) __nonnull(2) __scanflike(2, 3); >> +int vsscanf(const char *, char const *, __va_list) __nonnull(1) __nonnull(2) __scanflike(2, 0); >> long strtol(const char *, char **, int) __nonnull(1); >> u_long strtoul(const char *, char **, int) __nonnull(1); >> quad_t strtoq(const char *, char **, int) __nonnull(1); >> _______________________________________________ >> svn-src-all@freebsd.org mailing list >> https://lists.freebsd.org/mailman/listinfo/svn-src-all >> To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org" > > -- > Tomorrow Will Never Die From owner-svn-src-head@freebsd.org Mon Dec 19 09:41:16 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 050CEC86701; Mon, 19 Dec 2016 09:41:16 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from citapm.icyb.net.ua (citapm.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id B75AB16AC; Mon, 19 Dec 2016 09:41:14 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from porto.starpoint.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citapm.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id LAA05949; Mon, 19 Dec 2016 11:41:06 +0200 (EET) (envelope-from avg@FreeBSD.org) Received: from localhost ([127.0.0.1]) by porto.starpoint.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1cIuRN-0009Cz-V6; Mon, 19 Dec 2016 11:41:05 +0200 Subject: Re: svn commit: r310172 - in head/sys/mips: conf ingenic To: Jared McNeill , src-committers@FreeBSD.org, svn-src-all@FreeBSD.org, svn-src-head@FreeBSD.org References: <201612162004.uBGK4uHI066983@repo.freebsd.org> From: Andriy Gapon Message-ID: <99ab694b-5cc8-f485-9028-4158caaa337a@FreeBSD.org> Date: Mon, 19 Dec 2016 11:40:29 +0200 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <201612162004.uBGK4uHI066983@repo.freebsd.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 09:41:16 -0000 On 16/12/2016 22:04, Jared McNeill wrote: > Log: > Add support for Ingenic JZ4780 SMBus controller. Just a note that it looks, swims and quacks like an I²C (I2C / IIC) controller :-) > Reviewed by: kan > Relnotes: yes > Differential Revision: https://reviews.freebsd.org/D8793 > > Added: > head/sys/mips/ingenic/jz4780_smb.c (contents, props changed) > head/sys/mips/ingenic/jz4780_smb.h (contents, props changed) > Modified: > head/sys/mips/conf/JZ4780 > head/sys/mips/ingenic/files.jz4780 -- Andriy Gapon From owner-svn-src-head@freebsd.org Mon Dec 19 10:25:49 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4AB4BC87D18; Mon, 19 Dec 2016 10:25:49 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 19DE9158B; Mon, 19 Dec 2016 10:25:49 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBJAPm2M003688; Mon, 19 Dec 2016 10:25:48 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBJAPleQ003682; Mon, 19 Dec 2016 10:25:47 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201612191025.uBJAPleQ003682@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Mon, 19 Dec 2016 10:25:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310257 - in head/sys/cam: ctl scsi X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 10:25:49 -0000 Author: mav Date: Mon Dec 19 10:25:47 2016 New Revision: 310257 URL: https://svnweb.freebsd.org/changeset/base/310257 Log: Improve support for informational exceptions. While CTL still has no real events to report in this way (like SMART), it is possible to trigger false event by manually setting TEST bit in Informational Exceptions Control mode page, that can be useful for initiator testing. This code supports all flavours of IE reporting: UNIT ATTENTION, RECOVERED ERROR and NO SENSE sense keys, REQUEST SENSE command and Informational Exceptions log page. MFC after: 2 weeks Sponsored by: iXsystems, Inc. Modified: head/sys/cam/ctl/ctl.c head/sys/cam/ctl/ctl.h head/sys/cam/ctl/ctl_error.c head/sys/cam/ctl/ctl_private.h head/sys/cam/scsi/scsi_all.h head/sys/cam/scsi/scsi_da.h Modified: head/sys/cam/ctl/ctl.c ============================================================================== --- head/sys/cam/ctl/ctl.c Mon Dec 19 10:00:56 2016 (r310256) +++ head/sys/cam/ctl/ctl.c Mon Dec 19 10:25:47 2016 (r310257) @@ -93,25 +93,6 @@ struct ctl_softc *control_softc = NULL; * Note that these are default values only. The actual values will be * filled in when the user does a mode sense. */ -const static struct copan_debugconf_subpage debugconf_page_default = { - DBGCNF_PAGE_CODE | SMPH_SPF, /* page_code */ - DBGCNF_SUBPAGE_CODE, /* subpage */ - {(sizeof(struct copan_debugconf_subpage) - 4) >> 8, - (sizeof(struct copan_debugconf_subpage) - 4) >> 0}, /* page_length */ - DBGCNF_VERSION, /* page_version */ - {CTL_TIME_IO_DEFAULT_SECS>>8, - CTL_TIME_IO_DEFAULT_SECS>>0}, /* ctl_time_io_secs */ -}; - -const static struct copan_debugconf_subpage debugconf_page_changeable = { - DBGCNF_PAGE_CODE | SMPH_SPF, /* page_code */ - DBGCNF_SUBPAGE_CODE, /* subpage */ - {(sizeof(struct copan_debugconf_subpage) - 4) >> 8, - (sizeof(struct copan_debugconf_subpage) - 4) >> 0}, /* page_length */ - 0, /* page_version */ - {0xff,0xff}, /* ctl_time_io_secs */ -}; - const static struct scsi_da_rw_recovery_page rw_er_page_default = { /*page_code*/SMS_RW_ERROR_RECOVERY_PAGE, /*page_length*/sizeof(struct scsi_da_rw_recovery_page) - 2, @@ -129,12 +110,12 @@ const static struct scsi_da_rw_recovery_ const static struct scsi_da_rw_recovery_page rw_er_page_changeable = { /*page_code*/SMS_RW_ERROR_RECOVERY_PAGE, /*page_length*/sizeof(struct scsi_da_rw_recovery_page) - 2, - /*byte3*/0, + /*byte3*/SMS_RWER_PER, /*read_retry_count*/0, /*correction_span*/0, /*head_offset_count*/0, /*data_strobe_offset_cnt*/0, - /*byte8*/0, + /*byte8*/SMS_RWER_LBPERE, /*write_retry_count*/0, /*reserved2*/0, /*recovery_time_limit*/{0, 0}, @@ -206,6 +187,24 @@ const static struct scsi_rigid_disk_page /*reserved2*/ {0, 0} }; +const static struct scsi_da_verify_recovery_page verify_er_page_default = { + /*page_code*/SMS_VERIFY_ERROR_RECOVERY_PAGE, + /*page_length*/sizeof(struct scsi_da_verify_recovery_page) - 2, + /*byte3*/0, + /*read_retry_count*/0, + /*reserved*/{ 0, 0, 0, 0, 0, 0 }, + /*recovery_time_limit*/{0, 0}, +}; + +const static struct scsi_da_verify_recovery_page verify_er_page_changeable = { + /*page_code*/SMS_VERIFY_ERROR_RECOVERY_PAGE, + /*page_length*/sizeof(struct scsi_da_verify_recovery_page) - 2, + /*byte3*/SMS_VER_PER, + /*read_retry_count*/0, + /*reserved*/{ 0, 0, 0, 0, 0, 0 }, + /*recovery_time_limit*/{0, 0}, +}; + const static struct scsi_caching_page caching_page_default = { /*page_code*/SMS_CACHING_PAGE, /*page_length*/sizeof(struct scsi_caching_page) - 2, @@ -285,19 +284,20 @@ const static struct scsi_control_ext_pag const static struct scsi_info_exceptions_page ie_page_default = { /*page_code*/SMS_INFO_EXCEPTIONS_PAGE, /*page_length*/sizeof(struct scsi_info_exceptions_page) - 2, - /*info_flags*/SIEP_FLAGS_DEXCPT, - /*mrie*/0, + /*info_flags*/SIEP_FLAGS_EWASC, + /*mrie*/SIEP_MRIE_NO, /*interval_timer*/{0, 0, 0, 0}, - /*report_count*/{0, 0, 0, 0} + /*report_count*/{0, 0, 0, 1} }; const static struct scsi_info_exceptions_page ie_page_changeable = { /*page_code*/SMS_INFO_EXCEPTIONS_PAGE, /*page_length*/sizeof(struct scsi_info_exceptions_page) - 2, - /*info_flags*/0, - /*mrie*/0, - /*interval_timer*/{0, 0, 0, 0}, - /*report_count*/{0, 0, 0, 0} + /*info_flags*/SIEP_FLAGS_EWASC | SIEP_FLAGS_DEXCPT | SIEP_FLAGS_TEST | + SIEP_FLAGS_LOGERR, + /*mrie*/0x0f, + /*interval_timer*/{0xff, 0xff, 0xff, 0xff}, + /*report_count*/{0xff, 0xff, 0xff, 0xff} }; #define CTL_LBPM_LEN (sizeof(struct ctl_logical_block_provisioning_page) - 4) @@ -4070,6 +4070,26 @@ ctl_init_page_index(struct ctl_lun *lun) (uint8_t *)lun->mode_pages.rigid_disk_page; break; } + case SMS_VERIFY_ERROR_RECOVERY_PAGE: { + KASSERT(page_index->subpage == SMS_SUBPAGE_PAGE_0, + ("subpage %#x for page %#x is incorrect!", + page_index->subpage, page_code)); + memcpy(&lun->mode_pages.verify_er_page[CTL_PAGE_CURRENT], + &verify_er_page_default, + sizeof(verify_er_page_default)); + memcpy(&lun->mode_pages.verify_er_page[CTL_PAGE_CHANGEABLE], + &verify_er_page_changeable, + sizeof(verify_er_page_changeable)); + memcpy(&lun->mode_pages.verify_er_page[CTL_PAGE_DEFAULT], + &verify_er_page_default, + sizeof(verify_er_page_default)); + memcpy(&lun->mode_pages.verify_er_page[CTL_PAGE_SAVED], + &verify_er_page_default, + sizeof(verify_er_page_default)); + page_index->page_data = + (uint8_t *)lun->mode_pages.verify_er_page; + break; + } case SMS_CACHING_PAGE: { struct scsi_caching_page *caching_page; @@ -4280,35 +4300,6 @@ ctl_init_page_index(struct ctl_lun *lun) (uint8_t *)lun->mode_pages.cddvd_page; break; } - case SMS_VENDOR_SPECIFIC_PAGE:{ - switch (page_index->subpage) { - case DBGCNF_SUBPAGE_CODE: { - memcpy(&lun->mode_pages.debugconf_subpage[ - CTL_PAGE_CURRENT], - &debugconf_page_default, - sizeof(debugconf_page_default)); - memcpy(&lun->mode_pages.debugconf_subpage[ - CTL_PAGE_CHANGEABLE], - &debugconf_page_changeable, - sizeof(debugconf_page_changeable)); - memcpy(&lun->mode_pages.debugconf_subpage[ - CTL_PAGE_DEFAULT], - &debugconf_page_default, - sizeof(debugconf_page_default)); - memcpy(&lun->mode_pages.debugconf_subpage[ - CTL_PAGE_SAVED], - &debugconf_page_default, - sizeof(debugconf_page_default)); - page_index->page_data = - (uint8_t *)lun->mode_pages.debugconf_subpage; - break; - } - default: - panic("subpage %#x for page %#x is incorrect!", - page_index->subpage, page_code); - } - break; - } default: panic("invalid page code value %#x", page_code); } @@ -4361,6 +4352,8 @@ ctl_init_log_page_index(struct ctl_lun * lun->log_pages.index[2].page_len = 12*CTL_NUM_LBP_PARAMS; lun->log_pages.index[3].page_data = (uint8_t *)&lun->log_pages.stat_page; lun->log_pages.index[3].page_len = sizeof(lun->log_pages.stat_page); + lun->log_pages.index[4].page_data = (uint8_t *)&lun->log_pages.ie_page; + lun->log_pages.index[4].page_len = sizeof(lun->log_pages.ie_page); return (CTL_RETVAL_COMPLETE); } @@ -4591,6 +4584,8 @@ ctl_alloc_lun(struct ctl_softc *ctl_soft TAILQ_INIT(&lun->ooa_queue); TAILQ_INIT(&lun->blocked_queue); STAILQ_INIT(&lun->error_list); + lun->ie_reported = 1; + callout_init_mtx(&lun->ie_callout, &lun->lun_lock, 0); ctl_tpc_lun_init(lun); /* @@ -4664,6 +4659,9 @@ ctl_free_lun(struct ctl_lun *lun) atomic_subtract_int(&lun->be_lun->be->num_luns, 1); lun->be_lun->lun_shutdown(lun->be_lun->be_lun); + lun->ie_reportcnt = UINT32_MAX; + callout_drain(&lun->ie_callout); + ctl_tpc_lun_shutdown(lun); mtx_destroy(&lun->lun_lock); free(lun->lun_devid, M_CTL); @@ -5832,25 +5830,12 @@ done: return (CTL_RETVAL_COMPLETE); } -/* - * Note that this function currently doesn't actually do anything inside - * CTL to enforce things if the DQue bit is turned on. - * - * Also note that this function can't be used in the default case, because - * the DQue bit isn't set in the changeable mask for the control mode page - * anyway. This is just here as an example for how to implement a page - * handler, and a placeholder in case we want to allow the user to turn - * tagged queueing on and off. - * - * The D_SENSE bit handling is functional, however, and will turn - * descriptor sense on and off for a given LUN. - */ int -ctl_control_page_handler(struct ctl_scsiio *ctsio, +ctl_default_page_handler(struct ctl_scsiio *ctsio, struct ctl_page_index *page_index, uint8_t *page_ptr) { - struct scsi_control_page *current_cp, *saved_cp, *user_cp; struct ctl_lun *lun; + uint8_t *current_cp, *saved_cp; int set_ua; uint32_t initidx; @@ -5858,50 +5843,15 @@ ctl_control_page_handler(struct ctl_scsi initidx = ctl_get_initindex(&ctsio->io_hdr.nexus); set_ua = 0; - user_cp = (struct scsi_control_page *)page_ptr; - current_cp = (struct scsi_control_page *) - (page_index->page_data + (page_index->page_len * - CTL_PAGE_CURRENT)); - saved_cp = (struct scsi_control_page *) - (page_index->page_data + (page_index->page_len * - CTL_PAGE_SAVED)); + current_cp = (page_index->page_data + (page_index->page_len * + CTL_PAGE_CURRENT)); + saved_cp = (page_index->page_data + (page_index->page_len * + CTL_PAGE_SAVED)); mtx_lock(&lun->lun_lock); - if (((current_cp->rlec & SCP_DSENSE) == 0) - && ((user_cp->rlec & SCP_DSENSE) != 0)) { - /* - * Descriptor sense is currently turned off and the user - * wants to turn it on. - */ - current_cp->rlec |= SCP_DSENSE; - saved_cp->rlec |= SCP_DSENSE; - lun->flags |= CTL_LUN_SENSE_DESC; - set_ua = 1; - } else if (((current_cp->rlec & SCP_DSENSE) != 0) - && ((user_cp->rlec & SCP_DSENSE) == 0)) { - /* - * Descriptor sense is currently turned on, and the user - * wants to turn it off. - */ - current_cp->rlec &= ~SCP_DSENSE; - saved_cp->rlec &= ~SCP_DSENSE; - lun->flags &= ~CTL_LUN_SENSE_DESC; - set_ua = 1; - } - if ((current_cp->queue_flags & SCP_QUEUE_ALG_MASK) != - (user_cp->queue_flags & SCP_QUEUE_ALG_MASK)) { - current_cp->queue_flags &= ~SCP_QUEUE_ALG_MASK; - current_cp->queue_flags |= user_cp->queue_flags & SCP_QUEUE_ALG_MASK; - saved_cp->queue_flags &= ~SCP_QUEUE_ALG_MASK; - saved_cp->queue_flags |= user_cp->queue_flags & SCP_QUEUE_ALG_MASK; - set_ua = 1; - } - if ((current_cp->eca_and_aen & SCP_SWP) != - (user_cp->eca_and_aen & SCP_SWP)) { - current_cp->eca_and_aen &= ~SCP_SWP; - current_cp->eca_and_aen |= user_cp->eca_and_aen & SCP_SWP; - saved_cp->eca_and_aen &= ~SCP_SWP; - saved_cp->eca_and_aen |= user_cp->eca_and_aen & SCP_SWP; + if (memcmp(current_cp, page_ptr, page_index->page_len)) { + memcpy(current_cp, page_ptr, page_index->page_len); + memcpy(saved_cp, page_ptr, page_index->page_len); set_ua = 1; } if (set_ua != 0) @@ -5912,101 +5862,78 @@ ctl_control_page_handler(struct ctl_scsi ctl_get_initindex(&ctsio->io_hdr.nexus), page_index->page_code, page_index->subpage); } - return (0); + return (CTL_RETVAL_COMPLETE); } -int -ctl_caching_sp_handler(struct ctl_scsiio *ctsio, - struct ctl_page_index *page_index, uint8_t *page_ptr) +static void +ctl_ie_timer(void *arg) { - struct scsi_caching_page *current_cp, *saved_cp, *user_cp; - struct ctl_lun *lun; - int set_ua; - uint32_t initidx; + struct ctl_lun *lun = arg; + struct scsi_info_exceptions_page *pg; + uint64_t t; - lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; - initidx = ctl_get_initindex(&ctsio->io_hdr.nexus); - set_ua = 0; + if (lun->ie_asc == 0) + return; - user_cp = (struct scsi_caching_page *)page_ptr; - current_cp = (struct scsi_caching_page *) - (page_index->page_data + (page_index->page_len * - CTL_PAGE_CURRENT)); - saved_cp = (struct scsi_caching_page *) - (page_index->page_data + (page_index->page_len * - CTL_PAGE_SAVED)); + pg = &lun->mode_pages.ie_page[CTL_PAGE_CURRENT]; + if (pg->mrie == SIEP_MRIE_UA) + ctl_est_ua_all(lun, -1, CTL_UA_IE); + else + lun->ie_reported = 0; - mtx_lock(&lun->lun_lock); - if ((current_cp->flags1 & (SCP_WCE | SCP_RCD)) != - (user_cp->flags1 & (SCP_WCE | SCP_RCD))) { - current_cp->flags1 &= ~(SCP_WCE | SCP_RCD); - current_cp->flags1 |= user_cp->flags1 & (SCP_WCE | SCP_RCD); - saved_cp->flags1 &= ~(SCP_WCE | SCP_RCD); - saved_cp->flags1 |= user_cp->flags1 & (SCP_WCE | SCP_RCD); - set_ua = 1; + if (lun->ie_reportcnt < scsi_4btoul(pg->report_count)) { + lun->ie_reportcnt++; + t = scsi_4btoul(pg->interval_timer); + if (t == 0 || t == UINT32_MAX) + t = 3000; /* 5 min */ + callout_schedule(&lun->ie_callout, t * hz / 10); } - if (set_ua != 0) - ctl_est_ua_all(lun, initidx, CTL_UA_MODE_CHANGE); - mtx_unlock(&lun->lun_lock); - if (set_ua) { - ctl_isc_announce_mode(lun, - ctl_get_initindex(&ctsio->io_hdr.nexus), - page_index->page_code, page_index->subpage); - } - return (0); } int -ctl_debugconf_sp_select_handler(struct ctl_scsiio *ctsio, - struct ctl_page_index *page_index, - uint8_t *page_ptr) -{ - uint8_t *c; - int i; - - c = ((struct copan_debugconf_subpage *)page_ptr)->ctl_time_io_secs; - ctl_time_io_secs = - (c[0] << 8) | - (c[1] << 0) | - 0; - CTL_DEBUG_PRINT(("set ctl_time_io_secs to %d\n", ctl_time_io_secs)); - printf("set ctl_time_io_secs to %d\n", ctl_time_io_secs); - printf("page data:"); - for (i=0; i<8; i++) - printf(" %.2x",page_ptr[i]); - printf("\n"); - return (0); -} - -int -ctl_debugconf_sp_sense_handler(struct ctl_scsiio *ctsio, - struct ctl_page_index *page_index, - int pc) +ctl_ie_page_handler(struct ctl_scsiio *ctsio, + struct ctl_page_index *page_index, uint8_t *page_ptr) { - struct copan_debugconf_subpage *page; + struct scsi_info_exceptions_page *pg; + struct ctl_lun *lun; + uint64_t t; - page = (struct copan_debugconf_subpage *)page_index->page_data + - (page_index->page_len * pc); + (void)ctl_default_page_handler(ctsio, page_index, page_ptr); - switch (pc) { - case SMS_PAGE_CTRL_CHANGEABLE >> 6: - case SMS_PAGE_CTRL_DEFAULT >> 6: - case SMS_PAGE_CTRL_SAVED >> 6: - /* - * We don't update the changeable or default bits for this page. - */ - break; - case SMS_PAGE_CTRL_CURRENT >> 6: - page->ctl_time_io_secs[0] = ctl_time_io_secs >> 8; - page->ctl_time_io_secs[1] = ctl_time_io_secs >> 0; - break; - default: - break; + lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; + pg = (struct scsi_info_exceptions_page *)page_ptr; + mtx_lock(&lun->lun_lock); + if (pg->info_flags & SIEP_FLAGS_TEST) { + lun->ie_asc = 0x5d; + lun->ie_ascq = 0xff; + if (pg->mrie == SIEP_MRIE_UA) { + ctl_est_ua_all(lun, -1, CTL_UA_IE); + lun->ie_reported = 1; + } else { + ctl_clr_ua_all(lun, -1, CTL_UA_IE); + lun->ie_reported = -1; + } + lun->ie_reportcnt = 1; + if (lun->ie_reportcnt < scsi_4btoul(pg->report_count)) { + lun->ie_reportcnt++; + t = scsi_4btoul(pg->interval_timer); + if (t == 0 || t == UINT32_MAX) + t = 3000; /* 5 min */ + callout_reset(&lun->ie_callout, t * hz / 10, + ctl_ie_timer, lun); + } + } else { + lun->ie_asc = 0; + lun->ie_ascq = 0; + lun->ie_reported = 1; + ctl_clr_ua_all(lun, -1, CTL_UA_IE); + lun->ie_reportcnt = UINT32_MAX; + callout_stop(&lun->ie_callout); } - return (0); + mtx_unlock(&lun->lun_lock); + return (CTL_RETVAL_COMPLETE); } - static int ctl_do_mode_select(union ctl_io *io) { @@ -6824,8 +6751,27 @@ ctl_sap_log_sense_handler(struct ctl_scs sizeof(struct scsi_log_param_header); scsi_ulto4b(3, data->ti.exponent); scsi_ulto4b(1, data->ti.integer); + return (0); +} - page_index->page_len = sizeof(*data); +int +ctl_ie_log_sense_handler(struct ctl_scsiio *ctsio, + struct ctl_page_index *page_index, + int pc) +{ + struct ctl_lun *lun; + struct scsi_log_informational_exceptions *data; + + lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; + data = (struct scsi_log_informational_exceptions *)page_index->page_data; + + scsi_ulto2b(SLP_IE_GEN, data->hdr.param_code); + data->hdr.param_control = SLP_LBIN; + data->hdr.param_len = sizeof(struct scsi_log_informational_exceptions) - + sizeof(struct scsi_log_param_header); + data->ie_asc = lun->ie_asc; + data->ie_ascq = lun->ie_ascq; + data->temperature = 0xff; return (0); } @@ -9265,6 +9211,7 @@ ctl_request_sense(struct ctl_scsiio *cts int have_error; scsi_sense_data_type sense_format; ctl_ua_type ua_type; + uint8_t asc = 0, ascq = 0; cdb = (struct scsi_request_sense *)ctsio->cdb; @@ -9383,19 +9330,23 @@ ctl_request_sense(struct ctl_scsiio *cts return (CTL_RETVAL_COMPLETE); } -no_sense: - /* * No sense information to report, so we report that everything is - * okay. + * okay, unless we have allowed Informational Exception. */ + if (lun->mode_pages.ie_page[CTL_PAGE_CURRENT].mrie != SIEP_MRIE_NO) { + asc = lun->ie_asc; + ascq = lun->ie_ascq; + } + +no_sense: ctl_set_sense_data(sense_ptr, lun, sense_format, /*current_error*/ 1, /*sense_key*/ SSD_KEY_NO_SENSE, - /*asc*/ 0x00, - /*ascq*/ 0x00, + /*asc*/ asc, + /*ascq*/ ascq, SSD_ELEM_NONE); /* @@ -13265,6 +13216,37 @@ ctl_process_done(union ctl_io *io) mtx_lock(&lun->lun_lock); /* + * Check to see if we have any informational exception and status + * of this command can be modified to report it in form of either + * RECOVERED ERROR or NO SENSE, depending on MRIE mode page field. + */ + if (lun->ie_reported == 0 && lun->ie_asc != 0 && + io->io_hdr.status == CTL_SUCCESS && + (io->io_hdr.flags & CTL_FLAG_STATUS_SENT) == 0) { + uint8_t mrie = lun->mode_pages.ie_page[CTL_PAGE_CURRENT].mrie; + uint8_t per = + ((lun->mode_pages.rw_er_page[CTL_PAGE_CURRENT].byte3 & + SMS_RWER_PER) || + (lun->mode_pages.verify_er_page[CTL_PAGE_CURRENT].byte3 & + SMS_VER_PER)); + if (((mrie == SIEP_MRIE_REC_COND && per) || + mrie == SIEP_MRIE_REC_UNCOND || + mrie == SIEP_MRIE_NO_SENSE) && + (ctl_get_cmd_entry(&io->scsiio, NULL)->flags & + CTL_CMD_FLAG_NO_SENSE) == 0) { + ctl_set_sense(&io->scsiio, + /*current_error*/ 1, + /*sense_key*/ (mrie == SIEP_MRIE_NO_SENSE) ? + SSD_KEY_NO_SENSE : SSD_KEY_RECOVERED_ERROR, + /*asc*/ lun->ie_asc, + /*ascq*/ lun->ie_ascq, + SSD_ELEM_NONE); + lun->ie_reported = 1; + } + } else if (lun->ie_reported < 0) + lun->ie_reported = 0; + + /* * Check to see if we have any errors to inject here. We only * inject errors for commands that don't already have errors set. */ @@ -13537,10 +13519,6 @@ ctl_done(union ctl_io *io) #ifdef CTL_IO_DELAY if (io->io_hdr.flags & CTL_FLAG_DELAY_DONE) { - struct ctl_lun *lun; - - lun =(struct ctl_lun *)io->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; - io->io_hdr.flags &= ~CTL_FLAG_DELAY_DONE; } else { struct ctl_lun *lun; Modified: head/sys/cam/ctl/ctl.h ============================================================================== --- head/sys/cam/ctl/ctl.h Mon Dec 19 10:00:56 2016 (r310256) +++ head/sys/cam/ctl/ctl.h Mon Dec 19 10:25:47 2016 (r310257) @@ -127,7 +127,8 @@ typedef enum { CTL_UA_ASYM_ACC_CHANGE = 0x2000, CTL_UA_CAPACITY_CHANGE = 0x4000, CTL_UA_THIN_PROV_THRES = 0x8000, - CTL_UA_MEDIUM_CHANGE = 0x10000 + CTL_UA_MEDIUM_CHANGE = 0x10000, + CTL_UA_IE = 0x20000 } ctl_ua_type; #ifdef _KERNEL @@ -154,23 +155,21 @@ int ctl_ffz(uint32_t *mask, uint32_t fir int ctl_set_mask(uint32_t *mask, uint32_t bit); int ctl_clear_mask(uint32_t *mask, uint32_t bit); int ctl_is_set(uint32_t *mask, uint32_t bit); -int ctl_caching_sp_handler(struct ctl_scsiio *ctsio, - struct ctl_page_index *page_index, uint8_t *page_ptr); -int ctl_control_page_handler(struct ctl_scsiio *ctsio, +int ctl_default_page_handler(struct ctl_scsiio *ctsio, struct ctl_page_index *page_index, uint8_t *page_ptr); -int ctl_debugconf_sp_sense_handler(struct ctl_scsiio *ctsio, - struct ctl_page_index *page_index, - int pc); -int ctl_debugconf_sp_select_handler(struct ctl_scsiio *ctsio, - struct ctl_page_index *page_index, - uint8_t *page_ptr); +int ctl_ie_page_handler(struct ctl_scsiio *ctsio, + struct ctl_page_index *page_index, + uint8_t *page_ptr); int ctl_lbp_log_sense_handler(struct ctl_scsiio *ctsio, struct ctl_page_index *page_index, int pc); int ctl_sap_log_sense_handler(struct ctl_scsiio *ctsio, struct ctl_page_index *page_index, int pc); +int ctl_ie_log_sense_handler(struct ctl_scsiio *ctsio, + struct ctl_page_index *page_index, + int pc); int ctl_config_move_done(union ctl_io *io); void ctl_datamove(union ctl_io *io); void ctl_serseq_done(union ctl_io *io); Modified: head/sys/cam/ctl/ctl_error.c ============================================================================== --- head/sys/cam/ctl/ctl_error.c Mon Dec 19 10:00:56 2016 (r310256) +++ head/sys/cam/ctl/ctl_error.c Mon Dec 19 10:25:47 2016 (r310257) @@ -84,7 +84,8 @@ ctl_set_sense_data_va(struct scsi_sense_ * on for that LUN. */ if ((lun != NULL) - && (lun->flags & CTL_LUN_SENSE_DESC)) + && (lun->mode_pages.control_page[CTL_PAGE_CURRENT].rlec & + SCP_DSENSE)) sense_format = SSD_TYPE_DESC; else sense_format = SSD_TYPE_FIXED; @@ -461,6 +462,11 @@ ctl_ua_to_acsq(struct ctl_lun *lun, ctl_ *asc = 0x28; *ascq = 0x00; break; + case CTL_UA_IE: + /* Informational exception */ + *asc = lun->ie_asc; + *ascq = lun->ie_ascq; + break; default: panic("%s: Unknown UA %x", __func__, ua_to_build); } Modified: head/sys/cam/ctl/ctl_private.h ============================================================================== --- head/sys/cam/ctl/ctl_private.h Mon Dec 19 10:00:56 2016 (r310256) +++ head/sys/cam/ctl/ctl_private.h Mon Dec 19 10:25:47 2016 (r310257) @@ -151,7 +151,6 @@ typedef enum { CTL_LUN_EJECTED = 0x080, CTL_LUN_PR_RESERVED = 0x100, CTL_LUN_PRIMARY_SC = 0x200, - CTL_LUN_SENSE_DESC = 0x400, CTL_LUN_READONLY = 0x800, CTL_LUN_PEER_SC_PRIMARY = 0x1000, CTL_LUN_REMOVABLE = 0x2000 @@ -272,30 +271,29 @@ struct ctl_logical_block_provisioning_pa static const struct ctl_page_index page_index_template[] = { {SMS_RW_ERROR_RECOVERY_PAGE, 0, sizeof(struct scsi_da_rw_recovery_page), NULL, - CTL_PAGE_FLAG_DIRECT | CTL_PAGE_FLAG_CDROM, NULL, NULL}, + CTL_PAGE_FLAG_DIRECT | CTL_PAGE_FLAG_CDROM, NULL, ctl_default_page_handler}, {SMS_FORMAT_DEVICE_PAGE, 0, sizeof(struct scsi_format_page), NULL, CTL_PAGE_FLAG_DIRECT, NULL, NULL}, {SMS_RIGID_DISK_PAGE, 0, sizeof(struct scsi_rigid_disk_page), NULL, CTL_PAGE_FLAG_DIRECT, NULL, NULL}, + {SMS_VERIFY_ERROR_RECOVERY_PAGE, 0, sizeof(struct scsi_da_verify_recovery_page), NULL, + CTL_PAGE_FLAG_DIRECT | CTL_PAGE_FLAG_CDROM, NULL, ctl_default_page_handler}, {SMS_CACHING_PAGE, 0, sizeof(struct scsi_caching_page), NULL, CTL_PAGE_FLAG_DIRECT | CTL_PAGE_FLAG_CDROM, - NULL, ctl_caching_sp_handler}, + NULL, ctl_default_page_handler}, {SMS_CONTROL_MODE_PAGE, 0, sizeof(struct scsi_control_page), NULL, - CTL_PAGE_FLAG_ALL, NULL, ctl_control_page_handler}, + CTL_PAGE_FLAG_ALL, NULL, ctl_default_page_handler}, {SMS_CONTROL_MODE_PAGE | SMPH_SPF, 0x01, sizeof(struct scsi_control_ext_page), NULL, CTL_PAGE_FLAG_ALL, NULL, NULL}, {SMS_INFO_EXCEPTIONS_PAGE, 0, sizeof(struct scsi_info_exceptions_page), NULL, - CTL_PAGE_FLAG_ALL, NULL, NULL}, + CTL_PAGE_FLAG_ALL, NULL, ctl_ie_page_handler}, {SMS_INFO_EXCEPTIONS_PAGE | SMPH_SPF, 0x02, sizeof(struct ctl_logical_block_provisioning_page), NULL, CTL_PAGE_FLAG_DIRECT, NULL, NULL}, {SMS_CDDVD_CAPS_PAGE, 0, sizeof(struct scsi_cddvd_capabilities_page), NULL, CTL_PAGE_FLAG_CDROM, NULL, NULL}, - {SMS_VENDOR_SPECIFIC_PAGE | SMPH_SPF, DBGCNF_SUBPAGE_CODE, - sizeof(struct copan_debugconf_subpage), NULL, CTL_PAGE_FLAG_ALL, - ctl_debugconf_sp_sense_handler, ctl_debugconf_sp_select_handler}, }; #define CTL_NUM_MODE_PAGES sizeof(page_index_template)/ \ @@ -305,13 +303,13 @@ struct ctl_mode_pages { struct scsi_da_rw_recovery_page rw_er_page[4]; struct scsi_format_page format_page[4]; struct scsi_rigid_disk_page rigid_disk_page[4]; + struct scsi_da_verify_recovery_page verify_er_page[4]; struct scsi_caching_page caching_page[4]; struct scsi_control_page control_page[4]; struct scsi_control_ext_page control_ext_page[4]; struct scsi_info_exceptions_page ie_page[4]; struct ctl_logical_block_provisioning_page lbp_page[4]; struct scsi_cddvd_capabilities_page cddvd_page[4]; - struct copan_debugconf_subpage debugconf_subpage[4]; struct ctl_page_index index[CTL_NUM_MODE_PAGES]; }; @@ -324,6 +322,8 @@ static const struct ctl_page_index log_p CTL_PAGE_FLAG_DIRECT, ctl_lbp_log_sense_handler, NULL}, {SLS_STAT_AND_PERF, 0, 0, NULL, CTL_PAGE_FLAG_ALL, ctl_sap_log_sense_handler, NULL}, + {SLS_IE_PAGE, 0, 0, NULL, + CTL_PAGE_FLAG_ALL, ctl_ie_log_sense_handler, NULL}, }; #define CTL_NUM_LOG_PAGES sizeof(log_page_index_template)/ \ @@ -338,6 +338,7 @@ struct ctl_log_pages { struct scsi_log_idle_time it; struct scsi_log_time_interval ti; } stat_page; + struct scsi_log_informational_exceptions ie_page; struct ctl_page_index index[CTL_NUM_LOG_PAGES]; }; @@ -385,6 +386,11 @@ struct ctl_lun { ctl_ua_type *pending_ua[CTL_MAX_PORTS]; uint8_t ua_tpt_info[8]; time_t lasttpt; + uint8_t ie_asc; /* Informational exceptions */ + uint8_t ie_ascq; + int ie_reported; /* Already reported */ + uint32_t ie_reportcnt; /* REPORT COUNT */ + struct callout ie_callout; /* INTERVAL TIMER */ struct ctl_mode_pages mode_pages; struct ctl_log_pages log_pages; struct ctl_lun_io_stats stats; Modified: head/sys/cam/scsi/scsi_all.h ============================================================================== --- head/sys/cam/scsi/scsi_all.h Mon Dec 19 10:00:56 2016 (r310256) +++ head/sys/cam/scsi/scsi_all.h Mon Dec 19 10:25:47 2016 (r310257) @@ -662,6 +662,14 @@ struct scsi_log_fua_stat_and_perf { uint8_t fuanv_write_int[8]; }; +struct scsi_log_informational_exceptions { + struct scsi_log_param_header hdr; +#define SLP_IE_GEN 0x0000 + uint8_t ie_asc; + uint8_t ie_ascq; + uint8_t temperature; +}; + struct scsi_control_page { u_int8_t page_code; u_int8_t page_length; @@ -765,21 +773,6 @@ struct scsi_caching_page { uint8_t non_cache_seg_size[3]; }; -/* - * XXX KDM move this off to a vendor shim. - */ -struct copan_debugconf_subpage { - uint8_t page_code; -#define DBGCNF_PAGE_CODE 0x00 - uint8_t subpage; -#define DBGCNF_SUBPAGE_CODE 0xF0 - uint8_t page_length[2]; - uint8_t page_version; -#define DBGCNF_VERSION 0x00 - uint8_t ctl_time_io_secs[2]; -}; - - struct scsi_info_exceptions_page { u_int8_t page_code; #define SIEP_PAGE_SAVABLE 0x80 /* Page is savable */ @@ -793,6 +786,12 @@ struct scsi_info_exceptions_page { #define SIEP_FLAGS_EBACKERR 0x02 #define SIEP_FLAGS_LOGERR 0x01 u_int8_t mrie; +#define SIEP_MRIE_NO 0x00 +#define SIEP_MRIE_UA 0x02 +#define SIEP_MRIE_REC_COND 0x03 +#define SIEP_MRIE_REC_UNCOND 0x04 +#define SIEP_MRIE_NO_SENSE 0x05 +#define SIEP_MRIE_ON_REQ 0x06 u_int8_t interval_timer[4]; u_int8_t report_count[4]; }; Modified: head/sys/cam/scsi/scsi_da.h ============================================================================== --- head/sys/cam/scsi/scsi_da.h Mon Dec 19 10:00:56 2016 (r310256) +++ head/sys/cam/scsi/scsi_da.h Mon Dec 19 10:25:47 2016 (r310257) @@ -634,6 +634,20 @@ struct scsi_da_rw_recovery_page { u_int8_t recovery_time_limit[2]; }; +struct scsi_da_verify_recovery_page { + u_int8_t page_code; +#define SMS_VERIFY_ERROR_RECOVERY_PAGE 0x07 + u_int8_t page_length; + u_int8_t byte3; +#define SMS_VER_EER 0x08 +#define SMS_VER_PER 0x04 +#define SMS_VER_DTE 0x02 +#define SMS_VER_DCR 0x01 + u_int8_t read_retry_count; + u_int8_t reserved[6]; + u_int8_t recovery_time_limit[2]; +}; + __BEGIN_DECLS /* * XXX These are only left out of the kernel build to silence warnings. If, From owner-svn-src-head@freebsd.org Mon Dec 19 11:02:51 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 22652C8784D; Mon, 19 Dec 2016 11:02:51 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 F11A594A; Mon, 19 Dec 2016 11:02:50 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBJB2oow020337; Mon, 19 Dec 2016 11:02:50 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBJB2oS7020335; Mon, 19 Dec 2016 11:02:50 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201612191102.uBJB2oS7020335@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Mon, 19 Dec 2016 11:02:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310258 - in head/sys: netinet netinet6 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 11:02:51 -0000 Author: ae Date: Mon Dec 19 11:02:49 2016 New Revision: 310258 URL: https://svnweb.freebsd.org/changeset/base/310258 Log: ip[6]_tryforward does inbound and outbound packet firewall processing. This can lead to change of mbuf pointer (packet filter could do m_pullup(), NAT, etc). Also in case of change of destination address, tryforward can decide that packet should be handled by local system. In this case modified mbuf can be returned to the ip[6]_input(). To handle this correctly, check M_FASTFWD_OURS flag after return from ip[6]_tryforward. And if it is present, update variables that depend from mbuf pointer and skip another inbound firewall processing. No objection from: #network MFC after: 3 weeks Sponsored by: Yandex LLC Differential Revision: https://reviews.freebsd.org/D8764 Modified: head/sys/netinet/ip_input.c head/sys/netinet6/ip6_input.c Modified: head/sys/netinet/ip_input.c ============================================================================== --- head/sys/netinet/ip_input.c Mon Dec 19 10:25:47 2016 (r310257) +++ head/sys/netinet/ip_input.c Mon Dec 19 11:02:49 2016 (r310258) @@ -550,24 +550,35 @@ tooshort: m_adj(m, ip_len - m->m_pkthdr.len); } - /* Try to forward the packet, but if we fail continue */ + /* + * Try to forward the packet, but if we fail continue. + * ip_tryforward() does inbound and outbound packet firewall + * processing. If firewall has decided that destination becomes + * our local address, it sets M_FASTFWD_OURS flag. In this + * case skip another inbound firewall processing and update + * ip pointer. + */ + if (V_ipforwarding != 0 #ifdef IPSEC - /* For now we do not handle IPSEC in tryforward. */ - if (!key_havesp(IPSEC_DIR_INBOUND) && !key_havesp(IPSEC_DIR_OUTBOUND) && - (V_ipforwarding == 1)) - if (ip_tryforward(m) == NULL) + && !key_havesp(IPSEC_DIR_INBOUND) + && !key_havesp(IPSEC_DIR_OUTBOUND) +#endif + ) { + if ((m = ip_tryforward(m)) == NULL) return; + if (m->m_flags & M_FASTFWD_OURS) { + m->m_flags &= ~M_FASTFWD_OURS; + ip = mtod(m, struct ip *); + goto ours; + } + } +#ifdef IPSEC /* * Bypass packet filtering for packets previously handled by IPsec. */ if (ip_ipsec_filtertunnel(m)) goto passin; -#else - if (V_ipforwarding == 1) - if (ip_tryforward(m) == NULL) - return; -#endif /* IPSEC */ - +#endif /* * Run through list of hooks for input packets. * Modified: head/sys/netinet6/ip6_input.c ============================================================================== --- head/sys/netinet6/ip6_input.c Mon Dec 19 10:25:47 2016 (r310257) +++ head/sys/netinet6/ip6_input.c Mon Dec 19 11:02:49 2016 (r310258) @@ -726,23 +726,36 @@ ip6_input(struct mbuf *m) goto bad; } #endif - /* Try to forward the packet, but if we fail continue */ + /* + * Try to forward the packet, but if we fail continue. + * ip6_tryforward() does inbound and outbound packet firewall + * processing. If firewall has decided that destination becomes + * our local address, it sets M_FASTFWD_OURS flag. In this + * case skip another inbound firewall processing and update + * ip6 pointer. + */ + if (V_ip6_forwarding != 0 #ifdef IPSEC - if (V_ip6_forwarding != 0 && !key_havesp(IPSEC_DIR_INBOUND) && - !key_havesp(IPSEC_DIR_OUTBOUND)) - if (ip6_tryforward(m) == NULL) + && !key_havesp(IPSEC_DIR_INBOUND) + && !key_havesp(IPSEC_DIR_OUTBOUND) +#endif + ) { + if ((m = ip6_tryforward(m)) == NULL) return; + if (m->m_flags & M_FASTFWD_OURS) { + m->m_flags &= ~M_FASTFWD_OURS; + ours = 1; + ip6 = mtod(m, struct ip6_hdr *); + goto hbhcheck; + } + } +#ifdef IPSEC /* * Bypass packet filtering for packets previously handled by IPsec. */ if (ip6_ipsec_filtertunnel(m)) goto passin; -#else - if (V_ip6_forwarding != 0) - if (ip6_tryforward(m) == NULL) - return; -#endif /* IPSEC */ - +#endif /* * Run through list of hooks for input packets. * @@ -750,12 +763,12 @@ ip6_input(struct mbuf *m) * (e.g. by NAT rewriting). When this happens, * tell ip6_forward to do the right thing. */ - odst = ip6->ip6_dst; /* Jump over all PFIL processing if hooks are not active. */ if (!PFIL_HOOKED(&V_inet6_pfil_hook)) goto passin; + odst = ip6->ip6_dst; if (pfil_run_hooks(&V_inet6_pfil_hook, &m, m->m_pkthdr.rcvif, PFIL_IN, NULL)) return; From owner-svn-src-head@freebsd.org Mon Dec 19 11:44:43 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 22D78C87235; Mon, 19 Dec 2016 11:44:43 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 F19381D6F; Mon, 19 Dec 2016 11:44:42 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBJBigDl037569; Mon, 19 Dec 2016 11:44:42 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBJBigpN037568; Mon, 19 Dec 2016 11:44:42 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201612191144.uBJBigpN037568@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Mon, 19 Dec 2016 11:44:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310259 - head/sys/cam/ctl X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 11:44:43 -0000 Author: mav Date: Mon Dec 19 11:44:41 2016 New Revision: 310259 URL: https://svnweb.freebsd.org/changeset/base/310259 Log: Following SPC-5, make REQUEST SENSE report "Logical unit not supported" in returned parameter data for not accessible LUNs. MFC after: 2 weeks Modified: head/sys/cam/ctl/ctl.c Modified: head/sys/cam/ctl/ctl.c ============================================================================== --- head/sys/cam/ctl/ctl.c Mon Dec 19 11:02:49 2016 (r310258) +++ head/sys/cam/ctl/ctl.c Mon Dec 19 11:44:41 2016 (r310259) @@ -9205,7 +9205,7 @@ ctl_request_sense(struct ctl_scsiio *cts { struct scsi_request_sense *cdb; struct scsi_sense_data *sense_ptr; - struct ctl_softc *ctl_softc; + struct ctl_softc *softc; struct ctl_lun *lun; uint32_t initidx; int have_error; @@ -9215,7 +9215,7 @@ ctl_request_sense(struct ctl_scsiio *cts cdb = (struct scsi_request_sense *)ctsio->cdb; - ctl_softc = control_softc; + softc = control_softc; lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; CTL_DEBUG_PRINT(("ctl_request_sense\n")); @@ -9248,8 +9248,18 @@ ctl_request_sense(struct ctl_scsiio *cts /* * If we don't have a LUN, we don't have any pending sense. */ - if (lun == NULL) - goto no_sense; + if (lun == NULL || + ((lun->flags & CTL_LUN_PRIMARY_SC) == 0 && + softc->ha_link < CTL_HA_LINK_UNKNOWN)) { + /* "Logical unit not supported" */ + ctl_set_sense_data(sense_ptr, NULL, sense_format, + /*current_error*/ 1, + /*sense_key*/ SSD_KEY_ILLEGAL_REQUEST, + /*asc*/ 0x25, + /*ascq*/ 0x00, + SSD_ELEM_NONE); + goto send; + } have_error = 0; initidx = ctl_get_initindex(&ctsio->io_hdr.nexus); @@ -9297,61 +9307,39 @@ ctl_request_sense(struct ctl_scsiio *cts have_error = 1; } else #endif - { + if (have_error == 0) { ua_type = ctl_build_ua(lun, initidx, sense_ptr, sense_format); if (ua_type != CTL_UA_NONE) have_error = 1; if (ua_type == CTL_UA_LUN_CHANGE) { mtx_unlock(&lun->lun_lock); - mtx_lock(&ctl_softc->ctl_lock); - ctl_clr_ua_allluns(ctl_softc, initidx, ua_type); - mtx_unlock(&ctl_softc->ctl_lock); + mtx_lock(&softc->ctl_lock); + ctl_clr_ua_allluns(softc, initidx, ua_type); + mtx_unlock(&softc->ctl_lock); mtx_lock(&lun->lun_lock); } - } - mtx_unlock(&lun->lun_lock); - - /* - * We already have a pending error, return it. - */ - if (have_error != 0) { + if (have_error == 0) { /* - * We report the SCSI status as OK, since the status of the - * request sense command itself is OK. - * We report 0 for the sense length, because we aren't doing - * autosense in this case. We're reporting sense as - * parameter data. + * Report informational exception if have one and allowed. */ - ctl_set_success(ctsio); - ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; - ctsio->be_move_done = ctl_config_move_done; - ctl_datamove((union ctl_io *)ctsio); - return (CTL_RETVAL_COMPLETE); + if (lun->mode_pages.ie_page[CTL_PAGE_CURRENT].mrie != SIEP_MRIE_NO) { + asc = lun->ie_asc; + ascq = lun->ie_ascq; + } + ctl_set_sense_data(sense_ptr, lun, sense_format, + /*current_error*/ 1, + /*sense_key*/ SSD_KEY_NO_SENSE, + /*asc*/ asc, + /*ascq*/ ascq, + SSD_ELEM_NONE); } + mtx_unlock(&lun->lun_lock); +send: /* - * No sense information to report, so we report that everything is - * okay, unless we have allowed Informational Exception. - */ - if (lun->mode_pages.ie_page[CTL_PAGE_CURRENT].mrie != SIEP_MRIE_NO) { - asc = lun->ie_asc; - ascq = lun->ie_ascq; - } - -no_sense: - ctl_set_sense_data(sense_ptr, - lun, - sense_format, - /*current_error*/ 1, - /*sense_key*/ SSD_KEY_NO_SENSE, - /*asc*/ asc, - /*ascq*/ ascq, - SSD_ELEM_NONE); - - /* - * We report 0 for the sense length, because we aren't doing - * autosense in this case. We're reporting sense as parameter data. + * We report the SCSI status as OK, since the status of the command + * itself is OK. We're reporting sense as parameter data. */ ctl_set_success(ctsio); ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; From owner-svn-src-head@freebsd.org Mon Dec 19 13:25:54 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B2376C87D69; Mon, 19 Dec 2016 13:25:54 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 7323DF66; Mon, 19 Dec 2016 13:25:54 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBJDPr0H079367; Mon, 19 Dec 2016 13:25:53 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBJDPr8h079364; Mon, 19 Dec 2016 13:25:53 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201612191325.uBJDPr8h079364@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Mon, 19 Dec 2016 13:25:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310265 - head/sys/cam/ctl X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 13:25:54 -0000 Author: mav Date: Mon Dec 19 13:25:53 2016 New Revision: 310265 URL: https://svnweb.freebsd.org/changeset/base/310265 Log: Add set of macros to simplify code access to mode pages fields. MFC after: 2 weeks Modified: head/sys/cam/ctl/ctl.c head/sys/cam/ctl/ctl_error.c head/sys/cam/ctl/ctl_private.h Modified: head/sys/cam/ctl/ctl.c ============================================================================== --- head/sys/cam/ctl/ctl.c Mon Dec 19 13:14:39 2016 (r310264) +++ head/sys/cam/ctl/ctl.c Mon Dec 19 13:25:53 2016 (r310265) @@ -5869,21 +5869,19 @@ static void ctl_ie_timer(void *arg) { struct ctl_lun *lun = arg; - struct scsi_info_exceptions_page *pg; uint64_t t; if (lun->ie_asc == 0) return; - pg = &lun->mode_pages.ie_page[CTL_PAGE_CURRENT]; - if (pg->mrie == SIEP_MRIE_UA) + if (lun->MODE_IE.mrie == SIEP_MRIE_UA) ctl_est_ua_all(lun, -1, CTL_UA_IE); else lun->ie_reported = 0; - if (lun->ie_reportcnt < scsi_4btoul(pg->report_count)) { + if (lun->ie_reportcnt < scsi_4btoul(lun->MODE_IE.report_count)) { lun->ie_reportcnt++; - t = scsi_4btoul(pg->interval_timer); + t = scsi_4btoul(lun->MODE_IE.interval_timer); if (t == 0 || t == UINT32_MAX) t = 3000; /* 5 min */ callout_schedule(&lun->ie_callout, t * hz / 10); @@ -6477,9 +6475,8 @@ ctl_mode_sense(struct ctl_scsiio *ctsio) if (lun->be_lun->lun_type == T_DIRECT) { header->dev_specific = 0x10; /* DPOFUA */ if ((lun->be_lun->flags & CTL_LUN_FLAG_READONLY) || - (lun->mode_pages.control_page[CTL_PAGE_CURRENT] - .eca_and_aen & SCP_SWP) != 0) - header->dev_specific |= 0x80; /* WP */ + (lun->MODE_CTRL.eca_and_aen & SCP_SWP) != 0) + header->dev_specific |= 0x80; /* WP */ } if (dbd) header->block_descr_len = 0; @@ -6500,9 +6497,8 @@ ctl_mode_sense(struct ctl_scsiio *ctsio) if (lun->be_lun->lun_type == T_DIRECT) { header->dev_specific = 0x10; /* DPOFUA */ if ((lun->be_lun->flags & CTL_LUN_FLAG_READONLY) || - (lun->mode_pages.control_page[CTL_PAGE_CURRENT] - .eca_and_aen & SCP_SWP) != 0) - header->dev_specific |= 0x80; /* WP */ + (lun->MODE_CTRL.eca_and_aen & SCP_SWP) != 0) + header->dev_specific |= 0x80; /* WP */ } if (dbd) scsi_ulto2b(0, header->block_descr_len); @@ -8807,12 +8803,10 @@ ctl_read_write(struct ctl_scsiio *ctsio) /* Set FUA and/or DPO if caches are disabled. */ if (isread) { - if ((lun->mode_pages.caching_page[CTL_PAGE_CURRENT].flags1 & - SCP_RCD) != 0) + if ((lun->MODE_CACHING.flags1 & SCP_RCD) != 0) flags |= CTL_LLF_FUA | CTL_LLF_DPO; } else { - if ((lun->mode_pages.caching_page[CTL_PAGE_CURRENT].flags1 & - SCP_WCE) == 0) + if ((lun->MODE_CACHING.flags1 & SCP_WCE) == 0) flags |= CTL_LLF_FUA; } @@ -8915,8 +8909,7 @@ ctl_cnw(struct ctl_scsiio *ctsio) } /* Set FUA if write cache is disabled. */ - if ((lun->mode_pages.caching_page[CTL_PAGE_CURRENT].flags1 & - SCP_WCE) == 0) + if ((lun->MODE_CACHING.flags1 & SCP_WCE) == 0) flags |= CTL_LLF_FUA; ctsio->kern_total_len = 2 * num_blocks * lun->be_lun->blocksize; @@ -9323,7 +9316,7 @@ ctl_request_sense(struct ctl_scsiio *cts /* * Report informational exception if have one and allowed. */ - if (lun->mode_pages.ie_page[CTL_PAGE_CURRENT].mrie != SIEP_MRIE_NO) { + if (lun->MODE_IE.mrie != SIEP_MRIE_NO) { asc = lun->ie_asc; ascq = lun->ie_ascq; } @@ -11088,8 +11081,8 @@ ctl_check_for_blockage(struct ctl_lun *l return (ctl_extent_check(ooa_io, pending_io, (lun->be_lun && lun->be_lun->serseq == CTL_LUN_SERSEQ_ON))); case CTL_SER_EXTENTOPT: - if ((lun->mode_pages.control_page[CTL_PAGE_CURRENT].queue_flags - & SCP_QUEUE_ALG_MASK) != SCP_QUEUE_ALG_UNRESTRICTED) + if ((lun->MODE_CTRL.queue_flags & SCP_QUEUE_ALG_MASK) != + SCP_QUEUE_ALG_UNRESTRICTED) return (ctl_extent_check(ooa_io, pending_io, (lun->be_lun && lun->be_lun->serseq == CTL_LUN_SERSEQ_ON))); @@ -11101,8 +11094,8 @@ ctl_check_for_blockage(struct ctl_lun *l case CTL_SER_PASS: return (CTL_ACTION_PASS); case CTL_SER_BLOCKOPT: - if ((lun->mode_pages.control_page[CTL_PAGE_CURRENT].queue_flags - & SCP_QUEUE_ALG_MASK) != SCP_QUEUE_ALG_UNRESTRICTED) + if ((lun->MODE_CTRL.queue_flags & SCP_QUEUE_ALG_MASK) != + SCP_QUEUE_ALG_UNRESTRICTED) return (CTL_ACTION_BLOCK); return (CTL_ACTION_PASS); case CTL_SER_SKIP: @@ -11343,8 +11336,7 @@ ctl_scsiio_lun_check(struct ctl_lun *lun retval = 1; goto bailout; } - if ((lun->mode_pages.control_page[CTL_PAGE_CURRENT] - .eca_and_aen & SCP_SWP) != 0) { + if ((lun->MODE_CTRL.eca_and_aen & SCP_SWP) != 0) { ctl_set_sense(ctsio, /*current_error*/ 1, /*sense_key*/ SSD_KEY_DATA_PROTECT, /*asc*/ 0x27, /*ascq*/ 0x02, SSD_ELEM_NONE); @@ -13211,12 +13203,9 @@ ctl_process_done(union ctl_io *io) if (lun->ie_reported == 0 && lun->ie_asc != 0 && io->io_hdr.status == CTL_SUCCESS && (io->io_hdr.flags & CTL_FLAG_STATUS_SENT) == 0) { - uint8_t mrie = lun->mode_pages.ie_page[CTL_PAGE_CURRENT].mrie; - uint8_t per = - ((lun->mode_pages.rw_er_page[CTL_PAGE_CURRENT].byte3 & - SMS_RWER_PER) || - (lun->mode_pages.verify_er_page[CTL_PAGE_CURRENT].byte3 & - SMS_VER_PER)); + uint8_t mrie = lun->MODE_IE.mrie; + uint8_t per = ((lun->MODE_RWER.byte3 & SMS_RWER_PER) || + (lun->MODE_VER.byte3 & SMS_VER_PER)); if (((mrie == SIEP_MRIE_REC_COND && per) || mrie == SIEP_MRIE_REC_UNCOND || mrie == SIEP_MRIE_NO_SENSE) && @@ -13622,7 +13611,6 @@ ctl_thresh_thread(void *arg) { struct ctl_softc *softc = (struct ctl_softc *)arg; struct ctl_lun *lun; - struct scsi_da_rw_recovery_page *rwpage; struct ctl_logical_block_provisioning_page *page; const char *attr; union ctl_ha_msg msg; @@ -13641,11 +13629,10 @@ ctl_thresh_thread(void *arg) if ((lun->flags & CTL_LUN_PRIMARY_SC) == 0 && softc->ha_mode == CTL_HA_MODE_XFER) continue; - rwpage = &lun->mode_pages.rw_er_page[CTL_PAGE_CURRENT]; - if ((rwpage->byte8 & SMS_RWER_LBPERE) == 0) + if ((lun->MODE_RWER.byte8 & SMS_RWER_LBPERE) == 0) continue; e = 0; - page = &lun->mode_pages.lbp_page[CTL_PAGE_CURRENT]; + page = &lun->MODE_LBP; for (i = 0; i < CTL_NUM_LBP_THRESH; i++) { if ((page->descr[i].flags & SLBPPD_ENABLED) == 0) continue; Modified: head/sys/cam/ctl/ctl_error.c ============================================================================== --- head/sys/cam/ctl/ctl_error.c Mon Dec 19 13:14:39 2016 (r310264) +++ head/sys/cam/ctl/ctl_error.c Mon Dec 19 13:25:53 2016 (r310265) @@ -83,9 +83,7 @@ ctl_set_sense_data_va(struct scsi_sense_ * sense if the LUN exists and descriptor sense is turned * on for that LUN. */ - if ((lun != NULL) - && (lun->mode_pages.control_page[CTL_PAGE_CURRENT].rlec & - SCP_DSENSE)) + if ((lun != NULL) && (lun->MODE_CTRL.rlec & SCP_DSENSE)) sense_format = SSD_TYPE_DESC; else sense_format = SSD_TYPE_FIXED; Modified: head/sys/cam/ctl/ctl_private.h ============================================================================== --- head/sys/cam/ctl/ctl_private.h Mon Dec 19 13:14:39 2016 (r310264) +++ head/sys/cam/ctl/ctl_private.h Mon Dec 19 13:25:53 2016 (r310265) @@ -313,6 +313,17 @@ struct ctl_mode_pages { struct ctl_page_index index[CTL_NUM_MODE_PAGES]; }; +#define MODE_RWER mode_pages.rw_er_page[CTL_PAGE_CURRENT] +#define MODE_FMT mode_pages.format_page[CTL_PAGE_CURRENT] +#define MODE_RDISK mode_pages.rigid_disk_page[CTL_PAGE_CURRENT] +#define MODE_VER mode_pages.verify_er_page[CTL_PAGE_CURRENT] +#define MODE_CACHING mode_pages.caching_page[CTL_PAGE_CURRENT] +#define MODE_CTRL mode_pages.control_page[CTL_PAGE_CURRENT] +#define MODE_CTRLE mode_pages.control_ext_page[CTL_PAGE_CURRENT] +#define MODE_IE mode_pages.ie_page[CTL_PAGE_CURRENT] +#define MODE_LBP mode_pages.lbp_page[CTL_PAGE_CURRENT] +#define MODE_CDDVD mode_pages.cddvd_page[CTL_PAGE_CURRENT] + static const struct ctl_page_index log_page_index_template[] = { {SLS_SUPPORTED_PAGES_PAGE, 0, 0, NULL, CTL_PAGE_FLAG_ALL, NULL, NULL}, From owner-svn-src-head@freebsd.org Mon Dec 19 14:19:54 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4686BC88082; Mon, 19 Dec 2016 14:19:54 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 F08A51EBA; Mon, 19 Dec 2016 14:19:53 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBJEJrlo099317; Mon, 19 Dec 2016 14:19:53 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBJEJra4099316; Mon, 19 Dec 2016 14:19:53 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201612191419.uBJEJra4099316@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Mon, 19 Dec 2016 14:19:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310266 - head/sys/cam/ctl X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 14:19:54 -0000 Author: mav Date: Mon Dec 19 14:19:52 2016 New Revision: 310266 URL: https://svnweb.freebsd.org/changeset/base/310266 Log: Add support for NUAR bit in Control mode page. MFC after: 2 weeks Modified: head/sys/cam/ctl/ctl.c Modified: head/sys/cam/ctl/ctl.c ============================================================================== --- head/sys/cam/ctl/ctl.c Mon Dec 19 13:25:53 2016 (r310265) +++ head/sys/cam/ctl/ctl.c Mon Dec 19 14:19:52 2016 (r310266) @@ -253,7 +253,7 @@ const static struct scsi_control_page co /*page_code*/SMS_CONTROL_MODE_PAGE, /*page_length*/sizeof(struct scsi_control_page) - 2, /*rlec*/SCP_DSENSE, - /*queue_flags*/SCP_QUEUE_ALG_MASK, + /*queue_flags*/SCP_QUEUE_ALG_MASK | SCP_NUAR, /*eca_and_aen*/SCP_SWP, /*flags4*/0, /*aen_holdoff_period*/{0, 0}, @@ -8440,12 +8440,11 @@ ctl_persistent_reserve_out(struct ctl_sc lun->pr_res_type = 0; /* - * if this isn't an exclusive access - * res generate UA for all other - * registrants. + * If this isn't an exclusive access reservation and NUAR + * is not set, generate UA for all other registrants. */ - if (type != SPR_TYPE_EX_AC - && type != SPR_TYPE_WR_EX) { + if (type != SPR_TYPE_EX_AC && type != SPR_TYPE_WR_EX && + (lun->MODE_CTRL.queue_flags & SCP_NUAR) == 0) { for (i = softc->init_min; i < softc->init_max; i++) { if (i == residx || ctl_get_prkey(lun, i) == 0) continue; @@ -8595,11 +8594,12 @@ ctl_hndl_per_res_out_on_other_sc(union c case CTL_PR_RELEASE: /* - * if this isn't an exclusive access res generate UA for all - * other registrants. + * If this isn't an exclusive access reservation and NUAR + * is not set, generate UA for all other registrants. */ if (lun->pr_res_type != SPR_TYPE_EX_AC && - lun->pr_res_type != SPR_TYPE_WR_EX) { + lun->pr_res_type != SPR_TYPE_WR_EX && + (lun->MODE_CTRL.queue_flags & SCP_NUAR) == 0) { for (i = softc->init_min; i < softc->init_max; i++) if (i == residx || ctl_get_prkey(lun, i) == 0) continue; From owner-svn-src-head@freebsd.org Mon Dec 19 14:41:01 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9F506C88711; Mon, 19 Dec 2016 14:41:01 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 65B8D1CC8; Mon, 19 Dec 2016 14:41:01 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBJEf0fC008582; Mon, 19 Dec 2016 14:41:00 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBJEexcV008565; Mon, 19 Dec 2016 14:40:59 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201612191440.uBJEexcV008565@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Mon, 19 Dec 2016 14:40:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310267 - in head/sys/boot: arm/uboot common efi/loader i386/loader mips/beri/loader mips/uboot pc98/loader powerpc/kboot powerpc/ofw powerpc/ps3 powerpc/uboot sparc64/loader userboot/u... X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 14:41:01 -0000 Author: emaste Date: Mon Dec 19 14:40:59 2016 New Revision: 310267 URL: https://svnweb.freebsd.org/changeset/base/310267 Log: Deduplicate loader vers.c Makefile rules The Makefile rule to create vers.c for loader version info was previously duplicated in each of the various loader Makefiles. Instead, share a common rule in Makefile.inc. Reviewed by: bapt MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D8841 Modified: head/sys/boot/arm/uboot/Makefile head/sys/boot/common/Makefile.inc head/sys/boot/efi/loader/Makefile head/sys/boot/i386/loader/Makefile head/sys/boot/mips/beri/loader/Makefile head/sys/boot/mips/uboot/Makefile head/sys/boot/pc98/loader/Makefile head/sys/boot/powerpc/kboot/Makefile head/sys/boot/powerpc/ofw/Makefile head/sys/boot/powerpc/ps3/Makefile head/sys/boot/powerpc/uboot/Makefile head/sys/boot/sparc64/loader/Makefile head/sys/boot/userboot/userboot/Makefile Modified: head/sys/boot/arm/uboot/Makefile ============================================================================== --- head/sys/boot/arm/uboot/Makefile Mon Dec 19 14:19:52 2016 (r310266) +++ head/sys/boot/arm/uboot/Makefile Mon Dec 19 14:40:59 2016 (r310267) @@ -90,7 +90,7 @@ LIBFICL= ${.OBJDIR}/../../ficl/libficl.a CFLAGS+= -I${.CURDIR}/../../common CFLAGS+= -I. -CLEANFILES+= vers.c loader.help +CLEANFILES+= loader.help CFLAGS+= -ffreestanding -msoft-float @@ -119,9 +119,6 @@ LDADD= ${LIBFICL} ${LIBUBOOT} ${LIBFDT} OBJS+= ${SRCS:N*.h:R:S/$/.o/g} -vers.c: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version - sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT} - loader.help: help.common help.uboot ${.CURDIR}/../../fdt/help.fdt cat ${.ALLSRC} | \ awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET} Modified: head/sys/boot/common/Makefile.inc ============================================================================== --- head/sys/boot/common/Makefile.inc Mon Dec 19 14:19:52 2016 (r310266) +++ head/sys/boot/common/Makefile.inc Mon Dec 19 14:40:59 2016 (r310267) @@ -71,3 +71,8 @@ CFLAGS+= -DBOOT_PROMPT_123 SRCS+= install.c CFLAGS+=-I${.CURDIR}/../../../../lib/libstand .endif + +CLEANFILES+= vers.c +VERSION_FILE?= ${.CURDIR}/version +vers.c: ${SRCTOP}/sys/boot/common/newvers.sh ${VERSION_FILE} + sh ${SRCTOP}/sys/boot/common/newvers.sh ${VERSION_FILE} ${NEWVERSWHAT} Modified: head/sys/boot/efi/loader/Makefile ============================================================================== --- head/sys/boot/efi/loader/Makefile Mon Dec 19 14:19:52 2016 (r310266) +++ head/sys/boot/efi/loader/Makefile Mon Dec 19 14:40:59 2016 (r310267) @@ -115,13 +115,10 @@ FILESMODE_loader.efi= ${BINMODE} LDSCRIPT= ${.CURDIR}/arch/${MACHINE}/ldscript.${MACHINE} LDFLAGS+= -Wl,-T${LDSCRIPT} -Wl,-Bsymbolic -shared -CLEANFILES+= vers.c loader.efi +CLEANFILES+= loader.efi NEWVERSWHAT= "EFI loader" ${MACHINE} -vers.c: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/../../efi/loader/version - sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT} - NM?= nm OBJCOPY?= objcopy Modified: head/sys/boot/i386/loader/Makefile ============================================================================== --- head/sys/boot/i386/loader/Makefile Mon Dec 19 14:19:52 2016 (r310266) +++ head/sys/boot/i386/loader/Makefile Mon Dec 19 14:40:59 2016 (r310267) @@ -8,6 +8,7 @@ PROG= ${LOADER}.sym MAN= INTERNALPROG= NEWVERSWHAT?= "bootstrap loader" x86 +VERSION_FILE= ${.CURDIR}/../loader/version # architecture-specific loader code SRCS= main.c conf.c vers.c @@ -72,7 +73,7 @@ CFLAGS+= -I${.CURDIR}/../../.. -D_STAND CFLAGS+= -I${.CURDIR}/../../common CFLAGS+= -I. -CLEANFILES= vers.c ${LOADER} ${LOADER}.bin loader.help +CLEANFILES= ${LOADER} ${LOADER}.bin loader.help CFLAGS+= -Wall LDFLAGS= -static -Ttext 0x0 @@ -93,10 +94,6 @@ CFLAGS+= -I${.CURDIR}/../btx/lib # Pick up ../Makefile.inc early. .include -vers.c: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/../loader/version - sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/../loader/version \ - ${NEWVERSWHAT} - ${LOADER}: ${LOADER}.bin ${BTXLDR} ${BTXKERN} btxld -v -f aout -e ${LOADER_ADDRESS} -o ${.TARGET} -l ${BTXLDR} \ -b ${BTXKERN} ${LOADER}.bin Modified: head/sys/boot/mips/beri/loader/Makefile ============================================================================== --- head/sys/boot/mips/beri/loader/Makefile Mon Dec 19 14:19:52 2016 (r310266) +++ head/sys/boot/mips/beri/loader/Makefile Mon Dec 19 14:40:59 2016 (r310267) @@ -92,7 +92,7 @@ CFLAGS+= -I${.CURDIR}/../common # Loader-specific MD headers CFLAGS+= -I${.CURDIR} -CLEANFILES+= vers.c loader.help +CLEANFILES+= loader.help # Generate code appropriate for the loader environment CFLAGS+= -G0 \ @@ -114,10 +114,6 @@ LIBSTAND= ${.OBJDIR}/../../../../../lib/ DPADD= ${LIBFICL} ${LIBSTAND} LDADD= ${LIBFICL} ${LIBSTAND} -vers.c: ${.CURDIR}/../../../common/newvers.sh ${.CURDIR}/version - sh ${.CURDIR}/../../../common/newvers.sh ${.CURDIR}/version \ - ${NEWVERSWHAT} - loader.help: help.common help.mips cat ${.ALLSRC} | \ awk -f ${.CURDIR}/../../../common/merge_help.awk > ${.TARGET} Modified: head/sys/boot/mips/uboot/Makefile ============================================================================== --- head/sys/boot/mips/uboot/Makefile Mon Dec 19 14:19:52 2016 (r310266) +++ head/sys/boot/mips/uboot/Makefile Mon Dec 19 14:40:59 2016 (r310267) @@ -99,7 +99,7 @@ LIBFICL= ${.OBJDIR}/../../ficl/libficl.a CFLAGS+= -I${.CURDIR}/../../common CFLAGS+= -I. -CLEANFILES+= vers.c loader.help +CLEANFILES+= loader.help CFLAGS+= -ffreestanding -msoft-float -g @@ -128,9 +128,6 @@ LDADD= ${LIBFICL} ${LIBUBOOT} ${LIBFDT} OBJS+= ${SRCS:N*.h:R:S/$/.o/g} -vers.c: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version - sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT} - loader.help: help.common help.uboot ${.CURDIR}/../../fdt/help.fdt cat ${.ALLSRC} | \ awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET} Modified: head/sys/boot/pc98/loader/Makefile ============================================================================== --- head/sys/boot/pc98/loader/Makefile Mon Dec 19 14:19:52 2016 (r310266) +++ head/sys/boot/pc98/loader/Makefile Mon Dec 19 14:40:59 2016 (r310267) @@ -8,6 +8,7 @@ LOADER?= loader PROG= ${LOADER}.sym INTERNALPROG= NEWVERSWHAT= "bootstrap loader" pc98 +VERSION_FILE= ${.CURDIR}/../../i386/loader/version # architecture-specific loader code SRCS= main.c conf.c vers.c @@ -48,7 +49,7 @@ CFLAGS+= -I${.CURDIR}/../../common CFLAGS+= -I${.CURDIR}/../../i386 CFLAGS+= -I. -CLEANFILES= vers.c ${LOADER} ${LOADER}.bin loader.help +CLEANFILES= ${LOADER} ${LOADER}.bin loader.help CFLAGS+= -Wall LDFLAGS= -static -Ttext 0x0 @@ -69,9 +70,6 @@ CFLAGS+= -I${.CURDIR}/../btx/lib # Pick up ../Makefile.inc early. .include -vers.c: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/../../i386/loader/version - sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/../../i386/loader/version ${NEWVERSWHAT} - ${LOADER}: ${LOADER}.bin ${BTXLDR} ${BTXKERN} btxld -v -f aout -e ${LOADER_ADDRESS} -o ${.TARGET} -l ${BTXLDR} \ -b ${BTXKERN} ${LOADER}.bin Modified: head/sys/boot/powerpc/kboot/Makefile ============================================================================== --- head/sys/boot/powerpc/kboot/Makefile Mon Dec 19 14:19:52 2016 (r310266) +++ head/sys/boot/powerpc/kboot/Makefile Mon Dec 19 14:40:59 2016 (r310267) @@ -76,7 +76,7 @@ CFLAGS+= -mcpu=powerpc64 CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../../.. CFLAGS+= -I. -CLEANFILES+= vers.c loader.help +CLEANFILES+= loader.help CFLAGS+= -Wall -ffreestanding -msoft-float -DAIM # load address. set in linker script @@ -99,9 +99,6 @@ CFLAGS+= -I${.CURDIR}/../../../../lib/li DPADD= ${LIBFICL} ${LIBOFW} ${LIBFDT} ${LIBSTAND} LDADD= ${LIBFICL} ${LIBOFW} ${LIBFDT} ${LIBSTAND} -vers.c: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version - sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT} - loader.help: help.common help.kboot ${.CURDIR}/../../fdt/help.fdt cat ${.ALLSRC} | \ awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET} Modified: head/sys/boot/powerpc/ofw/Makefile ============================================================================== --- head/sys/boot/powerpc/ofw/Makefile Mon Dec 19 14:19:52 2016 (r310266) +++ head/sys/boot/powerpc/ofw/Makefile Mon Dec 19 14:40:59 2016 (r310267) @@ -73,7 +73,7 @@ LIBFICL= ${.OBJDIR}/../../ficl/libficl.a CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../../.. CFLAGS+= -I. -CLEANFILES+= vers.c loader.help +CLEANFILES+= loader.help CFLAGS+= -ffreestanding -msoft-float # load address. set in linker script @@ -97,9 +97,6 @@ CFLAGS+= -I${.CURDIR}/../../../../lib/li DPADD= ${LIBFICL} ${LIBOFW} ${LIBFDT} ${LIBSTAND} LDADD= ${LIBFICL} ${LIBOFW} ${LIBFDT} ${LIBSTAND} -vers.c: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version - sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT} - loader.help: help.common help.ofw ${.CURDIR}/../../fdt/help.fdt cat ${.ALLSRC} | \ awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET} Modified: head/sys/boot/powerpc/ps3/Makefile ============================================================================== --- head/sys/boot/powerpc/ps3/Makefile Mon Dec 19 14:19:52 2016 (r310266) +++ head/sys/boot/powerpc/ps3/Makefile Mon Dec 19 14:40:59 2016 (r310267) @@ -76,7 +76,7 @@ CFLAGS+= -mcpu=powerpc64 CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../../.. CFLAGS+= -I. -CLEANFILES+= vers.c loader.help +CLEANFILES+= loader.help CFLAGS+= -Wall -ffreestanding -msoft-float -DAIM # load address. set in linker script @@ -101,9 +101,6 @@ SC_DFLT_FONT=cp437 font.h: uudecode < /usr/share/syscons/fonts/${SC_DFLT_FONT}-8x16.fnt && file2c 'u_char dflt_font_16[16*256] = {' '};' < ${SC_DFLT_FONT}-8x16 > font.h && uudecode < /usr/share/syscons/fonts/${SC_DFLT_FONT}-8x14.fnt && file2c 'u_char dflt_font_14[14*256] = {' '};' < ${SC_DFLT_FONT}-8x14 >> font.h && uudecode < /usr/share/syscons/fonts/${SC_DFLT_FONT}-8x8.fnt && file2c 'u_char dflt_font_8[8*256] = {' '};' < ${SC_DFLT_FONT}-8x8 >> font.h -vers.c: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version - sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT} - loader.help: help.common help.ps3 ${.CURDIR}/../../fdt/help.fdt cat ${.ALLSRC} | \ awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET} Modified: head/sys/boot/powerpc/uboot/Makefile ============================================================================== --- head/sys/boot/powerpc/uboot/Makefile Mon Dec 19 14:19:52 2016 (r310266) +++ head/sys/boot/powerpc/uboot/Makefile Mon Dec 19 14:40:59 2016 (r310267) @@ -79,7 +79,7 @@ LIBFICL= ${.OBJDIR}/../../ficl/libficl.a CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../../.. CFLAGS+= -I. -CLEANFILES+= vers.c ${PROG}.help +CLEANFILES+= ${PROG}.help CFLAGS+= -ffreestanding @@ -102,9 +102,6 @@ CFLAGS+= -I${.CURDIR}/../../../../lib/li DPADD= ${LIBFICL} ${LIBUBOOT} ${LIBFDT} ${LIBUBOOT_FDT} ${LIBSTAND} LDADD= ${LIBFICL} ${LIBUBOOT} ${LIBFDT} ${LIBUBOOT_FDT} ${LIBSTAND} -vers.c: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version - sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT} - loader.help: help.common help.uboot ${.CURDIR}/../../fdt/help.fdt cat ${.ALLSRC} | \ awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET} Modified: head/sys/boot/sparc64/loader/Makefile ============================================================================== --- head/sys/boot/sparc64/loader/Makefile Mon Dec 19 14:19:52 2016 (r310266) +++ head/sys/boot/sparc64/loader/Makefile Mon Dec 19 14:40:59 2016 (r310267) @@ -6,6 +6,7 @@ MAN= PROG?= loader NEWVERSWHAT?= "bootstrap loader" sparc64 +VERSION_FILE= ${.CURDIR}/../loader/version INSTALLFLAGS= -b # Architecture-specific loader code @@ -70,7 +71,7 @@ LIBFICL= ${.OBJDIR}/../../ficl/libficl.a CFLAGS+= -I${.CURDIR}/../../common CFLAGS+= -I. -CLEANFILES+= vers.c loader.help +CLEANFILES+= loader.help LDFLAGS= -static @@ -84,10 +85,6 @@ CFLAGS+= -I${.CURDIR}/../../../../lib/li DPADD= ${LIBFICL} ${LIBZFSBOOT} ${LIBOFW} ${LIBSTAND} LDADD= ${LIBFICL} ${LIBZFSBOOT} ${LIBOFW} -lstand -vers.c: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/../loader/version - sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/../loader/version \ - ${NEWVERSWHAT} - loader.help: help.common help.sparc64 cat ${.ALLSRC} | \ awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET} Modified: head/sys/boot/userboot/userboot/Makefile ============================================================================== --- head/sys/boot/userboot/userboot/Makefile Mon Dec 19 14:19:52 2016 (r310266) +++ head/sys/boot/userboot/userboot/Makefile Mon Dec 19 14:40:59 2016 (r310267) @@ -41,11 +41,6 @@ LDFLAGS+= -nostdlib -Wl,-Bsymbolic NEWVERSWHAT= "User boot" ${MACHINE_CPUARCH} -vers.c: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version - sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT} - -CLEANFILES= vers.c - .if ${MK_FORTH} != "no" BOOT_FORTH= yes CFLAGS+= -DBOOT_FORTH -I${.CURDIR}/../../ficl -I${.CURDIR}/../../ficl/i386 From owner-svn-src-head@freebsd.org Mon Dec 19 14:46:00 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8BED5C88976; Mon, 19 Dec 2016 14:46:00 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 5ED8E1FE0; Mon, 19 Dec 2016 14:46:00 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBJEjxPg011604; Mon, 19 Dec 2016 14:45:59 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBJEjxhD011600; Mon, 19 Dec 2016 14:45:59 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201612191445.uBJEjxhD011600@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Mon, 19 Dec 2016 14:45:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310268 - in head: share/mk sys/boot/common tools/build/options X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 14:46:00 -0000 Author: emaste Date: Mon Dec 19 14:45:59 2016 New Revision: 310268 URL: https://svnweb.freebsd.org/changeset/base/310268 Log: Build loaders reproducibly when WITH_REPRODUCIBLE_BUILD When WITH_REPRODUCIBLE_BUILD=yes is set in src.conf(5), eliminate the time, user, and host from the loader's version information. This allows builds to produce bit-for-bit identical output. Reviewed by: bapt MFC after: 1 month Relnotes: yes Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D8842 Modified: head/share/mk/src.opts.mk head/sys/boot/common/Makefile.inc head/sys/boot/common/newvers.sh head/tools/build/options/WITH_REPRODUCIBLE_BUILD Modified: head/share/mk/src.opts.mk ============================================================================== --- head/share/mk/src.opts.mk Mon Dec 19 14:40:59 2016 (r310267) +++ head/share/mk/src.opts.mk Mon Dec 19 14:45:59 2016 (r310268) @@ -190,6 +190,7 @@ __DEFAULT_NO_OPTIONS = \ OFED \ OPENLDAP \ RCS \ + REPRODUCIBLE_BUILD \ SHARED_TOOLCHAIN \ SORT_THREADS \ SVN \ Modified: head/sys/boot/common/Makefile.inc ============================================================================== --- head/sys/boot/common/Makefile.inc Mon Dec 19 14:40:59 2016 (r310267) +++ head/sys/boot/common/Makefile.inc Mon Dec 19 14:45:59 2016 (r310268) @@ -74,5 +74,9 @@ CFLAGS+=-I${.CURDIR}/../../../../lib/lib CLEANFILES+= vers.c VERSION_FILE?= ${.CURDIR}/version +.if ${MK_REPRODUCIBLE_BUILD} != no +REPRO_FLAG= -r +.endif vers.c: ${SRCTOP}/sys/boot/common/newvers.sh ${VERSION_FILE} - sh ${SRCTOP}/sys/boot/common/newvers.sh ${VERSION_FILE} ${NEWVERSWHAT} + sh ${SRCTOP}/sys/boot/common/newvers.sh ${REPRO_FLAG} ${VERSION_FILE} \ + ${NEWVERSWHAT} Modified: head/sys/boot/common/newvers.sh ============================================================================== --- head/sys/boot/common/newvers.sh Mon Dec 19 14:40:59 2016 (r310267) +++ head/sys/boot/common/newvers.sh Mon Dec 19 14:45:59 2016 (r310268) @@ -35,11 +35,26 @@ tempfile=$(mktemp tmp.XXXXXX) || exit trap "rm -f $tempfile" EXIT INT TERM +include_metadata=true +while getopts r opt; do + case "$opt" in + r) + include_metadata= + ;; + esac +done +shift $((OPTIND - 1)) + LC_ALL=C; export LC_ALL u=${USER-root} h=${HOSTNAME-`hostname`} t=`date` #r=`head -n 6 $1 | tail -n 1 | awk -F: ' { print $1 } '` r=`awk -F: ' /^[0-9]\.[0-9]+:/ { print $1; exit }' $1` -echo "char bootprog_info[] = \"FreeBSD/${3} ${2}, Revision ${r}\\n(${t} ${u}@${h})\\n\";" > $tempfile +bootprog_info="FreeBSD/${3} ${2}, Revision ${r}\\n" +if [ -n "${include_metadata}" ]; then + bootprog_info="$bootprog_info(${t} ${u}@${h})\\n" +fi + +echo "char bootprog_info[] = \"$bootprog_info\";" > $tempfile echo "unsigned bootprog_rev = ${r%%.*}${r##*.};" >> $tempfile mv $tempfile vers.c Modified: head/tools/build/options/WITH_REPRODUCIBLE_BUILD ============================================================================== --- head/tools/build/options/WITH_REPRODUCIBLE_BUILD Mon Dec 19 14:40:59 2016 (r310267) +++ head/tools/build/options/WITH_REPRODUCIBLE_BUILD Mon Dec 19 14:45:59 2016 (r310268) @@ -1,3 +1,4 @@ $FreeBSD$ -Set to exclude build metadata (build time, user, host and path) from the -kernel and uname output. +Set to exclude build metadata (such as the build time, user, or host) +from the kernel, boot loaders, and uname output, so that builds produce +bit-for-bit identical output. From owner-svn-src-head@freebsd.org Mon Dec 19 14:54:07 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id ACB62C88B3C; Mon, 19 Dec 2016 14:54:07 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 714DE163B; Mon, 19 Dec 2016 14:54:07 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBJEs6q7015807; Mon, 19 Dec 2016 14:54:06 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBJEs6aO015806; Mon, 19 Dec 2016 14:54:06 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201612191454.uBJEs6aO015806@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Mon, 19 Dec 2016 14:54:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310269 - head/share/man/man5 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 14:54:07 -0000 Author: emaste Date: Mon Dec 19 14:54:06 2016 New Revision: 310269 URL: https://svnweb.freebsd.org/changeset/base/310269 Log: src.conf.5: regen after r310268 (WITH_REPRODUCIBLE_BUILD) Modified: head/share/man/man5/src.conf.5 Modified: head/share/man/man5/src.conf.5 ============================================================================== --- head/share/man/man5/src.conf.5 Mon Dec 19 14:45:59 2016 (r310268) +++ head/share/man/man5/src.conf.5 Mon Dec 19 14:54:06 2016 (r310269) @@ -1,7 +1,7 @@ .\" DO NOT EDIT-- this file is automatically generated. .\" from FreeBSD: head/tools/build/options/makeman 306729 2016-10-05 20:12:00Z emaste .\" $FreeBSD$ -.Dd December 10, 2016 +.Dd December 19, 2016 .Dt SRC.CONF 5 .Os .Sh NAME @@ -1368,6 +1368,11 @@ This includes .Xr rlogin 1 , .Xr rsh 1 , etc. +.It Va WITH_REPRODUCIBLE_BUILD +from FreeBSD: head/tools/build/options/WITH_REPRODUCIBLE_BUILD 310268 2016-12-19 14:45:59Z emaste +Set to exclude build metadata (such as the build time, user, or host) +from the kernel, boot loaders, and uname output, so that builds produce +bit-for-bit identical output. .It Va WITHOUT_RESCUE .\" from FreeBSD: head/tools/build/options/WITHOUT_RESCUE 156932 2006-03-21 07:50:50Z ru Set to not build From owner-svn-src-head@freebsd.org Mon Dec 19 15:05:47 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 60A3CC88E69; Mon, 19 Dec 2016 15:05:47 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 254FA1F17; Mon, 19 Dec 2016 15:05:47 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBJF5kTB020204; Mon, 19 Dec 2016 15:05:46 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBJF5km6020203; Mon, 19 Dec 2016 15:05:46 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201612191505.uBJF5km6020203@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Mon, 19 Dec 2016 15:05:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310270 - head/share/man/man5 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 15:05:47 -0000 Author: emaste Date: Mon Dec 19 15:05:46 2016 New Revision: 310270 URL: https://svnweb.freebsd.org/changeset/base/310270 Log: Restore missing comment in src.conf.5 I'm not sure how I managed to generate src.conf.5 without the comment; add it manually while looking into that. Reported by: gjb Modified: head/share/man/man5/src.conf.5 Modified: head/share/man/man5/src.conf.5 ============================================================================== --- head/share/man/man5/src.conf.5 Mon Dec 19 14:54:06 2016 (r310269) +++ head/share/man/man5/src.conf.5 Mon Dec 19 15:05:46 2016 (r310270) @@ -1369,7 +1369,7 @@ This includes .Xr rsh 1 , etc. .It Va WITH_REPRODUCIBLE_BUILD -from FreeBSD: head/tools/build/options/WITH_REPRODUCIBLE_BUILD 310268 2016-12-19 14:45:59Z emaste +.\" from FreeBSD: head/tools/build/options/WITH_REPRODUCIBLE_BUILD 310268 2016-12-19 14:45:59Z emaste Set to exclude build metadata (such as the build time, user, or host) from the kernel, boot loaders, and uname output, so that builds produce bit-for-bit identical output. From owner-svn-src-head@freebsd.org Mon Dec 19 15:09:31 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D4507C88F3F; Mon, 19 Dec 2016 15:09:31 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 A40BF11F1; Mon, 19 Dec 2016 15:09:31 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBJF9Uqd020365; Mon, 19 Dec 2016 15:09:30 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBJF9UwU020364; Mon, 19 Dec 2016 15:09:30 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <201612191509.uBJF9UwU020364@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Mon, 19 Dec 2016 15:09:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310271 - head/tools/build/options X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 15:09:31 -0000 Author: gjb Date: Mon Dec 19 15:09:30 2016 New Revision: 310271 URL: https://svnweb.freebsd.org/changeset/base/310271 Log: Comment the RCSID. Sponsored by: The FreeBSD Foundation Modified: head/tools/build/options/WITH_REPRODUCIBLE_BUILD Modified: head/tools/build/options/WITH_REPRODUCIBLE_BUILD ============================================================================== --- head/tools/build/options/WITH_REPRODUCIBLE_BUILD Mon Dec 19 15:05:46 2016 (r310270) +++ head/tools/build/options/WITH_REPRODUCIBLE_BUILD Mon Dec 19 15:09:30 2016 (r310271) @@ -1,4 +1,4 @@ -$FreeBSD$ +.\" $FreeBSD$ Set to exclude build metadata (such as the build time, user, or host) from the kernel, boot loaders, and uname output, so that builds produce bit-for-bit identical output. From owner-svn-src-head@freebsd.org Mon Dec 19 15:18:33 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 59206C880C5; Mon, 19 Dec 2016 15:18:33 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 0EE7C16F0; Mon, 19 Dec 2016 15:18:32 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBJFIWGA024401; Mon, 19 Dec 2016 15:18:32 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBJFIWNr024399; Mon, 19 Dec 2016 15:18:32 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201612191518.uBJFIWNr024399@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Mon, 19 Dec 2016 15:18:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310272 - in head/sys/cam: ctl scsi X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 15:18:33 -0000 Author: mav Date: Mon Dec 19 15:18:31 2016 New Revision: 310272 URL: https://svnweb.freebsd.org/changeset/base/310272 Log: Add new bits into Extended Inquiry VPD page. MFC after: 2 weeks Modified: head/sys/cam/ctl/ctl.c head/sys/cam/scsi/scsi_all.h Modified: head/sys/cam/ctl/ctl.c ============================================================================== --- head/sys/cam/ctl/ctl.c Mon Dec 19 15:09:30 2016 (r310271) +++ head/sys/cam/ctl/ctl.c Mon Dec 19 15:18:31 2016 (r310272) @@ -9542,7 +9542,7 @@ ctl_inquiry_evpd_eid(struct ctl_scsiio * * attention for a particular IT nexus on all LUNs once we report * it to that nexus once. This bit is required as of SPC-4. */ - eid_ptr->flags4 = SVPD_EID_LUICLT; + eid_ptr->flags4 = SVPD_EID_LUICLR; /* * XXX KDM in order to correctly answer this, we would need Modified: head/sys/cam/scsi/scsi_all.h ============================================================================== --- head/sys/cam/scsi/scsi_all.h Mon Dec 19 15:09:30 2016 (r310271) +++ head/sys/cam/scsi/scsi_all.h Mon Dec 19 15:18:31 2016 (r310272) @@ -2476,10 +2476,17 @@ struct scsi_vpd_extended_inquiry_data #define SVPD_EID_NV_SUP 0x02 #define SVPD_EID_V_SUP 0x01 uint8_t flags4; +#define SVPD_EID_NO_PI_CHK 0x20 #define SVPD_EID_P_I_I_SUP 0x10 -#define SVPD_EID_LUICLT 0x01 +#define SVPD_EID_LUICLR 0x01 uint8_t flags5; +#define SVPD_EID_LUCT_MASK 0xe0 +#define SVPD_EID_LUCT_NOT_REP 0x00 +#define SVPD_EID_LUCT_CONGL 0x20 +#define SVPD_EID_LUCT_GROUP 0x40 #define SVPD_EID_R_SUP 0x10 +#define SVPD_EID_RTD_SUP 0x08 +#define SVPD_EID_HSSRELEF 0x02 #define SVPD_EID_CBCS 0x01 uint8_t flags6; #define SVPD_EID_MULTI_I_T_FW 0x0F @@ -2490,10 +2497,16 @@ struct scsi_vpd_extended_inquiry_data uint8_t est[2]; uint8_t flags7; #define SVPD_EID_POA_SUP 0x80 -#define SVPD_EID_HRA_SUP 0x80 -#define SVPD_EID_VSA_SUP 0x80 +#define SVPD_EID_HRA_SUP 0x40 +#define SVPD_EID_VSA_SUP 0x20 uint8_t max_sense_length; - uint8_t reserved2[50]; + uint8_t bind_flags; +#define SVPD_EID_IBS 0x80 +#define SVPD_EID_IAS 0x40 +#define SVPD_EID_SAC 0x04 +#define SVPD_EID_NRD1 0x02 +#define SVPD_EID_NRD0 0x01 + uint8_t reserved2[49]; }; struct scsi_vpd_mode_page_policy_descr From owner-svn-src-head@freebsd.org Mon Dec 19 15:19:45 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 77B9BC8811D; Mon, 19 Dec 2016 15:19:45 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 4758B1890; Mon, 19 Dec 2016 15:19:45 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBJFJit3024485; Mon, 19 Dec 2016 15:19:44 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBJFJiQk024484; Mon, 19 Dec 2016 15:19:44 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201612191519.uBJFJiQk024484@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Mon, 19 Dec 2016 15:19:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310273 - head/sys/conf X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 15:19:45 -0000 Author: emaste Date: Mon Dec 19 15:19:44 2016 New Revision: 310273 URL: https://svnweb.freebsd.org/changeset/base/310273 Log: newvers.sh: add -R option to include metadata only for unmodified src tree Sponsored by: The FreeBSD Foundation Modified: head/sys/conf/newvers.sh Modified: head/sys/conf/newvers.sh ============================================================================== --- head/sys/conf/newvers.sh Mon Dec 19 15:18:31 2016 (r310272) +++ head/sys/conf/newvers.sh Mon Dec 19 15:19:44 2016 (r310273) @@ -37,6 +37,10 @@ # the output file. This is intended to allow two builds # done at different times and even by different people on # different hosts to produce identical output. +# +# -R Reproducible build if the tree represents an unmodified +# checkout from a version control system. Metadata is +# included if the tree is modified. TYPE="FreeBSD" REVISION="12.0" @@ -193,6 +197,9 @@ fi if [ -n "$svnversion" ] ; then svn=`cd ${SYSDIR} && $svnversion 2>/dev/null` + if expr "$svn" : ".*M" >/dev/null; then + modified=true + fi case "$svn" in [0-9]*) svn=" r${svn}" ;; *) unset svn ;; @@ -227,6 +234,7 @@ if [ -n "$git_cmd" ] ; then if $git_cmd --work-tree=${VCSDIR}/.. diff-index \ --name-only HEAD | read dummy; then git="${git}-dirty" + modified=true fi fi @@ -239,7 +247,10 @@ if [ -n "$p4_cmd" ] ; then p4opened=`cd ${SYSDIR} && $p4_cmd opened ./... 2>&1` case "$p4opened" in File*) ;; - //*) p4version="${p4version}+edit" ;; + //*) + p4version="${p4version}+edit" + modified=true + ;; esac ;; *) unset p4version ;; @@ -264,6 +275,10 @@ while getopts r opt; do r) include_metadata= ;; + R) + if [ -z "${modified}" ]; then + include_metadata= + fi esac done shift $((OPTIND - 1)) From owner-svn-src-head@freebsd.org Mon Dec 19 15:23:26 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3449CC88294; Mon, 19 Dec 2016 15:23:26 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 00E511D15; Mon, 19 Dec 2016 15:23:25 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBJFNPQ4028155; Mon, 19 Dec 2016 15:23:25 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBJFNPP9028154; Mon, 19 Dec 2016 15:23:25 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201612191523.uBJFNPP9028154@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Mon, 19 Dec 2016 15:23:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310274 - head X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 15:23:26 -0000 Author: emaste Date: Mon Dec 19 15:23:24 2016 New Revision: 310274 URL: https://svnweb.freebsd.org/changeset/base/310274 Log: Add ld.debug to ObsoleteFiles.inc After r293285 GNU ld is installed as /usr/bin/ld.bfd, and linked as /usr/bin/ld. The debug file is /usr/lib/debug/usr/bin/ld.bfd.debug. MFC after: 1 week Sponsored by: The FreeBSD Foundation Modified: head/ObsoleteFiles.inc Modified: head/ObsoleteFiles.inc ============================================================================== --- head/ObsoleteFiles.inc Mon Dec 19 15:19:44 2016 (r310273) +++ head/ObsoleteFiles.inc Mon Dec 19 15:23:24 2016 (r310274) @@ -642,6 +642,8 @@ OLD_FILES+=usr/share/mdocml/style.css OLD_DIRS+=usr/share/mdocml # 20160114: SA-16:06.snmpd OLD_FILES+=usr/share/examples/etc/snmpd.config +# 20160107: GNU ld installed as ld.bfd and linked as ld +OLD_FILES+=usr/lib/debug/usr/bin/ld.debug # 20151225: new clang import which bumps version from 3.7.0 to 3.7.1. OLD_FILES+=usr/lib/clang/3.7.0/include/sanitizer/allocator_interface.h OLD_FILES+=usr/lib/clang/3.7.0/include/sanitizer/asan_interface.h From owner-svn-src-head@freebsd.org Mon Dec 19 15:48:15 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1D3BBC88A8A; Mon, 19 Dec 2016 15:48:15 +0000 (UTC) (envelope-from ken@kdm.org) Received: from mithlond.kdm.org (mithlond.kdm.org [96.89.93.250]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "A1-33714", Issuer "A1-33714" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id B95B61B48; Mon, 19 Dec 2016 15:48:14 +0000 (UTC) (envelope-from ken@kdm.org) Received: from mithlond.kdm.org (localhost [127.0.0.1]) by mithlond.kdm.org (8.15.2/8.14.9) with ESMTPS id uBJFm6Uv043171 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 19 Dec 2016 10:48:06 -0500 (EST) (envelope-from ken@mithlond.kdm.org) Received: (from ken@localhost) by mithlond.kdm.org (8.15.2/8.14.9/Submit) id uBJFm62k043170; Mon, 19 Dec 2016 10:48:06 -0500 (EST) (envelope-from ken) Date: Mon, 19 Dec 2016 10:48:06 -0500 From: "Kenneth D. Merry" To: Oliver Pinter Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r307684 - head/sbin/camcontrol Message-ID: <20161219154806.GA43009@mithlond.kdm.org> References: <201610201942.u9KJgQOR062772@repo.freebsd.org> <20161212223354.GA16028@mithlond.kdm.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (mithlond.kdm.org [127.0.0.1]); Mon, 19 Dec 2016 10:48:06 -0500 (EST) X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on mithlond.kdm.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 15:48:15 -0000 On Sat, Dec 17, 2016 at 20:50:15 +0100, Oliver Pinter wrote: > On 12/12/16, Kenneth D. Merry wrote: > > On Sun, Dec 11, 2016 at 00:49:12 +0100, Oliver Pinter wrote: > >> On 10/20/16, Kenneth D. Merry wrote: > >> > Author: ken > >> > Date: Thu Oct 20 19:42:26 2016 > >> > New Revision: 307684 > >> > URL: https://svnweb.freebsd.org/changeset/base/307684 > >> > > >> > Log: > >> > For CCBs allocated on the stack, we need to clear the entire CCB, not > >> > just > >> > the header. Otherwise stack garbage can lead to random flags getting > >> > set. > >> > > >> > This showed up as 'camcontrol rescan all' failing with EINVAL because > >> > the > >> > address type wasn't CAM_DATA_VADDR. > >> > > >> > sbin/camcontrol/camcontrol.c: > >> > In rescan_or_reset_bus(), bzero the stack-allocated CCBs before > >> > use instead of clearing the body. > >> > > >> > MFC after: 3 days > >> > Sponsored by: Spectra Logic > >> > >> The MFC of this commit is missed both for 10-STABLE and 11-STABLE. Is > >> this still in plan to do? > > > > Done, thanks for the reminder! > > Thanks! > > Slightly related problem what I found on one of my INVARIANTS enabled > kernel is the following: > https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=215356 . A similar > change what this is required in smartmontools too. Ahh, yes, sounds like the same basic issue. Thanks for submitting it upstream! Ken -- Kenneth Merry ken@FreeBSD.ORG From owner-svn-src-head@freebsd.org Mon Dec 19 15:50:00 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id ADEDEC88BAD; Mon, 19 Dec 2016 15:50:00 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 7D8B81D1E; Mon, 19 Dec 2016 15:50:00 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBJFnxf8037142; Mon, 19 Dec 2016 15:49:59 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBJFnxwE037141; Mon, 19 Dec 2016 15:49:59 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201612191549.uBJFnxwE037141@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Mon, 19 Dec 2016 15:49:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310275 - head/sys/cam/ctl X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 15:50:00 -0000 Author: mav Date: Mon Dec 19 15:49:59 2016 New Revision: 310275 URL: https://svnweb.freebsd.org/changeset/base/310275 Log: Fix typo in function name. Modified: head/sys/cam/ctl/ctl_error.c Modified: head/sys/cam/ctl/ctl_error.c ============================================================================== --- head/sys/cam/ctl/ctl_error.c Mon Dec 19 15:23:24 2016 (r310274) +++ head/sys/cam/ctl/ctl_error.c Mon Dec 19 15:49:59 2016 (r310275) @@ -366,7 +366,7 @@ ctl_set_ua(struct ctl_scsiio *ctsio, int } static void -ctl_ua_to_acsq(struct ctl_lun *lun, ctl_ua_type ua_to_build, int *asc, +ctl_ua_to_ascq(struct ctl_lun *lun, ctl_ua_type ua_to_build, int *asc, int *ascq, ctl_ua_type *ua_to_clear, uint8_t **info) { @@ -492,7 +492,7 @@ ctl_build_qae(struct ctl_lun *lun, uint3 ua_to_build = (1 << (ffs(ua) - 1)); ua_to_clear = ua_to_build; info = NULL; - ctl_ua_to_acsq(lun, ua_to_build, &asc, &ascq, &ua_to_clear, &info); + ctl_ua_to_ascq(lun, ua_to_build, &asc, &ascq, &ua_to_clear, &info); resp[0] = SSD_KEY_UNIT_ATTENTION; if (ua_to_build == ua) @@ -537,7 +537,7 @@ ctl_build_ua(struct ctl_lun *lun, uint32 ua_to_build = (1 << (ffs(ua[i]) - 1)); ua_to_clear = ua_to_build; info = NULL; - ctl_ua_to_acsq(lun, ua_to_build, &asc, &ascq, &ua_to_clear, &info); + ctl_ua_to_ascq(lun, ua_to_build, &asc, &ascq, &ua_to_clear, &info); ctl_set_sense_data(sense, lun, sense_format, /*current_error*/ 1, /*sense_key*/ SSD_KEY_UNIT_ATTENTION, asc, ascq, From owner-svn-src-head@freebsd.org Mon Dec 19 17:02:27 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9811DC8838F; Mon, 19 Dec 2016 17:02:27 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from mail.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 70C141013; Mon, 19 Dec 2016 17:02:27 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by mail.baldwin.cx (Postfix) with ESMTPSA id 2EBC010A76C; Mon, 19 Dec 2016 12:02:26 -0500 (EST) From: John Baldwin To: Hans Petter Selasky Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r310242 - head/sys/dev/usb Date: Mon, 19 Dec 2016 08:13:18 -0800 Message-ID: <2058091.PnquSlH0qI@ralph.baldwin.cx> User-Agent: KMail/4.14.10 (FreeBSD/11.0-PRERELEASE; KDE/4.14.10; amd64; ; ) In-Reply-To: <201612190928.uBJ9SDFc078376@repo.freebsd.org> References: <201612190928.uBJ9SDFc078376@repo.freebsd.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mail.baldwin.cx); Mon, 19 Dec 2016 12:02:26 -0500 (EST) X-Virus-Scanned: clamav-milter 0.99.2 at mail.baldwin.cx X-Virus-Status: Clean X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 17:02:27 -0000 On Monday, December 19, 2016 09:28:13 AM Hans Petter Selasky wrote: > Author: hselasky > Date: Mon Dec 19 09:28:12 2016 > New Revision: 310242 > URL: https://svnweb.freebsd.org/changeset/base/310242 > > Log: > Defer USB enumeration until the SI_SUB_KICK_SCHEDULER is executed to avoid > boot panics in conjunction with the recently added EARLY_AP_STARTUP feature. > The panics happen due to using kernel facilities like callouts too early. > > Tested by: jhb @ > MFC after: 1 week As mentioned in the thread, the patches to usb_hub.c weren't needed and the block in usb_process.c can just be removed unconditionally since it should never execute in the non-EARLY_AP_STARTUP case. -- John Baldwin From owner-svn-src-head@freebsd.org Mon Dec 19 17:02:29 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 536D7C88393; Mon, 19 Dec 2016 17:02:29 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from mail.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1371C101E; Mon, 19 Dec 2016 17:02:29 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by mail.baldwin.cx (Postfix) with ESMTPSA id 9587D10A746; Mon, 19 Dec 2016 12:02:27 -0500 (EST) From: John Baldwin To: Eric van Gyzen Cc: Warner Losh , Dimitry Andric , Baptiste Daroussin , "Conrad E. Meyer" , src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Subject: Re: svn commit: r310138 - head/lib/libc/stdio Date: Sat, 17 Dec 2016 12:33:33 -0800 Message-ID: <49460793.UcUNovQMDa@ralph.baldwin.cx> User-Agent: KMail/4.14.10 (FreeBSD/11.0-PRERELEASE; KDE/4.14.10; amd64; ; ) In-Reply-To: References: <201612160144.uBG1ipjW016736@repo.freebsd.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mail.baldwin.cx); Mon, 19 Dec 2016 12:02:27 -0500 (EST) X-Virus-Scanned: clamav-milter 0.99.2 at mail.baldwin.cx X-Virus-Status: Clean X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 17:02:29 -0000 On Friday, December 16, 2016 07:31:28 PM Eric van Gyzen wrote: > On 12/16/2016 17:44, Warner Losh wrote: > > On Fri, Dec 16, 2016 at 3:07 PM, John Baldwin wrote: > >> On Friday, December 16, 2016 04:53:04 PM Eric van Gyzen wrote: > >>> On 12/16/2016 16:45, John Baldwin wrote: > >>>> On Friday, December 16, 2016 08:53:26 PM Dimitry Andric wrote: > >>>>> On 16 Dec 2016, at 20:31, Baptiste Daroussin wrote: > >>>>>> > >>>>>> On Fri, Dec 16, 2016 at 01:44:51AM +0000, Conrad E. Meyer wrote: > >>>>>>> Author: cem > >>>>>>> Date: Fri Dec 16 01:44:50 2016 > >>>>>>> New Revision: 310138 > >>>>>>> URL: https://svnweb.freebsd.org/changeset/base/310138 > >>>>>>> > >>>>>>> Log: > >>>>>>> vfprintf(3): Add support for kernel %b format > >>>>>>> > >>>>>>> This is a direct port of the kernel %b format. > >>>>>>> > >>>>>>> I'm unclear on if (more) non-portable printf extensions will be a > >>>>>>> problem. I think it's desirable to have userspace formats include all > >>>>>>> kernel formats, but there may be competing goals I'm not aware of. > >>>>>>> > >>>>>>> Reviewed by: no one, unfortunately > >>>>>>> Sponsored by: Dell EMC Isilon > >>>>>>> Differential Revision: https://reviews.freebsd.org/D8426 > >>>>>>> > >>>>>> > >>>>>> I really don't think it is a good idea, if used in userland it would be make > >>>>>> more of our code difficult to port elsewhere. > >>>>> > >>>>> Indeed, this is a bad idea. These custom format specifiers should be > >>>>> eliminated, not multiplied. :-) > >>>>> > >>>>> > >>>>>> Other than that, it makes more difficult to use vanilla gcc with out userland. > >>>>>> and it is adding more complexity to be able to build freebsd from a non freebsd > >>>>>> system which some people are working on. > >>>>>> > >>>>>> Personnaly I would prefer to see those extensions removed from the kernel rather > >>>>>> than see them available in userland. > >>>>> > >>>>> Same here. > >>>>> > >>>>> > >>>>>> Can't we use simple helper function instead? > >>>>> > >>>>> Yes, please. Just take the snprintb(3) function from NetBSD: > >>>>> > >>>>> http://netbsd.gw.com/cgi-bin/man-cgi?snprintb+3+NetBSD-current > >>>> > >>>> In general I agree with something like this instead, but it is quite a bit more > >>>> tedious to use as you have to run it once to determine the length, allocate a > >>>> buffer, and then run it again. Calling malloc() for that buffer isn't always > >>>> convenient in the kernel (though it should be fine in userland). Having it live > >>>> in printf() itself means the output is generated to the stream without having to > >>>> manage a variable-sized intermediate buffer. > >>> > >>> I imagine most callers can simply use a char[sizeof(fmt)+C] on the stack, where > >>> C is some constant that I haven't taken the time to calculate, at the risk of > >>> making myself look foolish and unprofessional. > >> > >> Hmm, that might work, but it is still cumbersome. Probably to make things readable > >> we'd end up with a wrapper: > >> > >> printb(uint val, const char *fmt) > >> { > >> char buf[strlen(fmt) + C]; > >> > >> snprintb(...); > >> printf("%s", buf); > >> } > > > > Sadly this "cure" is worse than the disease. > > How about this cure? > > printf("reg=%b\n", value, FORMAT); > > // versus > > char buf[BITMASK_BUFFER_SIZE(FORMAT)]; > printf("reg=%s\n", format_bitmask(buf, sizeof(buf), value, FORMAT)); > > That doesn't seem so bad. The trick here is giving FORMAT twice. For code that often uses %b that is untenable. You would have to make it a macro (or use printb which only accepts it once which is why I suggested that approach instead). But a macro moves its definition out of context. Here's an example to think about: /* * Here we should probably set up flags indicating * whether or not various features are available. * The interesting ones are probably VME, PSE, PAE, * and PGE. The code already assumes without bothering * to check that all CPUs >= Pentium have a TSC and * MSRs. */ printf("\n Features=0x%b", cpu_feature, "\020" "\001FPU" /* Integral FPU */ "\002VME" /* Extended VM86 mode support */ "\003DE" /* Debugging Extensions (CR4.DE) */ "\004PSE" /* 4MByte page tables */ "\005TSC" /* Timestamp counter */ "\006MSR" /* Machine specific registers */ "\007PAE" /* Physical address extension */ "\010MCE" /* Machine Check support */ "\011CX8" /* CMPEXCH8 instruction */ "\012APIC" /* SMP local APIC */ "\013oldMTRR" /* Previous implementation of MTRR */ "\014SEP" /* Fast System Call */ "\015MTRR" /* Memory Type Range Registers */ "\016PGE" /* PG_G (global bit) support */ "\017MCA" /* Machine Check Architecture */ "\020CMOV" /* CMOV instruction */ "\021PAT" /* Page attributes table */ "\022PSE36" /* 36 bit address space support */ "\023PN" /* Processor Serial number */ "\024CLFLUSH" /* Has the CLFLUSH instruction */ "\025" "\026DTS" /* Debug Trace Store */ "\027ACPI" /* ACPI support */ "\030MMX" /* MMX instructions */ "\031FXSR" /* FXSAVE/FXRSTOR */ "\032SSE" /* Streaming SIMD Extensions */ "\033SSE2" /* Streaming SIMD Extensions #2 */ "\034SS" /* Self snoop */ "\035HTT" /* Hyperthreading (see EBX bit 16-23) */ "\036TM" /* Thermal Monitor clock slowdown */ "\037IA64" /* CPU can execute IA64 instructions */ "\040PBE" /* Pending Break Enable */ ); if (cpu_feature2 != 0) { printf("\n Features2=0x%b", cpu_feature2, "\020" "\001SSE3" /* SSE3 */ "\002PCLMULQDQ" /* Carry-Less Mul Quadword */ "\003DTES64" /* 64-bit Debug Trace */ "\004MON" /* MONITOR/MWAIT Instructions */ "\005DS_CPL" /* CPL Qualified Debug Store */ "\006VMX" /* Virtual Machine Extensions */ "\007SMX" /* Safer Mode Extensions */ "\010EST" /* Enhanced SpeedStep */ "\011TM2" /* Thermal Monitor 2 */ "\012SSSE3" /* SSSE3 */ "\013CNXT-ID" /* L1 context ID available */ "\014SDBG" /* IA32 silicon debug */ "\015FMA" /* Fused Multiply Add */ "\016CX16" /* CMPXCHG16B Instruction */ "\017xTPR" /* Send Task Priority Messages*/ "\020PDCM" /* Perf/Debug Capability MSR */ "\021" "\022PCID" /* Process-context Identifiers*/ "\023DCA" /* Direct Cache Access */ "\024SSE4.1" /* SSE 4.1 */ "\025SSE4.2" /* SSE 4.2 */ "\026x2APIC" /* xAPIC Extensions */ "\027MOVBE" /* MOVBE Instruction */ "\030POPCNT" /* POPCNT Instruction */ "\031TSCDLT" /* TSC-Deadline Timer */ "\032AESNI" /* AES Crypto */ "\033XSAVE" /* XSAVE/XRSTOR States */ "\034OSXSAVE" /* OS-Enabled State Management*/ "\035AVX" /* Advanced Vector Extensions */ "\036F16C" /* Half-precision conversions */ "\037RDRAND" /* RDRAND Instruction */ "\040HV" /* Hypervisor */ ); } (and several more of these) -- John Baldwin From owner-svn-src-head@freebsd.org Mon Dec 19 17:10:31 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EFE82C887B3; Mon, 19 Dec 2016 17:10:31 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 B0A9819B4; Mon, 19 Dec 2016 17:10:31 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBJHAUw2074235; Mon, 19 Dec 2016 17:10:30 GMT (envelope-from hrs@FreeBSD.org) Received: (from hrs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBJHAUZL074234; Mon, 19 Dec 2016 17:10:30 GMT (envelope-from hrs@FreeBSD.org) Message-Id: <201612191710.uBJHAUZL074234@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hrs set sender to hrs@FreeBSD.org using -f From: Hiroki Sato Date: Mon, 19 Dec 2016 17:10:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310278 - head/usr.sbin/syslogd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 17:10:32 -0000 Author: hrs Date: Mon Dec 19 17:10:30 2016 New Revision: 310278 URL: https://svnweb.freebsd.org/changeset/base/310278 Log: Add a missing STAILQ_INSERT_TAIL() for allowaddr rule. Modified: head/usr.sbin/syslogd/syslogd.c Modified: head/usr.sbin/syslogd/syslogd.c ============================================================================== --- head/usr.sbin/syslogd/syslogd.c Mon Dec 19 17:05:24 2016 (r310277) +++ head/usr.sbin/syslogd/syslogd.c Mon Dec 19 17:10:30 2016 (r310278) @@ -2303,7 +2303,7 @@ static int allowaddr(char *s) { char *cp1, *cp2; - struct allowedpeer ap; + struct allowedpeer *ap; struct servent *se; int masklen = -1; struct addrinfo hints, *res; @@ -2314,6 +2314,10 @@ allowaddr(char *s) #endif char ip[NI_MAXHOST]; + ap = calloc(1, sizeof(*ap)); + if (ap == NULL) + err(1, "malloc failed"); + #ifdef INET6 if (*s != '[' || (cp1 = strchr(s + 1, ']')) == NULL) #endif @@ -2323,20 +2327,20 @@ allowaddr(char *s) *cp1++ = '\0'; if (strlen(cp1) == 1 && *cp1 == '*') /* any port allowed */ - ap.port = 0; + ap->port = 0; else if ((se = getservbyname(cp1, "udp"))) { - ap.port = ntohs(se->s_port); + ap->port = ntohs(se->s_port); } else { - ap.port = strtol(cp1, &cp2, 0); + ap->port = strtol(cp1, &cp2, 0); if (*cp2 != '\0') return (-1); /* port not numeric */ } } else { if ((se = getservbyname("syslog", "udp"))) - ap.port = ntohs(se->s_port); + ap->port = ntohs(se->s_port); else /* sanity, should not happen */ - ap.port = 514; + ap->port = 514; } if ((cp1 = strchr(s, '/')) != NULL && @@ -2363,14 +2367,14 @@ allowaddr(char *s) hints.ai_socktype = SOCK_DGRAM; hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST; if (getaddrinfo(s, NULL, &hints, &res) == 0) { - ap.isnumeric = 1; - memcpy(&ap.a_addr, res->ai_addr, res->ai_addrlen); - memset(&ap.a_mask, 0, sizeof(ap.a_mask)); - ap.a_mask.ss_family = res->ai_family; + ap->isnumeric = 1; + memcpy(&ap->a_addr, res->ai_addr, res->ai_addrlen); + memset(&ap->a_mask, 0, sizeof(ap->a_mask)); + ap->a_mask.ss_family = res->ai_family; if (res->ai_family == AF_INET) { - ap.a_mask.ss_len = sizeof(struct sockaddr_in); - maskp = &((struct sockaddr_in *)&ap.a_mask)->sin_addr; - addrp = &((struct sockaddr_in *)&ap.a_addr)->sin_addr; + ap->a_mask.ss_len = sizeof(struct sockaddr_in); + maskp = &((struct sockaddr_in *)&ap->a_mask)->sin_addr; + addrp = &((struct sockaddr_in *)&ap->a_addr)->sin_addr; if (masklen < 0) { /* use default netmask */ if (IN_CLASSA(ntohl(addrp->s_addr))) @@ -2394,10 +2398,10 @@ allowaddr(char *s) } #ifdef INET6 else if (res->ai_family == AF_INET6 && masklen <= 128) { - ap.a_mask.ss_len = sizeof(struct sockaddr_in6); + ap->a_mask.ss_len = sizeof(struct sockaddr_in6); if (masklen < 0) masklen = 128; - mask6p = (u_int32_t *)&((struct sockaddr_in6 *)&ap.a_mask)->sin6_addr; + mask6p = (u_int32_t *)&((struct sockaddr_in6 *)&ap->a_mask)->sin6_addr; /* convert masklen to netmask */ while (masklen > 0) { if (masklen < 32) { @@ -2408,8 +2412,8 @@ allowaddr(char *s) masklen -= 32; } /* Lose any host bits in the network number. */ - mask6p = (u_int32_t *)&((struct sockaddr_in6 *)&ap.a_mask)->sin6_addr; - addr6p = (u_int32_t *)&((struct sockaddr_in6 *)&ap.a_addr)->sin6_addr; + mask6p = (u_int32_t *)&((struct sockaddr_in6 *)&ap->a_mask)->sin6_addr; + addr6p = (u_int32_t *)&((struct sockaddr_in6 *)&ap->a_addr)->sin6_addr; for (i = 0; i < 4; i++) addr6p[i] &= mask6p[i]; } @@ -2421,8 +2425,8 @@ allowaddr(char *s) freeaddrinfo(res); } else { /* arg `s' is domain name */ - ap.isnumeric = 0; - ap.a_name = s; + ap->isnumeric = 0; + ap->a_name = s; if (cp1) *cp1 = '/'; #ifdef INET6 @@ -2432,23 +2436,24 @@ allowaddr(char *s) } #endif } + STAILQ_INSERT_TAIL(&aphead, ap, next); if (Debug) { printf("allowaddr: rule "); - if (ap.isnumeric) { + if (ap->isnumeric) { printf("numeric, "); - getnameinfo((struct sockaddr *)&ap.a_addr, - ((struct sockaddr *)&ap.a_addr)->sa_len, + getnameinfo((struct sockaddr *)&ap->a_addr, + ((struct sockaddr *)&ap->a_addr)->sa_len, ip, sizeof ip, NULL, 0, NI_NUMERICHOST); printf("addr = %s, ", ip); - getnameinfo((struct sockaddr *)&ap.a_mask, - ((struct sockaddr *)&ap.a_mask)->sa_len, + getnameinfo((struct sockaddr *)&ap->a_mask, + ((struct sockaddr *)&ap->a_mask)->sa_len, ip, sizeof ip, NULL, 0, NI_NUMERICHOST); printf("mask = %s; ", ip); } else { - printf("domainname = %s; ", ap.a_name); + printf("domainname = %s; ", ap->a_name); } - printf("port = %d\n", ap.port); + printf("port = %d\n", ap->port); } return (0); } From owner-svn-src-head@freebsd.org Mon Dec 19 17:31:36 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 24CD1C88CEA; Mon, 19 Dec 2016 17:31:36 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 E88DB1527; Mon, 19 Dec 2016 17:31:35 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBJHVZIR083760; Mon, 19 Dec 2016 17:31:35 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBJHVZHA083759; Mon, 19 Dec 2016 17:31:35 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201612191731.uBJHVZHA083759@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Mon, 19 Dec 2016 17:31:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310279 - head/sys/conf X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 17:31:36 -0000 Author: emaste Date: Mon Dec 19 17:31:34 2016 New Revision: 310279 URL: https://svnweb.freebsd.org/changeset/base/310279 Log: newvers.sh: consider as modified SVN mixed revision and other cases The newvers -R option is intended to include build metadata (e.g. user, host, time) if the build is from an unmodified VCS tree. For subversion it considered a trailing 'M' as an indication of a modified tree, and any other version string as modified. Also include mixed revision checkouts (e.g. 123:126), switched (123S) and partial (123P) working copies as modified: the revision number is insufficient to uniquely determine which source was used for the build. Reported by: gjb Reviewed by: gjb MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D8853 Modified: head/sys/conf/newvers.sh Modified: head/sys/conf/newvers.sh ============================================================================== --- head/sys/conf/newvers.sh Mon Dec 19 17:10:30 2016 (r310278) +++ head/sys/conf/newvers.sh Mon Dec 19 17:31:34 2016 (r310279) @@ -197,12 +197,17 @@ fi if [ -n "$svnversion" ] ; then svn=`cd ${SYSDIR} && $svnversion 2>/dev/null` - if expr "$svn" : ".*M" >/dev/null; then - modified=true - fi case "$svn" in - [0-9]*) svn=" r${svn}" ;; - *) unset svn ;; + [0-9]*[MSP]|*:*) + svn=" r${svn}" + modified=true + ;; + [0-9]*) + svn=" r${svn}" + ;; + *) + unset svn + ;; esac fi @@ -270,7 +275,7 @@ if [ -n "$hg_cmd" ] ; then fi include_metadata=true -while getopts r opt; do +while getopts rR opt; do case "$opt" in r) include_metadata= From owner-svn-src-head@freebsd.org Mon Dec 19 17:34:33 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 92BEEC88DA7; Mon, 19 Dec 2016 17:34:33 +0000 (UTC) (envelope-from etnapierala@gmail.com) Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 250F017AA; Mon, 19 Dec 2016 17:34:33 +0000 (UTC) (envelope-from etnapierala@gmail.com) Received: by mail-wm0-x242.google.com with SMTP id a20so19944104wme.2; Mon, 19 Dec 2016 09:34:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:mail-followup-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=55jvvjegnbyVqwBnjSbboejmPelXdGafZr4VViIfnGA=; b=E9UxuS+zIk5OwzbTA+egezd3YMGxzNESfYCTg7SP4OofVtNHpHusQGbmFjk9X6ydWM dlNMlgLZCFk04OEf0cxWvVq7MYLDT7R74v3ox/bfGKVVlsjdzRJuyXFRGLjbyhMEwZsp h4+bnz0Ns5F/XOH9V0jmLAofT+SL5hqwlzUEs5FlJK8ieuf4wxPEDTWbvfV5Q5mEZH8W zVySQnN5L0Fo3Xd/WSYAOSoHOBzNmru7C678Z8NIeb+jq+Kjpp/H+mz36YtTD1Be4Bgo qI9lvSG+x3mwIA1MQKoaE+GrjZ2BzyX8yfY2C2aKlyPLUsRcoWJ5NmJHzpHi083rgqj1 6wkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=55jvvjegnbyVqwBnjSbboejmPelXdGafZr4VViIfnGA=; b=GN2nWSnVgk8erhGJwlvDrVweDZPPMoxMIe4DerkQxj3Qet8okO90Qv5C1xYmA/zfb6 q/y5wpAXREXQMiTSXm6JnOpB/oNzYRReWW1SPKSDwGB9K1pj7AR7TmjeDt96b/5JTgDX eKQpAN66AfR2oaD3z6Ifor+TaX9hhlaK0mosaBmLGiJWj+ZxPNP/RbFB1wS0/5sgmfw9 MwcUJ4eI502zq2kS8pHfw1DYlLx5ipxlZJsfHqDmQZwooQgrrcdJT8by442dJZHiUXOz Vcz28CbWaH3BH1hyXLAB2jY/WeUuZS8jbyRSXEGvnSsp2C9QS96KdwlHnDJl59P0J9U4 ULvA== X-Gm-Message-State: AIkVDXKQ6AzrWoQ6W+UtWzlp7YKhu7dKsejtjQhh/LJBHq/os6SDZ2KlVbsDQ5qBbvfkKQ== X-Received: by 10.28.138.135 with SMTP id m129mr13879917wmd.36.1482168871550; Mon, 19 Dec 2016 09:34:31 -0800 (PST) Received: from brick (acyx46.neoplus.adsl.tpnet.pl. [83.11.207.46]) by smtp.gmail.com with ESMTPSA id w197sm18165736wmd.11.2016.12.19.09.34.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Dec 2016 09:34:30 -0800 (PST) Sender: =?UTF-8?Q?Edward_Tomasz_Napiera=C5=82a?= Date: Mon, 19 Dec 2016 18:34:27 +0100 From: Edward Tomasz Napierala To: Oliver Pinter Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r307774 - head/lib/libusb Message-ID: <20161219173427.GA3586@brick> Mail-Followup-To: Oliver Pinter , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201610221437.u9MEbDLR070111@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.7.1 (2016-10-04) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 17:34:33 -0000 On 1211T0110, Oliver Pinter wrote: > On 10/22/16, Edward Tomasz Napierala wrote: > > Author: trasz > > Date: Sat Oct 22 14:37:13 2016 > > New Revision: 307774 > > URL: https://svnweb.freebsd.org/changeset/base/307774 > > > > Log: > > Fix libusb20_dev_get_desc(3) to use the "vendor product" order, not > > "product vendor". This is consistent with how it's generally done. > > The ordering is visible eg in usbconfig(8) output. > > > > Note to self: MFC this to 9 and 8. > > > > Reviewed by: hselasky@ > > MFC after: 1 month > > Is this MFC still valid? I can't see them in 10-STABLE nor in 11-STABLE. Working on it, thanks for the reminder :-) From owner-svn-src-head@freebsd.org Mon Dec 19 17:37:50 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id ABD74C88FF8; Mon, 19 Dec 2016 17:37:50 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mail.turbocat.net (turbocat.net [88.99.82.50]) (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 74B211C29; Mon, 19 Dec 2016 17:37:49 +0000 (UTC) (envelope-from hps@selasky.org) Received: from hps2016.home.selasky.org (unknown [62.141.129.119]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id 3FBD51FE1B5; Mon, 19 Dec 2016 18:37:47 +0100 (CET) Subject: Re: svn commit: r310242 - head/sys/dev/usb To: John Baldwin References: <201612190928.uBJ9SDFc078376@repo.freebsd.org> <2058091.PnquSlH0qI@ralph.baldwin.cx> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org From: Hans Petter Selasky Message-ID: <57d2d5e2-1b2d-09d5-41e2-92b6f22fb229@selasky.org> Date: Mon, 19 Dec 2016 18:37:17 +0100 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <2058091.PnquSlH0qI@ralph.baldwin.cx> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 17:37:50 -0000 On 12/19/16 17:13, John Baldwin wrote: > On Monday, December 19, 2016 09:28:13 AM Hans Petter Selasky wrote: >> Author: hselasky >> Date: Mon Dec 19 09:28:12 2016 >> New Revision: 310242 >> URL: https://svnweb.freebsd.org/changeset/base/310242 >> >> Log: >> Defer USB enumeration until the SI_SUB_KICK_SCHEDULER is executed to avoid >> boot panics in conjunction with the recently added EARLY_AP_STARTUP feature. >> The panics happen due to using kernel facilities like callouts too early. >> >> Tested by: jhb @ >> MFC after: 1 week > > As mentioned in the thread, the patches to usb_hub.c weren't needed and the block > in usb_process.c can just be removed unconditionally since it should never execute > in the non-EARLY_AP_STARTUP case. > Hi John, The checks in usb_process.c are needed in case attaching a USB controller fails for some unknown reason. Then there is a problem that thread0 cannot wait/sleep for the process to exit, so that it doesn't access freed memory. Did I miss anything? --HPS From owner-svn-src-head@freebsd.org Mon Dec 19 18:55:11 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 80256C88968; Mon, 19 Dec 2016 18:55:11 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 4FC4919B1; Mon, 19 Dec 2016 18:55:11 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBJItArR019724; Mon, 19 Dec 2016 18:55:10 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBJItANu019723; Mon, 19 Dec 2016 18:55:10 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201612191855.uBJItANu019723@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Mon, 19 Dec 2016 18:55:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310284 - head/sys/cam/scsi X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 18:55:11 -0000 Author: mav Date: Mon Dec 19 18:55:10 2016 New Revision: 310284 URL: https://svnweb.freebsd.org/changeset/base/310284 Log: When writing fixed format sense data, set VALID bit only if provided value for INFORMATION field fit into available 4 bytes (has no non-zero bytes except last 4), as explicitly required by SPC-5 specification. MFC after: 2 weeks Modified: head/sys/cam/scsi/scsi_all.c Modified: head/sys/cam/scsi/scsi_all.c ============================================================================== --- head/sys/cam/scsi/scsi_all.c Mon Dec 19 18:32:26 2016 (r310283) +++ head/sys/cam/scsi/scsi_all.c Mon Dec 19 18:55:10 2016 (r310284) @@ -4020,11 +4020,17 @@ scsi_set_sense_data_va(struct scsi_sense data_dest = &sense->info[0]; len_to_copy = MIN(sense_len, sizeof(sense->info)); - /* - * We're setting the info field, so - * set the valid bit. - */ - sense->error_code |= SSD_ERRCODE_VALID; + + /* Set VALID bit only if no overflow. */ + for (i = 0; i < sense_len - len_to_copy; + i++) { + if (data[i] != 0) + break; + } + if (i >= sense_len - len_to_copy) { + sense->error_code |= + SSD_ERRCODE_VALID; + } } /* From owner-svn-src-head@freebsd.org Mon Dec 19 18:58:44 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 19297C88A7D for ; Mon, 19 Dec 2016 18:58:44 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-io0-x241.google.com (mail-io0-x241.google.com [IPv6:2607:f8b0:4001:c06::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D504C1CE5 for ; Mon, 19 Dec 2016 18:58:43 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-io0-x241.google.com with SMTP id y124so20117392iof.1 for ; Mon, 19 Dec 2016 10:58:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=P/ci+APtB4GbDjWcAW4TODiPAZc9Dl/8ICnDOqU4ZTA=; b=H5y6y9iNktDIpYTs+YL08tBbL2xAxRtdDehBcO4OupdZmqONSu0zjoONzmn0n13Svh 8OEKbV7JXt+n7+RpnKUb87meppIZUdK6g9mJjr2grlo8FNImdW17gvgRIW05GUUuAGOz s4f8OWvjVqj4A+W2DnbF3A+MRKWpEXu3NWqoSQxZ9h2mBPaGGUMWbfXUywSRgmKXgbXO lYtjBCJxVgdO+MLMe5Ehacm11Df3T5IRpsYLmUMQZkcT5FVzeDiX0js/IDtyZA2SkwcD buIlvJIWxLx3gqAT7byfxmRaD5l9hujQZvwHud0q4i3daAeVD0XGizqQD66Dyv6VQv38 5fzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=P/ci+APtB4GbDjWcAW4TODiPAZc9Dl/8ICnDOqU4ZTA=; b=uSjpMOKR0ysL3QyJhDpMlUlcjvRrgq/9+oWDcyS2mAwr6zATMFQME1Adqy5jOhePU9 gfd5N6smxxXSoAeNBUHQC33G3onIJKQ7jydnqjOzjudon5H/CSEurPf5hbx94fWvYdlg hvfIjmYUNCcC1OSkm4TF/N5XpXbzlW+fx42jCKUDYSAzf53BG/liQSqMi6vUU0YlU5EV UjE6DIpMUscDPUy8FOtKoHS6gy8Mm4c0O/CqgB5ZWDWBg8XU7Alhp0QUX3n15fh1gmfe fATb/v4yboyUK+MLe59sr0IHlkWVVY8Gk2FHy9RX9h+HsZjYtk35ushUoCXrb4sd0lVA RrXA== X-Gm-Message-State: AIkVDXLL9KIcDcjngiJwLeS+uN4i141Wt7I++Wt9K30URdS2/tD/V8LNHEOPdCPiQedFXUczGzTI95MWs9O9OA== X-Received: by 10.107.132.74 with SMTP id g71mr16685192iod.19.1482173923157; Mon, 19 Dec 2016 10:58:43 -0800 (PST) MIME-Version: 1.0 Sender: wlosh@bsdimp.com Received: by 10.79.22.135 with HTTP; Mon, 19 Dec 2016 10:58:42 -0800 (PST) X-Originating-IP: [69.53.245.200] In-Reply-To: <9BD5034F-55A6-48F6-A391-A0877FF49702@panasas.com> References: <201612161949.uBGJnMol059217@repo.freebsd.org> <9BD5034F-55A6-48F6-A391-A0877FF49702@panasas.com> From: Warner Losh Date: Mon, 19 Dec 2016 11:58:42 -0700 X-Google-Sender-Auth: fpAmNcP9Tg6kZ06GkJhovOIRnoc Message-ID: Subject: Re: svn commit: r310171 - head/sys/sys To: Ravi Pokala Cc: Sepherosa Ziehau , Dimitry Andric , src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 18:58:44 -0000 On Mon, Dec 19, 2016 at 1:39 AM, Ravi Pokala wrote: > -----Original Message----- >> From: on behalf of Sepherosa Ziehau >> Date: 2016-12-18, Sunday at 23:02 >> To: Dimitry Andric >> Cc: , , >> Subject: Re: svn commit: r310171 - head/sys/sys >> >> The following patch unbreaks the LINT builds on amd64 for me after this commit: >> https://people.freebsd.org/~sephe/geom_sscanf.diff > > Wouldn't it be better to use the SCN macros? Are there other precedence for avoiding the SCN macros in the tree as well, or is this new art? Warner >> Thanks, >> sephe >> >> >> On Sat, Dec 17, 2016 at 3:49 AM, Dimitry Andric wrote: >>> Author: dim >>> Date: Fri Dec 16 19:49:22 2016 >>> New Revision: 310171 >>> URL: https://svnweb.freebsd.org/changeset/base/310171 >>> >>> Log: >>> Add __scanflike attributes to the kernel's sscanf() and vsscanf() >>> declarations. This should help to catch future mismatches between >>> format strings and arguments. >>> >>> MFC after: 1 week >>> >>> Modified: >>> head/sys/sys/systm.h >>> >>> Modified: head/sys/sys/systm.h >>> ============================================================================== >>> --- head/sys/sys/systm.h Fri Dec 16 19:09:57 2016 (r310170) >>> +++ head/sys/sys/systm.h Fri Dec 16 19:49:22 2016 (r310171) >>> @@ -227,8 +227,8 @@ int vsnprintf(char *, size_t, const char >>> int vsnrprintf(char *, size_t, int, const char *, __va_list) __printflike(4, 0); >>> int vsprintf(char *buf, const char *, __va_list) __printflike(2, 0); >>> int ttyprintf(struct tty *, const char *, ...) __printflike(2, 3); >>> -int sscanf(const char *, char const *, ...) __nonnull(1) __nonnull(2); >>> -int vsscanf(const char *, char const *, __va_list) __nonnull(1) __nonnull(2); >>> +int sscanf(const char *, char const *, ...) __nonnull(1) __nonnull(2) __scanflike(2, 3); >>> +int vsscanf(const char *, char const *, __va_list) __nonnull(1) __nonnull(2) __scanflike(2, 0); >>> long strtol(const char *, char **, int) __nonnull(1); >>> u_long strtoul(const char *, char **, int) __nonnull(1); >>> quad_t strtoq(const char *, char **, int) __nonnull(1); >>> _______________________________________________ >>> svn-src-all@freebsd.org mailing list >>> https://lists.freebsd.org/mailman/listinfo/svn-src-all >>> To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org" >> >> -- >> Tomorrow Will Never Die > > > > From owner-svn-src-head@freebsd.org Mon Dec 19 19:00:05 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0F87CC88BA6; Mon, 19 Dec 2016 19:00:05 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 DE5861F9E; Mon, 19 Dec 2016 19:00:04 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBJJ04LS020206; Mon, 19 Dec 2016 19:00:04 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBJJ037h020202; Mon, 19 Dec 2016 19:00:03 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201612191900.uBJJ037h020202@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Mon, 19 Dec 2016 19:00:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310285 - head/sys/cam/ctl X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 19:00:05 -0000 Author: mav Date: Mon Dec 19 19:00:03 2016 New Revision: 310285 URL: https://svnweb.freebsd.org/changeset/base/310285 Log: When reporting "Logical block address out of range" error, report the LBA in sense data INFORMATION field. MFC after: 2 weeks Modified: head/sys/cam/ctl/ctl.c head/sys/cam/ctl/ctl_error.c head/sys/cam/ctl/ctl_error.h head/sys/cam/ctl/ctl_tpc.c Modified: head/sys/cam/ctl/ctl.c ============================================================================== --- head/sys/cam/ctl/ctl.c Mon Dec 19 18:55:10 2016 (r310284) +++ head/sys/cam/ctl/ctl.c Mon Dec 19 19:00:03 2016 (r310285) @@ -5362,7 +5362,8 @@ ctl_sync_cache(struct ctl_scsiio *ctsio) * to see an error for an out of range LBA. */ if ((starting_lba + block_count) > (lun->be_lun->maxlba + 1)) { - ctl_set_lba_out_of_range(ctsio); + ctl_set_lba_out_of_range(ctsio, + MAX(starting_lba, lun->be_lun->maxlba + 1)); ctl_done((union ctl_io *)ctsio); goto bailout; } @@ -5678,7 +5679,8 @@ ctl_write_same(struct ctl_scsiio *ctsio) */ if (((lba + num_blocks) > (lun->be_lun->maxlba + 1)) || ((lba + num_blocks) < lba)) { - ctl_set_lba_out_of_range(ctsio); + ctl_set_lba_out_of_range(ctsio, + MAX(lba, lun->be_lun->maxlba + 1)); ctl_done((union ctl_io *)ctsio); return (CTL_RETVAL_COMPLETE); } @@ -5791,7 +5793,8 @@ ctl_unmap(struct ctl_scsiio *ctsio) num_blocks = scsi_4btoul(range->length); if (((lba + num_blocks) > (lun->be_lun->maxlba + 1)) || ((lba + num_blocks) < lba)) { - ctl_set_lba_out_of_range(ctsio); + ctl_set_lba_out_of_range(ctsio, + MAX(lba, lun->be_lun->maxlba + 1)); ctl_done((union ctl_io *)ctsio); return (CTL_RETVAL_COMPLETE); } @@ -6995,7 +6998,7 @@ ctl_get_lba_status(struct ctl_scsiio *ct alloc_len = scsi_4btoul(cdb->alloc_len); if (lba > lun->be_lun->maxlba) { - ctl_set_lba_out_of_range(ctsio); + ctl_set_lba_out_of_range(ctsio, lba); ctl_done((union ctl_io *)ctsio); return (CTL_RETVAL_COMPLETE); } @@ -8785,7 +8788,8 @@ ctl_read_write(struct ctl_scsiio *ctsio) */ if (((lba + num_blocks) > (lun->be_lun->maxlba + 1)) || ((lba + num_blocks) < lba)) { - ctl_set_lba_out_of_range(ctsio); + ctl_set_lba_out_of_range(ctsio, + MAX(lba, lun->be_lun->maxlba + 1)); ctl_done((union ctl_io *)ctsio); return (CTL_RETVAL_COMPLETE); } @@ -8894,7 +8898,8 @@ ctl_cnw(struct ctl_scsiio *ctsio) */ if (((lba + num_blocks) > (lun->be_lun->maxlba + 1)) || ((lba + num_blocks) < lba)) { - ctl_set_lba_out_of_range(ctsio); + ctl_set_lba_out_of_range(ctsio, + MAX(lba, lun->be_lun->maxlba + 1)); ctl_done((union ctl_io *)ctsio); return (CTL_RETVAL_COMPLETE); } @@ -9005,7 +9010,8 @@ ctl_verify(struct ctl_scsiio *ctsio) */ if (((lba + num_blocks) > (lun->be_lun->maxlba + 1)) || ((lba + num_blocks) < lba)) { - ctl_set_lba_out_of_range(ctsio); + ctl_set_lba_out_of_range(ctsio, + MAX(lba, lun->be_lun->maxlba + 1)); ctl_done((union ctl_io *)ctsio); return (CTL_RETVAL_COMPLETE); } Modified: head/sys/cam/ctl/ctl_error.c ============================================================================== --- head/sys/cam/ctl/ctl_error.c Mon Dec 19 18:55:10 2016 (r310284) +++ head/sys/cam/ctl/ctl_error.c Mon Dec 19 19:00:03 2016 (r310285) @@ -181,8 +181,8 @@ ctl_sense_to_desc(struct scsi_sense_data /*asc*/ sense_src->add_sense_code, /*ascq*/ sense_src->add_sense_code_qual, - /* Information Bytes */ - (scsi_4btoul(sense_src->info) != 0) ? + /* Information Bytes */ + (sense_src->error_code & SSD_ERRCODE_VALID) ? SSD_ELEM_INFO : SSD_ELEM_SKIP, sizeof(sense_src->info), sense_src->info, @@ -727,14 +727,20 @@ ctl_set_aborted(struct ctl_scsiio *ctsio } void -ctl_set_lba_out_of_range(struct ctl_scsiio *ctsio) +ctl_set_lba_out_of_range(struct ctl_scsiio *ctsio, uint64_t lba) { + uint8_t info[8]; + + scsi_u64to8b(lba, info); + /* "Logical block address out of range" */ ctl_set_sense(ctsio, /*current_error*/ 1, /*sense_key*/ SSD_KEY_ILLEGAL_REQUEST, /*asc*/ 0x21, /*ascq*/ 0x00, + /*type*/ (lba != 0) ? SSD_ELEM_INFO : SSD_ELEM_SKIP, + /*size*/ sizeof(info), /*data*/ &info, SSD_ELEM_NONE); } Modified: head/sys/cam/ctl/ctl_error.h ============================================================================== --- head/sys/cam/ctl/ctl_error.h Mon Dec 19 18:55:10 2016 (r310284) +++ head/sys/cam/ctl/ctl_error.h Mon Dec 19 19:00:03 2016 (r310285) @@ -76,7 +76,7 @@ void ctl_set_internal_failure(struct ctl uint16_t retry_count); void ctl_set_medium_error(struct ctl_scsiio *ctsio, int read); void ctl_set_aborted(struct ctl_scsiio *ctsio); -void ctl_set_lba_out_of_range(struct ctl_scsiio *ctsio); +void ctl_set_lba_out_of_range(struct ctl_scsiio *ctsio, uint64_t lba); void ctl_set_lun_stopped(struct ctl_scsiio *ctsio); void ctl_set_lun_int_reqd(struct ctl_scsiio *ctsio); void ctl_set_lun_ejected(struct ctl_scsiio *ctsio); Modified: head/sys/cam/ctl/ctl_tpc.c ============================================================================== --- head/sys/cam/ctl/ctl_tpc.c Mon Dec 19 18:55:10 2016 (r310284) +++ head/sys/cam/ctl/ctl_tpc.c Mon Dec 19 19:00:03 2016 (r310285) @@ -1104,7 +1104,8 @@ tpc_ranges_length(struct scsi_range_desc } static int -tpc_check_ranges_l(struct scsi_range_desc *range, int nrange, uint64_t maxlba) +tpc_check_ranges_l(struct scsi_range_desc *range, int nrange, uint64_t maxlba, + uint64_t *lba) { uint64_t b1; uint32_t l1; @@ -1113,8 +1114,10 @@ tpc_check_ranges_l(struct scsi_range_des for (i = 0; i < nrange; i++) { b1 = scsi_8btou64(range[i].lba); l1 = scsi_4btoul(range[i].length); - if (b1 + l1 < b1 || b1 + l1 > maxlba + 1) + if (b1 + l1 < b1 || b1 + l1 > maxlba + 1) { + *lba = MAX(b1, maxlba + 1); return (-1); + } } return (0); } @@ -1952,6 +1955,7 @@ ctl_populate_token(struct ctl_scsiio *ct struct ctl_port *port; struct tpc_list *list, *tlist; struct tpc_token *token; + uint64_t lba; int len, lendata, lendesc; CTL_DEBUG_PRINT(("ctl_populate_token\n")); @@ -2032,8 +2036,8 @@ ctl_populate_token(struct ctl_scsiio *ct if (tpc_check_ranges_l(&data->desc[0], scsi_2btoul(data->range_descriptor_length) / sizeof(struct scsi_range_desc), - lun->be_lun->maxlba) != 0) { - ctl_set_lba_out_of_range(ctsio); + lun->be_lun->maxlba, &lba) != 0) { + ctl_set_lba_out_of_range(ctsio, lba); goto done; } if (tpc_check_ranges_x(&data->desc[0], @@ -2118,6 +2122,7 @@ ctl_write_using_token(struct ctl_scsiio struct ctl_lun *lun; struct tpc_list *list, *tlist; struct tpc_token *token; + uint64_t lba; int len, lendata, lendesc; CTL_DEBUG_PRINT(("ctl_write_using_token\n")); @@ -2180,8 +2185,8 @@ ctl_write_using_token(struct ctl_scsiio if (tpc_check_ranges_l(&data->desc[0], scsi_2btoul(data->range_descriptor_length) / sizeof(struct scsi_range_desc), - lun->be_lun->maxlba) != 0) { - ctl_set_lba_out_of_range(ctsio); + lun->be_lun->maxlba, &lba) != 0) { + ctl_set_lba_out_of_range(ctsio, lba); goto done; } if (tpc_check_ranges_x(&data->desc[0], From owner-svn-src-head@freebsd.org Mon Dec 19 19:02:54 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3307EC88D8E; Mon, 19 Dec 2016 19:02:54 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from tensor.andric.com (tensor.andric.com [IPv6:2001:7b8:3a7:1:2d0:b7ff:fea0:8c26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "tensor.andric.com", Issuer "COMODO RSA Domain Validation Secure Server CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id ECC581567; Mon, 19 Dec 2016 19:02:53 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from [IPv6:2001:7b8:3a7::edad:7930:572d:abe] (unknown [IPv6:2001:7b8:3a7:0:edad:7930:572d:abe]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id B8E5441D4E; Mon, 19 Dec 2016 20:02:50 +0100 (CET) Content-Type: multipart/signed; boundary="Apple-Mail=_D7AC963E-59B0-4A18-8480-32507CCD267D"; protocol="application/pgp-signature"; micalg=pgp-sha1 Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Subject: Re: svn commit: r310171 - head/sys/sys From: Dimitry Andric In-Reply-To: Date: Mon, 19 Dec 2016 20:02:42 +0100 Cc: Ravi Pokala , Sepherosa Ziehau , src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Message-Id: <0C6B935C-496B-4EF4-963F-95286CBA45BA@FreeBSD.org> References: <201612161949.uBGJnMol059217@repo.freebsd.org> <9BD5034F-55A6-48F6-A391-A0877FF49702@panasas.com> To: Warner Losh X-Mailer: Apple Mail (2.3124) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 19:02:54 -0000 --Apple-Mail=_D7AC963E-59B0-4A18-8480-32507CCD267D Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii On 19 Dec 2016, at 19:58, Warner Losh wrote: >=20 > On Mon, Dec 19, 2016 at 1:39 AM, Ravi Pokala wrote: >> -----Original Message----- >>> From: on behalf of Sepherosa = Ziehau >>> Date: 2016-12-18, Sunday at 23:02 >>> To: Dimitry Andric >>> Cc: , , = >>> Subject: Re: svn commit: r310171 - head/sys/sys >>>=20 >>> The following patch unbreaks the LINT builds on amd64 for me after = this commit: >>> https://people.freebsd.org/~sephe/geom_sscanf.diff >>=20 >> Wouldn't it be better to use the SCN macros? >=20 > Are there other precedence for avoiding the SCN macros in the tree as > well, or is this new art? I personally don't have anything against using the PRI or SCN macros, but traditionally there has been some backlash against it, if I recall correctly. It also requires including either or , depending on circumstance or preference. -Dimitry --Apple-Mail=_D7AC963E-59B0-4A18-8480-32507CCD267D Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.30 iEYEARECAAYFAlhYLtoACgkQsF6jCi4glqMQSQCgh5lW/6sUOUx9BCZdXXCtkqaI hLQAnRonSXarpfNVM5K65bvhxOQji+2j =yv1T -----END PGP SIGNATURE----- --Apple-Mail=_D7AC963E-59B0-4A18-8480-32507CCD267D-- From owner-svn-src-head@freebsd.org Mon Dec 19 19:20:18 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E6CADC88669 for ; Mon, 19 Dec 2016 19:20:18 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from pmta2.delivery6.ore.mailhop.org (pmta2.delivery6.ore.mailhop.org [54.200.129.228]) (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 C8BC01047 for ; Mon, 19 Dec 2016 19:20:18 +0000 (UTC) (envelope-from ian@freebsd.org) X-MHO-User: 28e3e9aa-c620-11e6-acc0-c7e6c9ad01d6 X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Originating-IP: 73.78.92.27 X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (unknown [73.78.92.27]) by outbound2.ore.mailhop.org (Halon) with ESMTPSA id 28e3e9aa-c620-11e6-acc0-c7e6c9ad01d6; Mon, 19 Dec 2016 19:20:11 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id uBJJK9Fb001639; Mon, 19 Dec 2016 12:20:09 -0700 (MST) (envelope-from ian@freebsd.org) Message-ID: <1482175209.48539.9.camel@freebsd.org> Subject: Re: svn commit: r310171 - head/sys/sys From: Ian Lepore To: Warner Losh , Ravi Pokala Cc: Sepherosa Ziehau , Dimitry Andric , src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Date: Mon, 19 Dec 2016 12:20:09 -0700 In-Reply-To: References: <201612161949.uBGJnMol059217@repo.freebsd.org> <9BD5034F-55A6-48F6-A391-A0877FF49702@panasas.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.18.5.1 FreeBSD GNOME Team Port Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 19:20:19 -0000 On Mon, 2016-12-19 at 11:58 -0700, Warner Losh wrote: > On Mon, Dec 19, 2016 at 1:39 AM, Ravi Pokala wrote: > > > > -----Original Message----- > > > > > > From: on behalf of Sepherosa > > > Ziehau > > > Date: 2016-12-18, Sunday at 23:02 > > > To: Dimitry Andric > > > Cc: , , > > -src-head@freebsd.org> > > > Subject: Re: svn commit: r310171 - head/sys/sys > > > > > > The following patch unbreaks the LINT builds on amd64 for me > > > after this commit: > > > https://people.freebsd.org/~sephe/geom_sscanf.diff > > Wouldn't it be better to use the SCN macros? > Are there other precedence for avoiding the SCN macros in the tree as > well, or is this new art? > > Warner There was another commit recently the fixed the same kind of scanf error by making the variable fit the scanf type (changing uint64_t to an explicit long long unsigned, iirc).  I don't know if that alone counts as a precedent, but IMO it's a more palatible fix than the SCN/PRI ugliness. -- Ian From owner-svn-src-head@freebsd.org Mon Dec 19 19:21:29 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 59F34C88789; Mon, 19 Dec 2016 19:21:29 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 297421303; Mon, 19 Dec 2016 19:21:29 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBJJLSUf028991; Mon, 19 Dec 2016 19:21:28 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBJJLSEc028990; Mon, 19 Dec 2016 19:21:28 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201612191921.uBJJLSEc028990@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Mon, 19 Dec 2016 19:21:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310286 - head/sys/netinet6 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 19:21:29 -0000 Author: markj Date: Mon Dec 19 19:21:28 2016 New Revision: 310286 URL: https://svnweb.freebsd.org/changeset/base/310286 Log: Remove a bogus KASSERT from nd6_prefix_unlink(). The caller may unlink a prefix before purging referencing addresses. An identical assertion in nd6_prefix_del() verifies that the addresses are purged before the prefix is freed. PR: 215372 X-MFC With: r306829 Modified: head/sys/netinet6/nd6_rtr.c Modified: head/sys/netinet6/nd6_rtr.c ============================================================================== --- head/sys/netinet6/nd6_rtr.c Mon Dec 19 19:00:03 2016 (r310285) +++ head/sys/netinet6/nd6_rtr.c Mon Dec 19 19:21:28 2016 (r310286) @@ -1122,8 +1122,6 @@ void nd6_prefix_unlink(struct nd_prefix *pr, struct nd_prhead *list) { - KASSERT(pr->ndpr_addrcnt == 0, - ("prefix %p has referencing addresses", pr)); ND6_WLOCK_ASSERT(); LIST_REMOVE(pr, ndpr_entry); From owner-svn-src-head@freebsd.org Mon Dec 19 19:40:13 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 509AAC8767C; Mon, 19 Dec 2016 19:40:13 +0000 (UTC) (envelope-from jchandra@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 05D6C1A7B; Mon, 19 Dec 2016 19:40:12 +0000 (UTC) (envelope-from jchandra@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBJJeCaY036286; Mon, 19 Dec 2016 19:40:12 GMT (envelope-from jchandra@FreeBSD.org) Received: (from jchandra@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBJJeCSB036285; Mon, 19 Dec 2016 19:40:12 GMT (envelope-from jchandra@FreeBSD.org) Message-Id: <201612191940.uBJJeCSB036285@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jchandra set sender to jchandra@FreeBSD.org using -f From: "Jayachandran C." Date: Mon, 19 Dec 2016 19:40:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310289 - head/sys/dev/uart X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 19:40:13 -0000 Author: jchandra Date: Mon Dec 19 19:40:11 2016 New Revision: 310289 URL: https://svnweb.freebsd.org/changeset/base/310289 Log: Fix whitespace issues in pl011 uart driver Fix up trailing whitespace introduced by r310190. While there, fix a couple of earlier whitespace errors as well. Modified: head/sys/dev/uart/uart_dev_pl011.c Modified: head/sys/dev/uart/uart_dev_pl011.c ============================================================================== --- head/sys/dev/uart/uart_dev_pl011.c Mon Dec 19 19:39:02 2016 (r310288) +++ head/sys/dev/uart/uart_dev_pl011.c Mon Dec 19 19:40:11 2016 (r310289) @@ -173,7 +173,7 @@ uart_pl011_param(struct uart_bas *bas, i line &= ~LCR_H_PEN; /* Configure the rest */ - line &= ~LCR_H_FEN; + line &= ~LCR_H_FEN; ctrl |= (CR_RXE | CR_TXE | CR_UARTEN); if (bas->rclk != 0 && baudrate != 0) { @@ -196,7 +196,7 @@ uart_pl011_init(struct uart_bas *bas, in /* Mask all interrupts */ __uart_setreg(bas, UART_IMSC, __uart_getreg(bas, UART_IMSC) & ~IMSC_MASK_ALL); - + uart_pl011_param(bas, baudrate, databits, stopbits, parity); } @@ -307,7 +307,7 @@ uart_pl011_bus_attach(struct uart_softc struct uart_pl011_softc *psc; struct uart_bas *bas; - psc = (struct uart_pl011_softc *)sc; + psc = (struct uart_pl011_softc *)sc; bas = &sc->sc_bas; /* Enable interrupts */ @@ -373,7 +373,7 @@ uart_pl011_bus_ipend(struct uart_softc * uint32_t ints; int ipend; - psc = (struct uart_pl011_softc *)sc; + psc = (struct uart_pl011_softc *)sc; bas = &sc->sc_bas; uart_lock(sc->sc_hwmtx); @@ -472,7 +472,7 @@ uart_pl011_bus_transmit(struct uart_soft struct uart_bas *bas; int i; - psc = (struct uart_pl011_softc *)sc; + psc = (struct uart_pl011_softc *)sc; bas = &sc->sc_bas; uart_lock(sc->sc_hwmtx); @@ -504,7 +504,7 @@ uart_pl011_bus_grab(struct uart_softc *s struct uart_pl011_softc *psc; struct uart_bas *bas; - psc = (struct uart_pl011_softc *)sc; + psc = (struct uart_pl011_softc *)sc; bas = &sc->sc_bas; /* Disable interrupts on switch to polling */ @@ -519,7 +519,7 @@ uart_pl011_bus_ungrab(struct uart_softc struct uart_pl011_softc *psc; struct uart_bas *bas; - psc = (struct uart_pl011_softc *) sc; + psc = (struct uart_pl011_softc *)sc; bas = &sc->sc_bas; /* Switch to using interrupts while not grabbed */ From owner-svn-src-head@freebsd.org Mon Dec 19 20:08:01 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 03E99C87F02; Mon, 19 Dec 2016 20:08:01 +0000 (UTC) (envelope-from landonf@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 9502D1953; Mon, 19 Dec 2016 20:08:00 +0000 (UTC) (envelope-from landonf@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBJK7xAk048345; Mon, 19 Dec 2016 20:07:59 GMT (envelope-from landonf@FreeBSD.org) Received: (from landonf@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBJK7wDh048330; Mon, 19 Dec 2016 20:07:58 GMT (envelope-from landonf@FreeBSD.org) Message-Id: <201612192007.uBJK7wDh048330@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: landonf set sender to landonf@FreeBSD.org using -f From: "Landon J. Fuller" Date: Mon, 19 Dec 2016 20:07:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310290 - in head/sys: dev/bhnd/nvram mips/broadcom X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 20:08:01 -0000 Author: landonf Date: Mon Dec 19 20:07:58 2016 New Revision: 310290 URL: https://svnweb.freebsd.org/changeset/base/310290 Log: bhnd(4): minor style(9) fixes Approved by: adrian (mentor) Differential Revision: https://reviews.freebsd.org/D8755 Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data.c head/sys/dev/bhnd/nvram/bhnd_nvram_data.h head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c head/sys/dev/bhnd/nvram/bhnd_nvram_datavar.h head/sys/dev/bhnd/nvram/bhnd_nvram_private.h head/sys/dev/bhnd/nvram/bhnd_nvram_store.c head/sys/dev/bhnd/nvram/bhnd_nvram_store.h head/sys/dev/bhnd/nvram/bhnd_nvram_subr.c head/sys/dev/bhnd/nvram/bhnd_nvram_value.c head/sys/dev/bhnd/nvram/bhnd_nvram_value.h head/sys/dev/bhnd/nvram/bhnd_nvram_value_fmts.c head/sys/dev/bhnd/nvram/bhnd_nvram_value_prf.c head/sys/dev/bhnd/nvram/bhnd_nvram_valuevar.h head/sys/mips/broadcom/bcm_nvram_cfe.c Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data.c ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_data.c Mon Dec 19 19:40:11 2016 (r310289) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_data.c Mon Dec 19 20:07:58 2016 (r310290) @@ -59,7 +59,7 @@ __FBSDID("$FreeBSD$"); * @param cls The NVRAM class. */ const char * -bhnd_nvram_data_class_desc(bhnd_nvram_data_class_t *cls) +bhnd_nvram_data_class_desc(bhnd_nvram_data_class *cls) { return (cls->desc); } @@ -80,7 +80,7 @@ bhnd_nvram_data_class_desc(bhnd_nvram_da * code should be returned. */ int -bhnd_nvram_data_probe(bhnd_nvram_data_class_t *cls, struct bhnd_nvram_io *io) +bhnd_nvram_data_probe(bhnd_nvram_data_class *cls, struct bhnd_nvram_io *io) { return (cls->op_probe(io)); } @@ -106,10 +106,10 @@ bhnd_nvram_data_probe(bhnd_nvram_data_cl */ int bhnd_nvram_data_probe_classes(struct bhnd_nvram_data **data, - struct bhnd_nvram_io *io, bhnd_nvram_data_class_t *classes[], + struct bhnd_nvram_io *io, bhnd_nvram_data_class *classes[], size_t num_classes) { - bhnd_nvram_data_class_t *cls; + bhnd_nvram_data_class *cls; int error, prio, result; cls = NULL; @@ -124,7 +124,7 @@ bhnd_nvram_data_probe_classes(struct bhn /* Try to find the best data class capable of parsing io */ for (size_t i = 0; i < num_classes; i++) { - bhnd_nvram_data_class_t *next_cls; + bhnd_nvram_data_class *next_cls; next_cls = classes[i]; @@ -196,8 +196,8 @@ bhnd_nvram_data_probe_classes(struct bhn * regular unix error code will be returned. */ int -bhnd_nvram_data_new(bhnd_nvram_data_class_t *cls, - struct bhnd_nvram_data **nv, struct bhnd_nvram_io *io) +bhnd_nvram_data_new(bhnd_nvram_data_class *cls, struct bhnd_nvram_data **nv, + struct bhnd_nvram_io *io) { struct bhnd_nvram_data *data; int error; @@ -263,8 +263,8 @@ bhnd_nvram_data_release(struct bhnd_nvra * * @param nv The NVRAM data instance to be queried. */ -bhnd_nvram_data_class_t * -bhnd_nvram_data_class(struct bhnd_nvram_data *nv) +bhnd_nvram_data_class * +bhnd_nvram_data_get_class(struct bhnd_nvram_data *nv) { return (nv->cls); } @@ -423,6 +423,7 @@ bhnd_nvram_data_getvar(struct bhnd_nvram return (nv->cls->op_getvar(nv, cookiep, buf, len, type)); } + /** * A generic implementation of bhnd_nvram_data_getvar(). * @@ -438,9 +439,9 @@ int bhnd_nvram_data_generic_rp_getvar(struct bhnd_nvram_data *nv, void *cookiep, void *outp, size_t *olen, bhnd_nvram_type otype) { - bhnd_nvram_val_t val; + bhnd_nvram_val val; const struct bhnd_nvram_vardefn *vdefn; - const bhnd_nvram_val_fmt_t *fmt; + const bhnd_nvram_val_fmt *fmt; const char *name; const void *vptr; bhnd_nvram_type vtype; Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data.h ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_data.h Mon Dec 19 19:40:11 2016 (r310289) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_data.h Mon Dec 19 20:07:58 2016 (r310290) @@ -46,7 +46,7 @@ #include "bhnd_nvram_io.h" /* NVRAM data class */ -typedef struct bhnd_nvram_data_class bhnd_nvram_data_class_t; +typedef struct bhnd_nvram_data_class bhnd_nvram_data_class; /* NVRAM data instance */ struct bhnd_nvram_data; @@ -88,25 +88,24 @@ enum { parsing */ }; -const char *bhnd_nvram_data_class_desc( - bhnd_nvram_data_class_t *cls); +const char *bhnd_nvram_data_class_desc(bhnd_nvram_data_class *cls); -int bhnd_nvram_data_probe(bhnd_nvram_data_class_t *cls, +int bhnd_nvram_data_probe(bhnd_nvram_data_class *cls, struct bhnd_nvram_io *io); int bhnd_nvram_data_probe_classes( struct bhnd_nvram_data **data, struct bhnd_nvram_io *io, - bhnd_nvram_data_class_t *classes[], + bhnd_nvram_data_class *classes[], size_t num_classes); -int bhnd_nvram_data_new(bhnd_nvram_data_class_t *cls, +int bhnd_nvram_data_new(bhnd_nvram_data_class *cls, struct bhnd_nvram_data **nv, struct bhnd_nvram_io *io); struct bhnd_nvram_data *bhnd_nvram_data_retain(struct bhnd_nvram_data *nv); void bhnd_nvram_data_release(struct bhnd_nvram_data *nv); -bhnd_nvram_data_class_t *bhnd_nvram_data_class(struct bhnd_nvram_data *nv); +bhnd_nvram_data_class *bhnd_nvram_data_get_class(struct bhnd_nvram_data *nv); size_t bhnd_nvram_data_count(struct bhnd_nvram_data *nv); Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c Mon Dec 19 19:40:11 2016 (r310289) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c Mon Dec 19 20:07:58 2016 (r310290) @@ -670,7 +670,7 @@ static int bhnd_nvram_sprom_getvar(struct bhnd_nvram_data *nv, void *cookiep, void *buf, size_t *len, bhnd_nvram_type otype) { - bhnd_nvram_val_t val; + bhnd_nvram_val val; struct bhnd_nvram_sprom *sp; struct sprom_opcode_idx *idx; const struct bhnd_nvram_vardefn *var; Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_datavar.h ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_datavar.h Mon Dec 19 19:40:11 2016 (r310289) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_datavar.h Mon Dec 19 20:07:58 2016 (r310290) @@ -41,7 +41,7 @@ #include "bhnd_nvram_data.h" /** Registered NVRAM parser class instances. */ -SET_DECLARE(bhnd_nvram_data_class_set, bhnd_nvram_data_class_t); +SET_DECLARE(bhnd_nvram_data_class_set, bhnd_nvram_data_class); void *bhnd_nvram_data_generic_find(struct bhnd_nvram_data *nv, const char *name); Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_private.h ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_private.h Mon Dec 19 19:40:11 2016 (r310289) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_private.h Mon Dec 19 20:07:58 2016 (r310290) @@ -258,7 +258,7 @@ struct bhnd_nvram_vardefn { bhnd_nvram_type type; /**< variable type */ uint8_t nelem; /**< element count, or 1 if not an array-typed variable */ - const bhnd_nvram_val_fmt_t *fmt; /**< value format, or NULL */ + const bhnd_nvram_val_fmt *fmt; /**< value format, or NULL */ uint32_t flags; /**< flags (BHND_NVRAM_VF_*) */ }; Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_store.c ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_store.c Mon Dec 19 19:40:11 2016 (r310289) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_store.c Mon Dec 19 20:07:58 2016 (r310290) @@ -140,7 +140,7 @@ cleanup: */ int bhnd_nvram_store_parse_new(struct bhnd_nvram_store **store, - struct bhnd_nvram_io *io, bhnd_nvram_data_class_t *cls) + struct bhnd_nvram_io *io, bhnd_nvram_data_class *cls) { struct bhnd_nvram_data *data; int error; Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_store.h ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_store.h Mon Dec 19 19:40:11 2016 (r310289) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_store.h Mon Dec 19 20:07:58 2016 (r310290) @@ -56,7 +56,7 @@ int bhnd_nvram_store_new(struct bhnd_nvr struct bhnd_nvram_data *data); int bhnd_nvram_store_parse_new(struct bhnd_nvram_store **store, - struct bhnd_nvram_io *io, bhnd_nvram_data_class_t *cls); + struct bhnd_nvram_io *io, bhnd_nvram_data_class *cls); void bhnd_nvram_store_free(struct bhnd_nvram_store *store); Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_subr.c ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_subr.c Mon Dec 19 19:40:11 2016 (r310289) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_subr.c Mon Dec 19 20:07:58 2016 (r310290) @@ -698,8 +698,8 @@ int bhnd_nvram_value_vprintf(const char *fmt, const void *inp, size_t ilen, bhnd_nvram_type itype, char *outp, size_t *olen, va_list ap) { - bhnd_nvram_val_t val; - int error; + bhnd_nvram_val val; + int error; /* Map input buffer as a value instance */ error = bhnd_nvram_val_init(&val, NULL, inp, ilen, itype, @@ -848,8 +848,8 @@ int bhnd_nvram_value_coerce(const void *inp, size_t ilen, bhnd_nvram_type itype, void *outp, size_t *olen, bhnd_nvram_type otype) { - bhnd_nvram_val_t val; - int error; + bhnd_nvram_val val; + int error; /* Wrap input buffer in a value instance */ error = bhnd_nvram_val_init(&val, NULL, inp, ilen, Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_value.c ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_value.c Mon Dec 19 19:40:11 2016 (r310289) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_value.c Mon Dec 19 20:07:58 2016 (r310290) @@ -55,17 +55,15 @@ __FBSDID("$FreeBSD$"); #include "bhnd_nvram_valuevar.h" -static void *bhnd_nvram_val_alloc_bytes(bhnd_nvram_val_t *value, - size_t ilen, bhnd_nvram_type itype, - uint32_t flags); -static int bhnd_nvram_val_set(bhnd_nvram_val_t *value, const void *inp, - size_t ilen, bhnd_nvram_type itype, - uint32_t flags); -static int bhnd_nvram_val_set_inline(bhnd_nvram_val_t *value, +static void *bhnd_nvram_val_alloc_bytes(bhnd_nvram_val *value, size_t ilen, + bhnd_nvram_type itype, uint32_t flags); +static int bhnd_nvram_val_set(bhnd_nvram_val *value, const void *inp, + size_t ilen, bhnd_nvram_type itype, uint32_t flags); +static int bhnd_nvram_val_set_inline(bhnd_nvram_val *value, const void *inp, size_t ilen, bhnd_nvram_type itype); #define BHND_NVRAM_VAL_INITIALIZER(_fmt, _storage) \ - (bhnd_nvram_val_t) { \ + (bhnd_nvram_val) { \ .refs = 1, \ .val_storage = _storage, \ .fmt = _fmt, \ @@ -85,9 +83,9 @@ static int bhnd_nvram_val_set_inline(bh /* Common initialization support for bhnd_nvram_val_init() and * bhnd_nvram_val_new() */ static int -bhnd_nvram_val_init_common(bhnd_nvram_val_t *value, bhnd_nvram_val_storage_t - val_storage, const bhnd_nvram_val_fmt_t *fmt, const void *inp, size_t ilen, - bhnd_nvram_type itype, uint32_t flags) +bhnd_nvram_val_init_common(bhnd_nvram_val *value, + bhnd_nvram_val_storage val_storage, const bhnd_nvram_val_fmt *fmt, + const void *inp, size_t ilen, bhnd_nvram_type itype, uint32_t flags) { void *outp; bhnd_nvram_type otype; @@ -97,7 +95,7 @@ bhnd_nvram_val_init_common(bhnd_nvram_va /* Determine expected data type, and allow the format to delegate to * a new format instance */ if (fmt != NULL && fmt->op_filter != NULL) { - const bhnd_nvram_val_fmt_t *nfmt = fmt; + const bhnd_nvram_val_fmt *nfmt = fmt; /* Use the filter function to determine whether direct * initialization from is itype permitted */ @@ -181,7 +179,7 @@ bhnd_nvram_val_init_common(bhnd_nvram_va * @p fmt representation. */ int -bhnd_nvram_val_init(bhnd_nvram_val_t *value, const bhnd_nvram_val_fmt_t *fmt, +bhnd_nvram_val_init(bhnd_nvram_val *value, const bhnd_nvram_val_fmt *fmt, const void *inp, size_t ilen, bhnd_nvram_type itype, uint32_t flags) { int error; @@ -218,7 +216,7 @@ bhnd_nvram_val_init(bhnd_nvram_val_t *va * @p fmt representation. */ int -bhnd_nvram_val_new(bhnd_nvram_val_t **value, const bhnd_nvram_val_fmt_t *fmt, +bhnd_nvram_val_new(bhnd_nvram_val **value, const bhnd_nvram_val_fmt *fmt, const void *inp, size_t ilen, bhnd_nvram_type itype, uint32_t flags) { int error; @@ -246,13 +244,13 @@ bhnd_nvram_val_new(bhnd_nvram_val_t **va * * @param value The value to be copied (or retained). * - * @retval bhnd_nvram_val_t if @p value was successfully copied or retained. + * @retval bhnd_nvram_val if @p value was successfully copied or retained. * @retval NULL if allocation failed. */ -bhnd_nvram_val_t * -bhnd_nvram_val_copy(bhnd_nvram_val_t *value) +bhnd_nvram_val * +bhnd_nvram_val_copy(bhnd_nvram_val *value) { - bhnd_nvram_val_t *result; + bhnd_nvram_val *result; const void *bytes; bhnd_nvram_type type; size_t len; @@ -306,7 +304,7 @@ bhnd_nvram_val_copy(bhnd_nvram_val_t *va * @param value The value to be released. */ void -bhnd_nvram_val_release(bhnd_nvram_val_t *value) +bhnd_nvram_val_release(bhnd_nvram_val *value) { BHND_NV_ASSERT(value->refs >= 1, ("value over-released")); @@ -720,7 +718,7 @@ bhnd_nvram_val_encode_int(void *outp, si * a @p otype representation. */ int -bhnd_nvram_val_encode(bhnd_nvram_val_t *value, void *outp, size_t *olen, +bhnd_nvram_val_encode(bhnd_nvram_val *value, void *outp, size_t *olen, bhnd_nvram_type otype) { /* Prefer format implementation */ @@ -755,7 +753,7 @@ bhnd_nvram_val_encode(bhnd_nvram_val_t * * a @p otype representation. */ int -bhnd_nvram_val_encode_elem(bhnd_nvram_val_t *value, const void *inp, +bhnd_nvram_val_encode_elem(bhnd_nvram_val *value, const void *inp, size_t ilen, void *outp, size_t *olen, bhnd_nvram_type otype) { /* Prefer format implementation */ @@ -777,7 +775,7 @@ bhnd_nvram_val_encode_elem(bhnd_nvram_va * @param[out] otype Data type. */ const void * -bhnd_nvram_val_bytes(bhnd_nvram_val_t *value, size_t *olen, +bhnd_nvram_val_bytes(bhnd_nvram_val *value, size_t *olen, bhnd_nvram_type *otype) { /* Provide type and length */ @@ -819,7 +817,7 @@ bhnd_nvram_val_bytes(bhnd_nvram_val_t *v * @retval NULL If the end of the element array is reached. */ const void * -bhnd_nvram_val_next(bhnd_nvram_val_t *value, const void *prev, size_t *len) +bhnd_nvram_val_next(bhnd_nvram_val *value, const void *prev, size_t *len) { /* Prefer the format implementation */ if (value->fmt != NULL && value->fmt->op_next != NULL) @@ -834,7 +832,7 @@ bhnd_nvram_val_next(bhnd_nvram_val_t *va * @param value The value to be queried. */ bhnd_nvram_type -bhnd_nvram_val_elem_type(bhnd_nvram_val_t *value) +bhnd_nvram_val_elem_type(bhnd_nvram_val *value) { return (bhnd_nvram_base_type(value->data_type)); } @@ -843,7 +841,7 @@ bhnd_nvram_val_elem_type(bhnd_nvram_val_ * Return the total number of elements represented by @p value. */ size_t -bhnd_nvram_val_nelem(bhnd_nvram_val_t *value) +bhnd_nvram_val_nelem(bhnd_nvram_val *value) { const void *bytes; bhnd_nvram_type type; @@ -890,7 +888,7 @@ bhnd_nvram_val_nelem(bhnd_nvram_val_t *v * all supported NVRAM data types. */ int -bhnd_nvram_val_generic_encode(bhnd_nvram_val_t *value, void *outp, size_t *olen, +bhnd_nvram_val_generic_encode(bhnd_nvram_val *value, void *outp, size_t *olen, bhnd_nvram_type otype) { const void *inp; @@ -1003,7 +1001,7 @@ bhnd_nvram_val_generic_encode(bhnd_nvram * all supported NVRAM data types. */ int -bhnd_nvram_val_generic_encode_elem(bhnd_nvram_val_t *value, const void *inp, +bhnd_nvram_val_generic_encode_elem(bhnd_nvram_val *value, const void *inp, size_t ilen, void *outp, size_t *olen, bhnd_nvram_type otype) { bhnd_nvram_type itype; @@ -1037,7 +1035,7 @@ bhnd_nvram_val_generic_encode_elem(bhnd_ * all supported NVRAM data types. */ const void * -bhnd_nvram_val_generic_next(bhnd_nvram_val_t *value, const void *prev, +bhnd_nvram_val_generic_next(bhnd_nvram_val *value, const void *prev, size_t *len) { const uint8_t *inp; @@ -1101,7 +1099,7 @@ bhnd_nvram_val_generic_next(bhnd_nvram_v * @p itype. */ static int -bhnd_nvram_val_set(bhnd_nvram_val_t *value, const void *inp, size_t ilen, +bhnd_nvram_val_set(bhnd_nvram_val *value, const void *inp, size_t ilen, bhnd_nvram_type itype, uint32_t flags) { void *bytes; @@ -1154,7 +1152,7 @@ bhnd_nvram_val_set(bhnd_nvram_val_t *val * @p itype. */ static int -bhnd_nvram_val_set_inline(bhnd_nvram_val_t *value, const void *inp, size_t ilen, +bhnd_nvram_val_set_inline(bhnd_nvram_val *value, const void *inp, size_t ilen, bhnd_nvram_type itype) { BHND_NVRAM_VAL_ASSERT_EMPTY(value); @@ -1278,7 +1276,7 @@ bhnd_nvram_val_set_inline(bhnd_nvram_val * @retval NULL If @p value is an externally allocated instance. */ static void * -bhnd_nvram_val_alloc_bytes(bhnd_nvram_val_t *value, size_t ilen, +bhnd_nvram_val_alloc_bytes(bhnd_nvram_val *value, size_t ilen, bhnd_nvram_type itype, uint32_t flags) { void *ptr; Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_value.h ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_value.h Mon Dec 19 19:40:11 2016 (r310289) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_value.h Mon Dec 19 20:07:58 2016 (r310290) @@ -42,51 +42,51 @@ #include "bhnd_nvram.h" -typedef struct bhnd_nvram_val_fmt bhnd_nvram_val_fmt_t; -typedef struct bhnd_nvram_val bhnd_nvram_val_t; +typedef struct bhnd_nvram_val_fmt bhnd_nvram_val_fmt; +typedef struct bhnd_nvram_val bhnd_nvram_val; -int bhnd_nvram_val_init(bhnd_nvram_val_t *value, - const bhnd_nvram_val_fmt_t *fmt, +int bhnd_nvram_val_init(bhnd_nvram_val *value, + const bhnd_nvram_val_fmt *fmt, const void *inp, size_t ilen, bhnd_nvram_type itype, uint32_t flags); -int bhnd_nvram_val_new(bhnd_nvram_val_t **value, - const bhnd_nvram_val_fmt_t *fmt, +int bhnd_nvram_val_new(bhnd_nvram_val **value, + const bhnd_nvram_val_fmt *fmt, const void *inp, size_t ilen, bhnd_nvram_type itype, uint32_t flags); -bhnd_nvram_val_t *bhnd_nvram_val_copy(bhnd_nvram_val_t *value); +bhnd_nvram_val *bhnd_nvram_val_copy(bhnd_nvram_val *value); void bhnd_nvram_val_release( - bhnd_nvram_val_t *value); + bhnd_nvram_val *value); -int bhnd_nvram_val_encode(bhnd_nvram_val_t *value, +int bhnd_nvram_val_encode(bhnd_nvram_val *value, void *outp, size_t *olen, bhnd_nvram_type otype); int bhnd_nvram_val_encode_elem( - bhnd_nvram_val_t *value, const void *inp, + bhnd_nvram_val *value, const void *inp, size_t ilen, void *outp, size_t *olen, bhnd_nvram_type otype); -int bhnd_nvram_val_printf(bhnd_nvram_val_t *value, +int bhnd_nvram_val_printf(bhnd_nvram_val *value, const char *fmt, char *outp, size_t *olen, ...); -int bhnd_nvram_val_vprintf(bhnd_nvram_val_t *value, +int bhnd_nvram_val_vprintf(bhnd_nvram_val *value, const char *fmt, char *outp, size_t *olen, va_list ap); -const void *bhnd_nvram_val_bytes(bhnd_nvram_val_t *value, +const void *bhnd_nvram_val_bytes(bhnd_nvram_val *value, size_t *len, bhnd_nvram_type *itype); bhnd_nvram_type bhnd_nvram_val_elem_type( - bhnd_nvram_val_t *value); + bhnd_nvram_val *value); -const void *bhnd_nvram_val_next(bhnd_nvram_val_t *value, +const void *bhnd_nvram_val_next(bhnd_nvram_val *value, const void *prev, size_t *len); -size_t bhnd_nvram_val_nelem(bhnd_nvram_val_t *value); +size_t bhnd_nvram_val_nelem(bhnd_nvram_val *value); /** * NVRAM value flags @@ -152,7 +152,7 @@ typedef enum { * as-is. */ BHND_NVRAM_VAL_STORAGE_DYNAMIC = 2, -} bhnd_nvram_val_storage_t; +} bhnd_nvram_val_storage; /** * @internal @@ -183,16 +183,16 @@ typedef enum { * when deallocating the value */ BHND_NVRAM_VAL_DATA_EXT_ALLOC = 4, -} bhnd_nvram_val_data_storage_t; +} bhnd_nvram_val_data_storage; /** * NVRAM value */ struct bhnd_nvram_val { volatile u_int refs; /**< reference count */ - bhnd_nvram_val_storage_t val_storage; /**< value structure storage */ - const bhnd_nvram_val_fmt_t *fmt; /**< value format, or NULL for default behavior */ - bhnd_nvram_val_data_storage_t data_storage; /**< data storage */ + bhnd_nvram_val_storage val_storage; /**< value structure storage */ + const bhnd_nvram_val_fmt *fmt; /**< value format, or NULL for default behavior */ + bhnd_nvram_val_data_storage data_storage; /**< data storage */ bhnd_nvram_type data_type; /**< data type */ size_t data_len; /**< data size */ @@ -213,7 +213,7 @@ struct bhnd_nvram_val { /** Declare a bhnd_nvram_val_fmt with name @p _n */ #define BHND_NVRAM_VAL_TYPE_DECL(_n) \ - extern const bhnd_nvram_val_fmt_t bhnd_nvram_val_ ## _n ## _fmt; + extern const bhnd_nvram_val_fmt bhnd_nvram_val_ ## _n ## _fmt; BHND_NVRAM_VAL_TYPE_DECL(bcm_decimal); BHND_NVRAM_VAL_TYPE_DECL(bcm_hex); Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_value_fmts.c ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_value_fmts.c Mon Dec 19 19:40:11 2016 (r310289) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_value_fmts.c Mon Dec 19 20:07:58 2016 (r310290) @@ -63,61 +63,61 @@ static bool bhnd_nvram_ident_num_strin size_t ilen, u_int base, u_int *obase); static int bhnd_nvram_val_bcm_macaddr_filter( - const bhnd_nvram_val_fmt_t **fmt, const void *inp, + const bhnd_nvram_val_fmt **fmt, const void *inp, size_t ilen, bhnd_nvram_type itype); static int bhnd_nvram_val_bcm_macaddr_encode( - bhnd_nvram_val_t *value, void *outp, size_t *olen, + bhnd_nvram_val *value, void *outp, size_t *olen, bhnd_nvram_type otype); static int bhnd_nvram_val_bcm_macaddr_string_filter( - const bhnd_nvram_val_fmt_t **fmt, const void *inp, + const bhnd_nvram_val_fmt **fmt, const void *inp, size_t ilen, bhnd_nvram_type itype); static int bhnd_nvram_val_bcm_macaddr_string_encode_elem( - bhnd_nvram_val_t *value, const void *inp, + bhnd_nvram_val *value, const void *inp, size_t ilen, void *outp, size_t *olen, bhnd_nvram_type otype); static const void *bhnd_nvram_val_bcm_macaddr_string_next( - bhnd_nvram_val_t *value, const void *prev, + bhnd_nvram_val *value, const void *prev, size_t *len); static int bhnd_nvram_val_bcm_int_filter( - const bhnd_nvram_val_fmt_t **fmt, const void *inp, + const bhnd_nvram_val_fmt **fmt, const void *inp, size_t ilen, bhnd_nvram_type itype); -static int bhnd_nvram_val_bcm_int_encode(bhnd_nvram_val_t *value, +static int bhnd_nvram_val_bcm_int_encode(bhnd_nvram_val *value, void *outp, size_t *olen, bhnd_nvram_type otype); static int bhnd_nvram_val_bcm_decimal_encode_elem( - bhnd_nvram_val_t *value, const void *inp, + bhnd_nvram_val *value, const void *inp, size_t ilen, void *outp, size_t *olen, bhnd_nvram_type otype); static int bhnd_nvram_val_bcm_hex_encode_elem( - bhnd_nvram_val_t *value, const void *inp, + bhnd_nvram_val *value, const void *inp, size_t ilen, void *outp, size_t *olen, bhnd_nvram_type otype); static int bhnd_nvram_val_bcm_leddc_filter( - const bhnd_nvram_val_fmt_t **fmt, const void *inp, + const bhnd_nvram_val_fmt **fmt, const void *inp, size_t ilen, bhnd_nvram_type itype); static int bhnd_nvram_val_bcm_leddc_encode_elem( - bhnd_nvram_val_t *value, const void *inp, + bhnd_nvram_val *value, const void *inp, size_t ilen, void *outp, size_t *olen, bhnd_nvram_type otype); -static int bhnd_nvram_val_bcmstr_encode(bhnd_nvram_val_t *value, +static int bhnd_nvram_val_bcmstr_encode(bhnd_nvram_val *value, void *outp, size_t *olen, bhnd_nvram_type otype); static int bhnd_nvram_val_bcmstr_csv_filter( - const bhnd_nvram_val_fmt_t **fmt, const void *inp, + const bhnd_nvram_val_fmt **fmt, const void *inp, size_t ilen, bhnd_nvram_type itype); -static const void *bhnd_nvram_val_bcmstr_csv_next(bhnd_nvram_val_t *value, +static const void *bhnd_nvram_val_bcmstr_csv_next(bhnd_nvram_val *value, const void *prev, size_t *len); /** * Broadcom NVRAM MAC address format. */ -const bhnd_nvram_val_fmt_t bhnd_nvram_val_bcm_macaddr_fmt = { +const bhnd_nvram_val_fmt bhnd_nvram_val_bcm_macaddr_fmt = { .name = "bcm-macaddr", .native_type = BHND_NVRAM_TYPE_UINT8_ARRAY, .op_filter = bhnd_nvram_val_bcm_macaddr_filter, @@ -125,7 +125,7 @@ const bhnd_nvram_val_fmt_t bhnd_nvram_va }; /** Broadcom NVRAM MAC address string format. */ -static const bhnd_nvram_val_fmt_t bhnd_nvram_val_bcm_macaddr_string_fmt = { +static const bhnd_nvram_val_fmt bhnd_nvram_val_bcm_macaddr_string_fmt = { .name = "bcm-macaddr-string", .native_type = BHND_NVRAM_TYPE_STRING, .op_filter = bhnd_nvram_val_bcm_macaddr_string_filter, @@ -136,7 +136,7 @@ static const bhnd_nvram_val_fmt_t bhnd_n /** * Broadcom NVRAM LED duty-cycle format. */ -const bhnd_nvram_val_fmt_t bhnd_nvram_val_bcm_leddc_fmt = { +const bhnd_nvram_val_fmt bhnd_nvram_val_bcm_leddc_fmt = { .name = "bcm-leddc", .native_type = BHND_NVRAM_TYPE_UINT32, .op_filter = bhnd_nvram_val_bcm_leddc_filter, @@ -152,7 +152,7 @@ const bhnd_nvram_val_fmt_t bhnd_nvram_va * - Positive values will be string-encoded without a prefix. * - Negative values will be string-encoded with a leading '-' sign. */ -const bhnd_nvram_val_fmt_t bhnd_nvram_val_bcm_decimal_fmt = { +const bhnd_nvram_val_fmt bhnd_nvram_val_bcm_decimal_fmt = { .name = "bcm-decimal", .native_type = BHND_NVRAM_TYPE_UINT64, .op_filter = bhnd_nvram_val_bcm_int_filter, @@ -171,7 +171,7 @@ const bhnd_nvram_val_fmt_t bhnd_nvram_va * both signed and negative, it will be string encoded as a negative decimal * value, not as a twos-complement hexadecimal value. */ -const bhnd_nvram_val_fmt_t bhnd_nvram_val_bcm_hex_fmt = { +const bhnd_nvram_val_fmt bhnd_nvram_val_bcm_hex_fmt = { .name = "bcm-hex", .native_type = BHND_NVRAM_TYPE_UINT64, .op_filter = bhnd_nvram_val_bcm_int_filter, @@ -185,14 +185,14 @@ const bhnd_nvram_val_fmt_t bhnd_nvram_va * Handles standard, comma-delimited, and octet-string values as used in * Broadcom NVRAM data. */ -const bhnd_nvram_val_fmt_t bhnd_nvram_val_bcm_string_fmt = { +const bhnd_nvram_val_fmt bhnd_nvram_val_bcm_string_fmt = { .name = "bcm-string", .native_type = BHND_NVRAM_TYPE_STRING, .op_encode = bhnd_nvram_val_bcmstr_encode, }; /** Broadcom comma-delimited string. */ -static const bhnd_nvram_val_fmt_t bhnd_nvram_val_bcm_string_csv_fmt = { +static const bhnd_nvram_val_fmt bhnd_nvram_val_bcm_string_csv_fmt = { .name = "bcm-string[]", .native_type = BHND_NVRAM_TYPE_STRING, .op_filter = bhnd_nvram_val_bcmstr_csv_filter, @@ -203,7 +203,7 @@ static const bhnd_nvram_val_fmt_t bhnd_n * Common hex/decimal integer filter implementation. */ static int -bhnd_nvram_val_bcm_int_filter(const bhnd_nvram_val_fmt_t **fmt, const void *inp, +bhnd_nvram_val_bcm_int_filter(const bhnd_nvram_val_fmt **fmt, const void *inp, size_t ilen, bhnd_nvram_type itype) { bhnd_nvram_type itype_base; @@ -233,7 +233,7 @@ bhnd_nvram_val_bcm_int_filter(const bhnd * Broadcom hex/decimal integer encode implementation. */ static int -bhnd_nvram_val_bcm_int_encode(bhnd_nvram_val_t *value, void *outp, size_t *olen, +bhnd_nvram_val_bcm_int_encode(bhnd_nvram_val *value, void *outp, size_t *olen, bhnd_nvram_type otype) { /* If encoding to a string, format multiple elements (if any) with a @@ -248,7 +248,7 @@ bhnd_nvram_val_bcm_int_encode(bhnd_nvram * Broadcom hex integer encode_elem implementation. */ static int -bhnd_nvram_val_bcm_hex_encode_elem(bhnd_nvram_val_t *value, const void *inp, +bhnd_nvram_val_bcm_hex_encode_elem(bhnd_nvram_val *value, const void *inp, size_t ilen, void *outp, size_t *olen, bhnd_nvram_type otype) { bhnd_nvram_type itype; @@ -303,7 +303,7 @@ bhnd_nvram_val_bcm_hex_encode_elem(bhnd_ * Broadcom decimal integer encode_elem implementation. */ static int -bhnd_nvram_val_bcm_decimal_encode_elem(bhnd_nvram_val_t *value, const void *inp, +bhnd_nvram_val_bcm_decimal_encode_elem(bhnd_nvram_val *value, const void *inp, size_t ilen, void *outp, size_t *olen, bhnd_nvram_type otype) { const char *sfmt; @@ -325,7 +325,7 @@ bhnd_nvram_val_bcm_decimal_encode_elem(b * Broadcom LED duty-cycle filter. */ static int -bhnd_nvram_val_bcm_leddc_filter(const bhnd_nvram_val_fmt_t **fmt, +bhnd_nvram_val_bcm_leddc_filter(const bhnd_nvram_val_fmt **fmt, const void *inp, size_t ilen, bhnd_nvram_type itype) { const char *p; @@ -356,7 +356,7 @@ bhnd_nvram_val_bcm_leddc_filter(const bh * Broadcom LED duty-cycle encode. */ static int -bhnd_nvram_val_bcm_leddc_encode_elem(bhnd_nvram_val_t *value, const void *inp, +bhnd_nvram_val_bcm_leddc_encode_elem(bhnd_nvram_val *value, const void *inp, size_t ilen, void *outp, size_t *olen, bhnd_nvram_type otype) { bhnd_nvram_type itype; @@ -536,11 +536,11 @@ bhnd_nvram_val_bcm_leddc_encode_elem(bhn * Broadcom NVRAM string encoding. */ static int -bhnd_nvram_val_bcmstr_encode(bhnd_nvram_val_t *value, void *outp, - size_t *olen, bhnd_nvram_type otype) +bhnd_nvram_val_bcmstr_encode(bhnd_nvram_val *value, void *outp, size_t *olen, + bhnd_nvram_type otype) { - bhnd_nvram_val_t array; - const bhnd_nvram_val_fmt_t *array_fmt; + bhnd_nvram_val array; + const bhnd_nvram_val_fmt *array_fmt; const void *inp; bhnd_nvram_type itype; size_t ilen; @@ -588,7 +588,7 @@ bhnd_nvram_val_bcmstr_encode(bhnd_nvram_ * Broadcom NVRAM comma-delimited string filter. */ static int -bhnd_nvram_val_bcmstr_csv_filter(const bhnd_nvram_val_fmt_t **fmt, +bhnd_nvram_val_bcmstr_csv_filter(const bhnd_nvram_val_fmt **fmt, const void *inp, size_t ilen, bhnd_nvram_type itype) { switch (itype) { @@ -604,7 +604,7 @@ bhnd_nvram_val_bcmstr_csv_filter(const b * Broadcom NVRAM comma-delimited string iteration. */ static const void * -bhnd_nvram_val_bcmstr_csv_next(bhnd_nvram_val_t *value, const void *prev, +bhnd_nvram_val_bcmstr_csv_next(bhnd_nvram_val *value, const void *prev, size_t *len) { const char *next; @@ -671,7 +671,7 @@ bhnd_nvram_val_bcmstr_csv_next(bhnd_nvra * MAC address filter. */ static int -bhnd_nvram_val_bcm_macaddr_filter(const bhnd_nvram_val_fmt_t **fmt, +bhnd_nvram_val_bcm_macaddr_filter(const bhnd_nvram_val_fmt **fmt, const void *inp, size_t ilen, bhnd_nvram_type itype) { switch (itype) { @@ -690,7 +690,7 @@ bhnd_nvram_val_bcm_macaddr_filter(const * MAC address encoding. */ static int -bhnd_nvram_val_bcm_macaddr_encode(bhnd_nvram_val_t *value, void *outp, +bhnd_nvram_val_bcm_macaddr_encode(bhnd_nvram_val *value, void *outp, size_t *olen, bhnd_nvram_type otype) { const void *inp; @@ -714,7 +714,7 @@ bhnd_nvram_val_bcm_macaddr_encode(bhnd_n * MAC address string filter. */ static int -bhnd_nvram_val_bcm_macaddr_string_filter(const bhnd_nvram_val_fmt_t **fmt, +bhnd_nvram_val_bcm_macaddr_string_filter(const bhnd_nvram_val_fmt **fmt, const void *inp, size_t ilen, bhnd_nvram_type itype) { switch (itype) { @@ -735,7 +735,7 @@ bhnd_nvram_val_bcm_macaddr_string_filter * MAC address string octet encoding. */ static int -bhnd_nvram_val_bcm_macaddr_string_encode_elem(bhnd_nvram_val_t *value, +bhnd_nvram_val_bcm_macaddr_string_encode_elem(bhnd_nvram_val *value, const void *inp, size_t ilen, void *outp, size_t *olen, bhnd_nvram_type otype) { @@ -765,7 +765,7 @@ bhnd_nvram_val_bcm_macaddr_string_encode * MAC address string octet iteration. */ static const void * -bhnd_nvram_val_bcm_macaddr_string_next(bhnd_nvram_val_t *value, const void *prev, +bhnd_nvram_val_bcm_macaddr_string_next(bhnd_nvram_val *value, const void *prev, size_t *len) { const char *next; Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_value_prf.c ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_value_prf.c Mon Dec 19 19:40:11 2016 (r310289) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_value_prf.c Mon Dec 19 20:07:58 2016 (r310290) @@ -98,7 +98,7 @@ static char const bhnd_nv_hex2ascii[] = * underflow) the representation defined by @p fmt. */ int -bhnd_nvram_val_printf(bhnd_nvram_val_t *value, const char *fmt, char *outp, +bhnd_nvram_val_printf(bhnd_nvram_val *value, const char *fmt, char *outp, size_t *olen, ...) { va_list ap; @@ -209,7 +209,7 @@ bhnd_nvram_val_printf(bhnd_nvram_val_t * * underflow) the representation defined by @p fmt. */ int -bhnd_nvram_val_vprintf(bhnd_nvram_val_t *value, const char *fmt, char *outp, +bhnd_nvram_val_vprintf(bhnd_nvram_val *value, const char *fmt, char *outp, size_t *olen, va_list ap) { const void *elem; Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_valuevar.h ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_valuevar.h Mon Dec 19 19:40:11 2016 (r310289) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_valuevar.h Mon Dec 19 20:07:58 2016 (r310290) @@ -34,12 +34,12 @@ #include "bhnd_nvram_value.h" -int bhnd_nvram_val_generic_encode(bhnd_nvram_val_t *value, +int bhnd_nvram_val_generic_encode(bhnd_nvram_val *value, void *outp, size_t *olen, bhnd_nvram_type otype); -int bhnd_nvram_val_generic_encode_elem(bhnd_nvram_val_t *value, +int bhnd_nvram_val_generic_encode_elem(bhnd_nvram_val *value, const void *inp, size_t ilen, void *outp, size_t *olen, bhnd_nvram_type otype); -const void *bhnd_nvram_val_generic_next(bhnd_nvram_val_t *value, +const void *bhnd_nvram_val_generic_next(bhnd_nvram_val *value, const void *prev, size_t *len); /** * Filter input data prior to initialization. @@ -60,24 +60,24 @@ const void *bhnd_nvram_val_generic_next( * @retval EFAULT if @p ilen is not correctly aligned for elements of * @p itype. */ -typedef int (bhnd_nvram_val_op_filter)(const bhnd_nvram_val_fmt_t **fmt, +typedef int (bhnd_nvram_val_op_filter)(const bhnd_nvram_val_fmt **fmt, const void *inp, size_t ilen, bhnd_nvram_type itype); /** @see bhnd_nvram_val_encode() */ -typedef int (bhnd_nvram_val_op_encode)(bhnd_nvram_val_t *value, void *outp, +typedef int (bhnd_nvram_val_op_encode)(bhnd_nvram_val *value, void *outp, size_t *olen, bhnd_nvram_type otype); /** @see bhnd_nvram_val_encode_elem() */ -typedef int (bhnd_nvram_val_op_encode_elem)(bhnd_nvram_val_t *value, +typedef int (bhnd_nvram_val_op_encode_elem)(bhnd_nvram_val *value, const void *inp, size_t ilen, void *outp, size_t *olen, bhnd_nvram_type otype); /** @see bhnd_nvram_val_next() */ -typedef const void *(bhnd_nvram_val_op_next)(bhnd_nvram_val_t *value, +typedef const void *(bhnd_nvram_val_op_next)(bhnd_nvram_val *value, const void *prev, size_t *len); /** @see bhnd_nvram_val_nelem() */ -typedef size_t (bhnd_nvram_val_op_nelem)(bhnd_nvram_val_t *value); +typedef size_t (bhnd_nvram_val_op_nelem)(bhnd_nvram_val *value); /** * NVRAM value format. Modified: head/sys/mips/broadcom/bcm_nvram_cfe.c ============================================================================== --- head/sys/mips/broadcom/bcm_nvram_cfe.c Mon Dec 19 19:40:11 2016 (r310289) +++ head/sys/mips/broadcom/bcm_nvram_cfe.c Mon Dec 19 20:07:58 2016 (r310290) @@ -83,8 +83,7 @@ static int bhnd_nvram_iocfe_new(struc char *dname); static struct bhnd_nvram_io *bhnd_nvram_find_cfedev(device_t dev, - char **dname, - bhnd_nvram_data_class_t **cls); + char **dname, bhnd_nvram_data_class **cls); /** Known CFE NVRAM device names, in probe order. */ static char *nvram_cfe_devs[] = { @@ -95,7 +94,7 @@ static char *nvram_cfe_devs[] = { }; /** Supported CFE NVRAM formats, in probe order. */ -static bhnd_nvram_data_class_t * const nvram_cfe_fmts[] = { +static bhnd_nvram_data_class * const nvram_cfe_fmts[] = { &bhnd_nvram_bcm_class, &bhnd_nvram_tlv_class }; @@ -105,7 +104,7 @@ static int bhnd_nvram_cfe_probe(device_t dev) { struct bhnd_nvram_io *io; - bhnd_nvram_data_class_t *cls; + bhnd_nvram_data_class *cls; const char *cls_desc; char *dname; char *desc; @@ -135,7 +134,7 @@ static int bhnd_nvram_cfe_attach(device_t dev) { struct bhnd_nvram_cfe_softc *sc; - bhnd_nvram_data_class_t *cls; + bhnd_nvram_data_class *cls; struct bhnd_nvram_io *io; char *dname; int error; @@ -215,8 +214,7 @@ bhnd_nvram_cfe_setvar(device_t dev, cons * @retval NULL if no usable CFE NVRAM device could be found. */ static struct bhnd_nvram_io * -bhnd_nvram_find_cfedev(device_t dev, char **dname, - bhnd_nvram_data_class_t **cls) +bhnd_nvram_find_cfedev(device_t dev, char **dname, bhnd_nvram_data_class **cls) { struct bhnd_nvram_io *io; int devinfo; From owner-svn-src-head@freebsd.org Mon Dec 19 20:11:50 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 26836C88137; Mon, 19 Dec 2016 20:11:50 +0000 (UTC) (envelope-from landonf@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 DC4061D43; Mon, 19 Dec 2016 20:11:49 +0000 (UTC) (envelope-from landonf@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBJKBnBL051384; Mon, 19 Dec 2016 20:11:49 GMT (envelope-from landonf@FreeBSD.org) Received: (from landonf@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBJKBmYt051380; Mon, 19 Dec 2016 20:11:48 GMT (envelope-from landonf@FreeBSD.org) Message-Id: <201612192011.uBJKBmYt051380@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: landonf set sender to landonf@FreeBSD.org using -f From: "Landon J. Fuller" Date: Mon, 19 Dec 2016 20:11:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310291 - in head/sys: conf dev/bhnd/nvram modules/bhnd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 20:11:50 -0000 Author: landonf Date: Mon Dec 19 20:11:48 2016 New Revision: 310291 URL: https://svnweb.freebsd.org/changeset/base/310291 Log: bhnd(4): Implement a new bhnd_nvram_plist and bhnd_nvram_prop API for representing arbitrary Broadcom NVRAM key/value pairs. This will be used to track pending changes in bhnd_nvram_store, and provide support for exporting all or a device subpath for NVRAM (as required by some fullmac wifi chipsets). Approved by: adrian (mentor) Differential Revision: https://reviews.freebsd.org/D8756 Added: head/sys/dev/bhnd/nvram/bhnd_nvram_plist.c (contents, props changed) head/sys/dev/bhnd/nvram/bhnd_nvram_plist.h (contents, props changed) head/sys/dev/bhnd/nvram/bhnd_nvram_plistvar.h (contents, props changed) Modified: head/sys/conf/files head/sys/dev/bhnd/nvram/bhnd_nvram_private.h head/sys/dev/bhnd/nvram/bhnd_nvram_value.c head/sys/dev/bhnd/nvram/bhnd_nvram_value.h head/sys/modules/bhnd/Makefile Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Mon Dec 19 20:07:58 2016 (r310290) +++ head/sys/conf/files Mon Dec 19 20:11:48 2016 (r310291) @@ -1241,6 +1241,7 @@ dev/bhnd/nvram/bhnd_nvram_if.m optional dev/bhnd/nvram/bhnd_nvram_io.c optional bhnd dev/bhnd/nvram/bhnd_nvram_iobuf.c optional bhnd dev/bhnd/nvram/bhnd_nvram_iores.c optional bhnd +dev/bhnd/nvram/bhnd_nvram_plist.c optional bhnd dev/bhnd/nvram/bhnd_nvram_store.c optional bhnd dev/bhnd/nvram/bhnd_nvram_subr.c optional bhnd dev/bhnd/nvram/bhnd_nvram_value.c optional bhnd Added: head/sys/dev/bhnd/nvram/bhnd_nvram_plist.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_plist.c Mon Dec 19 20:11:48 2016 (r310291) @@ -0,0 +1,947 @@ +/*- + * Copyright (c) 2015-2016 Landon Fuller + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any + * redistribution must be conditioned upon including a substantially + * similar Disclaimer requirement for further binary redistribution. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, + * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGES. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include + +#ifdef _KERNEL + +#include + +#else /* !_KERNEL */ + +#include +#include +#include +#include + +#endif /* _KERNEL */ + +#include "bhnd_nvram_plistvar.h" +#include "bhnd_nvram_private.h" + +static bhnd_nvram_plist_entry *bhnd_nvram_plist_get_entry( + bhnd_nvram_plist *plist, const char *name); + +/** + * Allocate and initialize a new, empty property list. + * + * The caller is responsible for releasing the returned property value + * via bhnd_nvram_plist_release(). + * + * @retval non-NULL success + * @retval NULL if allocation fails. + */ +bhnd_nvram_plist * +bhnd_nvram_plist_new(void) +{ + bhnd_nvram_plist *plist; + + plist = bhnd_nv_calloc(1, sizeof(*plist)); + if (plist == NULL) + return NULL; + + /* Implicit caller-owned reference */ + plist->refs = 1; + + /* Initialize entry list */ + plist->num_entries = 0; + TAILQ_INIT(&plist->entries); + + /* Initialize entry hash table */ + for (size_t i = 0; i < nitems(plist->names); i++) + LIST_INIT(&plist->names[i]); + + return (plist); +} + +/** + * Retain a reference and return @p plist to the caller. + * + * The caller is responsible for releasing their reference ownership via + * bhnd_nvram_plist_release(). + * + * @param plist The property list to be retained. + */ +bhnd_nvram_plist * +bhnd_nvram_plist_retain(bhnd_nvram_plist *plist) +{ + BHND_NV_ASSERT(plist->refs >= 1, ("plist over-released")); + + refcount_acquire(&plist->refs); + return (plist); +} + +/** + * Release a reference to @p plist. + * + * If this is the last reference, all associated resources will be freed. + * + * @param plist The property list to be released. + */ +void +bhnd_nvram_plist_release(bhnd_nvram_plist *plist) +{ + bhnd_nvram_plist_entry *ple, *ple_next; + + BHND_NV_ASSERT(plist->refs >= 1, ("plist over-released")); + + /* Drop reference */ + if (!refcount_release(&plist->refs)) + return; + + /* Free all property entries */ + TAILQ_FOREACH_SAFE(ple, &plist->entries, pl_link, ple_next) { + bhnd_nvram_prop_release(ple->prop); + bhnd_nv_free(ple); + } + + /* Free plist instance */ + bhnd_nv_free(plist); +} + +/** + * Return a shallow copy of @p plist. + * + * The caller is responsible for releasing the returned property value + * via bhnd_nvram_plist_release(). + * + * @retval non-NULL success + * @retval NULL if allocation fails. + */ +bhnd_nvram_plist * +bhnd_nvram_plist_copy(bhnd_nvram_plist *plist) +{ + bhnd_nvram_plist *copy; + bhnd_nvram_prop *prop; + int error; + + /* Allocate new, empty plist */ + if ((copy = bhnd_nvram_plist_new()) == NULL) + return (NULL); + + /* Append all properties */ + prop = NULL; + while ((prop = bhnd_nvram_plist_next(plist, prop)) != NULL) { + error = bhnd_nvram_plist_append(copy, prop); + if (error) { + if (error != ENOMEM) { + BHND_NV_LOG("error copying property: %d\n", + error); + } + + bhnd_nvram_plist_release(copy); + return (NULL); + } + } + + /* Return ownership of the copy to our caller */ + return (copy); +} + +/** + * Return the number of properties in @p plist. + */ +size_t +bhnd_nvram_plist_count(bhnd_nvram_plist *plist) +{ + return (plist->num_entries); +} + +/** + * Return true if @p plist contains a property name @p name, false otherwise. + * + * @param plist The property list to be queried. + * @param name The property name to be queried. + */ +bool +bhnd_nvram_plist_contains(bhnd_nvram_plist *plist, const char *name) +{ + if (bhnd_nvram_plist_get_entry(plist, name) != NULL) + return (true); + + return (false); +} + +/** + * Replace the current property value for a property matching the name + * of @p prop, maintaining the property's current order in @p plist. + * + * If a matching property is not found in @p plist, @p prop will instead be + * appended. + * + * @param plist The property list to be modified. + * @param prop The replacement property. + * + * @retval 0 success + * @retval ENOMEM if allocation fails. + * @retval non-zero if modifying @p plist otherwise fails, a regular unix + * error code will be returned. + */ +int +bhnd_nvram_plist_replace(bhnd_nvram_plist *plist, bhnd_nvram_prop *prop) +{ + bhnd_nvram_plist_entry *entry; + + /* Fetch current entry */ + entry = bhnd_nvram_plist_get_entry(plist, prop->name); + if (entry == NULL) { + /* Not found -- append property instead */ + return (bhnd_nvram_plist_append(plist, prop)); + } + + /* Replace the current entry's property reference */ + bhnd_nvram_prop_release(entry->prop); + entry->prop = bhnd_nvram_prop_retain(prop); + + return (0); +} + +/** + * Replace the current property value for a property matching @p name, + * maintaining the property's order in @p plist. + * + * If @p name is not found in @p plist, a new property will be appended. + * + * @param plist The property list to be modified. + * @param name The name of the property to be replaced. + * @param val The replacement value for @p name. + * + * @retval 0 success + * @retval ENOMEM if allocation fails. + * @retval non-zero if modifying @p plist otherwise fails, a regular unix + * error code will be returned. + */ +int +bhnd_nvram_plist_replace_val(bhnd_nvram_plist *plist, const char *name, + bhnd_nvram_val *val) +{ + bhnd_nvram_prop *prop; + int error; + + /* Construct a new property instance for the name and value */ + if ((prop = bhnd_nvram_prop_new(name, val)) == NULL) + return (ENOMEM); + + /* Attempt replace */ + error = bhnd_nvram_plist_replace(plist, prop); + bhnd_nvram_prop_release(prop); + + return (error); +} + +/** + * Replace the current property value for a property matching @p name, copying + * the new property value from the given @p inp buffer of @p itype and @p ilen. + * + * The current property order of @p name in @p plist will be maintained. + * + * If @p name is not found in @p plist, a new property will be appended. + * + * @param plist The property list to be modified. + * @param name The name of the property to be replaced. + * @param inp Input buffer. + * @param ilen Input buffer length. + * @param itype Input buffer type. + * + * @retval 0 success + * @retval ENOMEM if allocation fails. + * @retval non-zero if modifying @p plist otherwise fails, a regular unix + * error code will be returned. + */ +int +bhnd_nvram_plist_replace_bytes(bhnd_nvram_plist *plist, const char *name, + const void *inp, size_t ilen, bhnd_nvram_type itype) +{ + bhnd_nvram_prop *prop; + int error; + + if ((prop = bhnd_nvram_prop_bytes_new(name, inp, ilen, itype)) == NULL) + return (ENOMEM); + + error = bhnd_nvram_plist_replace(plist, prop); + bhnd_nvram_prop_release(prop); + + return (error); +} + +/** + * Replace the current property value for a property matching @p name, copying + * the new property value from @p val. + * + * The current property order of @p name in @p plist will be maintained. + * + * If @p name is not found in @p plist, a new property will be appended. + * + * @param plist The property list to be modified. + * @param name The name of the property to be replaced. + * @param val The property's replacement string value. + * + * @retval 0 success + * @retval ENOMEM if allocation fails. + * @retval non-zero if modifying @p plist otherwise fails, a regular unix + * error code will be returned. + */ +int +bhnd_nvram_plist_replace_string(bhnd_nvram_plist *plist, const char *name, + const char *val) +{ + return (bhnd_nvram_plist_replace_bytes(plist, name, val, strlen(val)+1, + BHND_NVRAM_TYPE_STRING)); +} + +/** + * Remove the property entry for the property @p name, if any. + * + * @param plist The property list to be modified. + * @param name The name of the property to be removed. + */ +void +bhnd_nvram_plist_remove(bhnd_nvram_plist *plist, const char *name) +{ + bhnd_nvram_plist_entry *entry; + + /* Fetch entry */ + entry = bhnd_nvram_plist_get_entry(plist, name); + if (entry == NULL) + return; + + /* Remove from entry list and hash table */ + TAILQ_REMOVE(&plist->entries, entry, pl_link); + LIST_REMOVE(entry, pl_hash_link); + + /* Free plist entry */ + bhnd_nvram_prop_release(entry->prop); + bhnd_nv_free(entry); + + /* Decrement entry count */ + BHND_NV_ASSERT(plist->num_entries > 0, ("entry count over-release")); + plist->num_entries--; +} + +/** + * Fetch the property list entry for @p name, if any. + * + * @param plist The property list to be queried. + * @param name The property name to be queried. + * + * @retval non-NULL if @p name is found. + * @retval NULL if @p name is not found. + */ +static bhnd_nvram_plist_entry * +bhnd_nvram_plist_get_entry(bhnd_nvram_plist *plist, const char *name) +{ + bhnd_nvram_plist_entry_list *hash_list; + bhnd_nvram_plist_entry *entry; + uint32_t h; + + h = hash32_str(name, HASHINIT); + hash_list = &plist->names[h % nitems(plist->names)]; + + LIST_FOREACH(entry, hash_list, pl_hash_link) { + if (strcmp(entry->prop->name, name) == 0) + return (entry); + }; + + /* Not found */ + return (NULL); +} + +/** + * Append all properties from @p tail to @p plist. + * + * @param plist The property list to be modified. + * @param tail The property list to append. + * + * @retval 0 success + * @retval ENOMEM if allocation fails. + * @retval EEXIST an existing property from @p tail was found in @p plist. + */ +int +bhnd_nvram_plist_append_list(bhnd_nvram_plist *plist, bhnd_nvram_plist *tail) +{ + bhnd_nvram_prop *p; + int error; + + p = NULL; + while ((p = bhnd_nvram_plist_next(tail, p)) != NULL) { + if ((error = bhnd_nvram_plist_append(plist, p))) + return (error); + } + + return (0); +} + +/** + * Append @p prop to @p plist. + * + * @param plist The property list to be modified. + * @param prop The property to append. + * + * @retval 0 success + * @retval ENOMEM if allocation fails. + * @retval EEXIST an existing property with @p name was found in @p plist. + */ +int +bhnd_nvram_plist_append(bhnd_nvram_plist *plist, bhnd_nvram_prop *prop) +{ + bhnd_nvram_plist_entry_list *hash_list; + bhnd_nvram_plist_entry *entry; + uint32_t h; + + if (bhnd_nvram_plist_contains(plist, prop->name)) + return (EEXIST); + + /* Have we hit the maximum representable entry count? */ + if (plist->num_entries == SIZE_MAX) + return (ENOMEM); + + /* Allocate new entry */ + entry = bhnd_nv_malloc(sizeof(*entry)); + if (entry == NULL) + return (ENOMEM); + + entry->prop = bhnd_nvram_prop_retain(prop); + + /* Append to entry list */ + TAILQ_INSERT_TAIL(&plist->entries, entry, pl_link); + + /* Add to name-based hash table */ + h = hash32_str(prop->name, HASHINIT); + hash_list = &plist->names[h % nitems(plist->names)]; + LIST_INSERT_HEAD(hash_list, entry, pl_hash_link); + + /* Increment entry count */ + plist->num_entries++; + + return (0); +} + +/** + * Append a new property to @p plist with @p name and @p val. + * + * @param plist The property list to be modified. + * @param name The name of the property to be appended. + * @param val The value of the property to be appended. + * + * @retval 0 success + * @retval ENOMEM if allocation fails. + * @retval EEXIST an existing property with @p name was found in @p plist. + */ +int +bhnd_nvram_plist_append_val(bhnd_nvram_plist *plist, const char *name, + bhnd_nvram_val *val) +{ + bhnd_nvram_prop *prop; + int error; + + if ((prop = bhnd_nvram_prop_new(name, val)) == NULL) + return (ENOMEM); + + error = bhnd_nvram_plist_append(plist, prop); + bhnd_nvram_prop_release(prop); + + return (error); +} + +/** + * Append a new property to @p plist, copying the property value from the + * given @p inp buffer of @p itype and @p ilen. + * + * @param plist The property list to be modified. + * @param name The name of the property to be appended. + * @param inp Input buffer. + * @param ilen Input buffer length. + * @param itype Input buffer type. + * + * @retval 0 success + * @retval ENOMEM if allocation fails. + * @retval EEXIST an existing property with @p name was found in @p plist. + */ +int +bhnd_nvram_plist_append_bytes(bhnd_nvram_plist *plist, const char *name, + const void *inp, size_t ilen, bhnd_nvram_type itype) +{ + bhnd_nvram_prop *prop; + int error; + + if ((prop = bhnd_nvram_prop_bytes_new(name, inp, ilen, itype)) == NULL) + return (ENOMEM); + + error = bhnd_nvram_plist_append(plist, prop); + bhnd_nvram_prop_release(prop); + + return (error); +} + +/** + * Append a new string property to @p plist, copying the property value from + * @p val. + * + * @param plist The property list to be modified. + * @param name The name of the property to be appended. + * @param val The new property's string value. + * + * @retval 0 success + * @retval ENOMEM if allocation fails. + * @retval EEXIST an existing property with @p name was found in @p plist. + */ +int +bhnd_nvram_plist_append_string(bhnd_nvram_plist *plist, const char *name, + const char *val) +{ + return (bhnd_nvram_plist_append_bytes(plist, name, val, strlen(val)+1, + BHND_NVRAM_TYPE_STRING)); +} + +/** + * Iterate over all properties in @p plist. + * + * @param plist The property list to be iterated. + * @param prop A property in @p plist, or NULL to return the first + * property in @p plist. + * + * @retval non-NULL A borrowed reference to the next property in @p plist. + * @retval NULL If the end of the property list is reached or @p prop + * is not found in @p plist. + */ +bhnd_nvram_prop * +bhnd_nvram_plist_next(bhnd_nvram_plist *plist, bhnd_nvram_prop *prop) +{ + bhnd_nvram_plist_entry *entry; + + if (prop == NULL) { + if ((entry = TAILQ_FIRST(&plist->entries)) == NULL) + return (NULL); + + return (entry->prop); + } + + /* Look up previous property entry by name */ + if ((entry = bhnd_nvram_plist_get_entry(plist, prop->name)) == NULL) + return (NULL); + + /* The property instance must be identical */ + if (entry->prop != prop) + return (NULL); + + /* Fetch next entry */ + if ((entry = TAILQ_NEXT(entry, pl_link)) == NULL) + return (NULL); + + return (entry->prop); +} + +/** + * Return a borrowed reference to a named property, or NULL if @p name is + * not found in @p plist. + * + * @param plist The property list to be queried. + * @param name The name of the property to be returned. + * + * @retval non-NULL if @p name is found. + * @retval NULL if @p name is not found. + */ +bhnd_nvram_prop * +bhnd_nvram_plist_get_prop(bhnd_nvram_plist *plist, const char *name) +{ + bhnd_nvram_plist_entry *entry; + + if ((entry = bhnd_nvram_plist_get_entry(plist, name)) == NULL) + return (NULL); + + return (entry->prop); +} + +/** + * Return a borrowed reference to the named property's value, or NULL if + * @p name is not found in @p plist. + * + * @param plist The property list to be queried. + * @param name The name of the property to be returned. + * + * @retval non-NULL if @p name is found. + * @retval NULL if @p name is not found. + */ +bhnd_nvram_val * +bhnd_nvram_plist_get_val(bhnd_nvram_plist *plist, const char *name) +{ + bhnd_nvram_prop *prop; + + if ((prop = bhnd_nvram_plist_get_prop(plist, name)) == NULL) + return (NULL); + + return (bhnd_nvram_prop_val(prop)); +} + +/** + * Attempt to encode a named property's value as @p otype, writing the result + * to @p outp. + * + * @param plist The property list to be queried. + * @param name The name of the property value to be returned. + * @param[out] outp On success, the value will be written to this + * buffer. This argment may be NULL if the value is + * not desired. + * @param[in,out] olen The capacity of @p outp. On success, will be set + * to the actual size of the requested value. + * @param otype The data type to be written to @p outp. + * + * @retval 0 success + * @retval ENOENT If @p name is not found in @p plist. + * @retval ENOMEM If the @p outp is non-NULL, and the provided @p olen + * is too small to hold the encoded value. + * @retval EFTYPE If value coercion from @p prop to @p otype is + * impossible. + * @retval ERANGE If value coercion would overflow (or underflow) the + * a @p otype representation. + */ +int +bhnd_nvram_plist_get_encoded(bhnd_nvram_plist *plist, const char *name, + void *outp, size_t olen, bhnd_nvram_type otype) +{ + bhnd_nvram_prop *prop; + + if ((prop = bhnd_nvram_plist_get_prop(plist, name)) == NULL) + return (ENOENT); + + return (bhnd_nvram_prop_encode(prop, outp, &olen, otype)); +} + +/** + * Return the character representation of a named property's value. + * + * @param plist The property list to be queried. + * @param name The name of the property value to be returned. + * @param[out] val On success, the character value of @p name. + * + * @retval 0 success + * @retval ENOENT If @p name is not found in @p plist. + * @retval EFTYPE If coercion of the property's value to @p val. + * @retval ERANGE If coercion of the property's value would overflow + * (or underflow) @p val. + */ +int +bhnd_nvram_plist_get_char(bhnd_nvram_plist *plist, const char *name, + u_char *val) +{ + return (bhnd_nvram_plist_get_encoded(plist, name, val, sizeof(*val), + BHND_NVRAM_TYPE_CHAR)); +} + +/** + * Return the uint8 representation of a named property's value. + * + * @param plist The property list to be queried. + * @param name The name of the property value to be returned. + * @param[out] val On success, the uint8 value of @p name. + * + * @retval 0 success + * @retval ENOENT If @p name is not found in @p plist. + * @retval EFTYPE If coercion of the property's value to @p val. + * @retval ERANGE If coercion of the property's value would overflow + * (or underflow) @p val. + */ +int +bhnd_nvram_plist_get_uint8(bhnd_nvram_plist *plist, const char *name, + uint8_t *val) +{ + return (bhnd_nvram_plist_get_encoded(plist, name, val, sizeof(*val), + BHND_NVRAM_TYPE_UINT8)); +} + +/** + * Return the uint16 representation of a named property's value. + * + * @param plist The property list to be queried. + * @param name The name of the property value to be returned. + * @param[out] val On success, the uint16 value of @p name. + * + * @retval 0 success + * @retval ENOENT If @p name is not found in @p plist. + * @retval EFTYPE If coercion of the property's value to @p val. + * @retval ERANGE If coercion of the property's value would overflow + * (or underflow) @p val. + */ +int +bhnd_nvram_plist_get_uint16(bhnd_nvram_plist *plist, const char *name, + uint16_t *val) +{ + return (bhnd_nvram_plist_get_encoded(plist, name, val, sizeof(*val), + BHND_NVRAM_TYPE_UINT16)); +} + +/** + * Return the uint32 representation of a named property's value. + * + * @param plist The property list to be queried. + * @param name The name of the property value to be returned. + * @param[out] val On success, the uint32 value of @p name. + * + * @retval 0 success + * @retval ENOENT If @p name is not found in @p plist. + * @retval EFTYPE If coercion of the property's value to @p val. + * @retval ERANGE If coercion of the property's value would overflow + * (or underflow) @p val. + */ +int +bhnd_nvram_plist_get_uint32(bhnd_nvram_plist *plist, const char *name, + uint32_t *val) +{ + return (bhnd_nvram_plist_get_encoded(plist, name, val, sizeof(*val), + BHND_NVRAM_TYPE_UINT32)); +} + +/** + * Return the uint64 representation of a named property's value. + * + * @param plist The property list to be queried. + * @param name The name of the property value to be returned. + * @param[out] val On success, the uint64 value of @p name. + * + * @retval 0 success + * @retval ENOENT If @p name is not found in @p plist. + * @retval EFTYPE If coercion of the property's value to @p val. + * @retval ERANGE If coercion of the property's value would overflow + * (or underflow) @p val. + */ +int +bhnd_nvram_plist_get_uint64(bhnd_nvram_plist *plist, const char *name, + uint64_t *val) +{ + return (bhnd_nvram_plist_get_encoded(plist, name, val, sizeof(*val), + BHND_NVRAM_TYPE_UINT64)); +} + +/** + * Allocate and initialize a new property value. + * + * The caller is responsible for releasing the returned property value + * via bhnd_nvram_prop_release(). + * + * @param name Property name. + * @param val Property value. + * + * @retval non-NULL success + * @retval NULL if allocation fails. + */ +struct bhnd_nvram_prop * +bhnd_nvram_prop_new(const char *name, bhnd_nvram_val *val) +{ + struct bhnd_nvram_prop *prop; + + prop = bhnd_nv_calloc(1, sizeof(*prop)); + if (prop == NULL) + return NULL; + + /* Implicit caller-owned reference */ + prop->refs = 1; + + if ((prop->name = bhnd_nv_strdup(name)) == NULL) + goto failed; + + if ((prop->val = bhnd_nvram_val_copy(val)) == NULL) + goto failed; + + return (prop); + +failed: + if (prop->name != NULL) + bhnd_nv_free(prop->name); + + if (prop->val != NULL) + bhnd_nvram_val_release(prop->val); + + bhnd_nv_free(prop); + return (NULL); +} + +/** + * Allocate a new property value and attempt to initialize its value from + * the given @p inp buffer of @p itype and @p ilen. + * + * The caller is responsible for releasing the returned property value + * via bhnd_nvram_prop_release(). + * + * @param name Property name. + * @param inp Input buffer. + * @param ilen Input buffer length. + * @param itype Input buffer type. + * + * @retval non-NULL success + * @retval NULL if allocation or initialization fails. + */ +bhnd_nvram_prop * +bhnd_nvram_prop_bytes_new(const char *name, const void *inp, size_t ilen, + bhnd_nvram_type itype) +{ + bhnd_nvram_prop *prop; + bhnd_nvram_val *val; + int error; + + /* Construct new value instance */ + error = bhnd_nvram_val_new(&val, NULL, inp, ilen, itype, + BHND_NVRAM_VAL_DYNAMIC); + if (error) { + if (error != ENOMEM) { + BHND_NV_LOG("invalid input data; initialization " + "failed: %d\n", error); + } + + return (NULL); + } + + /* Delegate to default implementation */ + prop = bhnd_nvram_prop_new(name, val); + + /* Clean up */ + bhnd_nvram_val_release(val); + return (prop); +} + +/** + * Retain a reference and return @p prop to the caller. + * + * The caller is responsible for releasing their reference ownership via + * bhnd_nvram_prop_release(). + * + * @param prop The property to be retained. + */ +bhnd_nvram_prop * +bhnd_nvram_prop_retain(bhnd_nvram_prop *prop) +{ + BHND_NV_ASSERT(prop->refs >= 1, ("prop over-released")); + + refcount_acquire(&prop->refs); + return (prop); +} + +/** + * Release a reference to @p prop. + * + * If this is the last reference, all associated resources will be freed. + * + * @param prop The property to be released. + */ +void +bhnd_nvram_prop_release(bhnd_nvram_prop *prop) +{ + BHND_NV_ASSERT(prop->refs >= 1, ("prop over-released")); + + /* Drop reference */ + if (!refcount_release(&prop->refs)) + return; + + /* Free property data */ + bhnd_nvram_val_release(prop->val); + bhnd_nv_free(prop->name); + bhnd_nv_free(prop); +} + +/** + * Return a borrowed reference to the property's name. + * + * @param prop The property to query. + */ +const char * +bhnd_nvram_prop_name(bhnd_nvram_prop *prop) +{ + return (prop->name); +} + +/** + * Return a borrowed reference to the property's value. + * + * @param prop The property to query. + */ +bhnd_nvram_val * +bhnd_nvram_prop_val(bhnd_nvram_prop *prop) +{ + return (prop->val); +} + +/** + * Return the property's value type. + * + * @param prop The property to query. + */ +bhnd_nvram_type +bhnd_nvram_prop_type(bhnd_nvram_prop *prop) +{ + return (bhnd_nvram_val_type(prop->val)); +} + +/** + * Return a borrowed reference to the property's internal value representation. + * + * @param prop The property to query. + * @param[out] olen The returned data's size, in bytes. + * @param[out] otype The returned data's type. + */ +const void * +bhnd_nvram_prop_bytes(bhnd_nvram_prop *prop, size_t *olen, + bhnd_nvram_type *otype) +{ + const void *bytes; + + bytes = bhnd_nvram_val_bytes(prop->val, olen, otype); + BHND_NV_ASSERT(*otype == bhnd_nvram_prop_type(prop), ("type mismatch")); + + return (bytes); +} + +/** + * Attempt to encode the property's value as @p otype, writing the result + * to @p outp. + * + * @param prop The property to be encoded. + * @param[out] outp On success, the value will be written to this + * buffer. This argment may be NULL if the value is + * not desired. + * @param[in,out] olen The capacity of @p outp. On success, will be set + * to the actual size of the requested value. + * @param otype The data type to be written to @p outp. + * + * @retval 0 success + * @retval ENOMEM If the @p outp is non-NULL, and the provided @p olen + * is too small to hold the encoded value. + * @retval EFTYPE If value coercion from @p prop to @p otype is + * impossible. + * @retval ERANGE If value coercion would overflow (or underflow) the + * a @p otype representation. + */ +int +bhnd_nvram_prop_encode(bhnd_nvram_prop *prop, void *outp, size_t *olen, + bhnd_nvram_type otype) +{ + return (bhnd_nvram_val_encode(prop->val, outp, olen, otype)); +} Added: head/sys/dev/bhnd/nvram/bhnd_nvram_plist.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_plist.h Mon Dec 19 20:11:48 2016 (r310291) @@ -0,0 +1,126 @@ +/*- + * Copyright (c) 2015-2016 Landon Fuller + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any + * redistribution must be conditioned upon including a substantially + * similar Disclaimer requirement for further binary redistribution. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, + * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGES. + * + * $FreeBSD$ + */ + +#ifndef _BHND_NVRAM_BHND_NVRAM_PLIST_H_ +#define _BHND_NVRAM_BHND_NVRAM_PLIST_H_ + +#ifdef _KERNEL +#include +#else /* !_KERNEL */ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@freebsd.org Mon Dec 19 20:20:35 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D4CF7C885D4; Mon, 19 Dec 2016 20:20:35 +0000 (UTC) (envelope-from landonf@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 9CED911A7; Mon, 19 Dec 2016 20:20:35 +0000 (UTC) (envelope-from landonf@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBJKKYT1052386; Mon, 19 Dec 2016 20:20:34 GMT (envelope-from landonf@FreeBSD.org) Received: (from landonf@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBJKKY0O052377; Mon, 19 Dec 2016 20:20:34 GMT (envelope-from landonf@FreeBSD.org) Message-Id: <201612192020.uBJKKY0O052377@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: landonf set sender to landonf@FreeBSD.org using -f From: "Landon J. Fuller" Date: Mon, 19 Dec 2016 20:20:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310292 - in head/sys: conf dev/bhnd/nvram modules/bhnd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 20:20:35 -0000 Author: landonf Date: Mon Dec 19 20:20:33 2016 New Revision: 310292 URL: https://svnweb.freebsd.org/changeset/base/310292 Log: bhnd(4): support direct conversion of bhnd_nvram_val This adds support for bhnd_nvram_val_convert_init() and bhnd_nvram_val_convert_new(), which may be used to perform value format-aware encoding of an NVRAM value to a new target format/type. This will be used to simplify converting to/from serialized format-specific NVRAM value representations to common external representations. Approved by: adrian (mentor) Differential Revision: https://reviews.freebsd.org/D8757 Added: head/sys/dev/bhnd/nvram/bhnd_nvram_value_subr.c (contents, props changed) Modified: head/sys/conf/files head/sys/dev/bhnd/nvram/bhnd_nvram.h head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcm.c head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c head/sys/dev/bhnd/nvram/bhnd_nvram_private.h head/sys/dev/bhnd/nvram/bhnd_nvram_store.c head/sys/dev/bhnd/nvram/bhnd_nvram_subr.c head/sys/dev/bhnd/nvram/bhnd_nvram_value.c head/sys/dev/bhnd/nvram/bhnd_nvram_value.h head/sys/dev/bhnd/nvram/bhnd_nvram_value_fmts.c head/sys/dev/bhnd/nvram/bhnd_nvram_value_prf.c head/sys/dev/bhnd/nvram/bhnd_nvram_valuevar.h head/sys/modules/bhnd/Makefile Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Mon Dec 19 20:11:48 2016 (r310291) +++ head/sys/conf/files Mon Dec 19 20:20:33 2016 (r310292) @@ -1247,6 +1247,7 @@ dev/bhnd/nvram/bhnd_nvram_subr.c optiona dev/bhnd/nvram/bhnd_nvram_value.c optional bhnd dev/bhnd/nvram/bhnd_nvram_value_fmts.c optional bhnd dev/bhnd/nvram/bhnd_nvram_value_prf.c optional bhnd +dev/bhnd/nvram/bhnd_nvram_value_subr.c optional bhnd dev/bhnd/nvram/bhnd_sprom.c optional bhnd dev/bhnd/siba/siba.c optional siba bhnd dev/bhnd/siba/siba_bhndb.c optional siba bhnd bhndb Modified: head/sys/dev/bhnd/nvram/bhnd_nvram.h ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram.h Mon Dec 19 20:11:48 2016 (r310291) +++ head/sys/dev/bhnd/nvram/bhnd_nvram.h Mon Dec 19 20:20:33 2016 (r310292) @@ -111,14 +111,16 @@ typedef enum { NUL-terminated strings */ } bhnd_nvram_type; -const char *bhnd_nvram_string_array_next(const char *inp, size_t ilen, - const char *prev); - bool bhnd_nvram_is_signed_type(bhnd_nvram_type type); bool bhnd_nvram_is_unsigned_type(bhnd_nvram_type type); bool bhnd_nvram_is_int_type(bhnd_nvram_type type); bool bhnd_nvram_is_array_type(bhnd_nvram_type type); bhnd_nvram_type bhnd_nvram_base_type(bhnd_nvram_type type); const char *bhnd_nvram_type_name(bhnd_nvram_type type); +size_t bhnd_nvram_type_width(bhnd_nvram_type type); +size_t bhnd_nvram_type_host_align(bhnd_nvram_type type); + +const char *bhnd_nvram_string_array_next(const char *inp, size_t ilen, + const char *prev, size_t *olen); #endif /* _BHND_NVRAM_BHND_NVRAM_H_ */ Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcm.c ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcm.c Mon Dec 19 20:11:48 2016 (r310291) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcm.c Mon Dec 19 20:20:33 2016 (r310292) @@ -647,10 +647,8 @@ bhnd_nvram_bcm_getvar_ptr(struct bhnd_nv /* Handle header variables */ if ((hvar = bhnd_nvram_bcm_to_hdrvar(bcm, cookiep)) != NULL) { - BHND_NV_ASSERT( - hvar->len % bhnd_nvram_value_size(hvar->type, NULL, 0, - hvar->nelem) == 0, - ("length is not aligned to type width")); + BHND_NV_ASSERT(bhnd_nvram_value_check_aligned(&hvar->value, + hvar->len, hvar->type) == 0, ("value misaligned")); *type = hvar->type; *len = hvar->len; Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c Mon Dec 19 20:11:48 2016 (r310291) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c Mon Dec 19 20:20:33 2016 (r310292) @@ -597,7 +597,7 @@ bhnd_nvram_sprom_read_offset(struct bhnd } sp_value; /* Determine type width */ - sp_width = bhnd_nvram_value_size(type, NULL, 0, 1); + sp_width = bhnd_nvram_type_width(type); if (sp_width == 0) { /* Variable-width types are unsupported */ BHND_NV_LOG("invalid %s SPROM offset type %d\n", var->name, @@ -716,7 +716,7 @@ bhnd_nvram_sprom_getvar(struct bhnd_nvra var_btype = bhnd_nvram_base_type(var->type); /* Calculate total byte length of the native encoding */ - if ((iwidth = bhnd_nvram_value_size(var_btype, NULL, 0, 1)) == 0) { + if ((iwidth = bhnd_nvram_value_size(NULL, 0, var_btype, 1)) == 0) { /* SPROM does not use (and we do not support) decoding of * variable-width data types */ BHND_NV_LOG("invalid SPROM data type: %d", var->type); @@ -1219,7 +1219,7 @@ sprom_opcode_set_type(struct sprom_opcod } /* Fetch type width for use as our scale value */ - width = bhnd_nvram_value_size(type, NULL, 0, 1); + width = bhnd_nvram_type_width(type); if (width == 0) { SPROM_OP_BAD(state, "unsupported variable-width type: %d\n", type); Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_private.h ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_private.h Mon Dec 19 20:11:48 2016 (r310291) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_private.h Mon Dec 19 20:20:33 2016 (r310292) @@ -167,11 +167,15 @@ int bhnd_nvram_value_coerce(const vo void *outp, size_t *olen, bhnd_nvram_type otype); -int bhnd_nvram_value_nelem(bhnd_nvram_type type, - const void *data, size_t len, +int bhnd_nvram_value_check_aligned(const void *inp, + size_t ilen, bhnd_nvram_type itype); + +int bhnd_nvram_value_nelem(const void *inp, + size_t ilen, bhnd_nvram_type itype, size_t *nelem); -size_t bhnd_nvram_value_size(bhnd_nvram_type type, - const void *data, size_t nbytes, + +size_t bhnd_nvram_value_size(const void *inp, + size_t ilen, bhnd_nvram_type itype, size_t nelem); int bhnd_nvram_value_printf(const char *fmt, @@ -183,6 +187,10 @@ int bhnd_nvram_value_vprintf(const c bhnd_nvram_type itype, char *outp, size_t *olen, va_list ap); +const void *bhnd_nvram_value_array_next(const void *inp, + size_t ilen, bhnd_nvram_type itype, + const void *prev, size_t *olen); + const struct bhnd_nvram_vardefn *bhnd_nvram_find_vardefn(const char *varname); const struct bhnd_nvram_vardefn *bhnd_nvram_get_vardefn(size_t id); size_t bhnd_nvram_get_vardefn_id( Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_store.c ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_store.c Mon Dec 19 20:11:48 2016 (r310291) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_store.c Mon Dec 19 20:20:33 2016 (r310292) @@ -288,7 +288,7 @@ bhnd_nvram_store_setvar(struct bhnd_nvra /* Verify buffer size alignment for the given type. If this is a * variable width type, a width of 0 will always pass this check */ - if (len % bhnd_nvram_value_size(type, buf, len, 1) != 0) + if (len % bhnd_nvram_value_size(buf, len, type, 1) != 0) return (EINVAL); /* Determine string format (or directly add variable, if a C string) */ Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_subr.c ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_subr.c Mon Dec 19 20:11:48 2016 (r310291) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_subr.c Mon Dec 19 20:20:33 2016 (r310292) @@ -71,12 +71,6 @@ __FBSDID("$FreeBSD$"); MALLOC_DEFINE(M_BHND_NVRAM, "bhnd_nvram", "bhnd nvram data"); #endif -/** signed/unsigned 32-bit integer value storage */ -union bhnd_nvram_int_storage { - uint32_t u32; - int32_t s32; -}; - /* * CRC-8 lookup table used to checksum SPROM and NVRAM data via * bhnd_nvram_crc8(). @@ -343,112 +337,44 @@ bhnd_nvram_base_type(bhnd_nvram_type typ } /** - * Calculate the number of elements represented by a value of @p len bytes - * with @p type. - * - * @param type The value type. - * @param data The actual data to be queried, or NULL if unknown. - * @param len The length in bytes of @p data, or if @p data is NULL, - * the expected length in bytes. - * @param[out] nelem On success, the number of elements. If @p type is not - * a fixed width type (e.g. BHND_NVRAM_TYPE_STRING_ARRAY), - * and @p data is NULL, an @p nelem value of 0 will be - * returned. - * - * @retval 0 success - * @retval EFTYPE if @p type is not an array type, and @p len is not - * equal to the size of a single element of @p type. - * @retval EFAULT if @p len is not correctly aligned for elements of - * @p type. + * Return the size, in bytes, of a single element of @p type, or 0 + * if @p type is a variable-width type. + * + * @param type The type to query. */ -int -bhnd_nvram_value_nelem(bhnd_nvram_type type, const void *data, size_t len, - size_t *nelem) +size_t +bhnd_nvram_type_width(bhnd_nvram_type type) { - bhnd_nvram_type base_type; - size_t base_size; - - /* Length must be aligned to the element size */ - base_type = bhnd_nvram_base_type(type); - base_size = bhnd_nvram_value_size(base_type, NULL, 0, 1); - if (base_size != 0 && len % base_size != 0) - return (EFAULT); - switch (type) { case BHND_NVRAM_TYPE_STRING: - case BHND_NVRAM_TYPE_STRING_ARRAY: { - const char *p; - size_t nleft; - - /* Cannot determine the element count without parsing - * the actual data */ - if (data == NULL) { - *nelem = 0; - return (0); - } - - /* Iterate over the NUL-terminated strings to calculate - * total element count */ - p = data; - nleft = len; - *nelem = 0; - while (nleft > 0) { - size_t slen; - - /* Increment element count */ - (*nelem)++; - - /* If not a string array, data must not contain more - * than one entry. */ - if (!bhnd_nvram_is_array_type(type) && *nelem > 1) - return (EFTYPE); - - /* Determine string length */ - slen = strnlen(p, nleft); - nleft -= slen; - - /* Advance input */ - p += slen; - - /* Account for trailing NUL, if we haven't hit the end - * of the input */ - if (nleft > 0) { - nleft--; - p++; - } - } - - return (0); - } - case BHND_NVRAM_TYPE_INT8: - case BHND_NVRAM_TYPE_UINT8: - case BHND_NVRAM_TYPE_CHAR: - case BHND_NVRAM_TYPE_INT16: - case BHND_NVRAM_TYPE_UINT16: - case BHND_NVRAM_TYPE_INT32: - case BHND_NVRAM_TYPE_UINT32: - case BHND_NVRAM_TYPE_INT64: - case BHND_NVRAM_TYPE_UINT64: - /* Length must be equal to the size of exactly one - * element (arrays can represent zero elements -- non-array - * types cannot) */ - if (len != base_size) - return (EFTYPE); - *nelem = 1; + case BHND_NVRAM_TYPE_STRING_ARRAY: return (0); + case BHND_NVRAM_TYPE_CHAR: + case BHND_NVRAM_TYPE_CHAR_ARRAY: + case BHND_NVRAM_TYPE_UINT8: case BHND_NVRAM_TYPE_UINT8_ARRAY: - case BHND_NVRAM_TYPE_UINT16_ARRAY: - case BHND_NVRAM_TYPE_UINT32_ARRAY: - case BHND_NVRAM_TYPE_UINT64_ARRAY: + case BHND_NVRAM_TYPE_INT8: case BHND_NVRAM_TYPE_INT8_ARRAY: + return (sizeof(uint8_t)); + + case BHND_NVRAM_TYPE_UINT16: + case BHND_NVRAM_TYPE_UINT16_ARRAY: + case BHND_NVRAM_TYPE_INT16: case BHND_NVRAM_TYPE_INT16_ARRAY: + return (sizeof(uint16_t)); + + case BHND_NVRAM_TYPE_UINT32: + case BHND_NVRAM_TYPE_UINT32_ARRAY: + case BHND_NVRAM_TYPE_INT32: case BHND_NVRAM_TYPE_INT32_ARRAY: + return (sizeof(uint32_t)); + + case BHND_NVRAM_TYPE_UINT64: + case BHND_NVRAM_TYPE_UINT64_ARRAY: + case BHND_NVRAM_TYPE_INT64: case BHND_NVRAM_TYPE_INT64_ARRAY: - case BHND_NVRAM_TYPE_CHAR_ARRAY: - BHND_NV_ASSERT(base_size != 0, ("invalid base size")); - *nelem = len / base_size; - return (0); + return (sizeof(uint64_t)); } /* Quiesce gcc4.2 */ @@ -456,130 +382,43 @@ bhnd_nvram_value_nelem(bhnd_nvram_type t } /** - * Return the size, in bytes, of a value of @p type with @p nelem elements. + * Return the native host alignment for values of @p type. * - * @param type The value type. - * @param data The actual data to be queried, or NULL if unknown. If - * NULL and the base type is not a fixed width type - * (e.g. BHND_NVRAM_TYPE_STRING), 0 will be returned. - * @param nbytes The size of @p data, in bytes, or 0 if @p data is NULL. - * @param nelem The number of elements. If @p type is not an array type, - * this value must be 1. - * - * @retval 0 If @p type has a variable width, and @p data is NULL. - * @retval 0 If a @p nelem value greater than 1 is provided for a - * non-array @p type. - * @retval 0 If a @p nelem value of 0 is provided. - * @retval 0 If the result would exceed the maximum value - * representable by size_t. - * @retval non-zero The size, in bytes, of @p type with @p nelem elements. + * @param type The type to query. */ size_t -bhnd_nvram_value_size(bhnd_nvram_type type, const void *data, size_t nbytes, - size_t nelem) +bhnd_nvram_type_host_align(bhnd_nvram_type type) { - /* If nelem 0, nothing to do */ - if (nelem == 0) - return (0); - - /* Non-array types must have an nelem value of 1 */ - if (!bhnd_nvram_is_array_type(type) && nelem != 1) - return (0); - switch (type) { + case BHND_NVRAM_TYPE_CHAR: + case BHND_NVRAM_TYPE_CHAR_ARRAY: + case BHND_NVRAM_TYPE_STRING: + case BHND_NVRAM_TYPE_STRING_ARRAY: + return (_Alignof(uint8_t)); + case BHND_NVRAM_TYPE_UINT8: case BHND_NVRAM_TYPE_UINT8_ARRAY: + return (_Alignof(uint8_t)); + case BHND_NVRAM_TYPE_UINT16: case BHND_NVRAM_TYPE_UINT16_ARRAY: + return (_Alignof(uint16_t)); + case BHND_NVRAM_TYPE_UINT32: case BHND_NVRAM_TYPE_UINT32_ARRAY: + return (_Alignof(uint32_t)); + case BHND_NVRAM_TYPE_UINT64: case BHND_NVRAM_TYPE_UINT64_ARRAY: - case BHND_NVRAM_TYPE_INT8_ARRAY: - case BHND_NVRAM_TYPE_INT16_ARRAY: - case BHND_NVRAM_TYPE_INT32_ARRAY: - case BHND_NVRAM_TYPE_INT64_ARRAY: - case BHND_NVRAM_TYPE_CHAR_ARRAY: { - bhnd_nvram_type base_type; - size_t base_size; - - base_type = bhnd_nvram_base_type(type); - base_size = bhnd_nvram_value_size(base_type, NULL, 0, 1); - - /* Would nelem * base_size overflow? */ - if (SIZE_MAX / nelem < base_size) { - BHND_NV_LOG("cannot represent size %s * %zu\n", - bhnd_nvram_type_name(base_type), nelem); - return (0); - } - - return (nelem * base_size); - } - - case BHND_NVRAM_TYPE_STRING_ARRAY: { - const char *p; - size_t total_size; - - if (data == NULL) - return (0); - - /* Iterate over the NUL-terminated strings to calculate - * total byte length */ - p = data; - total_size = 0; - for (size_t i = 0; i < nelem; i++) { - size_t elem_size; - - elem_size = strnlen(p, nbytes - total_size); - p += elem_size; - - /* Check for (and skip) terminating NUL */ - if (total_size < nbytes && *p == '\0') { - elem_size++; - p++; - } - - /* Would total_size + elem_size overflow? - * - * A memory range larger than SIZE_MAX shouldn't be, - * possible, but include the check for completeness */ - if (SIZE_MAX - total_size < elem_size) - return (0); - - total_size += elem_size; - } - - return (total_size); - } - - case BHND_NVRAM_TYPE_STRING: { - size_t size; - - if (data == NULL) - return (0); - - /* Find length */ - size = strnlen(data, nbytes); - - /* Is there a terminating NUL, or did we just hit the - * end of the string input */ - if (size < nbytes) - size++; - - return (size); - } + return (_Alignof(uint64_t)); case BHND_NVRAM_TYPE_INT8: - case BHND_NVRAM_TYPE_UINT8: - case BHND_NVRAM_TYPE_CHAR: - return (sizeof(uint8_t)); - + case BHND_NVRAM_TYPE_INT8_ARRAY: + return (_Alignof(int8_t)); case BHND_NVRAM_TYPE_INT16: - case BHND_NVRAM_TYPE_UINT16: - return (sizeof(uint16_t)); - + case BHND_NVRAM_TYPE_INT16_ARRAY: + return (_Alignof(int16_t)); case BHND_NVRAM_TYPE_INT32: - case BHND_NVRAM_TYPE_UINT32: - return (sizeof(uint32_t)); - - case BHND_NVRAM_TYPE_UINT64: + case BHND_NVRAM_TYPE_INT32_ARRAY: + return (_Alignof(int32_t)); case BHND_NVRAM_TYPE_INT64: - return (sizeof(uint64_t)); + case BHND_NVRAM_TYPE_INT64_ARRAY: + return (_Alignof(int64_t)); } /* Quiesce gcc4.2 */ @@ -587,132 +426,30 @@ bhnd_nvram_value_size(bhnd_nvram_type ty } /** - * Iterate over all strings in the @p inp string array. + * Iterate over all strings in the @p inp string array (@see + * BHNF_NVRAM_TYPE_STRING_ARRAY). * - * @param inp The string array to be iterated. This must be a buffer - * of one or more NUL-terminated strings -- - * @see BHND_NVRAM_TYPE_STRING_ARRAY. - * @param ilen The size, in bytes, of @p inp, including any - * terminating NUL character(s). - * @param prev The value previously returned by - * bhnd_nvram_string_array_next(), or NULL to begin - * iteration. + * @param inp The string array to be iterated. This must be a + * buffer of one or more NUL-terminated strings. + * @param ilen The size, in bytes, of @p inp, including any + * terminating NUL character(s). + * @param prev The pointer previously returned by + * bhnd_nvram_string_array_next(), or NULL to begin + * iteration. +* @param[in,out] olen If @p prev is non-NULL, @p olen must be a + * pointer to the length previously returned by + * bhnd_nvram_string_array_next(). On success, will + * be set to the next element's length, in bytes. * * @retval non-NULL A reference to the next NUL-terminated string * @retval NULL If the end of the string array is reached. */ const char * -bhnd_nvram_string_array_next(const char *inp, size_t ilen, const char *prev) +bhnd_nvram_string_array_next(const char *inp, size_t ilen, const char *prev, + size_t *olen) { - size_t nremain, plen; - - if (ilen == 0) - return (NULL); - - if (prev == NULL) - return (inp); - - /* Advance to next value */ - BHND_NV_ASSERT(prev >= inp, ("invalid prev pointer")); - BHND_NV_ASSERT(prev < (inp+ilen), ("invalid prev pointer")); - - nremain = ilen - (size_t)(prev - inp); - plen = strnlen(prev, nremain); - nremain -= plen; - - /* Only a trailing NUL remains? */ - if (nremain <= 1) - return (NULL); - - return (prev + plen + 1); -} - -/** - * Format a string representation of @p inp using @p fmt, with, writing the - * result to @p outp. - * - * Refer to bhnd_nvram_val_vprintf() for full format string documentation. - * - * @param fmt The format string. - * @param inp The value to be formatted. - * @param ilen The size of @p inp, in bytes. - * @param itype The type of @p inp. - * @param[out] outp On success, the string value will be written to - * this buffer. This argment may be NULL if the - * value is not desired. - * @param[in,out] olen The capacity of @p outp. On success, will be set - * to the actual size of the formatted string. - * - * @retval 0 success - * @retval EINVAL If @p fmt contains unrecognized format string - * specifiers. - * @retval ENOMEM If the @p outp is non-NULL, and the provided @p olen - * is too small to hold the encoded value. - * @retval EFTYPE If value coercion from @p inp to a string value via - * @p fmt is unsupported. - * @retval ERANGE If value coercion of @p value would overflow (or - * underflow) the representation defined by @p fmt. - */ -int -bhnd_nvram_value_printf(const char *fmt, const void *inp, size_t ilen, - bhnd_nvram_type itype, char *outp, size_t *olen, ...) -{ - va_list ap; - int error; - - va_start(ap, olen); - error = bhnd_nvram_value_vprintf(fmt, inp, ilen, itype, outp, olen, ap); - va_end(ap); - - return (error); -} - -/** - * Format a string representation of @p inp using @p fmt, with, writing the - * result to @p outp. - * - * Refer to bhnd_nvram_val_vprintf() for full format string documentation. - * - * @param fmt The format string. - * @param inp The value to be formatted. - * @param ilen The size of @p inp, in bytes. - * @param itype The type of @p inp. - * @param[out] outp On success, the string value will be written to - * this buffer. This argment may be NULL if the - * value is not desired. - * @param[in,out] olen The capacity of @p outp. On success, will be set - * to the actual size of the formatted string. - * @param ap Argument list. - * - * @retval 0 success - * @retval EINVAL If @p fmt contains unrecognized format string - * specifiers. - * @retval ENOMEM If the @p outp is non-NULL, and the provided @p olen - * is too small to hold the encoded value. - * @retval EFTYPE If value coercion from @p inp to a string value via - * @p fmt is unsupported. - * @retval ERANGE If value coercion of @p value would overflow (or - * underflow) the representation defined by @p fmt. - */ -int -bhnd_nvram_value_vprintf(const char *fmt, const void *inp, size_t ilen, - bhnd_nvram_type itype, char *outp, size_t *olen, va_list ap) -{ - bhnd_nvram_val val; - int error; - - /* Map input buffer as a value instance */ - error = bhnd_nvram_val_init(&val, NULL, inp, ilen, itype, - BHND_NVRAM_VAL_BORROW_DATA); - if (error) - return (error); - - /* Attempt to format the value */ - error = bhnd_nvram_val_vprintf(&val, fmt, outp, olen, ap); - - /* Clean up */ - bhnd_nvram_val_release(&val); - return (error); + return (bhnd_nvram_value_array_next(inp, ilen, + BHND_NVRAM_TYPE_STRING_ARRAY, prev, olen)); } /* used by bhnd_nvram_find_vardefn() */ @@ -825,47 +562,6 @@ bhnd_nvram_validate_name(const char *nam } /** - * Coerce value @p inp of type @p itype to @p otype, writing the - * result to @p outp. - * - * @param inp The value to be coerced. - * @param ilen The size of @p inp, in bytes. - * @param itype The base data type of @p inp. - * @param[out] outp On success, the value will be written to this - * buffer. This argment may be NULL if the value - * is not desired. - * @param[in,out] olen The capacity of @p outp. On success, will be set - * to the actual size of the requested value. - * @param otype The data type to be written to @p outp. - * - * @retval 0 success - * @retval ENOMEM If @p outp is non-NULL and a buffer of @p olen is too - * small to hold the requested value. - * @retval EFTYPE If the variable data cannot be coerced to @p otype. - * @retval ERANGE If value coercion would overflow @p otype. - */ -int -bhnd_nvram_value_coerce(const void *inp, size_t ilen, bhnd_nvram_type itype, - void *outp, size_t *olen, bhnd_nvram_type otype) -{ - bhnd_nvram_val val; - int error; - - /* Wrap input buffer in a value instance */ - error = bhnd_nvram_val_init(&val, NULL, inp, ilen, - itype, BHND_NVRAM_VAL_BORROW_DATA|BHND_NVRAM_VAL_FIXED); - if (error) - return (error); - - /* Try to encode as requested type */ - error = bhnd_nvram_val_encode(&val, outp, olen, otype); - - /* Clean up and return error */ - bhnd_nvram_val_release(&val); - return (error); -} - -/** * Parses the string in the optionally NUL-terminated @p str to as an integer * value of @p otype, accepting any integer format supported by the standard * strtoul(). @@ -1114,7 +810,7 @@ bhnd_nvram_parse_int(const char *str, si value = -value; /* Provide (and verify) required length */ - *olen = bhnd_nvram_value_size(otype, NULL, 0, 1); + *olen = bhnd_nvram_type_width(otype); if (outp == NULL) return (0); else if (limit < *olen) Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_value.c ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_value.c Mon Dec 19 20:11:48 2016 (r310291) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_value.c Mon Dec 19 20:20:33 2016 (r310292) @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #ifdef _KERNEL +#include #include #include #include @@ -43,6 +44,7 @@ __FBSDID("$FreeBSD$"); #else /* !_KERNEL */ +#include #include #include #include @@ -54,6 +56,8 @@ __FBSDID("$FreeBSD$"); #include "bhnd_nvram_valuevar.h" +static int bhnd_nvram_val_fmt_filter(const bhnd_nvram_val_fmt **fmt, + const void *inp, size_t ilen, bhnd_nvram_type itype); static void *bhnd_nvram_val_alloc_bytes(bhnd_nvram_val *value, size_t ilen, bhnd_nvram_type itype, uint32_t flags); @@ -62,6 +66,15 @@ static int bhnd_nvram_val_set(bhnd_nvra static int bhnd_nvram_val_set_inline(bhnd_nvram_val *value, const void *inp, size_t ilen, bhnd_nvram_type itype); +static int bhnd_nvram_val_encode_int(const void *inp, size_t ilen, + bhnd_nvram_type itype, void *outp, size_t *olen, + bhnd_nvram_type otype); +static int bhnd_nvram_val_encode_string(const void *inp, size_t ilen, + bhnd_nvram_type itype, void *outp, size_t *olen, + bhnd_nvram_type otype); + +/** Initialize an empty value instance with @p _fmt, @p _storage, and + * an implicit callee-owned reference */ #define BHND_NVRAM_VAL_INITIALIZER(_fmt, _storage) \ (bhnd_nvram_val) { \ .refs = 1, \ @@ -80,6 +93,156 @@ static int bhnd_nvram_val_set_inline(bh value->data.ptr == NULL, \ ("previously initialized value")) +/** Return true if BHND_NVRAM_VAL_BORROW_DATA or BHND_NVRAM_VAL_STATIC_DATA is + * set in @p _flags (e.g. we should attempt to directly reference external + * data */ +#define BHND_NVRAM_VAL_EXTREF_BORROWED_DATA(_flags) \ + (((_flags) & BHND_NVRAM_VAL_BORROW_DATA) || \ + ((_flags) & BHND_NVRAM_VAL_STATIC_DATA)) + +/** Flags permitted when performing val-based initialization via + * bhnd_nvram_val_convert_init() or bhnd_nvram_val_convert_new() */ +#define BHND_NVRAM_VALID_CONV_FLAGS \ + (BHND_NVRAM_VAL_FIXED | \ + BHND_NVRAM_VAL_DYNAMIC | \ + BHND_NVRAM_VAL_COPY_DATA) + +/** Returns true if @p _val must be copied in bhnd_nvram_val_copy(), false + * if its reference count may be safely incremented */ +#define BHND_NVRAM_VAL_NEED_COPY(_val) \ + ((_val)->val_storage == BHND_NVRAM_VAL_STORAGE_AUTO || \ + (_val)->data_storage == BHND_NVRAM_VAL_DATA_EXT_WEAK) + +volatile u_int refs; /**< reference count */ +bhnd_nvram_val_storage val_storage; /**< value structure storage */ +const bhnd_nvram_val_fmt *fmt; /**< value format */ +bhnd_nvram_val_data_storage data_storage; /**< data storage */ +bhnd_nvram_type data_type; /**< data type */ +size_t data_len; /**< data size */ + +/** + * Return the human-readable name of @p fmt. + */ +const char * +bhnd_nvram_val_fmt_name(const bhnd_nvram_val_fmt *fmt) +{ + return (fmt->name); +} + +/** + * Return the default format for values of @p type. + */ +const bhnd_nvram_val_fmt * +bhnd_nvram_val_default_fmt(bhnd_nvram_type type) +{ + switch (type) { + case BHND_NVRAM_TYPE_UINT8: + return (&bhnd_nvram_val_uint8_fmt); + case BHND_NVRAM_TYPE_UINT16: + return (&bhnd_nvram_val_uint16_fmt); + case BHND_NVRAM_TYPE_UINT32: + return (&bhnd_nvram_val_uint32_fmt); + case BHND_NVRAM_TYPE_UINT64: + return (&bhnd_nvram_val_uint64_fmt); + case BHND_NVRAM_TYPE_INT8: + return (&bhnd_nvram_val_int8_fmt); + case BHND_NVRAM_TYPE_INT16: + return (&bhnd_nvram_val_int16_fmt); + case BHND_NVRAM_TYPE_INT32: + return (&bhnd_nvram_val_int32_fmt); + case BHND_NVRAM_TYPE_INT64: + return (&bhnd_nvram_val_int64_fmt); + case BHND_NVRAM_TYPE_CHAR: + return (&bhnd_nvram_val_char_fmt); + case BHND_NVRAM_TYPE_STRING: + return (&bhnd_nvram_val_string_fmt); + case BHND_NVRAM_TYPE_UINT8_ARRAY: + return (&bhnd_nvram_val_uint8_array_fmt); + case BHND_NVRAM_TYPE_UINT16_ARRAY: + return (&bhnd_nvram_val_uint16_array_fmt); + case BHND_NVRAM_TYPE_UINT32_ARRAY: + return (&bhnd_nvram_val_uint32_array_fmt); + case BHND_NVRAM_TYPE_UINT64_ARRAY: + return (&bhnd_nvram_val_uint64_array_fmt); + case BHND_NVRAM_TYPE_INT8_ARRAY: + return (&bhnd_nvram_val_int8_array_fmt); + case BHND_NVRAM_TYPE_INT16_ARRAY: + return (&bhnd_nvram_val_int16_array_fmt); + case BHND_NVRAM_TYPE_INT32_ARRAY: + return (&bhnd_nvram_val_int32_array_fmt); + case BHND_NVRAM_TYPE_INT64_ARRAY: + return (&bhnd_nvram_val_int64_array_fmt); + case BHND_NVRAM_TYPE_CHAR_ARRAY: + return (&bhnd_nvram_val_char_array_fmt); + case BHND_NVRAM_TYPE_STRING_ARRAY: + return (&bhnd_nvram_val_string_array_fmt); + } + + /* Quiesce gcc4.2 */ + BHND_NV_PANIC("bhnd nvram type %u unknown", type); +} + +/** + * Determine whether @p fmt (or new format delegated to by @p fmt) is + * capable of direct initialization from buffer @p inp. + * + * @param[in,out] fmt Indirect pointer to the NVRAM value format. If + * the format instance cannot handle the data type + * directly, it may delegate to a new format + * instance. On success, this parameter will be + * set to the format that should be used when + * performing initialization from @p inp. + * @param inp Input data. + * @param ilen Input data length. + * @param itype Input data type. + * + * @retval 0 If initialization from @p inp is supported. + * @retval EFTYPE If initialization from @p inp is unsupported. + * @retval EFAULT if @p ilen is not correctly aligned for elements of + * @p itype. + */ +static int +bhnd_nvram_val_fmt_filter(const bhnd_nvram_val_fmt **fmt, const void *inp, + size_t ilen, bhnd_nvram_type itype) +{ + const bhnd_nvram_val_fmt *ofmt, *nfmt; + int error; + + nfmt = ofmt = *fmt; + + /* Validate alignment */ + if ((error = bhnd_nvram_value_check_aligned(inp, ilen, itype))) + return (error); + + /* If the format does not provide a filter function, it only supports + * direct initialization from its native type */ + if (ofmt->op_filter == NULL) { + if (itype == ofmt->native_type) + return (0); + + return (EFTYPE); + } + + /* Use the filter function to determine whether direct initialization + * from itype is permitted */ + error = ofmt->op_filter(&nfmt, inp, ilen, itype); + if (error) + return (error); + + /* Retry filter with new format? */ + if (ofmt != nfmt) { + error = bhnd_nvram_val_fmt_filter(&nfmt, inp, ilen, itype); + if (error) + return (error); + + /* Success -- provide delegated format to caller */ + *fmt = nfmt; + } + + /* Value can be initialized with provided format and input type */ + return (0); +} + /* Common initialization support for bhnd_nvram_val_init() and * bhnd_nvram_val_new() */ static int @@ -92,35 +255,20 @@ bhnd_nvram_val_init_common(bhnd_nvram_va size_t olen; int error; + /* If the value format is unspecified, we use the default format + * for the input data type */ + if (fmt == NULL) + fmt = bhnd_nvram_val_default_fmt(itype); + /* Determine expected data type, and allow the format to delegate to * a new format instance */ - if (fmt != NULL && fmt->op_filter != NULL) { - const bhnd_nvram_val_fmt *nfmt = fmt; - - /* Use the filter function to determine whether direct - * initialization from is itype permitted */ - error = fmt->op_filter(&nfmt, inp, ilen, itype); - if (error) - return (error); - - /* Retry initialization with new format? */ - if (nfmt != fmt) { - return (bhnd_nvram_val_init_common(value, val_storage, - nfmt, inp, ilen, itype, flags)); - } - - /* Value can be initialized with provided input type */ - otype = itype; - - } else if (fmt != NULL) { - /* Value must be initialized with the format's native - * type */ + if ((error = bhnd_nvram_val_fmt_filter(&fmt, inp, ilen, itype))) { + /* Direct initialization from the provided input type is + * not supported; alue must be initialized with the format's + * native type */ otype = fmt->native_type; - } else { - /* No format specified; we can initialize directly from the - * input data, and we'll handle all format operations - * internally. */ + /* Value can be initialized with provided input type */ otype = itype; } @@ -236,6 +384,145 @@ bhnd_nvram_val_new(bhnd_nvram_val **valu return (error); } + +/* Common initialization support for bhnd_nvram_val_convert_init() and + * bhnd_nvram_val_convert_new() */ +static int +bhnd_nvram_val_convert_common(bhnd_nvram_val *value, + bhnd_nvram_val_storage val_storage, const bhnd_nvram_val_fmt *fmt, + bhnd_nvram_val *src, uint32_t flags) +{ + const void *inp; + void *outp; + bhnd_nvram_type itype, otype; + size_t ilen, olen; + int error; + + /* Determine whether direct initialization from the source value's + * existing data type is supported by the new format */ + inp = bhnd_nvram_val_bytes(src, &ilen, &itype); + if (bhnd_nvram_val_fmt_filter(&fmt, inp, ilen, itype) == 0) { + /* Adjust value flags based on the source data storage */ + switch (src->data_storage) { + case BHND_NVRAM_VAL_DATA_NONE: + case BHND_NVRAM_VAL_DATA_INLINE: + case BHND_NVRAM_VAL_DATA_EXT_WEAK: + case BHND_NVRAM_VAL_DATA_EXT_ALLOC: + break; + + case BHND_NVRAM_VAL_DATA_EXT_STATIC: + /* If the source data has static storage duration, + * we should apply that transitively */ + if (flags & BHND_NVRAM_VAL_BORROW_DATA) + flags |= BHND_NVRAM_VAL_STATIC_DATA; + + break; + } + + /* Delegate to standard initialization */ + return (bhnd_nvram_val_init_common(value, val_storage, fmt, inp, + ilen, itype, flags)); + } + + /* Value must be initialized with the format's native type */ + otype = fmt->native_type; + + /* Initialize value instance */ + *value = BHND_NVRAM_VAL_INITIALIZER(fmt, val_storage); + + /* Determine size when encoded in native format */ + if ((error = bhnd_nvram_val_encode(src, NULL, &olen, otype))) + return (error); + + /* Fetch reference to (or allocate) an appropriately sized buffer */ + outp = bhnd_nvram_val_alloc_bytes(value, olen, otype, flags); + if (outp == NULL) + return (ENOMEM); + + /* Perform encode */ + if ((error = bhnd_nvram_val_encode(src, outp, &olen, otype))) + return (error); + + return (0); +} + +/** + * Initialize an externally allocated instance of @p value with @p fmt, and + * attempt to initialize its internal representation from the given @p src + * value. + * + * On success, the caller owns a reference to @p value, and is responsible for + * freeing any resources allocated for @p value via bhnd_nvram_val_release(). + * + * @param value The externally allocated value instance to be + * initialized. + * @param fmt The value's format. + * @param src Input value to be converted. + * @param flags Value flags (see BHND_NVRAM_VAL_*). + * + * @retval 0 success + * @retval ENOMEM If allocation fails. + * @retval EFTYPE If @p fmt initialization from @p src is unsupported. + * @retval EFAULT if @p ilen is not correctly aligned for elements of + * @p itype. + * @retval ERANGE If value coercion of @p src would overflow + * (or underflow) the @p fmt representation. + */ +int +bhnd_nvram_val_convert_init(bhnd_nvram_val *value, + const bhnd_nvram_val_fmt *fmt, bhnd_nvram_val *src, uint32_t flags) +{ + int error; + + error = bhnd_nvram_val_convert_common(value, + BHND_NVRAM_VAL_STORAGE_AUTO, fmt, src, flags); + if (error) + bhnd_nvram_val_release(value); + + return (error); +} + +/** + * Allocate a value instance with @p fmt, and attempt to initialize its internal + * representation from the given @p src value. + * + * On success, the caller owns a reference to @p value, and is responsible for + * freeing any resources allocated for @p value via bhnd_nvram_val_release(). + * + * @param[out] value On success, the allocated value instance. + * @param fmt The value's format. + * @param src Input value to be converted. + * @param flags Value flags (see BHND_NVRAM_VAL_*). + * + * @retval 0 success + * @retval ENOMEM If allocation fails. + * @retval EFTYPE If @p fmt initialization from @p src is unsupported. *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@freebsd.org Mon Dec 19 20:23:21 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4A2C6C88791; Mon, 19 Dec 2016 20:23:21 +0000 (UTC) (envelope-from landonf@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 ECCE41604; Mon, 19 Dec 2016 20:23:20 +0000 (UTC) (envelope-from landonf@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBJKNKpv056331; Mon, 19 Dec 2016 20:23:20 GMT (envelope-from landonf@FreeBSD.org) Received: (from landonf@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBJKNJ12056321; Mon, 19 Dec 2016 20:23:19 GMT (envelope-from landonf@FreeBSD.org) Message-Id: <201612192023.uBJKNJ12056321@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: landonf set sender to landonf@FreeBSD.org using -f From: "Landon J. Fuller" Date: Mon, 19 Dec 2016 20:23:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310293 - head/sys/dev/bhnd/nvram X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 20:23:21 -0000 Author: landonf Date: Mon Dec 19 20:23:19 2016 New Revision: 310293 URL: https://svnweb.freebsd.org/changeset/base/310293 Log: bhnd(4): Add support for three new NVRAM value types; booleans, NULL (which we'll use to denote deleted values in bhnd_nvram_store), and opaque data (aka octet-strings). Approved by: adrian (mentor) Differential Revision: https://reviews.freebsd.org/D8758 Modified: head/sys/dev/bhnd/nvram/bhnd_nvram.h head/sys/dev/bhnd/nvram/bhnd_nvram_plist.c head/sys/dev/bhnd/nvram/bhnd_nvram_plist.h head/sys/dev/bhnd/nvram/bhnd_nvram_store.c head/sys/dev/bhnd/nvram/bhnd_nvram_subr.c head/sys/dev/bhnd/nvram/bhnd_nvram_value.c head/sys/dev/bhnd/nvram/bhnd_nvram_value.h head/sys/dev/bhnd/nvram/bhnd_nvram_value_fmts.c head/sys/dev/bhnd/nvram/bhnd_nvram_value_subr.c Modified: head/sys/dev/bhnd/nvram/bhnd_nvram.h ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram.h Mon Dec 19 20:20:33 2016 (r310292) +++ head/sys/dev/bhnd/nvram/bhnd_nvram.h Mon Dec 19 20:23:19 2016 (r310293) @@ -40,6 +40,14 @@ #endif /* _KERNEL */ /** + * BHND NVRAM boolean type; guaranteed to be exactly 8-bits, representing + * true as integer constant 1, and false as integer constant 0. + * + * Compatible with stdbool constants (true, false). + */ +typedef uint8_t bhnd_nvram_bool_t; + +/** * NVRAM data sources supported by bhnd(4) devices. */ typedef enum { @@ -94,6 +102,10 @@ typedef enum { BHND_NVRAM_TYPE_CHAR = 8, /**< ASCII/UTF-8 character */ BHND_NVRAM_TYPE_STRING = 9, /**< ASCII/UTF-8 NUL-terminated string */ + BHND_NVRAM_TYPE_BOOL = 10, /**< uint8 boolean value. see + bhnd_nvram_bool_t. */ + BHND_NVRAM_TYPE_NULL = 11, /**< NULL (empty) value */ + BHND_NVRAM_TYPE_DATA = 12, /**< opaque octet string */ /* 10-15 reserved for primitive (non-array) types */ @@ -109,13 +121,17 @@ typedef enum { characters */ BHND_NVRAM_TYPE_STRING_ARRAY = 25, /**< array of ASCII/UTF-8 NUL-terminated strings */ + BHND_NVRAM_TYPE_BOOL_ARRAY = 26, /**< array of uint8 boolean + values */ } bhnd_nvram_type; + bool bhnd_nvram_is_signed_type(bhnd_nvram_type type); bool bhnd_nvram_is_unsigned_type(bhnd_nvram_type type); bool bhnd_nvram_is_int_type(bhnd_nvram_type type); bool bhnd_nvram_is_array_type(bhnd_nvram_type type); bhnd_nvram_type bhnd_nvram_base_type(bhnd_nvram_type type); +bhnd_nvram_type bhnd_nvram_raw_type(bhnd_nvram_type type); const char *bhnd_nvram_type_name(bhnd_nvram_type type); size_t bhnd_nvram_type_width(bhnd_nvram_type type); size_t bhnd_nvram_type_host_align(bhnd_nvram_type type); Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_plist.c ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_plist.c Mon Dec 19 20:20:33 2016 (r310292) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_plist.c Mon Dec 19 20:23:19 2016 (r310293) @@ -743,6 +743,27 @@ bhnd_nvram_plist_get_uint64(bhnd_nvram_p } /** + * Return the boolean representation of a named property's value. + * + * @param plist The property list to be queried. + * @param name The name of the property value to be returned. + * @param[out] val On success, the boolean value of @p name. + * + * @retval 0 success + * @retval ENOENT If @p name is not found in @p plist. + * @retval EFTYPE If coercion of the property's value to @p val. + * @retval ERANGE If coercion of the property's value would overflow + * (or underflow) @p val. + */ +int +bhnd_nvram_plist_get_bool(bhnd_nvram_plist *plist, const char *name, + bool *val) +{ + return (bhnd_nvram_plist_get_encoded(plist, name, val, sizeof(*val), + BHND_NVRAM_TYPE_BOOL)); +} + +/** * Allocate and initialize a new property value. * * The caller is responsible for releasing the returned property value @@ -901,6 +922,18 @@ bhnd_nvram_prop_type(bhnd_nvram_prop *pr } /** + * Return true if @p prop has a NULL value type (BHND_NVRAM_TYPE_NULL), false + * otherwise. + * + * @param prop The property to query. + */ +bool +bhnd_nvram_prop_is_null(bhnd_nvram_prop *prop) +{ + return (bhnd_nvram_prop_type(prop) == BHND_NVRAM_TYPE_NULL); +} + +/** * Return a borrowed reference to the property's internal value representation. * * @param prop The property to query. Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_plist.h ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_plist.h Mon Dec 19 20:20:33 2016 (r310292) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_plist.h Mon Dec 19 20:23:19 2016 (r310293) @@ -104,6 +104,8 @@ int bhnd_nvram_plist_get_uint64(bhnd_ const char *name, uint64_t *val); int bhnd_nvram_plist_get_string(bhnd_nvram_plist *plist, const char *name, const char **val); +int bhnd_nvram_plist_get_bool(bhnd_nvram_plist *plist, + const char *name, bool *val); bhnd_nvram_prop *bhnd_nvram_prop_new(const char *name, bhnd_nvram_val *val); @@ -118,6 +120,8 @@ const char *bhnd_nvram_prop_name(bhnd_n bhnd_nvram_val *bhnd_nvram_prop_val(bhnd_nvram_prop *prop); bhnd_nvram_type bhnd_nvram_prop_type(bhnd_nvram_prop *prop); +bool bhnd_nvram_prop_is_null(bhnd_nvram_prop *prop); + const void *bhnd_nvram_prop_bytes(bhnd_nvram_prop *prop, size_t *olen, bhnd_nvram_type *otype); int bhnd_nvram_prop_encode(bhnd_nvram_prop *prop, Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_store.c ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_store.c Mon Dec 19 20:20:33 2016 (r310292) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_store.c Mon Dec 19 20:23:19 2016 (r310293) @@ -301,6 +301,9 @@ bhnd_nvram_store_setvar(struct bhnd_nvra case BHND_NVRAM_TYPE_INT16: case BHND_NVRAM_TYPE_INT32: case BHND_NVRAM_TYPE_INT64: + case BHND_NVRAM_TYPE_NULL: + case BHND_NVRAM_TYPE_DATA: + case BHND_NVRAM_TYPE_BOOL: case BHND_NVRAM_TYPE_UINT8_ARRAY: case BHND_NVRAM_TYPE_UINT16_ARRAY: case BHND_NVRAM_TYPE_UINT32_ARRAY: @@ -311,6 +314,7 @@ bhnd_nvram_store_setvar(struct bhnd_nvra case BHND_NVRAM_TYPE_INT64_ARRAY: case BHND_NVRAM_TYPE_CHAR_ARRAY: case BHND_NVRAM_TYPE_STRING_ARRAY: + case BHND_NVRAM_TYPE_BOOL_ARRAY: // TODO: non-char/string value support return (EOPNOTSUPP); Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_subr.c ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_subr.c Mon Dec 19 20:20:33 2016 (r310292) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_subr.c Mon Dec 19 20:23:19 2016 (r310293) @@ -136,6 +136,12 @@ bhnd_nvram_type_name(bhnd_nvram_type typ return ("int64"); case BHND_NVRAM_TYPE_STRING: return ("string"); + case BHND_NVRAM_TYPE_BOOL: + return ("bool"); + case BHND_NVRAM_TYPE_NULL: + return ("null"); + case BHND_NVRAM_TYPE_DATA: + return ("data"); case BHND_NVRAM_TYPE_UINT8_ARRAY: return ("uint8[]"); case BHND_NVRAM_TYPE_UINT16_ARRAY: @@ -156,6 +162,8 @@ bhnd_nvram_type_name(bhnd_nvram_type typ return ("char[]"); case BHND_NVRAM_TYPE_STRING_ARRAY: return ("string[]"); + case BHND_NVRAM_TYPE_BOOL_ARRAY: + return ("bool[]"); } /* Quiesce gcc4.2 */ @@ -186,6 +194,9 @@ bhnd_nvram_is_signed_type(bhnd_nvram_typ case BHND_NVRAM_TYPE_UINT32: case BHND_NVRAM_TYPE_UINT64: case BHND_NVRAM_TYPE_STRING: + case BHND_NVRAM_TYPE_BOOL: + case BHND_NVRAM_TYPE_NULL: + case BHND_NVRAM_TYPE_DATA: case BHND_NVRAM_TYPE_UINT8_ARRAY: case BHND_NVRAM_TYPE_UINT16_ARRAY: case BHND_NVRAM_TYPE_UINT32_ARRAY: @@ -196,6 +207,7 @@ bhnd_nvram_is_signed_type(bhnd_nvram_typ case BHND_NVRAM_TYPE_INT64_ARRAY: case BHND_NVRAM_TYPE_CHAR_ARRAY: case BHND_NVRAM_TYPE_STRING_ARRAY: + case BHND_NVRAM_TYPE_BOOL_ARRAY: return (false); } @@ -243,6 +255,9 @@ bhnd_nvram_is_int_type(bhnd_nvram_type t case BHND_NVRAM_TYPE_CHAR: case BHND_NVRAM_TYPE_STRING: + case BHND_NVRAM_TYPE_BOOL: + case BHND_NVRAM_TYPE_NULL: + case BHND_NVRAM_TYPE_DATA: case BHND_NVRAM_TYPE_UINT8_ARRAY: case BHND_NVRAM_TYPE_UINT16_ARRAY: case BHND_NVRAM_TYPE_UINT32_ARRAY: @@ -253,6 +268,7 @@ bhnd_nvram_is_int_type(bhnd_nvram_type t case BHND_NVRAM_TYPE_INT64_ARRAY: case BHND_NVRAM_TYPE_CHAR_ARRAY: case BHND_NVRAM_TYPE_STRING_ARRAY: + case BHND_NVRAM_TYPE_BOOL_ARRAY: return (false); } @@ -279,6 +295,9 @@ bhnd_nvram_is_array_type(bhnd_nvram_type case BHND_NVRAM_TYPE_INT64: case BHND_NVRAM_TYPE_CHAR: case BHND_NVRAM_TYPE_STRING: + case BHND_NVRAM_TYPE_BOOL: + case BHND_NVRAM_TYPE_NULL: + case BHND_NVRAM_TYPE_DATA: return (false); case BHND_NVRAM_TYPE_UINT8_ARRAY: @@ -291,6 +310,7 @@ bhnd_nvram_is_array_type(bhnd_nvram_type case BHND_NVRAM_TYPE_INT64_ARRAY: case BHND_NVRAM_TYPE_CHAR_ARRAY: case BHND_NVRAM_TYPE_STRING_ARRAY: + case BHND_NVRAM_TYPE_BOOL_ARRAY: return (true); } @@ -318,6 +338,9 @@ bhnd_nvram_base_type(bhnd_nvram_type typ case BHND_NVRAM_TYPE_INT64: case BHND_NVRAM_TYPE_CHAR: case BHND_NVRAM_TYPE_STRING: + case BHND_NVRAM_TYPE_BOOL: + case BHND_NVRAM_TYPE_NULL: + case BHND_NVRAM_TYPE_DATA: return (type); case BHND_NVRAM_TYPE_UINT8_ARRAY: return (BHND_NVRAM_TYPE_UINT8); @@ -330,6 +353,63 @@ bhnd_nvram_base_type(bhnd_nvram_type typ case BHND_NVRAM_TYPE_INT64_ARRAY: return (BHND_NVRAM_TYPE_INT64); case BHND_NVRAM_TYPE_CHAR_ARRAY: return (BHND_NVRAM_TYPE_CHAR); case BHND_NVRAM_TYPE_STRING_ARRAY: return (BHND_NVRAM_TYPE_STRING); + case BHND_NVRAM_TYPE_BOOL_ARRAY: return (BHND_NVRAM_TYPE_BOOL); + } + + /* Quiesce gcc4.2 */ + BHND_NV_PANIC("bhnd nvram type %u unknown", type); +} + +/** + * Return the raw data type used to represent values of @p type, or return + * @p type is @p type is not a complex type. + * + * @param type The type to query. + */ +bhnd_nvram_type +bhnd_nvram_raw_type(bhnd_nvram_type type) +{ + switch (type) { + case BHND_NVRAM_TYPE_CHAR: + return (BHND_NVRAM_TYPE_UINT8); + + case BHND_NVRAM_TYPE_CHAR_ARRAY: + return (BHND_NVRAM_TYPE_UINT8_ARRAY); + + case BHND_NVRAM_TYPE_BOOL: { + _Static_assert(sizeof(bhnd_nvram_bool_t) == sizeof(uint8_t), + "bhnd_nvram_bool_t must be uint8-representable"); + return (BHND_NVRAM_TYPE_UINT8); + } + + case BHND_NVRAM_TYPE_BOOL_ARRAY: + return (BHND_NVRAM_TYPE_UINT8_ARRAY); + + case BHND_NVRAM_TYPE_DATA: + return (BHND_NVRAM_TYPE_UINT8_ARRAY); + + case BHND_NVRAM_TYPE_STRING: + case BHND_NVRAM_TYPE_STRING_ARRAY: + return (BHND_NVRAM_TYPE_UINT8_ARRAY); + + case BHND_NVRAM_TYPE_UINT8: + case BHND_NVRAM_TYPE_UINT16: + case BHND_NVRAM_TYPE_UINT32: + case BHND_NVRAM_TYPE_UINT64: + case BHND_NVRAM_TYPE_INT8: + case BHND_NVRAM_TYPE_INT16: + case BHND_NVRAM_TYPE_INT32: + case BHND_NVRAM_TYPE_INT64: + case BHND_NVRAM_TYPE_NULL: + case BHND_NVRAM_TYPE_UINT8_ARRAY: + case BHND_NVRAM_TYPE_UINT16_ARRAY: + case BHND_NVRAM_TYPE_UINT32_ARRAY: + case BHND_NVRAM_TYPE_UINT64_ARRAY: + case BHND_NVRAM_TYPE_INT8_ARRAY: + case BHND_NVRAM_TYPE_INT16_ARRAY: + case BHND_NVRAM_TYPE_INT32_ARRAY: + case BHND_NVRAM_TYPE_INT64_ARRAY: + return (type); } /* Quiesce gcc4.2 */ @@ -348,8 +428,16 @@ bhnd_nvram_type_width(bhnd_nvram_type ty switch (type) { case BHND_NVRAM_TYPE_STRING: case BHND_NVRAM_TYPE_STRING_ARRAY: + case BHND_NVRAM_TYPE_DATA: return (0); + case BHND_NVRAM_TYPE_NULL: + return (0); + + case BHND_NVRAM_TYPE_BOOL: + case BHND_NVRAM_TYPE_BOOL_ARRAY: + return (sizeof(bhnd_nvram_bool_t)); + case BHND_NVRAM_TYPE_CHAR: case BHND_NVRAM_TYPE_CHAR_ARRAY: case BHND_NVRAM_TYPE_UINT8: @@ -392,9 +480,18 @@ bhnd_nvram_type_host_align(bhnd_nvram_ty switch (type) { case BHND_NVRAM_TYPE_CHAR: case BHND_NVRAM_TYPE_CHAR_ARRAY: + case BHND_NVRAM_TYPE_DATA: case BHND_NVRAM_TYPE_STRING: case BHND_NVRAM_TYPE_STRING_ARRAY: return (_Alignof(uint8_t)); + case BHND_NVRAM_TYPE_BOOL: + case BHND_NVRAM_TYPE_BOOL_ARRAY: { + _Static_assert(sizeof(bhnd_nvram_bool_t) == sizeof(uint8_t), + "bhnd_nvram_bool_t must be uint8-representable"); + return (_Alignof(uint8_t)); + } + case BHND_NVRAM_TYPE_NULL: + return (1); case BHND_NVRAM_TYPE_UINT8: case BHND_NVRAM_TYPE_UINT8_ARRAY: return (_Alignof(uint8_t)); Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_value.c ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_value.c Mon Dec 19 20:20:33 2016 (r310292) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_value.c Mon Dec 19 20:23:19 2016 (r310293) @@ -66,9 +66,19 @@ static int bhnd_nvram_val_set(bhnd_nvra static int bhnd_nvram_val_set_inline(bhnd_nvram_val *value, const void *inp, size_t ilen, bhnd_nvram_type itype); + +static int bhnd_nvram_val_encode_data(const void *inp, size_t ilen, + bhnd_nvram_type itype, void *outp, size_t *olen, + bhnd_nvram_type otype); static int bhnd_nvram_val_encode_int(const void *inp, size_t ilen, bhnd_nvram_type itype, void *outp, size_t *olen, bhnd_nvram_type otype); +static int bhnd_nvram_val_encode_null(const void *inp, size_t ilen, + bhnd_nvram_type itype, void *outp, size_t *olen, + bhnd_nvram_type otype); +static int bhnd_nvram_val_encode_bool(const void *inp, size_t ilen, + bhnd_nvram_type itype, void *outp, size_t *olen, + bhnd_nvram_type otype); static int bhnd_nvram_val_encode_string(const void *inp, size_t ilen, bhnd_nvram_type itype, void *outp, size_t *olen, bhnd_nvram_type otype); @@ -83,7 +93,6 @@ static int bhnd_nvram_val_encode_string .data_storage = BHND_NVRAM_VAL_DATA_NONE, \ }; - /** Assert that @p value's backing representation state has initialized * as empty. */ #define BHND_NVRAM_VAL_ASSERT_EMPTY(_value) \ @@ -120,6 +129,16 @@ bhnd_nvram_val_data_storage data_storag bhnd_nvram_type data_type; /**< data type */ size_t data_len; /**< data size */ +/* Shared NULL value instance */ +bhnd_nvram_val bhnd_nvram_val_null = { + .refs = 1, + .val_storage = BHND_NVRAM_VAL_STORAGE_STATIC, + .fmt = &bhnd_nvram_val_null_fmt, + .data_storage = BHND_NVRAM_VAL_DATA_INLINE, + .data_type = BHND_NVRAM_TYPE_NULL, + .data_len = 0, +}; + /** * Return the human-readable name of @p fmt. */ @@ -156,6 +175,12 @@ bhnd_nvram_val_default_fmt(bhnd_nvram_ty return (&bhnd_nvram_val_char_fmt); case BHND_NVRAM_TYPE_STRING: return (&bhnd_nvram_val_string_fmt); + case BHND_NVRAM_TYPE_BOOL: + return (&bhnd_nvram_val_bool_fmt); + case BHND_NVRAM_TYPE_NULL: + return (&bhnd_nvram_val_null_fmt); + case BHND_NVRAM_TYPE_DATA: + return (&bhnd_nvram_val_data_fmt); case BHND_NVRAM_TYPE_UINT8_ARRAY: return (&bhnd_nvram_val_uint8_array_fmt); case BHND_NVRAM_TYPE_UINT16_ARRAY: @@ -176,6 +201,8 @@ bhnd_nvram_val_default_fmt(bhnd_nvram_ty return (&bhnd_nvram_val_char_array_fmt); case BHND_NVRAM_TYPE_STRING_ARRAY: return (&bhnd_nvram_val_string_array_fmt); + case BHND_NVRAM_TYPE_BOOL_ARRAY: + return (&bhnd_nvram_val_bool_array_fmt); } /* Quiesce gcc4.2 */ @@ -635,6 +662,156 @@ bhnd_nvram_val_release(bhnd_nvram_val *v } /** + * Standard BHND_NVRAM_TYPE_NULL encoding implementation. + */ +static int +bhnd_nvram_val_encode_null(const void *inp, size_t ilen, bhnd_nvram_type itype, + void *outp, size_t *olen, bhnd_nvram_type otype) +{ + size_t limit, nbytes; + + BHND_NV_ASSERT(itype == BHND_NVRAM_TYPE_NULL, + ("unsupported type: %d", itype)); + + /* Determine output byte limit */ + if (outp != NULL) + limit = *olen; + else + limit = 0; + + nbytes = 0; + + /* Write to output */ + switch (otype) { + case BHND_NVRAM_TYPE_NULL: + /* Can be directly encoded as a zero-length NULL value */ + nbytes = 0; + break; + default: + /* Not representable */ + return (EFTYPE); + } + + /* Provide required length */ + *olen = nbytes; + if (limit < *olen) { + if (outp == NULL) + return (0); + + return (ENOMEM); + } + + return (0); +} + +/** + * Standard BHND_NVRAM_TYPE_BOOL encoding implementation. + */ +static int +bhnd_nvram_val_encode_bool(const void *inp, size_t ilen, bhnd_nvram_type itype, + void *outp, size_t *olen, bhnd_nvram_type otype) +{ + bhnd_nvram_bool_t bval; + size_t limit, nbytes, nelem; + int error; + + BHND_NV_ASSERT(itype == BHND_NVRAM_TYPE_BOOL, + ("unsupported type: %d", itype)); + + /* Determine output byte limit */ + if (outp != NULL) + limit = *olen; + else + limit = 0; + + /* Must be exactly one element in input */ + if ((error = bhnd_nvram_value_nelem(inp, ilen, itype, &nelem))) + return (error); + + if (nelem != 1) + return (EFTYPE); + + /* Fetch (and normalize) boolean value */ + bval = (*(const bhnd_nvram_bool_t *)inp != 0) ? true : false; + + /* Write to output */ + switch (otype) { + case BHND_NVRAM_TYPE_NULL: + /* False can be directly encoded as a zero-length NULL value */ + if (bval != false) + return (EFTYPE); + + nbytes = 0; + break; + + case BHND_NVRAM_TYPE_STRING: + case BHND_NVRAM_TYPE_STRING_ARRAY: { + /* Can encode as "true" or "false" */ + const char *str = bval ? "true" : "false"; + + nbytes = strlen(str) + 1; + if (limit > nbytes) + strcpy(outp, str); + + break; + } + + default: + /* If output type is an integer, we can delegate to standard + * integer encoding to encode as zero or one. */ + if (bhnd_nvram_is_int_type(otype)) { + uint8_t ival = bval ? 1 : 0; + + return (bhnd_nvram_val_encode_int(&ival, sizeof(ival), + BHND_NVRAM_TYPE_UINT8, outp, olen, otype)); + } + + /* Otherwise not representable */ + return (EFTYPE); + } + + /* Provide required length */ + *olen = nbytes; + if (limit < *olen) { + if (outp == NULL) + return (0); + + return (ENOMEM); + } + + return (0); +} + +/** + * Standard BHND_NVRAM_TYPE_DATA encoding implementation. + */ +static int +bhnd_nvram_val_encode_data(const void *inp, size_t ilen, bhnd_nvram_type itype, + void *outp, size_t *olen, bhnd_nvram_type otype) +{ + BHND_NV_ASSERT(itype == BHND_NVRAM_TYPE_DATA, + ("unsupported type: %d", itype)); + + /* Write to output */ + switch (otype) { + case BHND_NVRAM_TYPE_STRING: + case BHND_NVRAM_TYPE_STRING_ARRAY: + /* If encoding as a string, produce an EFI-style hexadecimal + * byte array (HF1F...) by interpreting the octet string + * as an array of uint8 values */ + return (bhnd_nvram_value_printf("H%[]02hhX", inp, ilen, + BHND_NVRAM_TYPE_UINT8_ARRAY, outp, olen, "")); + + default: + /* Fall back on direct interpretation as an array of 8-bit + * integers array */ + return (bhnd_nvram_value_coerce(inp, ilen, + BHND_NVRAM_TYPE_UINT8_ARRAY, outp, olen, otype)); + } +} + + +/** * Standard string/char array/char encoding implementation. * * Input type must be one of: @@ -673,6 +850,14 @@ bhnd_nvram_val_encode_string(const void /* Parse the string data and write to output */ switch (otype) { + case BHND_NVRAM_TYPE_NULL: + /* Only an empty string may be represented as a NULL value */ + if (cstr_len != 0) + return (EFTYPE); + + *olen = 0; + return (0); + case BHND_NVRAM_TYPE_CHAR: case BHND_NVRAM_TYPE_CHAR_ARRAY: /* String must contain exactly 1 non-terminating-NUL character @@ -696,6 +881,99 @@ bhnd_nvram_val_encode_string(const void return (0); + case BHND_NVRAM_TYPE_BOOL: + case BHND_NVRAM_TYPE_BOOL_ARRAY: { + const char *p; + size_t plen; + bhnd_nvram_bool_t bval; + + /* Trim leading/trailing whitespace */ + p = cstr; + plen = bhnd_nvram_trim_field(&p, cstr_len, '\0'); + + /* Parse string representation */ + if (strncasecmp(p, "true", plen) == 0 || + strncasecmp(p, "yes", plen) == 0 || + strncmp(p, "1", plen) == 0) + { + bval = true; + } else if (strncasecmp(p, "false", plen) == 0 || + strncasecmp(p, "no", plen) == 0 || + strncmp(p, "0", plen) == 0) + { + bval = false; + } else { + /* Not a recognized boolean string */ + return (EFTYPE); + } + + /* Write to output */ + nbytes = sizeof(bhnd_nvram_bool_t); + if (limit >= nbytes) + *((bhnd_nvram_bool_t *)outp) = bval; + + /* Provide required length */ + *olen = nbytes; + if (limit < *olen && outp != NULL) + return (ENOMEM); + + return (0); + } + + case BHND_NVRAM_TYPE_DATA: { + const char *p; + size_t plen, parsed_len; + int error; + + /* Trim leading/trailing whitespace */ + p = cstr; + plen = bhnd_nvram_trim_field(&p, cstr_len, '\0'); + + /* Check for EFI-style hexadecimal byte array string format. + * Must have a 'H' prefix */ + if (plen < 1 || bhnd_nv_toupper(*p) != 'H') + return (EFTYPE); + + /* Skip leading 'H' */ + p++; + plen--; + + /* Parse the input string's two-char octets until the end + * of input is reached. The last octet may contain only + * one char */ + while (plen > 0) { + uint8_t byte; + size_t byte_len = sizeof(byte); + + /* Parse next two-character hex octet */ + error = bhnd_nvram_parse_int(p, bhnd_nv_ummin(plen, 2), + 16, &parsed_len, &byte, &byte_len, otype_base); + if (error) { + BHND_NV_DEBUG("error parsing '%.*s' as " + "integer: %d\n", BHND_NV_PRINT_WIDTH(plen), + p, error); + + return (error); + } + + /* Write to output */ + if (limit > nbytes) + *((uint8_t *)outp + nbytes) = byte; + nbytes++; + + /* Advance input */ + p += parsed_len; + plen -= parsed_len; + } + + /* Provide required length */ + *olen = nbytes; + if (limit < *olen && outp != NULL) + return (ENOMEM); + + return (0); + } + case BHND_NVRAM_TYPE_UINT8: case BHND_NVRAM_TYPE_UINT8_ARRAY: case BHND_NVRAM_TYPE_UINT16: @@ -896,8 +1174,30 @@ bhnd_nvram_val_encode_int(const void *in /* Write output */ switch (otype) { + case BHND_NVRAM_TYPE_NULL: + /* Cannot encode an integer value as NULL */ + return (EFTYPE); + + case BHND_NVRAM_TYPE_BOOL: { + bhnd_nvram_bool_t bval; + + if (intv.u64 == 0 || intv.u64 == 1) { + bval = intv.u64; + } else { + /* Encoding as a bool would lose information */ + return (ERANGE); + } + + nbytes = sizeof(bhnd_nvram_bool_t); + if (limit >= nbytes) + *((bhnd_nvram_bool_t *)outp) = bval; + + break; + } + case BHND_NVRAM_TYPE_CHAR: case BHND_NVRAM_TYPE_CHAR_ARRAY: + case BHND_NVRAM_TYPE_DATA: case BHND_NVRAM_TYPE_UINT8: case BHND_NVRAM_TYPE_UINT8_ARRAY: if (intv.u64 > UINT8_MAX) @@ -1335,11 +1635,23 @@ bhnd_nvram_val_generic_encode_elem(bhnd_ itype = bhnd_nvram_val_elem_type(value); switch (itype) { + case BHND_NVRAM_TYPE_NULL: + return (bhnd_nvram_val_encode_null(inp, ilen, itype, outp, olen, + otype)); + + case BHND_NVRAM_TYPE_DATA: + return (bhnd_nvram_val_encode_data(inp, ilen, itype, outp, + olen, otype)); + case BHND_NVRAM_TYPE_STRING: case BHND_NVRAM_TYPE_CHAR: return (bhnd_nvram_val_encode_string(inp, ilen, itype, outp, olen, otype)); + case BHND_NVRAM_TYPE_BOOL: + return (bhnd_nvram_val_encode_bool(inp, ilen, itype, outp, olen, + otype)); + case BHND_NVRAM_TYPE_UINT8: case BHND_NVRAM_TYPE_UINT16: case BHND_NVRAM_TYPE_UINT32: @@ -1486,10 +1798,22 @@ bhnd_nvram_val_set_inline(bhnd_nvram_val /* Attempt to copy to inline storage */ switch (itype) { + case BHND_NVRAM_TYPE_NULL: + if (ilen != 0) + return (EFAULT); + + /* Nothing to copy */ + NV_STORE_INIT_INLINE(); + return (0); + case BHND_NVRAM_TYPE_CHAR: NV_STORE_INLINE(uint8_t, ch); return (0); + case BHND_NVRAM_TYPE_BOOL: + NV_STORE_INLINE(bhnd_nvram_bool_t, b); + return(0); + case BHND_NVRAM_TYPE_UINT8: case BHND_NVRAM_TYPE_INT8: NV_STORE_INLINE(uint8_t, u8); @@ -1514,6 +1838,7 @@ bhnd_nvram_val_set_inline(bhnd_nvram_val NV_COPY_ARRRAY_INLINE(uint8_t, ch); return (0); + case BHND_NVRAM_TYPE_DATA: case BHND_NVRAM_TYPE_UINT8_ARRAY: case BHND_NVRAM_TYPE_INT8_ARRAY: NV_COPY_ARRRAY_INLINE(uint8_t, u8); @@ -1534,6 +1859,10 @@ bhnd_nvram_val_set_inline(bhnd_nvram_val NV_COPY_ARRRAY_INLINE(uint64_t, u64); return (0); + case BHND_NVRAM_TYPE_BOOL_ARRAY: + NV_COPY_ARRRAY_INLINE(bhnd_nvram_bool_t, b); + return(0); + case BHND_NVRAM_TYPE_STRING: case BHND_NVRAM_TYPE_STRING_ARRAY: if (ilen > sizeof(value->data.ch)) Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_value.h ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_value.h Mon Dec 19 20:20:33 2016 (r310292) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_value.h Mon Dec 19 20:23:19 2016 (r310293) @@ -235,6 +235,7 @@ struct bhnd_nvram_val { int32_t i32[2]; /**< 32-bit signed data */ int64_t i64[1]; /**< 64-bit signed data */ unsigned char ch[8]; /**< 8-bit character data */ + bhnd_nvram_bool_t b[8]; /**< 8-bit boolean data */ const void *ptr; /**< external data */ } data; }; @@ -258,7 +259,10 @@ BHND_NVRAM_VAL_FMT_DECL(int16); BHND_NVRAM_VAL_FMT_DECL(int32); BHND_NVRAM_VAL_FMT_DECL(int64); BHND_NVRAM_VAL_FMT_DECL(char); +BHND_NVRAM_VAL_FMT_DECL(bool); BHND_NVRAM_VAL_FMT_DECL(string); +BHND_NVRAM_VAL_FMT_DECL(data); +BHND_NVRAM_VAL_FMT_DECL(null); BHND_NVRAM_VAL_FMT_DECL(uint8_array); BHND_NVRAM_VAL_FMT_DECL(uint16_array); @@ -269,6 +273,11 @@ BHND_NVRAM_VAL_FMT_DECL(int16_array); BHND_NVRAM_VAL_FMT_DECL(int32_array); BHND_NVRAM_VAL_FMT_DECL(int64_array); BHND_NVRAM_VAL_FMT_DECL(char_array); +BHND_NVRAM_VAL_FMT_DECL(bool_array); BHND_NVRAM_VAL_FMT_DECL(string_array); +/** Shared NULL value instance */ +#define BHND_NVRAM_VAL_NULL (&bhnd_nvram_val_null) +extern bhnd_nvram_val bhnd_nvram_val_null; + #endif /* _BHND_NVRAM_BHND_NVRAM_VALUE_H_ */ Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_value_fmts.c ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_value_fmts.c Mon Dec 19 20:20:33 2016 (r310292) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_value_fmts.c Mon Dec 19 20:23:19 2016 (r310293) @@ -215,7 +215,10 @@ BHND_NVRAM_VAL_FMT_NATIVE(int16, INT16); BHND_NVRAM_VAL_FMT_NATIVE(int32, INT32); BHND_NVRAM_VAL_FMT_NATIVE(int64, INT64); BHND_NVRAM_VAL_FMT_NATIVE(char, CHAR); +BHND_NVRAM_VAL_FMT_NATIVE(bool, BOOL); BHND_NVRAM_VAL_FMT_NATIVE(string, STRING); +BHND_NVRAM_VAL_FMT_NATIVE(data, DATA); +BHND_NVRAM_VAL_FMT_NATIVE(null, NULL); BHND_NVRAM_VAL_FMT_NATIVE(uint8_array, UINT8_ARRAY); BHND_NVRAM_VAL_FMT_NATIVE(uint16_array, UINT16_ARRAY); @@ -226,6 +229,7 @@ BHND_NVRAM_VAL_FMT_NATIVE(int16_array, I BHND_NVRAM_VAL_FMT_NATIVE(int32_array, INT32_ARRAY); BHND_NVRAM_VAL_FMT_NATIVE(int64_array, INT64_ARRAY); BHND_NVRAM_VAL_FMT_NATIVE(char_array, CHAR_ARRAY); +BHND_NVRAM_VAL_FMT_NATIVE(bool_array, BOOL_ARRAY); BHND_NVRAM_VAL_FMT_NATIVE(string_array, STRING_ARRAY); /** Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_value_subr.c ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_value_subr.c Mon Dec 19 20:20:33 2016 (r310292) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_value_subr.c Mon Dec 19 20:23:19 2016 (r310293) @@ -66,6 +66,15 @@ bhnd_nvram_value_check_aligned(const voi { size_t align, width; + /* As a special case, NULL values have no alignment, but must + * always have a length of zero */ + if (itype == BHND_NVRAM_TYPE_NULL) { + if (ilen != 0) + return (EFAULT); + + return (0); + } + /* Check pointer alignment against the required host alignment */ align = bhnd_nvram_type_host_align(itype); BHND_NV_ASSERT(align != 0, ("invalid zero alignment")); @@ -119,6 +128,20 @@ bhnd_nvram_value_nelem(const void *inp, return (error); switch (itype) { + case BHND_NVRAM_TYPE_DATA: + /* Always exactly one element */ + *nelem = 1; + return (0); + + case BHND_NVRAM_TYPE_NULL: + /* Must be zero length */ + if (ilen != 0) + return (EFAULT); + + /* Always exactly one element */ + *nelem = 1; + return (0); + case BHND_NVRAM_TYPE_STRING: /* Always exactly one element */ *nelem = 1; @@ -165,7 +188,8 @@ bhnd_nvram_value_nelem(const void *inp, case BHND_NVRAM_TYPE_INT16_ARRAY: case BHND_NVRAM_TYPE_INT32_ARRAY: case BHND_NVRAM_TYPE_INT64_ARRAY: - case BHND_NVRAM_TYPE_CHAR_ARRAY: { + case BHND_NVRAM_TYPE_CHAR_ARRAY: + case BHND_NVRAM_TYPE_BOOL_ARRAY: { size_t width = bhnd_nvram_type_width(itype); BHND_NV_ASSERT(width != 0, ("invalid width")); @@ -182,6 +206,7 @@ bhnd_nvram_value_nelem(const void *inp, case BHND_NVRAM_TYPE_UINT32: case BHND_NVRAM_TYPE_INT64: case BHND_NVRAM_TYPE_UINT64: + case BHND_NVRAM_TYPE_BOOL: /* Length must be equal to the size of exactly one * element (arrays can represent zero elements -- non-array * types cannot) */ @@ -236,7 +261,8 @@ bhnd_nvram_value_size(const void *inp, s case BHND_NVRAM_TYPE_INT16_ARRAY: case BHND_NVRAM_TYPE_INT32_ARRAY: case BHND_NVRAM_TYPE_INT64_ARRAY: - case BHND_NVRAM_TYPE_CHAR_ARRAY: { + case BHND_NVRAM_TYPE_CHAR_ARRAY: + case BHND_NVRAM_TYPE_BOOL_ARRAY:{ size_t width; width = bhnd_nvram_type_width(itype); @@ -305,6 +331,18 @@ bhnd_nvram_value_size(const void *inp, s return (size); } + case BHND_NVRAM_TYPE_NULL: + return (0); + + case BHND_NVRAM_TYPE_DATA: + if (inp == NULL) + return (0); + + return (ilen); + + case BHND_NVRAM_TYPE_BOOL: + return (sizeof(bhnd_nvram_bool_t)); + case BHND_NVRAM_TYPE_INT8: case BHND_NVRAM_TYPE_UINT8: case BHND_NVRAM_TYPE_CHAR: From owner-svn-src-head@freebsd.org Mon Dec 19 20:26:12 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 437AAC8888F; Mon, 19 Dec 2016 20:26:12 +0000 (UTC) (envelope-from landonf@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 1B4EB17DC; Mon, 19 Dec 2016 20:26:12 +0000 (UTC) (envelope-from landonf@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBJKQBos056480; Mon, 19 Dec 2016 20:26:11 GMT (envelope-from landonf@FreeBSD.org) Received: (from landonf@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBJKQAHj056476; Mon, 19 Dec 2016 20:26:10 GMT (envelope-from landonf@FreeBSD.org) Message-Id: <201612192026.uBJKQAHj056476@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: landonf set sender to landonf@FreeBSD.org using -f From: "Landon J. Fuller" Date: Mon, 19 Dec 2016 20:26:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310294 - in head/sys: conf dev/bhnd/nvram modules/bhnd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 20:26:12 -0000 Author: landonf Date: Mon Dec 19 20:26:10 2016 New Revision: 310294 URL: https://svnweb.freebsd.org/changeset/base/310294 Log: bhnd(4): add support for wrapping arbitrary pointers in an NVRAM I/O context. Approved by: adrian (mentor) Differential Revision: https://reviews.freebsd.org/D8759 Added: head/sys/dev/bhnd/nvram/bhnd_nvram_ioptr.c (contents, props changed) Modified: head/sys/conf/files head/sys/dev/bhnd/nvram/bhnd_nvram_io.h head/sys/modules/bhnd/Makefile Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Mon Dec 19 20:23:19 2016 (r310293) +++ head/sys/conf/files Mon Dec 19 20:26:10 2016 (r310294) @@ -1240,6 +1240,7 @@ dev/bhnd/nvram/bhnd_nvram_data_tlv.c opt dev/bhnd/nvram/bhnd_nvram_if.m optional bhnd dev/bhnd/nvram/bhnd_nvram_io.c optional bhnd dev/bhnd/nvram/bhnd_nvram_iobuf.c optional bhnd +dev/bhnd/nvram/bhnd_nvram_ioptr.c optional bhnd dev/bhnd/nvram/bhnd_nvram_iores.c optional bhnd dev/bhnd/nvram/bhnd_nvram_plist.c optional bhnd dev/bhnd/nvram/bhnd_nvram_store.c optional bhnd Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_io.h ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_io.h Mon Dec 19 20:23:19 2016 (r310293) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_io.h Mon Dec 19 20:26:10 2016 (r310294) @@ -52,6 +52,9 @@ struct bhnd_nvram_io *bhnd_nvram_iobuf_c struct bhnd_nvram_io *bhnd_nvram_iobuf_copy_range(struct bhnd_nvram_io *src, size_t offset, size_t size); +struct bhnd_nvram_io *bhnd_nvram_ioptr_new(const void *ptr, size_t size, + size_t capacity, uint32_t flags); + #ifdef _KERNEL struct bhnd_nvram_io *bhnd_nvram_iores_new(struct bhnd_resource *r, bus_size_t offset, bus_size_t size, @@ -76,4 +79,12 @@ int bhnd_nvram_io_write_ptr(struct bh void bhnd_nvram_io_free(struct bhnd_nvram_io *io); +/** + * bhnd_nvram_ioptr flags + */ +enum { + BHND_NVRAM_IOPTR_RDONLY = (1<<0), /**< read-only */ + BHND_NVRAM_IOPTR_RDWR = (1<<1), /**< read/write */ +}; + #endif /* _BHND_NVRAM_BHND_NVRAM_IO_H_ */ Added: head/sys/dev/bhnd/nvram/bhnd_nvram_ioptr.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_ioptr.c Mon Dec 19 20:26:10 2016 (r310294) @@ -0,0 +1,228 @@ +/*- + * Copyright (c) 2016 Landon Fuller + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any + * redistribution must be conditioned upon including a substantially + * similar Disclaimer requirement for further binary redistribution. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, + * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGES. + */ + +#include +__FBSDID("$FreeBSD$"); + +#ifdef _KERNEL +#include +#include +#include +#else /* !_KERNEL */ +#include +#include +#include +#include +#endif /* _KERNEL */ + +#include "bhnd_nvram_private.h" + +#include "bhnd_nvram_io.h" +#include "bhnd_nvram_iovar.h" + +/** + * Memory-backed NVRAM I/O context. + * + * ioptr instances are gauranteed to provide persistent references to its + * backing contigious memory via bhnd_nvram_io_read_ptr() and + * bhnd_nvram_io_write_ptr(). + */ +struct bhnd_nvram_ioptr { + struct bhnd_nvram_io io; /**< common I/O instance state */ + void *ptr; /**< backing memory */ + size_t size; /**< size at @p ptr */ + size_t capacity; /**< capacity at @p ptr */ + uint32_t flags; /**< flags (see BHND_NVRAM_IOPTR_*) */ +}; + +BHND_NVRAM_IOPS_DEFN(ioptr) + +/** + * Allocate and return a new I/O context, mapping @p size bytes at @p ptr. + + * The caller is responsible for deallocating the returned I/O context via + * bhnd_nvram_io_free(). + * + * @param ptr The pointer to be mapped by the returned I/O + * context. Must remain valid for the lifetime of + * the returned I/O context. + * @param size The total number of bytes mapped at @p ptr. + * @param capacity The maximum number of bytes that may be mapped + * at @p ptr via bhnd_nvram_ioptr_setsize(). + * @param flags Access flags (see BHND_NVRAM_IOPTR_*). + * + * @retval bhnd_nvram_io success. + * @retval NULL allocation failed. + * @retval NULL the requested @p capacity is less than @p size. + */ +struct bhnd_nvram_io * +bhnd_nvram_ioptr_new(const void *ptr, size_t size, size_t capacity, + uint32_t flags) +{ + struct bhnd_nvram_ioptr *ioptr; + + /* Sanity check the capacity */ + if (size > capacity) + return (NULL); + + /* Allocate I/O context */ + ioptr = bhnd_nv_malloc(sizeof(*ioptr)); + if (ioptr == NULL) + return (NULL); + + ioptr->io.iops = &bhnd_nvram_ioptr_ops; + ioptr->ptr = __DECONST(void *, ptr); + ioptr->size = size; + ioptr->capacity = capacity; + ioptr->flags = flags; + + return (&ioptr->io); +} + +static void +bhnd_nvram_ioptr_free(struct bhnd_nvram_io *io) +{ + bhnd_nv_free(io); +} + +static size_t +bhnd_nvram_ioptr_getsize(struct bhnd_nvram_io *io) +{ + struct bhnd_nvram_ioptr *ioptr = (struct bhnd_nvram_ioptr *)io; + return (ioptr->size); +} + +static int +bhnd_nvram_ioptr_setsize(struct bhnd_nvram_io *io, size_t size) +{ + struct bhnd_nvram_ioptr *ioptr = (struct bhnd_nvram_ioptr *)io; + + /* Must be writable */ + if (!(ioptr->flags & BHND_NVRAM_IOPTR_RDWR)) + return (ENODEV); + + /* Can't exceed the actual capacity */ + if (size > ioptr->capacity) + return (ENXIO); + + ioptr->size = size; + return (0); +} + +/* Common ioptr_(read|write)_ptr implementation */ +static int +bhnd_nvram_ioptr_ptr(struct bhnd_nvram_ioptr *ioptr, size_t offset, void **ptr, + size_t nbytes, size_t *navail) +{ + size_t avail; + + /* Verify offset+nbytes fall within the buffer range */ + if (offset > ioptr->size) + return (ENXIO); + + avail = ioptr->size - offset; + if (avail < nbytes) + return (ENXIO); + + /* Valid I/O range, provide a pointer to the buffer and the + * total count of available bytes */ + *ptr = ((uint8_t *)ioptr->ptr) + offset; + if (navail != NULL) + *navail = avail; + + return (0); +} + +static int +bhnd_nvram_ioptr_read_ptr(struct bhnd_nvram_io *io, size_t offset, + const void **ptr, size_t nbytes, size_t *navail) +{ + struct bhnd_nvram_ioptr *ioptr; + void *writep; + int error; + + ioptr = (struct bhnd_nvram_ioptr *) io; + + /* Return a pointer into our backing buffer */ + error = bhnd_nvram_ioptr_ptr(ioptr, offset, &writep, nbytes, navail); + if (error) + return (error); + + *ptr = writep; + + return (0); +} + +static int +bhnd_nvram_ioptr_write_ptr(struct bhnd_nvram_io *io, size_t offset, + void **ptr, size_t nbytes, size_t *navail) +{ + struct bhnd_nvram_ioptr *ioptr; + + ioptr = (struct bhnd_nvram_ioptr *) io; + + /* Must be writable */ + if (!(ioptr->flags & BHND_NVRAM_IOPTR_RDWR)) + return (ENODEV); + + /* Return a pointer into our backing buffer */ + return (bhnd_nvram_ioptr_ptr(ioptr, offset, ptr, nbytes, navail)); +} + +static int +bhnd_nvram_ioptr_read(struct bhnd_nvram_io *io, size_t offset, void *buffer, + size_t nbytes) +{ + const void *ptr; + int error; + + /* Try to fetch a direct pointer for at least nbytes */ + if ((error = bhnd_nvram_io_read_ptr(io, offset, &ptr, nbytes, NULL))) + return (error); + + /* Copy out the requested data */ + memcpy(buffer, ptr, nbytes); + return (0); +} + +static int +bhnd_nvram_ioptr_write(struct bhnd_nvram_io *io, size_t offset, + void *buffer, size_t nbytes) +{ + void *ptr; + int error; + + /* Try to fetch a direct pointer for at least nbytes */ + if ((error = bhnd_nvram_io_write_ptr(io, offset, &ptr, nbytes, NULL))) + return (error); + + /* Copy in the provided data */ + memcpy(ptr, buffer, nbytes); + return (0); +} Modified: head/sys/modules/bhnd/Makefile ============================================================================== --- head/sys/modules/bhnd/Makefile Mon Dec 19 20:23:19 2016 (r310293) +++ head/sys/modules/bhnd/Makefile Mon Dec 19 20:26:10 2016 (r310294) @@ -35,6 +35,7 @@ SRCS+= bhnd_nvram_data.c \ bhnd_nvram_data_tlv.c \ bhnd_nvram_io.c \ bhnd_nvram_iobuf.c \ + bhnd_nvram_ioptr.c \ bhnd_nvram_iores.c \ bhnd_nvram_plist.c \ bhnd_nvram_store.c \ From owner-svn-src-head@freebsd.org Mon Dec 19 20:28:29 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AD0B5C88A27; Mon, 19 Dec 2016 20:28:29 +0000 (UTC) (envelope-from landonf@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 755991BE9; Mon, 19 Dec 2016 20:28:29 +0000 (UTC) (envelope-from landonf@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBJKSS30056599; Mon, 19 Dec 2016 20:28:28 GMT (envelope-from landonf@FreeBSD.org) Received: (from landonf@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBJKSRs4056590; Mon, 19 Dec 2016 20:28:27 GMT (envelope-from landonf@FreeBSD.org) Message-Id: <201612192028.uBJKSRs4056590@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: landonf set sender to landonf@FreeBSD.org using -f From: "Landon J. Fuller" Date: Mon, 19 Dec 2016 20:28:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310295 - in head/sys: conf dev/bhnd/nvram modules/bhnd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 20:28:29 -0000 Author: landonf Date: Mon Dec 19 20:28:27 2016 New Revision: 310295 URL: https://svnweb.freebsd.org/changeset/base/310295 Log: bhnd(4): NVRAM device path support. Implements bhnd_nvram_store support for parsing and operating over NVRAM device paths, and device path aliases, as well as tracking per-path NVRAM variable writes. Approved by: adrian (mentor) Differential Revision: https://reviews.freebsd.org/D8760 Added: head/sys/dev/bhnd/nvram/bhnd_nvram_store_subr.c (contents, props changed) Modified: head/sys/conf/files head/sys/dev/bhnd/nvram/bhnd_nvram_data.c head/sys/dev/bhnd/nvram/bhnd_nvram_data.h head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcm.c head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcmraw.c head/sys/dev/bhnd/nvram/bhnd_nvram_data_btxt.c head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c head/sys/dev/bhnd/nvram/bhnd_nvram_data_tlv.c head/sys/dev/bhnd/nvram/bhnd_nvram_datavar.h head/sys/dev/bhnd/nvram/bhnd_nvram_private.h head/sys/dev/bhnd/nvram/bhnd_nvram_store.c head/sys/dev/bhnd/nvram/bhnd_nvram_store.h head/sys/dev/bhnd/nvram/bhnd_nvram_storevar.h head/sys/dev/bhnd/nvram/bhnd_nvram_subr.c head/sys/modules/bhnd/Makefile Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Mon Dec 19 20:26:10 2016 (r310294) +++ head/sys/conf/files Mon Dec 19 20:28:27 2016 (r310295) @@ -1244,6 +1244,7 @@ dev/bhnd/nvram/bhnd_nvram_ioptr.c option dev/bhnd/nvram/bhnd_nvram_iores.c optional bhnd dev/bhnd/nvram/bhnd_nvram_plist.c optional bhnd dev/bhnd/nvram/bhnd_nvram_store.c optional bhnd +dev/bhnd/nvram/bhnd_nvram_store_subr.c optional bhnd dev/bhnd/nvram/bhnd_nvram_subr.c optional bhnd dev/bhnd/nvram/bhnd_nvram_value.c optional bhnd dev/bhnd/nvram/bhnd_nvram_value_fmts.c optional bhnd Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data.c ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_data.c Mon Dec 19 20:26:10 2016 (r310294) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_data.c Mon Dec 19 20:28:27 2016 (r310295) @@ -350,7 +350,26 @@ bhnd_nvram_data_caps(struct bhnd_nvram_d const char * bhnd_nvram_data_next(struct bhnd_nvram_data *nv, void **cookiep) { - return (nv->cls->op_next(nv, cookiep)); + const char *name; +#ifdef BHND_NV_INVARIANTS + void *prev = *cookiep; +#endif + + /* Fetch next */ + if ((name = nv->cls->op_next(nv, cookiep)) == NULL) + return (NULL); + + /* Enforce precedence ordering invariant between bhnd_nvram_data_next() + * and bhnd_nvram_data_getvar_order() */ +#ifdef BHND_NV_INVARIANTS + if (prev != NULL && + bhnd_nvram_data_getvar_order(nv, prev, *cookiep) > 0) + { + BHND_NV_PANIC("%s: returned out-of-order entry", __FUNCTION__); + } +#endif + + return (name); } /** @@ -388,7 +407,7 @@ bhnd_nvram_data_generic_find(struct bhnd cookiep = NULL; while ((next = bhnd_nvram_data_next(nv, &cookiep))) { - if (strcasecmp(name, next) == 0) + if (strcmp(name, next) == 0) return (cookiep); } @@ -397,6 +416,37 @@ bhnd_nvram_data_generic_find(struct bhnd } /** + * Compare the declaration order of two NVRAM variables. + * + * Variable declaration order is used to determine the current order of + * the variables in the source data, as well as to determine the precedence + * of variable declarations in data sources that define duplicate names. + * + * The comparison order will match the order of variables returned via + * bhnd_nvstore_path_data_next(). + * + * @param nv The NVRAM data. + * @param cookiep1 An NVRAM variable cookie previously + * returned via bhnd_nvram_data_next() or + * bhnd_nvram_data_find(). + * @param cookiep2 An NVRAM variable cookie previously + * returned via bhnd_nvram_data_next() or + * bhnd_nvram_data_find(). + * + * @retval <= -1 If @p cookiep1 has an earlier declaration order than + * @p cookiep2. + * @retval 0 If @p cookiep1 and @p cookiep2 are identical. + * @retval >= 1 If @p cookiep has a later declaration order than + * @p cookiep2. + */ +int +bhnd_nvram_data_getvar_order(struct bhnd_nvram_data *nv, void *cookiep1, + void *cookiep2) +{ + return (nv->cls->op_getvar_order(nv, cookiep1, cookiep2)); +} + +/** * Read a variable and decode as @p type. * * @param nv The NVRAM data. @@ -423,6 +473,58 @@ bhnd_nvram_data_getvar(struct bhnd_nvram return (nv->cls->op_getvar(nv, cookiep, buf, len, type)); } +/* + * Common bhnd_nvram_data_getvar_ptr() wrapper used by + * bhnd_nvram_data_generic_rp_getvar() and + * bhnd_nvram_data_generic_rp_copy_val(). + * + * If a variable definition for the requested variable is found via + * bhnd_nvram_find_vardefn(), the definition will be used to populate fmt. + */ +static const void * +bhnd_nvram_data_getvar_ptr_info(struct bhnd_nvram_data *nv, void *cookiep, + size_t *len, bhnd_nvram_type *type, const bhnd_nvram_val_fmt **fmt) +{ + const struct bhnd_nvram_vardefn *vdefn; + const char *name; + const void *vptr; + + BHND_NV_ASSERT(bhnd_nvram_data_caps(nv) & BHND_NVRAM_DATA_CAP_READ_PTR, + ("instance does not advertise READ_PTR support")); + + /* Fetch pointer to variable data */ + vptr = bhnd_nvram_data_getvar_ptr(nv, cookiep, len, type); + if (vptr == NULL) + return (NULL); + + /* Select a default value format implementation */ + + + /* Fetch the reference variable name */ + name = bhnd_nvram_data_getvar_name(nv, cookiep); + + /* Trim path prefix, if any; the Broadcom NVRAM format assumes a global + * namespace for all variable definitions */ + if (bhnd_nvram_data_caps(nv) & BHND_NVRAM_DATA_CAP_DEVPATHS) + name = bhnd_nvram_trim_path_name(name); + + /* Check the variable definition table for a matching entry; if + * it exists, use it to populate the value format. */ + vdefn = bhnd_nvram_find_vardefn(name); + if (vdefn != NULL) { + BHND_NV_ASSERT(vdefn->fmt != NULL, + ("NULL format for %s", name)); + *fmt = vdefn->fmt; + } else if (*type == BHND_NVRAM_TYPE_STRING) { + /* Default to Broadcom-specific string interpretation */ + *fmt = &bhnd_nvram_val_bcm_string_fmt; + } else { + /* Fall back on native formatting */ + *fmt = bhnd_nvram_val_default_fmt(*type); + } + + return (vptr); +} /** * A generic implementation of bhnd_nvram_data_getvar(). @@ -432,17 +534,15 @@ bhnd_nvram_data_getvar(struct bhnd_nvram * of the caller. * * If a variable definition for the requested variable is available via - * bhnd_nvram_find_vardefn(), the definition will be used to provide - * formatting hints to bhnd_nvram_coerce_value(). + * bhnd_nvram_find_vardefn(), the definition will be used to provide a + * formatting instance to bhnd_nvram_val_init(). */ int bhnd_nvram_data_generic_rp_getvar(struct bhnd_nvram_data *nv, void *cookiep, void *outp, size_t *olen, bhnd_nvram_type otype) { bhnd_nvram_val val; - const struct bhnd_nvram_vardefn *vdefn; const bhnd_nvram_val_fmt *fmt; - const char *name; const void *vptr; bhnd_nvram_type vtype; size_t vlen; @@ -451,28 +551,12 @@ bhnd_nvram_data_generic_rp_getvar(struct BHND_NV_ASSERT(bhnd_nvram_data_caps(nv) & BHND_NVRAM_DATA_CAP_READ_PTR, ("instance does not advertise READ_PTR support")); - /* Fetch pointer to our variable data */ - vptr = bhnd_nvram_data_getvar_ptr(nv, cookiep, &vlen, &vtype); + /* Fetch variable data and value format*/ + vptr = bhnd_nvram_data_getvar_ptr_info(nv, cookiep, &vlen, &vtype, + &fmt); if (vptr == NULL) return (EINVAL); - /* Use the NVRAM string support */ - switch (vtype) { - case BHND_NVRAM_TYPE_STRING: - case BHND_NVRAM_TYPE_STRING_ARRAY: - fmt = &bhnd_nvram_val_bcm_string_fmt; - break; - default: - fmt = NULL; - } - - /* Check the variable definition table for a matching entry; if - * it exists, use it to populate the value format. */ - name = bhnd_nvram_data_getvar_name(nv, cookiep); - vdefn = bhnd_nvram_find_vardefn(name); - if (vdefn != NULL) - fmt = vdefn->fmt; - /* Attempt value coercion */ error = bhnd_nvram_val_init(&val, fmt, vptr, vlen, vtype, BHND_NVRAM_VAL_BORROW_DATA); @@ -487,6 +571,63 @@ bhnd_nvram_data_generic_rp_getvar(struct } /** + * Return a caller-owned copy of an NVRAM entry's variable data. + * + * The caller is responsible for deallocating the returned value via + * bhnd_nvram_val_release(). + * + * @param nv The NVRAM data. + * @param cookiep An NVRAM variable cookie previously returned + * via bhnd_nvram_data_next() or bhnd_nvram_data_find(). + * @param[out] value On success, the caller-owned value instance. + * + * @retval 0 success + * @retval ENOMEM If allocation fails. + * @retval non-zero If initialization of the value otherwise fails, a + * regular unix error code will be returned. + */ +int +bhnd_nvram_data_copy_val(struct bhnd_nvram_data *nv, void *cookiep, + bhnd_nvram_val **value) +{ + return (nv->cls->op_copy_val(nv, cookiep, value)); +} + +/** + * A generic implementation of bhnd_nvram_data_copy_val(). + * + * This implementation will call bhnd_nvram_data_getvar_ptr() to fetch + * a pointer to the variable data and perform data coercion on behalf + * of the caller. + * + * If a variable definition for the requested variable is available via + * bhnd_nvram_find_vardefn(), the definition will be used to provide a + * formatting instance to bhnd_nvram_val_init(). + */ +int +bhnd_nvram_data_generic_rp_copy_val(struct bhnd_nvram_data *nv, + void *cookiep, bhnd_nvram_val **value) +{ + const bhnd_nvram_val_fmt *fmt; + const void *vptr; + bhnd_nvram_type vtype; + size_t vlen; + + BHND_NV_ASSERT(bhnd_nvram_data_caps(nv) & BHND_NVRAM_DATA_CAP_READ_PTR, + ("instance does not advertise READ_PTR support")); + + /* Fetch variable data and value format*/ + vptr = bhnd_nvram_data_getvar_ptr_info(nv, cookiep, &vlen, &vtype, + &fmt); + if (vptr == NULL) + return (EINVAL); + + /* Allocate and return the new value instance */ + return (bhnd_nvram_val_new(value, fmt, vptr, vlen, vtype, + BHND_NVRAM_VAL_DYNAMIC)); +} + +/** * If available and supported by the NVRAM data instance, return a reference * to the internal buffer containing an entry's variable data, * @@ -526,3 +667,44 @@ bhnd_nvram_data_getvar_name(struct bhnd_ { return (nv->cls->op_getvar_name(nv, cookiep)); } + +/** + * Filter a request to set variable @p name with @p value. + * + * On success, the caller owns a reference to @p result, and must release + * any held resources via bhnd_nvram_val_release(). + * + * @param nv The NVRAM data instance. + * @param name The name of the variable to be set. + * @param value The proposed value to be set. + * @param[out] result On success, a caller-owned reference to the filtered + * value to be set. + * + * @retval 0 success + * @retval ENOENT if @p name is unrecognized by @p nv. + * @retval EINVAL if @p name is read-only. + * @retval EINVAL if @p value cannot be converted to the required value + * type. + */ +int +bhnd_nvram_data_filter_setvar(struct bhnd_nvram_data *nv, const char *name, + bhnd_nvram_val *value, bhnd_nvram_val **result) +{ + return (nv->cls->op_filter_setvar(nv, name, value, result)); +} + +/** + * Filter a request to delete variable @p name. + * + * @param nv The NVRAM data instance. + * @param name The name of the variable to be deleted. + * + * @retval 0 success + * @retval ENOENT if @p name is unrecognized by @p nv. + * @retval EINVAL if @p name is read-only. + */ +int +bhnd_nvram_data_filter_unsetvar(struct bhnd_nvram_data *nv, const char *name) +{ + return (nv->cls->op_filter_unsetvar(nv, name)); +} Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data.h ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_data.h Mon Dec 19 20:26:10 2016 (r310294) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_data.h Mon Dec 19 20:28:27 2016 (r310295) @@ -44,6 +44,7 @@ #include "bhnd_nvram.h" #include "bhnd_nvram_io.h" +#include "bhnd_nvram_value.h" /* NVRAM data class */ typedef struct bhnd_nvram_data_class bhnd_nvram_data_class; @@ -108,7 +109,6 @@ void bhnd_nvram_data_release(struct b bhnd_nvram_data_class *bhnd_nvram_data_get_class(struct bhnd_nvram_data *nv); size_t bhnd_nvram_data_count(struct bhnd_nvram_data *nv); - int bhnd_nvram_data_size(struct bhnd_nvram_data *nv, size_t *size); @@ -119,10 +119,13 @@ uint32_t bhnd_nvram_data_caps(struct b const char *bhnd_nvram_data_next(struct bhnd_nvram_data *nv, void **cookiep); - void *bhnd_nvram_data_find(struct bhnd_nvram_data *nv, const char *name); +int bhnd_nvram_data_getvar_order( + struct bhnd_nvram_data *nv, void *cookiep1, + void *cookiep2); + int bhnd_nvram_data_getvar(struct bhnd_nvram_data *nv, void *cookiep, void *buf, size_t *len, bhnd_nvram_type type); @@ -133,4 +136,13 @@ const void *bhnd_nvram_data_getvar_ptr( const char *bhnd_nvram_data_getvar_name(struct bhnd_nvram_data *nv, void *cookiep); +int bhnd_nvram_data_copy_val(struct bhnd_nvram_data *nv, + void *cookiep, bhnd_nvram_val **val); + +int bhnd_nvram_data_filter_setvar( + struct bhnd_nvram_data *nv, const char *name, + bhnd_nvram_val *value, bhnd_nvram_val **result); +int bhnd_nvram_data_filter_unsetvar( + struct bhnd_nvram_data *nv, const char *name); + #endif /* _BHND_NVRAM_BHND_NVRAM_DATA_H_ */ Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcm.c ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcm.c Mon Dec 19 20:26:10 2016 (r310294) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcm.c Mon Dec 19 20:28:27 2016 (r310295) @@ -618,7 +618,7 @@ bhnd_nvram_bcm_next(struct bhnd_nvram_da return (NULL); } - *cookiep = (void *)(uintptr_t)envp; + *cookiep = __DECONST(void *, envp); return (envp); } @@ -629,12 +629,52 @@ bhnd_nvram_bcm_find(struct bhnd_nvram_da } static int +bhnd_nvram_bcm_getvar_order(struct bhnd_nvram_data *nv, void *cookiep1, + void *cookiep2) +{ + struct bhnd_nvram_bcm *bcm; + struct bhnd_nvram_bcm_hvar *hvar1, *hvar2; + + bcm = (struct bhnd_nvram_bcm *)nv; + + hvar1 = bhnd_nvram_bcm_to_hdrvar(bcm, cookiep1); + hvar2 = bhnd_nvram_bcm_to_hdrvar(bcm, cookiep2); + + /* Header variables are always ordered below any variables defined + * in the BCM data */ + if (hvar1 != NULL && hvar2 == NULL) { + return (1); /* hvar follows non-hvar */ + } else if (hvar1 == NULL && hvar2 != NULL) { + return (-1); /* non-hvar precedes hvar */ + } + + /* Otherwise, both cookies are either hvars or non-hvars. We can + * safely fall back on pointer order, which will provide a correct + * ordering matching the behavior of bhnd_nvram_data_next() for + * both cases */ + if (cookiep1 < cookiep2) + return (-1); + + if (cookiep1 > cookiep2) + return (1); + + return (0); +} + +static int bhnd_nvram_bcm_getvar(struct bhnd_nvram_data *nv, void *cookiep, void *buf, size_t *len, bhnd_nvram_type type) { return (bhnd_nvram_data_generic_rp_getvar(nv, cookiep, buf, len, type)); } +static int +bhnd_nvram_bcm_copy_val(struct bhnd_nvram_data *nv, void *cookiep, + bhnd_nvram_val **value) +{ + return (bhnd_nvram_data_generic_rp_copy_val(nv, cookiep, value)); +} + static const void * bhnd_nvram_bcm_getvar_ptr(struct bhnd_nvram_data *nv, void *cookiep, size_t *len, bhnd_nvram_type *type) @@ -683,6 +723,35 @@ bhnd_nvram_bcm_getvar_name(struct bhnd_n return (cookiep); } +static int +bhnd_nvram_bcm_filter_setvar(struct bhnd_nvram_data *nv, const char *name, + bhnd_nvram_val *value, bhnd_nvram_val **result) +{ + bhnd_nvram_val *str; + int error; + + /* Name (trimmed of any path prefix) must be valid */ + if (!bhnd_nvram_validate_name(bhnd_nvram_trim_path_name(name))) + return (EINVAL); + + /* Value must be bcm-formatted string */ + error = bhnd_nvram_val_convert_new(&str, &bhnd_nvram_val_bcm_string_fmt, + value, BHND_NVRAM_VAL_DYNAMIC); + if (error) + return (error); + + /* Success. Transfer result ownership to the caller. */ + *result = str; + return (0); +} + +static int +bhnd_nvram_bcm_filter_unsetvar(struct bhnd_nvram_data *nv, const char *name) +{ + /* We permit deletion of any variable */ + return (0); +} + /** * Return the internal BCM data reference for a header-defined variable * with @p name, or NULL if none exists. Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcmraw.c ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcmraw.c Mon Dec 19 20:26:10 2016 (r310294) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcmraw.c Mon Dec 19 20:28:27 2016 (r310295) @@ -351,12 +351,32 @@ bhnd_nvram_bcmraw_find(struct bhnd_nvram } static int +bhnd_nvram_bcmraw_getvar_order(struct bhnd_nvram_data *nv, void *cookiep1, + void *cookiep2) +{ + if (cookiep1 < cookiep2) + return (-1); + + if (cookiep1 > cookiep2) + return (1); + + return (0); +} + +static int bhnd_nvram_bcmraw_getvar(struct bhnd_nvram_data *nv, void *cookiep, void *buf, size_t *len, bhnd_nvram_type type) { return (bhnd_nvram_data_generic_rp_getvar(nv, cookiep, buf, len, type)); } +static int +bhnd_nvram_bcmraw_copy_val(struct bhnd_nvram_data *nv, void *cookiep, + bhnd_nvram_val **value) +{ + return (bhnd_nvram_data_generic_rp_copy_val(nv, cookiep, value)); +} + static const void * bhnd_nvram_bcmraw_getvar_ptr(struct bhnd_nvram_data *nv, void *cookiep, size_t *len, bhnd_nvram_type *type) @@ -378,3 +398,32 @@ bhnd_nvram_bcmraw_getvar_name(struct bhn /* Cookie points to key\0value\0 */ return (cookiep); } + +static int +bhnd_nvram_bcmraw_filter_setvar(struct bhnd_nvram_data *nv, const char *name, + bhnd_nvram_val *value, bhnd_nvram_val **result) +{ + bhnd_nvram_val *str; + int error; + + /* Name (trimmed of any path prefix) must be valid */ + if (!bhnd_nvram_validate_name(bhnd_nvram_trim_path_name(name))) + return (EINVAL); + + /* Value must be bcm-formatted string */ + error = bhnd_nvram_val_convert_new(&str, &bhnd_nvram_val_bcm_string_fmt, + value, BHND_NVRAM_VAL_DYNAMIC); + if (error) + return (error); + + /* Success. Transfer result ownership to the caller. */ + *result = str; + return (0); +} + +static int +bhnd_nvram_bcmraw_filter_unsetvar(struct bhnd_nvram_data *nv, const char *name) +{ + /* We permit deletion of any variable */ + return (0); +} Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data_btxt.c ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_data_btxt.c Mon Dec 19 20:26:10 2016 (r310294) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_data_btxt.c Mon Dec 19 20:28:27 2016 (r310295) @@ -77,8 +77,10 @@ union bhnd_nvram_btxt_ident { char btxt[8]; }; -static size_t bhnd_nvram_btxt_io_offset(struct bhnd_nvram_btxt *btxt, - void *cookiep); +static void *bhnd_nvram_btxt_offset_to_cookiep(struct bhnd_nvram_btxt *btxt, + size_t io_offset); +static size_t bhnd_nvram_btxt_cookiep_to_offset(struct bhnd_nvram_btxt *btxt, + void *cookiep); static int bhnd_nvram_btxt_entry_len(struct bhnd_nvram_io *io, size_t offset, size_t *line_len, size_t *env_len); @@ -322,35 +324,40 @@ bhnd_nvram_btxt_next(struct bhnd_nvram_d btxt = (struct bhnd_nvram_btxt *)nv; io_size = bhnd_nvram_io_getsize(btxt->data); - io_offset = bhnd_nvram_btxt_io_offset(btxt, *cookiep); + + if (*cookiep == NULL) { + /* Start search at initial file offset */ + io_offset = 0x0; + } else { + /* Start search after the current entry */ + io_offset = bhnd_nvram_btxt_cookiep_to_offset(btxt, *cookiep); + + /* Scan past the current entry by finding the next newline */ + error = bhnd_nvram_btxt_seek_eol(btxt->data, &io_offset); + if (error) { + BHND_NV_LOG("unexpected error in seek_eol(): %d\n", + error); + return (NULL); + } + } /* Already at EOF? */ if (io_offset == io_size) return (NULL); - /* Seek to the next entry (if any) */ - if ((error = bhnd_nvram_btxt_seek_eol(btxt->data, &io_offset))) { - BHND_NV_LOG("unexpected error in seek_eol(): %d\n", error); - return (NULL); - } - + /* Seek to the first valid entry, or EOF */ if ((error = bhnd_nvram_btxt_seek_next(btxt->data, &io_offset))) { BHND_NV_LOG("unexpected error in seek_next(): %d\n", error); return (NULL); } - /* Provide the new cookie for this offset */ - if (io_offset > UINTPTR_MAX) { - BHND_NV_LOG("io_offset > UINPTR_MAX!\n"); - return (NULL); - } - - *cookiep = (void *)(uintptr_t)io_offset; - /* Hit EOF? */ if (io_offset == io_size) return (NULL); + /* Provide the new cookie for this offset */ + *cookiep = bhnd_nvram_btxt_offset_to_cookiep(btxt, io_offset); + /* Fetch the name pointer; it must be at least 1 byte long */ error = bhnd_nvram_io_read_ptr(btxt->data, io_offset, &nptr, 1, NULL); if (error) { @@ -363,12 +370,32 @@ bhnd_nvram_btxt_next(struct bhnd_nvram_d } static int +bhnd_nvram_btxt_getvar_order(struct bhnd_nvram_data *nv, void *cookiep1, + void *cookiep2) +{ + if (cookiep1 < cookiep2) + return (-1); + + if (cookiep1 > cookiep2) + return (1); + + return (0); +} + +static int bhnd_nvram_btxt_getvar(struct bhnd_nvram_data *nv, void *cookiep, void *buf, size_t *len, bhnd_nvram_type type) { return (bhnd_nvram_data_generic_rp_getvar(nv, cookiep, buf, len, type)); } +static int +bhnd_nvram_btxt_copy_val(struct bhnd_nvram_data *nv, void *cookiep, + bhnd_nvram_val **value) +{ + return (bhnd_nvram_data_generic_rp_copy_val(nv, cookiep, value)); +} + const void * bhnd_nvram_btxt_getvar_ptr(struct bhnd_nvram_data *nv, void *cookiep, size_t *len, bhnd_nvram_type *type) @@ -383,7 +410,7 @@ bhnd_nvram_btxt_getvar_ptr(struct bhnd_n btxt = (struct bhnd_nvram_btxt *)nv; io_size = bhnd_nvram_io_getsize(btxt->data); - io_offset = bhnd_nvram_btxt_io_offset(btxt, cookiep); + io_offset = bhnd_nvram_btxt_cookiep_to_offset(btxt, cookiep); /* At EOF? */ if (io_offset == io_size) @@ -429,7 +456,7 @@ bhnd_nvram_btxt_getvar_name(struct bhnd_ btxt = (struct bhnd_nvram_btxt *)nv; io_size = bhnd_nvram_io_getsize(btxt->data); - io_offset = bhnd_nvram_btxt_io_offset(btxt, cookiep); + io_offset = bhnd_nvram_btxt_cookiep_to_offset(btxt, cookiep); /* At EOF? */ if (io_offset == io_size) @@ -444,20 +471,51 @@ bhnd_nvram_btxt_getvar_name(struct bhnd_ return (ptr); } -/* Convert cookie back to an I/O offset */ +/** + * Return a cookiep for the given I/O offset. + */ +static void * +bhnd_nvram_btxt_offset_to_cookiep(struct bhnd_nvram_btxt *btxt, + size_t io_offset) +{ + const void *ptr; + int error; + + BHND_NV_ASSERT(io_offset < bhnd_nvram_io_getsize(btxt->data), + ("io_offset %zu out-of-range", io_offset)); + BHND_NV_ASSERT(io_offset < UINTPTR_MAX, + ("io_offset %#zx exceeds UINTPTR_MAX", io_offset)); + + error = bhnd_nvram_io_read_ptr(btxt->data, 0x0, &ptr, io_offset, NULL); + if (error) + BHND_NV_PANIC("error mapping offset %zu: %d", io_offset, error); + + ptr = (const uint8_t *)ptr + io_offset; + return (__DECONST(void *, ptr)); +} + +/* Convert a cookiep back to an I/O offset */ static size_t -bhnd_nvram_btxt_io_offset(struct bhnd_nvram_btxt *btxt, void *cookiep) +bhnd_nvram_btxt_cookiep_to_offset(struct bhnd_nvram_btxt *btxt, void *cookiep) { - size_t io_size; - uintptr_t cval; + const void *ptr; + intptr_t offset; + size_t io_size; + int error; + + BHND_NV_ASSERT(cookiep != NULL, ("null cookiep")); io_size = bhnd_nvram_io_getsize(btxt->data); - cval = (uintptr_t)cookiep; + error = bhnd_nvram_io_read_ptr(btxt->data, 0x0, &ptr, io_size, NULL); + if (error) + BHND_NV_PANIC("error mapping offset %zu: %d", io_size, error); - BHND_NV_ASSERT(cval < SIZE_MAX, ("cookie > SIZE_MAX)")); - BHND_NV_ASSERT(cval <= io_size, ("cookie > io_size)")); + offset = (const uint8_t *)cookiep - (const uint8_t *)ptr; + BHND_NV_ASSERT(offset >= 0, ("invalid cookiep")); + BHND_NV_ASSERT((uintptr_t)offset < SIZE_MAX, ("cookiep > SIZE_MAX)")); + BHND_NV_ASSERT((uintptr_t)offset <= io_size, ("cookiep > io_size)")); - return ((size_t)cval); + return ((size_t)offset); } /* Determine the entry length and env 'key=value' string length of the entry @@ -584,3 +642,50 @@ bhnd_nvram_btxt_seek_next(struct bhnd_nv *offset += (p - baseptr); return (0); } + +static int +bhnd_nvram_btxt_filter_setvar(struct bhnd_nvram_data *nv, const char *name, + bhnd_nvram_val *value, bhnd_nvram_val **result) +{ + bhnd_nvram_val *str; + const char *inp; + bhnd_nvram_type itype; + size_t ilen; + int error; + + /* Name (trimmed of any path prefix) must be valid */ + if (!bhnd_nvram_validate_name(bhnd_nvram_trim_path_name(name))) + return (EINVAL); + + /* Value must be bcm-formatted string */ + error = bhnd_nvram_val_convert_new(&str, &bhnd_nvram_val_bcm_string_fmt, + value, BHND_NVRAM_VAL_DYNAMIC); + if (error) + return (error); + + /* Value string must not contain our record delimiter character ('\n'), + * or our comment character ('#') */ + inp = bhnd_nvram_val_bytes(str, &ilen, &itype); + BHND_NV_ASSERT(itype == BHND_NVRAM_TYPE_STRING, ("non-string value")); + for (size_t i = 0; i < ilen; i++) { + switch (inp[i]) { + case '\n': + case '#': + BHND_NV_LOG("invalid character (%#hhx) in value\n", + inp[i]); + bhnd_nvram_val_release(str); + return (EINVAL); + } + } + + /* Success. Transfer result ownership to the caller. */ + *result = str; + return (0); +} + +static int +bhnd_nvram_btxt_filter_unsetvar(struct bhnd_nvram_data *nv, const char *name) +{ + /* We permit deletion of any variable */ + return (0); +} Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c Mon Dec 19 20:26:10 2016 (r310294) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c Mon Dec 19 20:28:27 2016 (r310295) @@ -666,25 +666,34 @@ bhnd_nvram_sprom_read_offset(struct bhnd return (0); } +/** + * Common variable decoding; fetches and decodes variable to @p val, + * using @p storage for actual data storage. + * + * The returned @p val instance will hold a borrowed reference to @p storage, + * and must be copied via bhnd_nvram_val_copy() if it will be referenced beyond + * the lifetime of @p storage. + * + * The caller is responsible for releasing any allocated value state + * via bhnd_nvram_val_release(). + */ static int -bhnd_nvram_sprom_getvar(struct bhnd_nvram_data *nv, void *cookiep, void *buf, - size_t *len, bhnd_nvram_type otype) +bhnd_nvram_sprom_getvar_common(struct bhnd_nvram_data *nv, void *cookiep, + union bhnd_nvram_sprom_storage *storage, bhnd_nvram_val *val) { - bhnd_nvram_val val; struct bhnd_nvram_sprom *sp; - struct sprom_opcode_idx *idx; + struct sprom_opcode_idx *entry; const struct bhnd_nvram_vardefn *var; - union bhnd_nvram_sprom_storage storage; union bhnd_nvram_sprom_storage *inp; - union bhnd_nvram_sprom_intv intv; bhnd_nvram_type var_btype; + union bhnd_nvram_sprom_intv intv; size_t ilen, ipos, iwidth; size_t nelem; bool all_bits_set; int error; sp = (struct bhnd_nvram_sprom *)nv; - idx = cookiep; + entry = cookiep; BHND_NV_ASSERT(cookiep != NULL, ("NULL variable cookiep")); @@ -699,7 +708,7 @@ bhnd_nvram_sprom_getvar(struct bhnd_nvra * canonical NVRAM variable definition, but some SPROM layouts may * define a smaller element count. */ - if ((error = sprom_opcode_parse_var(&sp->state, idx))) { + if ((error = sprom_opcode_parse_var(&sp->state, entry))) { BHND_NV_LOG("variable evaluation failed: %d\n", error); return (error); } @@ -724,9 +733,9 @@ bhnd_nvram_sprom_getvar(struct bhnd_nvra } ilen = nelem * iwidth; - /* Decode into our own local storage. */ - inp = &storage; - if (ilen > sizeof(storage)) { + /* Decode into our caller's local storage */ + inp = storage; + if (ilen > sizeof(*storage)) { BHND_NV_LOG("error decoding '%s', SPROM_ARRAY_MAXLEN " "incorrect\n", var->name); return (EFTYPE); @@ -739,7 +748,7 @@ bhnd_nvram_sprom_getvar(struct bhnd_nvra /* * Decode the SPROM data, iteratively decoding up to nelem values. */ - if ((error = sprom_opcode_state_seek(&sp->state, idx))) { + if ((error = sprom_opcode_state_seek(&sp->state, entry))) { BHND_NV_LOG("variable seek failed: %d\n", error); return (error); } @@ -840,8 +849,9 @@ bhnd_nvram_sprom_getvar(struct bhnd_nvra /* Perform coercion of the array element */ nbyte = iwidth; - error = bhnd_nvram_value_coerce(&intv, sizeof(intv), - intv_type, ptr, &nbyte, var_btype); + error = bhnd_nvram_value_coerce(&intv.u32, + sizeof(intv.u32), intv_type, ptr, &nbyte, + var_btype); if (error) return (error); @@ -871,13 +881,45 @@ bhnd_nvram_sprom_getvar(struct bhnd_nvra if ((var->flags & BHND_NVRAM_VF_IGNALL1) && all_bits_set) return (ENOENT); + /* Provide value wrapper */ + return (bhnd_nvram_val_init(val, var->fmt, inp, ilen, var->type, + BHND_NVRAM_VAL_BORROW_DATA)); + return (error); +} + +static int +bhnd_nvram_sprom_getvar_order(struct bhnd_nvram_data *nv, void *cookiep1, + void *cookiep2) +{ + struct sprom_opcode_idx_entry *e1, *e2; + + e1 = cookiep1; + e2 = cookiep2; - /* Perform value coercion from our local representation */ - error = bhnd_nvram_val_init(&val, var->fmt, inp, ilen, var->type, - BHND_NVRAM_VAL_BORROW_DATA); + /* Use the index entry order; this matches the order of variables + * returned via bhnd_nvram_sprom_next() */ + if (e1 < e2) + return (-1); + else if (e1 > e2) + return (1); + + return (0); +} + +static int +bhnd_nvram_sprom_getvar(struct bhnd_nvram_data *nv, void *cookiep, void *buf, + size_t *len, bhnd_nvram_type otype) +{ + bhnd_nvram_val val; + union bhnd_nvram_sprom_storage storage; + int error; + + /* Decode variable to a new value instance */ + error = bhnd_nvram_sprom_getvar_common(nv, cookiep, &storage, &val); if (error) return (error); + /* Perform value coercion */ error = bhnd_nvram_val_encode(&val, buf, len, otype); /* Clean up */ @@ -885,6 +927,29 @@ bhnd_nvram_sprom_getvar(struct bhnd_nvra return (error); } +static int +bhnd_nvram_sprom_copy_val(struct bhnd_nvram_data *nv, void *cookiep, + bhnd_nvram_val **value) +{ + bhnd_nvram_val val; + union bhnd_nvram_sprom_storage storage; + int error; + + /* Decode variable to a new value instance */ + error = bhnd_nvram_sprom_getvar_common(nv, cookiep, &storage, &val); + if (error) + return (error); + + /* Attempt to copy to heap */ + *value = bhnd_nvram_val_copy(&val); + bhnd_nvram_val_release(&val); + + if (*value == NULL) + return (ENOMEM); + + return (0); +} + static const void * bhnd_nvram_sprom_getvar_ptr(struct bhnd_nvram_data *nv, void *cookiep, size_t *len, bhnd_nvram_type *type) @@ -906,6 +971,21 @@ bhnd_nvram_sprom_getvar_name(struct bhnd return (var->name); } +static int +bhnd_nvram_sprom_filter_setvar(struct bhnd_nvram_data *nv, const char *name, + bhnd_nvram_val *value, bhnd_nvram_val **result) +{ + // XXX TODO + return (ENXIO); +} + +static int +bhnd_nvram_sprom_filter_unsetvar(struct bhnd_nvram_data *nv, const char *name) +{ + // XXX TODO + return (ENXIO); +} + /** * Initialize SPROM opcode evaluation state. * Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data_tlv.c ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_data_tlv.c Mon Dec 19 20:26:10 2016 (r310294) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_data_tlv.c Mon Dec 19 20:28:27 2016 (r310295) @@ -82,6 +82,10 @@ struct bhnd_nvram_tlv_env { (((_env)->hdr.size < sizeof((_env)->flags)) ? 0 : \ ((_env)->hdr.size - sizeof((_env)->flags))) +/* Maximum supported length of the envp data field, in bytes */ +#define NVRAM_TLV_ENVP_DATA_MAX_LEN \ + (UINT8_MAX - sizeof(uint8_t) /* flags */) + static int bhnd_nvram_tlv_parse_size( struct bhnd_nvram_io *io, @@ -368,12 +372,32 @@ bhnd_nvram_tlv_find(struct bhnd_nvram_da } static int +bhnd_nvram_tlv_getvar_order(struct bhnd_nvram_data *nv, void *cookiep1, + void *cookiep2) +{ + if (cookiep1 < cookiep2) + return (-1); + + if (cookiep1 > cookiep2) + return (1); + + return (0); +} + +static int bhnd_nvram_tlv_getvar(struct bhnd_nvram_data *nv, void *cookiep, void *buf, size_t *len, bhnd_nvram_type type) { return (bhnd_nvram_data_generic_rp_getvar(nv, cookiep, buf, len, type)); } +static int +bhnd_nvram_tlv_copy_val(struct bhnd_nvram_data *nv, void *cookiep, + bhnd_nvram_val **value) +{ + return (bhnd_nvram_data_generic_rp_copy_val(nv, cookiep, value)); +} + static const void * bhnd_nvram_tlv_getvar_ptr(struct bhnd_nvram_data *nv, void *cookiep, size_t *len, bhnd_nvram_type *type) @@ -417,6 +441,61 @@ bhnd_nvram_tlv_getvar_name(struct bhnd_n return (&env->envp[0]); } +static int +bhnd_nvram_tlv_filter_setvar(struct bhnd_nvram_data *nv, const char *name, + bhnd_nvram_val *value, bhnd_nvram_val **result) +{ + bhnd_nvram_val *str; + const char *inp; + bhnd_nvram_type itype; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@freebsd.org Mon Dec 19 20:31:30 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 886C7C88DF8; Mon, 19 Dec 2016 20:31:30 +0000 (UTC) (envelope-from landonf@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 24EFC122E; Mon, 19 Dec 2016 20:31:30 +0000 (UTC) (envelope-from landonf@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBJKVTm5057615; Mon, 19 Dec 2016 20:31:29 GMT (envelope-from landonf@FreeBSD.org) Received: (from landonf@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBJKVSkP057602; Mon, 19 Dec 2016 20:31:28 GMT (envelope-from landonf@FreeBSD.org) Message-Id: <201612192031.uBJKVSkP057602@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: landonf set sender to landonf@FreeBSD.org using -f From: "Landon J. Fuller" Date: Mon, 19 Dec 2016 20:31:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310296 - head/sys/dev/bhnd/nvram X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 20:31:30 -0000 Author: landonf Date: Mon Dec 19 20:31:27 2016 New Revision: 310296 URL: https://svnweb.freebsd.org/changeset/base/310296 Log: bhnd(4): Add support for exporting all (or a subtree) of NVRAM properties backed by an NVRAM store. This will be used to support: - Serializing the current NVRAM state for writing back to flash. - Exporting subsidiary device paths for serialization and upload to fullmac chipsets. Additionally, this includes an improvement to BCM-RAW format detection to avoid matching on BCM-TEXT NVRAM data. Approved by: adrian (mentor) Differential Revision: https://reviews.freebsd.org/D8761 Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data.c head/sys/dev/bhnd/nvram/bhnd_nvram_data.h head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcm.c head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcmraw.c head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcmvar.h head/sys/dev/bhnd/nvram/bhnd_nvram_data_btxt.c head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c head/sys/dev/bhnd/nvram/bhnd_nvram_data_tlv.c head/sys/dev/bhnd/nvram/bhnd_nvram_datavar.h head/sys/dev/bhnd/nvram/bhnd_nvram_store.c head/sys/dev/bhnd/nvram/bhnd_nvram_store.h head/sys/dev/bhnd/nvram/bhnd_nvram_store_subr.c head/sys/dev/bhnd/nvram/bhnd_nvram_storevar.h Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data.c ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_data.c Mon Dec 19 20:28:27 2016 (r310295) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_data.c Mon Dec 19 20:31:27 2016 (r310296) @@ -281,6 +281,18 @@ bhnd_nvram_data_count(struct bhnd_nvram_ } /** + * Return a borrowed reference to the serialization options for @p nv, + * suitable for use with bhnd_nvram_data_serialize(), or NULL if none. + * + * @param nv The NVRAM data to be queried. + */ +bhnd_nvram_plist * +bhnd_nvram_data_options(struct bhnd_nvram_data *nv) +{ + return (nv->cls->op_options(nv)); +} + +/** * Compute the size of the serialized form of @p nv. * * Serialization may be performed via bhnd_nvram_data_serialize(). Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data.h ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_data.h Mon Dec 19 20:28:27 2016 (r310295) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_data.h Mon Dec 19 20:31:27 2016 (r310296) @@ -44,6 +44,7 @@ #include "bhnd_nvram.h" #include "bhnd_nvram_io.h" +#include "bhnd_nvram_plist.h" #include "bhnd_nvram_value.h" /* NVRAM data class */ @@ -115,6 +116,7 @@ int bhnd_nvram_data_size(struct bhnd_ int bhnd_nvram_data_serialize(struct bhnd_nvram_data *nv, void *buf, size_t *len); +bhnd_nvram_plist *bhnd_nvram_data_options(struct bhnd_nvram_data *nv); uint32_t bhnd_nvram_data_caps(struct bhnd_nvram_data *nv); const char *bhnd_nvram_data_next(struct bhnd_nvram_data *nv, Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcm.c ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcm.c Mon Dec 19 20:28:27 2016 (r310295) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcm.c Mon Dec 19 20:31:27 2016 (r310296) @@ -121,6 +121,7 @@ static const struct bhnd_nvram_bcm_hvar struct bhnd_nvram_bcm { struct bhnd_nvram_data nv; /**< common instance state */ struct bhnd_nvram_io *data; /**< backing buffer */ + bhnd_nvram_plist *opts; /**< serialization options */ /** BCM header values */ struct bhnd_nvram_bcm_hvar hvars[nitems(bhnd_nvram_bcm_hvars)]; @@ -157,7 +158,7 @@ bhnd_nvram_bcm_init(struct bhnd_nvram_bc uint8_t *p; void *ptr; size_t io_offset, io_size; - uint8_t crc, valid; + uint8_t crc, valid, bcm_ver; int error; if ((error = bhnd_nvram_io_read(src, 0x0, &hdr, sizeof(hdr)))) @@ -344,6 +345,14 @@ bhnd_nvram_bcm_init(struct bhnd_nvram_bc bcm->count++; } + /* Populate serialization options from our header */ + bcm_ver = BCM_NVRAM_GET_BITS(hdr.cfg0, BCM_NVRAM_CFG0_VER); + error = bhnd_nvram_plist_append_bytes(bcm->opts, + BCM_NVRAM_ENCODE_OPT_VERSION, &bcm_ver, sizeof(bcm_ver), + BHND_NVRAM_TYPE_UINT8); + if (error) + return (error); + return (0); } @@ -360,6 +369,12 @@ bhnd_nvram_bcm_new(struct bhnd_nvram_dat "hvar declarations must match bhnd_nvram_bcm_hvars template"); memcpy(bcm->hvars, bhnd_nvram_bcm_hvars, sizeof(bcm->hvars)); + /* Allocate (empty) option list, to be populated by + * bhnd_nvram_bcm_init() */ + bcm->opts = bhnd_nvram_plist_new(); + if (bcm->opts == NULL) + return (ENOMEM); + /* Parse the BCM input data and initialize our backing * data representation */ if ((error = bhnd_nvram_bcm_init(bcm, io))) { @@ -377,6 +392,9 @@ bhnd_nvram_bcm_free(struct bhnd_nvram_da if (bcm->data != NULL) bhnd_nvram_io_free(bcm->data); + + if (bcm->opts != NULL) + bhnd_nvram_plist_release(bcm->opts); } size_t @@ -386,6 +404,13 @@ bhnd_nvram_bcm_count(struct bhnd_nvram_d return (bcm->count); } +static bhnd_nvram_plist * +bhnd_nvram_bcm_options(struct bhnd_nvram_data *nv) +{ + struct bhnd_nvram_bcm *bcm = (struct bhnd_nvram_bcm *)nv; + return (bcm->opts); +} + static int bhnd_nvram_bcm_size(struct bhnd_nvram_data *nv, size_t *size) { Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcmraw.c ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcmraw.c Mon Dec 19 20:28:27 2016 (r310295) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcmraw.c Mon Dec 19 20:31:27 2016 (r310296) @@ -79,19 +79,19 @@ bhnd_nvram_bcmraw_probe(struct bhnd_nvra { char envp[16]; size_t envp_len; + size_t io_size; int error; + io_size = bhnd_nvram_io_getsize(io); + /* - * Fetch the initial bytes to try to identify BCM data. - * - * We always assert a low probe priority, as we only scan the initial - * bytes of the file. + * Fetch initial bytes */ - envp_len = bhnd_nv_ummin(sizeof(envp), bhnd_nvram_io_getsize(io)); + envp_len = bhnd_nv_ummin(sizeof(envp), io_size); if ((error = bhnd_nvram_io_read(io, 0x0, envp, envp_len))) return (error); - /* A zero-length BCM-RAW buffer should contain a single terminating + /* An empty BCM-RAW buffer should still contain a single terminating * NUL */ if (envp_len == 0) return (ENXIO); @@ -103,21 +103,33 @@ bhnd_nvram_bcmraw_probe(struct bhnd_nvra return (BHND_NVRAM_DATA_PROBE_MAYBE); } - /* Don't match on non-ASCII, non-printable data */ + /* Must contain only printable ASCII characters delimited + * by NUL record delimiters */ for (size_t i = 0; i < envp_len; i++) { char c = envp[i]; - if (envp[i] == '\0') - break; - if (!bhnd_nv_isprint(c)) + /* If we hit a newline, this is probably BCM-TXT */ + if (c == '\n') return (ENXIO); + + if (c == '\0' && !bhnd_nv_isprint(c)) + continue; } - /* The first character should be a valid key char */ - if (!bhnd_nv_isalpha(envp[0])) + /* A valid BCM-RAW buffer should contain a terminating NUL for + * the last record, followed by a final empty record terminated by + * NUL */ + envp_len = 2; + if (io_size < envp_len) + return (ENXIO); + + if ((error = bhnd_nvram_io_read(io, io_size-envp_len, envp, envp_len))) + return (error); + + if (envp[0] != '\0' || envp[1] != '\0') return (ENXIO); - return (BHND_NVRAM_DATA_PROBE_MAYBE); + return (BHND_NVRAM_DATA_PROBE_MAYBE + 1); } /** @@ -245,6 +257,12 @@ bhnd_nvram_bcmraw_count(struct bhnd_nvra return (bcm->count); } +static bhnd_nvram_plist * +bhnd_nvram_bcmraw_options(struct bhnd_nvram_data *nv) +{ + return (NULL); +} + static int bhnd_nvram_bcmraw_size(struct bhnd_nvram_data *nv, size_t *size) { Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcmvar.h ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcmvar.h Mon Dec 19 20:28:27 2016 (r310295) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcmvar.h Mon Dec 19 20:31:27 2016 (r310296) @@ -32,6 +32,8 @@ #ifndef _BHND_NVRAM_BHND_NVRAM_BCMVAR_H_ #define _BHND_NVRAM_BHND_NVRAM_BCMVAR_H_ +#define BCM_NVRAM_ENCODE_OPT_VERSION "bcm_version" + /** * BCM NVRAM header value data. */ Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data_btxt.c ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_data_btxt.c Mon Dec 19 20:28:27 2016 (r310295) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_data_btxt.c Mon Dec 19 20:31:27 2016 (r310296) @@ -255,6 +255,12 @@ bhnd_nvram_btxt_count(struct bhnd_nvram_ return (btxt->count); } +static bhnd_nvram_plist * +bhnd_nvram_btxt_options(struct bhnd_nvram_data *nv) +{ + return (NULL); +} + static int bhnd_nvram_btxt_size(struct bhnd_nvram_data *nv, size_t *size) { Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c Mon Dec 19 20:28:27 2016 (r310295) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c Mon Dec 19 20:31:27 2016 (r310296) @@ -416,6 +416,12 @@ bhnd_nvram_sprom_free(struct bhnd_nvram_ bhnd_nv_free(sp->idx); } +static bhnd_nvram_plist * +bhnd_nvram_sprom_options(struct bhnd_nvram_data *nv) +{ + return (NULL); +} + size_t bhnd_nvram_sprom_count(struct bhnd_nvram_data *nv) { Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data_tlv.c ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_data_tlv.c Mon Dec 19 20:28:27 2016 (r310295) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_data_tlv.c Mon Dec 19 20:31:27 2016 (r310296) @@ -256,6 +256,12 @@ bhnd_nvram_tlv_count(struct bhnd_nvram_d return (tlv->count); } +static bhnd_nvram_plist * +bhnd_nvram_tlv_options(struct bhnd_nvram_data *nv) +{ + return (NULL); +} + static int bhnd_nvram_tlv_size(struct bhnd_nvram_data *nv, size_t *size) { @@ -350,17 +356,26 @@ bhnd_nvram_tlv_next(struct bhnd_nvram_da tlv = (struct bhnd_nvram_tlv *)nv; - /* Seek past the TLV_ENV record referenced by cookiep */ - io_offset = bhnd_nvram_tlv_to_offset(tlv, *cookiep); - if (bhnd_nvram_tlv_next_env(tlv, &io_offset, NULL) == NULL) - BHND_NV_PANIC("invalid cookiep: %p\n", cookiep); - - /* Fetch the next TLV_ENV record */ - if ((env = bhnd_nvram_tlv_next_env(tlv, &io_offset, cookiep)) == NULL) { - /* No remaining ENV records */ - return (NULL); + /* Find next readable TLV record */ + if (*cookiep == NULL) { + /* Start search at offset 0x0 */ + io_offset = 0x0; + env = bhnd_nvram_tlv_next_env(tlv, &io_offset, cookiep); + } else { + /* Seek past the previous env record */ + io_offset = bhnd_nvram_tlv_to_offset(tlv, *cookiep); + env = bhnd_nvram_tlv_next_env(tlv, &io_offset, NULL); + if (env == NULL) + BHND_NV_PANIC("invalid cookiep; record missing"); + + /* Advance to next env record, update the caller's cookiep */ + env = bhnd_nvram_tlv_next_env(tlv, &io_offset, cookiep); } + /* Check for EOF */ + if (env == NULL) + return (NULL); + /* Return the NUL terminated name */ return (env->envp); } Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_datavar.h ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_datavar.h Mon Dec 19 20:28:27 2016 (r310295) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_datavar.h Mon Dec 19 20:31:27 2016 (r310296) @@ -75,6 +75,10 @@ typedef int (bhnd_nvram_data_op_serial struct bhnd_nvram_data *nv, void *buf, size_t *len); +/** @see bhnd_nvram_data_options() */ +typedef bhnd_nvram_plist*(bhnd_nvram_data_op_options)( + struct bhnd_nvram_data *nv); + /** @see bhnd_nvram_data_caps() */ typedef uint32_t (bhnd_nvram_data_op_caps)(struct bhnd_nvram_data *nv); @@ -133,6 +137,7 @@ struct bhnd_nvram_data_class { bhnd_nvram_data_op_count *op_count; bhnd_nvram_data_op_size *op_size; bhnd_nvram_data_op_serialize *op_serialize; + bhnd_nvram_data_op_options *op_options; bhnd_nvram_data_op_caps *op_caps; bhnd_nvram_data_op_next *op_next; bhnd_nvram_data_op_find *op_find; @@ -186,6 +191,7 @@ struct bhnd_nvram_data { _macro(_cname, count) \ _macro(_cname, size) \ _macro(_cname, serialize) \ + _macro(_cname, options) \ _macro(_cname, caps) \ _macro(_cname, next) \ _macro(_cname, find) \ Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_store.c ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_store.c Mon Dec 19 20:28:27 2016 (r310295) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_store.c Mon Dec 19 20:31:27 2016 (r310296) @@ -71,6 +71,26 @@ static int bhnd_nvstore_parse_data( static int bhnd_nvstore_parse_path_entries( struct bhnd_nvram_store *sc); +static int bhnd_nvram_store_export_child( + struct bhnd_nvram_store *sc, + bhnd_nvstore_path *top, + bhnd_nvstore_path *child, + bhnd_nvram_plist *plist, + uint32_t flags); + +static int bhnd_nvstore_export_merge( + struct bhnd_nvram_store *sc, + bhnd_nvstore_path *path, + bhnd_nvram_plist *merged, + uint32_t flags); + +static int bhnd_nvstore_export_devpath_alias( + struct bhnd_nvram_store *sc, + bhnd_nvstore_path *path, + const char *devpath, + bhnd_nvram_plist *plist, + u_long *alias_val); + /** * Allocate and initialize a new NVRAM data store instance. * @@ -114,6 +134,16 @@ bhnd_nvram_store_new(struct bhnd_nvram_s /* Retain the NVRAM data */ sc->data = bhnd_nvram_data_retain(data); sc->data_caps = bhnd_nvram_data_caps(data); + sc->data_opts = bhnd_nvram_data_options(data); + if (sc->data_opts != NULL) { + bhnd_nvram_plist_retain(sc->data_opts); + } else { + sc->data_opts = bhnd_nvram_plist_new(); + if (sc->data_opts == NULL) { + error = ENOMEM; + goto cleanup; + } + } /* Register required root path */ error = bhnd_nvstore_register_path(sc, BHND_NVSTORE_ROOT_PATH, @@ -207,6 +237,8 @@ bhnd_nvram_store_free(struct bhnd_nvram_ if (sc->data != NULL) bhnd_nvram_data_release(sc->data); + if (sc->data_opts != NULL) + bhnd_nvram_plist_release(sc->data_opts); BHND_NVSTORE_LOCK_DESTROY(sc); bhnd_nv_free(sc); @@ -400,6 +432,571 @@ bhnd_nvstore_parse_path_entries(struct b return (0); } + + +/** + * Merge exported per-path variables (uncommitted, committed, or both) into + * the empty @p merged property list. + * + * @param sc The NVRAM store instance. + * @param path The NVRAM path to be exported. + * @param merged The property list to populate with the merged results. + * @param flags Export flags. See BHND_NVSTORE_EXPORT_*. + * + * @retval 0 success + * @retval ENOMEM If allocation fails. + * @retval non-zero If merging the variables defined in @p path otherwise + * fails, a regular unix error code will be returned. + */ +static int +bhnd_nvstore_export_merge(struct bhnd_nvram_store *sc, + bhnd_nvstore_path *path, bhnd_nvram_plist *merged, uint32_t flags) +{ + void *cookiep, *idxp; + int error; + + /* Populate merged list with all pending variables */ + if (BHND_NVSTORE_GET_FLAG(flags, EXPORT_UNCOMMITTED)) { + bhnd_nvram_prop *prop; + + prop = NULL; + while ((prop = bhnd_nvram_plist_next(path->pending, prop))) { + /* Skip variables marked for deletion */ + if (!BHND_NVSTORE_GET_FLAG(flags, EXPORT_DELETED)) { + if (bhnd_nvram_prop_is_null(prop)) + continue; + } + + /* Append to merged list */ + error = bhnd_nvram_plist_append(merged, prop); + if (error) + return (error); + } + } + + /* Skip merging committed variables? */ + if (!BHND_NVSTORE_GET_FLAG(flags, EXPORT_COMMITTED)) + return (0); + + /* Merge in the committed NVRAM variables */ + idxp = NULL; + while ((cookiep = bhnd_nvstore_path_data_next(sc, path, &idxp))) { + const char *name; + bhnd_nvram_val *val; + + /* Fetch the variable name */ + name = bhnd_nvram_data_getvar_name(sc->data, cookiep); + + /* Trim device path prefix */ + if (sc->data_caps & BHND_NVRAM_DATA_CAP_DEVPATHS) + name = bhnd_nvram_trim_path_name(name); + + /* Skip if already defined in pending updates */ + if (BHND_NVSTORE_GET_FLAG(flags, EXPORT_UNCOMMITTED)) { + if (bhnd_nvram_plist_contains(path->pending, name)) + continue; + } + + /* Skip if higher precedence value was already defined. This + * may occur if the underlying data store contains duplicate + * keys; iteration will always return the definition with + * the highest precedence first */ + if (bhnd_nvram_plist_contains(merged, name)) + continue; + + /* Fetch the variable's value representation */ + if ((error = bhnd_nvram_data_copy_val(sc->data, cookiep, &val))) + return (error); + + /* Add to path variable list */ + error = bhnd_nvram_plist_append_val(merged, name, val); + bhnd_nvram_val_release(val); + if (error) + return (error); + } + + return (0); +} + +/** + * Find a free alias value for @p path, and append the devpathXX alias + * declaration to @p plist. + * + * @param sc The NVRAM store instance. + * @param path The NVRAM path for which a devpath alias + * variable should be produced. + * @param devpath The devpathXX path value for @p path. + * @param plist The property list to which @p path's devpath + * variable will be appended. + * @param[out] alias_val On success, will be set to the alias value + * allocated for @p path. + * + * @retval 0 success + * @retval ENOMEM If allocation fails. + * @retval non-zero If merging the variables defined in @p path otherwise + * fails, a regular unix error code will be returned. + */ +static int +bhnd_nvstore_export_devpath_alias(struct bhnd_nvram_store *sc, + bhnd_nvstore_path *path, const char *devpath, bhnd_nvram_plist *plist, + u_long *alias_val) +{ + bhnd_nvstore_alias *alias; + char *pathvar; + int error; + + *alias_val = 0; + + /* Prefer alias value already reserved for this path. */ + alias = bhnd_nvstore_find_alias(sc, path->path_str); + if (alias != NULL) { + *alias_val = alias->alias; + + /* Allocate devpathXX variable name */ + bhnd_nv_asprintf(&pathvar, "devpath%lu", *alias_val); + if (pathvar == NULL) + return (ENOMEM); + + /* Append alias variable to property list */ + error = bhnd_nvram_plist_append_string(plist, pathvar, devpath); + + BHND_NV_ASSERT(error != EEXIST, ("reserved alias %lu:%s in use", + * alias_val, path->path_str)); + + bhnd_nv_free(pathvar); + return (error); + } + + /* Find the next free devpathXX alias entry */ + while (1) { + /* Skip existing reserved alias values */ + while (bhnd_nvstore_get_alias(sc, *alias_val) != NULL) { + if (*alias_val == ULONG_MAX) + return (ENOMEM); + + (*alias_val)++; + } + + /* Allocate devpathXX variable name */ + bhnd_nv_asprintf(&pathvar, "devpath%lu", *alias_val); + if (pathvar == NULL) + return (ENOMEM); + + /* If not in-use, we can terminate the search */ + if (!bhnd_nvram_plist_contains(plist, pathvar)) + break; + + /* Keep searching */ + bhnd_nv_free(pathvar); + + if (*alias_val == ULONG_MAX) + return (ENOMEM); + + (*alias_val)++; + } + + /* Append alias variable to property list */ + error = bhnd_nvram_plist_append_string(plist, pathvar, devpath); + + bhnd_nv_free(pathvar); + return (error); +} + +/** + * Export a single @p child path's properties, appending the result to @p plist. + * + * @param sc The NVRAM store instance. + * @param top The root NVRAM path being exported. + * @param child The NVRAM path to be exported. + * @param plist The property list to which @p child's exported + * properties should be appended. + * @param flags Export flags. See BHND_NVSTORE_EXPORT_*. + * + * @retval 0 success + * @retval ENOMEM If allocation fails. + * @retval non-zero If merging the variables defined in @p path otherwise + * fails, a regular unix error code will be returned. + */ +static int +bhnd_nvram_store_export_child(struct bhnd_nvram_store *sc, + bhnd_nvstore_path *top, bhnd_nvstore_path *child, bhnd_nvram_plist *plist, + uint32_t flags) +{ + bhnd_nvram_plist *path_vars; + bhnd_nvram_prop *prop; + const char *relpath; + char *prefix, *namebuf; + size_t prefix_len, relpath_len; + size_t namebuf_size, num_props; + bool emit_compact_devpath; + int error; + + BHND_NVSTORE_LOCK_ASSERT(sc, MA_OWNED); + + prefix = NULL; + num_props = 0; + path_vars = NULL; + namebuf = NULL; + + /* Determine the path relative to the top-level path */ + relpath = bhnd_nvstore_parse_relpath(top->path_str, child->path_str); + if (relpath == NULL) { + /* Skip -- not a child of the root path */ + return (0); + } + relpath_len = strlen(relpath); + + /* Skip sub-path if export of children was not requested, */ + if (!BHND_NVSTORE_GET_FLAG(flags, EXPORT_CHILDREN) && relpath_len > 0) + return (0); + + /* Collect all variables to be included in the export */ + if ((path_vars = bhnd_nvram_plist_new()) == NULL) + return (ENOMEM); + + if ((error = bhnd_nvstore_export_merge(sc, child, path_vars, flags))) { + bhnd_nvram_plist_release(path_vars); + return (error); + } + + /* Skip if no children are to be exported */ + if (bhnd_nvram_plist_count(path_vars) == 0) { + bhnd_nvram_plist_release(path_vars); + return (0); + } + + /* Determine appropriate device path encoding */ + emit_compact_devpath = false; + if (BHND_NVSTORE_GET_FLAG(flags, EXPORT_COMPACT_DEVPATHS)) { + /* Re-encode as compact (if non-empty path) */ + if (relpath_len > 0) + emit_compact_devpath = true; + } else if (BHND_NVSTORE_GET_FLAG(flags, EXPORT_EXPAND_DEVPATHS)) { + /* Re-encode with fully expanded device path */ + emit_compact_devpath = false; + } else if (BHND_NVSTORE_GET_FLAG(flags, EXPORT_PRESERVE_DEVPATHS)) { + /* Preserve existing encoding of this path */ + if (bhnd_nvstore_find_alias(sc, child->path_str) != NULL) + emit_compact_devpath = true; + } else { + BHND_NV_LOG("invalid device path flag: %#" PRIx32, flags); + error = EINVAL; + goto finished; + } + + /* Allocate variable device path prefix to use for all property names, + * and if using compact encoding, emit the devpathXX= variable */ + prefix = NULL; + prefix_len = 0; + if (emit_compact_devpath) { + u_long alias_val; + int len; + + /* Reserve an alias value and append the devpathXX= variable to + * the property list */ + error = bhnd_nvstore_export_devpath_alias(sc, child, relpath, + plist, &alias_val); + if (error) + goto finished; + + /* Allocate variable name prefix */ + len = bhnd_nv_asprintf(&prefix, "%lu:", alias_val); + if (prefix == NULL) { + error = ENOMEM; + goto finished; + } + + prefix_len = len; + } else if (relpath_len > 0) { + int len; + + /* Allocate the variable name prefix, appending '/' to the + * relative path */ + len = bhnd_nv_asprintf(&prefix, "%s/", relpath); + if (prefix == NULL) { + error = ENOMEM; + goto finished; + } + + prefix_len = len; + } + + /* If prefixing of variable names is required, allocate a name + * formatting buffer */ + namebuf_size = 0; + if (prefix != NULL) { + size_t maxlen; + + /* Find the maximum name length */ + maxlen = 0; + prop = NULL; + while ((prop = bhnd_nvram_plist_next(path_vars, prop))) { + const char *name; + + name = bhnd_nvram_prop_name(prop); + maxlen = bhnd_nv_ummax(strlen(name), maxlen); + } + + /* Allocate name buffer (path-prefix + name + '\0') */ + namebuf_size = prefix_len + maxlen + 1; + namebuf = bhnd_nv_malloc(namebuf_size); + if (namebuf == NULL) { + error = ENOMEM; + goto finished; + } + } + + /* Append all path variables to the export plist, prepending the + * device-path prefix to the variable names, if required */ + prop = NULL; + while ((prop = bhnd_nvram_plist_next(path_vars, prop)) != NULL) { + const char *name; + + /* Prepend device prefix to the variable name */ + name = bhnd_nvram_prop_name(prop); + if (prefix != NULL) { + int len; + + /* + * Write prefixed variable name to our name buffer. + * + * We precalcuate the size when scanning all names + * above, so this should always succeed. + */ + len = snprintf(namebuf, namebuf_size, "%s%s", prefix, + name); + if (len < 0 || (size_t)len >= namebuf_size) + BHND_NV_PANIC("invalid max_name_len"); + + name = namebuf; + } + + /* Add property to export plist */ + error = bhnd_nvram_plist_append_val(plist, name, + bhnd_nvram_prop_val(prop)); + if (error) + goto finished; + } + + /* Success */ + error = 0; + +finished: + if (prefix != NULL) + bhnd_nv_free(prefix); + + if (namebuf != NULL) + bhnd_nv_free(namebuf); + + if (path_vars != NULL) + bhnd_nvram_plist_release(path_vars); + + return (error); +} + +/** + * Export a flat, ordered NVRAM property list representation of all NVRAM + * properties at @p path. + * + * @param sc The NVRAM store instance. + * @param path The NVRAM path to export, or NULL to select the root + * path. + * @param[out] cls On success, will be set to the backing data class + * of @p sc. If the data class is are not desired, + * a NULL pointer may be provided. + * @param[out] props On success, will be set to a caller-owned property + * list containing the exported properties. The caller is + * responsible for releasing this value via + * bhnd_nvram_plist_release(). + * @param[out] options On success, will be set to a caller-owned property + * list containing the current NVRAM serialization options + * for @p sc. The caller is responsible for releasing this + * value via bhnd_nvram_plist_release(). + * @param flags Export flags. See BHND_NVSTORE_EXPORT_*. + * + * @retval 0 success + * @retval EINVAL If @p flags is invalid. + * @retval ENOENT The requested path was not found. + * @retval ENOMEM If allocation fails. + * @retval non-zero If export of @p path otherwise fails, a regular unix + * error code will be returned. + */ +int +bhnd_nvram_store_export(struct bhnd_nvram_store *sc, const char *path, + bhnd_nvram_data_class **cls, bhnd_nvram_plist **props, + bhnd_nvram_plist **options, uint32_t flags) +{ + bhnd_nvram_plist *unordered; + bhnd_nvstore_path *top; + bhnd_nvram_prop *prop; + const char *name; + void *cookiep; + size_t num_dpath_flags; + int error; + + *props = NULL; + unordered = NULL; + num_dpath_flags = 0; + if (options != NULL) + *options = NULL; + + /* Default to exporting root path */ + if (path == NULL) + path = BHND_NVSTORE_ROOT_PATH; + + /* Default to exporting all properties */ + if (!BHND_NVSTORE_GET_FLAG(flags, EXPORT_COMMITTED) && + !BHND_NVSTORE_GET_FLAG(flags, EXPORT_UNCOMMITTED)) + { + flags |= BHND_NVSTORE_EXPORT_ALL_VARS; + } + + /* Default to preserving the current device path encoding */ + if (!BHND_NVSTORE_GET_FLAG(flags, EXPORT_COMPACT_DEVPATHS) && + !BHND_NVSTORE_GET_FLAG(flags, EXPORT_EXPAND_DEVPATHS)) + { + flags |= BHND_NVSTORE_EXPORT_PRESERVE_DEVPATHS; + } + + /* Exactly one device path encoding flag must be set */ + if (BHND_NVSTORE_GET_FLAG(flags, EXPORT_COMPACT_DEVPATHS)) + num_dpath_flags++; + + if (BHND_NVSTORE_GET_FLAG(flags, EXPORT_EXPAND_DEVPATHS)) + num_dpath_flags++; + + if (BHND_NVSTORE_GET_FLAG(flags, EXPORT_PRESERVE_DEVPATHS)) + num_dpath_flags++; + + if (num_dpath_flags != 1) + return (EINVAL); + + /* If EXPORT_DELETED is set, EXPORT_UNCOMMITTED must be set too */ + if (BHND_NVSTORE_GET_FLAG(flags, EXPORT_DELETED) && + !BHND_NVSTORE_GET_FLAG(flags, EXPORT_DELETED)) + { + return (EINVAL); + } + + /* Lock internal state before querying paths/properties */ + BHND_NVSTORE_LOCK(sc); + + /* Fetch referenced path */ + top = bhnd_nvstore_get_path(sc, path, strlen(path)); + if (top == NULL) { + error = ENOENT; + goto failed; + } + + /* Allocate new, empty property list */ + if ((unordered = bhnd_nvram_plist_new()) == NULL) { + error = ENOMEM; + goto failed; + } + + /* Export the top-level path first */ + error = bhnd_nvram_store_export_child(sc, top, top, unordered, flags); + if (error) + goto failed; + + /* Attempt to export any children of the root path */ + for (size_t i = 0; i < nitems(sc->paths); i++) { + bhnd_nvstore_path *child; + + LIST_FOREACH(child, &sc->paths[i], np_link) { + /* Top-level path was already exported */ + if (child == top) + continue; + + error = bhnd_nvram_store_export_child(sc, top, + child, unordered, flags); + if (error) + goto failed; + } + } + + /* If requested, provide the current class and serialization options */ + if (cls != NULL) + *cls = bhnd_nvram_data_get_class(sc->data); + + if (options != NULL) + *options = bhnd_nvram_plist_retain(sc->data_opts); + + /* + * If we're re-encoding device paths, don't bother preserving the + * existing NVRAM variable order; our variable names will not match + * the existing backing NVRAM data. + */ + if (!BHND_NVSTORE_GET_FLAG(flags, EXPORT_PRESERVE_DEVPATHS)) { + *props = unordered; + unordered = NULL; + + goto finished; + } + + /* + * Re-order the flattened output to match the existing NVRAM variable + * ordering. + * + * We append all new variables at the end of the input; this should + * reduce the delta that needs to be written (e.g. to flash) when + * committing NVRAM updates, and should result in a serialization + * identical to the input serialization if uncommitted updates are + * excluded from the export. + */ + if ((*props = bhnd_nvram_plist_new()) == NULL) { + error = ENOMEM; + goto failed; + } + + /* Using the backing NVRAM data ordering to order all variables + * currently defined in the backing store */ + cookiep = NULL; + while ((name = bhnd_nvram_data_next(sc->data, &cookiep))) { + prop = bhnd_nvram_plist_get_prop(unordered, name); + if (prop == NULL) + continue; + + /* Append to ordered result */ + if ((error = bhnd_nvram_plist_append(*props, prop))) + goto failed; + + /* Remove from unordered list */ + bhnd_nvram_plist_remove(unordered, name); + } + + /* Any remaining variables are new, and should be appended to the + * end of the export list */ + prop = NULL; + while ((prop = bhnd_nvram_plist_next(unordered, prop)) != NULL) { + if ((error = bhnd_nvram_plist_append(*props, prop))) + goto failed; + } + + /* Export complete */ +finished: + BHND_NVSTORE_UNLOCK(sc); + + if (unordered != NULL) + bhnd_nvram_plist_release(unordered); + + return (0); + +failed: + BHND_NVSTORE_UNLOCK(sc); + + if (unordered != NULL) + bhnd_nvram_plist_release(unordered); + + if (options != NULL && *options != NULL) + bhnd_nvram_plist_release(*options); + + if (*props != NULL) + bhnd_nvram_plist_release(*props); + + return (error); +} + /** * Read an NVRAM variable. * Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_store.h ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_store.h Mon Dec 19 20:28:27 2016 (r310295) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_store.h Mon Dec 19 20:31:27 2016 (r310296) @@ -45,10 +45,24 @@ #include "bhnd_nvram_data.h" #include "bhnd_nvram_io.h" -#include "bhnd_nvram_value.h" struct bhnd_nvram_store; +/** + * NVRAM export flags. + */ +enum { + BHND_NVSTORE_EXPORT_CHILDREN = (1<<0), /**< Include all subpaths */ + BHND_NVSTORE_EXPORT_PRESERVE_DEVPATHS = (1<<1), /**< Preserve existing device path definitions (default) */ + BHND_NVSTORE_EXPORT_COMPACT_DEVPATHS = (1<<2), /**< Re-encode all device paths using compact syntax */ + BHND_NVSTORE_EXPORT_EXPAND_DEVPATHS = (1<<3), /**< Re-encode all device paths using non-compact syntax */ + BHND_NVSTORE_EXPORT_ALL_VARS = (1<<6|1<<7), /**< Include all variables (default) */ + BHND_NVSTORE_EXPORT_COMMITTED = (1<<6), /**< Include all committed changes */ + BHND_NVSTORE_EXPORT_UNCOMMITTED = (1<<7), /**< Include all uncommitted changes (not including deletions) */ + BHND_NVSTORE_EXPORT_DELETED = (1<<8), /**< Include all uncommitted deltions (as + properties of type BHND_NVRAM_TYPE_NULL) */ +}; + int bhnd_nvram_store_new(struct bhnd_nvram_store **store, struct bhnd_nvram_data *data); @@ -57,6 +71,10 @@ int bhnd_nvram_store_parse_new(struct bh void bhnd_nvram_store_free(struct bhnd_nvram_store *store); +int bhnd_nvram_store_export(struct bhnd_nvram_store *store, + const char *path, bhnd_nvram_data_class **cls, + bhnd_nvram_plist **props, bhnd_nvram_plist **options, + uint32_t flags); int bhnd_nvram_store_getvar(struct bhnd_nvram_store *sc, const char *name, void *outp, size_t *olen, bhnd_nvram_type otype); Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_store_subr.c ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_store_subr.c Mon Dec 19 20:28:27 2016 (r310295) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_store_subr.c Mon Dec 19 20:31:27 2016 (r310296) @@ -342,7 +342,7 @@ bhnd_nvstore_path_register_update(struct /* Determine whether the variable is currently defined in the * backing NVRAM data, and derive its full path-prefixed name */ nvram_committed = false; - cookiep = bhnd_nvstore_index_lookup(sc, path->index, name); + cookiep = bhnd_nvstore_path_data_lookup(sc, path, name); if (cookiep != NULL) { /* Variable is defined in the backing data */ nvram_committed = true; Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_storevar.h ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_storevar.h Mon Dec 19 20:28:27 2016 (r310295) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_storevar.h Mon Dec 19 20:31:27 2016 (r310296) @@ -271,6 +271,7 @@ struct bhnd_nvram_store { #endif struct bhnd_nvram_data *data; /**< backing data */ uint32_t data_caps; /**< data capability flags */ + bhnd_nvram_plist *data_opts; /**< data serialization options */ bhnd_nvstore_alias_list aliases[4]; /**< path alias hash table */ size_t num_aliases; /**< alias count */ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@freebsd.org Mon Dec 19 20:34:07 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2142FC88FC0; Mon, 19 Dec 2016 20:34:07 +0000 (UTC) (envelope-from landonf@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 B23AC16F9; Mon, 19 Dec 2016 20:34:06 +0000 (UTC) (envelope-from landonf@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBJKY6u5060696; Mon, 19 Dec 2016 20:34:06 GMT (envelope-from landonf@FreeBSD.org) Received: (from landonf@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBJKY52T060687; Mon, 19 Dec 2016 20:34:05 GMT (envelope-from landonf@FreeBSD.org) Message-Id: <201612192034.uBJKY52T060687@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: landonf set sender to landonf@FreeBSD.org using -f From: "Landon J. Fuller" Date: Mon, 19 Dec 2016 20:34:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310297 - in head/sys: conf dev/bhnd/nvram dev/bhnd/tools modules/bhnd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 20:34:07 -0000 Author: landonf Date: Mon Dec 19 20:34:05 2016 New Revision: 310297 URL: https://svnweb.freebsd.org/changeset/base/310297 Log: bhnd(4): NVRAM serialization support. This adds support for: - Serializing an bhnd_nvram_plist (as exported from bhnd_nvram_store, etc) to an arbitrary NVRAM data format. - Generating a serialized representation of the current NVRAM store's state suitable for writing back to flash, or re-encoding for upload to a FullMAC device. Approved by: adrian (mentor) Differential Revision: https://reviews.freebsd.org/D8762 Added: head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom_subr.c (contents, props changed) Modified: head/sys/conf/files head/sys/dev/bhnd/nvram/bhnd_nvram_data.c head/sys/dev/bhnd/nvram/bhnd_nvram_data.h head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcm.c head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcmraw.c head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcmreg.h head/sys/dev/bhnd/nvram/bhnd_nvram_data_btxt.c head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c head/sys/dev/bhnd/nvram/bhnd_nvram_data_spromvar.h head/sys/dev/bhnd/nvram/bhnd_nvram_data_tlv.c head/sys/dev/bhnd/nvram/bhnd_nvram_datavar.h head/sys/dev/bhnd/nvram/bhnd_nvram_private.h head/sys/dev/bhnd/nvram/bhnd_nvram_store.c head/sys/dev/bhnd/nvram/bhnd_nvram_store.h head/sys/dev/bhnd/tools/nvram_map_gen.awk head/sys/modules/bhnd/Makefile Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Mon Dec 19 20:31:27 2016 (r310296) +++ head/sys/conf/files Mon Dec 19 20:34:05 2016 (r310297) @@ -1236,6 +1236,7 @@ dev/bhnd/nvram/bhnd_nvram_data_bcm.c opt dev/bhnd/nvram/bhnd_nvram_data_bcmraw.c optional bhnd dev/bhnd/nvram/bhnd_nvram_data_btxt.c optional bhnd dev/bhnd/nvram/bhnd_nvram_data_sprom.c optional bhnd +dev/bhnd/nvram/bhnd_nvram_data_sprom_subr.c optional bhnd dev/bhnd/nvram/bhnd_nvram_data_tlv.c optional bhnd dev/bhnd/nvram/bhnd_nvram_if.m optional bhnd dev/bhnd/nvram/bhnd_nvram_io.c optional bhnd Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data.c ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_data.c Mon Dec 19 20:31:27 2016 (r310296) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_data.c Mon Dec 19 20:34:05 2016 (r310297) @@ -65,6 +65,54 @@ bhnd_nvram_data_class_desc(bhnd_nvram_da } /** + * Return the class-level capability flags (@see BHND_NVRAM_DATA_CAP_*) for + * of @p cls. + * + * @param cls The NVRAM class. + */ +uint32_t +bhnd_nvram_data_class_caps(bhnd_nvram_data_class *cls) +{ + return (cls->caps); +} + +/** + * Serialize all NVRAM properties in @p plist using @p cls's NVRAM data + * format, writing the result to @p outp. + * + * @param cls The NVRAM data class to be used to perform + * serialization. + * @param props The raw property values to be serialized to + * @p outp, in serialization order. + * @param options Serialization options for @p cls, or NULL. + * @param[out] outp On success, the serialed NVRAM data will be + * written to this buffer. This argment may be + * NULL if the value is not desired. + * @param[in,out] olen The capacity of @p buf. On success, will be set + * to the actual length of the serialized data. + * + * @retval 0 success + * + * @retval ENOMEM If @p outp is non-NULL and a buffer of @p olen is too + * small to hold the serialized data. + * @retval EINVAL If a property value required by @p cls is not found in + * @p plist. + * @retval EFTYPE If a property value in @p plist cannot be represented + * as the data type required by @p cls. + * @retval ERANGE If a property value in @p plist would would overflow + * (or underflow) the data type required by @p cls. + * @retval non-zero If serialization otherwise fails, a regular unix error + * code will be returned. + */ +int +bhnd_nvram_data_serialize(bhnd_nvram_data_class *cls, + bhnd_nvram_plist *props, bhnd_nvram_plist *options, void *outp, + size_t *olen) +{ + return (cls->op_serialize(cls, props, options, outp, olen)); +} + +/** * Probe to see if this NVRAM data class class supports the data mapped by the * given I/O context, returning a BHND_NVRAM_DATA_PROBE probe result. * @@ -293,51 +341,6 @@ bhnd_nvram_data_options(struct bhnd_nvra } /** - * Compute the size of the serialized form of @p nv. - * - * Serialization may be performed via bhnd_nvram_data_serialize(). - * - * @param nv The NVRAM data to be queried. - * @param[out] len On success, will be set to the computed size. - * - * @retval 0 success - * @retval non-zero if computing the serialized size otherwise fails, a - * regular unix error code will be returned. - */ -int -bhnd_nvram_data_size(struct bhnd_nvram_data *nv, size_t *len) -{ - return (nv->cls->op_size(nv, len)); -} - -/** - * Serialize the NVRAM data to @p buf, using the NVRAM data class' native - * format. - * - * The resulting serialization may be reparsed with @p nv's BHND NVRAM data - * class. - * - * @param nv The NVRAM data to be serialized. - * @param[out] buf On success, the serialed NVRAM data will be - * written to this buffer. This argment may be - * NULL if the value is not desired. - * @param[in,out] len The capacity of @p buf. On success, will be set - * to the actual length of the serialized data. - * - * @retval 0 success - * @retval ENOMEM If @p buf is non-NULL and a buffer of @p len is too - * small to hold the serialized data. - * @retval non-zero If serialization otherwise fails, a regular unix error - * code will be returned. - */ -int -bhnd_nvram_data_serialize(struct bhnd_nvram_data *nv, - void *buf, size_t *len) -{ - return (nv->cls->op_serialize(nv, buf, len)); -} - -/** * Return the capability flags (@see BHND_NVRAM_DATA_CAP_*) for @p nv. * * @param nv The NVRAM data to be queried. Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data.h ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_data.h Mon Dec 19 20:31:27 2016 (r310296) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_data.h Mon Dec 19 20:34:05 2016 (r310297) @@ -91,6 +91,11 @@ enum { }; const char *bhnd_nvram_data_class_desc(bhnd_nvram_data_class *cls); +uint32_t bhnd_nvram_data_class_caps(bhnd_nvram_data_class *cls); + +int bhnd_nvram_data_serialize(bhnd_nvram_data_class *cls, + bhnd_nvram_plist *props, bhnd_nvram_plist *options, + void *outp, size_t *olen); int bhnd_nvram_data_probe(bhnd_nvram_data_class *cls, struct bhnd_nvram_io *io); @@ -110,12 +115,6 @@ void bhnd_nvram_data_release(struct b bhnd_nvram_data_class *bhnd_nvram_data_get_class(struct bhnd_nvram_data *nv); size_t bhnd_nvram_data_count(struct bhnd_nvram_data *nv); -int bhnd_nvram_data_size(struct bhnd_nvram_data *nv, - size_t *size); - -int bhnd_nvram_data_serialize(struct bhnd_nvram_data *nv, - void *buf, size_t *len); - bhnd_nvram_plist *bhnd_nvram_data_options(struct bhnd_nvram_data *nv); uint32_t bhnd_nvram_data_caps(struct bhnd_nvram_data *nv); Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcm.c ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcm.c Mon Dec 19 20:31:27 2016 (r310296) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcm.c Mon Dec 19 20:34:05 2016 (r310297) @@ -129,7 +129,8 @@ struct bhnd_nvram_bcm { size_t count; /**< total variable count */ }; -BHND_NVRAM_DATA_CLASS_DEFN(bcm, "Broadcom", sizeof(struct bhnd_nvram_bcm)) +BHND_NVRAM_DATA_CLASS_DEFN(bcm, "Broadcom", BHND_NVRAM_DATA_CAP_DEVPATHS, + sizeof(struct bhnd_nvram_bcm)) static int bhnd_nvram_bcm_probe(struct bhnd_nvram_io *io) @@ -146,6 +147,190 @@ bhnd_nvram_bcm_probe(struct bhnd_nvram_i return (BHND_NVRAM_DATA_PROBE_DEFAULT); } +static int +bhnd_nvram_bcm_serialize(bhnd_nvram_data_class *cls, bhnd_nvram_plist *props, + bhnd_nvram_plist *options, void *outp, size_t *olen) +{ + struct bhnd_nvram_bcmhdr hdr; + bhnd_nvram_prop *prop; + size_t limit, nbytes; + uint32_t sdram_ncdl; + uint16_t sdram_init, sdram_cfg, sdram_refresh; + uint8_t bcm_ver, crc8; + int error; + + /* Determine output byte limit */ + if (outp != NULL) + limit = *olen; + else + limit = 0; + + /* Fetch required header variables */ +#define PROPS_GET_HDRVAR(_name, _dest, _type) do { \ + const char *name = BCM_NVRAM_ ## _name ## _VAR; \ + if (!bhnd_nvram_plist_contains(props, name)) { \ + BHND_NV_LOG("missing required property: %s\n", \ + name); \ + return (EFTYPE); \ + } \ + \ + error = bhnd_nvram_plist_get_encoded(props, name, \ + (_dest), sizeof(*(_dest)), \ + BHND_NVRAM_TYPE_ ##_type); \ + if (error) { \ + BHND_NV_LOG("error reading required header " \ + "%s property: %d\n", name, error); \ + return (EFTYPE); \ + } \ +} while (0) + + PROPS_GET_HDRVAR(SDRAM_NCDL, &sdram_ncdl, UINT32); + PROPS_GET_HDRVAR(CFG0_SDRAM_INIT, &sdram_init, UINT16); + PROPS_GET_HDRVAR(CFG1_SDRAM_CFG, &sdram_cfg, UINT16); + PROPS_GET_HDRVAR(CFG1_SDRAM_REFRESH, &sdram_refresh, UINT16); + +#undef PROPS_GET_HDRVAR + + /* Fetch BCM nvram version from options */ + if (options != NULL && + bhnd_nvram_plist_contains(options, BCM_NVRAM_ENCODE_OPT_VERSION)) + { + error = bhnd_nvram_plist_get_uint8(options, + BCM_NVRAM_ENCODE_OPT_VERSION, &bcm_ver); + if (error) { + BHND_NV_LOG("error reading %s uint8 option value: %d\n", + BCM_NVRAM_ENCODE_OPT_VERSION, error); + return (EINVAL); + } + } else { + bcm_ver = BCM_NVRAM_CFG0_VER_DEFAULT; + } + + /* Construct our header */ + hdr = (struct bhnd_nvram_bcmhdr) { + .magic = htole32(BCM_NVRAM_MAGIC), + .size = 0, + .cfg0 = 0, + .cfg1 = 0, + .sdram_ncdl = htole32(sdram_ncdl) + }; + + hdr.cfg0 = BCM_NVRAM_SET_BITS(hdr.cfg0, BCM_NVRAM_CFG0_CRC, 0x0); + hdr.cfg0 = BCM_NVRAM_SET_BITS(hdr.cfg0, BCM_NVRAM_CFG0_VER, bcm_ver); + hdr.cfg0 = BCM_NVRAM_SET_BITS(hdr.cfg0, BCM_NVRAM_CFG0_SDRAM_INIT, + htole16(sdram_init)); + + hdr.cfg1 = BCM_NVRAM_SET_BITS(hdr.cfg1, BCM_NVRAM_CFG1_SDRAM_CFG, + htole16(sdram_cfg)); + hdr.cfg1 = BCM_NVRAM_SET_BITS(hdr.cfg1, BCM_NVRAM_CFG1_SDRAM_REFRESH, + htole16(sdram_refresh)); + + /* Write the header */ + nbytes = sizeof(hdr); + if (limit >= nbytes) + memcpy(outp, &hdr, sizeof(hdr)); + + /* Write all properties */ + prop = NULL; + while ((prop = bhnd_nvram_plist_next(props, prop)) != NULL) { + const char *name; + char *p; + size_t prop_limit; + size_t name_len, value_len; + + if (outp == NULL || limit < nbytes) { + p = NULL; + prop_limit = 0; + } else { + p = ((char *)outp) + nbytes; + prop_limit = limit - nbytes; + } + + /* Fetch and write name + '=' to output */ + name = bhnd_nvram_prop_name(prop); + name_len = strlen(name) + 1; + + if (prop_limit > name_len) { + memcpy(p, name, name_len - 1); + p[name_len - 1] = '='; + + prop_limit -= name_len; + p += name_len; + } else { + prop_limit = 0; + p = NULL; + } + + /* Advance byte count */ + if (SIZE_MAX - nbytes < name_len) + return (EFTYPE); /* would overflow size_t */ + + nbytes += name_len; + + /* Attempt to write NUL-terminated value to output */ + value_len = prop_limit; + error = bhnd_nvram_prop_encode(prop, p, &value_len, + BHND_NVRAM_TYPE_STRING); + + /* If encoding failed for any reason other than ENOMEM (which + * we'll detect and report after encoding all properties), + * return immediately */ + if (error && error != ENOMEM) { + BHND_NV_LOG("error serializing %s to required type " + "%s: %d\n", name, + bhnd_nvram_type_name(BHND_NVRAM_TYPE_STRING), + error); + return (error); + } + + /* Advance byte count */ + if (SIZE_MAX - nbytes < value_len) + return (EFTYPE); /* would overflow size_t */ + + nbytes += value_len; + } + + /* Write terminating '\0' */ + if (limit > nbytes) + *((char *)outp + nbytes) = '\0'; + + if (nbytes == SIZE_MAX) + return (EFTYPE); /* would overflow size_t */ + else + nbytes++; + + /* Update header length; this must fit within the header's 32-bit size + * field */ + if (nbytes <= UINT32_MAX) { + hdr.size = (uint32_t)nbytes; + } else { + BHND_NV_LOG("size %zu exceeds maximum supported size of %u " + "bytes\n", nbytes, UINT32_MAX); + return (EFTYPE); + } + + /* Provide required length */ + *olen = nbytes; + if (limit < *olen) { + if (outp == NULL) + return (0); + + return (ENOMEM); + } + + /* Calculate the CRC value */ + BHND_NV_ASSERT(nbytes >= BCM_NVRAM_CRC_SKIP, ("invalid output size")); + crc8 = bhnd_nvram_crc8((uint8_t *)outp + BCM_NVRAM_CRC_SKIP, + nbytes - BCM_NVRAM_CRC_SKIP, BHND_NVRAM_CRC8_INITIAL); + + /* Update CRC and write the finalized header */ + BHND_NV_ASSERT(nbytes >= sizeof(hdr), ("invalid output size")); + hdr.cfg0 = BCM_NVRAM_SET_BITS(hdr.cfg0, BCM_NVRAM_CFG0_CRC, crc8); + memcpy(outp, &hdr, sizeof(hdr)); + + return (0); +} + /** * Initialize @p bcm with the provided NVRAM data mapped by @p src. * @@ -411,127 +596,6 @@ bhnd_nvram_bcm_options(struct bhnd_nvram return (bcm->opts); } -static int -bhnd_nvram_bcm_size(struct bhnd_nvram_data *nv, size_t *size) -{ - return (bhnd_nvram_bcm_serialize(nv, NULL, size)); -} - -static int -bhnd_nvram_bcm_serialize(struct bhnd_nvram_data *nv, void *buf, size_t *len) -{ - struct bhnd_nvram_bcm *bcm; - struct bhnd_nvram_bcmhdr hdr; - void *cookiep; - const char *name; - size_t nbytes, limit; - uint8_t crc; - int error; - - bcm = (struct bhnd_nvram_bcm *)nv; - nbytes = 0; - - /* Save the output buffer limit */ - if (buf == NULL) - limit = 0; - else - limit = *len; - - /* Reserve space for the NVRAM header */ - nbytes += sizeof(struct bhnd_nvram_bcmhdr); - - /* Write all variables to the output buffer */ - cookiep = NULL; - while ((name = bhnd_nvram_data_next(nv, &cookiep))) { - uint8_t *outp; - size_t olen; - size_t name_len, val_len; - - if (limit > nbytes) { - outp = (uint8_t *)buf + nbytes; - olen = limit - nbytes; - } else { - outp = NULL; - olen = 0; - } - - /* Determine length of variable name */ - name_len = strlen(name) + 1; - - /* Write the variable name and '=' delimiter */ - if (olen >= name_len) { - /* Copy name */ - memcpy(outp, name, name_len - 1); - - /* Append '=' */ - *(outp + name_len - 1) = '='; - } - - /* Adjust byte counts */ - if (SIZE_MAX - name_len < nbytes) - return (ERANGE); - - nbytes += name_len; - - /* Reposition output */ - if (limit > nbytes) { - outp = (uint8_t *)buf + nbytes; - olen = limit - nbytes; - } else { - outp = NULL; - olen = 0; - } - - /* Coerce to NUL-terminated C string, writing to the output - * buffer (or just calculating the length if outp is NULL) */ - val_len = olen; - error = bhnd_nvram_data_getvar(nv, cookiep, outp, &val_len, - BHND_NVRAM_TYPE_STRING); - - if (error && error != ENOMEM) - return (error); - - /* Adjust byte counts */ - if (SIZE_MAX - val_len < nbytes) - return (ERANGE); - - nbytes += val_len; - } - - /* Write terminating NUL */ - if (nbytes < limit) - *((uint8_t *)buf + nbytes) = '\0'; - nbytes++; - - /* Provide actual size */ - *len = nbytes; - if (buf == NULL || nbytes > limit) { - if (buf != NULL) - return (ENOMEM); - - return (0); - } - - /* Fetch current NVRAM header */ - if ((error = bhnd_nvram_io_read(bcm->data, 0x0, &hdr, sizeof(hdr)))) - return (error); - - /* Update values covered by CRC and write to output buffer */ - hdr.size = htole32(*len); - memcpy(buf, &hdr, sizeof(hdr)); - - /* Calculate new CRC */ - crc = bhnd_nvram_crc8((uint8_t *)buf + BCM_NVRAM_CRC_SKIP, - *len - BCM_NVRAM_CRC_SKIP, BHND_NVRAM_CRC8_INITIAL); - - /* Update header with valid CRC */ - hdr.cfg0 &= ~BCM_NVRAM_CFG0_CRC_MASK; - hdr.cfg0 |= (crc << BCM_NVRAM_CFG0_CRC_SHIFT); - memcpy(buf, &hdr, sizeof(hdr)); - - return (0); -} - static uint32_t bhnd_nvram_bcm_caps(struct bhnd_nvram_data *nv) { Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcmraw.c ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcmraw.c Mon Dec 19 20:31:27 2016 (r310296) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcmraw.c Mon Dec 19 20:34:05 2016 (r310297) @@ -72,7 +72,7 @@ struct bhnd_nvram_bcmraw { }; BHND_NVRAM_DATA_CLASS_DEFN(bcmraw, "Broadcom (RAW)", - sizeof(struct bhnd_nvram_bcmraw)) + BHND_NVRAM_DATA_CAP_DEVPATHS, sizeof(struct bhnd_nvram_bcmraw)) static int bhnd_nvram_bcmraw_probe(struct bhnd_nvram_io *io) @@ -132,6 +132,103 @@ bhnd_nvram_bcmraw_probe(struct bhnd_nvra return (BHND_NVRAM_DATA_PROBE_MAYBE + 1); } +static int +bhnd_nvram_bcmraw_serialize(bhnd_nvram_data_class *cls, bhnd_nvram_plist *props, + bhnd_nvram_plist *options, void *outp, size_t *olen) +{ + bhnd_nvram_prop *prop; + size_t limit, nbytes; + int error; + + /* Determine output byte limit */ + if (outp != NULL) + limit = *olen; + else + limit = 0; + + nbytes = 0; + + /* Write all properties */ + prop = NULL; + while ((prop = bhnd_nvram_plist_next(props, prop)) != NULL) { + const char *name; + char *p; + size_t prop_limit; + size_t name_len, value_len; + + if (outp == NULL || limit < nbytes) { + p = NULL; + prop_limit = 0; + } else { + p = ((char *)outp) + nbytes; + prop_limit = limit - nbytes; + } + + /* Fetch and write name + '=' to output */ + name = bhnd_nvram_prop_name(prop); + name_len = strlen(name) + 1; + + if (prop_limit > name_len) { + memcpy(p, name, name_len - 1); + p[name_len - 1] = '='; + + prop_limit -= name_len; + p += name_len; + } else { + prop_limit = 0; + p = NULL; + } + + /* Advance byte count */ + if (SIZE_MAX - nbytes < name_len) + return (EFTYPE); /* would overflow size_t */ + + nbytes += name_len; + + /* Attempt to write NUL-terminated value to output */ + value_len = prop_limit; + error = bhnd_nvram_prop_encode(prop, p, &value_len, + BHND_NVRAM_TYPE_STRING); + + /* If encoding failed for any reason other than ENOMEM (which + * we'll detect and report after encoding all properties), + * return immediately */ + if (error && error != ENOMEM) { + BHND_NV_LOG("error serializing %s to required type " + "%s: %d\n", name, + bhnd_nvram_type_name(BHND_NVRAM_TYPE_STRING), + error); + return (error); + } + + /* Advance byte count */ + if (SIZE_MAX - nbytes < value_len) + return (EFTYPE); /* would overflow size_t */ + + nbytes += value_len; + } + + /* Write terminating '\0' */ + if (limit > nbytes) + *((char *)outp + nbytes) = '\0'; + + if (nbytes == SIZE_MAX) + return (EFTYPE); /* would overflow size_t */ + else + nbytes++; + + /* Provide required length */ + *olen = nbytes; + if (limit < *olen) { + if (outp == NULL) + return (0); + + return (ENOMEM); + } + + return (0); +} + /** * Initialize @p bcm with the provided NVRAM data mapped by @p src. * @@ -249,85 +346,18 @@ bhnd_nvram_bcmraw_free(struct bhnd_nvram bhnd_nv_free(bcm->data); } -static size_t -bhnd_nvram_bcmraw_count(struct bhnd_nvram_data *nv) -{ - struct bhnd_nvram_bcmraw *bcm = (struct bhnd_nvram_bcmraw *)nv; - - return (bcm->count); -} - static bhnd_nvram_plist * bhnd_nvram_bcmraw_options(struct bhnd_nvram_data *nv) { return (NULL); } -static int -bhnd_nvram_bcmraw_size(struct bhnd_nvram_data *nv, size_t *size) -{ - return (bhnd_nvram_bcmraw_serialize(nv, NULL, size)); -} - -static int -bhnd_nvram_bcmraw_serialize(struct bhnd_nvram_data *nv, void *buf, size_t *len) +static size_t +bhnd_nvram_bcmraw_count(struct bhnd_nvram_data *nv) { - struct bhnd_nvram_bcmraw *bcm; - char * const p = (char *)buf; - size_t limit; - size_t offset; - - bcm = (struct bhnd_nvram_bcmraw *)nv; - - /* Save the output buffer limit */ - if (buf == NULL) - limit = 0; - else - limit = *len; - - /* The serialized form will be exactly the length - * of our backing buffer representation */ - *len = bcm->size; - - /* Skip serialization if not requested, or report ENOMEM if - * buffer is too small */ - if (buf == NULL) { - return (0); - } else if (*len > limit) { - return (ENOMEM); - } - - /* Write all variables to the output buffer */ - memcpy(buf, bcm->data, *len); - - /* Rewrite all '\0' delimiters back to '=' */ - offset = 0; - while (offset < bcm->size) { - size_t name_len, value_len; - - name_len = strlen(p + offset); - - /* EOF? */ - if (name_len == 0) { - BHND_NV_ASSERT(*(p + offset) == '\0', - ("no NUL terminator")); - - offset++; - break; - } - - /* Rewrite 'name\0' to 'name=' */ - offset += name_len; - BHND_NV_ASSERT(*(p + offset) == '\0', ("incorrect offset")); - - *(p + offset) = '='; - offset++; - - value_len = strlen(p + offset); - offset += value_len + 1; - } + struct bhnd_nvram_bcmraw *bcm = (struct bhnd_nvram_bcmraw *)nv; - return (0); + return (bcm->count); } static uint32_t Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcmreg.h ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcmreg.h Mon Dec 19 20:31:27 2016 (r310296) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcmreg.h Mon Dec 19 20:34:05 2016 (r310297) @@ -32,9 +32,13 @@ #ifndef _BHND_NVRAM_BHND_NVRAM_BCMREG_H_ #define _BHND_NVRAM_BHND_NVRAM_BCMREG_H_ -#define BCM_NVRAM_GET_BITS(_value, _field) \ +#define BCM_NVRAM_GET_BITS(_value, _field) \ ((_value & _field ## _MASK) >> _field ## _SHIFT) +#define BCM_NVRAM_SET_BITS(_value, _field, _bits) \ + ((_value & ~(_field ## _MASK)) | \ + (((_bits) << _field ## _SHIFT) & _field ## _MASK)) + /* BCM NVRAM header fields */ #define BCM_NVRAM_MAGIC 0x48534C46 /* 'FLSH' */ #define BCM_NVRAM_VERSION 1 @@ -45,6 +49,7 @@ #define BCM_NVRAM_CFG0_CRC_SHIFT 0 #define BCM_NVRAM_CFG0_VER_MASK 0x0000FF00 #define BCM_NVRAM_CFG0_VER_SHIFT 8 +#define BCM_NVRAM_CFG0_VER_DEFAULT 1 /* default version */ #define BCM_NVRAM_CFG0_SDRAM_INIT_FIELD cfg0 #define BCM_NVRAM_CFG0_SDRAM_INIT_MASK 0xFFFF0000 Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data_btxt.c ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_data_btxt.c Mon Dec 19 20:31:27 2016 (r310296) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_data_btxt.c Mon Dec 19 20:34:05 2016 (r310297) @@ -69,7 +69,7 @@ struct bhnd_nvram_btxt { }; BHND_NVRAM_DATA_CLASS_DEFN(btxt, "Broadcom Board Text", - sizeof(struct bhnd_nvram_btxt)) + BHND_NVRAM_DATA_CAP_DEVPATHS, sizeof(struct bhnd_nvram_btxt)) /** Minimal identification header */ union bhnd_nvram_btxt_ident { @@ -124,6 +124,100 @@ bhnd_nvram_btxt_probe(struct bhnd_nvram_ return (BHND_NVRAM_DATA_PROBE_MAYBE); } +static int +bhnd_nvram_btxt_serialize(bhnd_nvram_data_class *cls, bhnd_nvram_plist *props, + bhnd_nvram_plist *options, void *outp, size_t *olen) +{ + bhnd_nvram_prop *prop; + size_t limit, nbytes; + int error; + + /* Determine output byte limit */ + if (outp != NULL) + limit = *olen; + else + limit = 0; + + nbytes = 0; + + /* Write all properties */ + prop = NULL; + while ((prop = bhnd_nvram_plist_next(props, prop)) != NULL) { + const char *name; + char *p; + size_t prop_limit; + size_t name_len, value_len; + + if (outp == NULL || limit < nbytes) { + p = NULL; + prop_limit = 0; + } else { + p = ((char *)outp) + nbytes; + prop_limit = limit - nbytes; + } + + /* Fetch and write 'name=' to output */ + name = bhnd_nvram_prop_name(prop); + name_len = strlen(name) + 1; + + if (prop_limit > name_len) { + memcpy(p, name, name_len - 1); + p[name_len - 1] = '='; + + prop_limit -= name_len; + p += name_len; + } else { + prop_limit = 0; + p = NULL; + } + + /* Advance byte count */ + if (SIZE_MAX - nbytes < name_len) + return (EFTYPE); /* would overflow size_t */ + + nbytes += name_len; + + /* Write NUL-terminated value to output, rewrite NUL as + * '\n' record delimiter */ + value_len = prop_limit; + error = bhnd_nvram_prop_encode(prop, p, &value_len, + BHND_NVRAM_TYPE_STRING); + if (p != NULL && error == 0) { + /* Replace trailing '\0' with newline */ + BHND_NV_ASSERT(value_len > 0, ("string length missing " + "minimum required trailing NUL")); + + *(p + (value_len - 1)) = '\n'; + } else if (error && error != ENOMEM) { + /* If encoding failed for any reason other than ENOMEM + * (which we'll detect and report after encoding all + * properties), return immediately */ + BHND_NV_LOG("error serializing %s to required type " + "%s: %d\n", name, + bhnd_nvram_type_name(BHND_NVRAM_TYPE_STRING), + error); + return (error); + } + + /* Advance byte count */ + if (SIZE_MAX - nbytes < value_len) + return (EFTYPE); /* would overflow size_t */ + + nbytes += value_len; + } + + /* Provide required length */ + *olen = nbytes; + if (limit < *olen) { + if (outp == NULL) + return (0); + + return (ENOMEM); + } + + return (0); +} + /** * Initialize @p btxt with the provided board text data mapped by @p src. * @@ -261,52 +355,6 @@ bhnd_nvram_btxt_options(struct bhnd_nvra return (NULL); } -static int -bhnd_nvram_btxt_size(struct bhnd_nvram_data *nv, size_t *size) -{ - struct bhnd_nvram_btxt *btxt = (struct bhnd_nvram_btxt *)nv; - - /* The serialized form will be identical in length - * to our backing buffer representation */ - *size = bhnd_nvram_io_getsize(btxt->data); - return (0); -} - -static int -bhnd_nvram_btxt_serialize(struct bhnd_nvram_data *nv, void *buf, size_t *len) -{ - struct bhnd_nvram_btxt *btxt; - size_t limit; - int error; - - btxt = (struct bhnd_nvram_btxt *)nv; - - limit = *len; - - /* Provide actual output size */ - if ((error = bhnd_nvram_data_size(nv, len))) - return (error); - - if (buf == NULL) { - return (0); - } else if (limit < *len) { - return (ENOMEM); - } - - /* Copy our internal representation to the output buffer */ - if ((error = bhnd_nvram_io_read(btxt->data, 0x0, buf, *len))) - return (error); - - /* Restore the original key=value format, rewriting all '\0' - * key\0value delimiters back to '=' */ - for (char *p = buf; (size_t)(p - (char *)buf) < *len; p++) { - if (*p == '\0') - *p = '='; - } - - return (0); -} - static uint32_t bhnd_nvram_btxt_caps(struct bhnd_nvram_data *nv) { Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c Mon Dec 19 20:31:27 2016 (r310296) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c Mon Dec 19 20:34:05 2016 (r310297) @@ -49,8 +49,9 @@ __FBSDID("$FreeBSD$"); #include #endif /* _KERNEL */ -#include "bhnd_nvram_private.h" +#include "bhnd_nvram_map.h" +#include "bhnd_nvram_private.h" #include "bhnd_nvram_datavar.h" #include "bhnd_nvram_data_spromvar.h" @@ -62,44 +63,45 @@ __FBSDID("$FreeBSD$"); * used on Broadcom wireless and wired adapters, that provides a subset of the * variables defined by Broadcom SoC NVRAM formats. */ -BHND_NVRAM_DATA_CLASS_DEFN(sprom, "Broadcom SPROM", - sizeof(struct bhnd_nvram_sprom)) -static int sprom_sort_idx(const void *lhs, const void *rhs); +static const bhnd_sprom_layout *bhnd_nvram_sprom_get_layout(uint8_t sromrev); + +static int bhnd_nvram_sprom_ident( + struct bhnd_nvram_io *io, + const bhnd_sprom_layout **ident, + struct bhnd_nvram_io **shadow); + +static int bhnd_nvram_sprom_write_var( + bhnd_sprom_opcode_state *state, + bhnd_sprom_opcode_idx_entry *entry, + bhnd_nvram_val *value, + struct bhnd_nvram_io *io); + +static int bhnd_nvram_sprom_write_offset( + const struct bhnd_nvram_vardefn *var, + struct bhnd_nvram_io *data, + bhnd_nvram_type type, size_t offset, + uint32_t mask, int8_t shift, + uint32_t value); + +static int bhnd_nvram_sprom_read_offset( + const struct bhnd_nvram_vardefn *var, + struct bhnd_nvram_io *data, + bhnd_nvram_type type, size_t offset, + uint32_t mask, int8_t shift, + uint32_t *value); -static int sprom_opcode_state_init(struct sprom_opcode_state *state, - const struct bhnd_sprom_layout *layout); -static int sprom_opcode_state_reset(struct sprom_opcode_state *state); -static int sprom_opcode_state_seek(struct sprom_opcode_state *state, - struct sprom_opcode_idx *indexed); - -static int sprom_opcode_next_var(struct sprom_opcode_state *state); -static int sprom_opcode_parse_var(struct sprom_opcode_state *state, - struct sprom_opcode_idx *indexed); - -static int sprom_opcode_next_binding(struct sprom_opcode_state *state); - -static int sprom_opcode_set_type(struct sprom_opcode_state *state, - bhnd_nvram_type type); - -static int sprom_opcode_set_var(struct sprom_opcode_state *state, - size_t vid); -static int sprom_opcode_clear_var(struct sprom_opcode_state *state); -static int sprom_opcode_flush_bind(struct sprom_opcode_state *state); -static int sprom_opcode_read_opval32(struct sprom_opcode_state *state, - uint8_t type, uint32_t *opval); -static int sprom_opcode_apply_scale(struct sprom_opcode_state *state, - uint32_t *value); - -static int sprom_opcode_step(struct sprom_opcode_state *state, - uint8_t *opcode); - -#define SPROM_OP_BAD(_state, _fmt, ...) \ - BHND_NV_LOG("bad encoding at %td: " _fmt, \ - (_state)->input - (_state)->layout->bindings, ##__VA_ARGS__) +static bool bhnd_sprom_is_external_immutable( + const char *name); -#define SPROM_COOKIE_TO_NVRAM(_cookie) \ - bhnd_nvram_get_vardefn(((struct sprom_opcode_idx *)_cookie)->vid) +BHND_NVRAM_DATA_CLASS_DEFN(sprom, "Broadcom SPROM", + BHND_NVRAM_DATA_CAP_DEVPATHS, sizeof(struct bhnd_nvram_sprom)) + +#define SPROM_COOKIE_TO_VID(_cookie) \ + (((struct bhnd_sprom_opcode_idx_entry *)(_cookie))->vid) + +#define SPROM_COOKIE_TO_NVRAM_VAR(_cookie) \ + bhnd_nvram_get_vardefn(SPROM_COOKIE_TO_VID(_cookie)) /** * Read the magic value from @p io, and verify that it matches @@ -118,7 +120,7 @@ static int sprom_opcode_step(struct spro */ static int bhnd_nvram_sprom_check_magic(struct bhnd_nvram_io *io, - const struct bhnd_sprom_layout *layout, uint16_t *magic) + const bhnd_sprom_layout *layout, uint16_t *magic) { int error; @@ -162,7 +164,7 @@ bhnd_nvram_sprom_check_magic(struct bhnd */ static int bhnd_nvram_sprom_ident(struct bhnd_nvram_io *io, - const struct bhnd_sprom_layout **ident, struct bhnd_nvram_io **shadow) + const bhnd_sprom_layout **ident, struct bhnd_nvram_io **shadow) { struct bhnd_nvram_io *buf; uint8_t crc; @@ -185,13 +187,13 @@ bhnd_nvram_sprom_ident(struct bhnd_nvram /* We iterate the SPROM layouts smallest to largest, allowing us to * perform incremental checksum calculation */ for (size_t i = 0; i < bhnd_sprom_num_layouts; i++) { - const struct bhnd_sprom_layout *layout; - void *ptr; - size_t nbytes, nr; - uint16_t magic; - uint8_t srev; - bool crc_valid; - bool have_magic; + const bhnd_sprom_layout *layout; + void *ptr; + size_t nbytes, nr; + uint16_t magic; + uint8_t srev; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@freebsd.org Mon Dec 19 20:37:31 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 78370C880AE; Mon, 19 Dec 2016 20:37:31 +0000 (UTC) (envelope-from rpokala@mac.com) Received: from mr11p00im-asmtp002.me.com (mr11p00im-asmtp002.me.com [17.110.69.253]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 59F6018EE; Mon, 19 Dec 2016 20:37:31 +0000 (UTC) (envelope-from rpokala@mac.com) Received: from process-dkim-sign-daemon.mr11p00im-asmtp002.me.com by mr11p00im-asmtp002.me.com (Oracle Communications Messaging Server 7.0.5.38.0 64bit (built Feb 26 2016)) id <0OIG003008O33O00@mr11p00im-asmtp002.me.com>; Mon, 19 Dec 2016 20:37:25 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mac.com; s=4d515a; t=1482179845; bh=FwV5vsw81ZWur8RlonKYHLZMbxfOHoFRL23cvRJxKfk=; h=Date:Subject:From:To:Message-id:MIME-version:Content-type; b=sWeroYH2Db+8PQcEOb5uMzEB1zIFBsRbC+G9MwxTPPhHnQNH/lq8bFBdW8eEu+Jxr e9Ec7Xl+b9BYFQNKQsLCkjmlQIZNLOaCuKWxaTezOBRVLFS5IPwHvPs0ESWIkEZgtu zrTsW5IE4QC7nPdkxr/NnmzGtQOMuEI4hBqy6gMYp5AEuyT6axXKG8cHuiGL9RAmG7 aPBhsQAuP6tPdaBLg+ubmac8r4ozGVC73IeA1uxFZJXjo1QtTYxc0FE7/XnBFJSMqM 694E+BaKNVdnY+GzPp8aSlblWJoHTTuQZSuG6mvuZiS3ZSy+xSuN+JYFS444NcD4Fy 11xRX8+vluclw== Received: from [172.17.133.77] (dip-cali.panasas.com [64.80.217.3]) by mr11p00im-asmtp002.me.com (Oracle Communications Messaging Server 7.0.5.38.0 64bit (built Feb 26 2016)) with ESMTPSA id <0OIG00ET89ABKI10@mr11p00im-asmtp002.me.com>; Mon, 19 Dec 2016 20:37:25 +0000 (GMT) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-12-19_14:,, signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 clxscore=1034 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1603290000 definitions=main-1612190230 User-Agent: Microsoft-MacOutlook/f.1d.0.161209 Date: Mon, 19 Dec 2016 12:37:27 -0800 Subject: Re: svn commit: r310171 - head/sys/sys From: Ravi Pokala Sender: "Pokala, Ravi" To: Ian Lepore , Warner Losh Cc: Sepherosa Ziehau , Dimitry Andric , src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Message-id: Thread-topic: svn commit: r310171 - head/sys/sys References: <201612161949.uBGJnMol059217@repo.freebsd.org> <9BD5034F-55A6-48F6-A391-A0877FF49702@panasas.com> <1482175209.48539.9.camel@freebsd.org> In-reply-to: <1482175209.48539.9.camel@freebsd.org> MIME-version: 1.0 Content-type: text/plain; charset=UTF-8 Content-transfer-encoding: 7bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 20:37:31 -0000 -----Original Message----- > From: on behalf of Ian Lepore > Date: 2016-12-19, Monday at 11:20 > To: Warner Losh , Ravi Pokala > Cc: Sepherosa Ziehau , Dimitry Andric , src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" > Subject: Re: svn commit: r310171 - head/sys/sys > > On Mon, 2016-12-19 at 11:58 -0700, Warner Losh wrote: >> >> ... >> >> Are there other precedence for avoiding the SCN macros in the tree as >> well, or is this new art? >> >> Warner > > There was another commit recently the fixed the same kind of scanf > error by making the variable fit the scanf type (changing uint64_t to > an explicit long long unsigned, iirc). I don't know if that alone > counts as a precedent, but IMO it's a more palatible fix than the > SCN/PRI ugliness. With all apologies to Churchill, SCN/PRI are the worst way to address this in a machine-independent way, except for all the other ways that have been tried from time to time. :-P -Ravi (rpokala@) > -- Ian From owner-svn-src-head@freebsd.org Mon Dec 19 21:27:19 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 965D7C88169; Mon, 19 Dec 2016 21:27:19 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 6530415AF; Mon, 19 Dec 2016 21:27:19 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBJLRIDQ080684; Mon, 19 Dec 2016 21:27:18 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBJLRIcj080683; Mon, 19 Dec 2016 21:27:18 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201612192127.uBJLRIcj080683@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Mon, 19 Dec 2016 21:27:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310298 - head/sys/cam/ctl X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 21:27:19 -0000 Author: mav Date: Mon Dec 19 21:27:18 2016 New Revision: 310298 URL: https://svnweb.freebsd.org/changeset/base/310298 Log: Improve error handling when I/O split between several BIOs. If we get several error codes, handle one with lowest offset. MFC after: 2 weeks Modified: head/sys/cam/ctl/ctl_backend_block.c Modified: head/sys/cam/ctl/ctl_backend_block.c ============================================================================== --- head/sys/cam/ctl/ctl_backend_block.c Mon Dec 19 20:34:05 2016 (r310297) +++ head/sys/cam/ctl/ctl_backend_block.c Mon Dec 19 21:27:18 2016 (r310298) @@ -201,7 +201,8 @@ struct ctl_be_block_io { int num_bios_sent; int num_bios_done; int send_complete; - int num_errors; + int first_error; + uint64_t first_error_offset; struct bintime ds_t0; devstat_tag_type ds_tag_type; devstat_trans_flags ds_trans_type; @@ -486,8 +487,12 @@ ctl_be_block_biodone(struct bio *bio) error = bio->bio_error; mtx_lock(&be_lun->io_lock); - if (error != 0) - beio->num_errors++; + if (error != 0 && + (beio->first_error == 0 || + bio->bio_offset < beio->first_error_offset)) { + beio->first_error = error; + beio->first_error_offset = bio->bio_offset; + } beio->num_bios_done++; @@ -520,7 +525,8 @@ ctl_be_block_biodone(struct bio *bio) * If there are any errors from the backing device, we fail the * entire I/O with a medium error. */ - if (beio->num_errors > 0) { + error = beio->first_error; + if (error != 0) { if (error == EOPNOTSUPP) { ctl_set_invalid_opcode(&io->scsiio); } else if (error == ENOSPC || error == EDQUOT) { From owner-svn-src-head@freebsd.org Mon Dec 19 22:18:37 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A73E3C88441; Mon, 19 Dec 2016 22:18:37 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 5D2341771; Mon, 19 Dec 2016 22:18:37 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBJMIacY001228; Mon, 19 Dec 2016 22:18:36 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBJMIa1p001227; Mon, 19 Dec 2016 22:18:36 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201612192218.uBJMIa1p001227@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 19 Dec 2016 22:18:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310302 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 22:18:37 -0000 Author: kib Date: Mon Dec 19 22:18:36 2016 New Revision: 310302 URL: https://svnweb.freebsd.org/changeset/base/310302 Log: Do not clear KN_INFLUX when not owning influx state. For notes in KN_INFLUX|KN_SCAN state, the influx bit is set by a parallel scan. When knote() reports event for the vnode filters, which require kqueue unlocked, it unconditionally sets and then clears influx to keep note around kqueue unlock. There, do not clear influx flag if a scan set it, since we do not own it, instead we prevent scan from executing by holding knlist lock. The knote_fork() function has somewhat similar problem, it might set KN_INFLUX for scanned note, drop kqueue and list locks, and then clear the flag after relock. A solution there would be different enough, as well as the test program, so close the reported issue first. Reported and test case provided by: yjh0502@gmail.com PR: 214923 Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Modified: head/sys/kern/kern_event.c Modified: head/sys/kern/kern_event.c ============================================================================== --- head/sys/kern/kern_event.c Mon Dec 19 22:15:29 2016 (r310301) +++ head/sys/kern/kern_event.c Mon Dec 19 22:18:36 2016 (r310302) @@ -2006,6 +2006,7 @@ knote(struct knlist *list, long hint, in struct kqueue *kq; struct knote *kn, *tkn; int error; + bool own_influx; if (list == NULL) return; @@ -2036,11 +2037,14 @@ knote(struct knlist *list, long hint, in */ KQ_UNLOCK(kq); } else if ((lockflags & KNF_NOKQLOCK) != 0) { - kn->kn_status |= KN_INFLUX; + own_influx = (kn->kn_status & KN_INFLUX) == 0; + if (own_influx) + kn->kn_status |= KN_INFLUX; KQ_UNLOCK(kq); error = kn->kn_fop->f_event(kn, hint); KQ_LOCK(kq); - kn->kn_status &= ~KN_INFLUX; + if (own_influx) + kn->kn_status &= ~KN_INFLUX; if (error) KNOTE_ACTIVATE(kn, 1); KQ_UNLOCK_FLUX(kq); From owner-svn-src-head@freebsd.org Mon Dec 19 22:23:11 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D5E2EC88700; Mon, 19 Dec 2016 22:23:11 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: from mail-wj0-x241.google.com (mail-wj0-x241.google.com [IPv6:2a00:1450:400c:c01::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7E3FA1D74; Mon, 19 Dec 2016 22:23:11 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: by mail-wj0-x241.google.com with SMTP id xy5so25386084wjc.1; Mon, 19 Dec 2016 14:23:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=aR7oBwbyESPZtWFsR0tE7gQpYXZ2YRLi0yd7bAV6R9c=; b=j9HsmKNyZKzW0CskXSZjsKAi9njWwKCJfjYSvzz6g5b2o99HDTgoBiR6/ODGyUBH3D 9nGRzvPkkNOg9itdRAd3WnaQKW9QXCwvwAeYQi6+TC0Cycy/6d0xyc6dCuKKIolgiX82 DPPwTMvIlUYe16kq5n+y9HArSfxO7byKul3C0/Vt7KdUupUeKzFethEJ9Pgivl3YWrKZ zhMaVwIRXmr44eeM3ML12uu5tAilyOO0+FZEIB7tabn/BL2TSgQOWhmkSrNWsCXBr2j5 f2RWb+5KjhmwZeyGwAKEofPRYotyzECwHwPsKSV6zbl+8xt/flwLrNc7qxfEsZnwd7zA Szzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=aR7oBwbyESPZtWFsR0tE7gQpYXZ2YRLi0yd7bAV6R9c=; b=PSPe8EW/255o8XOu8bx4+n+hELkmF7JP4qU2vb7LdFPalNFqEfjk9MO9D5t21lxmOj jV6QH/h9hHHbXJjxQxxHtJubF6Vsc/ZLHPRtjYC55DlTC242JR86BWAQUua2oTdKQkSl JQo05c/PFzmNQmrUMDYFNiFraNikGX2bqOOB51WXTxSwCGiqehd8vSOCpB4m5J87egFK KnPPqoskqUD1KTNLfoF5eNj+NbVDyc4c3mii9xBk97Ue5Num+QbzdRR7lvqkvYEChmAX bKxU6ek44pldHotWAnB16viSzQZmRn7BSPIeSbRCaWR1wpi9pxZp7JdpzIyIDoGaQXih EzSw== X-Gm-Message-State: AIkVDXKi1TOFhPytSzEDgUE/797Yy1YE5KSEd3SAbiHHfcwFRlWpipd72WXTJGxizHcVoCCcRVtQczsQKeeOCw== X-Received: by 10.194.201.133 with SMTP id ka5mr17218670wjc.151.1482186189756; Mon, 19 Dec 2016 14:23:09 -0800 (PST) MIME-Version: 1.0 Received: by 10.194.44.1 with HTTP; Mon, 19 Dec 2016 14:23:08 -0800 (PST) In-Reply-To: <49460793.UcUNovQMDa@ralph.baldwin.cx> References: <201612160144.uBG1ipjW016736@repo.freebsd.org> <49460793.UcUNovQMDa@ralph.baldwin.cx> From: Adrian Chadd Date: Mon, 19 Dec 2016 14:23:08 -0800 Message-ID: Subject: Re: svn commit: r310138 - head/lib/libc/stdio To: John Baldwin Cc: Eric van Gyzen , Warner Losh , Dimitry Andric , Baptiste Daroussin , "Conrad E. Meyer" , src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 22:23:11 -0000 [snip] tl;dr - can we revert it from stdio for now so we don't end up having people use this? -adrian From owner-svn-src-head@freebsd.org Mon Dec 19 23:38:10 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 50DB9C88AEA; Mon, 19 Dec 2016 23:38:10 +0000 (UTC) (envelope-from sjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 C68B51E9F; Mon, 19 Dec 2016 23:38:09 +0000 (UTC) (envelope-from sjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBJNc9dE034933; Mon, 19 Dec 2016 23:38:09 GMT (envelope-from sjg@FreeBSD.org) Received: (from sjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBJNc7Rs034916; Mon, 19 Dec 2016 23:38:07 GMT (envelope-from sjg@FreeBSD.org) Message-Id: <201612192338.uBJNc7Rs034916@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sjg set sender to sjg@FreeBSD.org using -f From: "Simon J. Gerraty" Date: Mon, 19 Dec 2016 23:38:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310304 - in head: contrib/bmake contrib/bmake/mk usr.bin/bmake X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 19 Dec 2016 23:38:10 -0000 Author: sjg Date: Mon Dec 19 23:38:07 2016 New Revision: 310304 URL: https://svnweb.freebsd.org/changeset/base/310304 Log: Merge bmake-20161212 Added: head/contrib/bmake/mk/sys.debug.mk - copied unchanged from r310300, vendor/NetBSD/bmake/dist/mk/sys.debug.mk head/contrib/bmake/mk/sys.vars.mk - copied unchanged from r310300, vendor/NetBSD/bmake/dist/mk/sys.vars.mk Modified: head/contrib/bmake/ChangeLog head/contrib/bmake/Makefile head/contrib/bmake/bmake.1 head/contrib/bmake/bmake.cat1 head/contrib/bmake/compat.c head/contrib/bmake/job.c head/contrib/bmake/main.c head/contrib/bmake/make.1 head/contrib/bmake/make.c head/contrib/bmake/make.h head/contrib/bmake/mk/ChangeLog head/contrib/bmake/mk/FILES head/contrib/bmake/mk/dirdeps.mk head/contrib/bmake/mk/gendirdeps.mk head/contrib/bmake/mk/install-mk head/contrib/bmake/mk/lib.mk head/contrib/bmake/mk/meta.stage.mk head/contrib/bmake/mk/meta.sys.mk head/contrib/bmake/mk/meta2deps.py head/contrib/bmake/mk/meta2deps.sh head/contrib/bmake/mk/sys.mk head/contrib/bmake/nonints.h head/contrib/bmake/parse.c head/usr.bin/bmake/Makefile Directory Properties: head/contrib/bmake/ (props changed) Modified: head/contrib/bmake/ChangeLog ============================================================================== --- head/contrib/bmake/ChangeLog Mon Dec 19 22:28:28 2016 (r310303) +++ head/contrib/bmake/ChangeLog Mon Dec 19 23:38:07 2016 (r310304) @@ -1,3 +1,32 @@ +2016-12-12 Simon J. Gerraty + + * Makefile (_MAKE_VERSION): 20161212 + Merge with NetBSD make, pick up + o main.c: look for obj.${MACHINE}-${MACHINE_ARCH} too. + +2016-12-09 Simon J. Gerraty + + * Makefile (_MAKE_VERSION): 20161209 + Merge with NetBSD make, pick up + o main.c: cleanup setting of .OBJDIR + o parse.c: avoid coredump from (var)=val + +2016-11-26 Simon J. Gerraty + + * Makefile (_MAKE_VERSION): 20161126 + Merge with NetBSD make, pick up + o make.c: Make_OODate: report src node name if path not set + +2016-09-26 Simon J. Gerraty + + * Makefile (_MAKE_VERSION): 20160926 + Merge with NetBSD make, pick up + o support for .DELETE_ON_ERROR: (remove targets that fail) + +2016-09-26 Simon J. Gerraty + + * Makefile MAN: tweak .Dt to match ${PROG} + 2016-08-18 Simon J. Gerraty * Makefile (_MAKE_VERSION): 20160818 Modified: head/contrib/bmake/Makefile ============================================================================== --- head/contrib/bmake/Makefile Mon Dec 19 22:28:28 2016 (r310303) +++ head/contrib/bmake/Makefile Mon Dec 19 23:38:07 2016 (r310304) @@ -1,7 +1,7 @@ -# $Id: Makefile,v 1.72 2016/08/18 23:02:26 sjg Exp $ +# $Id: Makefile,v 1.77 2016/12/12 07:34:19 sjg Exp $ # Base version on src date -_MAKE_VERSION= 20160818 +_MAKE_VERSION= 20161212 PROG= bmake @@ -156,7 +156,10 @@ my.history: ${MAKEFILE} .NOPATH: ${MAN} ${MAN}: make.1 my.history @echo making $@ - @sed -e 's/^.Nx/NetBSD/' -e '/^.Nm/s/make/${PROG}/' \ + @sed \ + -e '/^.Dt/s/MAKE/${PROG:tu}/' \ + -e 's/^.Nx/NetBSD/' \ + -e '/^.Nm/s/make/${PROG}/' \ -e '/^.Sh HISTORY/rmy.history' \ -e '/^.Sh HISTORY/,$$s,^.Nm,make,' ${srcdir}/make.1 > $@ Modified: head/contrib/bmake/bmake.1 ============================================================================== --- head/contrib/bmake/bmake.1 Mon Dec 19 22:28:28 2016 (r310303) +++ head/contrib/bmake/bmake.1 Mon Dec 19 23:38:07 2016 (r310304) @@ -1,4 +1,4 @@ -.\" $NetBSD: make.1,v 1.262 2016/08/18 19:23:20 wiz Exp $ +.\" $NetBSD: make.1,v 1.263 2016/08/26 23:37:54 dholland Exp $ .\" .\" Copyright (c) 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,8 +29,8 @@ .\" .\" from: @(#)make.1 8.4 (Berkeley) 3/19/94 .\" -.Dd August 15, 2016 -.Dt MAKE 1 +.Dd August 26, 2016 +.Dt BMAKE 1 .Os .Sh NAME .Nm bmake @@ -2011,6 +2011,14 @@ variable of a target that inherits .Ic .DEFAULT Ns 's commands is set to the target's own name. +.It Ic .DELETE_ON_ERROR +If this target is present in the makefile, it globally causes make to +delete targets whose commands fail. +(By default, only targets whose commands are interrupted during +execution are deleted. +This is the historical behavior.) +This setting can be used to help prevent half-finished or malformed +targets from being left around and corrupting future rebuilds. .It Ic .END Any command lines attached to this target are executed after everything else is done. Modified: head/contrib/bmake/bmake.cat1 ============================================================================== --- head/contrib/bmake/bmake.cat1 Mon Dec 19 22:28:28 2016 (r310303) +++ head/contrib/bmake/bmake.cat1 Mon Dec 19 23:38:07 2016 (r310304) @@ -1,4 +1,4 @@ -MAKE(1) NetBSD General Commands Manual MAKE(1) +BMAKE(1) NetBSD General Commands Manual BMAKE(1) NNAAMMEE bbmmaakkee -- maintain program dependencies @@ -1285,6 +1285,14 @@ SSPPEECCIIAALL TTAARRGGEETT target that inherits ..DDEEFFAAUULLTT's commands is set to the target's own name. + ..DDEELLEETTEE__OONN__EERRRROORR + If this target is present in the makefile, it globally causes + make to delete targets whose commands fail. (By default, only + targets whose commands are interrupted during execution are + deleted. This is the historical behavior.) This setting can be + used to help prevent half-finished or malformed targets from + being left around and corrupting future rebuilds. + ..EENNDD Any command lines attached to this target are executed after everything else is done. @@ -1498,4 +1506,4 @@ BBUUGGSS There is no way of escaping a space character in a filename. -NetBSD 5.1 August 15, 2016 NetBSD 5.1 +NetBSD 5.1 August 26, 2016 NetBSD 5.1 Modified: head/contrib/bmake/compat.c ============================================================================== --- head/contrib/bmake/compat.c Mon Dec 19 22:28:28 2016 (r310303) +++ head/contrib/bmake/compat.c Mon Dec 19 23:38:07 2016 (r310304) @@ -1,4 +1,4 @@ -/* $NetBSD: compat.c,v 1.105 2016/05/12 20:28:34 sjg Exp $ */ +/* $NetBSD: compat.c,v 1.106 2016/08/26 23:28:39 dholland Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -70,14 +70,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: compat.c,v 1.105 2016/05/12 20:28:34 sjg Exp $"; +static char rcsid[] = "$NetBSD: compat.c,v 1.106 2016/08/26 23:28:39 dholland Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: compat.c,v 1.105 2016/05/12 20:28:34 sjg Exp $"); +__RCSID("$NetBSD: compat.c,v 1.106 2016/08/26 23:28:39 dholland Exp $"); #endif #endif /* not lint */ #endif @@ -119,6 +119,25 @@ static GNode *curTarg = NULL; static GNode *ENDNode; static void CompatInterrupt(int); +/* + * CompatDeleteTarget -- delete a failed, interrupted, or otherwise + * duffed target if not inhibited by .PRECIOUS. + */ +static void +CompatDeleteTarget(GNode *gn) +{ + if ((gn != NULL) && !Targ_Precious (gn)) { + char *p1; + char *file = Var_Value(TARGET, gn, &p1); + + if (!noExecute && eunlink(file) != -1) { + Error("*** %s removed", file); + } + + free(p1); + } +} + /*- *----------------------------------------------------------------------- * CompatInterrupt -- @@ -132,6 +151,9 @@ static void CompatInterrupt(int); * The target is removed and the process exits. If .INTERRUPT exists, * its commands are run first WITH INTERRUPTS IGNORED.. * + * XXX: is .PRECIOUS supposed to inhibit .INTERRUPT? I doubt it, but I've + * left the logic alone for now. - dholland 20160826 + * *----------------------------------------------------------------------- */ static void @@ -139,16 +161,9 @@ CompatInterrupt(int signo) { GNode *gn; - if ((curTarg != NULL) && !Targ_Precious (curTarg)) { - char *p1; - char *file = Var_Value(TARGET, curTarg, &p1); - - if (!noExecute && eunlink(file) != -1) { - Error("*** %s removed", file); - } - - free(p1); + CompatDeleteTarget(curTarg); + if ((curTarg != NULL) && !Targ_Precious (curTarg)) { /* * Run .INTERRUPT only if hit with interrupt signal */ @@ -158,7 +173,6 @@ CompatInterrupt(int signo) Compat_Make(gn, gn); } } - } if (signo == SIGQUIT) _exit(signo); @@ -447,6 +461,11 @@ again: * continue. */ printf(" (continuing)\n"); + } else { + printf("\n"); + } + if (deleteOnError) { + CompatDeleteTarget(gn); } } else { /* @@ -607,7 +626,7 @@ Compat_Make(void *gnp, void *pgnp) } else if (keepgoing) { pgn->flags &= ~REMAKE; } else { - PrintOnError(gn, "\n\nStop."); + PrintOnError(gn, "\nStop."); exit(1); } } else if (gn->made == ERROR) { @@ -698,7 +717,7 @@ Compat_Run(Lst targs) if (gn != NULL) { Compat_Make(gn, gn); if (gn->made == ERROR) { - PrintOnError(gn, "\n\nStop."); + PrintOnError(gn, "\nStop."); exit(1); } } @@ -739,7 +758,7 @@ Compat_Run(Lst targs) if (errors == 0) { Compat_Make(ENDNode, ENDNode); if (gn->made == ERROR) { - PrintOnError(gn, "\n\nStop."); + PrintOnError(gn, "\nStop."); exit(1); } } Modified: head/contrib/bmake/job.c ============================================================================== --- head/contrib/bmake/job.c Mon Dec 19 22:28:28 2016 (r310303) +++ head/contrib/bmake/job.c Mon Dec 19 23:38:07 2016 (r310304) @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.187 2016/05/12 20:28:34 sjg Exp $ */ +/* $NetBSD: job.c,v 1.188 2016/08/26 23:28:39 dholland Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -70,14 +70,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: job.c,v 1.187 2016/05/12 20:28:34 sjg Exp $"; +static char rcsid[] = "$NetBSD: job.c,v 1.188 2016/08/26 23:28:39 dholland Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: job.c,v 1.187 2016/05/12 20:28:34 sjg Exp $"); +__RCSID("$NetBSD: job.c,v 1.188 2016/08/26 23:28:39 dholland Exp $"); #endif #endif /* not lint */ #endif @@ -404,6 +404,21 @@ job_table_dump(const char *where) } /* + * Delete the target of a failed, interrupted, or otherwise + * unsuccessful job unless inhibited by .PRECIOUS. + */ +static void +JobDeleteTarget(GNode *gn) +{ + if ((gn->type & (OP_JOIN|OP_PHONY)) == 0 && !Targ_Precious(gn)) { + char *file = (gn->path == NULL ? gn->name : gn->path); + if (!noExecute && eunlink(file) != -1) { + Error("*** %s removed", file); + } + } +} + +/* * JobSigLock/JobSigUnlock * * Signal lock routines to get exclusive access. Currently used to @@ -1049,6 +1064,9 @@ JobFinish (Job *job, WAIT_T status) if (job->flags & JOB_IGNERR) { WAIT_STATUS(status) = 0; } else { + if (deleteOnError) { + JobDeleteTarget(job->node); + } PrintOnError(job->node, NULL); } } else if (DEBUG(JOB)) { @@ -1066,6 +1084,9 @@ JobFinish (Job *job, WAIT_T status) } (void)printf("*** [%s] Signal %d\n", job->node->name, WTERMSIG(status)); + if (deleteOnError) { + JobDeleteTarget(job->node); + } } (void)fflush(stdout); } @@ -2601,12 +2622,7 @@ JobInterrupt(int runINTERRUPT, int signo gn = job->node; - if ((gn->type & (OP_JOIN|OP_PHONY)) == 0 && !Targ_Precious(gn)) { - char *file = (gn->path == NULL ? gn->name : gn->path); - if (!noExecute && eunlink(file) != -1) { - Error("*** %s removed", file); - } - } + JobDeleteTarget(gn); if (job->pid) { if (DEBUG(JOB)) { (void)fprintf(debug_file, Modified: head/contrib/bmake/main.c ============================================================================== --- head/contrib/bmake/main.c Mon Dec 19 22:28:28 2016 (r310303) +++ head/contrib/bmake/main.c Mon Dec 19 23:38:07 2016 (r310304) @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.250 2016/08/11 19:53:17 sjg Exp $ */ +/* $NetBSD: main.c,v 1.254 2016/12/10 23:12:39 christos Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,7 +69,7 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: main.c,v 1.250 2016/08/11 19:53:17 sjg Exp $"; +static char rcsid[] = "$NetBSD: main.c,v 1.254 2016/12/10 23:12:39 christos Exp $"; #else #include #ifndef lint @@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19 #if 0 static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: main.c,v 1.250 2016/08/11 19:53:17 sjg Exp $"); +__RCSID("$NetBSD: main.c,v 1.254 2016/12/10 23:12:39 christos Exp $"); #endif #endif /* not lint */ #endif @@ -155,6 +155,7 @@ Lst create; /* Targets to be made */ time_t now; /* Time at start of make */ GNode *DEFAULT; /* .DEFAULT node */ Boolean allPrecious; /* .PRECIOUS given on line by itself */ +Boolean deleteOnError; /* .DELETE_ON_ERROR: set */ static Boolean noBuiltins; /* -r flag */ static Lst makefiles; /* ordered list of makefiles to read */ @@ -711,18 +712,24 @@ Main_ParseArgLine(const char *line) } Boolean -Main_SetObjdir(const char *path) +Main_SetObjdir(const char *fmt, ...) { struct stat sb; - char *p = NULL; - char buf[MAXPATHLEN + 1]; + char *p, *path; + char buf[MAXPATHLEN + 1], pbuf[MAXPATHLEN + 1]; Boolean rc = FALSE; + va_list ap; + + va_start(ap, fmt); + vsnprintf(path = pbuf, MAXPATHLEN, fmt, ap); + va_end(ap); /* expand variable substitutions */ if (strchr(path, '$') != 0) { snprintf(buf, MAXPATHLEN, "%s", path); path = p = Var_Subst(NULL, buf, VAR_GLOBAL, VARF_WANTRES); - } + } else + p = NULL; if (path[0] != '/') { snprintf(buf, MAXPATHLEN, "%s/%s", curdir, path); @@ -749,6 +756,18 @@ Main_SetObjdir(const char *path) return rc; } +static Boolean +Main_SetVarObjdir(const char *var, const char *suffix) +{ + char *p1, *path; + if ((path = Var_Value(var, VAR_CMD, &p1)) == NULL) + return FALSE; + + (void)Main_SetObjdir("%s%s", path, suffix); + free(p1); + return TRUE; +} + /*- * ReadAllMakefiles -- * wrapper around ReadMakefile() to read all. @@ -979,6 +998,7 @@ main(int argc, char **argv) noRecursiveExecute = FALSE; /* Execute all .MAKE targets */ keepgoing = FALSE; /* Stop on error */ allPrecious = FALSE; /* Remove targets when interrupted */ + deleteOnError = FALSE; /* Historical default behavior */ queryFlag = FALSE; /* This is not just a check-run */ noBuiltins = FALSE; /* Read the built-in rules */ touchFlag = FALSE; /* Actually update targets */ @@ -1128,28 +1148,19 @@ main(int argc, char **argv) * MAKEOBJDIR is set in the environment, try only that value * and fall back to .CURDIR if it does not exist. * - * Otherwise, try _PATH_OBJDIR.MACHINE, _PATH_OBJDIR, and - * finally _PATH_OBJDIRPREFIX`pwd`, in that order. If none + * Otherwise, try _PATH_OBJDIR.MACHINE-MACHINE_ARCH, _PATH_OBJDIR.MACHINE, + * and * finally _PATH_OBJDIRPREFIX`pwd`, in that order. If none * of these paths exist, just use .CURDIR. */ Dir_Init(curdir); - (void)Main_SetObjdir(curdir); + (void)Main_SetObjdir("%s", curdir); - if ((path = Var_Value("MAKEOBJDIRPREFIX", VAR_CMD, &p1)) != NULL) { - (void)snprintf(mdpath, MAXPATHLEN, "%s%s", path, curdir); - (void)Main_SetObjdir(mdpath); - free(p1); - } else if ((path = Var_Value("MAKEOBJDIR", VAR_CMD, &p1)) != NULL) { - (void)Main_SetObjdir(path); - free(p1); - } else { - (void)snprintf(mdpath, MAXPATHLEN, "%s.%s", _PATH_OBJDIR, machine); - if (!Main_SetObjdir(mdpath) && !Main_SetObjdir(_PATH_OBJDIR)) { - (void)snprintf(mdpath, MAXPATHLEN, "%s%s", - _PATH_OBJDIRPREFIX, curdir); - (void)Main_SetObjdir(mdpath); - } - } + if (!Main_SetVarObjdir("MAKEOBJDIRPREFIX", curdir) && + !Main_SetVarObjdir("MAKEOBJDIR", "") && + !Main_SetObjdir("%s.%s-%s", _PATH_OBJDIR, machine, machine_arch) && + !Main_SetObjdir("%s.%s", _PATH_OBJDIR, machine) && + !Main_SetObjdir("%s", _PATH_OBJDIR)) + (void)Main_SetObjdir("%s%s", _PATH_OBJDIRPREFIX, curdir); /* * Initialize archive, target and suffix modules in preparation for Modified: head/contrib/bmake/make.1 ============================================================================== --- head/contrib/bmake/make.1 Mon Dec 19 22:28:28 2016 (r310303) +++ head/contrib/bmake/make.1 Mon Dec 19 23:38:07 2016 (r310304) @@ -1,4 +1,4 @@ -.\" $NetBSD: make.1,v 1.262 2016/08/18 19:23:20 wiz Exp $ +.\" $NetBSD: make.1,v 1.263 2016/08/26 23:37:54 dholland Exp $ .\" .\" Copyright (c) 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" from: @(#)make.1 8.4 (Berkeley) 3/19/94 .\" -.Dd August 15, 2016 +.Dd August 26, 2016 .Dt MAKE 1 .Os .Sh NAME @@ -2022,6 +2022,14 @@ variable of a target that inherits .Ic .DEFAULT Ns 's commands is set to the target's own name. +.It Ic .DELETE_ON_ERROR +If this target is present in the makefile, it globally causes make to +delete targets whose commands fail. +(By default, only targets whose commands are interrupted during +execution are deleted. +This is the historical behavior.) +This setting can be used to help prevent half-finished or malformed +targets from being left around and corrupting future rebuilds. .It Ic .END Any command lines attached to this target are executed after everything else is done. Modified: head/contrib/bmake/make.c ============================================================================== --- head/contrib/bmake/make.c Mon Dec 19 22:28:28 2016 (r310303) +++ head/contrib/bmake/make.c Mon Dec 19 23:38:07 2016 (r310304) @@ -1,4 +1,4 @@ -/* $NetBSD: make.c,v 1.95 2016/02/18 18:29:14 christos Exp $ */ +/* $NetBSD: make.c,v 1.96 2016/11/10 23:41:58 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: make.c,v 1.95 2016/02/18 18:29:14 christos Exp $"; +static char rcsid[] = "$NetBSD: make.c,v 1.96 2016/11/10 23:41:58 sjg Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)make.c 8.1 (Berkeley) 6/6/93"; #else -__RCSID("$NetBSD: make.c,v 1.95 2016/02/18 18:29:14 christos Exp $"); +__RCSID("$NetBSD: make.c,v 1.96 2016/11/10 23:41:58 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -308,7 +308,7 @@ Make_OODate(GNode *gn) if (DEBUG(MAKE)) { if (gn->cmgn != NULL && gn->mtime < gn->cmgn->mtime) { fprintf(debug_file, "modified before source %s...", - gn->cmgn->path); + gn->cmgn->path ? gn->cmgn->path : gn->cmgn->name); } else if (gn->mtime == 0) { fprintf(debug_file, "non-existent and no sources..."); } else { Modified: head/contrib/bmake/make.h ============================================================================== --- head/contrib/bmake/make.h Mon Dec 19 22:28:28 2016 (r310303) +++ head/contrib/bmake/make.h Mon Dec 19 23:38:07 2016 (r310304) @@ -1,4 +1,4 @@ -/* $NetBSD: make.h,v 1.100 2016/06/07 00:40:00 sjg Exp $ */ +/* $NetBSD: make.h,v 1.102 2016/12/07 15:00:46 christos Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -389,6 +389,7 @@ extern Boolean beSilent; /* True if extern Boolean noExecute; /* True if should execute nothing */ extern Boolean noRecursiveExecute; /* True if should execute nothing */ extern Boolean allPrecious; /* True if every target is precious */ +extern Boolean deleteOnError; /* True if failed targets should be deleted */ extern Boolean keepgoing; /* True if should continue on unaffected * portions of the graph when have an error * in one portion */ @@ -503,7 +504,7 @@ char * Check_Cwd_Cmd(const char *); void Check_Cwd(const char **); void PrintOnError(GNode *, const char *); void Main_ExportMAKEFLAGS(Boolean); -Boolean Main_SetObjdir(const char *); +Boolean Main_SetObjdir(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2); int mkTempFile(const char *, char **); int str2Lst_Append(Lst, char *, const char *); int cached_lstat(const char *, void *); Modified: head/contrib/bmake/mk/ChangeLog ============================================================================== --- head/contrib/bmake/mk/ChangeLog Mon Dec 19 22:28:28 2016 (r310303) +++ head/contrib/bmake/mk/ChangeLog Mon Dec 19 23:38:07 2016 (r310304) @@ -1,3 +1,62 @@ +2016-12-12 Simon J. Gerraty + + * install-mk (MK_VERSION): 20161212 + + * meta2deps.py: set pid_cwd[pid] when we process 'C'hdir, + rather than when we detect pid change. + +2016-12-07 Simon J. Gerraty + + * install-mk (MK_VERSION): 20161207 + + * meta.stage.mk: add stage_as_and_symlink for staging packages. + We build foo.tgz stage_as foo-${VERSION}.tgz but want to be able + to use foo.tgz to reference the latest staged version - so we + make foo.tgz a symlink to it. + Using a target to do both operations ensures we stay in sync. + +2016-11-26 Simon J. Gerraty + + * install-mk (MK_VERSION): 20161126 + + * dirdeps.mk: set DIRDEPS_CACHE before we include local.dirdeps.mk + so it can add dependencies. + +2016-10-10 Simon J. Gerraty + + * dirdeps.mk: set DEP_* before we expand .MAKE.DEPENDFILE_PREFERENCE + do that they can influence the result correctly. + + * dirdeps.mk (${DIRDEPS_CACHE}): make sure we pass on TARGET_SPEC + + * dirdeps.mk: Add ONLY_TARGET_SPEC_LIST and NOT_TARGET_SPEC_LIST + similar to ONLY_MACHINE_LIST and NOT_MACHINE_LIST + +2016-10-05 Simon J. Gerraty + + * dirdeps.mk: remove dependence on jot (normal situations anyway). + Before we read another Makefile.depend* set DEP_* vars from + _DEP_TARGET_SPEC in case it uses any of them with := + When bootstrapping, trim any ,* from extention of chosen _src + Makefile.depend* to get the machine value we subst for. + +2016-09-30 Simon J. Gerraty + + * dirdeps.mk: use TARGET_SPEC_VARS to qualify components added to + DEP_SKIP_DIR and DEP_DIRDEPS_FILTER + + * sys.mk: extract some bits to sys.{debug,vars}.mk + for easier re-use by others. + +2016-09-23 Simon Gerraty + + * lib.mk: Use ${PICO} for extension for PIC objects. + default to .pico (like NetBSD) safe on case insensitive filesystem. + +2016-08-19 Simon J. Gerraty + + * meta.sys.mk (META_COOKIE_TOUCH): use ${.OBJDIR}/${.TARGET:T} as default + 2016-08-15 Simon J. Gerraty * install-mk (MK_VERSION): 20160815 Modified: head/contrib/bmake/mk/FILES ============================================================================== --- head/contrib/bmake/mk/FILES Mon Dec 19 22:28:28 2016 (r310303) +++ head/contrib/bmake/mk/FILES Mon Dec 19 23:38:07 2016 (r310304) @@ -38,7 +38,9 @@ stage-install.sh subdir.mk sys.mk sys.clean-env.mk +sys.debug.mk sys.dependfile.mk +sys.vars.mk sys/AIX.mk sys/Darwin.mk sys/Generic.mk Modified: head/contrib/bmake/mk/dirdeps.mk ============================================================================== --- head/contrib/bmake/mk/dirdeps.mk Mon Dec 19 22:28:28 2016 (r310303) +++ head/contrib/bmake/mk/dirdeps.mk Mon Dec 19 23:38:07 2016 (r310304) @@ -1,4 +1,4 @@ -# $Id: dirdeps.mk,v 1.73 2016/08/15 19:28:13 sjg Exp $ +# $Id: dirdeps.mk,v 1.84 2016/11/27 02:44:34 sjg Exp $ # Copyright (c) 2010-2013, Juniper Networks, Inc. # All rights reserved. @@ -56,9 +56,12 @@ # .MAKE.DEPENDFILE_PREFIX) to refer to these makefiles to # distinguish them from others. # -# Each Makefile.depend file sets DEP_RELDIR to be the -# the RELDIR (path relative to SRCTOP) for its directory, and -# since each Makefile.depend file includes dirdeps.mk, this +# Before each Makefile.depend file is read, we set +# DEP_RELDIR to be the the RELDIR (path relative to SRCTOP) for +# its directory, and DEP_MACHINE etc according to the . +# represented by the suffix of the corresponding target. +# +# Since each Makefile.depend file includes dirdeps.mk, this # processing is recursive and results in .MAKE.LEVEL 0 learning the # dependencies of the tree wrt the initial directory (_DEP_RELDIR). # @@ -110,6 +113,29 @@ # # as we may need it to find Makefile.depend* # TARGET_SPEC = ${TARGET_SPEC_VARS:@v@${$v:U}@:ts,} # +# The following variables can influence the initial DIRDEPS +# computation with regard to the TARGET_SPECs that will be +# built. +# Most should also be considered by init.mk +# +# ONLY_TARGET_SPEC_LIST +# Defines a list of TARGET_SPECs for which the current +# directory can be built. +# If ALL_MACHINES is defined, we build for all the +# TARGET_SPECs listed. +# +# ONLY_MACHINE_LIST +# As for ONLY_TARGET_SPEC_LIST but only specifies +# MACHINEs. +# +# NOT_TARGET_SPEC_LIST +# A list of TARGET_SPECs for which the current +# directory should not be built. +# +# NOT_MACHINE_LIST +# A list of MACHINEs the current directory should not be +# built for. +# # touch this at your peril _DIRDEP_USE_LEVEL?= 0 @@ -171,9 +197,13 @@ DEP_$v ?= ${$v} # we compute below are fully qualified wrt DEP_TARGET_SPEC. # The makefiles may only partially specify (eg. MACHINE only), # so we need to construct a set of modifiers to fill in the gaps. -# jot 10 should output 1 2 3 .. 10 -JOT ?= jot -_tspec_x := ${${JOT} ${TARGET_SPEC_VARS:[#]}:L:sh} +.if ${TARGET_SPEC_VARS:[#]} > 10 +# seriously? better have jot(1) or equivalent to produce suitable sequence +_tspec_x := ${${JOT:Ujot} ${TARGET_SPEC_VARS:[#]}:L:sh} +.else +# we can provide the sequence ourselves +_tspec_x := ${1 2 3 4 5 6 7 8 9 10:L:[1..${TARGET_SPEC_VARS:[#]}]} +.endif # this handles unqualified entries M_dep_qual_fixes = C;(/[^/.,]+)$$;\1.$${DEP_TARGET_SPEC}; # there needs to be at least one item missing for these to make sense @@ -287,6 +317,18 @@ _DEP_RELDIR := ${DEP_RELDIR} .endif +# DIRDEPS_CACHE can be very handy for debugging. +# Also if repeatedly building the same target, +# we can avoid the overhead of re-computing the tree dependencies. +MK_DIRDEPS_CACHE ?= no +BUILD_DIRDEPS_CACHE ?= no +BUILD_DIRDEPS ?= yes + +.if ${MK_DIRDEPS_CACHE} == "yes" +# this is where we will cache all our work +DIRDEPS_CACHE ?= ${_OBJDIR:tA}/dirdeps.cache${.TARGETS:Nall:O:u:ts-:S,/,_,g:S,^,.,:N.} +.endif + # pickup customizations # as below you can use !target(_DIRDEP_USE) to protect things # which should only be done once. @@ -305,8 +347,10 @@ SKIP_DIR.host += ${SKIP_HOSTDIR} DEP_SKIP_DIR = ${SKIP_DIR} \ ${SKIP_DIR.${DEP_TARGET_SPEC}:U} \ - ${SKIP_DIR.${DEP_MACHINE}:U} \ - ${SKIP_DIRDEPS.${DEP_MACHINE}:U} + ${TARGET_SPEC_VARS:@v@${SKIP_DIR.${DEP_$v}:U}@} \ + ${SKIP_DIRDEPS.${DEP_TARGET_SPEC}:U} \ + ${TARGET_SPEC_VARS:@v@${SKIP_DIRDEPS.${DEP_$v}:U}@} + NSkipDir = ${DEP_SKIP_DIR:${M_ListToSkip}} @@ -344,7 +388,7 @@ _DIRDEP_USE: .USE .MAKE .ifdef ALL_MACHINES # this is how you limit it to only the machines we have been built for # previously. -.if empty(ONLY_MACHINE_LIST) +.if empty(ONLY_TARGET_SPEC_LIST) && empty(ONLY_MACHINE_LIST) .if !empty(ALL_MACHINE_LIST) # ALL_MACHINE_LIST is the list of all legal machines - ignore anything else _machine_list != cd ${_CURDIR} && 'ls' -1 ${ALL_MACHINE_LIST:O:u:@m@${.MAKE.DEPENDFILE:T:R}.$m@} 2> /dev/null; echo @@ -353,7 +397,7 @@ _machine_list != 'ls' -1 ${_CURDIR}/${.M .endif _only_machines := ${_machine_list:${NIgnoreFiles:UN*.bak}:E:O:u} .else -_only_machines := ${ONLY_MACHINE_LIST} +_only_machines := ${ONLY_TARGET_SPEC_LIST:U} ${ONLY_MACHINE_LIST:U} .endif .if empty(_only_machines) @@ -362,30 +406,35 @@ _only_machines := ${TARGET_MACHINE:U${AL .endif .else # ! ALL_MACHINES -# if ONLY_MACHINE_LIST is set, we are limited to that +# if ONLY_TARGET_SPEC_LIST or ONLY_MACHINE_LIST is set, we are limited to that. +# Note that ONLY_TARGET_SPEC_LIST should be fully qualified. # if TARGET_MACHINE is set - it is really the same as ONLY_MACHINE_LIST # otherwise DEP_MACHINE is it - so DEP_MACHINE will match. +_only_machines := ${ONLY_TARGET_SPEC_LIST:U:M${DEP_MACHINE},*} +.if empty(_only_machines) _only_machines := ${ONLY_MACHINE_LIST:U${TARGET_MACHINE:U${DEP_MACHINE}}:M${DEP_MACHINE}} .endif +.endif .if !empty(NOT_MACHINE_LIST) _only_machines := ${_only_machines:${NOT_MACHINE_LIST:${M_ListToSkip}}} .endif +.if !empty(NOT_TARGET_SPEC_LIST) +# we must first qualify +_dm := ${DEP_MACHINE} +_only_machines := ${_only_machines:M*,*} ${_only_machines:N*,*:@DEP_MACHINE@${DEP_TARGET_SPEC}@:S,^,.,:${M_dep_qual_fixes:ts:}:O:u:S,^.,,} +DEP_MACHINE := ${_dm} +_only_machines := ${_only_machines:${NOT_TARGET_SPEC_LIST:${M_ListToSkip}}} +.endif +# clean up +_only_machines := ${_only_machines:O:u} # make sure we have a starting place? DIRDEPS ?= ${RELDIR} .endif # target -# if repeatedly building the same target, -# we can avoid the overhead of re-computing the tree dependencies. -MK_DIRDEPS_CACHE ?= no -BUILD_DIRDEPS_CACHE ?= no -BUILD_DIRDEPS ?= yes - .if !defined(NO_DIRDEPS) && !defined(NO_DIRDEPS_BELOW) .if ${MK_DIRDEPS_CACHE} == "yes" -# this is where we will cache all our work -DIRDEPS_CACHE?= ${_OBJDIR:tA}/dirdeps.cache${.TARGETS:Nall:O:u:ts-:S,/,_,g:S,^,.,:N.} # just ensure this exists build-dirdeps: @@ -420,6 +469,7 @@ ${DIRDEPS_CACHE}: .META .NOMETA_CMP } > ${.TARGET}.new +@MAKELEVEL=${.MAKE.LEVEL} DIRDEPS_CACHE=${DIRDEPS_CACHE} \ DIRDEPS="${DIRDEPS}" \ + TARGET_SPEC=${TARGET_SPEC} \ MAKEFLAGS= ${.MAKE} -C ${_CURDIR} -f ${BUILD_DIRDEPS_MAKEFILE} \ ${BUILD_DIRDEPS_TARGETS} BUILD_DIRDEPS_CACHE=yes \ .MAKE.DEPENDFILE=.none \ @@ -489,8 +539,10 @@ _machines := ${_machines:O:u} _dm := ${DEP_MACHINE} # apply the same filtering that we do when qualifying DIRDEPS. # M_dep_qual_fixes expects .${MACHINE}* so add (and remove) '.' -_machines := ${_machines:@DEP_MACHINE@${DEP_TARGET_SPEC}@:S,^,.,:${M_dep_qual_fixes:ts:}:O:u:S,^.,,} +# Again we expect that any already qualified machines are fully qualified. +_machines := ${_machines:M*,*} ${_machines:N*,*:@DEP_MACHINE@${DEP_TARGET_SPEC}@:S,^,.,:${M_dep_qual_fixes:ts:}:O:u:S,^.,,} DEP_MACHINE := ${_dm} +_machines := ${_machines:O:u} .endif # reset each time through @@ -522,7 +574,7 @@ _build_dirs += ${_machines:N${DEP_TARGET # these we reset each time through as they can depend on DEP_MACHINE DEP_DIRDEPS_FILTER = \ ${DIRDEPS_FILTER.${DEP_TARGET_SPEC}:U} \ - ${DIRDEPS_FILTER.${DEP_MACHINE}:U} \ + ${TARGET_SPEC_VARS:@v@${DIRDEPS_FILTER.${DEP_$v}:U}@} \ ${DIRDEPS_FILTER:U} .if empty(DEP_DIRDEPS_FILTER) # something harmless @@ -621,6 +673,19 @@ _dirdeps_checked.$d: .endif # Note: _build_all_dirs is fully qualifed so d:R is always the directory .if exists(${d:R}) +# we pass _DEP_TARGET_SPEC to tell the next step what we want +_DEP_TARGET_SPEC := ${d:E} +# some makefiles may still look at this +_DEP_MACHINE := ${d:E:C/,.*//} +# set these too in case Makefile.depend* uses them +.if ${TARGET_SPEC_VARS:[#]} > 1 +_dtspec := ${_DEP_TARGET_SPEC:S/,/ /g} +.for i in ${_tspec_x} +DEP_${TARGET_SPEC_VARS:[$i]} := ${_dtspec:[$i]} +.endfor +.else +DEP_MACHINE := ${_DEP_MACHINE} +.endif # Warning: there is an assumption here that MACHINE is always # the first entry in TARGET_SPEC_VARS. # If TARGET_SPEC and MACHINE are insufficient, you have a problem. @@ -631,10 +696,6 @@ _qm := ${_m:C;(\.depend)$;\1.${d:E};:${M .if ${_debug_search} .info Looking for ${_qm} .endif -# we pass _DEP_TARGET_SPEC to tell the next step what we want -_DEP_TARGET_SPEC := ${d:E} -# some makefiles may still look at this -_DEP_MACHINE := ${d:E:C/,.*//} # set this "just in case" # we can skip :tA since we computed the path above DEP_RELDIR := ${_m:H:S,${SRCTOP}/,,} @@ -687,7 +748,7 @@ _src != cd ${.CURDIR} && for m in ${.MAK _src?= ${.MAKE.DEPENDFILE} -.MAKE.DEPENDFILE_BOOTSTRAP_SED+= -e 's,${_src:E},${MACHINE},g' +.MAKE.DEPENDFILE_BOOTSTRAP_SED+= -e 's/${_src:E:C/,.*//}/${MACHINE}/g' # just create Makefile.depend* for this dir bootstrap-this: .NOTMAIN @@ -696,7 +757,7 @@ bootstrap-this: .NOTMAIN .if ${_src:T} != ${.MAKE.DEPENDFILE_PREFIX:T} (cd ${.CURDIR} && sed ${.MAKE.DEPENDFILE_BOOTSTRAP_SED} ${_src} > ${_want}) .else - cp ${.CURDIR}/${_src} ${_want} + cp ${.CURDIR}/${_src:T} ${_want} .endif # create Makefile.depend* for this dir and its dependencies Modified: head/contrib/bmake/mk/gendirdeps.mk ============================================================================== --- head/contrib/bmake/mk/gendirdeps.mk Mon Dec 19 22:28:28 2016 (r310303) +++ head/contrib/bmake/mk/gendirdeps.mk Mon Dec 19 23:38:07 2016 (r310304) @@ -1,4 +1,4 @@ -# $Id: gendirdeps.mk,v 1.32 2016/04/05 15:58:37 sjg Exp $ +# $Id: gendirdeps.mk,v 1.33 2016/10/11 22:37:28 sjg Exp $ # Copyright (c) 2010-2013, Juniper Networks, Inc. # All rights reserved. @@ -146,6 +146,9 @@ M2D_OBJROOTS += ${OBJTOP} ${_OBJROOT} ${ .if defined(SB_OBJROOT) M2D_OBJROOTS += ${SB_OBJROOT} .endif +.if defined(STAGE_ROOT) +M2D_OBJROOTS += ${STAGE_ROOT} +.endif .if ${.MAKE.DEPENDFILE_PREFERENCE:U${.MAKE.DEPENDFILE}:M*.${MACHINE}} == "" # meta2deps.py only groks objroot # so we need to give it what it expects Modified: head/contrib/bmake/mk/install-mk ============================================================================== --- head/contrib/bmake/mk/install-mk Mon Dec 19 22:28:28 2016 (r310303) +++ head/contrib/bmake/mk/install-mk Mon Dec 19 23:38:07 2016 (r310304) @@ -55,7 +55,7 @@ # Simon J. Gerraty # RCSid: -# $Id: install-mk,v 1.130 2016/08/15 19:28:13 sjg Exp $ +# $Id: install-mk,v 1.135 2016/12/12 19:07:42 sjg Exp $ # # @(#) Copyright (c) 1994 Simon J. Gerraty # @@ -70,7 +70,7 @@ # sjg@crufty.net # -MK_VERSION=20160815 +MK_VERSION=20161212 OWNER= GROUP= MODE=444 Modified: head/contrib/bmake/mk/lib.mk ============================================================================== --- head/contrib/bmake/mk/lib.mk Mon Dec 19 22:28:28 2016 (r310303) +++ head/contrib/bmake/mk/lib.mk Mon Dec 19 23:38:07 2016 (r310304) @@ -1,4 +1,4 @@ -# $Id: lib.mk,v 1.54 2016/08/02 20:52:17 sjg Exp $ +# $Id: lib.mk,v 1.55 2016/09/23 23:04:51 sjg Exp $ .if !target(__${.PARSEFILE}__) __${.PARSEFILE}__: @@ -9,39 +9,30 @@ __${.PARSEFILE}__: NEED_SOLINKS?= yes .endif -.if exists(${.CURDIR}/shlib_version) -SHLIB_MAJOR != . ${.CURDIR}/shlib_version ; echo $$major -SHLIB_MINOR != . ${.CURDIR}/shlib_version ; echo $$minor -.endif - -print-shlib-major: -.if defined(SHLIB_MAJOR) && ${MK_PIC} != "no" - @echo ${SHLIB_MAJOR} -.else - @false +SHLIB_VERSION_FILE?= ${.CURDIR}/shlib_version +.if !defined(SHLIB_MAJOR) && exists(${SHLIB_VERSION_FILE}) +SHLIB_MAJOR != . ${SHLIB_VERSION_FILE} ; echo $$major +SHLIB_MINOR != . ${SHLIB_VERSION_FILE} ; echo $$minor +SHLIB_TEENY != . ${SHLIB_VERSION_FILE} ; echo $$teeny .endif -print-shlib-minor: -.if defined(SHLIB_MINOR) && ${MK_PIC} != "no" - @echo ${SHLIB_MINOR} -.else - @false -.endif - -print-shlib-teeny: -.if defined(SHLIB_TEENY) && ${MK_PIC} != "no" - @echo ${SHLIB_TEENY} +.for x in major minor teeny +print-shlib-$x: +.if defined(SHLIB_${x:tu}) && ${MK_PIC} != "no" + @echo ${SHLIB_${x:tu}} .else @false .endif +.endfor SHLIB_FULLVERSION ?= ${${SHLIB_MAJOR} ${SHLIB_MINOR} ${SHLIB_TEENY}:L:ts.} SHLIB_FULLVERSION := ${SHLIB_FULLVERSION} # add additional suffixes not exported. # .po is used for profiling object files. -# .So is used for PIC object files. -.SUFFIXES: .out .a .ln .So .po .o .s .S .c .cc .C .m .F .f .r .y .l .cl .p .h +# ${PICO} is used for PIC object files. +PICO?= .pico +.SUFFIXES: .out .a .ln ${PICO} .po .o .s .S .c .cc .C .m .F .f .r .y .l .cl .p .h .SUFFIXES: .sh .m4 .m CFLAGS+= ${COPTS} @@ -62,12 +53,12 @@ CFLAGS+= ${COPTS} # with ELF, also set shared-lib version for ld.so. # SHLIB_LDSTARTFILE: support .o file, call C++ file-level constructors # SHLIB_LDENDFILE: support .o file, call C++ file-level destructors -# FPICFLAGS: flags for ${FC} to compile .[fF] files to .So objects. +# FPICFLAGS: flags for ${FC} to compile .[fF] files to ${PICO} objects. # CPPICFLAGS: flags for ${CPP} to preprocess .[sS] files for ${AS} -# CPICFLAGS: flags for ${CC} to compile .[cC] files to .So objects. +# CPICFLAGS: flags for ${CC} to compile .[cC] files to ${PICO} objects. # CAPICFLAGS flags for {$CC} to compiling .[Ss] files # (usually just ${CPPPICFLAGS} ${CPICFLAGS}) -# APICFLAGS: flags for ${AS} to assemble .[sS] to .So objects. +# APICFLAGS: flags for ${AS} to assemble .[sS] to ${PICO} objects. .if ${TARGET_OSNAME} == "NetBSD" .if ${MACHINE_ARCH} == "alpha" @@ -162,14 +153,14 @@ LD_shared=-b LD_so=sl DLLIB= # HPsUX lorder does not grok anything but .o -LD_sobjs=`${LORDER} ${OBJS} | ${TSORT} | sed 's,\.o,.So,'` +LD_sobjs=`${LORDER} ${OBJS} | ${TSORT} | sed 's,\.o,${PICO},'` LD_pobjs=`${LORDER} ${OBJS} | ${TSORT} | sed 's,\.o,.po,'` .elif ${TARGET_OSNAME} == "OSF1" LD_shared= -msym -shared -expect_unresolved '*' LD_solib= -all lib${LIB}_pic.a DLLIB= # lorder does not grok anything but .o -LD_sobjs=`${LORDER} ${OBJS} | ${TSORT} | sed 's,\.o,.So,'` +LD_sobjs=`${LORDER} ${OBJS} | ${TSORT} | sed 's,\.o,${PICO},'` LD_pobjs=`${LORDER} ${OBJS} | ${TSORT} | sed 's,\.o,.po,'` *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@freebsd.org Tue Dec 20 01:13:12 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CBA03C8796E; Tue, 20 Dec 2016 01:13:12 +0000 (UTC) (envelope-from kevlo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 A62EA1D19; Tue, 20 Dec 2016 01:13:12 +0000 (UTC) (envelope-from kevlo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBK1DBYc082013; Tue, 20 Dec 2016 01:13:11 GMT (envelope-from kevlo@FreeBSD.org) Received: (from kevlo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBK1DBtN082008; Tue, 20 Dec 2016 01:13:11 GMT (envelope-from kevlo@FreeBSD.org) Message-Id: <201612200113.uBK1DBtN082008@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevlo set sender to kevlo@FreeBSD.org using -f From: Kevin Lo Date: Tue, 20 Dec 2016 01:13:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310305 - in head/sys/dev/rtwn: rtl8188e/usb rtl8192c rtl8812a X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 20 Dec 2016 01:13:12 -0000 Author: kevlo Date: Tue Dec 20 01:13:11 2016 New Revision: 310305 URL: https://svnweb.freebsd.org/changeset/base/310305 Log: Merge r92c_init_rf_common() into r92c_init_rf(). In r88eu_attach.c, we could use r92c_init_rf() rather than r92c_init_rf_common() when sc_init_rf() callback is invoked. While here, constantly use RF chain instead of RF path in comment. Reviewed by: avos Modified: head/sys/dev/rtwn/rtl8188e/usb/r88eu_attach.c head/sys/dev/rtwn/rtl8188e/usb/r88eu_init.c head/sys/dev/rtwn/rtl8192c/r92c.h head/sys/dev/rtwn/rtl8192c/r92c_init.c head/sys/dev/rtwn/rtl8812a/r12a_priv.h Modified: head/sys/dev/rtwn/rtl8188e/usb/r88eu_attach.c ============================================================================== --- head/sys/dev/rtwn/rtl8188e/usb/r88eu_attach.c Mon Dec 19 23:38:07 2016 (r310304) +++ head/sys/dev/rtwn/rtl8188e/usb/r88eu_attach.c Tue Dec 20 01:13:11 2016 (r310305) @@ -171,7 +171,7 @@ r88eu_attach(struct rtwn_usb_softc *uc) sc->sc_init_intr = r88eu_init_intr; sc->sc_init_edca = r92c_init_edca; sc->sc_init_bb = r88e_init_bb; - sc->sc_init_rf = r92c_init_rf_common; + sc->sc_init_rf = r92c_init_rf; sc->sc_init_antsel = rtwn_nop_softc; sc->sc_post_init = r88eu_post_init; sc->sc_init_bcnq1_boundary = rtwn_nop_int_softc; Modified: head/sys/dev/rtwn/rtl8188e/usb/r88eu_init.c ============================================================================== --- head/sys/dev/rtwn/rtl8188e/usb/r88eu_init.c Mon Dec 19 23:38:07 2016 (r310304) +++ head/sys/dev/rtwn/rtl8188e/usb/r88eu_init.c Tue Dec 20 01:13:11 2016 (r310305) @@ -200,9 +200,6 @@ r88eu_init_rx_agg(struct rtwn_softc *sc) void r88eu_post_init(struct rtwn_softc *sc) { - /* Turn CCK and OFDM blocks on. */ - rtwn_bb_setbits(sc, R92C_FPGA0_RFMOD, 0, R92C_RFMOD_CCK_EN); - rtwn_bb_setbits(sc, R92C_FPGA0_RFMOD, 0, R92C_RFMOD_OFDM_EN); /* Enable per-packet TX report. */ rtwn_setbits_1(sc, R88E_TX_RPT_CTRL, 0, R88E_TX_RPT1_ENA); Modified: head/sys/dev/rtwn/rtl8192c/r92c.h ============================================================================== --- head/sys/dev/rtwn/rtl8192c/r92c.h Mon Dec 19 23:38:07 2016 (r310304) +++ head/sys/dev/rtwn/rtl8192c/r92c.h Tue Dec 20 01:13:11 2016 (r310305) @@ -81,7 +81,6 @@ int r92c_set_page_size(struct rtwn_softc void r92c_init_bb_common(struct rtwn_softc *); int r92c_init_rf_chain(struct rtwn_softc *, const struct rtwn_rf_prog *, int); -void r92c_init_rf_common(struct rtwn_softc *); void r92c_init_rf(struct rtwn_softc *); void r92c_init_edca(struct rtwn_softc *); void r92c_init_ampdu(struct rtwn_softc *); Modified: head/sys/dev/rtwn/rtl8192c/r92c_init.c ============================================================================== --- head/sys/dev/rtwn/rtl8192c/r92c_init.c Mon Dec 19 23:38:07 2016 (r310304) +++ head/sys/dev/rtwn/rtl8192c/r92c_init.c Tue Dec 20 01:13:11 2016 (r310305) @@ -204,7 +204,7 @@ r92c_init_rf_chain(struct rtwn_softc *sc } void -r92c_init_rf_common(struct rtwn_softc *sc) +r92c_init_rf(struct rtwn_softc *sc) { struct r92c_softc *rs = sc->sc_priv; uint32_t reg, type; @@ -244,14 +244,6 @@ r92c_init_rf_common(struct rtwn_softc *s rs->rf_chnlbw[chain] = rtwn_rf_read(sc, chain, R92C_RF_CHNLBW); } -} - -void -r92c_init_rf(struct rtwn_softc *sc) -{ - struct r92c_softc *rs = sc->sc_priv; - - r92c_init_rf_common(sc); if ((rs->chip & (R92C_CHIP_UMC_A_CUT | R92C_CHIP_92C)) == R92C_CHIP_UMC_A_CUT) { Modified: head/sys/dev/rtwn/rtl8812a/r12a_priv.h ============================================================================== --- head/sys/dev/rtwn/rtl8812a/r12a_priv.h Mon Dec 19 23:38:07 2016 (r310304) +++ head/sys/dev/rtwn/rtl8812a/r12a_priv.h Tue Dec 20 01:13:11 2016 (r310305) @@ -657,7 +657,7 @@ static const struct rtwn_rf_prog rtl8812 NULL }, { 0, NULL, NULL, { 0 }, NULL }, - /* RF path 2. */ + /* RF chain 1. */ { nitems(rtl8812au_rf1_regs0), rtl8812au_rf1_regs0, From owner-svn-src-head@freebsd.org Tue Dec 20 01:34:31 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 32340C886C4; Tue, 20 Dec 2016 01:34:31 +0000 (UTC) (envelope-from jmcneill@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 C2F81CA1; Tue, 20 Dec 2016 01:34:30 +0000 (UTC) (envelope-from jmcneill@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBK1YU6Q089965; Tue, 20 Dec 2016 01:34:30 GMT (envelope-from jmcneill@FreeBSD.org) Received: (from jmcneill@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBK1YTu3089959; Tue, 20 Dec 2016 01:34:29 GMT (envelope-from jmcneill@FreeBSD.org) Message-Id: <201612200134.uBK1YTu3089959@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jmcneill set sender to jmcneill@FreeBSD.org using -f From: Jared McNeill Date: Tue, 20 Dec 2016 01:34:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310306 - in head/sys: arm/allwinner arm/arm arm/freescale/imx conf dev/hdmi X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 20 Dec 2016 01:34:31 -0000 Author: jmcneill Date: Tue Dec 20 01:34:29 2016 New Revision: 310306 URL: https://svnweb.freebsd.org/changeset/base/310306 Log: Split the DesignWare HDMI-specific code from imx6_hdmi.c into a separate file and add a generic DT binding that takes advantage of the extres framework for setting up clocks. Reviewed by: gonzo Differential Revision: https://reviews.freebsd.org/D8826 Added: head/sys/dev/hdmi/ head/sys/dev/hdmi/dwc_hdmi.c (contents, props changed) head/sys/dev/hdmi/dwc_hdmi.h (contents, props changed) head/sys/dev/hdmi/dwc_hdmi_fdt.c (contents, props changed) head/sys/dev/hdmi/dwc_hdmireg.h (contents, props changed) head/sys/dev/hdmi/hdmi_if.m - copied unchanged from r310305, head/sys/arm/arm/hdmi_if.m Deleted: head/sys/arm/arm/hdmi_if.m head/sys/arm/freescale/imx/imx6_hdmireg.h Modified: head/sys/arm/allwinner/files.allwinner head/sys/arm/freescale/imx/files.imx6 head/sys/arm/freescale/imx/imx6_hdmi.c head/sys/conf/files.arm Modified: head/sys/arm/allwinner/files.allwinner ============================================================================== --- head/sys/arm/allwinner/files.allwinner Tue Dec 20 01:13:11 2016 (r310305) +++ head/sys/arm/allwinner/files.allwinner Tue Dec 20 01:34:29 2016 (r310306) @@ -35,7 +35,7 @@ arm/allwinner/aw_cir.c optional aw_cir arm/allwinner/a10_fb.c optional vt arm/allwinner/a10_hdmi.c optional hdmi arm/allwinner/a10_hdmiaudio.c optional hdmi sound -arm/arm/hdmi_if.m optional hdmi +dev/hdmi/hdmi_if.m optional hdmi arm/allwinner/aw_reset.c standard arm/allwinner/aw_ccu.c standard Modified: head/sys/arm/freescale/imx/files.imx6 ============================================================================== --- head/sys/arm/freescale/imx/files.imx6 Tue Dec 20 01:13:11 2016 (r310305) +++ head/sys/arm/freescale/imx/files.imx6 Tue Dec 20 01:34:29 2016 (r310306) @@ -24,7 +24,8 @@ arm/freescale/imx/imx6_sdma.c optional arm/freescale/imx/imx6_audmux.c optional sound arm/freescale/imx/imx6_ssi.c optional sound -arm/arm/hdmi_if.m optional hdmi +dev/hdmi/hdmi_if.m optional hdmi +dev/hdmi/dwc_hdmi.c optional hdmi arm/freescale/imx/imx6_hdmi.c optional hdmi arm/freescale/imx/imx6_ipu.c optional vt Modified: head/sys/arm/freescale/imx/imx6_hdmi.c ============================================================================== --- head/sys/arm/freescale/imx/imx6_hdmi.c Tue Dec 20 01:13:11 2016 (r310305) +++ head/sys/arm/freescale/imx/imx6_hdmi.c Tue Dec 20 01:34:29 2016 (r310306) @@ -44,30 +44,18 @@ __FBSDID("$FreeBSD$"); #include #include -#include - -#include -#include #include #include #include -#include -#include "hdmi_if.h" +#include -#define I2C_DDC_ADDR (0x50 << 1) -#define EDID_LENGTH 0x80 +#include "hdmi_if.h" struct imx_hdmi_softc { - device_t sc_dev; - struct resource *sc_mem_res; - int sc_mem_rid; - struct intr_config_hook sc_mode_hook; - struct videomode sc_mode; - uint8_t *sc_edid; - uint8_t sc_edid_len; - phandle_t sc_i2c_xref; + struct dwc_hdmi_softc base; + phandle_t i2c_xref; }; static struct ofw_compat_data compat_data[] = { @@ -76,565 +64,17 @@ static struct ofw_compat_data compat_dat {NULL, 0} }; -static inline uint8_t -RD1(struct imx_hdmi_softc *sc, bus_size_t off) -{ - - return (bus_read_1(sc->sc_mem_res, off)); -} - -static inline void -WR1(struct imx_hdmi_softc *sc, bus_size_t off, uint8_t val) -{ - - bus_write_1(sc->sc_mem_res, off, val); -} - -static void -imx_hdmi_phy_wait_i2c_done(struct imx_hdmi_softc *sc, int msec) -{ - uint8_t val; - - val = RD1(sc, HDMI_IH_I2CMPHY_STAT0) & - (HDMI_IH_I2CMPHY_STAT0_DONE | HDMI_IH_I2CMPHY_STAT0_ERROR); - while (val == 0) { - pause("HDMI_PHY", hz/100); - msec -= 10; - if (msec <= 0) - return; - val = RD1(sc, HDMI_IH_I2CMPHY_STAT0) & - (HDMI_IH_I2CMPHY_STAT0_DONE | HDMI_IH_I2CMPHY_STAT0_ERROR); - } -} - -static void -imx_hdmi_phy_i2c_write(struct imx_hdmi_softc *sc, unsigned short data, - unsigned char addr) -{ - - /* clear DONE and ERROR flags */ - WR1(sc, HDMI_IH_I2CMPHY_STAT0, - HDMI_IH_I2CMPHY_STAT0_DONE | HDMI_IH_I2CMPHY_STAT0_ERROR); - WR1(sc, HDMI_PHY_I2CM_ADDRESS_ADDR, addr); - WR1(sc, HDMI_PHY_I2CM_DATAO_1_ADDR, ((data >> 8) & 0xff)); - WR1(sc, HDMI_PHY_I2CM_DATAO_0_ADDR, ((data >> 0) & 0xff)); - WR1(sc, HDMI_PHY_I2CM_OPERATION_ADDR, HDMI_PHY_I2CM_OPERATION_ADDR_WRITE); - imx_hdmi_phy_wait_i2c_done(sc, 1000); -} - -static void -imx_hdmi_disable_overflow_interrupts(struct imx_hdmi_softc *sc) -{ - WR1(sc, HDMI_IH_MUTE_FC_STAT2, HDMI_IH_MUTE_FC_STAT2_OVERFLOW_MASK); - WR1(sc, HDMI_FC_MASK2, - HDMI_FC_MASK2_LOW_PRI | HDMI_FC_MASK2_HIGH_PRI); -} - -static void -imx_hdmi_av_composer(struct imx_hdmi_softc *sc) -{ - uint8_t inv_val; - int is_dvi; - int hblank, vblank, hsync_len, hbp, vbp; - - /* Set up HDMI_FC_INVIDCONF */ - inv_val = ((sc->sc_mode.flags & VID_NVSYNC) ? - HDMI_FC_INVIDCONF_VSYNC_IN_POLARITY_ACTIVE_LOW : - HDMI_FC_INVIDCONF_VSYNC_IN_POLARITY_ACTIVE_HIGH); - - inv_val |= ((sc->sc_mode.flags & VID_NHSYNC) ? - HDMI_FC_INVIDCONF_HSYNC_IN_POLARITY_ACTIVE_LOW : - HDMI_FC_INVIDCONF_HSYNC_IN_POLARITY_ACTIVE_HIGH); - - inv_val |= HDMI_FC_INVIDCONF_DE_IN_POLARITY_ACTIVE_HIGH; - - inv_val |= ((sc->sc_mode.flags & VID_INTERLACE) ? - HDMI_FC_INVIDCONF_R_V_BLANK_IN_OSC_ACTIVE_HIGH : - HDMI_FC_INVIDCONF_R_V_BLANK_IN_OSC_ACTIVE_LOW); - - inv_val |= ((sc->sc_mode.flags & VID_INTERLACE) ? - HDMI_FC_INVIDCONF_IN_I_P_INTERLACED : - HDMI_FC_INVIDCONF_IN_I_P_PROGRESSIVE); - - /* TODO: implement HDMI part */ - is_dvi = 1; - inv_val |= (is_dvi ? - HDMI_FC_INVIDCONF_DVI_MODEZ_DVI_MODE : - HDMI_FC_INVIDCONF_DVI_MODEZ_HDMI_MODE); - - WR1(sc, HDMI_FC_INVIDCONF, inv_val); - - /* Set up horizontal active pixel region width */ - WR1(sc, HDMI_FC_INHACTV1, sc->sc_mode.hdisplay >> 8); - WR1(sc, HDMI_FC_INHACTV0, sc->sc_mode.hdisplay); - - /* Set up vertical blanking pixel region width */ - WR1(sc, HDMI_FC_INVACTV1, sc->sc_mode.vdisplay >> 8); - WR1(sc, HDMI_FC_INVACTV0, sc->sc_mode.vdisplay); - - /* Set up horizontal blanking pixel region width */ - hblank = sc->sc_mode.htotal - sc->sc_mode.hdisplay; - WR1(sc, HDMI_FC_INHBLANK1, hblank >> 8); - WR1(sc, HDMI_FC_INHBLANK0, hblank); - - /* Set up vertical blanking pixel region width */ - vblank = sc->sc_mode.vtotal - sc->sc_mode.vdisplay; - WR1(sc, HDMI_FC_INVBLANK, vblank); - - /* Set up HSYNC active edge delay width (in pixel clks) */ - hbp = sc->sc_mode.htotal - sc->sc_mode.hsync_end; - WR1(sc, HDMI_FC_HSYNCINDELAY1, hbp >> 8); - WR1(sc, HDMI_FC_HSYNCINDELAY0, hbp); - - /* Set up VSYNC active edge delay (in pixel clks) */ - vbp = sc->sc_mode.vtotal - sc->sc_mode.vsync_end; - WR1(sc, HDMI_FC_VSYNCINDELAY, vbp); - - hsync_len = (sc->sc_mode.hsync_end - sc->sc_mode.hsync_start); - /* Set up HSYNC active pulse width (in pixel clks) */ - WR1(sc, HDMI_FC_HSYNCINWIDTH1, hsync_len >> 8); - WR1(sc, HDMI_FC_HSYNCINWIDTH0, hsync_len); - - /* Set up VSYNC active edge delay (in pixel clks) */ - WR1(sc, HDMI_FC_VSYNCINWIDTH, (sc->sc_mode.vsync_end - sc->sc_mode.vsync_start)); -} - -static void -imx_hdmi_phy_enable_power(struct imx_hdmi_softc *sc, uint8_t enable) -{ - uint8_t reg; - - reg = RD1(sc, HDMI_PHY_CONF0); - reg &= ~HDMI_PHY_CONF0_PDZ_MASK; - reg |= (enable << HDMI_PHY_CONF0_PDZ_OFFSET); - WR1(sc, HDMI_PHY_CONF0, reg); -} - -static void -imx_hdmi_phy_enable_tmds(struct imx_hdmi_softc *sc, uint8_t enable) -{ - uint8_t reg; - - reg = RD1(sc, HDMI_PHY_CONF0); - reg &= ~HDMI_PHY_CONF0_ENTMDS_MASK; - reg |= (enable << HDMI_PHY_CONF0_ENTMDS_OFFSET); - WR1(sc, HDMI_PHY_CONF0, reg); -} - -static void -imx_hdmi_phy_gen2_pddq(struct imx_hdmi_softc *sc, uint8_t enable) -{ - uint8_t reg; - - reg = RD1(sc, HDMI_PHY_CONF0); - reg &= ~HDMI_PHY_CONF0_GEN2_PDDQ_MASK; - reg |= (enable << HDMI_PHY_CONF0_GEN2_PDDQ_OFFSET); - WR1(sc, HDMI_PHY_CONF0, reg); -} - -static void -imx_hdmi_phy_gen2_txpwron(struct imx_hdmi_softc *sc, uint8_t enable) -{ - uint8_t reg; - - reg = RD1(sc, HDMI_PHY_CONF0); - reg &= ~HDMI_PHY_CONF0_GEN2_TXPWRON_MASK; - reg |= (enable << HDMI_PHY_CONF0_GEN2_TXPWRON_OFFSET); - WR1(sc, HDMI_PHY_CONF0, reg); -} - -static void -imx_hdmi_phy_sel_data_en_pol(struct imx_hdmi_softc *sc, uint8_t enable) -{ - uint8_t reg; - - reg = RD1(sc, HDMI_PHY_CONF0); - reg &= ~HDMI_PHY_CONF0_SELDATAENPOL_MASK; - reg |= (enable << HDMI_PHY_CONF0_SELDATAENPOL_OFFSET); - WR1(sc, HDMI_PHY_CONF0, reg); -} - -static void -imx_hdmi_phy_sel_interface_control(struct imx_hdmi_softc *sc, uint8_t enable) -{ - uint8_t reg; - - reg = RD1(sc, HDMI_PHY_CONF0); - reg &= ~HDMI_PHY_CONF0_SELDIPIF_MASK; - reg |= (enable << HDMI_PHY_CONF0_SELDIPIF_OFFSET); - WR1(sc, HDMI_PHY_CONF0, reg); -} - -static inline void -imx_hdmi_phy_test_clear(struct imx_hdmi_softc *sc, unsigned char bit) -{ - uint8_t val; - - val = RD1(sc, HDMI_PHY_TST0); - val &= ~HDMI_PHY_TST0_TSTCLR_MASK; - val |= (bit << HDMI_PHY_TST0_TSTCLR_OFFSET) & - HDMI_PHY_TST0_TSTCLR_MASK; - WR1(sc, HDMI_PHY_TST0, val); -} - -static void -imx_hdmi_clear_overflow(struct imx_hdmi_softc *sc) -{ - int count; - uint8_t val; - - /* TMDS software reset */ - WR1(sc, HDMI_MC_SWRSTZ, (uint8_t)~HDMI_MC_SWRSTZ_TMDSSWRST_REQ); - - val = RD1(sc, HDMI_FC_INVIDCONF); - - for (count = 0 ; count < 5 ; count++) - WR1(sc, HDMI_FC_INVIDCONF, val); -} - -static int -imx_hdmi_phy_configure(struct imx_hdmi_softc *sc) -{ - uint8_t val; - uint8_t msec; - - WR1(sc, HDMI_MC_FLOWCTRL, HDMI_MC_FLOWCTRL_FEED_THROUGH_OFF_CSC_BYPASS); - - /* gen2 tx power off */ - imx_hdmi_phy_gen2_txpwron(sc, 0); - - /* gen2 pddq */ - imx_hdmi_phy_gen2_pddq(sc, 1); - - /* PHY reset */ - WR1(sc, HDMI_MC_PHYRSTZ, HDMI_MC_PHYRSTZ_DEASSERT); - WR1(sc, HDMI_MC_PHYRSTZ, HDMI_MC_PHYRSTZ_ASSERT); - - WR1(sc, HDMI_MC_HEACPHY_RST, HDMI_MC_HEACPHY_RST_ASSERT); - - imx_hdmi_phy_test_clear(sc, 1); - WR1(sc, HDMI_PHY_I2CM_SLAVE_ADDR, HDMI_PHY_I2CM_SLAVE_ADDR_PHY_GEN2); - imx_hdmi_phy_test_clear(sc, 0); - - /* - * Following initialization are for 8bit per color case - */ - - /* - * PLL/MPLL config, see section 24.7.22 in TRM - * config, see section 24.7.22 - */ - if (sc->sc_mode.dot_clock*1000 <= 45250000) { - imx_hdmi_phy_i2c_write(sc, CPCE_CTRL_45_25, HDMI_PHY_I2C_CPCE_CTRL); - imx_hdmi_phy_i2c_write(sc, GMPCTRL_45_25, HDMI_PHY_I2C_GMPCTRL); - } else if (sc->sc_mode.dot_clock*1000 <= 92500000) { - imx_hdmi_phy_i2c_write(sc, CPCE_CTRL_92_50, HDMI_PHY_I2C_CPCE_CTRL); - imx_hdmi_phy_i2c_write(sc, GMPCTRL_92_50, HDMI_PHY_I2C_GMPCTRL); - } else if (sc->sc_mode.dot_clock*1000 <= 185000000) { - imx_hdmi_phy_i2c_write(sc, CPCE_CTRL_185, HDMI_PHY_I2C_CPCE_CTRL); - imx_hdmi_phy_i2c_write(sc, GMPCTRL_185, HDMI_PHY_I2C_GMPCTRL); - } else { - imx_hdmi_phy_i2c_write(sc, CPCE_CTRL_370, HDMI_PHY_I2C_CPCE_CTRL); - imx_hdmi_phy_i2c_write(sc, GMPCTRL_370, HDMI_PHY_I2C_GMPCTRL); - } - - /* - * Values described in TRM section 34.9.2 PLL/MPLL Generic - * Configuration Settings. Table 34-23. - */ - if (sc->sc_mode.dot_clock*1000 <= 54000000) { - imx_hdmi_phy_i2c_write(sc, 0x091c, HDMI_PHY_I2C_CURRCTRL); - } else if (sc->sc_mode.dot_clock*1000 <= 58400000) { - imx_hdmi_phy_i2c_write(sc, 0x091c, HDMI_PHY_I2C_CURRCTRL); - } else if (sc->sc_mode.dot_clock*1000 <= 72000000) { - imx_hdmi_phy_i2c_write(sc, 0x06dc, HDMI_PHY_I2C_CURRCTRL); - } else if (sc->sc_mode.dot_clock*1000 <= 74250000) { - imx_hdmi_phy_i2c_write(sc, 0x06dc, HDMI_PHY_I2C_CURRCTRL); - } else if (sc->sc_mode.dot_clock*1000 <= 118800000) { - imx_hdmi_phy_i2c_write(sc, 0x091c, HDMI_PHY_I2C_CURRCTRL); - } else if (sc->sc_mode.dot_clock*1000 <= 216000000) { - imx_hdmi_phy_i2c_write(sc, 0x06dc, HDMI_PHY_I2C_CURRCTRL); - } else { - panic("Unsupported mode\n"); - } - - imx_hdmi_phy_i2c_write(sc, 0x0000, HDMI_PHY_I2C_PLLPHBYCTRL); - imx_hdmi_phy_i2c_write(sc, MSM_CTRL_FB_CLK, HDMI_PHY_I2C_MSM_CTRL); - /* RESISTANCE TERM 133 Ohm */ - imx_hdmi_phy_i2c_write(sc, TXTERM_133, HDMI_PHY_I2C_TXTERM); - - /* REMOVE CLK TERM */ - imx_hdmi_phy_i2c_write(sc, CKCALCTRL_OVERRIDE, HDMI_PHY_I2C_CKCALCTRL); - - if (sc->sc_mode.dot_clock*1000 > 148500000) { - imx_hdmi_phy_i2c_write(sc,CKSYMTXCTRL_OVERRIDE | CKSYMTXCTRL_TX_SYMON | - CKSYMTXCTRL_TX_TRBON | CKSYMTXCTRL_TX_CK_SYMON, HDMI_PHY_I2C_CKSYMTXCTRL); - imx_hdmi_phy_i2c_write(sc, VLEVCTRL_TX_LVL(9) | VLEVCTRL_CK_LVL(9), - HDMI_PHY_I2C_VLEVCTRL); - } else { - imx_hdmi_phy_i2c_write(sc,CKSYMTXCTRL_OVERRIDE | CKSYMTXCTRL_TX_SYMON | - CKSYMTXCTRL_TX_TRAON | CKSYMTXCTRL_TX_CK_SYMON, HDMI_PHY_I2C_CKSYMTXCTRL); - imx_hdmi_phy_i2c_write(sc, VLEVCTRL_TX_LVL(13) | VLEVCTRL_CK_LVL(13), - HDMI_PHY_I2C_VLEVCTRL); - } - - imx_hdmi_phy_enable_power(sc, 1); - - /* toggle TMDS enable */ - imx_hdmi_phy_enable_tmds(sc, 0); - imx_hdmi_phy_enable_tmds(sc, 1); - - /* gen2 tx power on */ - imx_hdmi_phy_gen2_txpwron(sc, 1); - imx_hdmi_phy_gen2_pddq(sc, 0); - - /*Wait for PHY PLL lock */ - msec = 4; - val = RD1(sc, HDMI_PHY_STAT0) & HDMI_PHY_TX_PHY_LOCK; - while (val == 0) { - DELAY(1000); - if (msec-- == 0) { - device_printf(sc->sc_dev, "PHY PLL not locked\n"); - return (-1); - } - val = RD1(sc, HDMI_PHY_STAT0) & HDMI_PHY_TX_PHY_LOCK; - } - - return true; -} - -static void -imx_hdmi_phy_init(struct imx_hdmi_softc *sc) -{ - int i; - - /* HDMI Phy spec says to do the phy initialization sequence twice */ - for (i = 0 ; i < 2 ; i++) { - imx_hdmi_phy_sel_data_en_pol(sc, 1); - imx_hdmi_phy_sel_interface_control(sc, 0); - imx_hdmi_phy_enable_tmds(sc, 0); - imx_hdmi_phy_enable_power(sc, 0); - - /* Enable CSC */ - imx_hdmi_phy_configure(sc); - } -} - -static void -imx_hdmi_enable_video_path(struct imx_hdmi_softc *sc) -{ - uint8_t clkdis; - - /* - * Control period timing - * Values are minimal according to HDMI spec 1.4a - */ - WR1(sc, HDMI_FC_CTRLDUR, 12); - WR1(sc, HDMI_FC_EXCTRLDUR, 32); - WR1(sc, HDMI_FC_EXCTRLSPAC, 1); - - /* - * Bits to fill data lines not used to transmit preamble - * for channels 0, 1, and 2 respectively - */ - WR1(sc, HDMI_FC_CH0PREAM, 0x0B); - WR1(sc, HDMI_FC_CH1PREAM, 0x16); - WR1(sc, HDMI_FC_CH2PREAM, 0x21); - - /* Save CEC clock */ - clkdis = RD1(sc, HDMI_MC_CLKDIS) & HDMI_MC_CLKDIS_CECCLK_DISABLE; - clkdis |= ~HDMI_MC_CLKDIS_CECCLK_DISABLE; - - /* Enable pixel clock and tmds data path */ - clkdis &= ~HDMI_MC_CLKDIS_PIXELCLK_DISABLE; - WR1(sc, HDMI_MC_CLKDIS, clkdis); - - clkdis &= ~HDMI_MC_CLKDIS_TMDSCLK_DISABLE; - WR1(sc, HDMI_MC_CLKDIS, clkdis); -} - -static void -imx_hdmi_video_packetize(struct imx_hdmi_softc *sc) -{ - unsigned int color_depth = 0; - unsigned int remap_size = HDMI_VP_REMAP_YCC422_16BIT; - unsigned int output_select = HDMI_VP_CONF_OUTPUT_SELECTOR_PP; - uint8_t val; - - output_select = HDMI_VP_CONF_OUTPUT_SELECTOR_BYPASS; - color_depth = 0; - - /* set the packetizer registers */ - val = ((color_depth << HDMI_VP_PR_CD_COLOR_DEPTH_OFFSET) & - HDMI_VP_PR_CD_COLOR_DEPTH_MASK); - WR1(sc, HDMI_VP_PR_CD, val); - - val = RD1(sc, HDMI_VP_STUFF); - val &= ~HDMI_VP_STUFF_PR_STUFFING_MASK; - val |= HDMI_VP_STUFF_PR_STUFFING_STUFFING_MODE; - WR1(sc, HDMI_VP_STUFF, val); - - val = RD1(sc, HDMI_VP_CONF); - val &= ~(HDMI_VP_CONF_PR_EN_MASK | - HDMI_VP_CONF_BYPASS_SELECT_MASK); - val |= HDMI_VP_CONF_PR_EN_DISABLE | - HDMI_VP_CONF_BYPASS_SELECT_VID_PACKETIZER; - WR1(sc, HDMI_VP_CONF, val); - - val = RD1(sc, HDMI_VP_STUFF); - val &= ~HDMI_VP_STUFF_IDEFAULT_PHASE_MASK; - val |= 1 << HDMI_VP_STUFF_IDEFAULT_PHASE_OFFSET; - WR1(sc, HDMI_VP_STUFF, val); - - WR1(sc, HDMI_VP_REMAP, remap_size); - - if (output_select == HDMI_VP_CONF_OUTPUT_SELECTOR_PP) { - val = RD1(sc, HDMI_VP_CONF); - val &= ~(HDMI_VP_CONF_BYPASS_EN_MASK | - HDMI_VP_CONF_PP_EN_ENMASK | - HDMI_VP_CONF_YCC422_EN_MASK); - val |= HDMI_VP_CONF_BYPASS_EN_DISABLE | - HDMI_VP_CONF_PP_EN_ENABLE | - HDMI_VP_CONF_YCC422_EN_DISABLE; - WR1(sc, HDMI_VP_CONF, val); - } else if (output_select == HDMI_VP_CONF_OUTPUT_SELECTOR_YCC422) { - val = RD1(sc, HDMI_VP_CONF); - val &= ~(HDMI_VP_CONF_BYPASS_EN_MASK | - HDMI_VP_CONF_PP_EN_ENMASK | - HDMI_VP_CONF_YCC422_EN_MASK); - val |= HDMI_VP_CONF_BYPASS_EN_DISABLE | - HDMI_VP_CONF_PP_EN_DISABLE | - HDMI_VP_CONF_YCC422_EN_ENABLE; - WR1(sc, HDMI_VP_CONF, val); - } else if (output_select == HDMI_VP_CONF_OUTPUT_SELECTOR_BYPASS) { - val = RD1(sc, HDMI_VP_CONF); - val &= ~(HDMI_VP_CONF_BYPASS_EN_MASK | - HDMI_VP_CONF_PP_EN_ENMASK | - HDMI_VP_CONF_YCC422_EN_MASK); - val |= HDMI_VP_CONF_BYPASS_EN_ENABLE | - HDMI_VP_CONF_PP_EN_DISABLE | - HDMI_VP_CONF_YCC422_EN_DISABLE; - WR1(sc, HDMI_VP_CONF, val); - } else { - return; - } - - val = RD1(sc, HDMI_VP_STUFF); - val &= ~(HDMI_VP_STUFF_PP_STUFFING_MASK | - HDMI_VP_STUFF_YCC422_STUFFING_MASK); - val |= HDMI_VP_STUFF_PP_STUFFING_STUFFING_MODE | - HDMI_VP_STUFF_YCC422_STUFFING_STUFFING_MODE; - WR1(sc, HDMI_VP_STUFF, val); - - val = RD1(sc, HDMI_VP_CONF); - val &= ~HDMI_VP_CONF_OUTPUT_SELECTOR_MASK; - val |= output_select; - WR1(sc, HDMI_VP_CONF, val); -} - -static void -imx_hdmi_video_sample(struct imx_hdmi_softc *sc) -{ - int color_format; - uint8_t val; - - color_format = 0x01; - val = HDMI_TX_INVID0_INTERNAL_DE_GENERATOR_DISABLE | - ((color_format << HDMI_TX_INVID0_VIDEO_MAPPING_OFFSET) & - HDMI_TX_INVID0_VIDEO_MAPPING_MASK); - WR1(sc, HDMI_TX_INVID0, val); - - /* Enable TX stuffing: When DE is inactive, fix the output data to 0 */ - val = HDMI_TX_INSTUFFING_BDBDATA_STUFFING_ENABLE | - HDMI_TX_INSTUFFING_RCRDATA_STUFFING_ENABLE | - HDMI_TX_INSTUFFING_GYDATA_STUFFING_ENABLE; - WR1(sc, HDMI_TX_INSTUFFING, val); - WR1(sc, HDMI_TX_GYDATA0, 0x0); - WR1(sc, HDMI_TX_GYDATA1, 0x0); - WR1(sc, HDMI_TX_RCRDATA0, 0x0); - WR1(sc, HDMI_TX_RCRDATA1, 0x0); - WR1(sc, HDMI_TX_BCBDATA0, 0x0); - WR1(sc, HDMI_TX_BCBDATA1, 0x0); -} - -static int -imx_hdmi_set_mode(struct imx_hdmi_softc *sc) -{ - - imx_hdmi_disable_overflow_interrupts(sc); - imx_hdmi_av_composer(sc); - imx_hdmi_phy_init(sc); - imx_hdmi_enable_video_path(sc); - /* TODO: AVI infoframes */ - imx_hdmi_video_packetize(sc); - /* TODO: imx_hdmi_video_csc(sc); */ - imx_hdmi_video_sample(sc); - imx_hdmi_clear_overflow(sc); - - return (0); -} - -static int -hdmi_edid_read(struct imx_hdmi_softc *sc, uint8_t **edid, uint32_t *edid_len) +static device_t +imx_hdmi_get_i2c_dev(device_t dev) { - device_t i2c_dev; - int result; - uint8_t addr = 0; - struct iic_msg msg[] = { - { 0, IIC_M_WR, 1, &addr }, - { 0, IIC_M_RD, EDID_LENGTH, NULL} - }; - - *edid = NULL; - *edid_len = 0; - - if (sc->sc_i2c_xref == 0) - return (ENXIO); - - i2c_dev = OF_device_from_xref(sc->sc_i2c_xref); - if (!i2c_dev) { - device_printf(sc->sc_dev, - "no actual device for \"ddc-i2c-bus\" property (handle=%x)\n", sc->sc_i2c_xref); - return (ENXIO); - } - - device_printf(sc->sc_dev, "reading EDID from %s, addr %02x\n", - device_get_nameunit(i2c_dev), I2C_DDC_ADDR/2); - - msg[0].slave = I2C_DDC_ADDR; - msg[1].slave = I2C_DDC_ADDR; - msg[1].buf = sc->sc_edid; - - result = iicbus_request_bus(i2c_dev, sc->sc_dev, IIC_INTRWAIT); - - if (result) { - device_printf(sc->sc_dev, "failed to request i2c bus: %d\n", result); - return (result); - } - - result = iicbus_transfer(i2c_dev, msg, 2); - iicbus_release_bus(i2c_dev, sc->sc_dev); - - if (result) { - device_printf(sc->sc_dev, "i2c transfer failed: %d\n", result); - return (result); - } else { - *edid_len = sc->sc_edid_len; - *edid = sc->sc_edid; - } + struct imx_hdmi_softc *sc; - return (result); -} + sc = device_get_softc(dev); -static void -imx_hdmi_detect_cable(void *arg) -{ - struct imx_hdmi_softc *sc; + if (sc->i2c_xref == 0) + return (NULL); - sc = arg; - EVENTHANDLER_INVOKE(hdmi_event, sc->sc_dev, HDMI_EVENT_CONNECTED); - /* Finished with the interrupt hook */ - config_intrhook_disestablish(&sc->sc_mode_hook); + return (OF_device_from_xref(sc->i2c_xref)); } static int @@ -644,9 +84,9 @@ imx_hdmi_detach(device_t dev) sc = device_get_softc(dev); - if (sc->sc_mem_res != NULL) + if (sc->base.sc_mem_res != NULL) bus_release_resource(dev, SYS_RES_MEMORY, - sc->sc_mem_rid, sc->sc_mem_res); + sc->base.sc_mem_rid, sc->base.sc_mem_res); return (0); } @@ -660,55 +100,37 @@ imx_hdmi_attach(device_t dev) phandle_t node, i2c_xref; sc = device_get_softc(dev); - sc->sc_dev = dev; + sc->base.sc_dev = dev; + sc->base.sc_get_i2c_dev = imx_hdmi_get_i2c_dev; err = 0; /* Allocate memory resources. */ - sc->sc_mem_rid = 0; - sc->sc_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->sc_mem_rid, - RF_ACTIVE); - if (sc->sc_mem_res == NULL) { + sc->base.sc_mem_rid = 0; + sc->base.sc_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, + &sc->base.sc_mem_rid, RF_ACTIVE); + if (sc->base.sc_mem_res == NULL) { device_printf(dev, "Cannot allocate memory resources\n"); err = ENXIO; goto out; } - sc->sc_mode_hook.ich_func = imx_hdmi_detect_cable; - sc->sc_mode_hook.ich_arg = sc; - - if (config_intrhook_establish(&sc->sc_mode_hook) != 0) { - err = ENOMEM; - goto out; - } - node = ofw_bus_get_node(dev); if (OF_getencprop(node, "ddc-i2c-bus", &i2c_xref, sizeof(i2c_xref)) == -1) - sc->sc_i2c_xref = 0; + sc->i2c_xref = 0; else - sc->sc_i2c_xref = i2c_xref; - - sc->sc_edid = malloc(EDID_LENGTH, M_DEVBUF, M_WAITOK | M_ZERO); - sc->sc_edid_len = EDID_LENGTH; + sc->i2c_xref = i2c_xref; imx_ccm_hdmi_enable(); - device_printf(sc->sc_dev, "HDMI controller %02x:%02x:%02x:%02x\n", - RD1(sc, HDMI_DESIGN_ID), RD1(sc, HDMI_REVISION_ID), - RD1(sc, HDMI_PRODUCT_ID0), RD1(sc, HDMI_PRODUCT_ID1)); - - gpr3 = imx_iomux_gpr_get(IOMUXC_GPR3); gpr3 &= ~(IOMUXC_GPR3_HDMI_MASK); gpr3 |= IOMUXC_GPR3_HDMI_IPU1_DI0; imx_iomux_gpr_set(IOMUXC_GPR3, gpr3); - WR1(sc, HDMI_PHY_POL0, HDMI_PHY_HPD); - WR1(sc, HDMI_IH_PHY_STAT0, HDMI_IH_PHY_STAT0_HPD); + return (dwc_hdmi_init(dev)); out: - - if (err != 0) - imx_hdmi_detach(dev); + imx_hdmi_detach(dev); return (err); } @@ -725,25 +147,6 @@ imx_hdmi_probe(device_t dev) return (BUS_PROBE_DEFAULT); } -static int -imx_hdmi_get_edid(device_t dev, uint8_t **edid, uint32_t *edid_len) -{ - - return (hdmi_edid_read(device_get_softc(dev), edid, edid_len)); -} - -static int -imx_hdmi_set_videomode(device_t dev, const struct videomode *mode) -{ - struct imx_hdmi_softc *sc; - - sc = device_get_softc(dev); - memcpy(&sc->sc_mode, mode, sizeof(*mode)); - imx_hdmi_set_mode(sc); - - return (0); -} - static device_method_t imx_hdmi_methods[] = { /* Device interface */ DEVMETHOD(device_probe, imx_hdmi_probe), @@ -751,8 +154,8 @@ static device_method_t imx_hdmi_methods[ DEVMETHOD(device_detach, imx_hdmi_detach), /* HDMI methods */ - DEVMETHOD(hdmi_get_edid, imx_hdmi_get_edid), - DEVMETHOD(hdmi_set_videomode, imx_hdmi_set_videomode), + DEVMETHOD(hdmi_get_edid, dwc_hdmi_get_edid), + DEVMETHOD(hdmi_set_videomode, dwc_hdmi_set_videomode), DEVMETHOD_END }; Modified: head/sys/conf/files.arm ============================================================================== --- head/sys/conf/files.arm Tue Dec 20 01:13:11 2016 (r310305) +++ head/sys/conf/files.arm Tue Dec 20 01:34:29 2016 (r310306) @@ -60,7 +60,6 @@ arm/arm/gdb_machdep.c optional gdb arm/arm/generic_timer.c optional generic_timer arm/arm/gic.c optional gic arm/arm/gic_fdt.c optional gic fdt -arm/arm/hdmi_if.m optional hdmi arm/arm/identcpu-v4.c optional !armv6 arm/arm/identcpu-v6.c optional armv6 arm/arm/in_cksum.c optional inet | inet6 @@ -120,6 +119,7 @@ dev/dwc/if_dwc.c optional dwc dev/dwc/if_dwc_if.m optional dwc dev/fb/fb.c optional sc dev/fdt/fdt_arm_platform.c optional platform fdt +dev/hdmi/hdmi_if.m optional hdmi dev/hwpmc/hwpmc_arm.c optional hwpmc dev/hwpmc/hwpmc_armv7.c optional hwpmc armv6 dev/iicbus/twsi/twsi.c optional twsi Added: head/sys/dev/hdmi/dwc_hdmi.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/hdmi/dwc_hdmi.c Tue Dec 20 01:34:29 2016 (r310306) @@ -0,0 +1,691 @@ +/*- + * Copyright (c) 2015 Oleksandr Tymoshenko + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +/* + * HDMI core module + */ + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include + +#include +#include + +#include "hdmi_if.h" + +#define I2C_DDC_ADDR (0x50 << 1) +#define EDID_LENGTH 0x80 + +static void +dwc_hdmi_phy_wait_i2c_done(struct dwc_hdmi_softc *sc, int msec) +{ + uint8_t val; + + val = RD1(sc, HDMI_IH_I2CMPHY_STAT0) & + (HDMI_IH_I2CMPHY_STAT0_DONE | HDMI_IH_I2CMPHY_STAT0_ERROR); + while (val == 0) { + pause("HDMI_PHY", hz/100); + msec -= 10; + if (msec <= 0) + return; + val = RD1(sc, HDMI_IH_I2CMPHY_STAT0) & + (HDMI_IH_I2CMPHY_STAT0_DONE | HDMI_IH_I2CMPHY_STAT0_ERROR); + } +} + +static void +dwc_hdmi_phy_i2c_write(struct dwc_hdmi_softc *sc, unsigned short data, + unsigned char addr) +{ + + /* clear DONE and ERROR flags */ + WR1(sc, HDMI_IH_I2CMPHY_STAT0, + HDMI_IH_I2CMPHY_STAT0_DONE | HDMI_IH_I2CMPHY_STAT0_ERROR); + WR1(sc, HDMI_PHY_I2CM_ADDRESS_ADDR, addr); + WR1(sc, HDMI_PHY_I2CM_DATAO_1_ADDR, ((data >> 8) & 0xff)); + WR1(sc, HDMI_PHY_I2CM_DATAO_0_ADDR, ((data >> 0) & 0xff)); + WR1(sc, HDMI_PHY_I2CM_OPERATION_ADDR, HDMI_PHY_I2CM_OPERATION_ADDR_WRITE); + dwc_hdmi_phy_wait_i2c_done(sc, 1000); +} + +static void +dwc_hdmi_disable_overflow_interrupts(struct dwc_hdmi_softc *sc) +{ + WR1(sc, HDMI_IH_MUTE_FC_STAT2, HDMI_IH_MUTE_FC_STAT2_OVERFLOW_MASK); + WR1(sc, HDMI_FC_MASK2, + HDMI_FC_MASK2_LOW_PRI | HDMI_FC_MASK2_HIGH_PRI); +} + +static void +dwc_hdmi_av_composer(struct dwc_hdmi_softc *sc) +{ + uint8_t inv_val; + int is_dvi; + int hblank, vblank, hsync_len, hfp, vfp; + + /* Set up HDMI_FC_INVIDCONF */ + inv_val = ((sc->sc_mode.flags & VID_PVSYNC) ? + HDMI_FC_INVIDCONF_VSYNC_IN_POLARITY_ACTIVE_HIGH : + HDMI_FC_INVIDCONF_VSYNC_IN_POLARITY_ACTIVE_LOW); + + inv_val |= ((sc->sc_mode.flags & VID_PHSYNC) ? + HDMI_FC_INVIDCONF_HSYNC_IN_POLARITY_ACTIVE_HIGH : + HDMI_FC_INVIDCONF_HSYNC_IN_POLARITY_ACTIVE_LOW); + + inv_val |= HDMI_FC_INVIDCONF_DE_IN_POLARITY_ACTIVE_HIGH; + + inv_val |= ((sc->sc_mode.flags & VID_INTERLACE) ? + HDMI_FC_INVIDCONF_R_V_BLANK_IN_OSC_ACTIVE_HIGH : + HDMI_FC_INVIDCONF_R_V_BLANK_IN_OSC_ACTIVE_LOW); + + inv_val |= ((sc->sc_mode.flags & VID_INTERLACE) ? + HDMI_FC_INVIDCONF_IN_I_P_INTERLACED : + HDMI_FC_INVIDCONF_IN_I_P_PROGRESSIVE); + + /* TODO: implement HDMI part */ + is_dvi = 1; + inv_val |= (is_dvi ? + HDMI_FC_INVIDCONF_DVI_MODEZ_DVI_MODE : + HDMI_FC_INVIDCONF_DVI_MODEZ_HDMI_MODE); + + WR1(sc, HDMI_FC_INVIDCONF, inv_val); + + /* Set up horizontal active pixel region width */ + WR1(sc, HDMI_FC_INHACTV1, sc->sc_mode.hdisplay >> 8); + WR1(sc, HDMI_FC_INHACTV0, sc->sc_mode.hdisplay); + + /* Set up vertical blanking pixel region width */ + WR1(sc, HDMI_FC_INVACTV1, sc->sc_mode.vdisplay >> 8); + WR1(sc, HDMI_FC_INVACTV0, sc->sc_mode.vdisplay); + + /* Set up horizontal blanking pixel region width */ + hblank = sc->sc_mode.htotal - sc->sc_mode.hdisplay; + WR1(sc, HDMI_FC_INHBLANK1, hblank >> 8); + WR1(sc, HDMI_FC_INHBLANK0, hblank); + + /* Set up vertical blanking pixel region width */ + vblank = sc->sc_mode.vtotal - sc->sc_mode.vdisplay; + WR1(sc, HDMI_FC_INVBLANK, vblank); + + /* Set up HSYNC active edge delay width (in pixel clks) */ + hfp = sc->sc_mode.hsync_start - sc->sc_mode.hdisplay; + WR1(sc, HDMI_FC_HSYNCINDELAY1, hfp >> 8); + WR1(sc, HDMI_FC_HSYNCINDELAY0, hfp); + + /* Set up VSYNC active edge delay (in pixel clks) */ + vfp = sc->sc_mode.vsync_start - sc->sc_mode.vdisplay; + WR1(sc, HDMI_FC_VSYNCINDELAY, vfp); + + hsync_len = (sc->sc_mode.hsync_end - sc->sc_mode.hsync_start); + /* Set up HSYNC active pulse width (in pixel clks) */ + WR1(sc, HDMI_FC_HSYNCINWIDTH1, hsync_len >> 8); + WR1(sc, HDMI_FC_HSYNCINWIDTH0, hsync_len); + + /* Set up VSYNC active edge delay (in pixel clks) */ + WR1(sc, HDMI_FC_VSYNCINWIDTH, (sc->sc_mode.vsync_end - sc->sc_mode.vsync_start)); +} + +static void +dwc_hdmi_phy_enable_power(struct dwc_hdmi_softc *sc, uint8_t enable) +{ + uint8_t reg; + + reg = RD1(sc, HDMI_PHY_CONF0); + reg &= ~HDMI_PHY_CONF0_PDZ_MASK; + reg |= (enable << HDMI_PHY_CONF0_PDZ_OFFSET); + WR1(sc, HDMI_PHY_CONF0, reg); +} + +static void +dwc_hdmi_phy_enable_tmds(struct dwc_hdmi_softc *sc, uint8_t enable) +{ + uint8_t reg; + + reg = RD1(sc, HDMI_PHY_CONF0); + reg &= ~HDMI_PHY_CONF0_ENTMDS_MASK; + reg |= (enable << HDMI_PHY_CONF0_ENTMDS_OFFSET); + WR1(sc, HDMI_PHY_CONF0, reg); +} + +static void +dwc_hdmi_phy_gen2_pddq(struct dwc_hdmi_softc *sc, uint8_t enable) +{ + uint8_t reg; + + reg = RD1(sc, HDMI_PHY_CONF0); + reg &= ~HDMI_PHY_CONF0_GEN2_PDDQ_MASK; + reg |= (enable << HDMI_PHY_CONF0_GEN2_PDDQ_OFFSET); + WR1(sc, HDMI_PHY_CONF0, reg); +} + +static void +dwc_hdmi_phy_gen2_txpwron(struct dwc_hdmi_softc *sc, uint8_t enable) +{ + uint8_t reg; + + reg = RD1(sc, HDMI_PHY_CONF0); + reg &= ~HDMI_PHY_CONF0_GEN2_TXPWRON_MASK; + reg |= (enable << HDMI_PHY_CONF0_GEN2_TXPWRON_OFFSET); + WR1(sc, HDMI_PHY_CONF0, reg); +} + +static void +dwc_hdmi_phy_sel_data_en_pol(struct dwc_hdmi_softc *sc, uint8_t enable) +{ + uint8_t reg; + + reg = RD1(sc, HDMI_PHY_CONF0); + reg &= ~HDMI_PHY_CONF0_SELDATAENPOL_MASK; + reg |= (enable << HDMI_PHY_CONF0_SELDATAENPOL_OFFSET); + WR1(sc, HDMI_PHY_CONF0, reg); +} + +static void +dwc_hdmi_phy_sel_interface_control(struct dwc_hdmi_softc *sc, uint8_t enable) +{ + uint8_t reg; + + reg = RD1(sc, HDMI_PHY_CONF0); + reg &= ~HDMI_PHY_CONF0_SELDIPIF_MASK; + reg |= (enable << HDMI_PHY_CONF0_SELDIPIF_OFFSET); + WR1(sc, HDMI_PHY_CONF0, reg); +} *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@freebsd.org Tue Dec 20 01:37:02 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 098BFC88823; Tue, 20 Dec 2016 01:37:02 +0000 (UTC) (envelope-from jmcneill@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 C8944F47; Tue, 20 Dec 2016 01:37:01 +0000 (UTC) (envelope-from jmcneill@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBK1b0Rq090097; Tue, 20 Dec 2016 01:37:00 GMT (envelope-from jmcneill@FreeBSD.org) Received: (from jmcneill@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBK1b0BX090096; Tue, 20 Dec 2016 01:37:00 GMT (envelope-from jmcneill@FreeBSD.org) Message-Id: <201612200137.uBK1b0BX090096@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jmcneill set sender to jmcneill@FreeBSD.org using -f From: Jared McNeill Date: Tue, 20 Dec 2016 01:37:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310307 - head/sys/mips/ingenic X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 20 Dec 2016 01:37:02 -0000 Author: jmcneill Date: Tue Dec 20 01:37:00 2016 New Revision: 310307 URL: https://svnweb.freebsd.org/changeset/base/310307 Log: Choose the closes matching divider instead of one that results in a frequency >= target. Fix inverted rounding logic for CLK_SET_ROUND_UP/DOWN. Reviewed by: kan Differential Revision: https://reviews.freebsd.org/D8784 Modified: head/sys/mips/ingenic/jz4780_clk_gen.c Modified: head/sys/mips/ingenic/jz4780_clk_gen.c ============================================================================== --- head/sys/mips/ingenic/jz4780_clk_gen.c Tue Dec 20 01:34:29 2016 (r310306) +++ head/sys/mips/ingenic/jz4780_clk_gen.c Tue Dec 20 01:37:00 2016 (r310307) @@ -153,23 +153,29 @@ jz4780_clk_gen_set_freq(struct clknode * { struct jz4780_clk_gen_sc *sc; uint64_t _fout; - uint32_t divider, div_reg, div_msk, reg; + uint32_t divider, div_reg, div_msk, reg, div_l, div_h; int rv; sc = clknode_get_softc(clk); - divider = fin / *fout; + /* Find closest divider */ + div_l = howmany(fin, *fout); + div_h = fin / *fout; + divider = abs((int64_t)*fout - (fin / div_l)) < + abs((int64_t)*fout - (fin / div_h)) ? div_l : div_h; /* Adjust for divider multiplier */ div_reg = divider >> sc->clk_descr->clk_div.div_lg; divider = div_reg << sc->clk_descr->clk_div.div_lg; + if (divider == 0) + divider = 1; _fout = fin / divider; /* Rounding */ - if ((flags & CLK_SET_ROUND_UP) && (*fout < _fout)) + if ((flags & CLK_SET_ROUND_UP) && (*fout > _fout)) div_reg--; - else if ((flags & CLK_SET_ROUND_DOWN) && (*fout > _fout)) + else if ((flags & CLK_SET_ROUND_DOWN) && (*fout < _fout)) div_reg++; if (div_reg == 0) div_reg = 1; From owner-svn-src-head@freebsd.org Tue Dec 20 01:51:11 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 256FBC89030; Tue, 20 Dec 2016 01:51:11 +0000 (UTC) (envelope-from jmcneill@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 E1F8018DA; Tue, 20 Dec 2016 01:51:10 +0000 (UTC) (envelope-from jmcneill@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBK1pARO098120; Tue, 20 Dec 2016 01:51:10 GMT (envelope-from jmcneill@FreeBSD.org) Received: (from jmcneill@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBK1p9oR098115; Tue, 20 Dec 2016 01:51:09 GMT (envelope-from jmcneill@FreeBSD.org) Message-Id: <201612200151.uBK1p9oR098115@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jmcneill set sender to jmcneill@FreeBSD.org using -f From: Jared McNeill Date: Tue, 20 Dec 2016 01:51:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310308 - in head/sys/mips: conf ingenic X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 20 Dec 2016 01:51:11 -0000 Author: jmcneill Date: Tue Dec 20 01:51:09 2016 New Revision: 310308 URL: https://svnweb.freebsd.org/changeset/base/310308 Log: Add support for Ingenic JZ4780 LCD controller and enable framebuffer console support. Reviewed by: kan Differential Revision: https://reviews.freebsd.org/D8827 Added: head/sys/mips/ingenic/jz4780_lcd.c (contents, props changed) head/sys/mips/ingenic/jz4780_lcd.h (contents, props changed) Modified: head/sys/mips/conf/JZ4780 head/sys/mips/ingenic/files.jz4780 Modified: head/sys/mips/conf/JZ4780 ============================================================================== --- head/sys/mips/conf/JZ4780 Tue Dec 20 01:37:00 2016 (r310307) +++ head/sys/mips/conf/JZ4780 Tue Dec 20 01:51:09 2016 (r310308) @@ -86,6 +86,16 @@ device mmcsd device dme +device iic +device iicbus + +# Framebuffer console support +device vt +device kbdmux +device hdmi +device videomode +device pty + # USB support options USB_DEBUG # enable debug msgs options USB_HOST_ALIGN=128 # L2 cache line size @@ -95,6 +105,7 @@ device dwcotg # DesignWare HS OTG cont device usb # USB Bus (required) #device udbp # USB Double Bulk Pipe devices device uhid # "Human Interface Devices" +device ukbd # Allow keyboard like HIDs to control console #device ulpt # Printer device umass # Disks/Mass storage - Requires scbus and da device ums # Mouse Modified: head/sys/mips/ingenic/files.jz4780 ============================================================================== --- head/sys/mips/ingenic/files.jz4780 Tue Dec 20 01:37:00 2016 (r310307) +++ head/sys/mips/ingenic/files.jz4780 Tue Dec 20 01:51:09 2016 (r310308) @@ -6,6 +6,9 @@ mips/ingenic/jz4780_mmc.c optional mmc mips/ingenic/jz4780_ohci.c optional ohci mips/ingenic/jz4780_smb.c optional iicbus mips/ingenic/jz4780_uart.c optional uart +mips/ingenic/jz4780_lcd.c optional vt +dev/hdmi/dwc_hdmi.c optional hdmi iicbus +dev/hdmi/dwc_hdmi_fdt.c optional hdmi iicbus mips/ingenic/jz4780_clock.c standard mips/ingenic/jz4780_clk_gen.c standard @@ -25,3 +28,6 @@ mips/ingenic/jz4780_mpboot.S optional sm # Custom interface between pinctrl and gpio mips/ingenic/jz4780_gpio_if.m standard + +# HDMI interface +dev/hdmi/hdmi_if.m standard Added: head/sys/mips/ingenic/jz4780_lcd.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/mips/ingenic/jz4780_lcd.c Tue Dec 20 01:51:09 2016 (r310308) @@ -0,0 +1,572 @@ +/*- + * Copyright (c) 2016 Jared McNeill + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +/* + * Ingenic JZ4780 LCD Controller + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include + +#include + +#include + +#include "fb_if.h" +#include "hdmi_if.h" + +#define FB_DEFAULT_W 800 +#define FB_DEFAULT_H 600 +#define FB_DEFAULT_REF 60 +#define FB_BPP 32 +#define FB_ALIGN (16 * 4) +#define FB_MAX_BW (1920 * 1080 * 60) +#define FB_MAX_W 2048 +#define FB_MAX_H 2048 +#define FB_DIVIDE(x, y) (((x) + ((y) / 2)) / (y)) + +#define PCFG_MAGIC 0xc7ff2100 + +#define DOT_CLOCK_TO_HZ(c) ((c) * 1000) + +#ifndef VM_MEMATTR_WRITE_COMBINING +#define VM_MEMATTR_WRITE_COMBINING VM_MEMATTR_UNCACHEABLE +#endif + +struct jzlcd_softc { + device_t dev; + device_t fbdev; + struct resource *res[1]; + + /* Clocks */ + clk_t clk; + clk_t clk_pix; + + /* Framebuffer */ + struct fb_info info; + size_t fbsize; + bus_addr_t paddr; + vm_offset_t vaddr; + + /* HDMI */ + eventhandler_tag hdmi_evh; + + /* Frame descriptor DMA */ + bus_dma_tag_t fdesc_tag; + bus_dmamap_t fdesc_map; + bus_addr_t fdesc_paddr; + struct lcd_frame_descriptor *fdesc; +}; + +static struct resource_spec jzlcd_spec[] = { + { SYS_RES_MEMORY, 0, RF_ACTIVE }, + { -1, 0 } +}; + +#define LCD_READ(sc, reg) bus_read_4((sc)->res[0], (reg)) +#define LCD_WRITE(sc, reg, val) bus_write_4((sc)->res[0], (reg), (val)) + +static int +jzlcd_allocfb(struct jzlcd_softc *sc) +{ + sc->vaddr = kmem_alloc_contig(kernel_arena, sc->fbsize, + M_NOWAIT | M_ZERO, 0, ~0, FB_ALIGN, 0, VM_MEMATTR_WRITE_COMBINING); + if (sc->vaddr == 0) { + device_printf(sc->dev, "failed to allocate FB memory\n"); + return (ENOMEM); + } + sc->paddr = pmap_kextract(sc->vaddr); + + return (0); +} + +static void +jzlcd_freefb(struct jzlcd_softc *sc) +{ + kmem_free(kernel_arena, sc->vaddr, sc->fbsize); +} + +static void +jzlcd_start(struct jzlcd_softc *sc) +{ + uint32_t ctrl; + + /* Clear status registers */ + LCD_WRITE(sc, LCDSTATE, 0); + LCD_WRITE(sc, LCDOSDS, 0); + /* Enable the controller */ + ctrl = LCD_READ(sc, LCDCTRL); + ctrl |= LCDCTRL_ENA; + ctrl &= ~LCDCTRL_DIS; + LCD_WRITE(sc, LCDCTRL, ctrl); +} + +static void +jzlcd_stop(struct jzlcd_softc *sc) +{ + uint32_t ctrl; + + ctrl = LCD_READ(sc, LCDCTRL); + if ((ctrl & LCDCTRL_ENA) != 0) { + /* Disable the controller and wait for it to stop */ + ctrl |= LCDCTRL_DIS; + LCD_WRITE(sc, LCDCTRL, ctrl); + while ((LCD_READ(sc, LCDSTATE) & LCDSTATE_LDD) == 0) + DELAY(100); + } + /* Clear all status except for disable */ + LCD_WRITE(sc, LCDSTATE, LCD_READ(sc, LCDSTATE) & ~LCDSTATE_LDD); +} + +static void +jzlcd_setup_descriptor(struct jzlcd_softc *sc, const struct videomode *mode, + u_int desno) +{ + struct lcd_frame_descriptor *fdesc; + int line_sz; + + /* Frame size is specified in # words */ + line_sz = (mode->hdisplay * FB_BPP) >> 3; + line_sz = ((line_sz + 3) & ~3) / 4; + + fdesc = sc->fdesc + desno; + + if (desno == 0) + fdesc->next = sc->fdesc_paddr + + sizeof(struct lcd_frame_descriptor); + else + fdesc->next = sc->fdesc_paddr; + fdesc->physaddr = sc->paddr; + fdesc->id = desno; + fdesc->cmd = LCDCMD_FRM_EN | (line_sz * mode->vdisplay); + fdesc->offs = 0; + fdesc->pw = 0; + fdesc->cnum_pos = LCDPOS_BPP01_18_24 | + LCDPOS_PREMULTI01 | + (desno == 0 ? LCDPOS_COEF_BLE01_1 : LCDPOS_COEF_SLE01); + fdesc->dessize = LCDDESSIZE_ALPHA | + ((mode->vdisplay - 1) << LCDDESSIZE_HEIGHT_SHIFT) | + ((mode->hdisplay - 1) << LCDDESSIZE_WIDTH_SHIFT); +} + +static int +jzlcd_set_videomode(struct jzlcd_softc *sc, const struct videomode *mode) +{ + u_int hbp, hfp, hsw, vbp, vfp, vsw; + u_int hds, hde, ht, vds, vde, vt; + uint32_t ctrl; + int error; + + hbp = mode->htotal - mode->hsync_end; + hfp = mode->hsync_start - mode->hdisplay; + hsw = mode->hsync_end - mode->hsync_start; + vbp = mode->vtotal - mode->vsync_end; + vfp = mode->vsync_start - mode->vdisplay; + vsw = mode->vsync_end - mode->vsync_start; + + hds = hsw + hbp; + hde = hds + mode->hdisplay; + ht = hde + hfp; + + vds = vsw + vbp; + vde = vds + mode->vdisplay; + vt = vde + vfp; + + /* Setup timings */ + LCD_WRITE(sc, LCDVAT, + (ht << LCDVAT_HT_SHIFT) | (vt << LCDVAT_VT_SHIFT)); + LCD_WRITE(sc, LCDDAH, + (hds << LCDDAH_HDS_SHIFT) | (hde << LCDDAH_HDE_SHIFT)); + LCD_WRITE(sc, LCDDAV, + (vds << LCDDAV_VDS_SHIFT) | (vde << LCDDAV_VDE_SHIFT)); + LCD_WRITE(sc, LCDHSYNC, hsw); + LCD_WRITE(sc, LCDVSYNC, vsw); + + /* Set configuration */ + LCD_WRITE(sc, LCDCFG, LCDCFG_NEWDES | LCDCFG_RECOVER | LCDCFG_24 | + LCDCFG_PSM | LCDCFG_CLSM | LCDCFG_SPLM | LCDCFG_REVM | LCDCFG_PCP); + ctrl = LCD_READ(sc, LCDCTRL); + ctrl &= ~LCDCTRL_BST; + ctrl |= LCDCTRL_BST_64 | LCDCTRL_OFUM; + LCD_WRITE(sc, LCDCTRL, ctrl); + LCD_WRITE(sc, LCDPCFG, PCFG_MAGIC); + LCD_WRITE(sc, LCDRGBC, LCDRGBC_RGBFMT); + + /* Update registers */ + LCD_WRITE(sc, LCDSTATE, 0); + + /* Setup frame descriptors */ + jzlcd_setup_descriptor(sc, mode, 0); + jzlcd_setup_descriptor(sc, mode, 1); + bus_dmamap_sync(sc->fdesc_tag, sc->fdesc_map, BUS_DMASYNC_PREWRITE); + + /* Setup DMA channels */ + LCD_WRITE(sc, LCDDA0, sc->fdesc_paddr + + sizeof(struct lcd_frame_descriptor)); + LCD_WRITE(sc, LCDDA1, sc->fdesc_paddr); + + /* Set display clock */ + error = clk_set_freq(sc->clk_pix, DOT_CLOCK_TO_HZ(mode->dot_clock), 0); + if (error != 0) { + device_printf(sc->dev, "failed to set pixel clock to %u Hz\n", + DOT_CLOCK_TO_HZ(mode->dot_clock)); + return (error); + } + + return (0); +} + +static int +jzlcd_configure(struct jzlcd_softc *sc, const struct videomode *mode) +{ + size_t fbsize; + int error; + + fbsize = round_page(mode->hdisplay * mode->vdisplay * (FB_BPP / NBBY)); + + /* Detach the old FB device */ + if (sc->fbdev != NULL) { + device_delete_child(sc->dev, sc->fbdev); + sc->fbdev = NULL; + } + + /* If the FB size has changed, free the old FB memory */ + if (sc->fbsize > 0 && sc->fbsize != fbsize) { + jzlcd_freefb(sc); + sc->vaddr = 0; + } + + /* Allocate the FB if necessary */ + sc->fbsize = fbsize; + if (sc->vaddr == 0) { + error = jzlcd_allocfb(sc); + if (error != 0) { + device_printf(sc->dev, "failed to allocate FB memory\n"); + return (ENXIO); + } + } + + /* Setup video mode */ + error = jzlcd_set_videomode(sc, mode); + if (error != 0) + return (error); + + /* Attach framebuffer device */ + sc->info.fb_name = device_get_nameunit(sc->dev); + sc->info.fb_vbase = (intptr_t)sc->vaddr; + sc->info.fb_pbase = sc->paddr; + sc->info.fb_size = sc->fbsize; + sc->info.fb_bpp = sc->info.fb_depth = FB_BPP; + sc->info.fb_stride = mode->hdisplay * (FB_BPP / NBBY); + sc->info.fb_width = mode->hdisplay; + sc->info.fb_height = mode->vdisplay; + + sc->fbdev = device_add_child(sc->dev, "fbd", device_get_unit(sc->dev)); + if (sc->fbdev == NULL) { + device_printf(sc->dev, "failed to add fbd child\n"); + return (ENOENT); + } + + error = device_probe_and_attach(sc->fbdev); + if (error != 0) { + device_printf(sc->dev, "failed to attach fbd device\n"); + return (error); + } + + return (0); +} + +static int +jzlcd_get_bandwidth(const struct videomode *mode) +{ + int refresh; + + refresh = FB_DIVIDE(FB_DIVIDE(DOT_CLOCK_TO_HZ(mode->dot_clock), + mode->htotal), mode->vtotal); + + return mode->hdisplay * mode->vdisplay * refresh; +} + +static int +jzlcd_mode_supported(const struct videomode *mode) +{ + /* Width and height must be less than 2048 */ + if (mode->hdisplay > FB_MAX_W || mode->vdisplay > FB_MAX_H) + return (0); + + /* Bandwidth check */ + if (jzlcd_get_bandwidth(mode) > FB_MAX_BW) + return (0); + + /* Interlace modes not yet supported by the driver */ + if ((mode->flags & VID_INTERLACE) != 0) + return (0); + + return (1); +} + +static const struct videomode * +jzlcd_find_mode(struct edid_info *ei) +{ + const struct videomode *best; + int n, bw, best_bw; + + /* If the preferred mode is OK, just use it */ + if (jzlcd_mode_supported(ei->edid_preferred_mode) != 0) + return ei->edid_preferred_mode; + + /* Pick the mode with the highest bandwidth requirements */ + best = NULL; + best_bw = 0; + for (n = 0; n < ei->edid_nmodes; n++) { + if (jzlcd_mode_supported(&ei->edid_modes[n]) == 0) + continue; + bw = jzlcd_get_bandwidth(&ei->edid_modes[n]); + if (bw > FB_MAX_BW) + continue; + if (best == NULL || bw > best_bw) { + best = &ei->edid_modes[n]; + best_bw = bw; + } + } + + return best; +} + +static void +jzlcd_hdmi_event(void *arg, device_t hdmi_dev) +{ + const struct videomode *mode; + struct videomode hdmi_mode; + struct jzlcd_softc *sc; + struct edid_info ei; + uint8_t *edid; + uint32_t edid_len; + int error; + + sc = arg; + edid = NULL; + edid_len = 0; + mode = NULL; + + error = HDMI_GET_EDID(hdmi_dev, &edid, &edid_len); + if (error != 0) { + device_printf(sc->dev, "failed to get EDID: %d\n", error); + } else { + error = edid_parse(edid, &ei); + if (error != 0) { + device_printf(sc->dev, "failed to parse EDID: %d\n", + error); + } else { + if (bootverbose) + edid_print(&ei); + + mode = jzlcd_find_mode(&ei); + } + } + + /* If a suitable mode could not be found, try the default */ + if (mode == NULL) + mode = pick_mode_by_ref(FB_DEFAULT_W, FB_DEFAULT_H, + FB_DEFAULT_REF); + + if (mode == NULL) { + device_printf(sc->dev, "failed to find usable video mode\n"); + return; + } + + if (bootverbose) + device_printf(sc->dev, "using %dx%d\n", + mode->hdisplay, mode->vdisplay); + + /* Stop the controller */ + jzlcd_stop(sc); + + /* Configure LCD controller */ + error = jzlcd_configure(sc, mode); + if (error != 0) { + device_printf(sc->dev, "failed to configure FB: %d\n", error); + return; + } + + /* Enable HDMI TX */ + hdmi_mode = *mode; + HDMI_SET_VIDEOMODE(hdmi_dev, &hdmi_mode); + + /* Start the controller! */ + jzlcd_start(sc); +} + +static void +jzlcd_dmamap_cb(void *arg, bus_dma_segment_t *segs, int nseg, int error) +{ + if (error != 0) + return; + *(bus_addr_t *)arg = segs[0].ds_addr; +} + +static int +jzlcd_probe(device_t dev) +{ + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + + if (!ofw_bus_is_compatible(dev, "ingenic,jz4780-lcd")) + return (ENXIO); + + device_set_desc(dev, "Ingenic JZ4780 LCD Controller"); + return (BUS_PROBE_DEFAULT); +} + +static int +jzlcd_attach(device_t dev) +{ + struct jzlcd_softc *sc; + int error; + + sc = device_get_softc(dev); + + sc->dev = dev; + + if (bus_alloc_resources(dev, jzlcd_spec, sc->res)) { + device_printf(dev, "cannot allocate resources for device\n"); + goto failed; + } + + if (clk_get_by_ofw_name(dev, 0, "lcd_clk", &sc->clk) != 0 || + clk_get_by_ofw_name(dev, 0, "lcd_pixclk", &sc->clk_pix) != 0) { + device_printf(dev, "cannot get clocks\n"); + goto failed; + } + if (clk_enable(sc->clk) != 0 || clk_enable(sc->clk_pix) != 0) { + device_printf(dev, "cannot enable clocks\n"); + goto failed; + } + + error = bus_dma_tag_create( + bus_get_dma_tag(dev), + sizeof(struct lcd_frame_descriptor), 0, + BUS_SPACE_MAXADDR_32BIT, + BUS_SPACE_MAXADDR, + NULL, NULL, + sizeof(struct lcd_frame_descriptor) * 2, 1, + sizeof(struct lcd_frame_descriptor) * 2, + 0, + NULL, NULL, + &sc->fdesc_tag); + if (error != 0) { + device_printf(dev, "cannot create bus dma tag\n"); + goto failed; + } + + error = bus_dmamem_alloc(sc->fdesc_tag, (void **)&sc->fdesc, + BUS_DMA_NOCACHE | BUS_DMA_WAITOK | BUS_DMA_ZERO, &sc->fdesc_map); + if (error != 0) { + device_printf(dev, "cannot allocate dma descriptor\n"); + goto dmaalloc_failed; + } + + error = bus_dmamap_load(sc->fdesc_tag, sc->fdesc_map, sc->fdesc, + sizeof(struct lcd_frame_descriptor) * 2, jzlcd_dmamap_cb, + &sc->fdesc_paddr, 0); + if (error != 0) { + device_printf(dev, "cannot load dma map\n"); + goto dmaload_failed; + } + + sc->hdmi_evh = EVENTHANDLER_REGISTER(hdmi_event, + jzlcd_hdmi_event, sc, 0); + + return (0); + +dmaload_failed: + bus_dmamem_free(sc->fdesc_tag, sc->fdesc, sc->fdesc_map); +dmaalloc_failed: + bus_dma_tag_destroy(sc->fdesc_tag); +failed: + if (sc->clk_pix != NULL) + clk_release(sc->clk); + if (sc->clk != NULL) + clk_release(sc->clk); + if (sc->res != NULL) + bus_release_resources(dev, jzlcd_spec, sc->res); + + return (ENXIO); +} + +static struct fb_info * +jzlcd_fb_getinfo(device_t dev) +{ + struct jzlcd_softc *sc; + + sc = device_get_softc(dev); + + return (&sc->info); +} + +static device_method_t jzlcd_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, jzlcd_probe), + DEVMETHOD(device_attach, jzlcd_attach), + + /* FB interface */ + DEVMETHOD(fb_getinfo, jzlcd_fb_getinfo), + + DEVMETHOD_END +}; + +static driver_t jzlcd_driver = { + "fb", + jzlcd_methods, + sizeof(struct jzlcd_softc), +}; + +static devclass_t jzlcd_devclass; + +DRIVER_MODULE(fb, simplebus, jzlcd_driver, jzlcd_devclass, 0, 0); Added: head/sys/mips/ingenic/jz4780_lcd.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/mips/ingenic/jz4780_lcd.h Tue Dec 20 01:51:09 2016 (r310308) @@ -0,0 +1,204 @@ +/*- + * Copyright (c) 2016 Jared McNeill + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +/* + * Ingenic JZ4780 LCD Controller + */ + +#ifndef __JZ4780_LCD_H__ +#define __JZ4780_LCD_H__ + +#define LCDCFG 0x0000 +#define LCDCFG_LCDPIN (1 << 31) +#define LCDCFG_TVEPEH (1 << 30) +#define LCDCFG_NEWDES (1 << 28) +#define LCDCFG_PALBP (1 << 27) +#define LCDCFG_TVEN (1 << 26) +#define LCDCFG_RECOVER (1 << 25) +#define LCDCFG_PSM (1 << 23) +#define LCDCFG_CLSM (1 << 22) +#define LCDCFG_SPLM (1 << 21) +#define LCDCFG_REVM (1 << 20) +#define LCDCFG_HSYNM (1 << 19) +#define LCDCFG_VSYNM (1 << 18) +#define LCDCFG_INVDAT (1 << 17) +#define LCDCFG_SYNDIR (1 << 16) +#define LCDCFG_PSP (1 << 15) +#define LCDCFG_CLSP (1 << 14) +#define LCDCFG_SPLP (1 << 13) +#define LCDCFG_REVP (1 << 12) +#define LCDCFG_HSP (1 << 11) +#define LCDCFG_PCP (1 << 10) +#define LCDCFG_DEP (1 << 9) +#define LCDCFG_VSP (1 << 8) +#define LCDCFG_18_16 (1 << 7) +#define LCDCFG_24 (1 << 6) +#define LCDCFG_MODE (0xf << 0) +#define LCDCTRL 0x0030 +#define LCDCTRL_PINMD (1 << 31) +#define LCDCTRL_BST (0x7 << 28) +#define LCDCTRL_BST_4 (0 << 28) +#define LCDCTRL_BST_8 (1 << 28) +#define LCDCTRL_BST_16 (2 << 28) +#define LCDCTRL_BST_32 (3 << 28) +#define LCDCTRL_BST_64 (4 << 28) +#define LCDCTRL_OUTRGB (1 << 27) +#define LCDCTRL_OFUP (1 << 26) +#define LCDCTRL_DACTE (1 << 14) +#define LCDCTRL_EOFM (1 << 13) +#define LCDCTRL_SOFM (1 << 12) +#define LCDCTRL_OFUM (1 << 11) +#define LCDCTRL_IFUM0 (1 << 10) +#define LCDCTRL_IFUM1 (1 << 9) +#define LCDCTRL_LDDM (1 << 8) +#define LCDCTRL_QDM (1 << 7) +#define LCDCTRL_BEDN (1 << 6) +#define LCDCTRL_PEDN (1 << 5) +#define LCDCTRL_DIS (1 << 4) +#define LCDCTRL_ENA (1 << 3) +#define LCDCTRL_BPP0 (0x7 << 0) +#define LCDCTRL_BPP0_1 (0 << 0) +#define LCDCTRL_BPP0_2 (1 << 0) +#define LCDCTRL_BPP0_4 (2 << 0) +#define LCDCTRL_BPP0_8 (3 << 0) +#define LCDCTRL_BPP0_15_16 (4 << 0) +#define LCDCTRL_BPP0_18_24 (5 << 0) +#define LCDCTRL_BPP0_24_COMP (6 << 0) +#define LCDCTRL_BPP0_30 (7 << 0) +#define LCDCTR +#define LCDSTATE 0x0034 +#define LCDSTATE_QD (1 << 7) +#define LCDSTATE_EOF (1 << 5) +#define LCDSTATE_SOF (1 << 4) +#define LCDSTATE_OUT (1 << 3) +#define LCDSTATE_IFU0 (1 << 2) +#define LCDSTATE_IFU1 (1 << 1) +#define LCDSTATE_LDD (1 << 0) +#define LCDOSDC 0x0100 +#define LCDOSDCTRL 0x0104 +#define LCDOSDS 0x0108 +#define LCDBGC0 0x010c +#define LCDBGC1 0x02c4 +#define LCDKEY0 0x0110 +#define LCDKEY1 0x0114 +#define LCDALPHA 0x0118 +#define LCDIPUR 0x011c +#define LCDRGBC 0x0090 +#define LCDRGBC_RGBDM (1 << 15) +#define LCDRGBC_DMM (1 << 14) +#define LCDRGBC_422 (1 << 8) +#define LCDRGBC_RGBFMT (1 << 7) +#define LCDRGBC_ODDRGB (0x7 << 4) +#define LCDRGBC_EVENRGB (0x7 << 0) +#define LCDVAT 0x000c +#define LCDVAT_HT_SHIFT 16 +#define LCDVAT_VT_SHIFT 0 +#define LCDDAH 0x0010 +#define LCDDAH_HDS_SHIFT 16 +#define LCDDAH_HDE_SHIFT 0 +#define LCDDAV 0x0014 +#define LCDDAV_VDS_SHIFT 16 +#define LCDDAV_VDE_SHIFT 0 +#define LCDXYP0 0x0120 +#define LCDXYP1 0x0124 +#define LCDSIZE0 0x0128 +#define LCDSIZE1 0x012c +#define LCDVSYNC 0x0004 +#define LCDHSYNC 0x0008 +#define LCDPS 0x0018 +#define LCDCLS 0x001c +#define LCDSPL 0x0020 +#define LCDREV 0x0024 +#define LCDIID 0x0038 +#define LCDDA0 0x0040 +#define LCDSA0 0x0044 +#define LCDFID0 0x0048 +#define LCDCMD0 0x004c +#define LCDCMD_SOFINT (1 << 31) +#define LCDCMD_EOFINT (1 << 30) +#define LCDCMD_CMD (1 << 29) +#define LCDCMD_COMPE (1 << 27) +#define LCDCMD_FRM_EN (1 << 26) +#define LCDCMD_FIELD_SEL (1 << 25) +#define LCDCMD_16X16BLOCK (1 << 24) +#define LCDCMD_LEN (0xffffff << 0) +#define LCDOFFS0 0x0060 +#define LCDPW0 0x0064 +#define LCDCNUM0 0x0068 +#define LCDPOS0 LCDCNUM0 +#define LCDPOS_ALPHAMD1 (1 << 31) +#define LCDPOS_RGB01 (1 << 30) +#define LCDPOS_BPP01 (0x7 << 27) +#define LCDPOS_BPP01_15_16 (4 << 27) +#define LCDPOS_BPP01_18_24 (5 << 27) +#define LCDPOS_BPP01_24_COMP (6 << 27) +#define LCDPOS_BPP01_30 (7 << 27) +#define LCDPOS_PREMULTI01 (1 << 26) +#define LCDPOS_COEF_SLE01 (0x3 << 24) +#define LCDPOS_COEF_BLE01_1 (1 << 24) +#define LCDPOS_YPOS01 (0xfff << 12) +#define LCDPOS_XPOS01 (0xfff << 0) +#define LCDDESSIZE0 0x006c +#define LCDDESSIZE_ALPHA (0xff << 24) +#define LCDDESSIZE_HEIGHT (0xfff << 12) +#define LCDDESSIZE_HEIGHT_SHIFT 12 +#define LCDDESSIZE_WIDTH (0xfff << 0) +#define LCDDESSIZE_WIDTH_SHIFT 0 +#define LCDDA1 0x0050 +#define LCDSA1 0x0054 +#define LCDFID1 0x0058 +#define LCDCMD1 0x005c +#define LCDOFFS1 0x0070 +#define LCDPW1 0x0074 +#define LCDCNUM1 0x0078 +#define LCDPOS1 LCDCNUM1 +#define LCDDESSIZE1 0x007c +#define LCDPCFG 0x02c0 +#define LCDDUALCTRL 0x02c8 +#define LCDENH_CFG 0x0400 +#define LCDENH_CSCCFG 0x0404 +#define LCDENH_LUMACFG 0x0408 +#define LCDENH_CHROCFG0 0x040c +#define LCDENH_CHROCFG1 0x0410 +#define LCDENH_DITHERCFG 0x0414 +#define LCDENH_STATUS 0x0418 +#define LCDENH_GAMMA 0x0800 /* base */ +#define LCDENH_VEE 0x1000 /* base */ + +struct lcd_frame_descriptor { + uint32_t next; + uint32_t physaddr; + uint32_t id; + uint32_t cmd; + uint32_t offs; + uint32_t pw; + uint32_t cnum_pos; + uint32_t dessize; +} __packed; + +#endif /* !__JZ4780_LCD_H__ */ From owner-svn-src-head@freebsd.org Tue Dec 20 02:14:48 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B8C91C899A1; Tue, 20 Dec 2016 02:14:48 +0000 (UTC) (envelope-from sepherosa@gmail.com) Received: from mail-ua0-x243.google.com (mail-ua0-x243.google.com [IPv6:2607:f8b0:400c:c08::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 78BA9B88; Tue, 20 Dec 2016 02:14:48 +0000 (UTC) (envelope-from sepherosa@gmail.com) Received: by mail-ua0-x243.google.com with SMTP id 50so13572104uae.2; Mon, 19 Dec 2016 18:14:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=speRyE2gJF0/WqQvHnl52AQ4OvVvkJPKtJ56gEiAG5o=; b=RlJ7igaelU7VNRg+WejkBEhH4gdnkOaWxQk1R57lMpBigYTRdbx4vfboSSPLV1u+0j hPXeld5HHvzuPRAA7sXiW6HTi5n+f7JHD6WES5w8d+Emy5qnoscJSSnMsSZxeBmJt5z2 J8m486pmPPyy6Y1Pn8A23QNqVFi+YpGu1keiHIoTGQSy6r6wFqZit54c+rQb1n7F/Kq0 dVRgdbKOWwYrD1V7RRIwUmKUHxNpy0WZBPI/+M4iI+MWcuShczPeXc/MMhXorapQhFmy oIXSCEU/oPKfnHJbUbwMYcYyOOrUEfTV4sjSDpHS8blCJkZsoYzu5Qh32v5GIhWRf0Xm 32Pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=speRyE2gJF0/WqQvHnl52AQ4OvVvkJPKtJ56gEiAG5o=; b=CVLMBOunnsY4RAq4dpUV3ycYsFQcYx0NrYjj5TyHjEMsk0U5Zf1fTZdMdcb84Mh5dG 62Fa2TLrXflZ+CjqR+yh9f7KRmn07hPbs7tJpBIAJjXQnih7FfFG8/oiOYAbOF4eElPG pYxsgc6tHKW6ZpOkSdd669VyJmnW48pRc0C937ykSWfne8u6BJS8J8mmLXzCKAjvGCeA +lo7CY4XpW+GfQIl8FN9yt8ibBPm0nPqWKuKwUjsZpv/lM1/Uh9eZE6/VHFpvstC/7bm a30AZlyrLwM59JK0FsVAj8NiUQYtyCyIQhuO99GHnO5KqrNr5jv+aS+I0HTMC6dLDlTg hUgA== X-Gm-Message-State: AKaTC03M/fvVBTzr4arUnVjDXjbdZlN1iUc4t9aapv0/JJMw48gUB5dvpRO2mWeFVD3kMHVXVNQ6F+HWhLs9aA== X-Received: by 10.176.68.132 with SMTP id n4mr15257506uan.75.1482200072482; Mon, 19 Dec 2016 18:14:32 -0800 (PST) MIME-Version: 1.0 Received: by 10.176.2.86 with HTTP; Mon, 19 Dec 2016 18:14:31 -0800 (PST) In-Reply-To: References: <201612161949.uBGJnMol059217@repo.freebsd.org> <9BD5034F-55A6-48F6-A391-A0877FF49702@panasas.com> <1482175209.48539.9.camel@freebsd.org> From: Sepherosa Ziehau Date: Tue, 20 Dec 2016 10:14:31 +0800 Message-ID: Subject: Re: svn commit: r310171 - head/sys/sys To: Ravi Pokala Cc: Ian Lepore , Warner Losh , Dimitry Andric , src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 20 Dec 2016 02:14:48 -0000 On Tue, Dec 20, 2016 at 4:37 AM, Ravi Pokala wrote: > -----Original Message----- >> From: on behalf of Ian Lepore >> Date: 2016-12-19, Monday at 11:20 >> To: Warner Losh , Ravi Pokala >> Cc: Sepherosa Ziehau , Dimitry Andric , src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" >> Subject: Re: svn commit: r310171 - head/sys/sys >> >> On Mon, 2016-12-19 at 11:58 -0700, Warner Losh wrote: >>> >>> ... >>> >>> Are there other precedence for avoiding the SCN macros in the tree as >>> well, or is this new art? >>> >>> Warner >> >> There was another commit recently the fixed the same kind of scanf >> error by making the variable fit the scanf type (changing uint64_t to >> an explicit long long unsigned, iirc). I don't know if that alone >> counts as a precedent, but IMO it's a more palatible fix than the >> SCN/PRI ugliness. > > With all apologies to Churchill, SCN/PRI are the worst way to address this in a machine-independent way, except for all the other ways that have been tried from time to time. :-P > If no objection comes, I'd commit the posted patch as it is tomorrow in my time. Thanks, sephe -- Tomorrow Will Never Die From owner-svn-src-head@freebsd.org Tue Dec 20 02:44:26 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EAE98C890D3; Tue, 20 Dec 2016 02:44:26 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail105.syd.optusnet.com.au (mail105.syd.optusnet.com.au [211.29.132.249]) by mx1.freebsd.org (Postfix) with ESMTP id 971E21B76; Tue, 20 Dec 2016 02:44:26 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from besplex.bde.org (c122-106-153-191.carlnfd1.nsw.optusnet.com.au [122.106.153.191]) by mail105.syd.optusnet.com.au (Postfix) with ESMTPS id 7F8EC1044B1A; Tue, 20 Dec 2016 13:44:16 +1100 (AEDT) Date: Tue, 20 Dec 2016 13:44:15 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Ravi Pokala cc: Ian Lepore , Warner Losh , Sepherosa Ziehau , Dimitry Andric , src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Subject: Re: svn commit: r310171 - head/sys/sys In-Reply-To: Message-ID: <20161220115922.H1147@besplex.bde.org> References: <201612161949.uBGJnMol059217@repo.freebsd.org> <9BD5034F-55A6-48F6-A391-A0877FF49702@panasas.com> <1482175209.48539.9.camel@freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.2 cv=cZeiljLM c=1 sm=1 tr=0 a=Tj3pCpwHnMupdyZSltBt7Q==:117 a=Tj3pCpwHnMupdyZSltBt7Q==:17 a=kj9zAlcOel0A:10 a=6I5d2MoRAAAA:8 a=7Qk2ozbKAAAA:8 a=n-kJSqksAAAA:8 a=pGLkceISAAAA:8 a=bdFN6mIY_9BeUA2hOmwA:9 a=sO5Achs8AXtz-njr:21 a=C33AFFPnMQOz1LBH:21 a=CjuIK1q_8ugA:10 a=IjZwj45LgO3ly-622nXo:22 a=1lyxoWkJIXJV6VJUPhuM:22 a=fMAGXkzVR7cRuVcbbVfL:22 a=6kGIvZw6iX1k4Y-7sg4_:22 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 20 Dec 2016 02:44:27 -0000 On Mon, 19 Dec 2016, Ravi Pokala wrote: > -----Original Message----- >> From: on behalf of Ian Lepore >> Date: 2016-12-19, Monday at 11:20 >> To: Warner Losh , Ravi Pokala >> Cc: Sepherosa Ziehau , Dimitry Andric , src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" >> Subject: Re: svn commit: r310171 - head/sys/sys >> >> On Mon, 2016-12-19 at 11:58 -0700, Warner Losh wrote: >>> >>> ... >>> >>> Are there other precedence for avoiding the SCN macros in the tree as >>> well, or is this new art? >> >> There was another commit recently the fixed the same kind of scanf >> error by making the variable fit the scanf type (changing uint64_t to >> an explicit long long unsigned, iirc). I don't know if that alone >> counts as a precedent, but IMO it's a more palatible fix than the >> SCN/PRI ugliness. That was apparently a bug, not a fix. Someone said that the variable needs to have type precisely uint64_t. (Extensive use of fixed-width types in FreeBSD is another bug. It asks for fixed width at all cost. Using the "fast" or "least" types would as for time or space efficiency instead. Or just use basic types whenever possible for simplicity. Fixed-width types should only be used on ABI boundaries.) I think there is an ABI boundary near the other commit. Some hardware wants uint64_t, and we should use uint_fast64_t or uint_least64_t, but we used uint64_t. These uses require translation at the ABI boundary, since the fast and least types may be larger than the fixed-width types. (In more complicated cases, the relevant fixed-width type does't exist. IIRC, POSIX requires only fixed width types of width 8, 16 and 32 to exist, since old badly designed ABIs like inet_addr() require a fixed width, but newer ABIs don't repeat the mistake for width 64. The C standard requires the "fast" and "least" types for widths 8, 16, 32 and 64 to exist. This is possible since they can all be [unsigned] long long or [u]intmax_t although these might be very far from being either fast or least. All fixed-width types are optional in C. So to support bad software ABIs and some hardware ABIs using portable code, you have to read write the data using some basic type (perhaps unsigned char) and convert it to a "fast" or "least" type (or maybe [u]intmax_t). We changed to using the unsigned long long abomination. This is basically a bad spelling of uintmax_t. All uint_fast64_t, uint_least64_t, unsigned long long and uintmax_t are at least as large asthe ABI type uint64_t, so they can be used to represent the ABI values, but all need translation at ABI booundaries since they may be strictly larger. The translation may be as simple as assignment, depending on how the code is written. Since the code wasn't written with this in mind, it might have type puns instead. Or the compiler might just warn about all implicit conversions that might lose bits. > With all apologies to Churchill, SCN/PRI are the worst way to address this in a machine-independent way, except for all the other ways that have been tried from time to time. :-P No, there are much better ways. For PRI*, just cast to [u]intmax_t. The only thing wrong with this is that it lots wastes space and time when [u]intmax_t is very wide. We don't have this problem yet since [u]intmax_t is only 64 bits. That would be very wide on 8-bit systems but is merely wide on 32-bit systems and not wide on 63-bit systems. PRI* is not even available for an average typedef like uid_t. It is available for all "fast" and "least" typedefs. For SCN*, first don't use *scanf(). Use APIs that can actually handle errors, like strtol(). If you have to maintain bad code that uses *scanf(), then convert to uintmax_t. The conversions are not as short as casting for *printf(). They are much like what is needed at ABI boundaries: uintmax_t tmp; uint64_t val; /* * Good code does tmp = strtoumax() here. Then handle errors * reported by strtoumax(). Then check that the result is * representable in uint64_t. Then handle errors from that. * * Bad code did *sscanf(str, "%llx", &val) with no error checking * or handling of course. The type didn't't match the format in * general, and the behaviour was undefined on overflow. */ sscanf(str, "%jx", &tmp); /* keep null error handling */ val = tmp; /* preserve undefined on overflow */ /* * Overflow in sscanf() is less likely than before (uintmax_t * might be larger). Then overflow occurs much like before on * assignment (if the result is too large for the final type). */ Since the conversion is more elaborate for *scanf() than for *printf(), SCN* is slightly less bad than PRI*. SCN* is also not available for an average type like uid_t. It is available for the "fast" and "least" typedefs. But with error handling, it is even easier to always read into a temporary variable of type [u]intmax_t so as to do range checking: uintmax_t tmp; uint_fast64_t fast_val; uint_least64_t least_val; unsigned long long abom_val; uint64_t val; errno = 0; /* chummy with implementation */ r = sscanf(str, "%jx", &tmp); if (r < 0 || errno != 0) /* detect undef behaviour sometimes */ some_error(); if (tmp > UINT64_MAX) range_error(); fast_val = tmp; /* for local use */ least_val = tmp; /* for local use */ abom_val = tmp; /* for unspeakable use */ val = tmp; /* for ABI use */ The value could have been read directly into any of the other variables except uint64_t directly, with only portable SCN* ugliness, but it is easier to use uintmax_t. It is a small step from this to using correct code using strtoumax(). The SCN* mistake is not made for the strtol() family (by having a function for every possible type). But if you have to maintain bad code using *scanf(), it might have 20 args instead of 1, or complications like %n or string input (there is nothing like the strtol() family for convenient parsing of strings). Then converting to 20 copies of the above would be painful (or course you would use a function). The quick fix is to omit the error handling and add 20 temorary variables and 20 assignments. Grepping for examples in src/bin shows only 3 utilities using *scanf() and 1 serious type error: - ls uses 1 sscanf() with bad error handling (no range checking, and a broken fall-through for < 0 (it is treated as all args present), and no errno hack. - sleep uses 1 sscanf() rewritten be me to do all possible error handling short of using the errno hack. - stty uses 4 sscanf()s with assorted type errors. It always reads 1 variable at a time into a single temporary variable of type long. This (or rather using strtol()) was almost correct before C99 broke long being longest. It should have read into a u_long for the unsigned cases. Instead, it bogusly casts &tmp from long * to u_long * and then depends on benign conversions to use tmp as a u_long. Many of the uncast longs have sign errrors in a different way -- they are for speed_t, which happens to be u_int. stty's use shows most of the ABI complications mentioned above. The sscanf()s are 1 for variables of type tcflags_t, 2 for variables of type speed_t and 1 for variables of type cc_t. All of these types are supposed to be opaque, except they are unsigned and integer. So using long to read them was wrong on all cases. The correct type was u_long in C90 and uintmax_t after C99 broke long being longest. u_long still works in FreeBSD because ABIs don't allow easy expansion and there is no need for expanding these types. These types are actually u_char and u_int, so they fit easily in u_long and more care should be taken to disallow reading values that don't fit in the final type. All other errors are ignored anyway. Bruce From owner-svn-src-head@freebsd.org Tue Dec 20 03:38:15 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9183FC8804E; Tue, 20 Dec 2016 03:38:15 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 524D81B68; Tue, 20 Dec 2016 03:38:15 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBK3cE0x039708; Tue, 20 Dec 2016 03:38:14 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBK3cESQ039706; Tue, 20 Dec 2016 03:38:14 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201612200338.uBK3cESQ039706@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: "Conrad E. Meyer" Date: Tue, 20 Dec 2016 03:38:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310309 - in head/sys/dev: mmc sdhci X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 20 Dec 2016 03:38:15 -0000 Author: cem Date: Tue Dec 20 03:38:14 2016 New Revision: 310309 URL: https://svnweb.freebsd.org/changeset/base/310309 Log: sdhci/mmc: Minor whitespace cleanups No functional change. Submitted by: Johannes Lundberg Modified: head/sys/dev/mmc/mmc.c head/sys/dev/sdhci/sdhci_pci.c Modified: head/sys/dev/mmc/mmc.c ============================================================================== --- head/sys/dev/mmc/mmc.c Tue Dec 20 01:51:09 2016 (r310308) +++ head/sys/dev/mmc/mmc.c Tue Dec 20 03:38:14 2016 (r310309) @@ -401,7 +401,7 @@ mmc_wait_for_req(struct mmc_softc *sc, s msleep(req, &sc->sc_mtx, 0, "mmcreq", 0); MMC_UNLOCK(sc); if (mmc_debug > 2 || (mmc_debug > 0 && req->cmd->error != MMC_ERR_NONE)) - device_printf(sc->dev, "CMD%d RESULT: %d\n", + device_printf(sc->dev, "CMD%d RESULT: %d\n", req->cmd->opcode, req->cmd->error); return (0); } @@ -511,7 +511,7 @@ mmc_idle_cards(struct mmc_softc *sc) { device_t dev; struct mmc_command cmd; - + dev = sc->dev; mmcbr_set_chip_select(dev, cs_high); mmcbr_update_ios(dev); @@ -795,7 +795,7 @@ mmc_test_bus_width(struct mmc_softc *sc) data.len = 8; data.flags = MMC_DATA_WRITE; mmc_wait_for_cmd(sc, &cmd, 0); - + memset(&cmd, 0, sizeof(cmd)); memset(&data, 0, sizeof(data)); cmd.opcode = MMC_BUSTEST_R; @@ -808,7 +808,7 @@ mmc_test_bus_width(struct mmc_softc *sc) data.flags = MMC_DATA_READ; err = mmc_wait_for_cmd(sc, &cmd, 0); sc->squelched--; - + mmcbr_set_bus_width(sc->dev, bus_width_1); mmcbr_update_ios(sc->dev); @@ -832,7 +832,7 @@ mmc_test_bus_width(struct mmc_softc *sc) data.len = 4; data.flags = MMC_DATA_WRITE; mmc_wait_for_cmd(sc, &cmd, 0); - + memset(&cmd, 0, sizeof(cmd)); memset(&data, 0, sizeof(data)); cmd.opcode = MMC_BUSTEST_R; @@ -1017,7 +1017,7 @@ mmc_decode_csd_sd(uint32_t *raw_csd, str csd->r2w_factor = 1 << mmc_get_bits(raw_csd, 128, 26, 3); csd->write_bl_len = 1 << mmc_get_bits(raw_csd, 128, 22, 4); csd->write_bl_partial = mmc_get_bits(raw_csd, 128, 21, 1); - } else + } else panic("unknown SD CSD version"); } @@ -1349,9 +1349,9 @@ mmc_discover_cards(struct mmc_softc *sc) if (ivar->csd.csd_structure > 0) ivar->high_cap = 1; ivar->tran_speed = ivar->csd.tran_speed; - ivar->erase_sector = ivar->csd.erase_sector * + ivar->erase_sector = ivar->csd.erase_sector * ivar->csd.write_bl_len / MMC_SECTOR_SIZE; - + err = mmc_send_status(sc, ivar->rca, &status); if (err != MMC_ERR_NONE) { device_printf(sc->dev, @@ -1446,7 +1446,7 @@ mmc_discover_cards(struct mmc_softc *sc) mmc_decode_csd_mmc(ivar->raw_csd, &ivar->csd); ivar->sec_count = ivar->csd.capacity / MMC_SECTOR_SIZE; ivar->tran_speed = ivar->csd.tran_speed; - ivar->erase_sector = ivar->csd.erase_sector * + ivar->erase_sector = ivar->csd.erase_sector * ivar->csd.write_bl_len / MMC_SECTOR_SIZE; err = mmc_send_status(sc, ivar->rca, &status); @@ -1655,7 +1655,7 @@ mmc_calculate_clock(struct mmc_softc *sc int nkid, i, f_max; device_t *kids; struct mmc_ivars *ivar; - + f_max = mmcbr_get_f_max(sc->dev); max_dtr = max_hs_dtr = f_max; if ((mmcbr_get_caps(sc->dev) & MMC_CAP_HSPEED)) @@ -1770,7 +1770,7 @@ static void mmc_delayed_attach(void *xsc) { struct mmc_softc *sc = xsc; - + mmc_scan(sc); config_intrhook_disestablish(&sc->config_intrhook); } Modified: head/sys/dev/sdhci/sdhci_pci.c ============================================================================== --- head/sys/dev/sdhci/sdhci_pci.c Tue Dec 20 01:51:09 2016 (r310308) +++ head/sys/dev/sdhci/sdhci_pci.c Tue Dec 20 03:38:14 2016 (r310309) @@ -63,15 +63,15 @@ __FBSDID("$FreeBSD$"); #define PCI_SDHCI_IFVENDOR 0x02 #define PCI_SLOT_INFO 0x40 /* 8 bits */ -#define PCI_SLOT_INFO_SLOTS(x) (((x >> 4) & 7) + 1) -#define PCI_SLOT_INFO_FIRST_BAR(x) ((x) & 7) +#define PCI_SLOT_INFO_SLOTS(x) (((x >> 4) & 7) + 1) +#define PCI_SLOT_INFO_FIRST_BAR(x) ((x) & 7) /* * RICOH specific PCI registers */ #define SDHC_PCI_MODE_KEY 0xf9 #define SDHC_PCI_MODE 0x150 -#define SDHC_PCI_MODE_SD20 0x10 +#define SDHC_PCI_MODE_SD20 0x10 #define SDHC_PCI_BASE_FREQ_KEY 0xfc #define SDHC_PCI_BASE_FREQ 0xe1 @@ -450,11 +450,11 @@ static device_method_t sdhci_methods[] = DEVMETHOD(bus_write_ivar, sdhci_generic_write_ivar), /* mmcbr_if */ - DEVMETHOD(mmcbr_update_ios, sdhci_generic_update_ios), - DEVMETHOD(mmcbr_request, sdhci_generic_request), - DEVMETHOD(mmcbr_get_ro, sdhci_generic_get_ro), - DEVMETHOD(mmcbr_acquire_host, sdhci_generic_acquire_host), - DEVMETHOD(mmcbr_release_host, sdhci_generic_release_host), + DEVMETHOD(mmcbr_update_ios, sdhci_generic_update_ios), + DEVMETHOD(mmcbr_request, sdhci_generic_request), + DEVMETHOD(mmcbr_get_ro, sdhci_generic_get_ro), + DEVMETHOD(mmcbr_acquire_host, sdhci_generic_acquire_host), + DEVMETHOD(mmcbr_release_host, sdhci_generic_release_host), /* SDHCI registers accessors */ DEVMETHOD(sdhci_read_1, sdhci_pci_read_1), From owner-svn-src-head@freebsd.org Tue Dec 20 03:41:41 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 80D54C8825E; Tue, 20 Dec 2016 03:41:41 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 50CD41F12; Tue, 20 Dec 2016 03:41:41 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBK3feiB042694; Tue, 20 Dec 2016 03:41:40 GMT (envelope-from hrs@FreeBSD.org) Received: (from hrs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBK3fe2x042693; Tue, 20 Dec 2016 03:41:40 GMT (envelope-from hrs@FreeBSD.org) Message-Id: <201612200341.uBK3fe2x042693@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hrs set sender to hrs@FreeBSD.org using -f From: Hiroki Sato Date: Tue, 20 Dec 2016 03:41:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310310 - head/usr.sbin/syslogd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 20 Dec 2016 03:41:41 -0000 Author: hrs Date: Tue Dec 20 03:41:40 2016 New Revision: 310310 URL: https://svnweb.freebsd.org/changeset/base/310310 Log: Add a default socket bound to *:514 when no -b option is specified. This was accidentally removed at r309933. Spotted by: Michael Butler Modified: head/usr.sbin/syslogd/syslogd.c Modified: head/usr.sbin/syslogd/syslogd.c ============================================================================== --- head/usr.sbin/syslogd/syslogd.c Tue Dec 20 03:38:14 2016 (r310309) +++ head/usr.sbin/syslogd/syslogd.c Tue Dec 20 03:41:40 2016 (r310310) @@ -383,7 +383,7 @@ close_filed(struct filed *f) int main(int argc, char *argv[]) { - int ch, i, fdsrmax = 0; + int ch, i, fdsrmax = 0, bflag = 0; struct sockaddr_storage ss; fd_set *fdsr = NULL; char line[MAXLINE + 1]; @@ -437,6 +437,7 @@ main(int argc, char *argv[]) pe->pe_name = (strlen(optarg) == 0) ? NULL : optarg; } + bflag = 1; STAILQ_INSERT_TAIL(&pqueue, pe, next); break; case 'c': @@ -528,6 +529,14 @@ main(int argc, char *argv[]) } if ((argc -= optind) != 0) usage(); + + if (bflag == 0) { + pe = calloc(1, sizeof(*pe)); + *pe = (struct peer) { + .pe_serv = "syslog" + }; + STAILQ_INSERT_TAIL(&pqueue, pe, next); + } STAILQ_FOREACH(pe, &pqueue, next) socksetup(pe); From owner-svn-src-head@freebsd.org Tue Dec 20 04:05:23 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F3AA8C88CD5; Tue, 20 Dec 2016 04:05:22 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 C2F431D0C; Tue, 20 Dec 2016 04:05:22 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBK45Li3051855; Tue, 20 Dec 2016 04:05:21 GMT (envelope-from hrs@FreeBSD.org) Received: (from hrs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBK45L9Q051854; Tue, 20 Dec 2016 04:05:21 GMT (envelope-from hrs@FreeBSD.org) Message-Id: <201612200405.uBK45L9Q051854@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hrs set sender to hrs@FreeBSD.org using -f From: Hiroki Sato Date: Tue, 20 Dec 2016 04:05:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310311 - head/usr.sbin/syslogd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 20 Dec 2016 04:05:23 -0000 Author: hrs Date: Tue Dec 20 04:05:21 2016 New Revision: 310311 URL: https://svnweb.freebsd.org/changeset/base/310311 Log: Add a NULL check. Modified: head/usr.sbin/syslogd/syslogd.c Modified: head/usr.sbin/syslogd/syslogd.c ============================================================================== --- head/usr.sbin/syslogd/syslogd.c Tue Dec 20 03:41:40 2016 (r310310) +++ head/usr.sbin/syslogd/syslogd.c Tue Dec 20 04:05:21 2016 (r310311) @@ -532,6 +532,8 @@ main(int argc, char *argv[]) if (bflag == 0) { pe = calloc(1, sizeof(*pe)); + if (pe == NULL) + err(1, "malloc failed"); *pe = (struct peer) { .pe_serv = "syslog" }; From owner-svn-src-head@freebsd.org Tue Dec 20 04:21:09 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1A6D8C876F7; Tue, 20 Dec 2016 04:21:09 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from mail.baldwin.cx (bigwig.baldwin.cx [96.47.65.170]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DF8D81766; Tue, 20 Dec 2016 04:21:07 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by mail.baldwin.cx (Postfix) with ESMTPSA id 66D0B10A980; Mon, 19 Dec 2016 23:21:06 -0500 (EST) From: John Baldwin To: Adrian Chadd Cc: Eric van Gyzen , Warner Losh , Dimitry Andric , Baptiste Daroussin , "Conrad E. Meyer" , src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Subject: Re: svn commit: r310138 - head/lib/libc/stdio Date: Mon, 19 Dec 2016 20:10:13 -0800 Message-ID: <247095068.jHM79JMCGm@ralph.baldwin.cx> User-Agent: KMail/4.14.10 (FreeBSD/11.0-PRERELEASE; KDE/4.14.10; amd64; ; ) In-Reply-To: References: <201612160144.uBG1ipjW016736@repo.freebsd.org> <49460793.UcUNovQMDa@ralph.baldwin.cx> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mail.baldwin.cx); Mon, 19 Dec 2016 23:21:06 -0500 (EST) X-Virus-Scanned: clamav-milter 0.99.2 at mail.baldwin.cx X-Virus-Status: Clean X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 20 Dec 2016 04:21:09 -0000 On Monday, December 19, 2016 02:23:08 PM Adrian Chadd wrote: > [snip] > > tl;dr - can we revert it from stdio for now so we don't end up having > people use this? I agree with that. I think in userland something like snprintb() is ok. In the kernel I'd rather keep '%b'. -- John Baldwin From owner-svn-src-head@freebsd.org Tue Dec 20 04:51:16 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6E473C8900F; Tue, 20 Dec 2016 04:51:16 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 3F6D313C7; Tue, 20 Dec 2016 04:51:16 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBK4pFSO069935; Tue, 20 Dec 2016 04:51:15 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBK4pEdq069930; Tue, 20 Dec 2016 04:51:14 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201612200451.uBK4pEdq069930@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 20 Dec 2016 04:51:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310312 - head/sys/dev/hyperv/utilities X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 20 Dec 2016 04:51:16 -0000 Author: sephe Date: Tue Dec 20 04:51:14 2016 New Revision: 310312 URL: https://svnweb.freebsd.org/changeset/base/310312 Log: hyperv/ic: Factor out function to send IC response MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8844 Modified: head/sys/dev/hyperv/utilities/hv_heartbeat.c head/sys/dev/hyperv/utilities/hv_shutdown.c head/sys/dev/hyperv/utilities/hv_timesync.c head/sys/dev/hyperv/utilities/hv_util.c head/sys/dev/hyperv/utilities/hv_util.h Modified: head/sys/dev/hyperv/utilities/hv_heartbeat.c ============================================================================== --- head/sys/dev/hyperv/utilities/hv_heartbeat.c Tue Dec 20 04:05:21 2016 (r310311) +++ head/sys/dev/hyperv/utilities/hv_heartbeat.c Tue Dec 20 04:51:14 2016 (r310312) @@ -110,13 +110,9 @@ vmbus_heartbeat_cb(struct vmbus_channel } /* - * Send response by echoing the updated request back. + * Send response by echoing the request back. */ - hdr->ic_flags = VMBUS_ICMSG_FLAG_XACT | VMBUS_ICMSG_FLAG_RESP; - error = vmbus_chan_send(chan, VMBUS_CHANPKT_TYPE_INBAND, 0, - data, dlen, xactid); - if (error) - device_printf(sc->ic_dev, "resp send failed: %d\n", error); + vmbus_ic_sendresp(sc, chan, data, dlen, xactid); } static int Modified: head/sys/dev/hyperv/utilities/hv_shutdown.c ============================================================================== --- head/sys/dev/hyperv/utilities/hv_shutdown.c Tue Dec 20 04:05:21 2016 (r310311) +++ head/sys/dev/hyperv/utilities/hv_shutdown.c Tue Dec 20 04:51:14 2016 (r310312) @@ -122,13 +122,9 @@ vmbus_shutdown_cb(struct vmbus_channel * } /* - * Send response by echoing the updated request back. + * Send response by echoing the request back. */ - hdr->ic_flags = VMBUS_ICMSG_FLAG_XACT | VMBUS_ICMSG_FLAG_RESP; - error = vmbus_chan_send(chan, VMBUS_CHANPKT_TYPE_INBAND, 0, - data, dlen, xactid); - if (error) - device_printf(sc->ic_dev, "resp send failed: %d\n", error); + vmbus_ic_sendresp(sc, chan, data, dlen, xactid); if (do_shutdown) shutdown_nice(RB_POWEROFF); Modified: head/sys/dev/hyperv/utilities/hv_timesync.c ============================================================================== --- head/sys/dev/hyperv/utilities/hv_timesync.c Tue Dec 20 04:05:21 2016 (r310311) +++ head/sys/dev/hyperv/utilities/hv_timesync.c Tue Dec 20 04:51:14 2016 (r310312) @@ -203,13 +203,9 @@ vmbus_timesync_cb(struct vmbus_channel * } /* - * Send response by echoing the updated request back. + * Send response by echoing the request back. */ - hdr->ic_flags = VMBUS_ICMSG_FLAG_XACT | VMBUS_ICMSG_FLAG_RESP; - error = vmbus_chan_send(chan, VMBUS_CHANPKT_TYPE_INBAND, 0, - data, dlen, xactid); - if (error) - device_printf(sc->ic_dev, "resp send failed: %d\n", error); + vmbus_ic_sendresp(sc, chan, data, dlen, xactid); } static int Modified: head/sys/dev/hyperv/utilities/hv_util.c ============================================================================== --- head/sys/dev/hyperv/utilities/hv_util.c Tue Dec 20 04:05:21 2016 (r310311) +++ head/sys/dev/hyperv/utilities/hv_util.c Tue Dec 20 04:51:14 2016 (r310312) @@ -287,3 +287,21 @@ hv_util_detach(device_t dev) return (0); } + +int +vmbus_ic_sendresp(struct hv_util_sc *sc, struct vmbus_channel *chan, + void *data, int dlen, uint64_t xactid) +{ + struct vmbus_icmsg_hdr *hdr; + int error; + + KASSERT(dlen >= sizeof(*hdr), ("invalid data length %d", dlen)); + hdr = data; + + hdr->ic_flags = VMBUS_ICMSG_FLAG_XACT | VMBUS_ICMSG_FLAG_RESP; + error = vmbus_chan_send(chan, VMBUS_CHANPKT_TYPE_INBAND, 0, + data, dlen, xactid); + if (error) + device_printf(sc->ic_dev, "resp send failed: %d\n", error); + return (error); +} Modified: head/sys/dev/hyperv/utilities/hv_util.h ============================================================================== --- head/sys/dev/hyperv/utilities/hv_util.h Tue Dec 20 04:05:21 2016 (r310311) +++ head/sys/dev/hyperv/utilities/hv_util.h Tue Dec 20 04:51:14 2016 (r310312) @@ -58,5 +58,8 @@ int hv_util_detach(device_t dev); int vmbus_ic_probe(device_t dev, const struct vmbus_ic_desc descs[]); int vmbus_ic_negomsg(struct hv_util_sc *sc, void *data, int *dlen, uint32_t fw_ver, uint32_t msg_ver); +int vmbus_ic_sendresp(struct hv_util_sc *sc, + struct vmbus_channel *chan, void *data, int dlen, + uint64_t xactid); #endif From owner-svn-src-head@freebsd.org Tue Dec 20 05:07:14 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 00ABFC8948C; Tue, 20 Dec 2016 05:07:14 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 CF2A01C91; Tue, 20 Dec 2016 05:07:13 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBK57DoH075503; Tue, 20 Dec 2016 05:07:13 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBK57COs075495; Tue, 20 Dec 2016 05:07:12 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201612200507.uBK57COs075495@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 20 Dec 2016 05:07:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310313 - head/sys/dev/hyperv/utilities X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 20 Dec 2016 05:07:14 -0000 Author: sephe Date: Tue Dec 20 05:07:12 2016 New Revision: 310313 URL: https://svnweb.freebsd.org/changeset/base/310313 Log: hyperv/ic: Cleanup common struct and functions. MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8845 Modified: head/sys/dev/hyperv/utilities/hv_heartbeat.c head/sys/dev/hyperv/utilities/hv_kvp.c head/sys/dev/hyperv/utilities/hv_shutdown.c head/sys/dev/hyperv/utilities/hv_snapshot.c head/sys/dev/hyperv/utilities/hv_timesync.c head/sys/dev/hyperv/utilities/hv_util.c head/sys/dev/hyperv/utilities/hv_util.h Modified: head/sys/dev/hyperv/utilities/hv_heartbeat.c ============================================================================== --- head/sys/dev/hyperv/utilities/hv_heartbeat.c Tue Dec 20 04:51:14 2016 (r310312) +++ head/sys/dev/hyperv/utilities/hv_heartbeat.c Tue Dec 20 05:07:12 2016 (r310313) @@ -61,7 +61,7 @@ static const struct vmbus_ic_desc vmbus_ static void vmbus_heartbeat_cb(struct vmbus_channel *chan, void *xsc) { - struct hv_util_sc *sc = xsc; + struct vmbus_ic_softc *sc = xsc; struct vmbus_icmsg_hdr *hdr; int dlen, error; uint64_t xactid; @@ -70,7 +70,7 @@ vmbus_heartbeat_cb(struct vmbus_channel /* * Receive request. */ - data = sc->receive_buffer; + data = sc->ic_buf; dlen = sc->ic_buflen; error = vmbus_chan_recv(chan, data, &dlen, &xactid); KASSERT(error != ENOBUFS, ("icbuf is not large enough")); @@ -126,18 +126,22 @@ static int hv_heartbeat_attach(device_t dev) { - return (hv_util_attach(dev, vmbus_heartbeat_cb)); + return (vmbus_ic_attach(dev, vmbus_heartbeat_cb)); } static device_method_t heartbeat_methods[] = { /* Device interface */ DEVMETHOD(device_probe, hv_heartbeat_probe), DEVMETHOD(device_attach, hv_heartbeat_attach), - DEVMETHOD(device_detach, hv_util_detach), + DEVMETHOD(device_detach, vmbus_ic_detach), { 0, 0 } }; -static driver_t heartbeat_driver = { "hvheartbeat", heartbeat_methods, sizeof(hv_util_sc)}; +static driver_t heartbeat_driver = { + "hvheartbeat", + heartbeat_methods, + sizeof(struct vmbus_ic_softc) +}; static devclass_t heartbeat_devclass; Modified: head/sys/dev/hyperv/utilities/hv_kvp.c ============================================================================== --- head/sys/dev/hyperv/utilities/hv_kvp.c Tue Dec 20 04:51:14 2016 (r310312) +++ head/sys/dev/hyperv/utilities/hv_kvp.c Tue Dec 20 05:07:12 2016 (r310313) @@ -128,7 +128,7 @@ static struct cdevsw hv_kvp_cdevsw = * KVP transaction requests from the host. */ typedef struct hv_kvp_sc { - struct hv_util_sc util_sc; + struct vmbus_ic_softc util_sc; device_t dev; /* Unless specified the pending mutex should be @@ -590,7 +590,7 @@ hv_kvp_process_request(void *context, in hv_kvp_log_info("%s: entering hv_kvp_process_request\n", __func__); sc = (hv_kvp_sc*)context; - kvp_buf = sc->util_sc.receive_buffer; + kvp_buf = sc->util_sc.ic_buf; channel = vmbus_get_channel(sc->dev); recvlen = sc->util_sc.ic_buflen; @@ -885,7 +885,7 @@ hv_kvp_attach(device_t dev) return (error); sc->hv_kvp_dev->si_drv1 = sc; - return hv_util_attach(dev, hv_kvp_callback); + return (vmbus_ic_attach(dev, hv_kvp_callback)); } static int @@ -900,7 +900,7 @@ hv_kvp_detach(device_t dev) } destroy_dev(sc->hv_kvp_dev); - return hv_util_detach(dev); + return (vmbus_ic_detach(dev)); } static device_method_t kvp_methods[] = { Modified: head/sys/dev/hyperv/utilities/hv_shutdown.c ============================================================================== --- head/sys/dev/hyperv/utilities/hv_shutdown.c Tue Dec 20 04:51:14 2016 (r310312) +++ head/sys/dev/hyperv/utilities/hv_shutdown.c Tue Dec 20 05:07:12 2016 (r310313) @@ -62,7 +62,7 @@ static const struct vmbus_ic_desc vmbus_ static void vmbus_shutdown_cb(struct vmbus_channel *chan, void *xsc) { - struct hv_util_sc *sc = xsc; + struct vmbus_ic_softc *sc = xsc; struct vmbus_icmsg_hdr *hdr; struct vmbus_icmsg_shutdown *msg; int dlen, error, do_shutdown = 0; @@ -72,7 +72,7 @@ vmbus_shutdown_cb(struct vmbus_channel * /* * Receive request. */ - data = sc->receive_buffer; + data = sc->ic_buf; dlen = sc->ic_buflen; error = vmbus_chan_recv(chan, data, &dlen, &xactid); KASSERT(error != ENOBUFS, ("icbuf is not large enough")); @@ -141,18 +141,22 @@ static int hv_shutdown_attach(device_t dev) { - return (hv_util_attach(dev, vmbus_shutdown_cb)); + return (vmbus_ic_attach(dev, vmbus_shutdown_cb)); } static device_method_t shutdown_methods[] = { /* Device interface */ DEVMETHOD(device_probe, hv_shutdown_probe), DEVMETHOD(device_attach, hv_shutdown_attach), - DEVMETHOD(device_detach, hv_util_detach), + DEVMETHOD(device_detach, vmbus_ic_detach), { 0, 0 } }; -static driver_t shutdown_driver = { "hvshutdown", shutdown_methods, sizeof(hv_util_sc)}; +static driver_t shutdown_driver = { + "hvshutdown", + shutdown_methods, + sizeof(struct vmbus_ic_softc) +}; static devclass_t shutdown_devclass; Modified: head/sys/dev/hyperv/utilities/hv_snapshot.c ============================================================================== --- head/sys/dev/hyperv/utilities/hv_snapshot.c Tue Dec 20 04:51:14 2016 (r310312) +++ head/sys/dev/hyperv/utilities/hv_snapshot.c Tue Dec 20 05:07:12 2016 (r310313) @@ -204,7 +204,7 @@ struct hv_vss_dev_sc { * https://clovertrail.github.io/assets/vssdot.png */ typedef struct hv_vss_sc { - struct hv_util_sc util_sc; + struct vmbus_ic_softc util_sc; device_t dev; struct task task; @@ -808,7 +808,7 @@ hv_vss_process_request(void *context, in hv_vss_log_info("%s: entering hv_vss_process_request\n", __func__); sc = (hv_vss_sc*)context; - vss_buf = sc->util_sc.receive_buffer; + vss_buf = sc->util_sc.ic_buf; channel = vmbus_get_channel(sc->dev); recvlen = sc->util_sc.ic_buflen; @@ -1020,7 +1020,7 @@ hv_vss_attach(device_t dev) sc->hv_appvss_dev->si_drv1 = &sc->app_sc; sc->app_sc.sc = sc; - return hv_util_attach(dev, hv_vss_callback); + return (vmbus_ic_attach(dev, hv_vss_callback)); } static int @@ -1041,7 +1041,7 @@ hv_vss_detach(device_t dev) hv_vss_destroy_send_receive_queue(dev); destroy_dev(sc->hv_vss_dev); destroy_dev(sc->hv_appvss_dev); - return hv_util_detach(dev); + return (vmbus_ic_detach(dev)); } static device_method_t vss_methods[] = { Modified: head/sys/dev/hyperv/utilities/hv_timesync.c ============================================================================== --- head/sys/dev/hyperv/utilities/hv_timesync.c Tue Dec 20 04:51:14 2016 (r310312) +++ head/sys/dev/hyperv/utilities/hv_timesync.c Tue Dec 20 05:07:12 2016 (r310313) @@ -85,7 +85,7 @@ SYSCTL_INT(_hw_hvtimesync, OID_AUTO, sam &vmbus_ts_sample_verbose, 0, "Increase sample request verbosity."); static void -vmbus_timesync(struct hv_util_sc *sc, uint64_t hvtime, uint64_t sent_tc, +vmbus_timesync(struct vmbus_ic_softc *sc, uint64_t hvtime, uint64_t sent_tc, uint8_t tsflags) { struct timespec vm_ts; @@ -150,7 +150,7 @@ vmbus_timesync(struct hv_util_sc *sc, ui static void vmbus_timesync_cb(struct vmbus_channel *chan, void *xsc) { - struct hv_util_sc *sc = xsc; + struct vmbus_ic_softc *sc = xsc; struct vmbus_icmsg_hdr *hdr; const struct vmbus_icmsg_timesync *msg; int dlen, error; @@ -160,7 +160,7 @@ vmbus_timesync_cb(struct vmbus_channel * /* * Receive request. */ - data = sc->receive_buffer; + data = sc->ic_buf; dlen = sc->ic_buflen; error = vmbus_chan_recv(chan, data, &dlen, &xactid); KASSERT(error != ENOBUFS, ("icbuf is not large enough")); @@ -219,18 +219,22 @@ static int hv_timesync_attach(device_t dev) { - return (hv_util_attach(dev, vmbus_timesync_cb)); + return (vmbus_ic_attach(dev, vmbus_timesync_cb)); } static device_method_t timesync_methods[] = { /* Device interface */ DEVMETHOD(device_probe, hv_timesync_probe), DEVMETHOD(device_attach, hv_timesync_attach), - DEVMETHOD(device_detach, hv_util_detach), + DEVMETHOD(device_detach, vmbus_ic_detach), { 0, 0 } }; -static driver_t timesync_driver = { "hvtimesync", timesync_methods, sizeof(hv_util_sc)}; +static driver_t timesync_driver = { + "hvtimesync", + timesync_methods, + sizeof(struct vmbus_ic_softc) +}; static devclass_t timesync_devclass; Modified: head/sys/dev/hyperv/utilities/hv_util.c ============================================================================== --- head/sys/dev/hyperv/utilities/hv_util.c Tue Dec 20 04:51:14 2016 (r310312) +++ head/sys/dev/hyperv/utilities/hv_util.c Tue Dec 20 05:07:12 2016 (r310313) @@ -58,7 +58,7 @@ static int vmbus_ic_fwver_sysctl(SYSCTL_ static int vmbus_ic_msgver_sysctl(SYSCTL_HANDLER_ARGS); int -vmbus_ic_negomsg(struct hv_util_sc *sc, void *data, int *dlen0, +vmbus_ic_negomsg(struct vmbus_ic_softc *sc, void *data, int *dlen0, uint32_t fw_ver, uint32_t msg_ver) { struct vmbus_icmsg_negotiate *nego; @@ -214,9 +214,9 @@ vmbus_ic_probe(device_t dev, const struc } int -hv_util_attach(device_t dev, vmbus_chan_callback_t cb) +vmbus_ic_attach(device_t dev, vmbus_chan_callback_t cb) { - struct hv_util_sc *sc = device_get_softc(dev); + struct vmbus_ic_softc *sc = device_get_softc(dev); struct vmbus_channel *chan = vmbus_get_channel(dev); struct sysctl_oid_list *child; struct sysctl_ctx_list *ctx; @@ -224,8 +224,7 @@ hv_util_attach(device_t dev, vmbus_chan_ sc->ic_dev = dev; sc->ic_buflen = VMBUS_IC_BRSIZE; - sc->receive_buffer = malloc(VMBUS_IC_BRSIZE, M_DEVBUF, - M_WAITOK | M_ZERO); + sc->ic_buf = malloc(VMBUS_IC_BRSIZE, M_DEVBUF, M_WAITOK | M_ZERO); /* * These services are not performance critical and do not need @@ -239,7 +238,7 @@ hv_util_attach(device_t dev, vmbus_chan_ error = vmbus_chan_open(chan, VMBUS_IC_BRSIZE, VMBUS_IC_BRSIZE, NULL, 0, cb, sc); if (error) { - free(sc->receive_buffer, M_DEVBUF); + free(sc->ic_buf, M_DEVBUF); return (error); } @@ -258,7 +257,7 @@ hv_util_attach(device_t dev, vmbus_chan_ static int vmbus_ic_fwver_sysctl(SYSCTL_HANDLER_ARGS) { - struct hv_util_sc *sc = arg1; + struct vmbus_ic_softc *sc = arg1; char verstr[16]; snprintf(verstr, sizeof(verstr), "%u.%u", @@ -269,7 +268,7 @@ vmbus_ic_fwver_sysctl(SYSCTL_HANDLER_ARG static int vmbus_ic_msgver_sysctl(SYSCTL_HANDLER_ARGS) { - struct hv_util_sc *sc = arg1; + struct vmbus_ic_softc *sc = arg1; char verstr[16]; snprintf(verstr, sizeof(verstr), "%u.%u", @@ -278,18 +277,18 @@ vmbus_ic_msgver_sysctl(SYSCTL_HANDLER_AR } int -hv_util_detach(device_t dev) +vmbus_ic_detach(device_t dev) { - struct hv_util_sc *sc = device_get_softc(dev); + struct vmbus_ic_softc *sc = device_get_softc(dev); vmbus_chan_close(vmbus_get_channel(dev)); - free(sc->receive_buffer, M_DEVBUF); + free(sc->ic_buf, M_DEVBUF); return (0); } int -vmbus_ic_sendresp(struct hv_util_sc *sc, struct vmbus_channel *chan, +vmbus_ic_sendresp(struct vmbus_ic_softc *sc, struct vmbus_channel *chan, void *data, int dlen, uint64_t xactid) { struct vmbus_icmsg_hdr *hdr; Modified: head/sys/dev/hyperv/utilities/hv_util.h ============================================================================== --- head/sys/dev/hyperv/utilities/hv_util.h Tue Dec 20 04:51:14 2016 (r310312) +++ head/sys/dev/hyperv/utilities/hv_util.h Tue Dec 20 05:07:12 2016 (r310313) @@ -28,23 +28,19 @@ * $FreeBSD$ */ -#ifndef _HVUTIL_H_ -#define _HVUTIL_H_ +#ifndef _VMBUS_ICVAR_H_ +#define _VMBUS_ICVAR_H_ #include #include -/** - * hv_util related structures - * - */ -typedef struct hv_util_sc { +struct vmbus_ic_softc { device_t ic_dev; - uint8_t *receive_buffer; + uint8_t *ic_buf; int ic_buflen; uint32_t ic_fwver; /* framework version */ uint32_t ic_msgver; /* message version */ -} hv_util_sc; +}; struct vmbus_ic_desc { const struct hyperv_guid ic_guid; @@ -53,13 +49,13 @@ struct vmbus_ic_desc { #define VMBUS_IC_DESC_END { .ic_desc = NULL } -int hv_util_attach(device_t dev, vmbus_chan_callback_t cb); -int hv_util_detach(device_t dev); +int vmbus_ic_attach(device_t dev, vmbus_chan_callback_t cb); +int vmbus_ic_detach(device_t dev); int vmbus_ic_probe(device_t dev, const struct vmbus_ic_desc descs[]); -int vmbus_ic_negomsg(struct hv_util_sc *sc, void *data, int *dlen, - uint32_t fw_ver, uint32_t msg_ver); -int vmbus_ic_sendresp(struct hv_util_sc *sc, +int vmbus_ic_negomsg(struct vmbus_ic_softc *sc, void *data, + int *dlen, uint32_t fw_ver, uint32_t msg_ver); +int vmbus_ic_sendresp(struct vmbus_ic_softc *sc, struct vmbus_channel *chan, void *data, int dlen, uint64_t xactid); -#endif +#endif /* !_VMBUS_ICVAR_H_ */ From owner-svn-src-head@freebsd.org Tue Dec 20 05:26:40 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 93567C89C64; Tue, 20 Dec 2016 05:26:40 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 6DFE218B4; Tue, 20 Dec 2016 05:26:40 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBK5QdB6083572; Tue, 20 Dec 2016 05:26:39 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBK5QcgI083565; Tue, 20 Dec 2016 05:26:38 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201612200526.uBK5QcgI083565@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 20 Dec 2016 05:26:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310314 - head/sys/dev/hyperv/utilities X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 20 Dec 2016 05:26:40 -0000 Author: sephe Date: Tue Dec 20 05:26:38 2016 New Revision: 310314 URL: https://svnweb.freebsd.org/changeset/base/310314 Log: hyperv/ic: Rename cleaned up header file. MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8846 Added: head/sys/dev/hyperv/utilities/vmbus_icvar.h - copied unchanged from r310313, head/sys/dev/hyperv/utilities/hv_util.h Deleted: head/sys/dev/hyperv/utilities/hv_util.h Modified: head/sys/dev/hyperv/utilities/hv_heartbeat.c head/sys/dev/hyperv/utilities/hv_kvp.c head/sys/dev/hyperv/utilities/hv_shutdown.c head/sys/dev/hyperv/utilities/hv_snapshot.c head/sys/dev/hyperv/utilities/hv_timesync.c head/sys/dev/hyperv/utilities/hv_util.c Modified: head/sys/dev/hyperv/utilities/hv_heartbeat.c ============================================================================== --- head/sys/dev/hyperv/utilities/hv_heartbeat.c Tue Dec 20 05:07:12 2016 (r310313) +++ head/sys/dev/hyperv/utilities/hv_heartbeat.c Tue Dec 20 05:26:38 2016 (r310314) @@ -35,8 +35,8 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include +#include #include "vmbus_if.h" Modified: head/sys/dev/hyperv/utilities/hv_kvp.c ============================================================================== --- head/sys/dev/hyperv/utilities/hv_kvp.c Tue Dec 20 05:07:12 2016 (r310313) +++ head/sys/dev/hyperv/utilities/hv_kvp.c Tue Dec 20 05:26:38 2016 (r310314) @@ -64,8 +64,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include -#include "hv_util.h" #include "unicode.h" #include "hv_kvp.h" #include "vmbus_if.h" Modified: head/sys/dev/hyperv/utilities/hv_shutdown.c ============================================================================== --- head/sys/dev/hyperv/utilities/hv_shutdown.c Tue Dec 20 05:07:12 2016 (r310313) +++ head/sys/dev/hyperv/utilities/hv_shutdown.c Tue Dec 20 05:26:38 2016 (r310314) @@ -36,8 +36,8 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include +#include #include "vmbus_if.h" Modified: head/sys/dev/hyperv/utilities/hv_snapshot.c ============================================================================== --- head/sys/dev/hyperv/utilities/hv_snapshot.c Tue Dec 20 05:07:12 2016 (r310313) +++ head/sys/dev/hyperv/utilities/hv_snapshot.c Tue Dec 20 05:26:38 2016 (r310314) @@ -57,8 +57,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include -#include "hv_util.h" #include "hv_snapshot.h" #include "vmbus_if.h" Modified: head/sys/dev/hyperv/utilities/hv_timesync.c ============================================================================== --- head/sys/dev/hyperv/utilities/hv_timesync.c Tue Dec 20 05:07:12 2016 (r310313) +++ head/sys/dev/hyperv/utilities/hv_timesync.c Tue Dec 20 05:26:38 2016 (r310314) @@ -37,8 +37,8 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include +#include #include "vmbus_if.h" Modified: head/sys/dev/hyperv/utilities/hv_util.c ============================================================================== --- head/sys/dev/hyperv/utilities/hv_util.c Tue Dec 20 05:07:12 2016 (r310313) +++ head/sys/dev/hyperv/utilities/hv_util.c Tue Dec 20 05:26:38 2016 (r310314) @@ -42,8 +42,8 @@ #include #include -#include #include +#include #include "vmbus_if.h" Copied: head/sys/dev/hyperv/utilities/vmbus_icvar.h (from r310313, head/sys/dev/hyperv/utilities/hv_util.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/hyperv/utilities/vmbus_icvar.h Tue Dec 20 05:26:38 2016 (r310314, copy of r310313, head/sys/dev/hyperv/utilities/hv_util.h) @@ -0,0 +1,61 @@ +/*- + * Copyright (c) 2009-2012,2016 Microsoft Corp. + * Copyright (c) 2012 NetApp Inc. + * Copyright (c) 2012 Citrix Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _VMBUS_ICVAR_H_ +#define _VMBUS_ICVAR_H_ + +#include +#include + +struct vmbus_ic_softc { + device_t ic_dev; + uint8_t *ic_buf; + int ic_buflen; + uint32_t ic_fwver; /* framework version */ + uint32_t ic_msgver; /* message version */ +}; + +struct vmbus_ic_desc { + const struct hyperv_guid ic_guid; + const char *ic_desc; +}; + +#define VMBUS_IC_DESC_END { .ic_desc = NULL } + +int vmbus_ic_attach(device_t dev, vmbus_chan_callback_t cb); +int vmbus_ic_detach(device_t dev); +int vmbus_ic_probe(device_t dev, const struct vmbus_ic_desc descs[]); +int vmbus_ic_negomsg(struct vmbus_ic_softc *sc, void *data, + int *dlen, uint32_t fw_ver, uint32_t msg_ver); +int vmbus_ic_sendresp(struct vmbus_ic_softc *sc, + struct vmbus_channel *chan, void *data, int dlen, + uint64_t xactid); + +#endif /* !_VMBUS_ICVAR_H_ */ From owner-svn-src-head@freebsd.org Tue Dec 20 05:39:02 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 601FCC89EAD; Tue, 20 Dec 2016 05:39:02 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 136961D82; Tue, 20 Dec 2016 05:39:02 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBK5d19X087588; Tue, 20 Dec 2016 05:39:01 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBK5d08P087584; Tue, 20 Dec 2016 05:39:00 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201612200539.uBK5d08P087584@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 20 Dec 2016 05:39:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310315 - head/sys/dev/hyperv/utilities X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 20 Dec 2016 05:39:02 -0000 Author: sephe Date: Tue Dec 20 05:39:00 2016 New Revision: 310315 URL: https://svnweb.freebsd.org/changeset/base/310315 Log: hyperv/ic: Inclusion cleanup MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8847 Modified: head/sys/dev/hyperv/utilities/hv_heartbeat.c head/sys/dev/hyperv/utilities/hv_shutdown.c head/sys/dev/hyperv/utilities/hv_timesync.c head/sys/dev/hyperv/utilities/hv_util.c Modified: head/sys/dev/hyperv/utilities/hv_heartbeat.c ============================================================================== --- head/sys/dev/hyperv/utilities/hv_heartbeat.c Tue Dec 20 05:26:38 2016 (r310314) +++ head/sys/dev/hyperv/utilities/hv_heartbeat.c Tue Dec 20 05:39:00 2016 (r310315) @@ -38,8 +38,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include "vmbus_if.h" - #define VMBUS_HEARTBEAT_FWVER_MAJOR 3 #define VMBUS_HEARTBEAT_FWVER \ VMBUS_IC_VERSION(VMBUS_HEARTBEAT_FWVER_MAJOR, 0) Modified: head/sys/dev/hyperv/utilities/hv_shutdown.c ============================================================================== --- head/sys/dev/hyperv/utilities/hv_shutdown.c Tue Dec 20 05:26:38 2016 (r310314) +++ head/sys/dev/hyperv/utilities/hv_shutdown.c Tue Dec 20 05:39:00 2016 (r310315) @@ -39,8 +39,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include "vmbus_if.h" - #define VMBUS_SHUTDOWN_FWVER_MAJOR 3 #define VMBUS_SHUTDOWN_FWVER \ VMBUS_IC_VERSION(VMBUS_SHUTDOWN_FWVER_MAJOR, 0) Modified: head/sys/dev/hyperv/utilities/hv_timesync.c ============================================================================== --- head/sys/dev/hyperv/utilities/hv_timesync.c Tue Dec 20 05:26:38 2016 (r310314) +++ head/sys/dev/hyperv/utilities/hv_timesync.c Tue Dec 20 05:39:00 2016 (r310315) @@ -40,8 +40,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include "vmbus_if.h" - #define VMBUS_TIMESYNC_FWVER_MAJOR 3 #define VMBUS_TIMESYNC_FWVER \ VMBUS_IC_VERSION(VMBUS_TIMESYNC_FWVER_MAJOR, 0) Modified: head/sys/dev/hyperv/utilities/hv_util.c ============================================================================== --- head/sys/dev/hyperv/utilities/hv_util.c Tue Dec 20 05:26:38 2016 (r310314) +++ head/sys/dev/hyperv/utilities/hv_util.c Tue Dec 20 05:39:00 2016 (r310315) @@ -22,23 +22,16 @@ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ */ -/* - * A common driver for all hyper-V util services. - */ +#include +__FBSDID("$FreeBSD$"); #include -#include #include #include -#include -#include #include #include -#include #include #include From owner-svn-src-head@freebsd.org Tue Dec 20 05:45:53 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E4D9AC8906E; Tue, 20 Dec 2016 05:45:53 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 B43621203; Tue, 20 Dec 2016 05:45:53 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBK5jqqZ091479; Tue, 20 Dec 2016 05:45:52 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBK5jqU3091478; Tue, 20 Dec 2016 05:45:52 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201612200545.uBK5jqU3091478@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 20 Dec 2016 05:45:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310316 - head/cddl/contrib/opensolaris/lib/libdtrace/common X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 20 Dec 2016 05:45:54 -0000 Author: markj Date: Tue Dec 20 05:45:52 2016 New Revision: 310316 URL: https://svnweb.freebsd.org/changeset/base/310316 Log: Consistently print D variable indices in decimal when disassembling. MFC after: 1 week Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dis.c Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dis.c ============================================================================== --- head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dis.c Tue Dec 20 05:39:00 2016 (r310315) +++ head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dis.c Tue Dec 20 05:45:52 2016 (r310316) @@ -499,7 +499,7 @@ dt_dis(const dtrace_difo_t *dp, FILE *fp if (v->dtdv_flags & DIFV_F_MOD) (void) strcat(flags, "/w"); - (void) fprintf(fp, "%-16s %-4x %-3s %-3s %-4s %s\n", + (void) fprintf(fp, "%-16s %-4u %-3s %-3s %-4s %s\n", &dp->dtdo_strtab[v->dtdv_name], v->dtdv_id, kind, scope, flags + 1, dt_dis_typestr(&v->dtdv_type, type, sizeof (type))); From owner-svn-src-head@freebsd.org Tue Dec 20 07:14:25 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C48A5C891C3; Tue, 20 Dec 2016 07:14:25 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 94083127A; Tue, 20 Dec 2016 07:14:25 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBK7EOmZ027552; Tue, 20 Dec 2016 07:14:24 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBK7EOeC027549; Tue, 20 Dec 2016 07:14:24 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201612200714.uBK7EOeC027549@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 20 Dec 2016 07:14:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310317 - in head/sys: conf dev/hyperv/utilities modules/hyperv/utilities X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 20 Dec 2016 07:14:25 -0000 Author: sephe Date: Tue Dec 20 07:14:24 2016 New Revision: 310317 URL: https://svnweb.freebsd.org/changeset/base/310317 Log: hyperv/ic: Rname cleaned up file. MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8848 Added: head/sys/dev/hyperv/utilities/vmbus_ic.c - copied unchanged from r310316, head/sys/dev/hyperv/utilities/hv_util.c Deleted: head/sys/dev/hyperv/utilities/hv_util.c Modified: head/sys/conf/files.amd64 head/sys/conf/files.i386 head/sys/modules/hyperv/utilities/Makefile Modified: head/sys/conf/files.amd64 ============================================================================== --- head/sys/conf/files.amd64 Tue Dec 20 05:45:52 2016 (r310316) +++ head/sys/conf/files.amd64 Tue Dec 20 07:14:24 2016 (r310317) @@ -303,7 +303,7 @@ dev/hyperv/utilities/hv_kvp.c optiona dev/hyperv/utilities/hv_snapshot.c optional hyperv dev/hyperv/utilities/hv_shutdown.c optional hyperv dev/hyperv/utilities/hv_timesync.c optional hyperv -dev/hyperv/utilities/hv_util.c optional hyperv +dev/hyperv/utilities/vmbus_ic.c optional hyperv dev/hyperv/vmbus/hyperv.c optional hyperv dev/hyperv/vmbus/hyperv_busdma.c optional hyperv dev/hyperv/vmbus/vmbus.c optional hyperv pci Modified: head/sys/conf/files.i386 ============================================================================== --- head/sys/conf/files.i386 Tue Dec 20 05:45:52 2016 (r310316) +++ head/sys/conf/files.i386 Tue Dec 20 07:14:24 2016 (r310317) @@ -259,7 +259,7 @@ dev/hyperv/utilities/hv_kvp.c optiona dev/hyperv/utilities/hv_snapshot.c optional hyperv dev/hyperv/utilities/hv_shutdown.c optional hyperv dev/hyperv/utilities/hv_timesync.c optional hyperv -dev/hyperv/utilities/hv_util.c optional hyperv +dev/hyperv/utilities/vmbus_ic.c optional hyperv dev/hyperv/vmbus/hyperv.c optional hyperv dev/hyperv/vmbus/hyperv_busdma.c optional hyperv dev/hyperv/vmbus/vmbus.c optional hyperv pci Copied: head/sys/dev/hyperv/utilities/vmbus_ic.c (from r310316, head/sys/dev/hyperv/utilities/hv_util.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/hyperv/utilities/vmbus_ic.c Tue Dec 20 07:14:24 2016 (r310317, copy of r310316, head/sys/dev/hyperv/utilities/hv_util.c) @@ -0,0 +1,299 @@ +/*- + * Copyright (c) 2014,2016 Microsoft Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "vmbus_if.h" + +#define VMBUS_IC_BRSIZE (4 * PAGE_SIZE) + +#define VMBUS_IC_VERCNT 2 +#define VMBUS_IC_NEGOSZ \ + __offsetof(struct vmbus_icmsg_negotiate, ic_ver[VMBUS_IC_VERCNT]) +CTASSERT(VMBUS_IC_NEGOSZ < VMBUS_IC_BRSIZE); + +static int vmbus_ic_fwver_sysctl(SYSCTL_HANDLER_ARGS); +static int vmbus_ic_msgver_sysctl(SYSCTL_HANDLER_ARGS); + +int +vmbus_ic_negomsg(struct vmbus_ic_softc *sc, void *data, int *dlen0, + uint32_t fw_ver, uint32_t msg_ver) +{ + struct vmbus_icmsg_negotiate *nego; + int i, cnt, dlen = *dlen0, error; + uint32_t sel_fw_ver, sel_msg_ver; + bool has_fw_ver, has_msg_ver; + + /* + * Preliminary message verification. + */ + if (dlen < sizeof(*nego)) { + device_printf(sc->ic_dev, "truncated ic negotiate, len %d\n", + dlen); + return (EINVAL); + } + nego = data; + + if (nego->ic_fwver_cnt == 0) { + device_printf(sc->ic_dev, "ic negotiate does not contain " + "framework version %u\n", nego->ic_fwver_cnt); + return (EINVAL); + } + if (nego->ic_msgver_cnt == 0) { + device_printf(sc->ic_dev, "ic negotiate does not contain " + "message version %u\n", nego->ic_msgver_cnt); + return (EINVAL); + } + + cnt = nego->ic_fwver_cnt + nego->ic_msgver_cnt; + if (dlen < __offsetof(struct vmbus_icmsg_negotiate, ic_ver[cnt])) { + device_printf(sc->ic_dev, "ic negotiate does not contain " + "versions %d\n", dlen); + return (EINVAL); + } + + error = EOPNOTSUPP; + + /* + * Find the best match framework version. + */ + has_fw_ver = false; + for (i = 0; i < nego->ic_fwver_cnt; ++i) { + if (VMBUS_ICVER_LE(nego->ic_ver[i], fw_ver)) { + if (!has_fw_ver) { + sel_fw_ver = nego->ic_ver[i]; + has_fw_ver = true; + } else if (VMBUS_ICVER_GT(nego->ic_ver[i], + sel_fw_ver)) { + sel_fw_ver = nego->ic_ver[i]; + } + } + } + if (!has_fw_ver) { + device_printf(sc->ic_dev, "failed to select framework " + "version\n"); + goto done; + } + + /* + * Fine the best match message version. + */ + has_msg_ver = false; + for (i = nego->ic_fwver_cnt; + i < nego->ic_fwver_cnt + nego->ic_msgver_cnt; ++i) { + if (VMBUS_ICVER_LE(nego->ic_ver[i], msg_ver)) { + if (!has_msg_ver) { + sel_msg_ver = nego->ic_ver[i]; + has_msg_ver = true; + } else if (VMBUS_ICVER_GT(nego->ic_ver[i], + sel_msg_ver)) { + sel_msg_ver = nego->ic_ver[i]; + } + } + } + if (!has_msg_ver) { + device_printf(sc->ic_dev, "failed to select message " + "version\n"); + goto done; + } + + error = 0; +done: + if (bootverbose || !has_fw_ver || !has_msg_ver) { + if (has_fw_ver) { + device_printf(sc->ic_dev, "sel framework version: " + "%u.%u\n", + VMBUS_ICVER_MAJOR(sel_fw_ver), + VMBUS_ICVER_MINOR(sel_fw_ver)); + } + for (i = 0; i < nego->ic_fwver_cnt; i++) { + device_printf(sc->ic_dev, "supp framework version: " + "%u.%u\n", + VMBUS_ICVER_MAJOR(nego->ic_ver[i]), + VMBUS_ICVER_MINOR(nego->ic_ver[i])); + } + + if (has_msg_ver) { + device_printf(sc->ic_dev, "sel message version: " + "%u.%u\n", + VMBUS_ICVER_MAJOR(sel_msg_ver), + VMBUS_ICVER_MINOR(sel_msg_ver)); + } + for (i = nego->ic_fwver_cnt; + i < nego->ic_fwver_cnt + nego->ic_msgver_cnt; i++) { + device_printf(sc->ic_dev, "supp message version: " + "%u.%u\n", + VMBUS_ICVER_MAJOR(nego->ic_ver[i]), + VMBUS_ICVER_MINOR(nego->ic_ver[i])); + } + } + if (error) + return (error); + + /* Record the selected versions. */ + sc->ic_fwver = sel_fw_ver; + sc->ic_msgver = sel_msg_ver; + + /* One framework version. */ + nego->ic_fwver_cnt = 1; + nego->ic_ver[0] = sel_fw_ver; + + /* One message version. */ + nego->ic_msgver_cnt = 1; + nego->ic_ver[1] = sel_msg_ver; + + /* Update data size. */ + nego->ic_hdr.ic_dsize = VMBUS_IC_NEGOSZ - + sizeof(struct vmbus_icmsg_hdr); + + /* Update total size, if necessary. */ + if (dlen < VMBUS_IC_NEGOSZ) + *dlen0 = VMBUS_IC_NEGOSZ; + + return (0); +} + +int +vmbus_ic_probe(device_t dev, const struct vmbus_ic_desc descs[]) +{ + device_t bus = device_get_parent(dev); + const struct vmbus_ic_desc *d; + + if (resource_disabled(device_get_name(dev), 0)) + return (ENXIO); + + for (d = descs; d->ic_desc != NULL; ++d) { + if (VMBUS_PROBE_GUID(bus, dev, &d->ic_guid) == 0) { + device_set_desc(dev, d->ic_desc); + return (BUS_PROBE_DEFAULT); + } + } + return (ENXIO); +} + +int +vmbus_ic_attach(device_t dev, vmbus_chan_callback_t cb) +{ + struct vmbus_ic_softc *sc = device_get_softc(dev); + struct vmbus_channel *chan = vmbus_get_channel(dev); + struct sysctl_oid_list *child; + struct sysctl_ctx_list *ctx; + int error; + + sc->ic_dev = dev; + sc->ic_buflen = VMBUS_IC_BRSIZE; + sc->ic_buf = malloc(VMBUS_IC_BRSIZE, M_DEVBUF, M_WAITOK | M_ZERO); + + /* + * These services are not performance critical and do not need + * batched reading. Furthermore, some services such as KVP can + * only handle one message from the host at a time. + * Turn off batched reading for all util drivers before we open the + * channel. + */ + vmbus_chan_set_readbatch(chan, false); + + error = vmbus_chan_open(chan, VMBUS_IC_BRSIZE, VMBUS_IC_BRSIZE, NULL, 0, + cb, sc); + if (error) { + free(sc->ic_buf, M_DEVBUF); + return (error); + } + + ctx = device_get_sysctl_ctx(dev); + child = SYSCTL_CHILDREN(device_get_sysctl_tree(dev)); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "fw_version", + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, + vmbus_ic_fwver_sysctl, "A", "framework version"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "msg_version", + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, + vmbus_ic_msgver_sysctl, "A", "message version"); + + return (0); +} + +static int +vmbus_ic_fwver_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct vmbus_ic_softc *sc = arg1; + char verstr[16]; + + snprintf(verstr, sizeof(verstr), "%u.%u", + VMBUS_ICVER_MAJOR(sc->ic_fwver), VMBUS_ICVER_MINOR(sc->ic_fwver)); + return sysctl_handle_string(oidp, verstr, sizeof(verstr), req); +} + +static int +vmbus_ic_msgver_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct vmbus_ic_softc *sc = arg1; + char verstr[16]; + + snprintf(verstr, sizeof(verstr), "%u.%u", + VMBUS_ICVER_MAJOR(sc->ic_msgver), VMBUS_ICVER_MINOR(sc->ic_msgver)); + return sysctl_handle_string(oidp, verstr, sizeof(verstr), req); +} + +int +vmbus_ic_detach(device_t dev) +{ + struct vmbus_ic_softc *sc = device_get_softc(dev); + + vmbus_chan_close(vmbus_get_channel(dev)); + free(sc->ic_buf, M_DEVBUF); + + return (0); +} + +int +vmbus_ic_sendresp(struct vmbus_ic_softc *sc, struct vmbus_channel *chan, + void *data, int dlen, uint64_t xactid) +{ + struct vmbus_icmsg_hdr *hdr; + int error; + + KASSERT(dlen >= sizeof(*hdr), ("invalid data length %d", dlen)); + hdr = data; + + hdr->ic_flags = VMBUS_ICMSG_FLAG_XACT | VMBUS_ICMSG_FLAG_RESP; + error = vmbus_chan_send(chan, VMBUS_CHANPKT_TYPE_INBAND, 0, + data, dlen, xactid); + if (error) + device_printf(sc->ic_dev, "resp send failed: %d\n", error); + return (error); +} Modified: head/sys/modules/hyperv/utilities/Makefile ============================================================================== --- head/sys/modules/hyperv/utilities/Makefile Tue Dec 20 05:45:52 2016 (r310316) +++ head/sys/modules/hyperv/utilities/Makefile Tue Dec 20 07:14:24 2016 (r310317) @@ -3,7 +3,12 @@ .PATH: ${.CURDIR}/../../../dev/hyperv/utilities KMOD= hv_utils -SRCS= hv_util.c hv_kvp.c hv_snapshot.c hv_timesync.c hv_shutdown.c hv_heartbeat.c hv_snapshot.c +SRCS= vmbus_ic.c +SRCS+= hv_heartbeat.c +SRCS+= hv_kvp.c +SRCS+= hv_shutdown.c +SRCS+= hv_snapshot.c +SRCS+= hv_timesync.c SRCS+= bus_if.h device_if.h vmbus_if.h CFLAGS+= -I${.CURDIR}/../../../dev/hyperv/include \ From owner-svn-src-head@freebsd.org Tue Dec 20 07:34:46 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 26845C8971D; Tue, 20 Dec 2016 07:34:46 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 011BD1D1B; Tue, 20 Dec 2016 07:34:45 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBK7YjY3035526; Tue, 20 Dec 2016 07:34:45 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBK7YirF035523; Tue, 20 Dec 2016 07:34:44 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201612200734.uBK7YirF035523@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 20 Dec 2016 07:34:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310318 - head/sys/dev/hyperv/utilities X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 20 Dec 2016 07:34:46 -0000 Author: sephe Date: Tue Dec 20 07:34:44 2016 New Revision: 310318 URL: https://svnweb.freebsd.org/changeset/base/310318 Log: hyperv/ic: Cleanup driver glue. MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8849 Modified: head/sys/dev/hyperv/utilities/hv_heartbeat.c head/sys/dev/hyperv/utilities/hv_shutdown.c head/sys/dev/hyperv/utilities/hv_timesync.c Modified: head/sys/dev/hyperv/utilities/hv_heartbeat.c ============================================================================== --- head/sys/dev/hyperv/utilities/hv_heartbeat.c Tue Dec 20 07:14:24 2016 (r310317) +++ head/sys/dev/hyperv/utilities/hv_heartbeat.c Tue Dec 20 07:34:44 2016 (r310318) @@ -46,6 +46,9 @@ __FBSDID("$FreeBSD$"); #define VMBUS_HEARTBEAT_MSGVER \ VMBUS_IC_VERSION(VMBUS_HEARTBEAT_MSGVER_MAJOR, 0) +static int vmbus_heartbeat_probe(device_t); +static int vmbus_heartbeat_attach(device_t); + static const struct vmbus_ic_desc vmbus_heartbeat_descs[] = { { .ic_guid = { .hv_guid = { @@ -56,6 +59,27 @@ static const struct vmbus_ic_desc vmbus_ VMBUS_IC_DESC_END }; +static device_method_t vmbus_heartbeat_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, vmbus_heartbeat_probe), + DEVMETHOD(device_attach, vmbus_heartbeat_attach), + DEVMETHOD(device_detach, vmbus_ic_detach), + DEVMETHOD_END +}; + +static driver_t vmbus_heartbeat_driver = { + "hvheartbeat", + vmbus_heartbeat_methods, + sizeof(struct vmbus_ic_softc) +}; + +static devclass_t vmbus_heartbeat_devclass; + +DRIVER_MODULE(hv_heartbeat, vmbus, vmbus_heartbeat_driver, + vmbus_heartbeat_devclass, NULL, NULL); +MODULE_VERSION(hv_heartbeat, 1); +MODULE_DEPEND(hv_heartbeat, vmbus, 1, 1, 1); + static void vmbus_heartbeat_cb(struct vmbus_channel *chan, void *xsc) { @@ -114,35 +138,15 @@ vmbus_heartbeat_cb(struct vmbus_channel } static int -hv_heartbeat_probe(device_t dev) +vmbus_heartbeat_probe(device_t dev) { return (vmbus_ic_probe(dev, vmbus_heartbeat_descs)); } static int -hv_heartbeat_attach(device_t dev) +vmbus_heartbeat_attach(device_t dev) { return (vmbus_ic_attach(dev, vmbus_heartbeat_cb)); } - -static device_method_t heartbeat_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, hv_heartbeat_probe), - DEVMETHOD(device_attach, hv_heartbeat_attach), - DEVMETHOD(device_detach, vmbus_ic_detach), - { 0, 0 } -}; - -static driver_t heartbeat_driver = { - "hvheartbeat", - heartbeat_methods, - sizeof(struct vmbus_ic_softc) -}; - -static devclass_t heartbeat_devclass; - -DRIVER_MODULE(hv_heartbeat, vmbus, heartbeat_driver, heartbeat_devclass, NULL, NULL); -MODULE_VERSION(hv_heartbeat, 1); -MODULE_DEPEND(hv_heartbeat, vmbus, 1, 1, 1); Modified: head/sys/dev/hyperv/utilities/hv_shutdown.c ============================================================================== --- head/sys/dev/hyperv/utilities/hv_shutdown.c Tue Dec 20 07:14:24 2016 (r310317) +++ head/sys/dev/hyperv/utilities/hv_shutdown.c Tue Dec 20 07:34:44 2016 (r310318) @@ -47,6 +47,9 @@ __FBSDID("$FreeBSD$"); #define VMBUS_SHUTDOWN_MSGVER \ VMBUS_IC_VERSION(VMBUS_SHUTDOWN_MSGVER_MAJOR, 0) +static int vmbus_shutdown_probe(device_t); +static int vmbus_shutdown_attach(device_t); + static const struct vmbus_ic_desc vmbus_shutdown_descs[] = { { .ic_guid = { .hv_guid = { @@ -57,6 +60,27 @@ static const struct vmbus_ic_desc vmbus_ VMBUS_IC_DESC_END }; +static device_method_t vmbus_shutdown_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, vmbus_shutdown_probe), + DEVMETHOD(device_attach, vmbus_shutdown_attach), + DEVMETHOD(device_detach, vmbus_ic_detach), + DEVMETHOD_END +}; + +static driver_t vmbus_shutdown_driver = { + "hvshutdown", + vmbus_shutdown_methods, + sizeof(struct vmbus_ic_softc) +}; + +static devclass_t vmbus_shutdown_devclass; + +DRIVER_MODULE(hv_shutdown, vmbus, vmbus_shutdown_driver, + vmbus_shutdown_devclass, NULL, NULL); +MODULE_VERSION(hv_shutdown, 1); +MODULE_DEPEND(hv_shutdown, vmbus, 1, 1, 1); + static void vmbus_shutdown_cb(struct vmbus_channel *chan, void *xsc) { @@ -129,35 +153,15 @@ vmbus_shutdown_cb(struct vmbus_channel * } static int -hv_shutdown_probe(device_t dev) +vmbus_shutdown_probe(device_t dev) { return (vmbus_ic_probe(dev, vmbus_shutdown_descs)); } static int -hv_shutdown_attach(device_t dev) +vmbus_shutdown_attach(device_t dev) { return (vmbus_ic_attach(dev, vmbus_shutdown_cb)); } - -static device_method_t shutdown_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, hv_shutdown_probe), - DEVMETHOD(device_attach, hv_shutdown_attach), - DEVMETHOD(device_detach, vmbus_ic_detach), - { 0, 0 } -}; - -static driver_t shutdown_driver = { - "hvshutdown", - shutdown_methods, - sizeof(struct vmbus_ic_softc) -}; - -static devclass_t shutdown_devclass; - -DRIVER_MODULE(hv_shutdown, vmbus, shutdown_driver, shutdown_devclass, NULL, NULL); -MODULE_VERSION(hv_shutdown, 1); -MODULE_DEPEND(hv_shutdown, vmbus, 1, 1, 1); Modified: head/sys/dev/hyperv/utilities/hv_timesync.c ============================================================================== --- head/sys/dev/hyperv/utilities/hv_timesync.c Tue Dec 20 07:14:24 2016 (r310317) +++ head/sys/dev/hyperv/utilities/hv_timesync.c Tue Dec 20 07:34:44 2016 (r310318) @@ -52,6 +52,9 @@ __FBSDID("$FreeBSD$"); ((sc)->ic_msgver >= VMBUS_IC_VERSION(4, 0) && \ (hyperv_features & CPUID_HV_MSR_TIME_REFCNT)) +static int vmbus_timesync_probe(device_t); +static int vmbus_timesync_attach(device_t); + static const struct vmbus_ic_desc vmbus_timesync_descs[] = { { .ic_guid = { .hv_guid = { @@ -62,6 +65,27 @@ static const struct vmbus_ic_desc vmbus_ VMBUS_IC_DESC_END }; +static device_method_t vmbus_timesync_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, vmbus_timesync_probe), + DEVMETHOD(device_attach, vmbus_timesync_attach), + DEVMETHOD(device_detach, vmbus_ic_detach), + DEVMETHOD_END +}; + +static driver_t vmbus_timesync_driver = { + "hvtimesync", + vmbus_timesync_methods, + sizeof(struct vmbus_ic_softc) +}; + +static devclass_t vmbus_timesync_devclass; + +DRIVER_MODULE(hv_timesync, vmbus, vmbus_timesync_driver, + vmbus_timesync_devclass, NULL, NULL); +MODULE_VERSION(hv_timesync, 1); +MODULE_DEPEND(hv_timesync, vmbus, 1, 1, 1); + SYSCTL_NODE(_hw, OID_AUTO, hvtimesync, CTLFLAG_RW | CTLFLAG_MPSAFE, NULL, "Hyper-V timesync interface"); @@ -207,35 +231,15 @@ vmbus_timesync_cb(struct vmbus_channel * } static int -hv_timesync_probe(device_t dev) +vmbus_timesync_probe(device_t dev) { return (vmbus_ic_probe(dev, vmbus_timesync_descs)); } static int -hv_timesync_attach(device_t dev) +vmbus_timesync_attach(device_t dev) { return (vmbus_ic_attach(dev, vmbus_timesync_cb)); } - -static device_method_t timesync_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, hv_timesync_probe), - DEVMETHOD(device_attach, hv_timesync_attach), - DEVMETHOD(device_detach, vmbus_ic_detach), - { 0, 0 } -}; - -static driver_t timesync_driver = { - "hvtimesync", - timesync_methods, - sizeof(struct vmbus_ic_softc) -}; - -static devclass_t timesync_devclass; - -DRIVER_MODULE(hv_timesync, vmbus, timesync_driver, timesync_devclass, NULL, NULL); -MODULE_VERSION(hv_timesync, 1); -MODULE_DEPEND(hv_timesync, vmbus, 1, 1, 1); From owner-svn-src-head@freebsd.org Tue Dec 20 08:49:14 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 44F36C880D9; Tue, 20 Dec 2016 08:49:14 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 149ED12E0; Tue, 20 Dec 2016 08:49:14 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBK8nD8B063723; Tue, 20 Dec 2016 08:49:13 GMT (envelope-from hrs@FreeBSD.org) Received: (from hrs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBK8nDbq063722; Tue, 20 Dec 2016 08:49:13 GMT (envelope-from hrs@FreeBSD.org) Message-Id: <201612200849.uBK8nDbq063722@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hrs set sender to hrs@FreeBSD.org using -f From: Hiroki Sato Date: Tue, 20 Dec 2016 08:49:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310323 - head/usr.sbin/syslogd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 20 Dec 2016 08:49:14 -0000 Author: hrs Date: Tue Dec 20 08:49:13 2016 New Revision: 310323 URL: https://svnweb.freebsd.org/changeset/base/310323 Log: Escape punctuation characters. Modified: head/usr.sbin/syslogd/syslogd.8 Modified: head/usr.sbin/syslogd/syslogd.8 ============================================================================== --- head/usr.sbin/syslogd/syslogd.8 Tue Dec 20 08:42:47 2016 (r310322) +++ head/usr.sbin/syslogd/syslogd.8 Tue Dec 20 08:49:13 2016 (r310323) @@ -40,7 +40,7 @@ .Op Fl a Ar allowed_peer .Op Fl b Ar bind_address .Op Fl f Ar config_file -.Op Fl l Oo Ar mode : Oc Ns Ar path +.Op Fl l Oo Ar mode \&: Oc Ns Ar path .Op Fl m Ar mark_interval .Op Fl P Ar pid_file .Op Fl p Ar log_socket @@ -103,7 +103,7 @@ option may be any of the following: .Sm off .Ar ipaddr .No / Ar masklen -.Op : Ar service +.Op \&: Ar service .Sm on .Xc Accept datagrams from @@ -145,7 +145,7 @@ is IPv6 address, a missing will be substituted by 128. .It Xo .Sm off -.Ar domainname Op : Ar service +.Ar domainname Op \&: Ar service .Sm on .Xc Accept datagrams where the reverse address lookup yields @@ -156,7 +156,7 @@ The meaning of is as explained above. .It Xo .Sm off -.No * Ar domainname Op : Ar service +.No * Ar domainname Op \&: Ar service .Sm on .Xc Same as before, except that any source host whose name @@ -174,13 +174,13 @@ option is also specified. .It Xo .Fl b .Sm off -.Ar bind_address Op : Ar service +.Ar bind_address Op \&: Ar service .Sm on .Xc .It Xo .Fl b .Sm off -.Li : Ar service +.Li \&: Ar service .Sm on .Xc Bind to a specific address and/or port. From owner-svn-src-head@freebsd.org Tue Dec 20 09:46:16 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 07C72C8755C; Tue, 20 Dec 2016 09:46:16 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 C44D2112; Tue, 20 Dec 2016 09:46:15 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBK9kFC1088341; Tue, 20 Dec 2016 09:46:15 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBK9kEJp088335; Tue, 20 Dec 2016 09:46:14 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201612200946.uBK9kEJp088335@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 20 Dec 2016 09:46:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310324 - in head/sys: conf dev/hyperv/utilities modules/hyperv/utilities X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 20 Dec 2016 09:46:16 -0000 Author: sephe Date: Tue Dec 20 09:46:14 2016 New Revision: 310324 URL: https://svnweb.freebsd.org/changeset/base/310324 Log: hyperv/ic: Rename cleaned up files. MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8850 Added: head/sys/dev/hyperv/utilities/vmbus_heartbeat.c - copied unchanged from r310323, head/sys/dev/hyperv/utilities/hv_heartbeat.c head/sys/dev/hyperv/utilities/vmbus_shutdown.c - copied unchanged from r310323, head/sys/dev/hyperv/utilities/hv_shutdown.c head/sys/dev/hyperv/utilities/vmbus_timesync.c - copied unchanged from r310323, head/sys/dev/hyperv/utilities/hv_timesync.c Deleted: head/sys/dev/hyperv/utilities/hv_heartbeat.c head/sys/dev/hyperv/utilities/hv_shutdown.c head/sys/dev/hyperv/utilities/hv_timesync.c Modified: head/sys/conf/files.amd64 head/sys/conf/files.i386 head/sys/modules/hyperv/utilities/Makefile Modified: head/sys/conf/files.amd64 ============================================================================== --- head/sys/conf/files.amd64 Tue Dec 20 08:49:13 2016 (r310323) +++ head/sys/conf/files.amd64 Tue Dec 20 09:46:14 2016 (r310324) @@ -298,12 +298,12 @@ dev/hyperv/netvsc/hn_nvs.c optional h dev/hyperv/netvsc/hn_rndis.c optional hyperv dev/hyperv/netvsc/if_hn.c optional hyperv dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c optional hyperv -dev/hyperv/utilities/hv_heartbeat.c optional hyperv dev/hyperv/utilities/hv_kvp.c optional hyperv dev/hyperv/utilities/hv_snapshot.c optional hyperv -dev/hyperv/utilities/hv_shutdown.c optional hyperv -dev/hyperv/utilities/hv_timesync.c optional hyperv +dev/hyperv/utilities/vmbus_heartbeat.c optional hyperv dev/hyperv/utilities/vmbus_ic.c optional hyperv +dev/hyperv/utilities/vmbus_shutdown.c optional hyperv +dev/hyperv/utilities/vmbus_timesync.c optional hyperv dev/hyperv/vmbus/hyperv.c optional hyperv dev/hyperv/vmbus/hyperv_busdma.c optional hyperv dev/hyperv/vmbus/vmbus.c optional hyperv pci Modified: head/sys/conf/files.i386 ============================================================================== --- head/sys/conf/files.i386 Tue Dec 20 08:49:13 2016 (r310323) +++ head/sys/conf/files.i386 Tue Dec 20 09:46:14 2016 (r310324) @@ -254,12 +254,12 @@ dev/hyperv/netvsc/hn_nvs.c optional h dev/hyperv/netvsc/hn_rndis.c optional hyperv dev/hyperv/netvsc/if_hn.c optional hyperv dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c optional hyperv -dev/hyperv/utilities/hv_heartbeat.c optional hyperv dev/hyperv/utilities/hv_kvp.c optional hyperv dev/hyperv/utilities/hv_snapshot.c optional hyperv -dev/hyperv/utilities/hv_shutdown.c optional hyperv -dev/hyperv/utilities/hv_timesync.c optional hyperv +dev/hyperv/utilities/vmbus_heartbeat.c optional hyperv dev/hyperv/utilities/vmbus_ic.c optional hyperv +dev/hyperv/utilities/vmbus_shutdown.c optional hyperv +dev/hyperv/utilities/vmbus_timesync.c optional hyperv dev/hyperv/vmbus/hyperv.c optional hyperv dev/hyperv/vmbus/hyperv_busdma.c optional hyperv dev/hyperv/vmbus/vmbus.c optional hyperv pci Copied: head/sys/dev/hyperv/utilities/vmbus_heartbeat.c (from r310323, head/sys/dev/hyperv/utilities/hv_heartbeat.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/hyperv/utilities/vmbus_heartbeat.c Tue Dec 20 09:46:14 2016 (r310324, copy of r310323, head/sys/dev/hyperv/utilities/hv_heartbeat.c) @@ -0,0 +1,152 @@ +/*- + * Copyright (c) 2014,2016 Microsoft Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#define VMBUS_HEARTBEAT_FWVER_MAJOR 3 +#define VMBUS_HEARTBEAT_FWVER \ + VMBUS_IC_VERSION(VMBUS_HEARTBEAT_FWVER_MAJOR, 0) + +#define VMBUS_HEARTBEAT_MSGVER_MAJOR 3 +#define VMBUS_HEARTBEAT_MSGVER \ + VMBUS_IC_VERSION(VMBUS_HEARTBEAT_MSGVER_MAJOR, 0) + +static int vmbus_heartbeat_probe(device_t); +static int vmbus_heartbeat_attach(device_t); + +static const struct vmbus_ic_desc vmbus_heartbeat_descs[] = { + { + .ic_guid = { .hv_guid = { + 0x39, 0x4f, 0x16, 0x57, 0x15, 0x91, 0x78, 0x4e, + 0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d} }, + .ic_desc = "Hyper-V Heartbeat" + }, + VMBUS_IC_DESC_END +}; + +static device_method_t vmbus_heartbeat_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, vmbus_heartbeat_probe), + DEVMETHOD(device_attach, vmbus_heartbeat_attach), + DEVMETHOD(device_detach, vmbus_ic_detach), + DEVMETHOD_END +}; + +static driver_t vmbus_heartbeat_driver = { + "hvheartbeat", + vmbus_heartbeat_methods, + sizeof(struct vmbus_ic_softc) +}; + +static devclass_t vmbus_heartbeat_devclass; + +DRIVER_MODULE(hv_heartbeat, vmbus, vmbus_heartbeat_driver, + vmbus_heartbeat_devclass, NULL, NULL); +MODULE_VERSION(hv_heartbeat, 1); +MODULE_DEPEND(hv_heartbeat, vmbus, 1, 1, 1); + +static void +vmbus_heartbeat_cb(struct vmbus_channel *chan, void *xsc) +{ + struct vmbus_ic_softc *sc = xsc; + struct vmbus_icmsg_hdr *hdr; + int dlen, error; + uint64_t xactid; + void *data; + + /* + * Receive request. + */ + data = sc->ic_buf; + dlen = sc->ic_buflen; + error = vmbus_chan_recv(chan, data, &dlen, &xactid); + KASSERT(error != ENOBUFS, ("icbuf is not large enough")); + if (error) + return; + + if (dlen < sizeof(*hdr)) { + device_printf(sc->ic_dev, "invalid data len %d\n", dlen); + return; + } + hdr = data; + + /* + * Update request, which will be echoed back as response. + */ + switch (hdr->ic_type) { + case VMBUS_ICMSG_TYPE_NEGOTIATE: + error = vmbus_ic_negomsg(sc, data, &dlen, + VMBUS_HEARTBEAT_FWVER, VMBUS_HEARTBEAT_MSGVER); + if (error) + return; + break; + + case VMBUS_ICMSG_TYPE_HEARTBEAT: + /* Only ic_seq is a must */ + if (dlen < VMBUS_ICMSG_HEARTBEAT_SIZE_MIN) { + device_printf(sc->ic_dev, "invalid heartbeat len %d\n", + dlen); + return; + } + ((struct vmbus_icmsg_heartbeat *)data)->ic_seq++; + break; + + default: + device_printf(sc->ic_dev, "got 0x%08x icmsg\n", hdr->ic_type); + break; + } + + /* + * Send response by echoing the request back. + */ + vmbus_ic_sendresp(sc, chan, data, dlen, xactid); +} + +static int +vmbus_heartbeat_probe(device_t dev) +{ + + return (vmbus_ic_probe(dev, vmbus_heartbeat_descs)); +} + +static int +vmbus_heartbeat_attach(device_t dev) +{ + + return (vmbus_ic_attach(dev, vmbus_heartbeat_cb)); +} Copied: head/sys/dev/hyperv/utilities/vmbus_shutdown.c (from r310323, head/sys/dev/hyperv/utilities/hv_shutdown.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/hyperv/utilities/vmbus_shutdown.c Tue Dec 20 09:46:14 2016 (r310324, copy of r310323, head/sys/dev/hyperv/utilities/hv_shutdown.c) @@ -0,0 +1,167 @@ +/*- + * Copyright (c) 2014,2016 Microsoft Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#define VMBUS_SHUTDOWN_FWVER_MAJOR 3 +#define VMBUS_SHUTDOWN_FWVER \ + VMBUS_IC_VERSION(VMBUS_SHUTDOWN_FWVER_MAJOR, 0) + +#define VMBUS_SHUTDOWN_MSGVER_MAJOR 3 +#define VMBUS_SHUTDOWN_MSGVER \ + VMBUS_IC_VERSION(VMBUS_SHUTDOWN_MSGVER_MAJOR, 0) + +static int vmbus_shutdown_probe(device_t); +static int vmbus_shutdown_attach(device_t); + +static const struct vmbus_ic_desc vmbus_shutdown_descs[] = { + { + .ic_guid = { .hv_guid = { + 0x31, 0x60, 0x0b, 0x0e, 0x13, 0x52, 0x34, 0x49, + 0x81, 0x8b, 0x38, 0xd9, 0x0c, 0xed, 0x39, 0xdb } }, + .ic_desc = "Hyper-V Shutdown" + }, + VMBUS_IC_DESC_END +}; + +static device_method_t vmbus_shutdown_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, vmbus_shutdown_probe), + DEVMETHOD(device_attach, vmbus_shutdown_attach), + DEVMETHOD(device_detach, vmbus_ic_detach), + DEVMETHOD_END +}; + +static driver_t vmbus_shutdown_driver = { + "hvshutdown", + vmbus_shutdown_methods, + sizeof(struct vmbus_ic_softc) +}; + +static devclass_t vmbus_shutdown_devclass; + +DRIVER_MODULE(hv_shutdown, vmbus, vmbus_shutdown_driver, + vmbus_shutdown_devclass, NULL, NULL); +MODULE_VERSION(hv_shutdown, 1); +MODULE_DEPEND(hv_shutdown, vmbus, 1, 1, 1); + +static void +vmbus_shutdown_cb(struct vmbus_channel *chan, void *xsc) +{ + struct vmbus_ic_softc *sc = xsc; + struct vmbus_icmsg_hdr *hdr; + struct vmbus_icmsg_shutdown *msg; + int dlen, error, do_shutdown = 0; + uint64_t xactid; + void *data; + + /* + * Receive request. + */ + data = sc->ic_buf; + dlen = sc->ic_buflen; + error = vmbus_chan_recv(chan, data, &dlen, &xactid); + KASSERT(error != ENOBUFS, ("icbuf is not large enough")); + if (error) + return; + + if (dlen < sizeof(*hdr)) { + device_printf(sc->ic_dev, "invalid data len %d\n", dlen); + return; + } + hdr = data; + + /* + * Update request, which will be echoed back as response. + */ + switch (hdr->ic_type) { + case VMBUS_ICMSG_TYPE_NEGOTIATE: + error = vmbus_ic_negomsg(sc, data, &dlen, + VMBUS_SHUTDOWN_FWVER, VMBUS_SHUTDOWN_MSGVER); + if (error) + return; + break; + + case VMBUS_ICMSG_TYPE_SHUTDOWN: + if (dlen < VMBUS_ICMSG_SHUTDOWN_SIZE_MIN) { + device_printf(sc->ic_dev, "invalid shutdown len %d\n", + dlen); + return; + } + msg = data; + + /* XXX ic_flags definition? */ + if (msg->ic_haltflags == 0 || msg->ic_haltflags == 1) { + device_printf(sc->ic_dev, "shutdown requested\n"); + hdr->ic_status = VMBUS_ICMSG_STATUS_OK; + do_shutdown = 1; + } else { + device_printf(sc->ic_dev, "unknown shutdown flags " + "0x%08x\n", msg->ic_haltflags); + hdr->ic_status = VMBUS_ICMSG_STATUS_FAIL; + } + break; + + default: + device_printf(sc->ic_dev, "got 0x%08x icmsg\n", hdr->ic_type); + break; + } + + /* + * Send response by echoing the request back. + */ + vmbus_ic_sendresp(sc, chan, data, dlen, xactid); + + if (do_shutdown) + shutdown_nice(RB_POWEROFF); +} + +static int +vmbus_shutdown_probe(device_t dev) +{ + + return (vmbus_ic_probe(dev, vmbus_shutdown_descs)); +} + +static int +vmbus_shutdown_attach(device_t dev) +{ + + return (vmbus_ic_attach(dev, vmbus_shutdown_cb)); +} Copied: head/sys/dev/hyperv/utilities/vmbus_timesync.c (from r310323, head/sys/dev/hyperv/utilities/hv_timesync.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/hyperv/utilities/vmbus_timesync.c Tue Dec 20 09:46:14 2016 (r310324, copy of r310323, head/sys/dev/hyperv/utilities/hv_timesync.c) @@ -0,0 +1,245 @@ +/*- + * Copyright (c) 2014,2016 Microsoft Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#define VMBUS_TIMESYNC_FWVER_MAJOR 3 +#define VMBUS_TIMESYNC_FWVER \ + VMBUS_IC_VERSION(VMBUS_TIMESYNC_FWVER_MAJOR, 0) + +#define VMBUS_TIMESYNC_MSGVER_MAJOR 4 +#define VMBUS_TIMESYNC_MSGVER \ + VMBUS_IC_VERSION(VMBUS_TIMESYNC_MSGVER_MAJOR, 0) + +#define VMBUS_TIMESYNC_DORTT(sc) \ + ((sc)->ic_msgver >= VMBUS_IC_VERSION(4, 0) && \ + (hyperv_features & CPUID_HV_MSR_TIME_REFCNT)) + +static int vmbus_timesync_probe(device_t); +static int vmbus_timesync_attach(device_t); + +static const struct vmbus_ic_desc vmbus_timesync_descs[] = { + { + .ic_guid = { .hv_guid = { + 0x30, 0xe6, 0x27, 0x95, 0xae, 0xd0, 0x7b, 0x49, + 0xad, 0xce, 0xe8, 0x0a, 0xb0, 0x17, 0x5c, 0xaf } }, + .ic_desc = "Hyper-V Timesync" + }, + VMBUS_IC_DESC_END +}; + +static device_method_t vmbus_timesync_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, vmbus_timesync_probe), + DEVMETHOD(device_attach, vmbus_timesync_attach), + DEVMETHOD(device_detach, vmbus_ic_detach), + DEVMETHOD_END +}; + +static driver_t vmbus_timesync_driver = { + "hvtimesync", + vmbus_timesync_methods, + sizeof(struct vmbus_ic_softc) +}; + +static devclass_t vmbus_timesync_devclass; + +DRIVER_MODULE(hv_timesync, vmbus, vmbus_timesync_driver, + vmbus_timesync_devclass, NULL, NULL); +MODULE_VERSION(hv_timesync, 1); +MODULE_DEPEND(hv_timesync, vmbus, 1, 1, 1); + +SYSCTL_NODE(_hw, OID_AUTO, hvtimesync, CTLFLAG_RW | CTLFLAG_MPSAFE, NULL, + "Hyper-V timesync interface"); + +static int vmbus_ts_ignore_sync = 0; +SYSCTL_INT(_hw_hvtimesync, OID_AUTO, ignore_sync, CTLFLAG_RWTUN, + &vmbus_ts_ignore_sync, 0, "Ignore the sync request."); + +/* + * Trigger sample sync when drift exceeds threshold (ms). + * Ignore the sample request when set to 0. + */ +static int vmbus_ts_sample_thresh = 100; +SYSCTL_INT(_hw_hvtimesync, OID_AUTO, sample_thresh, CTLFLAG_RWTUN, + &vmbus_ts_sample_thresh, 0, + "Threshold that makes sample request trigger the sync (unit: ms)."); + +static int vmbus_ts_sample_verbose = 0; +SYSCTL_INT(_hw_hvtimesync, OID_AUTO, sample_verbose, CTLFLAG_RWTUN, + &vmbus_ts_sample_verbose, 0, "Increase sample request verbosity."); + +static void +vmbus_timesync(struct vmbus_ic_softc *sc, uint64_t hvtime, uint64_t sent_tc, + uint8_t tsflags) +{ + struct timespec vm_ts; + uint64_t hv_ns, vm_ns, rtt = 0; + + if (VMBUS_TIMESYNC_DORTT(sc)) + rtt = rdmsr(MSR_HV_TIME_REF_COUNT) - sent_tc; + + hv_ns = (hvtime - VMBUS_ICMSG_TS_BASE + rtt) * HYPERV_TIMER_NS_FACTOR; + nanotime(&vm_ts); + vm_ns = (vm_ts.tv_sec * NANOSEC) + vm_ts.tv_nsec; + + if ((tsflags & VMBUS_ICMSG_TS_FLAG_SYNC) && !vmbus_ts_ignore_sync) { + struct timespec hv_ts; + + if (bootverbose) { + device_printf(sc->ic_dev, "apply sync request, " + "hv: %ju, vm: %ju\n", + (uintmax_t)hv_ns, (uintmax_t)vm_ns); + } + hv_ts.tv_sec = hv_ns / NANOSEC; + hv_ts.tv_nsec = hv_ns % NANOSEC; + kern_clock_settime(curthread, CLOCK_REALTIME, &hv_ts); + /* Done! */ + return; + } + + if ((tsflags & VMBUS_ICMSG_TS_FLAG_SAMPLE) && + vmbus_ts_sample_thresh > 0) { + int64_t diff; + + if (vmbus_ts_sample_verbose) { + device_printf(sc->ic_dev, "sample request, " + "hv: %ju, vm: %ju\n", + (uintmax_t)hv_ns, (uintmax_t)vm_ns); + } + + if (hv_ns > vm_ns) + diff = hv_ns - vm_ns; + else + diff = vm_ns - hv_ns; + /* nanosec -> millisec */ + diff /= 1000000; + + if (diff > vmbus_ts_sample_thresh) { + struct timespec hv_ts; + + if (bootverbose) { + device_printf(sc->ic_dev, + "apply sample request, hv: %ju, vm: %ju\n", + (uintmax_t)hv_ns, (uintmax_t)vm_ns); + } + hv_ts.tv_sec = hv_ns / NANOSEC; + hv_ts.tv_nsec = hv_ns % NANOSEC; + kern_clock_settime(curthread, CLOCK_REALTIME, &hv_ts); + } + /* Done */ + return; + } +} + +static void +vmbus_timesync_cb(struct vmbus_channel *chan, void *xsc) +{ + struct vmbus_ic_softc *sc = xsc; + struct vmbus_icmsg_hdr *hdr; + const struct vmbus_icmsg_timesync *msg; + int dlen, error; + uint64_t xactid; + void *data; + + /* + * Receive request. + */ + data = sc->ic_buf; + dlen = sc->ic_buflen; + error = vmbus_chan_recv(chan, data, &dlen, &xactid); + KASSERT(error != ENOBUFS, ("icbuf is not large enough")); + if (error) + return; + + if (dlen < sizeof(*hdr)) { + device_printf(sc->ic_dev, "invalid data len %d\n", dlen); + return; + } + hdr = data; + + /* + * Update request, which will be echoed back as response. + */ + switch (hdr->ic_type) { + case VMBUS_ICMSG_TYPE_NEGOTIATE: + error = vmbus_ic_negomsg(sc, data, &dlen, + VMBUS_TIMESYNC_FWVER, VMBUS_TIMESYNC_MSGVER); + if (error) + return; + if (VMBUS_TIMESYNC_DORTT(sc)) + device_printf(sc->ic_dev, "RTT\n"); + break; + + case VMBUS_ICMSG_TYPE_TIMESYNC: + if (dlen < sizeof(*msg)) { + device_printf(sc->ic_dev, "invalid timesync len %d\n", + dlen); + return; + } + msg = data; + vmbus_timesync(sc, msg->ic_hvtime, msg->ic_sent_tc, + msg->ic_tsflags); + break; + + default: + device_printf(sc->ic_dev, "got 0x%08x icmsg\n", hdr->ic_type); + break; + } + + /* + * Send response by echoing the request back. + */ + vmbus_ic_sendresp(sc, chan, data, dlen, xactid); +} + +static int +vmbus_timesync_probe(device_t dev) +{ + + return (vmbus_ic_probe(dev, vmbus_timesync_descs)); +} + +static int +vmbus_timesync_attach(device_t dev) +{ + + return (vmbus_ic_attach(dev, vmbus_timesync_cb)); +} Modified: head/sys/modules/hyperv/utilities/Makefile ============================================================================== --- head/sys/modules/hyperv/utilities/Makefile Tue Dec 20 08:49:13 2016 (r310323) +++ head/sys/modules/hyperv/utilities/Makefile Tue Dec 20 09:46:14 2016 (r310324) @@ -4,11 +4,11 @@ KMOD= hv_utils SRCS= vmbus_ic.c -SRCS+= hv_heartbeat.c SRCS+= hv_kvp.c -SRCS+= hv_shutdown.c SRCS+= hv_snapshot.c -SRCS+= hv_timesync.c +SRCS+= vmbus_heartbeat.c +SRCS+= vmbus_shutdown.c +SRCS+= vmbus_timesync.c SRCS+= bus_if.h device_if.h vmbus_if.h CFLAGS+= -I${.CURDIR}/../../../dev/hyperv/include \ From owner-svn-src-head@freebsd.org Tue Dec 20 14:52:18 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D9AF4C88AEB; Tue, 20 Dec 2016 14:52:18 +0000 (UTC) (envelope-from rysto32@gmail.com) Received: from mail-it0-x229.google.com (mail-it0-x229.google.com [IPv6:2607:f8b0:4001:c0b::229]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A2FCC756; Tue, 20 Dec 2016 14:52:18 +0000 (UTC) (envelope-from rysto32@gmail.com) Received: by mail-it0-x229.google.com with SMTP id c20so82348247itb.0; Tue, 20 Dec 2016 06:52:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=DgnXGuIaE/Pqoxnb2SU6aaXhauQX+pfTTlJFIXWYpIg=; b=am4ZH8A9/uGDhOy7Ige2FJtKCwCA9sq+ZWfe7VGjqBMJO12dqhra8SydTTyyY0Khdi mLG3OKn6HxzjGVqWWRCh1+IKqGziNEqVFnjY1Erxks164akU6t/LFi2YO5cu3xOLXJvG qBWa0gEjoX5GB2siCslX8mjyVfrs6dwEpemSnVNeNv8zrhezl14nzO2pSMi5H1S3B6QH Xt8cblKy5Sb8xfqzO88jL4JHNceoOJJ57noQsNR2MqRgUZ1aKS4QPT9/5MpjNGIGEpyz k5YF3dh8O2ZSJ7XWqnB9NjfPzcgEmpRsmYr1CXdITfJuIu4Eeq8/MQSBvyJooTIY50ZW kfog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=DgnXGuIaE/Pqoxnb2SU6aaXhauQX+pfTTlJFIXWYpIg=; b=XjvBm6DP7HDz61AHVEgA2/U34ZaxHQF9RrlXcgoxNgcwyPYNGaJAlrsYX7SMSfe0Wf 5Esu9/Jwmud5+UPNMpwJqNd+4svMp/G+iDaiYO7pkPzeGDXfh4nWA0RoEos52t4VAcy3 KF0kT+5hNP1/hjSVKqKlTTqGpiZ3is419qTTYfqD8VQ73j99jkR1wGkzCX6H/u+nwHIE A1ajnWLuckD5k8U6C19HrcW9tJ3p8ZsJndr4lLuwjfpSjzdFsAmpef8outziCNC8vMqB blYGgdaCf1mZFezVUDJsEoXYScC2AU3ufSV+14MBR4lE6Ffh9wf8iWIgms9Y434e6qCc H35A== X-Gm-Message-State: AIkVDXKnZI7Cai6aqNQX8PkAqaSyyY6Y+lD7oAPCKnS4a+uxDRE1+xRZQOovEAPnP8VCMwWZN2q+sVSWeuWfIg== X-Received: by 10.36.131.138 with SMTP id d132mr385620ite.98.1482245537920; Tue, 20 Dec 2016 06:52:17 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.144.84 with HTTP; Tue, 20 Dec 2016 06:52:17 -0800 (PST) In-Reply-To: <201612162239.uBGMdVSL027853@repo.freebsd.org> References: <201612162239.uBGMdVSL027853@repo.freebsd.org> From: Ryan Stone Date: Tue, 20 Dec 2016 09:52:17 -0500 Message-ID: Subject: Re: svn commit: r310180 - head/sys/net To: Alan Somers Cc: "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 20 Dec 2016 14:52:19 -0000 On Fri, Dec 16, 2016 at 5:39 PM, Alan Somers wrote: > > Modified: head/sys/net/if_lagg.c > ============================================================ > ================== > --- head/sys/net/if_lagg.c Fri Dec 16 22:37:16 2016 (r310179) > +++ head/sys/net/if_lagg.c Fri Dec 16 22:39:30 2016 (r310180) > @@ -252,6 +252,7 @@ SYSCTL_INT(_net_link_lagg, OID_AUTO, def > &VNET_NAME(def_flowid_shift), 0, > "Default setting for flowid shift for load sharing"); > > +#pragma clang optimize off > static void > vnet_lagg_init(const void *unused __unused) > { > Did you intend to commit this pragma? From owner-svn-src-head@freebsd.org Tue Dec 20 15:45:54 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 77599C89A09; Tue, 20 Dec 2016 15:45:54 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 396CB216; Tue, 20 Dec 2016 15:45:54 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBKFjrjk033909; Tue, 20 Dec 2016 15:45:53 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBKFjrJj033908; Tue, 20 Dec 2016 15:45:53 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201612201545.uBKFjrJj033908@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Tue, 20 Dec 2016 15:45:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310327 - head/sys/net X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 20 Dec 2016 15:45:54 -0000 Author: asomers Date: Tue Dec 20 15:45:53 2016 New Revision: 310327 URL: https://svnweb.freebsd.org/changeset/base/310327 Log: Remove stray debugging code from r310180 Reported by: rstone Pointy hat to: asomers MFC after: 3 weeks X-MFC-with: 310180 Sponsored by: Spectra Logic Corp Modified: head/sys/net/if_lagg.c Modified: head/sys/net/if_lagg.c ============================================================================== --- head/sys/net/if_lagg.c Tue Dec 20 10:56:08 2016 (r310326) +++ head/sys/net/if_lagg.c Tue Dec 20 15:45:53 2016 (r310327) @@ -252,7 +252,6 @@ SYSCTL_INT(_net_link_lagg, OID_AUTO, def &VNET_NAME(def_flowid_shift), 0, "Default setting for flowid shift for load sharing"); -#pragma clang optimize off static void vnet_lagg_init(const void *unused __unused) { From owner-svn-src-head@freebsd.org Tue Dec 20 15:47:26 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CE89BC89AAF; Tue, 20 Dec 2016 15:47:26 +0000 (UTC) (envelope-from asomers@gmail.com) Received: from mail-qt0-x242.google.com (mail-qt0-x242.google.com [IPv6:2607:f8b0:400d:c0d::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 92218418; Tue, 20 Dec 2016 15:47:26 +0000 (UTC) (envelope-from asomers@gmail.com) Received: by mail-qt0-x242.google.com with SMTP id n6so23365351qtd.0; Tue, 20 Dec 2016 07:47:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=T05k9yCyxEn9ZUZ8RSWlEwqgfJIEU0NJgyNy/owTWIY=; b=LMxOtqWmcqu6FNbDv3jnwGyvb8gkEfbl6525nZTqnsULN2LbpjF8fLyCTUQLGhlmXh g75J0ZlI0iPHH9VDvgPxwQeAoHvFgsB4w7JVpkdhXYuODEYxUmS7C/iDYzl71hAFkaJd YGdH1v9VZVJvyB553Q6eV2ItWxKLstDVpzmqD7tk5L+5JwMQBmd/4a2G1txU2zH1bCx4 bDdGXEVMjFEbK967K8NMmOu8dF09BvcJ9SJ6wKR8mLJzRonulzYM/ydPqtu1GxUH+2Ei /pcPaur3i+jXDnY/wriAKiJFplTLlU+HTEljSoOUOmRZ4LcsmnHer/ZXy6PMby2K33Mn QFig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=T05k9yCyxEn9ZUZ8RSWlEwqgfJIEU0NJgyNy/owTWIY=; b=ECNLPYd2dCTETyUIlaRviqj5FKGtIxdgSUuUBooyz8+ZKvpI6ZsFVnI/Kpp+UnhuQv +FSb70vd/U8eY/ruF2SGPIsZiB7wh2+rl1srGjPtEjtqbY6b/JiCDJnIq9xhQv+S1qAR jzcH4MS1c8PQEaD0+6g4Hr0GOGCA1atx+h/kqQ+RWCxB0iHFeXsBczxPSmPeuvyOxtZr zn/5HfZZc3O4DBmC7sWEX+0QCtD//N6hz7sS5PpshnucDNKLYqxbMN4cJAIwcPjcSGNL /PUGolD8YQdCj7faJYYQ6+J1QMTlcvIaFKuC6wYYvvO51fevqWdCxo3dZYLjcsJby6rf sZWw== X-Gm-Message-State: AIkVDXKHrxWkHsrEnqsLnFJTs7Jq1dAdc6JC0+gPqY5B0R7dpG07mBNSxMRxB1ptKdWHj0XOH495hJuOlfADkg== X-Received: by 10.200.37.178 with SMTP id e47mr23256566qte.7.1482248845615; Tue, 20 Dec 2016 07:47:25 -0800 (PST) MIME-Version: 1.0 Sender: asomers@gmail.com Received: by 10.12.181.208 with HTTP; Tue, 20 Dec 2016 07:47:25 -0800 (PST) In-Reply-To: References: <201612162239.uBGMdVSL027853@repo.freebsd.org> From: Alan Somers Date: Tue, 20 Dec 2016 08:47:25 -0700 X-Google-Sender-Auth: pIhahnB2XHbRCs0ZKGGS57bUzdo Message-ID: Subject: Re: svn commit: r310180 - head/sys/net To: Ryan Stone Cc: "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 20 Dec 2016 15:47:26 -0000 On Tue, Dec 20, 2016 at 7:52 AM, Ryan Stone wrote: > > > On Fri, Dec 16, 2016 at 5:39 PM, Alan Somers wrote: >> >> >> Modified: head/sys/net/if_lagg.c >> >> ============================================================================== >> --- head/sys/net/if_lagg.c Fri Dec 16 22:37:16 2016 (r310179) >> +++ head/sys/net/if_lagg.c Fri Dec 16 22:39:30 2016 (r310180) >> @@ -252,6 +252,7 @@ SYSCTL_INT(_net_link_lagg, OID_AUTO, def >> &VNET_NAME(def_flowid_shift), 0, >> "Default setting for flowid shift for load sharing"); >> >> +#pragma clang optimize off >> static void >> vnet_lagg_init(const void *unused __unused) >> { > > > Did you intend to commit this pragma? > Uh, no. Fixed in r310327. From owner-svn-src-head@freebsd.org Tue Dec 20 17:12:18 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DE186C89BED; Tue, 20 Dec 2016 17:12:18 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 A01C580D; Tue, 20 Dec 2016 17:12:18 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBKHCHaX070769; Tue, 20 Dec 2016 17:12:17 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBKHCHlZ070767; Tue, 20 Dec 2016 17:12:17 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201612201712.uBKHCHlZ070767@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: "Conrad E. Meyer" Date: Tue, 20 Dec 2016 17:12:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310329 - head/usr.sbin/cron/crontab X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 20 Dec 2016 17:12:19 -0000 Author: cem Date: Tue Dec 20 17:12:17 2016 New Revision: 310329 URL: https://svnweb.freebsd.org/changeset/base/310329 Log: Add a 'force' option for non-interactive crontab removal Add a '-f' option to force crontab '-r' to be non-interactive. Submitted by: Sam Gwydir Reviewed by: me, wblock (previous version) Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D8815 Modified: head/usr.sbin/cron/crontab/crontab.1 head/usr.sbin/cron/crontab/crontab.c Modified: head/usr.sbin/cron/crontab/crontab.1 ============================================================================== --- head/usr.sbin/cron/crontab/crontab.1 Tue Dec 20 16:37:45 2016 (r310328) +++ head/usr.sbin/cron/crontab/crontab.1 Tue Dec 20 17:12:17 2016 (r310329) @@ -17,7 +17,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 13, 2010 +.Dd December 20, 2016 .Dt CRONTAB 1 .Os .Sh NAME @@ -31,7 +31,8 @@ .Op Fl u Ar user { .Fl l | -.Fl r | +.Fl r Op Fl f +| .Fl e } .Sh DESCRIPTION @@ -97,6 +98,11 @@ option for safety's sake. Display the current crontab on standard output. .It Fl r Remove the current crontab. +By default the +.Fl r +option prompts for confirmation, adding the +.Fl f +option will attempt to remove the current crontab without confirmation. .It Fl e Edit the current crontab using the editor specified by the Modified: head/usr.sbin/cron/crontab/crontab.c ============================================================================== --- head/usr.sbin/cron/crontab/crontab.c Tue Dec 20 16:37:45 2016 (r310328) +++ head/usr.sbin/cron/crontab/crontab.c Tue Dec 20 17:12:17 2016 (r310329) @@ -63,6 +63,7 @@ static char Filename[MAX_FNAME]; static FILE *NewCrontab; static int CheckErrorCount; static enum opt_t Option; +static int fflag; static struct passwd *pw; static void list_cmd(void), delete_cmd(void), @@ -79,7 +80,7 @@ usage(char *msg) fprintf(stderr, "crontab: usage error: %s\n", msg); fprintf(stderr, "%s\n%s\n", "usage: crontab [-u user] file", - " crontab [-u user] { -e | -l | -r }"); + " crontab [-u user] { -l | -r [-f] | -e }"); exit(ERROR_EXIT); } @@ -142,7 +143,7 @@ parse_args(argc, argv) strcpy(RealUser, User); Filename[0] = '\0'; Option = opt_unknown; - while ((argch = getopt(argc, argv, "u:lerx:")) != -1) { + while ((argch = getopt(argc, argv, "u:lerx:f")) != -1) { switch (argch) { case 'x': if (!set_debug_flags(optarg)) @@ -172,6 +173,9 @@ parse_args(argc, argv) usage("only one operation permitted"); Option = opt_edit; break; + case 'f': + fflag = 1; + break; default: usage("unrecognized option"); } @@ -282,7 +286,7 @@ delete_cmd() { char n[MAX_FNAME]; int ch, first; - if (isatty(STDIN_FILENO)) { + if (!fflag && isatty(STDIN_FILENO)) { (void)fprintf(stderr, "remove crontab for %s? ", User); first = ch = getchar(); while (ch != '\n' && ch != EOF) From owner-svn-src-head@freebsd.org Tue Dec 20 18:02:08 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B3849C89DD1; Tue, 20 Dec 2016 18:02:08 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 622BE926; Tue, 20 Dec 2016 18:02:08 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBKI27G3091172; Tue, 20 Dec 2016 18:02:07 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBKI27oN091165; Tue, 20 Dec 2016 18:02:07 GMT (envelope-from br@FreeBSD.org) Message-Id: <201612201802.uBKI27oN091165@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Tue, 20 Dec 2016 18:02:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310330 - in head: share/man/man4 sys/conf sys/dev/xdma X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 20 Dec 2016 18:02:08 -0000 Author: br Date: Tue Dec 20 18:02:07 2016 New Revision: 310330 URL: https://svnweb.freebsd.org/changeset/base/310330 Log: Add xDMA -- the DMA abstraction layer, initial verison. xDMA is a DMA framework designed to abstract the interaction between device drivers and DMA engines. Project wiki: https://wiki.freebsd.org/xdma Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D8807 Added: head/share/man/man4/xdma.4 (contents, props changed) head/sys/dev/xdma/ head/sys/dev/xdma/xdma.c (contents, props changed) head/sys/dev/xdma/xdma.h (contents, props changed) head/sys/dev/xdma/xdma_fdt_test.c (contents, props changed) head/sys/dev/xdma/xdma_if.m (contents, props changed) Modified: head/sys/conf/files Added: head/share/man/man4/xdma.4 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/share/man/man4/xdma.4 Tue Dec 20 18:02:07 2016 (r310330) @@ -0,0 +1,77 @@ +.\" Copyright (c) 2016 Ruslan Bukin +.\" All rights reserved. +.\" +.\" This software was developed by SRI International and the University of +.\" Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-10-C-0237 +.\" ("CTSRD"), as part of the DARPA CRASH research programme. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd December 12, 2016 +.Dt XDMA 4 +.Os +.Sh NAME +.Nm xdma +.Nd DMA abstraction layer +.Sh SYNOPSIS +To compile xDMA device support into the kernel, place the following line +in your kernel configuration file: +.Bd -ragged -offset indent +.Cd "device xdma" +.Ed +.Pp +To compile xDMA FDT-based test driver, place the following line as well: +.Bd -literal -offset indent +.Cd "device xdma_test" +.Ed +.Sh DESCRIPTION +xDMA is a DMA framework designed to abstract the interaction between device +drivers and DMA engines. +.Pp +xDMA defines an interface for efficient interaction between the device driver +and DMA controller. +The +.Nm +device provides a virtual DMA controller and virtual channels called xchans. +The controller provides virtual channels management (allocation, deallocation, +configuration) and interrupt notification esteblishment needed to receive +events from the hardware DMA controller. +.Nm +supports the following transfer types: +.Bl -hang -offset indent -width xxxxxxxx +.It Nm Cyclic +A non-stop periodic transfer designed for applications like audio. +.It Nm Memcpy +A memory-to-memory transfer. +.El +.Sh SEE ALSO +.Xr bus_dma 9 +.Sh HISTORY +Support for xDMA first appeared in +.Fx 12.0 . +.Sh AUTHORS +.An -nosplit +.Fx +xDMA framework was first added by +.An Ruslan Bukin Aq Mt br@FreeBSD.org . Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Tue Dec 20 17:12:17 2016 (r310329) +++ head/sys/conf/files Tue Dec 20 18:02:07 2016 (r310330) @@ -3262,6 +3262,9 @@ wpi.fw optional wpifw \ compile-with "${NORMAL_FW}" \ no-obj no-implicit-rule \ clean "wpi.fw" +dev/xdma/xdma.c optional xdma +dev/xdma/xdma_if.m optional xdma +dev/xdma/xdma_fdt_test.c optional xdma xdma_test fdt dev/xe/if_xe.c optional xe dev/xe/if_xe_pccard.c optional xe pccard dev/xen/balloon/balloon.c optional xenhvm Added: head/sys/dev/xdma/xdma.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/xdma/xdma.c Tue Dec 20 18:02:07 2016 (r310330) @@ -0,0 +1,673 @@ +/*- + * Copyright (c) 2016 Ruslan Bukin + * All rights reserved. + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-10-C-0237 + * ("CTSRD"), as part of the DARPA CRASH research programme. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include "opt_platform.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#ifdef FDT +#include +#include +#include +#endif + +#include + +#include + +MALLOC_DEFINE(M_XDMA, "xdma", "xDMA framework"); + +/* + * Multiple xDMA controllers may work with single DMA device, + * so we have global lock for physical channel management. + */ +static struct mtx xdma_mtx; +#define XDMA_LOCK() mtx_lock(&xdma_mtx) +#define XDMA_UNLOCK() mtx_unlock(&xdma_mtx) +#define XDMA_ASSERT_LOCKED() mtx_assert(&xdma_mtx, MA_OWNED) + +/* + * Per channel locks. + */ +#define XCHAN_LOCK(xchan) mtx_lock(&xchan->mtx_lock) +#define XCHAN_UNLOCK(xchan) mtx_unlock(&xchan->mtx_lock) +#define XCHAN_ASSERT_LOCKED(xchan) mtx_assert(&xchan->mtx_lock, MA_OWNED) + +/* + * Allocate virtual xDMA channel. + */ +xdma_channel_t * +xdma_channel_alloc(xdma_controller_t *xdma) +{ + xdma_channel_t *xchan; + int ret; + + xchan = malloc(sizeof(xdma_channel_t), M_XDMA, M_WAITOK | M_ZERO); + if (xchan == NULL) { + device_printf(xdma->dev, + "%s: Can't allocate memory for channel.\n", __func__); + return (NULL); + } + xchan->xdma = xdma; + + XDMA_LOCK(); + + /* Request a real channel from hardware driver. */ + ret = XDMA_CHANNEL_ALLOC(xdma->dma_dev, xchan); + if (ret != 0) { + device_printf(xdma->dev, + "%s: Can't request hardware channel.\n", __func__); + XDMA_UNLOCK(); + free(xchan, M_XDMA); + + return (NULL); + } + + TAILQ_INIT(&xchan->ie_handlers); + mtx_init(&xchan->mtx_lock, "xDMA", NULL, MTX_DEF); + + TAILQ_INSERT_TAIL(&xdma->channels, xchan, xchan_next); + + XDMA_UNLOCK(); + + return (xchan); +} + +int +xdma_channel_free(xdma_channel_t *xchan) +{ + xdma_controller_t *xdma; + int err; + + xdma = xchan->xdma; + + XDMA_LOCK(); + + /* Free the real DMA channel. */ + err = XDMA_CHANNEL_FREE(xdma->dma_dev, xchan); + if (err != 0) { + device_printf(xdma->dev, + "%s: Can't free real hw channel.\n", __func__); + XDMA_UNLOCK(); + return (-1); + } + + xdma_teardown_all_intr(xchan); + + /* Deallocate descriptors, if any. */ + xdma_desc_free(xchan); + + mtx_destroy(&xchan->mtx_lock); + + TAILQ_REMOVE(&xdma->channels, xchan, xchan_next); + + free(xchan, M_XDMA); + + XDMA_UNLOCK(); + + return (0); +} + +int +xdma_setup_intr(xdma_channel_t *xchan, int (*cb)(void *), void *arg, + void **ihandler) +{ + struct xdma_intr_handler *ih; + xdma_controller_t *xdma; + + xdma = xchan->xdma; + KASSERT(xdma != NULL, ("xdma is NULL")); + + /* Sanity check. */ + if (cb == NULL) { + device_printf(xdma->dev, + "%s: Can't setup interrupt handler.\n", + __func__); + + return (-1); + } + + ih = malloc(sizeof(struct xdma_intr_handler), + M_XDMA, M_WAITOK | M_ZERO); + if (ih == NULL) { + device_printf(xdma->dev, + "%s: Can't allocate memory for interrupt handler.\n", + __func__); + + return (-1); + } + + ih->cb = cb; + ih->cb_user = arg; + + TAILQ_INSERT_TAIL(&xchan->ie_handlers, ih, ih_next); + + if (ihandler != NULL) { + *ihandler = ih; + } + + return (0); +} + +int +xdma_teardown_intr(xdma_channel_t *xchan, struct xdma_intr_handler *ih) +{ + xdma_controller_t *xdma; + + xdma = xchan->xdma; + KASSERT(xdma != NULL, ("xdma is NULL")); + + /* Sanity check. */ + if (ih == NULL) { + device_printf(xdma->dev, + "%s: Can't teardown interrupt.\n", __func__); + return (-1); + } + + TAILQ_REMOVE(&xchan->ie_handlers, ih, ih_next); + free(ih, M_XDMA); + + return (0); +} + +int +xdma_teardown_all_intr(xdma_channel_t *xchan) +{ + struct xdma_intr_handler *ih_tmp; + struct xdma_intr_handler *ih; + xdma_controller_t *xdma; + + xdma = xchan->xdma; + KASSERT(xdma != NULL, ("xdma is NULL")); + + TAILQ_FOREACH_SAFE(ih, &xchan->ie_handlers, ih_next, ih_tmp) { + TAILQ_REMOVE(&xchan->ie_handlers, ih, ih_next); + free(ih, M_XDMA); + } + + return (0); +} + +static void +xdma_dmamap_cb(void *arg, bus_dma_segment_t *segs, int nseg, int err) +{ + xdma_channel_t *xchan; + int i; + + xchan = (xdma_channel_t *)arg; + KASSERT(xchan != NULL, ("xchan is NULL")); + + if (err) { + xchan->map_err = 1; + return; + } + + for (i = 0; i < nseg; i++) { + xchan->descs_phys[i].ds_addr = segs[i].ds_addr; + xchan->descs_phys[i].ds_len = segs[i].ds_len; + } +} + +static int +xdma_desc_alloc_bus_dma(xdma_channel_t *xchan, uint32_t desc_size, + uint32_t align) +{ + xdma_controller_t *xdma; + bus_size_t all_desc_sz; + xdma_config_t *conf; + int nsegments; + int err; + + xdma = xchan->xdma; + conf = &xchan->conf; + + nsegments = conf->block_num; + all_desc_sz = (nsegments * desc_size); + + err = bus_dma_tag_create( + bus_get_dma_tag(xdma->dev), + align, desc_size, /* alignment, boundary */ + BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ + BUS_SPACE_MAXADDR, /* highaddr */ + NULL, NULL, /* filter, filterarg */ + all_desc_sz, nsegments, /* maxsize, nsegments*/ + desc_size, 0, /* maxsegsize, flags */ + NULL, NULL, /* lockfunc, lockarg */ + &xchan->dma_tag); + if (err) { + device_printf(xdma->dev, + "%s: Can't create bus_dma tag.\n", __func__); + return (-1); + } + + err = bus_dmamem_alloc(xchan->dma_tag, (void **)&xchan->descs, + BUS_DMA_WAITOK | BUS_DMA_COHERENT, &xchan->dma_map); + if (err) { + device_printf(xdma->dev, + "%s: Can't allocate memory for descriptors.\n", __func__); + return (-1); + } + + xchan->descs_phys = malloc(nsegments * sizeof(xdma_descriptor_t), M_XDMA, + (M_WAITOK | M_ZERO)); + + xchan->map_err = 0; + err = bus_dmamap_load(xchan->dma_tag, xchan->dma_map, xchan->descs, + all_desc_sz, xdma_dmamap_cb, xchan, BUS_DMA_WAITOK); + if (err) { + device_printf(xdma->dev, + "%s: Can't load DMA map.\n", __func__); + return (-1); + } + + if (xchan->map_err != 0) { + device_printf(xdma->dev, + "%s: Can't load DMA map.\n", __func__); + return (-1); + } + + return (0); +} + +/* + * This function called by DMA controller driver. + */ +int +xdma_desc_alloc(xdma_channel_t *xchan, uint32_t desc_size, uint32_t align) +{ + xdma_controller_t *xdma; + xdma_config_t *conf; + int ret; + + XCHAN_ASSERT_LOCKED(xchan); + + xdma = xchan->xdma; + if (xdma == NULL) { + device_printf(xdma->dev, + "%s: Channel was not allocated properly.\n", __func__); + return (-1); + } + + if (xchan->flags & XCHAN_DESC_ALLOCATED) { + device_printf(xdma->dev, + "%s: Descriptors already allocated.\n", __func__); + return (-1); + } + + if ((xchan->flags & XCHAN_CONFIGURED) == 0) { + device_printf(xdma->dev, + "%s: Channel has no configuration.\n", __func__); + return (-1); + } + + conf = &xchan->conf; + + XCHAN_UNLOCK(xchan); + ret = xdma_desc_alloc_bus_dma(xchan, desc_size, align); + XCHAN_LOCK(xchan); + if (ret != 0) { + device_printf(xdma->dev, + "%s: Can't allocate memory for descriptors.\n", + __func__); + return (-1); + } + + xchan->flags |= XCHAN_DESC_ALLOCATED; + + /* We are going to write to descriptors. */ + bus_dmamap_sync(xchan->dma_tag, xchan->dma_map, BUS_DMASYNC_PREWRITE); + + return (0); +} + +int +xdma_desc_free(xdma_channel_t *xchan) +{ + + if ((xchan->flags & XCHAN_DESC_ALLOCATED) == 0) { + /* No descriptors allocated. */ + return (-1); + } + + bus_dmamap_unload(xchan->dma_tag, xchan->dma_map); + bus_dmamem_free(xchan->dma_tag, xchan->descs, xchan->dma_map); + bus_dma_tag_destroy(xchan->dma_tag); + free(xchan->descs_phys, M_XDMA); + + xchan->flags &= ~(XCHAN_DESC_ALLOCATED); + + return (0); +} + +int +xdma_prep_memcpy(xdma_channel_t *xchan, uintptr_t src_addr, + uintptr_t dst_addr, size_t len) +{ + xdma_controller_t *xdma; + xdma_config_t *conf; + int ret; + + xdma = xchan->xdma; + KASSERT(xdma != NULL, ("xdma is NULL")); + + conf = &xchan->conf; + conf->direction = XDMA_MEM_TO_MEM; + conf->src_addr = src_addr; + conf->dst_addr = dst_addr; + conf->block_len = len; + conf->block_num = 1; + + xchan->flags |= (XCHAN_CONFIGURED | XCHAN_TYPE_MEMCPY); + + XCHAN_LOCK(xchan); + + /* Deallocate old descriptors, if any. */ + xdma_desc_free(xchan); + + ret = XDMA_CHANNEL_PREP_MEMCPY(xdma->dma_dev, xchan); + if (ret != 0) { + device_printf(xdma->dev, + "%s: Can't prepare memcpy transfer.\n", __func__); + XDMA_UNLOCK(); + + return (-1); + } + + if (xchan->flags & XCHAN_DESC_ALLOCATED) { + /* Driver created xDMA descriptors. */ + bus_dmamap_sync(xchan->dma_tag, xchan->dma_map, + BUS_DMASYNC_POSTWRITE); + } + + XCHAN_UNLOCK(xchan); + + return (0); +} + +int +xdma_prep_cyclic(xdma_channel_t *xchan, enum xdma_direction dir, + uintptr_t src_addr, uintptr_t dst_addr, int block_len, + int block_num, int src_width, int dst_width) +{ + xdma_controller_t *xdma; + xdma_config_t *conf; + int ret; + + xdma = xchan->xdma; + KASSERT(xdma != NULL, ("xdma is NULL")); + + conf = &xchan->conf; + conf->direction = dir; + conf->src_addr = src_addr; + conf->dst_addr = dst_addr; + conf->block_len = block_len; + conf->block_num = block_num; + conf->src_width = src_width; + conf->dst_width = dst_width; + + xchan->flags |= (XCHAN_CONFIGURED | XCHAN_TYPE_CYCLIC); + + XCHAN_LOCK(xchan); + + /* Deallocate old descriptors, if any. */ + xdma_desc_free(xchan); + + ret = XDMA_CHANNEL_PREP_CYCLIC(xdma->dma_dev, xchan); + if (ret != 0) { + device_printf(xdma->dev, + "%s: Can't prepare cyclic transfer.\n", __func__); + XDMA_UNLOCK(); + return (-1); + } + + if (xchan->flags & XCHAN_DESC_ALLOCATED) { + /* Driver has created xDMA descriptors. */ + bus_dmamap_sync(xchan->dma_tag, xchan->dma_map, + BUS_DMASYNC_POSTWRITE); + } + + XCHAN_UNLOCK(xchan); + + return (0); +} + +int +xdma_begin(xdma_channel_t *xchan) +{ + xdma_controller_t *xdma; + int ret; + + xdma = xchan->xdma; + + ret = XDMA_CHANNEL_CONTROL(xdma->dma_dev, xchan, XDMA_CMD_BEGIN); + if (ret != 0) { + device_printf(xdma->dev, + "%s: Can't begin the channel operation.\n", __func__); + return (-1); + } + + return (0); +} + +int +xdma_terminate(xdma_channel_t *xchan) +{ + xdma_controller_t *xdma; + int ret; + + xdma = xchan->xdma; + + ret = XDMA_CHANNEL_CONTROL(xdma->dma_dev, xchan, XDMA_CMD_TERMINATE); + if (ret != 0) { + device_printf(xdma->dev, + "%s: Can't terminate the channel operation.\n", __func__); + return (-1); + } + + return (0); +} + +int +xdma_pause(xdma_channel_t *xchan) +{ + xdma_controller_t *xdma; + int ret; + + xdma = xchan->xdma; + + ret = XDMA_CHANNEL_CONTROL(xdma->dma_dev, xchan, XDMA_CMD_PAUSE); + if (ret != 0) { + device_printf(xdma->dev, + "%s: Can't pause the channel operation.\n", __func__); + return (-1); + } + + return (ret); +} + +int +xdma_callback(xdma_channel_t *xchan) +{ + struct xdma_intr_handler *ih_tmp; + struct xdma_intr_handler *ih; + + TAILQ_FOREACH_SAFE(ih, &xchan->ie_handlers, ih_next, ih_tmp) { + if (ih->cb != NULL) { + ih->cb(ih->cb_user); + } + } + + return (0); +} + +void +xdma_assert_locked(void) +{ + + XDMA_ASSERT_LOCKED(); +} + +#ifdef FDT +/* + * Notify the DMA driver we have machine-dependent data in FDT. + */ +static int +xdma_ofw_md_data(xdma_controller_t *xdma, pcell_t *cells, int ncells) +{ + uint32_t ret; + + ret = XDMA_OFW_MD_DATA(xdma->dma_dev, cells, ncells, (void **)&xdma->data); + + return (ret); +} + +/* + * Allocate xdma controller. + */ +xdma_controller_t * +xdma_ofw_get(device_t dev, const char *prop) +{ + phandle_t node, parent; + xdma_controller_t *xdma; + device_t dma_dev; + pcell_t *cells; + int ncells; + int error; + int ndmas; + int idx; + + node = ofw_bus_get_node(dev); + if (node <= 0) { + device_printf(dev, + "%s called on not ofw based device.\n", __func__); + } + + error = ofw_bus_parse_xref_list_get_length(node, + "dmas", "#dma-cells", &ndmas); + if (error) { + device_printf(dev, + "%s can't get dmas list.\n", __func__); + return (NULL); + } + + if (ndmas == 0) { + device_printf(dev, + "%s dmas list is empty.\n", __func__); + return (NULL); + } + + error = ofw_bus_find_string_index(node, "dma-names", prop, &idx); + if (error != 0) { + device_printf(dev, + "%s can't find string index.\n", __func__); + return (NULL); + } + + error = ofw_bus_parse_xref_list_alloc(node, "dmas", "#dma-cells", + idx, &parent, &ncells, &cells); + if (error != 0) { + device_printf(dev, + "%s can't get dma device xref.\n", __func__); + return (NULL); + } + + dma_dev = OF_device_from_xref(parent); + if (dma_dev == NULL) { + device_printf(dev, + "%s can't get dma device.\n", __func__); + return (NULL); + } + + xdma = malloc(sizeof(struct xdma_controller), M_XDMA, M_WAITOK | M_ZERO); + if (xdma == NULL) { + device_printf(dev, + "%s can't allocate memory for xdma.\n", __func__); + return (NULL); + } + xdma->dev = dev; + xdma->dma_dev = dma_dev; + + TAILQ_INIT(&xdma->channels); + + xdma_ofw_md_data(xdma, cells, ncells); + free(cells, M_OFWPROP); + + return (xdma); +} +#endif + +/* + * Free xDMA controller object. + */ +int +xdma_put(xdma_controller_t *xdma) +{ + + XDMA_LOCK(); + + /* Ensure no channels allocated. */ + if (!TAILQ_EMPTY(&xdma->channels)) { + device_printf(xdma->dev, "%s: Can't free xDMA\n", __func__); + return (-1); + } + + free(xdma->data, M_DEVBUF); + free(xdma, M_XDMA); + + XDMA_UNLOCK(); + + return (0); +} + +static void +xdma_init(void) +{ + + mtx_init(&xdma_mtx, "xDMA", NULL, MTX_DEF); +} + +SYSINIT(xdma, SI_SUB_DRIVERS, SI_ORDER_FIRST, xdma_init, NULL); Added: head/sys/dev/xdma/xdma.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/xdma/xdma.h Tue Dec 20 18:02:07 2016 (r310330) @@ -0,0 +1,148 @@ +/*- + * Copyright (c) 2016 Ruslan Bukin + * All rights reserved. + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-10-C-0237 + * ("CTSRD"), as part of the DARPA CRASH research programme. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _DEV_EXTRES_XDMA_H_ +#define _DEV_EXTRES_XDMA_H_ + +enum xdma_direction { + XDMA_MEM_TO_MEM, + XDMA_MEM_TO_DEV, + XDMA_DEV_TO_MEM, + XDMA_DEV_TO_DEV, +}; + +enum xdma_operation_type { + XDMA_MEMCPY, + XDMA_SG, + XDMA_CYCLIC, +}; + +enum xdma_command { + XDMA_CMD_BEGIN, + XDMA_CMD_PAUSE, + XDMA_CMD_TERMINATE, + XDMA_CMD_TERMINATE_ALL, +}; + +struct xdma_controller { + device_t dev; /* DMA consumer device_t. */ + device_t dma_dev; /* A real DMA device_t. */ + void *data; /* OFW MD part. */ + + /* List of virtual channels allocated. */ + TAILQ_HEAD(xdma_channel_list, xdma_channel) channels; +}; + +typedef struct xdma_controller xdma_controller_t; + +struct xdma_channel_config { + enum xdma_direction direction; + uintptr_t src_addr; /* Physical address. */ + uintptr_t dst_addr; /* Physical address. */ + int block_len; /* In bytes. */ + int block_num; /* Count of blocks. */ + int src_width; /* In bytes. */ + int dst_width; /* In bytes. */ +}; + +typedef struct xdma_channel_config xdma_config_t; + +struct xdma_descriptor { + uintptr_t ds_addr; + uint32_t ds_len; +}; + +typedef struct xdma_descriptor xdma_descriptor_t; + +struct xdma_channel { + xdma_controller_t *xdma; + xdma_config_t conf; + + uint8_t flags; +#define XCHAN_DESC_ALLOCATED (1 << 0) +#define XCHAN_CONFIGURED (1 << 1) +#define XCHAN_TYPE_CYCLIC (1 << 2) +#define XCHAN_TYPE_MEMCPY (1 << 3) + + /* A real hardware driver channel. */ + void *chan; + + /* Interrupt handlers. */ + TAILQ_HEAD(, xdma_intr_handler) ie_handlers; + + /* Descriptors. */ + bus_dma_tag_t dma_tag; + bus_dmamap_t dma_map; + void *descs; + xdma_descriptor_t *descs_phys; + uint8_t map_err; + + struct mtx mtx_lock; + + TAILQ_ENTRY(xdma_channel) xchan_next; +}; + +typedef struct xdma_channel xdma_channel_t; + +/* xDMA controller alloc/free */ +xdma_controller_t *xdma_ofw_get(device_t dev, const char *prop); +int xdma_put(xdma_controller_t *xdma); + +xdma_channel_t * xdma_channel_alloc(xdma_controller_t *); +int xdma_channel_free(xdma_channel_t *); + +int xdma_prep_cyclic(xdma_channel_t *, enum xdma_direction, + uintptr_t, uintptr_t, int, int, int, int); +int xdma_prep_memcpy(xdma_channel_t *, uintptr_t, uintptr_t, size_t len); +int xdma_desc_alloc(xdma_channel_t *, uint32_t, uint32_t); +int xdma_desc_free(xdma_channel_t *xchan); + +/* Channel Control */ +int xdma_begin(xdma_channel_t *xchan); +int xdma_pause(xdma_channel_t *xchan); +int xdma_terminate(xdma_channel_t *xchan); + +/* Interrupt callback */ +int xdma_setup_intr(xdma_channel_t *xchan, int (*cb)(void *), void *arg, void **); +int xdma_teardown_intr(xdma_channel_t *xchan, struct xdma_intr_handler *ih); +int xdma_teardown_all_intr(xdma_channel_t *xchan); +int xdma_callback(struct xdma_channel *xchan); +void xdma_assert_locked(void); + +struct xdma_intr_handler { + int (*cb)(void *); + void *cb_user; + struct mtx ih_lock; + TAILQ_ENTRY(xdma_intr_handler) ih_next; +}; + +#endif /* !_DEV_EXTRES_XDMA_H_ */ Added: head/sys/dev/xdma/xdma_fdt_test.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/xdma/xdma_fdt_test.c Tue Dec 20 18:02:07 2016 (r310330) @@ -0,0 +1,417 @@ +/*- + * Copyright (c) 2016 Ruslan Bukin + * All rights reserved. + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-10-C-0237 + * ("CTSRD"), as part of the DARPA CRASH research programme. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* xDMA memcpy test driver. */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include + +/* + * To use this test add a compatible node to your dts, e.g. + * + * xdma_test { + * compatible = "freebsd,xdma-test"; + * + * dmas = <&dma 0 0 0xffffffff>; + * dma-names = "test"; + * }; + */ + +struct xdmatest_softc { + device_t dev; + xdma_controller_t *xdma; + xdma_channel_t *xchan; + void *ih; + struct intr_config_hook config_intrhook; + char *src; + char *dst; + uint32_t len; + uintptr_t src_phys; + uintptr_t dst_phys; + bus_dma_tag_t src_dma_tag; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@freebsd.org Tue Dec 20 18:10:00 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A9302C8932E; Tue, 20 Dec 2016 18:10:00 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 56E38E02; Tue, 20 Dec 2016 18:10:00 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBKI9xS8091608; Tue, 20 Dec 2016 18:09:59 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBKI9xs6091606; Tue, 20 Dec 2016 18:09:59 GMT (envelope-from br@FreeBSD.org) Message-Id: <201612201809.uBKI9xs6091606@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Tue, 20 Dec 2016 18:09:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310331 - head/sys/mips/ingenic X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 20 Dec 2016 18:10:00 -0000 Author: br Date: Tue Dec 20 18:09:59 2016 New Revision: 310331 URL: https://svnweb.freebsd.org/changeset/base/310331 Log: Add jz4780 PDMA controller driver. Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D8817 Added: head/sys/mips/ingenic/jz4780_pdma.c (contents, props changed) Modified: head/sys/mips/ingenic/files.jz4780 head/sys/mips/ingenic/files.x1000 Modified: head/sys/mips/ingenic/files.jz4780 ============================================================================== --- head/sys/mips/ingenic/files.jz4780 Tue Dec 20 18:02:07 2016 (r310330) +++ head/sys/mips/ingenic/files.jz4780 Tue Dec 20 18:09:59 2016 (r310331) @@ -19,6 +19,7 @@ mips/ingenic/jz4780_intr.c standard mips/ingenic/jz4780_gpio.c standard mips/ingenic/jz4780_machdep.c standard mips/ingenic/jz4780_nemc.c standard +mips/ingenic/jz4780_pdma.c standard mips/ingenic/jz4780_pinctrl.c standard mips/ingenic/jz4780_timer.c standard Modified: head/sys/mips/ingenic/files.x1000 ============================================================================== --- head/sys/mips/ingenic/files.x1000 Tue Dec 20 18:02:07 2016 (r310330) +++ head/sys/mips/ingenic/files.x1000 Tue Dec 20 18:09:59 2016 (r310331) @@ -10,6 +10,7 @@ mips/ingenic/jz4780_clk_pll.c standard mips/ingenic/jz4780_intr.c standard mips/ingenic/jz4780_gpio.c standard mips/ingenic/jz4780_machdep.c standard +mips/ingenic/jz4780_pdma.c standard mips/ingenic/jz4780_pinctrl.c standard mips/ingenic/jz4780_timer.c standard Added: head/sys/mips/ingenic/jz4780_pdma.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/mips/ingenic/jz4780_pdma.c Tue Dec 20 18:09:59 2016 (r310331) @@ -0,0 +1,544 @@ +/*- + * Copyright (c) 2016 Ruslan Bukin + * All rights reserved. + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-10-C-0237 + * ("CTSRD"), as part of the DARPA CRASH research programme. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* Ingenic JZ4780 PDMA Controller. */ + +#include +__FBSDID("$FreeBSD$"); + +#include "opt_platform.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#ifdef FDT +#include +#include +#include +#endif + +#include + +#include +#include + +#include "xdma_if.h" + +struct pdma_softc { + device_t dev; + struct resource *res[2]; + bus_space_tag_t bst; + bus_space_handle_t bsh; + void *ih; +}; + +struct pdma_fdt_data { + int tx; + int rx; + int chan; +}; + +struct pdma_channel { + xdma_channel_t *xchan; + struct pdma_fdt_data data; + int cur_desc; + int used; + int index; + int flags; +#define CHAN_DESCR_RELINK (1 << 0) +}; + +#define PDMA_NCHANNELS 32 +struct pdma_channel pdma_channels[PDMA_NCHANNELS]; + +static struct resource_spec pdma_spec[] = { + { SYS_RES_MEMORY, 0, RF_ACTIVE }, + { SYS_RES_IRQ, 0, RF_ACTIVE }, + { -1, 0 } +}; + +static int pdma_probe(device_t dev); +static int pdma_attach(device_t dev); +static int pdma_detach(device_t dev); +static int chan_start(struct pdma_softc *sc, struct pdma_channel *chan); + +static void +pdma_intr(void *arg) +{ + struct pdma_channel *chan; + struct pdma_softc *sc; + xdma_channel_t *xchan; + xdma_config_t *conf; + int pending; + int i; + + sc = arg; + + pending = READ4(sc, PDMA_DIRQP); + + /* Ack all the channels. */ + WRITE4(sc, PDMA_DIRQP, 0); + + for (i = 0; i < PDMA_NCHANNELS; i++) { + if (pending & (1 << i)) { + chan = &pdma_channels[i]; + xchan = chan->xchan; + conf = &xchan->conf; + + /* TODO: check for AR, HLT error bits here. */ + + /* Disable channel */ + WRITE4(sc, PDMA_DCS(chan->index), 0); + + if (chan->flags & CHAN_DESCR_RELINK) { + /* Enable again */ + chan->cur_desc = (chan->cur_desc + 1) % \ + conf->block_num; + chan_start(sc, chan); + } + + xdma_callback(chan->xchan); + } + } +} + +static int +pdma_probe(device_t dev) +{ + + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + + if (!ofw_bus_is_compatible(dev, "ingenic,jz4780-dma")) + return (ENXIO); + + device_set_desc(dev, "Ingenic JZ4780 PDMA Controller"); + + return (BUS_PROBE_DEFAULT); +} + +static int +pdma_attach(device_t dev) +{ + struct pdma_softc *sc; + phandle_t xref, node; + int err; + int reg; + + sc = device_get_softc(dev); + sc->dev = dev; + + if (bus_alloc_resources(dev, pdma_spec, sc->res)) { + device_printf(dev, "could not allocate resources for device\n"); + return (ENXIO); + } + + /* Memory interface */ + sc->bst = rman_get_bustag(sc->res[0]); + sc->bsh = rman_get_bushandle(sc->res[0]); + + /* Setup interrupt handler */ + err = bus_setup_intr(dev, sc->res[1], INTR_TYPE_MISC | INTR_MPSAFE, + NULL, pdma_intr, sc, &sc->ih); + if (err) { + device_printf(dev, "Unable to alloc interrupt resource.\n"); + return (ENXIO); + } + + node = ofw_bus_get_node(dev); + xref = OF_xref_from_node(node); + OF_device_register_xref(xref, dev); + + reg = READ4(sc, PDMA_DMAC); + reg &= ~(DMAC_HLT | DMAC_AR); + reg |= (DMAC_DMAE); + WRITE4(sc, PDMA_DMAC, reg); + + WRITE4(sc, PDMA_DMACP, 0); + + return (0); +} + +static int +pdma_detach(device_t dev) +{ + struct pdma_softc *sc; + + sc = device_get_softc(dev); + + bus_release_resources(dev, pdma_spec, sc->res); + + return (0); +} + +static int +chan_start(struct pdma_softc *sc, struct pdma_channel *chan) +{ + struct xdma_channel *xchan; + + xchan = chan->xchan; + + /* 8 byte descriptor. */ + WRITE4(sc, PDMA_DCS(chan->index), DCS_DES8); + WRITE4(sc, PDMA_DDA(chan->index), xchan->descs_phys[chan->cur_desc].ds_addr); + WRITE4(sc, PDMA_DDS, (1 << chan->index)); + + /* Channel transfer enable. */ + WRITE4(sc, PDMA_DCS(chan->index), (DCS_DES8 | DCS_CTE)); + + return (0); +} + +static int +chan_stop(struct pdma_softc *sc, struct pdma_channel *chan) +{ + int timeout; + + WRITE4(sc, PDMA_DCS(chan->index), 0); + + timeout = 100; + + do { + if ((READ4(sc, PDMA_DCS(chan->index)) & DCS_CTE) == 0) { + break; + } + } while (timeout--); + + if (timeout == 0) { + device_printf(sc->dev, "%s: Can't stop channel %d\n", + __func__, chan->index); + } + + return (0); +} + +static int +pdma_channel_alloc(device_t dev, struct xdma_channel *xchan) +{ + struct pdma_channel *chan; + struct pdma_softc *sc; + int i; + + sc = device_get_softc(dev); + + xdma_assert_locked(); + + for (i = 0; i < PDMA_NCHANNELS; i++) { + chan = &pdma_channels[i]; + if (chan->used == 0) { + chan->xchan = xchan; + xchan->chan = (void *)chan; + chan->used = 1; + chan->index = i; + + return (0); + } + } + + return (-1); +} + +static int +pdma_channel_free(device_t dev, struct xdma_channel *xchan) +{ + struct pdma_channel *chan; + struct pdma_softc *sc; + + sc = device_get_softc(dev); + + xdma_assert_locked(); + + chan = (struct pdma_channel *)xchan->chan; + chan->used = 0; + + return (0); +} + +static int +pdma_channel_prep_memcpy(device_t dev, struct xdma_channel *xchan) +{ + struct pdma_channel *chan; + struct pdma_hwdesc *desc; + struct pdma_softc *sc; + xdma_config_t *conf; + int ret; + + sc = device_get_softc(dev); + + chan = (struct pdma_channel *)xchan->chan; + /* Ensure we are not in operation */ + chan_stop(sc, chan); + + ret = xdma_desc_alloc(xchan, sizeof(struct pdma_hwdesc), 8); + if (ret != 0) { + device_printf(sc->dev, + "%s: Can't allocate descriptors.\n", __func__); + return (-1); + } + + conf = &xchan->conf; + desc = (struct pdma_hwdesc *)xchan->descs; + desc[0].dsa = conf->src_addr; + desc[0].dta = conf->dst_addr; + desc[0].drt = DRT_AUTO; + desc[0].dcm = DCM_SAI | DCM_DAI; + + /* 4 byte copy for now. */ + desc[0].dtc = (conf->block_len / 4); + desc[0].dcm |= DCM_SP_4 | DCM_DP_4 | DCM_TSZ_4; + desc[0].dcm |= DCM_TIE; + + return (0); +} + +static int +access_width(xdma_config_t *conf, uint32_t *dcm, uint32_t *max_width) +{ + + *dcm = 0; + *max_width = max(conf->src_width, conf->dst_width); + + switch (conf->src_width) { + case 1: + *dcm |= DCM_SP_1; + break; + case 2: + *dcm |= DCM_SP_2; + break; + case 4: + *dcm |= DCM_SP_4; + break; + default: + return (-1); + } + + switch (conf->dst_width) { + case 1: + *dcm |= DCM_DP_1; + break; + case 2: + *dcm |= DCM_DP_2; + break; + case 4: + *dcm |= DCM_DP_4; + break; + default: + return (-1); + } + + switch (*max_width) { + case 1: + *dcm |= DCM_TSZ_1; + break; + case 2: + *dcm |= DCM_TSZ_2; + break; + case 4: + *dcm |= DCM_TSZ_4; + break; + default: + return (-1); + }; + + return (0); +} + +static int +pdma_channel_prep_cyclic(device_t dev, struct xdma_channel *xchan) +{ + struct pdma_fdt_data *data; + struct pdma_channel *chan; + struct pdma_hwdesc *desc; + xdma_controller_t *xdma; + struct pdma_softc *sc; + xdma_config_t *conf; + int max_width; + uint32_t reg; + uint32_t dcm; + int ret; + int i; + + sc = device_get_softc(dev); + + conf = &xchan->conf; + xdma = xchan->xdma; + data = (struct pdma_fdt_data *)xdma->data; + + ret = xdma_desc_alloc(xchan, sizeof(struct pdma_hwdesc), 8); + if (ret != 0) { + device_printf(sc->dev, + "%s: Can't allocate descriptors.\n", __func__); + return (-1); + } + + chan = (struct pdma_channel *)xchan->chan; + /* Ensure we are not in operation */ + chan_stop(sc, chan); + chan->flags = CHAN_DESCR_RELINK; + chan->cur_desc = 0; + + desc = (struct pdma_hwdesc *)xchan->descs; + + for (i = 0; i < conf->block_num; i++) { + if (conf->direction == XDMA_MEM_TO_DEV) { + desc[i].dsa = conf->src_addr + (i * conf->block_len); + desc[i].dta = conf->dst_addr; + desc[i].drt = data->tx; + desc[i].dcm = DCM_SAI; + } else if (conf->direction == XDMA_DEV_TO_MEM) { + desc[i].dsa = conf->src_addr; + desc[i].dta = conf->dst_addr + (i * conf->block_len); + desc[i].drt = data->rx; + desc[i].dcm = DCM_DAI; + } else if (conf->direction == XDMA_MEM_TO_MEM) { + desc[i].dsa = conf->src_addr + (i * conf->block_len); + desc[i].dta = conf->dst_addr + (i * conf->block_len); + desc[i].drt = DRT_AUTO; + desc[i].dcm = DCM_SAI | DCM_DAI; + } + + if (access_width(conf, &dcm, &max_width) != 0) { + device_printf(dev, + "%s: can't configure access width\n", __func__); + return (-1); + } + + desc[i].dcm |= dcm | DCM_TIE; + desc[i].dtc = (conf->block_len / max_width); + + /* + * PDMA does not provide interrupt after processing each descriptor, + * but after processing all the chain only. + * As a workaround we do unlink descriptors here, so our chain will + * consists of single descriptor only. And then we reconfigure channel + * on each interrupt again. + */ + if ((chan->flags & CHAN_DESCR_RELINK) == 0) { + if (i != (conf->block_num - 1)) { + desc[i].dcm |= DCM_LINK; + reg = ((i + 1) * sizeof(struct pdma_hwdesc)); + desc[i].dtc |= (reg >> 4) << 24; + } + } + } + + return (0); +} + +static int +pdma_channel_control(device_t dev, xdma_channel_t *xchan, int cmd) +{ + struct pdma_channel *chan; + struct pdma_softc *sc; + + sc = device_get_softc(dev); + + chan = (struct pdma_channel *)xchan->chan; + + switch (cmd) { + case XDMA_CMD_BEGIN: + chan_start(sc, chan); + break; + case XDMA_CMD_TERMINATE: + chan_stop(sc, chan); + break; + case XDMA_CMD_PAUSE: + /* TODO: implement me */ + return (-1); + } + + return (0); +} + +#ifdef FDT +static int +pdma_ofw_md_data(device_t dev, pcell_t *cells, int ncells, void **ptr) +{ + struct pdma_fdt_data *data; + + if (ncells != 3) { + return (-1); + } + + data = malloc(sizeof(struct pdma_fdt_data), M_DEVBUF, (M_WAITOK | M_ZERO)); + if (data == NULL) { + device_printf(dev, "%s: Cant allocate memory\n", __func__); + return (-1); + } + + data->tx = cells[0]; + data->rx = cells[1]; + data->chan = cells[2]; + + *ptr = data; + + return (0); +} +#endif + +static device_method_t pdma_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, pdma_probe), + DEVMETHOD(device_attach, pdma_attach), + DEVMETHOD(device_detach, pdma_detach), + + /* xDMA Interface */ + DEVMETHOD(xdma_channel_alloc, pdma_channel_alloc), + DEVMETHOD(xdma_channel_free, pdma_channel_free), + DEVMETHOD(xdma_channel_prep_cyclic, pdma_channel_prep_cyclic), + DEVMETHOD(xdma_channel_prep_memcpy, pdma_channel_prep_memcpy), + DEVMETHOD(xdma_channel_control, pdma_channel_control), +#ifdef FDT + DEVMETHOD(xdma_ofw_md_data, pdma_ofw_md_data), +#endif + + DEVMETHOD_END +}; + +static driver_t pdma_driver = { + "pdma", + pdma_methods, + sizeof(struct pdma_softc), +}; + +static devclass_t pdma_devclass; + +EARLY_DRIVER_MODULE(pdma, simplebus, pdma_driver, pdma_devclass, 0, 0, + BUS_PASS_INTERRUPT + BUS_PASS_ORDER_LATE); From owner-svn-src-head@freebsd.org Tue Dec 20 18:25:42 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B1BDFC89AD3; Tue, 20 Dec 2016 18:25:42 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 6728E1A06; Tue, 20 Dec 2016 18:25:42 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBKIPfHv099703; Tue, 20 Dec 2016 18:25:41 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBKIPfVD099702; Tue, 20 Dec 2016 18:25:41 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201612201825.uBKIPfVD099702@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 20 Dec 2016 18:25:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310332 - head/cddl/contrib/opensolaris/lib/libdtrace/common X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 20 Dec 2016 18:25:42 -0000 Author: markj Date: Tue Dec 20 18:25:41 2016 New Revision: 310332 URL: https://svnweb.freebsd.org/changeset/base/310332 Log: Avoid modifying the object string table when patching USDT probes. dtrace converts pairs of consecutive underscores in a probe name to dashes. When dtrace -G processes relocations corresponding to USDT probe sites, it performs this conversion on the corresponding symbol names prior to looking up the resulting probe names in the USDT provider definition. However, in so doing it would actually modify the input object's string table, which breaks the string suffix merging done by recent binutils. Because we don't care about the symbol name once the probe site is recorded, just perform the probe lookup using a temporary copy. Reported by: hrs, swills MFC after: 3 weeks Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c ============================================================================== --- head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c Tue Dec 20 18:09:59 2016 (r310331) +++ head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c Tue Dec 20 18:25:41 2016 (r310332) @@ -1223,6 +1223,7 @@ process_obj(dtrace_hdl_t *dtp, const cha static const char dt_enabled[] = "enabled"; static const char dt_symprefix[] = "$dtrace"; static const char dt_symfmt[] = "%s%ld.%s"; + char probename[DTRACE_NAMELEN]; int fd, i, ndx, eprobe, mod = 0; Elf *elf = NULL; GElf_Ehdr ehdr; @@ -1576,8 +1577,6 @@ process_obj(dtrace_hdl_t *dtp, const cha bcopy(s, pname, p - s); pname[p - s] = '\0'; - p = strhyphenate(p + 3); /* strlen("___") */ - if (dt_symtab_lookup(data_sym, isym, rela.r_offset, shdr_rel.sh_info, &fsym, (emachine1 == EM_PPC64), elf) != 0) @@ -1628,10 +1627,14 @@ process_obj(dtrace_hdl_t *dtp, const cha "no such provider %s", pname)); } - if ((prp = dt_probe_lookup(pvp, p)) == NULL) { + if (strlcpy(probename, p + 3, sizeof (probename)) >= + sizeof (probename)) return (dt_link_error(dtp, elf, fd, bufs, - "no such probe %s", p)); - } + "invalid probe name %s", probename)); + (void) strhyphenate(probename); + if ((prp = dt_probe_lookup(pvp, probename)) == NULL) + return (dt_link_error(dtp, elf, fd, bufs, + "no such probe %s", probename)); assert(fsym.st_value <= rela.r_offset); From owner-svn-src-head@freebsd.org Tue Dec 20 18:27:55 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 453BBC89B63; Tue, 20 Dec 2016 18:27:55 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 0DCB61BA6; Tue, 20 Dec 2016 18:27:54 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBKIRsds099882; Tue, 20 Dec 2016 18:27:54 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBKIRrBA099876; Tue, 20 Dec 2016 18:27:53 GMT (envelope-from br@FreeBSD.org) Message-Id: <201612201827.uBKIRrBA099876@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Tue, 20 Dec 2016 18:27:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310333 - in head/sys/mips: conf ingenic X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 20 Dec 2016 18:27:55 -0000 Author: br Date: Tue Dec 20 18:27:53 2016 New Revision: 310333 URL: https://svnweb.freebsd.org/changeset/base/310333 Log: Add jz4780 AIC (Audio Interface Controller) driver. Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D8808 Added: head/sys/mips/ingenic/jz4780_aic.c (contents, props changed) Modified: head/sys/mips/conf/CANNA head/sys/mips/conf/CI20 head/sys/mips/ingenic/files.jz4780 head/sys/mips/ingenic/files.x1000 Modified: head/sys/mips/conf/CANNA ============================================================================== --- head/sys/mips/conf/CANNA Tue Dec 20 18:25:41 2016 (r310332) +++ head/sys/mips/conf/CANNA Tue Dec 20 18:27:53 2016 (r310333) @@ -26,5 +26,8 @@ options ROOTDEVNAME=\"ufs:mmcsd0s3\" makeoptions TRAMPLOADADDR=0x88000000 +device sound +device xdma + #options VERBOSE_SYSINIT options PRINTF_BUFR_SIZE=256 Modified: head/sys/mips/conf/CI20 ============================================================================== --- head/sys/mips/conf/CI20 Tue Dec 20 18:25:41 2016 (r310332) +++ head/sys/mips/conf/CI20 Tue Dec 20 18:27:53 2016 (r310333) @@ -25,6 +25,9 @@ makeoptions FDT_DTS_FILE=ingenic/ci20.dt options ROOTDEVNAME=\"ufs:mmcsd0\" +device sound +device xdma + makeoptions TRAMPLOADADDR=0x88000000 #options VERBOSE_SYSINIT Modified: head/sys/mips/ingenic/files.jz4780 ============================================================================== --- head/sys/mips/ingenic/files.jz4780 Tue Dec 20 18:25:41 2016 (r310332) +++ head/sys/mips/ingenic/files.jz4780 Tue Dec 20 18:27:53 2016 (r310333) @@ -23,6 +23,10 @@ mips/ingenic/jz4780_pdma.c standard mips/ingenic/jz4780_pinctrl.c standard mips/ingenic/jz4780_timer.c standard +# Sound +mips/ingenic/jz4780_aic.c optional sound xdma +mips/ingenic/jz4780_codec.c optional sound + # SMP mips/ingenic/jz4780_mp.c optional smp mips/ingenic/jz4780_mpboot.S optional smp Modified: head/sys/mips/ingenic/files.x1000 ============================================================================== --- head/sys/mips/ingenic/files.x1000 Tue Dec 20 18:25:41 2016 (r310332) +++ head/sys/mips/ingenic/files.x1000 Tue Dec 20 18:27:53 2016 (r310333) @@ -14,5 +14,9 @@ mips/ingenic/jz4780_pdma.c standard mips/ingenic/jz4780_pinctrl.c standard mips/ingenic/jz4780_timer.c standard +# Sound +mips/ingenic/jz4780_aic.c optional sound xdma +mips/ingenic/jz4780_codec.c optional sound + # Custom interface between pinctrl and gpio mips/ingenic/jz4780_gpio_if.m standard Added: head/sys/mips/ingenic/jz4780_aic.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/mips/ingenic/jz4780_aic.c Tue Dec 20 18:27:53 2016 (r310333) @@ -0,0 +1,754 @@ +/*- + * Copyright (c) 2016 Ruslan Bukin + * All rights reserved. + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-10-C-0237 + * ("CTSRD"), as part of the DARPA CRASH research programme. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* Ingenic JZ4780 Audio Interface Controller (AIC). */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include +#include + +#define AIC_NCHANNELS 1 + +struct aic_softc { + device_t dev; + struct resource *res[1]; + bus_space_tag_t bst; + bus_space_handle_t bsh; + struct mtx *lock; + int pos; + bus_dma_tag_t dma_tag; + bus_dmamap_t dma_map; + bus_addr_t buf_base_phys; + uint32_t *buf_base; + uintptr_t aic_fifo_paddr; + int dma_size; + clk_t clk_aic; + clk_t clk_i2s; + struct aic_rate *sr; + void *ih; + struct xdma_channel *xchan; + xdma_controller_t *xdma_tx; +}; + +/* Channel registers */ +struct sc_chinfo { + struct snd_dbuf *buffer; + struct pcm_channel *channel; + struct sc_pcminfo *parent; + + /* Channel information */ + uint32_t dir; + uint32_t format; + + /* Flags */ + uint32_t run; +}; + +/* PCM device private data */ +struct sc_pcminfo { + device_t dev; + uint32_t chnum; + struct sc_chinfo chan[AIC_NCHANNELS]; + struct aic_softc *sc; +}; + +static struct resource_spec aic_spec[] = { + { SYS_RES_MEMORY, 0, RF_ACTIVE }, + { -1, 0 } +}; + +static int aic_probe(device_t dev); +static int aic_attach(device_t dev); +static int aic_detach(device_t dev); +static int setup_xdma(struct sc_pcminfo *scp); + +struct aic_rate { + uint32_t speed; +}; + +static struct aic_rate rate_map[] = { + { 96000 }, + /* TODO: add more frequences */ + { 0 }, +}; + +/* + * Mixer interface. + */ +static int +aicmixer_init(struct snd_mixer *m) +{ + struct sc_pcminfo *scp; + struct aic_softc *sc; + int mask; + + scp = mix_getdevinfo(m); + sc = scp->sc; + + if (sc == NULL) + return -1; + + mask = SOUND_MASK_PCM; + + snd_mtxlock(sc->lock); + pcm_setflags(scp->dev, pcm_getflags(scp->dev) | SD_F_SOFTPCMVOL); + mix_setdevs(m, mask); + snd_mtxunlock(sc->lock); + + return (0); +} + +static int +aicmixer_set(struct snd_mixer *m, unsigned dev, + unsigned left, unsigned right) +{ + struct sc_pcminfo *scp; + + scp = mix_getdevinfo(m); + + /* Here we can configure hardware volume on our DAC */ + + return (0); +} + +static kobj_method_t aicmixer_methods[] = { + KOBJMETHOD(mixer_init, aicmixer_init), + KOBJMETHOD(mixer_set, aicmixer_set), + KOBJMETHOD_END +}; +MIXER_DECLARE(aicmixer); + +/* + * Channel interface. + */ +static void * +aicchan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, + struct pcm_channel *c, int dir) +{ + struct sc_pcminfo *scp; + struct sc_chinfo *ch; + struct aic_softc *sc; + + scp = (struct sc_pcminfo *)devinfo; + sc = scp->sc; + + snd_mtxlock(sc->lock); + ch = &scp->chan[0]; + ch->dir = dir; + ch->run = 0; + ch->buffer = b; + ch->channel = c; + ch->parent = scp; + snd_mtxunlock(sc->lock); + + if (sndbuf_setup(ch->buffer, sc->buf_base, sc->dma_size) != 0) { + device_printf(scp->dev, "Can't setup sndbuf.\n"); + return NULL; + } + + return (ch); +} + +static int +aicchan_free(kobj_t obj, void *data) +{ + struct sc_chinfo *ch = data; + struct sc_pcminfo *scp = ch->parent; + struct aic_softc *sc = scp->sc; + + snd_mtxlock(sc->lock); + /* TODO: free channel buffer */ + snd_mtxunlock(sc->lock); + + return (0); +} + +static int +aicchan_setformat(kobj_t obj, void *data, uint32_t format) +{ + struct sc_pcminfo *scp; + struct sc_chinfo *ch; + + ch = data; + scp = ch->parent; + + ch->format = format; + + return (0); +} + +static uint32_t +aicchan_setspeed(kobj_t obj, void *data, uint32_t speed) +{ + struct sc_pcminfo *scp; + struct sc_chinfo *ch; + struct aic_rate *sr; + struct aic_softc *sc; + int threshold; + int i; + + ch = data; + scp = ch->parent; + sc = scp->sc; + + sr = NULL; + + /* First look for equal frequency. */ + for (i = 0; rate_map[i].speed != 0; i++) { + if (rate_map[i].speed == speed) + sr = &rate_map[i]; + } + + /* If no match, just find nearest. */ + if (sr == NULL) { + for (i = 0; rate_map[i].speed != 0; i++) { + sr = &rate_map[i]; + threshold = sr->speed + ((rate_map[i + 1].speed != 0) ? + ((rate_map[i + 1].speed - sr->speed) >> 1) : 0); + if (speed < threshold) + break; + } + } + + sc->sr = sr; + + /* Clocks can be reconfigured here. */ + + return (sr->speed); +} + +static uint32_t +aicchan_setblocksize(kobj_t obj, void *data, uint32_t blocksize) +{ + struct sc_pcminfo *scp; + struct sc_chinfo *ch; + struct aic_softc *sc; + + ch = data; + scp = ch->parent; + sc = scp->sc; + + sndbuf_resize(ch->buffer, sc->dma_size / blocksize, blocksize); + + return (sndbuf_getblksz(ch->buffer)); +} + +static int +aic_intr(void *arg) +{ + struct sc_pcminfo *scp; + xdma_channel_t *xchan; + struct sc_chinfo *ch; + struct aic_softc *sc; + xdma_config_t *conf; + int bufsize; + + scp = arg; + sc = scp->sc; + ch = &scp->chan[0]; + + xchan = sc->xchan; + conf = &xchan->conf; + + bufsize = sndbuf_getsize(ch->buffer); + + sc->pos += conf->block_len; + if (sc->pos >= bufsize) + sc->pos -= bufsize; + + if (ch->run) + chn_intr(ch->channel); + + return (0); +} + +static int +setup_xdma(struct sc_pcminfo *scp) +{ + struct aic_softc *sc; + struct sc_chinfo *ch; + int fmt; + int err; + + ch = &scp->chan[0]; + sc = scp->sc; + + fmt = sndbuf_getfmt(ch->buffer); + + KASSERT(fmt & AFMT_16BIT, ("16-bit audio supported only.")); + + err = xdma_prep_cyclic(sc->xchan, + XDMA_MEM_TO_DEV, /* direction */ + sc->buf_base_phys, /* src addr */ + sc->aic_fifo_paddr, /* dst addr */ + sndbuf_getblksz(ch->buffer), /* block len */ + sndbuf_getblkcnt(ch->buffer), /* block num */ + 2, /* src port width */ + 2); /* dst port width */ + if (err != 0) { + device_printf(sc->dev, "Can't configure virtual channel\n"); + return (-1); + } + + xdma_begin(sc->xchan); + + return (0); +} + +static int +aic_start(struct sc_pcminfo *scp) +{ + struct aic_softc *sc; + int reg; + + sc = scp->sc; + sc->pos = 0; + + /* Ensure clock enabled. */ + reg = READ4(sc, I2SCR); + reg |= (I2SCR_ESCLK); + WRITE4(sc, I2SCR, reg); + + setup_xdma(scp); + + reg = (AICCR_OSS_16 | AICCR_ISS_16); + reg |= (AICCR_CHANNEL_2); + reg |= (AICCR_TDMS); + reg |= (AICCR_ERPL); + WRITE4(sc, AICCR, reg); + + return (0); +} + +static int +aic_stop(struct sc_pcminfo *scp) +{ + struct aic_softc *sc; + int reg; + + sc = scp->sc; + + reg = READ4(sc, AICCR); + reg &= ~(AICCR_TDMS | AICCR_ERPL); + WRITE4(sc, AICCR, reg); + + xdma_terminate(sc->xchan); + + sc->pos = 0; + + bzero(sc->buf_base, sc->dma_size); + + return (0); +} + +static int +aicchan_trigger(kobj_t obj, void *data, int go) +{ + struct sc_pcminfo *scp; + struct sc_chinfo *ch; + struct aic_softc *sc; + + ch = data; + scp = ch->parent; + sc = scp->sc; + + snd_mtxlock(sc->lock); + + switch (go) { + case PCMTRIG_START: + ch->run = 1; + + aic_start(scp); + + break; + + case PCMTRIG_STOP: + case PCMTRIG_ABORT: + ch->run = 0; + + aic_stop(scp); + + break; + } + + snd_mtxunlock(sc->lock); + + return (0); +} + +static uint32_t +aicchan_getptr(kobj_t obj, void *data) +{ + struct sc_pcminfo *scp; + struct sc_chinfo *ch; + struct aic_softc *sc; + + ch = data; + scp = ch->parent; + sc = scp->sc; + + return (sc->pos); +} + +static uint32_t aic_pfmt[] = { + SND_FORMAT(AFMT_S16_LE, 2, 0), + 0 +}; + +static struct pcmchan_caps aic_pcaps = {96000, 96000, aic_pfmt, 0}; + +static struct pcmchan_caps * +aicchan_getcaps(kobj_t obj, void *data) +{ + + return (&aic_pcaps); +} + +static kobj_method_t aicchan_methods[] = { + KOBJMETHOD(channel_init, aicchan_init), + KOBJMETHOD(channel_free, aicchan_free), + KOBJMETHOD(channel_setformat, aicchan_setformat), + KOBJMETHOD(channel_setspeed, aicchan_setspeed), + KOBJMETHOD(channel_setblocksize, aicchan_setblocksize), + KOBJMETHOD(channel_trigger, aicchan_trigger), + KOBJMETHOD(channel_getptr, aicchan_getptr), + KOBJMETHOD(channel_getcaps, aicchan_getcaps), + KOBJMETHOD_END +}; +CHANNEL_DECLARE(aicchan); + +static void +aic_dmamap_cb(void *arg, bus_dma_segment_t *segs, int nseg, int err) +{ + bus_addr_t *addr; + + if (err) + return; + + addr = (bus_addr_t*)arg; + *addr = segs[0].ds_addr; +} + +static int +aic_dma_setup(struct aic_softc *sc) +{ + device_t dev; + int err; + + dev = sc->dev; + + /* DMA buffer size. */ + sc->dma_size = 131072; + + /* + * Must use dma_size boundary as modulo feature required. + * Modulo feature allows setup circular buffer. + */ + err = bus_dma_tag_create( + bus_get_dma_tag(sc->dev), + 4, sc->dma_size, /* alignment, boundary */ + BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ + BUS_SPACE_MAXADDR, /* highaddr */ + NULL, NULL, /* filter, filterarg */ + sc->dma_size, 1, /* maxsize, nsegments */ + sc->dma_size, 0, /* maxsegsize, flags */ + NULL, NULL, /* lockfunc, lockarg */ + &sc->dma_tag); + if (err) { + device_printf(dev, "cannot create bus dma tag\n"); + return (-1); + } + + err = bus_dmamem_alloc(sc->dma_tag, (void **)&sc->buf_base, + BUS_DMA_WAITOK | BUS_DMA_COHERENT, &sc->dma_map); + if (err) { + device_printf(dev, "cannot allocate memory\n"); + return (-1); + } + + err = bus_dmamap_load(sc->dma_tag, sc->dma_map, sc->buf_base, + sc->dma_size, aic_dmamap_cb, &sc->buf_base_phys, BUS_DMA_WAITOK); + if (err) { + device_printf(dev, "cannot load DMA map\n"); + return (-1); + } + + bzero(sc->buf_base, sc->dma_size); + + return (0); +} + +static int +aic_configure_clocks(struct aic_softc *sc) +{ + uint64_t aic_freq; + uint64_t i2s_freq; + device_t dev; + int err; + + dev = sc->dev; + + err = clk_get_by_ofw_name(sc->dev, 0, "aic", &sc->clk_aic); + if (err != 0) { + device_printf(dev, "Can't find aic clock.\n"); + return (-1); + } + + err = clk_enable(sc->clk_aic); + if (err != 0) { + device_printf(dev, "Can't enable aic clock.\n"); + return (-1); + } + + err = clk_get_by_ofw_name(sc->dev, 0, "i2s", &sc->clk_i2s); + if (err != 0) { + device_printf(dev, "Can't find i2s clock.\n"); + return (-1); + } + + err = clk_enable(sc->clk_i2s); + if (err != 0) { + device_printf(dev, "Can't enable i2s clock.\n"); + return (-1); + } + + err = clk_set_freq(sc->clk_i2s, 12000000, 0); + if (err != 0) { + device_printf(dev, "Can't set i2s frequency.\n"); + return (-1); + } + + clk_get_freq(sc->clk_aic, &aic_freq); + clk_get_freq(sc->clk_i2s, &i2s_freq); + + device_printf(dev, "Frequency aic %d i2s %d\n", + (uint32_t)aic_freq, (uint32_t)i2s_freq); + + return (0); +} + +static int +aic_configure(struct aic_softc *sc) +{ + int internal_codec; + int reg; + + internal_codec = 1; + + WRITE4(sc, AICFR, AICFR_RST); + + /* Configure AIC */ + reg = 0; + if (internal_codec) { + reg |= (AICFR_ICDC); + } else { + reg |= (AICFR_SYNCD | AICFR_BCKD); + } + reg |= (AICFR_AUSEL); /* I2S/MSB-justified format. */ + reg |= (AICFR_TFTH(8)); /* Transmit FIFO threshold */ + reg |= (AICFR_RFTH(7)); /* Receive FIFO threshold */ + WRITE4(sc, AICFR, reg); + + reg = READ4(sc, AICFR); + reg |= (AICFR_ENB); /* Enable the controller. */ + WRITE4(sc, AICFR, reg); + + return (0); +} + +static int +aic_probe(device_t dev) +{ + + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + + if (!ofw_bus_is_compatible(dev, "ingenic,jz4780-i2s")) + return (ENXIO); + + device_set_desc(dev, "Audio Interface Controller"); + + return (BUS_PROBE_DEFAULT); +} + +static int +aic_attach(device_t dev) +{ + char status[SND_STATUSLEN]; + struct sc_pcminfo *scp; + struct aic_softc *sc; + int err; + + sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK | M_ZERO); + sc->dev = dev; + sc->pos = 0; + + /* Get xDMA controller */ + sc->xdma_tx = xdma_ofw_get(sc->dev, "tx"); + if (sc->xdma_tx == NULL) { + device_printf(dev, "Can't find DMA controller.\n"); + return (ENXIO); + } + + /* Alloc xDMA virtual channel. */ + sc->xchan = xdma_channel_alloc(sc->xdma_tx); + if (sc->xchan == NULL) { + device_printf(dev, "Can't alloc virtual DMA channel.\n"); + return (ENXIO); + } + + /* Setup sound subsystem */ + sc->lock = snd_mtxcreate(device_get_nameunit(dev), "aic softc"); + if (sc->lock == NULL) { + device_printf(dev, "Can't create mtx.\n"); + return (ENXIO); + } + + if (bus_alloc_resources(dev, aic_spec, sc->res)) { + device_printf(dev, + "could not allocate resources for device\n"); + return (ENXIO); + } + + /* Memory interface */ + sc->bst = rman_get_bustag(sc->res[0]); + sc->bsh = rman_get_bushandle(sc->res[0]); + sc->aic_fifo_paddr = rman_get_start(sc->res[0]) + AICDR; + + /* Setup PCM. */ + scp = malloc(sizeof(struct sc_pcminfo), M_DEVBUF, M_WAITOK | M_ZERO); + scp->sc = sc; + scp->dev = dev; + + /* Setup audio buffer. */ + err = aic_dma_setup(sc); + if (err != 0) { + device_printf(dev, "Can't setup sound buffer.\n"); + return (ENXIO); + } + + /* Setup clocks. */ + err = aic_configure_clocks(sc); + if (err != 0) { + device_printf(dev, "Can't configure clocks.\n"); + return (ENXIO); + } + + err = aic_configure(sc); + if (err != 0) { + device_printf(dev, "Can't configure AIC.\n"); + return (ENXIO); + } + + pcm_setflags(dev, pcm_getflags(dev) | SD_F_MPSAFE); + + /* Setup interrupt handler. */ + err = xdma_setup_intr(sc->xchan, aic_intr, scp, &sc->ih); + if (err) { + device_printf(sc->dev, + "Can't setup xDMA interrupt handler.\n"); + return (ENXIO); + } + + err = pcm_register(dev, scp, 1, 0); + if (err) { + device_printf(dev, "Can't register pcm.\n"); + return (ENXIO); + } + + scp->chnum = 0; + pcm_addchan(dev, PCMDIR_PLAY, &aicchan_class, scp); + scp->chnum++; + + snprintf(status, SND_STATUSLEN, "at %s", ofw_bus_get_name(dev)); + pcm_setstatus(dev, status); + + mixer_init(dev, &aicmixer_class, scp); + + return (0); +} + +static int +aic_detach(device_t dev) +{ + struct aic_softc *sc; + + sc = device_get_softc(dev); + + xdma_channel_free(sc->xchan); + + bus_release_resources(dev, aic_spec, sc->res); + + return (0); +} + +static device_method_t aic_pcm_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, aic_probe), + DEVMETHOD(device_attach, aic_attach), + DEVMETHOD(device_detach, aic_detach), + DEVMETHOD_END +}; + +static driver_t aic_pcm_driver = { + "pcm", + aic_pcm_methods, + PCM_SOFTC_SIZE, +}; + +DRIVER_MODULE(aic, simplebus, aic_pcm_driver, pcm_devclass, 0, 0); +MODULE_DEPEND(aic, sound, SOUND_MINVER, SOUND_PREFVER, SOUND_MAXVER); +MODULE_VERSION(aic, 1); From owner-svn-src-head@freebsd.org Tue Dec 20 18:47:03 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 865ECC87595; Tue, 20 Dec 2016 18:47:03 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 31AB818D0; Tue, 20 Dec 2016 18:47:03 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBKIl2qm010272; Tue, 20 Dec 2016 18:47:02 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBKIl25t010271; Tue, 20 Dec 2016 18:47:02 GMT (envelope-from br@FreeBSD.org) Message-Id: <201612201847.uBKIl25t010271@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Tue, 20 Dec 2016 18:47:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310334 - head/sys/mips/ingenic X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 20 Dec 2016 18:47:03 -0000 Author: br Date: Tue Dec 20 18:47:02 2016 New Revision: 310334 URL: https://svnweb.freebsd.org/changeset/base/310334 Log: o Unmute headphones on Imgtec CI20 board. o Add some delay between codec initialization procedures. Sponsored by: DARPA, AFRL Modified: head/sys/mips/ingenic/jz4780_codec.c Modified: head/sys/mips/ingenic/jz4780_codec.c ============================================================================== --- head/sys/mips/ingenic/jz4780_codec.c Tue Dec 20 18:27:53 2016 (r310333) +++ head/sys/mips/ingenic/jz4780_codec.c Tue Dec 20 18:47:02 2016 (r310334) @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include @@ -50,9 +51,14 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #include #include +#define CI20_HP_PIN 13 +#define CI20_HP_PORT 3 + struct codec_softc { device_t dev; struct resource *res[1]; @@ -149,6 +155,41 @@ codec_print_registers(struct codec_softc printf("codec DR_ADC_AGC %x\n", codec_read(sc, DR_ADC_AGC)); } +/* + * CI20 board-specific + */ +static int +ci20_hp_unmute(struct codec_softc *sc) +{ + device_t dev; + int port; + int err; + int pin; + + pin = CI20_HP_PIN; + port = CI20_HP_PORT; + + dev = devclass_get_device(devclass_find("gpio"), port); + if (dev == NULL) + return (0); + + err = GPIO_PIN_SETFLAGS(dev, pin, GPIO_PIN_OUTPUT); + if (err != 0) { + device_printf(dev, "Cannot configure GPIO pin %d on %s\n", + pin, device_get_nameunit(dev)); + return (err); + } + + err = GPIO_PIN_SET(dev, pin, 0); + if (err != 0) { + device_printf(dev, "Cannot configure GPIO pin %d on %s\n", + pin, device_get_nameunit(dev)); + return (err); + } + + return (0); +} + static int codec_probe(device_t dev) { @@ -187,10 +228,14 @@ codec_attach(device_t dev) reg &= ~(VIC_SB_SLEEP | VIC_SB); codec_write(sc, CR_VIC, reg); + DELAY(20000); + reg = codec_read(sc, CR_DAC); reg &= ~(DAC_SB | DAC_MUTE); codec_write(sc, CR_DAC, reg); + DELAY(10000); + /* I2S, 16-bit, 96 kHz. */ reg = codec_read(sc, AICR_DAC); reg &= ~(AICR_DAC_SB | DAC_ADWL_M); @@ -199,13 +244,19 @@ codec_attach(device_t dev) reg |= AUDIOIF_I2S; codec_write(sc, AICR_DAC, reg); + DELAY(10000); + reg = FCR_DAC_96; codec_write(sc, FCR_DAC, reg); + DELAY(10000); + /* Unmute headphones. */ reg = codec_read(sc, CR_HP); reg &= ~(HP_SB | HP_MUTE); - codec_write(sc, CR_HP, 0); + codec_write(sc, CR_HP, reg); + + ci20_hp_unmute(sc); return (0); } From owner-svn-src-head@freebsd.org Tue Dec 20 19:44:45 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B5EBAC89721; Tue, 20 Dec 2016 19:44:45 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 787AB1878; Tue, 20 Dec 2016 19:44:45 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBKJiiHO034232; Tue, 20 Dec 2016 19:44:44 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBKJiiMg034231; Tue, 20 Dec 2016 19:44:44 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201612201944.uBKJiiMg034231@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Tue, 20 Dec 2016 19:44:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310336 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 20 Dec 2016 19:44:45 -0000 Author: jhb Date: Tue Dec 20 19:44:44 2016 New Revision: 310336 URL: https://svnweb.freebsd.org/changeset/base/310336 Log: Don't spin in pause() during early boot for kthreads other than thread0. pause() uses a spin loop to simulate a sleep during early boot. However, we only need this for thread0 to get far enough in the boot process to enable timers (at which point pause() can sleep). For other kthreads, sleeping in pause() is ok as the callout will be scheduled and will eventually fire once thread0 initializes timers. Tested by: Steven Kargl Sleuthing by: markj MFC after: 1 week Sponsored by: Netflix Modified: head/sys/kern/kern_synch.c Modified: head/sys/kern/kern_synch.c ============================================================================== --- head/sys/kern/kern_synch.c Tue Dec 20 19:30:21 2016 (r310335) +++ head/sys/kern/kern_synch.c Tue Dec 20 19:44:44 2016 (r310336) @@ -321,7 +321,8 @@ pause_sbt(const char *wmesg, sbintime_t if (sbt == 0) sbt = tick_sbt; - if (cold || kdb_active || SCHEDULER_STOPPED()) { + if ((cold && curthread == &thread0) || kdb_active || + SCHEDULER_STOPPED()) { /* * We delay one second at a time to avoid overflowing the * system specific DELAY() function(s): From owner-svn-src-head@freebsd.org Tue Dec 20 20:11:17 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7CD1EC89D26; Tue, 20 Dec 2016 20:11:17 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 3AF0363C; Tue, 20 Dec 2016 20:11:17 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBKKBGiL043315; Tue, 20 Dec 2016 20:11:16 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBKKBGZr043314; Tue, 20 Dec 2016 20:11:16 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201612202011.uBKKBGZr043314@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: glebius set sender to glebius@FreeBSD.org using -f From: Gleb Smirnoff Date: Tue, 20 Dec 2016 20:11:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310337 - head/lib/libkvm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 20 Dec 2016 20:11:17 -0000 Author: glebius Date: Tue Dec 20 20:11:16 2016 New Revision: 310337 URL: https://svnweb.freebsd.org/changeset/base/310337 Log: Fix memory leak. CID: 1367751 Reviewed by: jhb Modified: head/lib/libkvm/kvm_private.c Modified: head/lib/libkvm/kvm_private.c ============================================================================== --- head/lib/libkvm/kvm_private.c Tue Dec 20 19:44:44 2016 (r310336) +++ head/lib/libkvm/kvm_private.c Tue Dec 20 20:11:16 2016 (r310337) @@ -200,6 +200,7 @@ _kvm_read_core_phdrs(kvm_t *kd, size_t * for (i = 0; i < phnum; i++) { if (gelf_getphdr(elf, i, &phdr[i]) == NULL) { + free(phdr); _kvm_err(kd, kd->program, "%s", elf_errmsg(0)); goto bad; } From owner-svn-src-head@freebsd.org Tue Dec 20 20:50:15 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9E9A4C89DD4; Tue, 20 Dec 2016 20:50:15 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from mail.baldwin.cx (bigwig.baldwin.cx [96.47.65.170]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E5F3B1A48; Tue, 20 Dec 2016 20:50:14 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by mail.baldwin.cx (Postfix) with ESMTPSA id CF11F10AA28; Tue, 20 Dec 2016 15:50:13 -0500 (EST) From: John Baldwin To: Ruslan Bukin Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r310330 - in head: share/man/man4 sys/conf sys/dev/xdma Date: Tue, 20 Dec 2016 12:50:11 -0800 Message-ID: <1904181.V85ZRTRTAB@ralph.baldwin.cx> User-Agent: KMail/4.14.10 (FreeBSD/11.0-PRERELEASE; KDE/4.14.10; amd64; ; ) In-Reply-To: <201612201802.uBKI27oN091165@repo.freebsd.org> References: <201612201802.uBKI27oN091165@repo.freebsd.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mail.baldwin.cx); Tue, 20 Dec 2016 15:50:13 -0500 (EST) X-Virus-Scanned: clamav-milter 0.99.2 at mail.baldwin.cx X-Virus-Status: Clean X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 20 Dec 2016 20:50:15 -0000 On Tuesday, December 20, 2016 06:02:07 PM Ruslan Bukin wrote: > Author: br > Date: Tue Dec 20 18:02:07 2016 > New Revision: 310330 > URL: https://svnweb.freebsd.org/changeset/base/310330 > > Log: > Add xDMA -- the DMA abstraction layer, initial verison. > > xDMA is a DMA framework designed to abstract the interaction > between device drivers and DMA engines. > > Project wiki: https://wiki.freebsd.org/xdma > > Sponsored by: DARPA, AFRL > Differential Revision: https://reviews.freebsd.org/D8807 It probably would have been a good idea to get some design review of this on arch@ before committing. In particular, I believe from earlier discussions that you want to build a general framework that things like ioat(4) can hook into. arch@ would give you a broader audience for working out the abstractions and interfaces. -- John Baldwin From owner-svn-src-head@freebsd.org Tue Dec 20 21:17:09 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 310EBC885FD; Tue, 20 Dec 2016 21:17:09 +0000 (UTC) (envelope-from ken@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 E02CCA11; Tue, 20 Dec 2016 21:17:08 +0000 (UTC) (envelope-from ken@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBKLH8gE070146; Tue, 20 Dec 2016 21:17:08 GMT (envelope-from ken@FreeBSD.org) Received: (from ken@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBKLH77j070143; Tue, 20 Dec 2016 21:17:07 GMT (envelope-from ken@FreeBSD.org) Message-Id: <201612202117.uBKLH77j070143@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ken set sender to ken@FreeBSD.org using -f From: "Kenneth D. Merry" Date: Tue, 20 Dec 2016 21:17:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310338 - in head: share/man/man4 sys/conf sys/dev/isp X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 20 Dec 2016 21:17:09 -0000 Author: ken Date: Tue Dec 20 21:17:07 2016 New Revision: 310338 URL: https://svnweb.freebsd.org/changeset/base/310338 Log: Turn on FC-Tape by default in the isp(4) driver. FC-Tape provides additional link level error recovery, and is highly recommended for tape devices. It will only be turned on for a given target if the target supports it. Without this setting, we default to whatever FC-Tape setting is in NVRAM on the card. This can be overridden by setting the following loader tunable, for example for isp0: hint.isp.0.nofctape=1 sys/conf/options: Add a new kernel config option, ISP_FCTAPE_OFF, that defaults the FC-Tape configuration to off. sys/dev/isp/isp_pci.c: If ISP_FCTAPE_OFF is defined, turn off FC-Tape. Otherwise, turn it on if the card supports it. share/man/man4/isp.4: Add a description of FC-Tape to the isp(4) man page. Add descriptions of the fctape and nofctape options, as well as the ISP_FCTAPE_OFF kernel configuration option. Add the ispfw module and kernel drivers to the suggested configurations at the top of the man page so that users are less likely to leave it out. The driver works well with the included firmware, but may not work at all with whatever firmware the user has flashed on their card. MFC after: 3 days Sponsored by: Spectra Logic Modified: head/share/man/man4/isp.4 head/sys/conf/options head/sys/dev/isp/isp_pci.c Modified: head/share/man/man4/isp.4 ============================================================================== --- head/share/man/man4/isp.4 Tue Dec 20 20:11:16 2016 (r310337) +++ head/share/man/man4/isp.4 Tue Dec 20 21:17:07 2016 (r310338) @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 9, 2015 +.Dd December 20, 2016 .Dt ISP 4 .Os .Sh NAME @@ -39,13 +39,15 @@ kernel configuration file: .Bd -ragged -offset indent .Cd "device scbus" .Cd "device isp" +.Cd "device ispfw" .Ed .Pp Alternatively, to load the driver as a -module at boot time, place the following line in +module at boot time, place the following lines in .Xr loader.conf 5 : .Bd -literal -offset indent isp_load="YES" +ispfw_load="YES" .Ed .Sh DESCRIPTION This driver provides access to @@ -62,6 +64,30 @@ Fibre Channel supports initiator and tar utilizing Class 3 and Class 2 (2200 and later) connections. Support is available for Public and Private loops, Point-to-Point and Fabric connections. +.Pp +FC-Tape is supported on 4Gb (2400) and newer controllers. +FC-Tape is highly recommended for connections to tape drives that support +it. +It encompasses four elements from the the T-10 FCP-4 specification: +.Bl -bullet -offset indent +.It +Precise Delivery of Commands +.It +Confirmed Completion of FCP I/O Operations +.It +Retransmission of Unsuccessfully Transmitted IUs +.It +Task Retry Identification +.El +.Pp +Together these features allow for link level error recovery with tape +devices. +Without it, an initiator cannot, for instance, tell whether a tape write +command that has timed out resulted in all, part or none of the data going to +the tape drive. +FC-Tape is automatically enabled when connecting controller that supports +it to a target that supports it. +It may be disabled using configuration and hint options described below. .Sh FIRMWARE Firmware loading is supported if the .Xr ispfw 4 @@ -120,6 +146,13 @@ Target mode support for Fibre Channel ad .Cd options ISP_TARGET_MODE .Pp option. +.Pp +To disable FC-Tape, use the following configuration option: +.Pp +.Cd options ISP_FCTAPE_OFF +.Pp +Note that even if the ISP_FCTAPE_OFF option is used, it may be overridden +by the fctape hint described below. .Sh BOOT OPTIONS The following options are switchable by setting values in .Pa /boot/device.hints . @@ -169,6 +202,11 @@ A hint value for a driver debug level (s for the values. .It Va hint.isp.0.vports A hint to create specified number of additional virtual ports. +.It Va hint.isp.0.nofctape +Set this to 1 to disable FC-Tape operation on the given isp instance. +.It Va hint.isp.0.fctape +Set this to 1 to enable FC-Tape operation on the given isp instance for +targets that support it. .El .Sh SYSCTL OPTIONS .Bl -tag -width indent Modified: head/sys/conf/options ============================================================================== --- head/sys/conf/options Tue Dec 20 20:11:16 2016 (r310337) +++ head/sys/conf/options Tue Dec 20 21:17:07 2016 (r310338) @@ -384,6 +384,7 @@ ISP_TARGET_MODE opt_isp.h ISP_FW_CRASH_DUMP opt_isp.h ISP_DEFAULT_ROLES opt_isp.h ISP_INTERNAL_TARGET opt_isp.h +ISP_FCTAPE_OFF opt_isp.h # Options used only in dev/iscsi ISCSI_INITIATOR_DEBUG opt_iscsi_initiator.h Modified: head/sys/dev/isp/isp_pci.c ============================================================================== --- head/sys/dev/isp/isp_pci.c Tue Dec 20 20:11:16 2016 (r310337) +++ head/sys/dev/isp/isp_pci.c Tue Dec 20 21:17:07 2016 (r310338) @@ -598,11 +598,18 @@ isp_get_specific_options(device_t dev, i } } +#ifdef ISP_FCTAPE_OFF + isp->isp_confopts |= ISP_CFG_NOFCTAPE; +#else + isp->isp_confopts |= ISP_CFG_FCTAPE; +#endif + tval = 0; snprintf(name, sizeof(name), "%snofctape", prefix); (void) resource_int_value(device_get_name(dev), device_get_unit(dev), name, &tval); if (tval) { + isp->isp_confopts &= ~ISP_CFG_FCTAPE; isp->isp_confopts |= ISP_CFG_NOFCTAPE; } From owner-svn-src-head@freebsd.org Tue Dec 20 21:58:45 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4F36EC7642A; Tue, 20 Dec 2016 21:58:45 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 11AF2255; Tue, 20 Dec 2016 21:58:44 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBKLwicZ086934; Tue, 20 Dec 2016 21:58:44 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBKLwiaH086932; Tue, 20 Dec 2016 21:58:44 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201612202158.uBKLwiaH086932@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 20 Dec 2016 21:58:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310339 - in head/sys/cam: ctl scsi X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 20 Dec 2016 21:58:45 -0000 Author: mav Date: Tue Dec 20 21:58:43 2016 New Revision: 310339 URL: https://svnweb.freebsd.org/changeset/base/310339 Log: Bump specifications support to SAM-6/SPC-5. Modified: head/sys/cam/ctl/ctl.c head/sys/cam/scsi/scsi_all.h Modified: head/sys/cam/ctl/ctl.c ============================================================================== --- head/sys/cam/ctl/ctl.c Tue Dec 20 21:17:07 2016 (r310338) +++ head/sys/cam/ctl/ctl.c Tue Dec 20 21:58:43 2016 (r310339) @@ -10174,7 +10174,7 @@ ctl_inquiry_std(struct ctl_scsiio *ctsio inq_ptr->device = (SID_QUAL_BAD_LU << 5) | T_NODEVICE; /* RMB in byte 2 is 0 */ - inq_ptr->version = SCSI_REV_SPC4; + inq_ptr->version = SCSI_REV_SPC5; /* * According to SAM-3, even if a device only supports a single @@ -10272,10 +10272,10 @@ ctl_inquiry_std(struct ctl_scsiio *ctsio inq_ptr->spi3data = SID_SPI_CLOCK_DT_ST | SID_SPI_QAS | SID_SPI_IUS; - /* SAM-5 (no version claimed) */ - scsi_ulto2b(0x00A0, inq_ptr->version1); - /* SPC-4 (no version claimed) */ - scsi_ulto2b(0x0460, inq_ptr->version2); + /* SAM-6 (no version claimed) */ + scsi_ulto2b(0x00C0, inq_ptr->version1); + /* SPC-5 (no version claimed) */ + scsi_ulto2b(0x05C0, inq_ptr->version2); if (port_type == CTL_PORT_FC) { /* FCP-2 ANSI INCITS.350:2003 */ scsi_ulto2b(0x0917, inq_ptr->version3); Modified: head/sys/cam/scsi/scsi_all.h ============================================================================== --- head/sys/cam/scsi/scsi_all.h Tue Dec 20 21:17:07 2016 (r310338) +++ head/sys/cam/scsi/scsi_all.h Tue Dec 20 21:58:43 2016 (r310339) @@ -2156,6 +2156,7 @@ struct scsi_inquiry_data #define SCSI_REV_SPC2 4 #define SCSI_REV_SPC3 5 #define SCSI_REV_SPC4 6 +#define SCSI_REV_SPC5 7 #define SID_ECMA 0x38 #define SID_ISO 0xC0 From owner-svn-src-head@freebsd.org Tue Dec 20 22:08:38 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 10278C768B8; Tue, 20 Dec 2016 22:08:38 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 BAAC3B76; Tue, 20 Dec 2016 22:08:37 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBKM8ata090814; Tue, 20 Dec 2016 22:08:36 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBKM8aH9090812; Tue, 20 Dec 2016 22:08:36 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201612202208.uBKM8aH9090812@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: "Conrad E. Meyer" Date: Tue, 20 Dec 2016 22:08:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310340 - in head/sys/dev: ichiic sdhci X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 20 Dec 2016 22:08:38 -0000 Author: cem Date: Tue Dec 20 22:08:36 2016 New Revision: 310340 URL: https://svnweb.freebsd.org/changeset/base/310340 Log: Add Braswell PCI IDs for Intel Cherryview Submitted by: Johannes Lundberg Reviewed by: jhb Differential Revision: https://reviews.freebsd.org/D8861 Modified: head/sys/dev/ichiic/ig4_pci.c head/sys/dev/sdhci/sdhci_pci.c Modified: head/sys/dev/ichiic/ig4_pci.c ============================================================================== --- head/sys/dev/ichiic/ig4_pci.c Tue Dec 20 21:58:43 2016 (r310339) +++ head/sys/dev/ichiic/ig4_pci.c Tue Dec 20 22:08:36 2016 (r310340) @@ -68,6 +68,12 @@ static int ig4iic_pci_detach(device_t de #define PCI_CHIP_LYNXPT_LP_I2C_1 0x9c618086 #define PCI_CHIP_LYNXPT_LP_I2C_2 0x9c628086 +#define PCI_CHIP_BRASWELL_I2C_1 0x22c18086 +#define PCI_CHIP_BRASWELL_I2C_2 0x22c28086 +#define PCI_CHIP_BRASWELL_I2C_3 0x22c38086 +#define PCI_CHIP_BRASWELL_I2C_5 0x22c58086 +#define PCI_CHIP_BRASWELL_I2C_6 0x22c68086 +#define PCI_CHIP_BRASWELL_I2C_7 0x22c78086 static int ig4iic_pci_probe(device_t dev) @@ -79,6 +85,24 @@ ig4iic_pci_probe(device_t dev) case PCI_CHIP_LYNXPT_LP_I2C_2: device_set_desc(dev, "Intel Lynx Point-LP I2C Controller-2"); break; + case PCI_CHIP_BRASWELL_I2C_1: + device_set_desc(dev, "Intel Braswell Serial I/O I2C Port 1"); + break; + case PCI_CHIP_BRASWELL_I2C_2: + device_set_desc(dev, "Intel Braswell Serial I/O I2C Port 2"); + break; + case PCI_CHIP_BRASWELL_I2C_3: + device_set_desc(dev, "Intel Braswell Serial I/O I2C Port 3"); + break; + case PCI_CHIP_BRASWELL_I2C_5: + device_set_desc(dev, "Intel Braswell Serial I/O I2C Port 5"); + break; + case PCI_CHIP_BRASWELL_I2C_6: + device_set_desc(dev, "Intel Braswell Serial I/O I2C Port 6"); + break; + case PCI_CHIP_BRASWELL_I2C_7: + device_set_desc(dev, "Intel Braswell Serial I/O I2C Port 7"); + break; default: return (ENXIO); } Modified: head/sys/dev/sdhci/sdhci_pci.c ============================================================================== --- head/sys/dev/sdhci/sdhci_pci.c Tue Dec 20 21:58:43 2016 (r310339) +++ head/sys/dev/sdhci/sdhci_pci.c Tue Dec 20 22:08:36 2016 (r310340) @@ -107,6 +107,8 @@ static const struct sdhci_device { SDHCI_QUIRK_RESET_AFTER_REQUEST }, { 0x16bc14e4, 0xffff, "Broadcom BCM577xx SDXC/MMC Card Reader", SDHCI_QUIRK_BCM577XX_400KHZ_CLKSRC }, + { 0x22948086, 0xffff, "Braswell Storage Cluster Control MMC Port", + 0 }, { 0, 0xffff, NULL, 0 } }; From owner-svn-src-head@freebsd.org Tue Dec 20 22:47:10 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B206BC81877; Tue, 20 Dec 2016 22:47:10 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 81B75289; Tue, 20 Dec 2016 22:47:10 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBKMl9bX006709; Tue, 20 Dec 2016 22:47:09 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBKMl9bW006708; Tue, 20 Dec 2016 22:47:09 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201612202247.uBKMl9bW006708@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: "Conrad E. Meyer" Date: Tue, 20 Dec 2016 22:47:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310341 - head/sys/dev/sdhci X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 20 Dec 2016 22:47:10 -0000 Author: cem Date: Tue Dec 20 22:47:09 2016 New Revision: 310341 URL: https://svnweb.freebsd.org/changeset/base/310341 Log: Follow-up to r310340: Add missing "Intel" to description Reported by: rpokala@ Modified: head/sys/dev/sdhci/sdhci_pci.c Modified: head/sys/dev/sdhci/sdhci_pci.c ============================================================================== --- head/sys/dev/sdhci/sdhci_pci.c Tue Dec 20 22:08:36 2016 (r310340) +++ head/sys/dev/sdhci/sdhci_pci.c Tue Dec 20 22:47:09 2016 (r310341) @@ -107,7 +107,7 @@ static const struct sdhci_device { SDHCI_QUIRK_RESET_AFTER_REQUEST }, { 0x16bc14e4, 0xffff, "Broadcom BCM577xx SDXC/MMC Card Reader", SDHCI_QUIRK_BCM577XX_400KHZ_CLKSRC }, - { 0x22948086, 0xffff, "Braswell Storage Cluster Control MMC Port", + { 0x22948086, 0xffff, "Intel Braswell Storage Cluster Control MMC Port", 0 }, { 0, 0xffff, NULL, 0 } From owner-svn-src-head@freebsd.org Wed Dec 21 00:47:34 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 607FAC88270; Wed, 21 Dec 2016 00:47:34 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-wj0-f170.google.com (mail-wj0-f170.google.com [209.85.210.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 74EC9112D; Wed, 21 Dec 2016 00:47:33 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-wj0-f170.google.com with SMTP id xy5so189606271wjc.0; Tue, 20 Dec 2016 16:47:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc:content-transfer-encoding; bh=6tb+h4fNNOHEW6lSGkx50xh9MypJYKYFGTzfYhvZHm0=; b=Shab7wLqhkDS7sGH9vY2PLmHfmWH2YCi6fngbl2RMVZXQX1boSW8nGFXTD7jHt4qZ+ CC/JylAnpJ2tNjidAgrqL7eT7krqGLigTecWGiQKpRuoAS7XoFE+NTKzLiM70/TMU7La 7+i/Jci1ZA7CrNeDJ+yXEcA8CnHVDXgudzADMcfeWLWHA5JDEQujgQaNpoCukaL/ZZHI Ns0ZBi0aYKv3IE7Yr9kEG0TE5NZEcZUG5MHOMO4AL3O5OC2ZdSd0jeYWGP3tGttPUrCb Oi1cZeXv3H0bnF+Xx+/wKv/tLm2ESoZrUpT9H5HF/1xUFPzikVdlJkay5z0fFn3TWJGM MHJg== X-Gm-Message-State: AIkVDXJAK4RZJytkmOENXbZIa+OJTFaNwK8uMTpIuFzdQZbeaL9jDNKjFxJICx09KjPB6Q== X-Received: by 10.195.17.170 with SMTP id gf10mr1642614wjd.59.1482277814599; Tue, 20 Dec 2016 15:50:14 -0800 (PST) Received: from mail-wm0-f53.google.com (mail-wm0-f53.google.com. [74.125.82.53]) by smtp.gmail.com with ESMTPSA id f3sm24445272wmf.10.2016.12.20.15.50.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Dec 2016 15:50:14 -0800 (PST) Received: by mail-wm0-f53.google.com with SMTP id t79so144340090wmt.0; Tue, 20 Dec 2016 15:50:14 -0800 (PST) X-Received: by 10.28.54.214 with SMTP id y83mr2006038wmh.45.1482277814318; Tue, 20 Dec 2016 15:50:14 -0800 (PST) MIME-Version: 1.0 Reply-To: cem@freebsd.org Received: by 10.194.29.72 with HTTP; Tue, 20 Dec 2016 15:50:13 -0800 (PST) In-Reply-To: References: <201612160144.uBG1ipjW016736@repo.freebsd.org> <49460793.UcUNovQMDa@ralph.baldwin.cx> From: Conrad Meyer Date: Tue, 20 Dec 2016 15:50:13 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r310138 - head/lib/libc/stdio To: Adrian Chadd Cc: Baptiste Daroussin , src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Dec 2016 00:47:34 -0000 I didn't get the same conclusion from the thread =E2=80=94 I haven't seen a persuasive argument for removal. Best, Conrad On Mon, Dec 19, 2016 at 2:23 PM, Adrian Chadd wrot= e: > [snip] > > tl;dr - can we revert it from stdio for now so we don't end up having > people use this? > > > > -adrian From owner-svn-src-head@freebsd.org Wed Dec 21 00:50:22 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 73F98C88343; Wed, 21 Dec 2016 00:50:22 +0000 (UTC) (envelope-from landonf@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 4E69B1336; Wed, 21 Dec 2016 00:50:22 +0000 (UTC) (envelope-from landonf@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBL0oL4j055521; Wed, 21 Dec 2016 00:50:21 GMT (envelope-from landonf@FreeBSD.org) Received: (from landonf@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBL0oL6i055520; Wed, 21 Dec 2016 00:50:21 GMT (envelope-from landonf@FreeBSD.org) Message-Id: <201612210050.uBL0oL6i055520@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: landonf set sender to landonf@FreeBSD.org using -f From: "Landon J. Fuller" Date: Wed, 21 Dec 2016 00:50:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310342 - head/sys/dev/bhnd/tools X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Dec 2016 00:50:22 -0000 Author: landonf Date: Wed Dec 21 00:50:21 2016 New Revision: 310342 URL: https://svnweb.freebsd.org/changeset/base/310342 Log: bhnd(4): Use a stable sort key to produce deterministic nvram_map_gen.awk output. When ordering SROM layout entries, we now use the unique (var_id, rev_start, rev_end) tuple as the sort key; this fixes the previously non-deterministic output when sorting entries with overlapping var_ids. PR: 215422 Reported by: emaste Reviewed by: emaste Approved by: adrian (mentor) Differential Revision: https://reviews.freebsd.org/D8859 Modified: head/sys/dev/bhnd/tools/nvram_map_gen.awk Modified: head/sys/dev/bhnd/tools/nvram_map_gen.awk ============================================================================== --- head/sys/dev/bhnd/tools/nvram_map_gen.awk Tue Dec 20 22:47:09 2016 (r310341) +++ head/sys/dev/bhnd/tools/nvram_map_gen.awk Wed Dec 21 00:50:21 2016 (r310342) @@ -1519,8 +1519,10 @@ function write_srom_bindings(layout, _va array_append(_entries, _entry) } - # Sort entries by variable ID, ascending - array_sort(_entries, prop_path_create(p_var, p_vid)) + # Sort entries by (variable ID, revision range), ascending + array_sort(_entries, prop_path_create(p_var, p_vid), + prop_path_create(p_revisions, p_start), + prop_path_create(p_revisions, p_end)) # Emit all entry binding opcodes emit("static const uint8_t " _varname "[] = {\n") @@ -2297,17 +2299,24 @@ function array_get(array, idx) { # # Sort an array, using standard awk comparison operators over its values. # -# If `prop_path` is non-NULL, the corresponding property path (or property ID) +# If `prop_path*` is non-NULL, the corresponding property path (or property ID) # will be fetched from each array element and used as the sorting value. # -function array_sort(array, prop_path, _size) { +# If multiple property paths are specified, the array is first sorted by +# the first path, and then any equal values are sorted by the second path, +# and so on. +# +function array_sort(array, prop_path0, prop_path1, prop_path2, _size) { obj_assert_class(array, Array) + if (_size != null) + errorx("no more than three property paths may be specified") + _size = array_size(array) if (_size <= 1) return - _qsort(array, prop_path, 0, _size-1) + _qsort(array, prop_path0, prop_path1, prop_path2, 0, _size-1) } function _qsort_get_key(array, idx, prop_path, _v) { @@ -2319,8 +2328,35 @@ function _qsort_get_key(array, idx, prop return (prop_get_path(_v, prop_path)) } -function _qsort(array, prop_path, first, last, _qpivot, _qpivot_val, _qleft, - _qleft_val, _qright, _qright_val) +function _qsort_compare(array, lhs_idx, rhs_val, ppath0, ppath1, ppath2, + _lhs_val, _rhs_prop_val) +{ + _lhs_val = _qsort_get_key(array, lhs_idx, ppath0) + if (ppath0 == null) + _rhs_prop_val = rhs_val + else + _rhs_prop_val = prop_get_path(rhs_val, ppath0) + + if (_lhs_val == _rhs_prop_val && ppath1 != null) { + _lhs_val = _qsort_get_key(array, lhs_idx, ppath1) + _rhs_prop_val = prop_get_path(rhs_val, ppath1) + + if (_lhs_val == _rhs_prop_val && ppath2 != null) { + _lhs_val = _qsort_get_key(array, lhs_idx, ppath2) + _rhs_prop_val = prop_get_path(rhs_val, ppath2) + } + } + + if (_lhs_val < _rhs_prop_val) + return (-1) + else if (_lhs_val > _rhs_prop_val) + return (1) + else + return (0) +} + +function _qsort(array, ppath0, ppath1, ppath2, first, last, _qpivot, + _qleft, _qleft_val, _qright, _qright_val) { if (first >= last) return @@ -2330,15 +2366,21 @@ function _qsort(array, prop_path, first, _qleft = first _qright = last - _qpivot_val = _qsort_get_key(array, _qpivot, prop_path) + _qpivot_val = array_get(array, _qpivot) # partition while (_qleft <= _qright) { - while (_qsort_get_key(array, _qleft, prop_path) < _qpivot_val) + while (_qsort_compare(array, _qleft, _qpivot_val, ppath0, ppath1, + ppath2) < 0) + { _qleft++ + } - while (_qsort_get_key(array, _qright, prop_path) > _qpivot_val) + while (_qsort_compare(array, _qright, _qpivot_val, ppath0, ppath1, + ppath2) > 0) + { _qright-- + } # swap if (_qleft <= _qright) { @@ -2354,8 +2396,8 @@ function _qsort(array, prop_path, first, } # sort the partitions - _qsort(array, prop_path, first, _qright) - _qsort(array, prop_path, _qleft, last) + _qsort(array, ppath0, ppath1, ppath2, first, _qright) + _qsort(array, ppath0, ppath1, ppath2, _qleft, last) } From owner-svn-src-head@freebsd.org Wed Dec 21 00:56:23 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 62DC1C88669 for ; Wed, 21 Dec 2016 00:56:23 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from outbound1b.ore.mailhop.org (outbound1b.ore.mailhop.org [54.200.247.200]) (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 443F5194A for ; Wed, 21 Dec 2016 00:56:22 +0000 (UTC) (envelope-from ian@freebsd.org) X-MHO-User: 4dcce6d5-c718-11e6-8c89-112185c90658 X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Originating-IP: 73.78.92.27 X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (unknown [73.78.92.27]) by outbound1.ore.mailhop.org (Halon) with ESMTPSA id 4dcce6d5-c718-11e6-8c89-112185c90658; Wed, 21 Dec 2016 00:56:28 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id uBL0uJCL004538; Tue, 20 Dec 2016 17:56:19 -0700 (MST) (envelope-from ian@freebsd.org) Message-ID: <1482281779.48539.41.camel@freebsd.org> Subject: Re: svn commit: r310138 - head/lib/libc/stdio From: Ian Lepore To: cem@freebsd.org, Adrian Chadd Cc: Baptiste Daroussin , src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Date: Tue, 20 Dec 2016 17:56:19 -0700 In-Reply-To: References: <201612160144.uBG1ipjW016736@repo.freebsd.org> <49460793.UcUNovQMDa@ralph.baldwin.cx> Content-Type: text/plain; charset="windows-1251" X-Mailer: Evolution 3.18.5.1 FreeBSD GNOME Team Port Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Dec 2016 00:56:23 -0000 On Tue, 2016-12-20 at 15:50 -0800, Conrad Meyer wrote: > I didn't get the same conclusion from the thread — I haven't seen a > persuasive argument for removal. > > Best, > Conrad > You're kidding, right?  Can you cite even a single message that supports the change?  My memory is that everyone who voiced an opinion said it was a bad idea, then the thread devolved into discussions of alternatives and how they were bad ideas too.  That latter bit doesn't change the basic fact that everyone started by agreeing this was a bad idea for userland. -- Ian > On Mon, Dec 19, 2016 at 2:23 PM, Adrian Chadd > wrote: > > > > [snip] > > > > tl;dr - can we revert it from stdio for now so we don't end up > > having > > people use this? > > > > > > > > -adrian > From owner-svn-src-head@freebsd.org Wed Dec 21 01:32:20 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5A672C89282; Wed, 21 Dec 2016 01:32:20 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 106AC1B25; Wed, 21 Dec 2016 01:32:19 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBL1WJkl075949; Wed, 21 Dec 2016 01:32:19 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBL1WJJJ075948; Wed, 21 Dec 2016 01:32:19 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201612210132.uBL1WJJJ075948@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Wed, 21 Dec 2016 01:32:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310343 - head/sys/arm/freescale/imx X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Dec 2016 01:32:20 -0000 Author: gonzo Date: Wed Dec 21 01:32:19 2016 New Revision: 310343 URL: https://svnweb.freebsd.org/changeset/base/310343 Log: [iMX6] Fix build for SSI driver and add dependency for SDMA driver - Pass correct pointer to OF_getencprop - Check the size of "dmas" property - Add dependency on sdma driver Reviewed by: br MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D8873 Modified: head/sys/arm/freescale/imx/imx6_ssi.c Modified: head/sys/arm/freescale/imx/imx6_ssi.c ============================================================================== --- head/sys/arm/freescale/imx/imx6_ssi.c Wed Dec 21 00:50:21 2016 (r310342) +++ head/sys/arm/freescale/imx/imx6_ssi.c Wed Dec 21 01:32:19 2016 (r310343) @@ -66,6 +66,7 @@ __FBSDID("$FreeBSD$"); bus_space_write_4(_sc->bst, _sc->bsh, _reg, _val) #define SSI_NCHANNELS 1 +#define DMAS_TOTAL 8 /* i.MX6 SSI registers */ @@ -187,8 +188,8 @@ struct sc_info { struct sdma_conf *conf; struct ssi_rate *sr; struct sdma_softc *sdma_sc; - int sdma_ev_rx; - int sdma_ev_tx; + uint32_t sdma_ev_rx; + uint32_t sdma_ev_tx; int sdma_channel; }; @@ -437,7 +438,7 @@ find_sdma_controller(struct sc_info *sc) struct sdma_softc *sdma_sc; phandle_t node, sdma_node; device_t sdma_dev; - int dts_value[8]; + pcell_t dts_value[DMAS_TOTAL]; int len; if ((node = ofw_bus_get_node(sc->dev)) == -1) @@ -446,7 +447,14 @@ find_sdma_controller(struct sc_info *sc) if ((len = OF_getproplen(node, "dmas")) <= 0) return (ENXIO); - OF_getencprop(node, "dmas", &dts_value, len); + if (len != sizeof(dts_value)) { + device_printf(sc->dev, + "\"dmas\" property length is invalid: %d (expected %d)", + len, sizeof(dts_value)); + return (ENXIO); + } + + OF_getencprop(node, "dmas", dts_value, sizeof(dts_value)); sc->sdma_ev_rx = dts_value[1]; sc->sdma_ev_tx = dts_value[5]; @@ -850,4 +858,5 @@ static driver_t ssi_pcm_driver = { DRIVER_MODULE(ssi, simplebus, ssi_pcm_driver, pcm_devclass, 0, 0); MODULE_DEPEND(ssi, sound, SOUND_MINVER, SOUND_PREFVER, SOUND_MAXVER); +MODULE_DEPEND(ssi, sdma, 0, 0, 0); MODULE_VERSION(ssi, 1); From owner-svn-src-head@freebsd.org Wed Dec 21 01:38:45 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A74EEC8940C; Wed, 21 Dec 2016 01:38:45 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 5E6F51D66; Wed, 21 Dec 2016 01:38:45 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBL1cipA076350; Wed, 21 Dec 2016 01:38:44 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBL1ci9b076348; Wed, 21 Dec 2016 01:38:44 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201612210138.uBL1ci9b076348@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Wed, 21 Dec 2016 01:38:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310344 - head/sys/arm/freescale/imx X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Dec 2016 01:38:45 -0000 Author: gonzo Date: Wed Dec 21 01:38:44 2016 New Revision: 310344 URL: https://svnweb.freebsd.org/changeset/base/310344 Log: [iMX6] Fix SDMA driver build - Place const modifiers where required - Make sure sdma device is attahched before consumers like SSI Reviewed by: br MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D8874 Modified: head/sys/arm/freescale/imx/imx6_sdma.c head/sys/arm/freescale/imx/imx6_sdma.h Modified: head/sys/arm/freescale/imx/imx6_sdma.c ============================================================================== --- head/sys/arm/freescale/imx/imx6_sdma.c Wed Dec 21 01:32:19 2016 (r310343) +++ head/sys/arm/freescale/imx/imx6_sdma.c Wed Dec 21 01:38:44 2016 (r310344) @@ -351,7 +351,7 @@ sdma_configure(int chn, struct sdma_conf static int load_firmware(struct sdma_softc *sc) { - struct sdma_firmware_header *header; + const struct sdma_firmware_header *header; const struct firmware *fp; fp = firmware_get("sdma_fw"); @@ -360,14 +360,14 @@ load_firmware(struct sdma_softc *sc) return (-1); } - header = (struct sdma_firmware_header *)fp->data; + header = fp->data; if (header->magic != FW_HEADER_MAGIC) { device_printf(sc->dev, "Can't use firmware.\n"); return (-1); } sc->fw_header = header; - sc->fw_scripts = (void *)((char *)header + + sc->fw_scripts = (const void *)((const char *)header + header->script_addrs_start); return (0); @@ -377,14 +377,14 @@ static int boot_firmware(struct sdma_softc *sc) { struct sdma_buffer_descriptor *bd0; - uint32_t *ram_code; + const uint32_t *ram_code; int timeout; int ret; int chn; int sz; int i; - ram_code = (void *)((char *)sc->fw_header + + ram_code = (const void *)((const char *)sc->fw_header + sc->fw_header->ram_code_start); /* Make sure SDMA has not started yet */ @@ -514,4 +514,5 @@ static driver_t sdma_driver = { static devclass_t sdma_devclass; -DRIVER_MODULE(sdma, simplebus, sdma_driver, sdma_devclass, 0, 0); +EARLY_DRIVER_MODULE(sdma, simplebus, sdma_driver, sdma_devclass, 0, 0, + BUS_PASS_RESOURCE); Modified: head/sys/arm/freescale/imx/imx6_sdma.h ============================================================================== --- head/sys/arm/freescale/imx/imx6_sdma.h Wed Dec 21 01:32:19 2016 (r310343) +++ head/sys/arm/freescale/imx/imx6_sdma.h Wed Dec 21 01:38:44 2016 (r310344) @@ -221,8 +221,8 @@ struct sdma_softc { uint32_t num_bd; uint32_t ccb_phys; uint32_t context_phys; - struct sdma_firmware_header *fw_header; - struct sdma_script_start_addrs *fw_scripts; + const struct sdma_firmware_header *fw_header; + const struct sdma_script_start_addrs *fw_scripts; }; struct sdma_conf { From owner-svn-src-head@freebsd.org Wed Dec 21 01:39:12 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5CFBEC89466; Wed, 21 Dec 2016 01:39:12 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 2CB491ED7; Wed, 21 Dec 2016 01:39:12 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBL1dBcb076420; Wed, 21 Dec 2016 01:39:11 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBL1dBrZ076419; Wed, 21 Dec 2016 01:39:11 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201612210139.uBL1dBrZ076419@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 21 Dec 2016 01:39:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310345 - head/sys/geom X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Dec 2016 01:39:12 -0000 Author: sephe Date: Wed Dec 21 01:39:11 2016 New Revision: 310345 URL: https://svnweb.freebsd.org/changeset/base/310345 Log: build: Unbreak LINT Sponsored by: Microsoft Modified: head/sys/geom/geom_map.c Modified: head/sys/geom/geom_map.c ============================================================================== --- head/sys/geom/geom_map.c Wed Dec 21 01:38:44 2016 (r310344) +++ head/sys/geom/geom_map.c Wed Dec 21 01:39:11 2016 (r310345) @@ -147,8 +147,13 @@ find_marker(struct g_consumer *cp, const bzero(search_key, MAP_MAX_MARKER_LEN); sectorsize = cp->provider->sectorsize; +#ifdef __LP64__ + ret = sscanf(line, "search:%li:%li:%63c", + &search_start, &search_step, search_key); +#else ret = sscanf(line, "search:%qi:%qi:%63c", &search_start, &search_step, search_key); +#endif if (ret < 3) return (1); From owner-svn-src-head@freebsd.org Wed Dec 21 01:48:55 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DB4E6C89802; Wed, 21 Dec 2016 01:48:55 +0000 (UTC) (envelope-from feld@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 AAA781533; Wed, 21 Dec 2016 01:48:55 +0000 (UTC) (envelope-from feld@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBL1msDU080490; Wed, 21 Dec 2016 01:48:54 GMT (envelope-from feld@FreeBSD.org) Received: (from feld@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBL1mswK080489; Wed, 21 Dec 2016 01:48:54 GMT (envelope-from feld@FreeBSD.org) Message-Id: <201612210148.uBL1mswK080489@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: feld set sender to feld@FreeBSD.org using -f From: Mark Felder Date: Wed, 21 Dec 2016 01:48:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310346 - head/share/misc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Dec 2016 01:48:56 -0000 Author: feld (ports committer) Date: Wed Dec 21 01:48:54 2016 New Revision: 310346 URL: https://svnweb.freebsd.org/changeset/base/310346 Log: Add amdmi3 to ports-secteam Approved by: swills Modified: head/share/misc/organization.dot Modified: head/share/misc/organization.dot ============================================================================== --- head/share/misc/organization.dot Wed Dec 21 01:39:11 2016 (r310345) +++ head/share/misc/organization.dot Wed Dec 21 01:48:54 2016 (r310346) @@ -34,7 +34,7 @@ portmgr [label="Port Management Team\npo portmgrsecretary [label="Port Management Team Secretary\nportmgr-secretary@FreeBSD.org\nrene"] re [label="Primary Release Engineering Team\nre@FreeBSD.org\nkib, blackend, jpaetzel, hrs, kensmith"] secteam [label="Security Team\nsecteam@FreeBSD.org\ndelphij,\ndes, gavin, gjb,\nglebius, remko"] -portssecteam [label="Ports Security Team\nports-secteam@FreeBSD.org\ndelphij, eadler, feld, jgh, junovitch, rea, sbz, simon, swills, zi"] +portssecteam [label="Ports Security Team\nports-secteam@FreeBSD.org\ndelphij, amdmi3, eadler, feld, jgh, junovitch, rea, sbz, simon, swills, zi"] secteamsecretary [label="Security Team Secretary\nsecteam-secretary@FreeBSD.org\nremko"] securityofficer [label="Security Officer Team\nsecurity-officer@FreeBSD.org\ncperciva, simon, nectar"] srccommitters [label="Src Committers\nsrc-committers@FreeBSD.org"] From owner-svn-src-head@freebsd.org Wed Dec 21 01:56:52 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E9335C89A65; Wed, 21 Dec 2016 01:56:52 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: from mail-wj0-x230.google.com (mail-wj0-x230.google.com [IPv6:2a00:1450:400c:c01::230]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8959B1A1F; Wed, 21 Dec 2016 01:56:52 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: by mail-wj0-x230.google.com with SMTP id xy5so190465961wjc.0; Tue, 20 Dec 2016 17:56:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=pDOiqbetTJuQCSug0oCLoaF9y/7eCOdvLwLU+Jbq1Eg=; b=ndcVTf1ReL9eQmhfqI/uj1LYZPvzcefmjjOsTf5O52M6mqTI/pzk6mod7WNeNNByFC 1LDPm7aFl7tQaYYZ44nEikWJ3K9nRvI0uitnXn5eMuf/fnjP7O71vXOqdJ2RG/RMXLCR QF0ktw761kk58aPZLSzZIgSovpWqfJ1qV8pS16EKyk2zc1a2JItBSAfSRX03bTtt7Kqj oMSStksczzWEHfrGKds0UkfiWFCyuhKfMLGi/H4wB5d+7uqxuOizb3fdEglqJ/wK19SR rxOAzsfTBDOh9sUSMGVqs5UsKiQ40u1ml3WrnSiiwpNw+zvdhwlRAGq1wg9OBic+Kgyq LQcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=pDOiqbetTJuQCSug0oCLoaF9y/7eCOdvLwLU+Jbq1Eg=; b=S/Il0XGz4lWTcFyIJKM7pVKkIgsP1MpepLLk2ql+p+BmIAb8ASNyTORy5cjZInf3Rj /0ELR6eakpKgOzOohCpWq5j7wOrWuXIIoPyxWHwjjtwM6ZgXuXsRLnHt7VZbIi1/ea/R NqLm/H3fjYcy06Ah3nkvaCJT40PQkZIJ3O09AgQQjYHAmb1vYntjKOrYOhr7n59Liad3 ASMNpwFbs7KB7MCU6sMBS3J+xr9yt3lU19AD+lXfe1ffgyxN/Z+UTsm50tktoZxPS7/K 2jBm4Gu1PsQrZC5JM3e5tm8JscxEYFia6N1+bwCSGjuhXzfuEQ2LTA/bugXtej83i4DZ rINA== X-Gm-Message-State: AIkVDXJT5+HfWYHR/+jOZVPw35WvwJO1nwmO3IFdIca/VZMYhAQpqNeblmitg+FeCbEjgvWHK0uhVaBt9P8TFw== X-Received: by 10.194.205.34 with SMTP id ld2mr1842885wjc.211.1482285409767; Tue, 20 Dec 2016 17:56:49 -0800 (PST) MIME-Version: 1.0 Received: by 10.194.44.1 with HTTP; Tue, 20 Dec 2016 17:56:49 -0800 (PST) In-Reply-To: <1482281779.48539.41.camel@freebsd.org> References: <201612160144.uBG1ipjW016736@repo.freebsd.org> <49460793.UcUNovQMDa@ralph.baldwin.cx> <1482281779.48539.41.camel@freebsd.org> From: Adrian Chadd Date: Tue, 20 Dec 2016 17:56:49 -0800 Message-ID: Subject: Re: svn commit: r310138 - head/lib/libc/stdio To: Ian Lepore Cc: "Conrad E. Meyer" , Baptiste Daroussin , src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Dec 2016 01:56:53 -0000 Hi, Here's my reason for removal. Plenty of us are looking to be able to build bits of the BSD source tree as part of other non FreeBSD systems, especially if they're involved in bootstrapping. That means that it needs to be compilable by a non-FreeBSD-modified compiler. Ideally this means we'd stick to mostly POSIX options source code that we can compile with unmodified compilers, and we push non-standard stuff into otherly-named functions. If things are harder then we end up with even more reasons people resist migrating to FreeBSD and instead just continue to use Linux as their platform of choice. It already cross-builds and does most of what people want without getting in their way. This change is one of those which encourage making that effort harder, and I'd like to make sure we don't do that. Building bits of the FreeBSD tree on non-FreeBSD systems (even non-same-version-FreeBSD-system trees) is increasingly painful. THanks, -adrian From owner-svn-src-head@freebsd.org Wed Dec 21 02:04:40 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2D43DC89CBC; Wed, 21 Dec 2016 02:04:40 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-wj0-f194.google.com (mail-wj0-f194.google.com [209.85.210.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id BE3631E69; Wed, 21 Dec 2016 02:04:39 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-wj0-f194.google.com with SMTP id kp2so30128404wjc.0; Tue, 20 Dec 2016 18:04:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc; bh=O/hLiuIhE+wSQkD9EF4tUgFXJj5+oKh6wGiAOtqqnwQ=; b=W//6+FqQ8wOq68MwZJJrMBS8pa+uxALnSpU9+FOSXLrWTXC0DJsXfvRWw5q+HquWlG sdNOtNoHpV0hcqk/ltq0iROKtb4/Ad0A0Y73TAIiVvrZo6wghd0y6oJs1fL6K45jeGqL KpG1qklluxHfT/TXYOC0YrpNqEdMmKhf4Q00OopGGOGCWbZg2nFEageZRTbnWwuGO93L Tn7+qz6MDt2Ho5G1hZe+SFbC+3NGdjzczXcjVO3kBW7lJAOwGxchucV7HBfaCdz1ELmU dOSFBHAc2uMzD2cF/Xhs1arZQPBnOxq4E34K/yyWh4kmW0EfNchrb52VhtTdEgDdEM4x YRLA== X-Gm-Message-State: AIkVDXLZf2eT5WjAwuJOuE0JhMjAz3NVZ6Ho/93kXv7Wcv8AHCjcHsu54uNvQwJmvZze1w== X-Received: by 10.194.66.101 with SMTP id e5mr1877598wjt.172.1482285872328; Tue, 20 Dec 2016 18:04:32 -0800 (PST) Received: from mail-wj0-f169.google.com (mail-wj0-f169.google.com. [209.85.210.169]) by smtp.gmail.com with ESMTPSA id f134sm24767493wmf.19.2016.12.20.18.04.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Dec 2016 18:04:32 -0800 (PST) Received: by mail-wj0-f169.google.com with SMTP id v7so191332702wjy.2; Tue, 20 Dec 2016 18:04:32 -0800 (PST) X-Received: by 10.194.222.202 with SMTP id qo10mr1908171wjc.115.1482285871946; Tue, 20 Dec 2016 18:04:31 -0800 (PST) MIME-Version: 1.0 Reply-To: cem@freebsd.org Received: by 10.194.29.72 with HTTP; Tue, 20 Dec 2016 18:04:31 -0800 (PST) In-Reply-To: References: <201612160144.uBG1ipjW016736@repo.freebsd.org> <49460793.UcUNovQMDa@ralph.baldwin.cx> <1482281779.48539.41.camel@freebsd.org> From: Conrad Meyer Date: Tue, 20 Dec 2016 18:04:31 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r310138 - head/lib/libc/stdio To: Adrian Chadd Cc: src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Dec 2016 02:04:40 -0000 Hi Adrian, On Tue, Dec 20, 2016 at 5:56 PM, Adrian Chadd wrote: > Here's my reason for removal. > > Plenty of us are looking to be able to build bits of the BSD source > tree as part of other non FreeBSD systems, especially if they're > involved in bootstrapping. Understood, however: > That means that it needs to be compilable > by a non-FreeBSD-modified compiler. Ideally this means we'd stick to > mostly POSIX options source code that we can compile with unmodified > compilers, and we push non-standard stuff into otherly-named > functions. Yeah, this isn't actually a problem. printf("%b", foo) compiles fine with non-modified compilers. Best, Conrad From owner-svn-src-head@freebsd.org Wed Dec 21 02:12:25 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D695EC89E9C for ; Wed, 21 Dec 2016 02:12:25 +0000 (UTC) (envelope-from juli@clockworksquid.com) Received: from mail-it0-x22d.google.com (mail-it0-x22d.google.com [IPv6:2607:f8b0:4001:c0b::22d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9DF8D12D6 for ; Wed, 21 Dec 2016 02:12:25 +0000 (UTC) (envelope-from juli@clockworksquid.com) Received: by mail-it0-x22d.google.com with SMTP id c20so93821840itb.0 for ; Tue, 20 Dec 2016 18:12:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=clockworksquid.com; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=82K8fiaYkfmqSWDt1wPSfWUcR2qffhzv1V1BbUGAOc4=; b=ayjBEtO7VheY4uQBvQ+m/4/i/+PqKePBI0Cbntw4RMOQaf9ogZdt9mITA3iXscedav ShJpnWrRdeK6OVqkkN4oasnLy24SPYPZQ3vXeTBnYV1utu3S75o0uJ+4MQ6jOLvZngSr EvcO79Iwg4J0tu4Z8ef3OxHZzZkFERHtww/4Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=82K8fiaYkfmqSWDt1wPSfWUcR2qffhzv1V1BbUGAOc4=; b=lpc55FYkJDIQ8Ym5YTK6jq1T+ad96BaDfvXIyN33tw/hl77p6FdYcwHHYqa1OWBgzU BfhJosHSDhJFkuDKwUeSLFjZJA03v5fmTAG4QYg9w2gn0p1mSeFf2ZxaEctpIR1KCPSs cGhsNZ9951LSzCkGYP3lhFy0Y6gHL4ZiFdzUD9FfasrpJLbVVlcY0K41Vpiz2BTPBnQG GmylI5w5UGdqAXF67rqe4/gisD0VxTuadLmp0PV86pyfZz6oQiXzj2cgzorhJCYHn3ZU KtyhgqQsUQtwoEiW9Ygw3LO9kFtToppHobJlv94u55L89Lh5Rwnpd+U5AnySn/ltNrO4 o+sA== X-Gm-Message-State: AIkVDXJICGUBMdTkdT5uUWzY0PJOghhDjTxeBX+WZQYKpNWPZ2rhr5JkCOZOK+prwWa9ewqwoWo1B+r+m7AwCw== X-Received: by 10.36.249.203 with SMTP id l194mr5460477ith.19.1482286344921; Tue, 20 Dec 2016 18:12:24 -0800 (PST) MIME-Version: 1.0 Received: by 10.36.50.210 with HTTP; Tue, 20 Dec 2016 18:12:04 -0800 (PST) In-Reply-To: References: <201612160144.uBG1ipjW016736@repo.freebsd.org> <49460793.UcUNovQMDa@ralph.baldwin.cx> <1482281779.48539.41.camel@freebsd.org> From: Juli Mallett Date: Tue, 20 Dec 2016 18:12:04 -0800 Message-ID: Subject: Re: svn commit: r310138 - head/lib/libc/stdio To: Conrad Meyer Cc: Adrian Chadd , src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Dec 2016 02:12:25 -0000 On Tue, Dec 20, 2016 at 6:04 PM, Conrad Meyer wrote: > Hi Adrian, > > On Tue, Dec 20, 2016 at 5:56 PM, Adrian Chadd wrote: >> Here's my reason for removal. >> >> Plenty of us are looking to be able to build bits of the BSD source >> tree as part of other non FreeBSD systems, especially if they're >> involved in bootstrapping. > > Understood, however: > >> That means that it needs to be compilable >> by a non-FreeBSD-modified compiler. Ideally this means we'd stick to >> mostly POSIX options source code that we can compile with unmodified >> compilers, and we push non-standard stuff into otherly-named >> functions. > > Yeah, this isn't actually a problem. printf("%b", foo) compiles fine > with non-modified compilers. I want FreeBSD tools to avoid non-standard extensions to standard APIs where possible. Non-standard APIs are fine, because they're easy to provide one's own implementations along with portable software, but building in quirky behaviour to core POSIX/C/whatever interfaces invites pain. In this case, the cost-benefit ratio is all out of whack. Now, %b is unusual enough that I don't have to worry that, say, a bootstrap tool will use it, but it's also unusual enough that the benefit here is elusive. I would love to see this reverted and snprintb instead. From owner-svn-src-head@freebsd.org Wed Dec 21 02:14:37 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1EF6CC89F28 for ; Wed, 21 Dec 2016 02:14:37 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from nm6.bullet.mail.ne1.yahoo.com (nm6.bullet.mail.ne1.yahoo.com [98.138.90.69]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DBB0714E6 for ; Wed, 21 Dec 2016 02:14:36 +0000 (UTC) (envelope-from pfg@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1482285713; bh=XHFRePtjVFdNJBpvFWzaLdcnqTYu3o0RYuRSXI78ylE=; h=Subject:To:References:Cc:From:Date:In-Reply-To:From:Subject; b=ZJPvvxxG+qse7PwmsdwPVgyGG2NAm1v5DxkPhlR89PDl4QvG3IIGCx8tBvD54zpOC6cYVXJpI1iqHS5/SIUswUyyruOxKEgQCyQtOwyKuBR1cNT+5Htp86CuhQayBWfZtT3JrAn26K9RM6Qiz46sFhsnrJQ7qSPzlM/LMSWrbUmIbBqpKR3fmkFZOHwUIUeTi0PtXvCKAIH3lbbsNqzk8j5AOInT+OGW7tXVjbM4TIpevVSYcDQCaWHnclbJ0SOu8ex5sdnLm28k8sm1Ub5r5GMAjhAmWqNiRPrR+izC7FCTK74pbDZY4x4kxbn7CBSD66Fboqm9mDPySUGtQU+Bsw== Received: from [98.138.100.116] by nm6.bullet.mail.ne1.yahoo.com with NNFMP; 21 Dec 2016 02:01:53 -0000 Received: from [98.138.84.47] by tm107.bullet.mail.ne1.yahoo.com with NNFMP; 21 Dec 2016 02:01:53 -0000 Received: from [127.0.0.1] by smtp115.mail.ne1.yahoo.com with NNFMP; 21 Dec 2016 02:01:53 -0000 X-Yahoo-Newman-Id: 291970.15957.bm@smtp115.mail.ne1.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: SYqiOeIVM1njR4IiSkSk.oyMjR9sGeiE1.lmc_3Sd.yJlBa ox766RKOBfJ5AYCkEbQWNEEHcLc5NZ6Nt8xztd5yOsbIT9CZMp5VDZ4KNTMn VP8_VyilDrVwubaZU6tdO11n9RUeexSxwV135Za8C_k6v9vodWHqKicuJ26P ljvk1Ifw5CSszE2u0Nahb2g38hnMxKB3rYq_8ZfV5XXJa_w8Xdoi2ae.Cuao lXACCq1xcdM0PkGpv8Y2IqSDZxTpJtrlfcTD5_zHk4f0SI6GmA24H4jRtcM5 G5I_H74wHOv4.fvodpyKgzHGJJrX4HCeN015kFpad_xqeyhHBPXuSOiiwDyp yLW0LeFuiwV3t4t2fJU4SbrRGFzbahOWIwK.P1aLVF3dZEKKB5nz13p9N_rK glsJERonkNRXgrdANATwZUFmYU_nFyPqCIJBVIDWTlTMWeX.ZnV_JKJUsYEt fFcbaJv8OCaej5My.hurGoWN_0_.zfAw0c2dbeA0zgkVoMuRUBYstsD9Jziw ZivCT7WOTszfduRTOpTkaIcTkc5SFHQOG8BmVoaDoJ8QUENc- X-Yahoo-SMTP: xcjD0guswBAZaPPIbxpWwLcp9Unf Subject: Re: svn commit: r310138 - head/lib/libc/stdio To: cem@freebsd.org, Adrian Chadd References: <201612160144.uBG1ipjW016736@repo.freebsd.org> <49460793.UcUNovQMDa@ralph.baldwin.cx> Cc: Baptiste Daroussin , src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" From: Pedro Giffuni Message-ID: <0f40f228-76fe-1073-ad23-d4b83a1705c8@FreeBSD.org> Date: Tue, 20 Dec 2016 21:03:16 -0500 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Dec 2016 02:14:37 -0000 On 20/12/2016 18:50, Conrad Meyer wrote: > I didn't get the same conclusion from the thread — I haven't seen a > persuasive argument for removal. > > Best, > Conrad It's not standard or even a GNU extension (which we sometimes carry for compatibility). We don't want to encourage it's use either so it doesn't really belong in libc. +1 for removal. Pedro. From owner-svn-src-head@freebsd.org Wed Dec 21 03:09:08 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B64EDC89EA0; Wed, 21 Dec 2016 03:09:08 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 7744B1D43; Wed, 21 Dec 2016 03:09:08 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBL397hl013067; Wed, 21 Dec 2016 03:09:07 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBL3970F013066; Wed, 21 Dec 2016 03:09:07 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201612210309.uBL3970F013066@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 21 Dec 2016 03:09:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310347 - head/sys/dev/hyperv/storvsc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Dec 2016 03:09:08 -0000 Author: sephe Date: Wed Dec 21 03:09:07 2016 New Revision: 310347 URL: https://svnweb.freebsd.org/changeset/base/310347 Log: hyperv/storvsc: The max channel in PDU actually means the max sub-chans. Use proper name for local variables. PDU fields' name was not changed yet. While I'm here, make # of usable channels tunable. This eases further testing. MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8851 Modified: head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Modified: head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c ============================================================================== --- head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Wed Dec 21 01:48:54 2016 (r310346) +++ head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Wed Dec 21 03:09:07 2016 (r310347) @@ -147,6 +147,10 @@ static u_int hv_storvsc_max_io = 512; SYSCTL_UINT(_hw_storvsc, OID_AUTO, max_io, CTLFLAG_RDTUN, &hv_storvsc_max_io, 0, "Hyper-V storage max io limit"); +static int hv_storvsc_chan_cnt = 0; +SYSCTL_INT(_hw_storvsc, OID_AUTO, chan_cnt, CTLFLAG_RDTUN, + &hv_storvsc_chan_cnt, 0, "# of channels to use"); + #define STORVSC_MAX_IO \ vmbus_chan_prplist_nelem(hv_storvsc_ringbuffer_size, \ STORVSC_DATA_SEGCNT_MAX, VSTOR_PKT_SIZE) @@ -385,16 +389,16 @@ storvsc_subchan_attach(struct storvsc_so * @param max_chans the max channels supported by vmbus */ static void -storvsc_send_multichannel_request(struct storvsc_softc *sc, int max_chans) +storvsc_send_multichannel_request(struct storvsc_softc *sc, int max_subch) { struct vmbus_channel **subchan; struct hv_storvsc_request *request; struct vstor_packet *vstor_packet; - int request_channels_cnt = 0; + int request_subch; int ret, i; - /* get multichannels count that need to create */ - request_channels_cnt = MIN(max_chans, mp_ncpus); + /* get sub-channel count that need to create */ + request_subch = MIN(max_subch, mp_ncpus - 1); request = &sc->hs_init_req; @@ -407,7 +411,7 @@ storvsc_send_multichannel_request(struct vstor_packet->operation = VSTOR_OPERATION_CREATE_MULTI_CHANNELS; vstor_packet->flags = REQUEST_COMPLETION_FLAG; - vstor_packet->u.multi_channels_cnt = request_channels_cnt; + vstor_packet->u.multi_channels_cnt = request_subch; ret = vmbus_chan_send(sc->hs_chan, VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, @@ -424,17 +428,17 @@ storvsc_send_multichannel_request(struct } /* Update channel count */ - sc->hs_nchan = request_channels_cnt + 1; + sc->hs_nchan = request_subch + 1; /* Wait for sub-channels setup to complete. */ - subchan = vmbus_subchan_get(sc->hs_chan, request_channels_cnt); + subchan = vmbus_subchan_get(sc->hs_chan, request_subch); /* Attach the sub-channels. */ - for (i = 0; i < request_channels_cnt; ++i) + for (i = 0; i < request_subch; ++i) storvsc_subchan_attach(sc, subchan[i]); /* Release the sub-channels. */ - vmbus_subchan_rel(subchan, request_channels_cnt); + vmbus_subchan_rel(subchan, request_subch); if (bootverbose) printf("Storvsc create multi-channel success!\n"); @@ -452,11 +456,11 @@ hv_storvsc_channel_init(struct storvsc_s int ret = 0, i; struct hv_storvsc_request *request; struct vstor_packet *vstor_packet; - uint16_t max_chans = 0; - boolean_t support_multichannel = FALSE; + uint16_t max_subch; + boolean_t support_multichannel; uint32_t version; - max_chans = 0; + max_subch = 0; support_multichannel = FALSE; request = &sc->hs_init_req; @@ -550,14 +554,21 @@ hv_storvsc_channel_init(struct storvsc_s goto cleanup; } + max_subch = vstor_packet->u.chan_props.max_channel_cnt; + if (hv_storvsc_chan_cnt > 0 && hv_storvsc_chan_cnt < (max_subch + 1)) + max_subch = hv_storvsc_chan_cnt - 1; + /* multi-channels feature is supported by WIN8 and above version */ - max_chans = vstor_packet->u.chan_props.max_channel_cnt; version = VMBUS_GET_VERSION(device_get_parent(sc->hs_dev), sc->hs_dev); if (version != VMBUS_VERSION_WIN7 && version != VMBUS_VERSION_WS2008 && (vstor_packet->u.chan_props.flags & HV_STORAGE_SUPPORTS_MULTI_CHANNEL)) { support_multichannel = TRUE; } + if (bootverbose) { + device_printf(sc->hs_dev, "max chans %d%s\n", max_subch + 1, + support_multichannel ? ", multi-chan capable" : ""); + } memset(vstor_packet, 0, sizeof(struct vstor_packet)); vstor_packet->operation = VSTOR_OPERATION_ENDINITIALIZATION; @@ -581,8 +592,8 @@ hv_storvsc_channel_init(struct storvsc_s * If multi-channel is supported, send multichannel create * request to host. */ - if (support_multichannel) - storvsc_send_multichannel_request(sc, max_chans); + if (support_multichannel && max_subch > 0) + storvsc_send_multichannel_request(sc, max_subch); cleanup: sema_destroy(&request->synch_sema); return (ret); From owner-svn-src-head@freebsd.org Wed Dec 21 03:23:37 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 09F56C8A266; Wed, 21 Dec 2016 03:23:37 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 BF12F160B; Wed, 21 Dec 2016 03:23:36 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBL3NZRn020971; Wed, 21 Dec 2016 03:23:35 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBL3NZeJ020969; Wed, 21 Dec 2016 03:23:35 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201612210323.uBL3NZeJ020969@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 21 Dec 2016 03:23:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310348 - head/sys/dev/hyperv/vmbus X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Dec 2016 03:23:37 -0000 Author: sephe Date: Wed Dec 21 03:23:35 2016 New Revision: 310348 URL: https://svnweb.freebsd.org/changeset/base/310348 Log: hyperv: Unbreak EARLY_AP_STARUP Hyper-V bootstrap by using intrhook Properly working pause and friends are required. MFC after: 3 days Sponsored by: Microsoft Modified: head/sys/dev/hyperv/vmbus/vmbus.c head/sys/dev/hyperv/vmbus/vmbus_var.h Modified: head/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- head/sys/dev/hyperv/vmbus/vmbus.c Wed Dec 21 03:09:07 2016 (r310347) +++ head/sys/dev/hyperv/vmbus/vmbus.c Wed Dec 21 03:23:35 2016 (r310348) @@ -99,6 +99,9 @@ static uint32_t vmbus_get_vcpu_id_meth device_t dev, int cpu); static struct taskqueue *vmbus_get_eventtq_method(device_t, device_t, int); +#ifdef EARLY_AP_STARTUP +static void vmbus_intrhook(void *); +#endif static int vmbus_init(struct vmbus_softc *); static int vmbus_connect(struct vmbus_softc *, uint32_t); @@ -1402,6 +1405,21 @@ vmbus_event_proc_dummy(struct vmbus_soft { } +#ifdef EARLY_AP_STARTUP + +static void +vmbus_intrhook(void *xsc) +{ + struct vmbus_softc *sc = xsc; + + if (bootverbose) + device_printf(sc->vmbus_dev, "intrhook\n"); + vmbus_doattach(sc); + config_intrhook_disestablish(&sc->vmbus_intrhook); +} + +#endif /* EARLY_AP_STARTUP */ + static int vmbus_attach(device_t dev) { @@ -1416,7 +1434,14 @@ vmbus_attach(device_t dev) */ vmbus_sc->vmbus_event_proc = vmbus_event_proc_dummy; -#ifndef EARLY_AP_STARTUP +#ifdef EARLY_AP_STARTUP + /* + * Defer the real attach until the pause(9) works as expected. + */ + vmbus_sc->vmbus_intrhook.ich_func = vmbus_intrhook; + vmbus_sc->vmbus_intrhook.ich_arg = vmbus_sc; + config_intrhook_establish(&vmbus_sc->vmbus_intrhook); +#else /* !EARLY_AP_STARTUP */ /* * If the system has already booted and thread * scheduling is possible indicated by the global @@ -1424,8 +1449,8 @@ vmbus_attach(device_t dev) * initialization directly. */ if (!cold) -#endif vmbus_doattach(vmbus_sc); +#endif /* EARLY_AP_STARTUP */ return (0); } Modified: head/sys/dev/hyperv/vmbus/vmbus_var.h ============================================================================== --- head/sys/dev/hyperv/vmbus/vmbus_var.h Wed Dec 21 03:09:07 2016 (r310347) +++ head/sys/dev/hyperv/vmbus/vmbus_var.h Wed Dec 21 03:23:35 2016 (r310348) @@ -30,6 +30,7 @@ #define _VMBUS_VAR_H_ #include +#include #include #include @@ -128,6 +129,8 @@ struct vmbus_softc { struct mtx vmbus_chan_lock; TAILQ_HEAD(, vmbus_channel) vmbus_chans; + struct intr_config_hook vmbus_intrhook; + #ifdef NEW_PCIB /* The list of usable MMIO ranges for PCIe pass-through */ struct pcib_host_resources vmbus_mmio_res; From owner-svn-src-head@freebsd.org Wed Dec 21 05:46:00 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C9755C8A29D; Wed, 21 Dec 2016 05:46:00 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 798BC1FC0; Wed, 21 Dec 2016 05:46:00 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBL5jx9F077422; Wed, 21 Dec 2016 05:45:59 GMT (envelope-from hrs@FreeBSD.org) Received: (from hrs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBL5jxfe077420; Wed, 21 Dec 2016 05:45:59 GMT (envelope-from hrs@FreeBSD.org) Message-Id: <201612210545.uBL5jxfe077420@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hrs set sender to hrs@FreeBSD.org using -f From: Hiroki Sato Date: Wed, 21 Dec 2016 05:45:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310349 - head/usr.sbin/syslogd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Dec 2016 05:46:00 -0000 Author: hrs Date: Wed Dec 21 05:45:59 2016 New Revision: 310349 URL: https://svnweb.freebsd.org/changeset/base/310349 Log: - Use fnmatch(3) for domanname matching of -a options. - Document the patten matching. - Document -S flag in SYNOPSIS. Modified: head/usr.sbin/syslogd/syslogd.8 head/usr.sbin/syslogd/syslogd.c Modified: head/usr.sbin/syslogd/syslogd.8 ============================================================================== --- head/usr.sbin/syslogd/syslogd.8 Wed Dec 21 03:23:35 2016 (r310348) +++ head/usr.sbin/syslogd/syslogd.8 Wed Dec 21 05:45:59 2016 (r310349) @@ -28,7 +28,7 @@ .\" @(#)syslogd.8 8.1 (Berkeley) 6/6/93 .\" $FreeBSD$ .\" -.Dd June 16, 2015 +.Dd December 21, 2016 .Dt SYSLOGD 8 .Os .Sh NAME @@ -44,6 +44,7 @@ .Op Fl m Ar mark_interval .Op Fl P Ar pid_file .Op Fl p Ar log_socket +.Op Fl S Ar logpriv_socket .Sh DESCRIPTION The .Nm @@ -154,16 +155,9 @@ for the sender address. The meaning of .Ar service is as explained above. -.It Xo -.Sm off -.No * Ar domainname Op \&: Ar service -.Sm on -.Xc -Same as before, except that any source host whose name -.Em ends -in .Ar domainname -will get permission. +can contain special characters of a shell-style pattern such as +.Ql Li \&* . .El .Pp The Modified: head/usr.sbin/syslogd/syslogd.c ============================================================================== --- head/usr.sbin/syslogd/syslogd.c Wed Dec 21 03:23:35 2016 (r310348) +++ head/usr.sbin/syslogd/syslogd.c Wed Dec 21 05:45:59 2016 (r310349) @@ -98,6 +98,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -2476,8 +2477,7 @@ static int validate(struct sockaddr *sa, const char *hname) { int i; - size_t l1, l2; - char *cp, name[NI_MAXHOST], ip[NI_MAXHOST], port[NI_MAXSERV]; + char name[NI_MAXHOST], ip[NI_MAXHOST], port[NI_MAXSERV]; struct allowedpeer *ap; struct sockaddr_in *sin4, *a4p = NULL, *m4p = NULL; #ifdef INET6 @@ -2558,23 +2558,11 @@ validate(struct sockaddr *sa, const char else continue; } else { - cp = ap->a_name; - l1 = strlen(name); - if (*cp == '*') { - /* allow wildmatch */ - cp++; - l2 = strlen(cp); - if (l2 > l1 || memcmp(cp, &name[l1 - l2], l2) != 0) { - dprintf("rejected in rule %d due to name mismatch.\n", i); - continue; - } - } else { - /* exact match */ - l2 = strlen(cp); - if (l2 != l1 || memcmp(cp, name, l1) != 0) { - dprintf("rejected in rule %d due to name mismatch.\n", i); - continue; - } + if (fnmatch(ap->a_name, name, FNM_NOESCAPE) == + FNM_NOMATCH) { + dprintf("rejected in rule %d due to name " + "mismatch.\n", i); + continue; } } dprintf("accepted in rule %d.\n", i); From owner-svn-src-head@freebsd.org Wed Dec 21 06:40:30 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id ADA76C8A033; Wed, 21 Dec 2016 06:40:30 +0000 (UTC) (envelope-from julian@freebsd.org) Received: from vps1.elischer.org (vps1.elischer.org [204.109.63.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "vps1.elischer.org", Issuer "CA Cert Signing Authority" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 8BE5D1964; Wed, 21 Dec 2016 06:40:30 +0000 (UTC) (envelope-from julian@freebsd.org) Received: from Julian-MBP3.local (ppp121-45-237-203.lns20.per1.internode.on.net [121.45.237.203]) (authenticated bits=0) by vps1.elischer.org (8.15.2/8.15.2) with ESMTPSA id uBL6eETb081741 (version=TLSv1.2 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Tue, 20 Dec 2016 22:40:19 -0800 (PST) (envelope-from julian@freebsd.org) Subject: Re: svn commit: r310336 - head/sys/kern To: John Baldwin , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201612201944.uBKJiiMg034231@repo.freebsd.org> From: Julian Elischer Message-ID: Date: Wed, 21 Dec 2016 14:40:09 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <201612201944.uBKJiiMg034231@repo.freebsd.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Dec 2016 06:40:30 -0000 On 21/12/2016 3:44 AM, John Baldwin wrote: > Author: jhb > Date: Tue Dec 20 19:44:44 2016 > New Revision: 310336 > URL: https://svnweb.freebsd.org/changeset/base/310336 > > Log: > Don't spin in pause() during early boot for kthreads other than thread0. > > pause() uses a spin loop to simulate a sleep during early boot. However, > we only need this for thread0 to get far enough in the boot process to > enable timers (at which point pause() can sleep). For other kthreads, > sleeping in pause() is ok as the callout will be scheduled and will > eventually fire once thread0 initializes timers. maybe we just need to depend on a variable "have_timers" that is independent of the cold/hot/whatever settings. first code to enable a timer sets it. > > Tested by: Steven Kargl > Sleuthing by: markj > MFC after: 1 week > Sponsored by: Netflix > > Modified: > head/sys/kern/kern_synch.c > > Modified: head/sys/kern/kern_synch.c > ============================================================================== > --- head/sys/kern/kern_synch.c Tue Dec 20 19:30:21 2016 (r310335) > +++ head/sys/kern/kern_synch.c Tue Dec 20 19:44:44 2016 (r310336) > @@ -321,7 +321,8 @@ pause_sbt(const char *wmesg, sbintime_t > if (sbt == 0) > sbt = tick_sbt; > > - if (cold || kdb_active || SCHEDULER_STOPPED()) { > + if ((cold && curthread == &thread0) || kdb_active || > + SCHEDULER_STOPPED()) { > /* > * We delay one second at a time to avoid overflowing the > * system specific DELAY() function(s): > > From owner-svn-src-head@freebsd.org Wed Dec 21 06:42:31 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 32283C8A1D6; Wed, 21 Dec 2016 06:42:31 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 E81601D71; Wed, 21 Dec 2016 06:42:30 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBL6gUEs001280; Wed, 21 Dec 2016 06:42:30 GMT (envelope-from hrs@FreeBSD.org) Received: (from hrs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBL6gUx6001279; Wed, 21 Dec 2016 06:42:30 GMT (envelope-from hrs@FreeBSD.org) Message-Id: <201612210642.uBL6gUx6001279@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hrs set sender to hrs@FreeBSD.org using -f From: Hiroki Sato Date: Wed, 21 Dec 2016 06:42:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310350 - head/usr.sbin/syslogd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Dec 2016 06:42:31 -0000 Author: hrs Date: Wed Dec 21 06:42:30 2016 New Revision: 310350 URL: https://svnweb.freebsd.org/changeset/base/310350 Log: - Add fklog into struct socklist. Files and local/remote sockets are now processed in struct socklist in a consistent manner. - Add helper functions to add a new entry of struct socklist, filed, or peer. - Use the same routine for -l, -p, and -S. - Close /dev/klog when read(2) failed. Modified: head/usr.sbin/syslogd/syslogd.c Modified: head/usr.sbin/syslogd/syslogd.c ============================================================================== --- head/usr.sbin/syslogd/syslogd.c Wed Dec 21 05:45:59 2016 (r310349) +++ head/usr.sbin/syslogd/syslogd.c Wed Dec 21 06:42:30 2016 (r310350) @@ -144,29 +144,17 @@ struct peer { mode_t pe_mode; STAILQ_ENTRY(peer) next; }; +static STAILQ_HEAD(, peer) pqueue = STAILQ_HEAD_INITIALIZER(pqueue); + struct socklist { struct sockaddr_storage sl_ss; int sl_socket; struct peer *sl_peer; + int (*sl_recv)(struct socklist *); STAILQ_ENTRY(socklist) next; }; static STAILQ_HEAD(, socklist) shead = STAILQ_HEAD_INITIALIZER(shead); -static struct peer funix_secure = { - .pe_name = _PATH_LOG_PRIV, - .pe_mode = S_IRUSR | S_IWUSR, - .next = {NULL}, -}; -static struct peer funix_default = { - .pe_name = _PATH_LOG, - .pe_mode = DEFFILEMODE, - .next = {&funix_secure}, -}; -static STAILQ_HEAD(, peer) pqueue = { - &funix_default, - &funix_secure.next.stqe_next, -}; - /* * Flags to logmsg(). */ @@ -306,7 +294,6 @@ static int Foreground = 0; /* Run in for static int resolve = 1; /* resolve hostname */ static char LocalHostName[MAXHOSTNAMELEN]; /* our hostname */ static const char *LocalDomain; /* our local domain name */ -static int fklog = -1; /* /dev/klog */ static int Initialized; /* set when we have initialized ourselves */ static int MarkInterval = 20 * 60; /* interval between marks in seconds */ static int MarkSeq; /* mark sequence number */ @@ -337,8 +324,10 @@ static struct pidfh *pfh; static volatile sig_atomic_t MarkSet, WantDie; static int allowaddr(char *); -static void cfline(const char *, struct filed *, - const char *, const char *); +static int addfile(struct filed *); +static int addpeer(struct peer *); +static int addsock(struct sockaddr *, socklen_t, struct socklist *); +static struct filed *cfline(const char *, const char *, const char *); static const char *cvthname(struct sockaddr *); static void deadq_enter(pid_t, const char *); static int deadq_remove(pid_t); @@ -354,11 +343,12 @@ static void logmsg(int, const char *, co static void log_deadchild(pid_t, int, const char *); static void markit(void); static int socksetup(struct peer *); +static int socklist_recv_file(struct socklist *); +static int socklist_recv_sock(struct socklist *); static int skip_message(const char *, const char *, int); static void printline(const char *, char *, int); static void printsys(char *); static int p_open(const char *, pid_t *); -static void readklog(void); static void reapchild(int); static const char *ttymsg_check(struct iovec *, int, char *, int); static void usage(void); @@ -381,21 +371,61 @@ close_filed(struct filed *f) f->f_type = F_UNUSED; } +static int +addfile(struct filed *f0) +{ + struct filed *f; + + f = calloc(1, sizeof(*f)); + if (f == NULL) + err(1, "malloc failed"); + *f = *f0; + STAILQ_INSERT_TAIL(&fhead, f, next); + + return (0); +} + +static int +addpeer(struct peer *pe0) +{ + struct peer *pe; + + pe = calloc(1, sizeof(*pe)); + if (pe == NULL) + err(1, "malloc failed"); + *pe = *pe0; + STAILQ_INSERT_TAIL(&pqueue, pe, next); + + return (0); +} + +static int +addsock(struct sockaddr *sa, socklen_t sa_len, struct socklist *sl0) +{ + struct socklist *sl; + + sl = calloc(1, sizeof(*sl)); + if (sl == NULL) + err(1, "malloc failed"); + *sl = *sl0; + if (sa != NULL && sa_len > 0) + memcpy(&sl->sl_ss, sa, sa_len); + STAILQ_INSERT_TAIL(&shead, sl, next); + + return (0); +} + int main(int argc, char *argv[]) { - int ch, i, fdsrmax = 0, bflag = 0; - struct sockaddr_storage ss; + int ch, i, s, fdsrmax = 0, bflag = 0, pflag = 0, Sflag = 0; fd_set *fdsr = NULL; - char line[MAXLINE + 1]; - const char *hname; struct timeval tv, *tvp; struct sigaction sact; struct peer *pe; struct socklist *sl; sigset_t mask; pid_t ppid = 1, spid; - socklen_t sslen; char *p; if (madvise(NULL, 0, MADV_PROTECT) != 0) @@ -425,21 +455,22 @@ main(int argc, char *argv[]) usage(); break; case 'b': - if ((pe = calloc(1, sizeof(*pe))) == NULL) - err(1, "malloc failed"); + bflag = 1; if ((p = strchr(optarg, ':')) == NULL) { /* A hostname or filename only. */ - pe->pe_name = optarg; - pe->pe_serv = "syslog"; + addpeer(&(struct peer){ + .pe_name = optarg, + .pe_serv = "syslog" + }); } else { /* The case of "name:service". */ *p++ = '\0'; - pe->pe_serv = p; - pe->pe_name = (strlen(optarg) == 0) ? - NULL : optarg; + addpeer(&(struct peer){ + .pe_serv = p, + .pe_name = (strlen(optarg) == 0) ? + NULL : optarg, + }); } - bflag = 1; - STAILQ_INSERT_TAIL(&pqueue, pe, next); break; case 'c': no_compress++; @@ -460,15 +491,25 @@ main(int argc, char *argv[]) KeepKernFac = 1; break; case 'l': + case 'p': + case 'S': { long perml; mode_t mode; char *name, *ep; - if (optarg[0] == '/') { + if (ch == 'l') mode = DEFFILEMODE; + else if (ch == 'p') { + mode = DEFFILEMODE; + pflag = 1; + } else if (ch == 'S') { + mode = S_IRUSR | S_IWUSR; + Sflag = 1; + } + if (optarg[0] == '/') name = optarg; - } else if ((name = strchr(optarg, ':')) != NULL) { + else if ((name = strchr(optarg, ':')) != NULL) { *name++ = '\0'; if (name[0] != '/') errx(1, "socket name must be absolute " @@ -483,12 +524,13 @@ main(int argc, char *argv[]) } else errx(1, "invalid mode %s, exiting", optarg); - } - if ((pe = calloc(1, sizeof(*pe))) == NULL) - err(1, "malloc failed"); - pe->pe_name = name; - pe->pe_mode = mode; - STAILQ_INSERT_TAIL(&pqueue, pe, next); + } else + errx(1, "invalid filename %s, exiting", + optarg); + addpeer(&(struct peer){ + .pe_name = name, + .pe_mode = mode + }); break; } case 'm': /* mark interval */ @@ -504,18 +546,12 @@ main(int argc, char *argv[]) case 'o': use_bootfile = 1; break; - case 'p': /* path */ - funix_default.pe_name = optarg; - break; case 'P': /* path for alt. PID */ PidFile = optarg; break; case 's': /* no network mode */ SecureMode++; break; - case 'S': /* path for privileged originator */ - funix_secure.pe_name = optarg; - break; case 'T': RemoteAddDate = 1; break; @@ -531,15 +567,33 @@ main(int argc, char *argv[]) if ((argc -= optind) != 0) usage(); - if (bflag == 0) { - pe = calloc(1, sizeof(*pe)); - if (pe == NULL) - err(1, "malloc failed"); - *pe = (struct peer) { + /* Listen by default: /dev/klog. */ + s = open(_PATH_KLOG, O_RDONLY|O_NONBLOCK, 0); + if (s < 0) { + dprintf("can't open %s (%d)\n", _PATH_KLOG, errno); + } else { + addsock(NULL, 0, &(struct socklist){ + .sl_socket = s, + .sl_recv = socklist_recv_file, + }); + } + /* Listen by default: *:514 if no -b flag. */ + if (bflag == 0) + addpeer(&(struct peer){ .pe_serv = "syslog" - }; - STAILQ_INSERT_TAIL(&pqueue, pe, next); - } + }); + /* Listen by default: /var/run/log if no -p flag. */ + if (pflag == 0) + addpeer(&(struct peer){ + .pe_name = _PATH_LOG, + .pe_mode = DEFFILEMODE, + }); + /* Listen by default: /var/run/logpriv if no -S flag. */ + if (Sflag == 0) + addpeer(&(struct peer){ + .pe_name = _PATH_LOG_PRIV, + .pe_mode = S_IRUSR | S_IWUSR, + }); STAILQ_FOREACH(pe, &pqueue, next) socksetup(pe); @@ -585,9 +639,6 @@ main(int argc, char *argv[]) TAILQ_INIT(&deadq_head); - if ((fklog = open(_PATH_KLOG, O_RDONLY|O_NONBLOCK, 0)) < 0) - dprintf("can't open %s (%d)\n", _PATH_KLOG, errno); - /* tuck my process id away */ pidfile_write(pfh); @@ -605,13 +656,10 @@ main(int argc, char *argv[]) tvp = &tv; tv.tv_sec = tv.tv_usec = 0; - if (fklog != -1 && fklog > fdsrmax) - fdsrmax = fklog; STAILQ_FOREACH(sl, &shead, next) { if (sl->sl_socket > fdsrmax) fdsrmax = sl->sl_socket; } - fdsr = (fd_set *)calloc(howmany(fdsrmax+1, NFDBITS), sizeof(fd_mask)); if (fdsr == NULL) @@ -626,8 +674,6 @@ main(int argc, char *argv[]) bzero(fdsr, howmany(fdsrmax+1, NFDBITS) * sizeof(fd_mask)); - if (fklog != -1) - FD_SET(fklog, fdsr); STAILQ_FOREACH(sl, &shead, next) { if (sl->sl_socket != -1) FD_SET(sl->sl_socket, fdsr); @@ -649,49 +695,55 @@ main(int argc, char *argv[]) logerror("select"); continue; } - if (fklog != -1 && FD_ISSET(fklog, fdsr)) - readklog(); STAILQ_FOREACH(sl, &shead, next) { - int date, len; - - if (FD_ISSET(sl->sl_socket, fdsr)) { - sslen = sizeof(ss); - dprintf("sslen(1) = %d\n", sslen); - len = recvfrom(sl->sl_socket, line, - sizeof(line) - 1, 0, - sstosa(&ss), &sslen); - dprintf("sslen(2) = %d\n", sslen); - if (len == 0) - continue; - if (len < 0) { - if (errno != EINTR) - logerror("recvfrom"); - continue; - } - /* Received valid data. */ - line[len] = '\0'; - if (sl->sl_ss.ss_family == AF_LOCAL) { - hname = LocalHostName; - date = 0; - } else { - hname = cvthname(sstosa(&ss)); - unmapped(sstosa(&ss)); - if (validate(sstosa(&ss), hname) == 0) - hname = NULL; - date = RemoteAddDate ? ADDDATE : 0; - } - if (hname != NULL) - printline(hname, line, date); - else - dprintf("Invalid msg from " - "%s was ignored.", hname); - } + if (FD_ISSET(sl->sl_socket, fdsr)) + (*sl->sl_recv)(sl); } } if (fdsr) free(fdsr); } +static int +socklist_recv_sock(struct socklist *sl) +{ + struct sockaddr_storage ss; + struct sockaddr *sa = (struct sockaddr *)&ss; + socklen_t sslen; + const char *hname; + char line[MAXLINE + 1]; + int date, len; + + sslen = sizeof(ss); + len = recvfrom(sl->sl_socket, line, sizeof(line) - 1, 0, sa, &sslen); + dprintf("received sa_len = %d\n", sslen); + if (len == 0) + return (-1); + if (len < 0) { + if (errno != EINTR) + logerror("recvfrom"); + return (-1); + } + /* Received valid data. */ + line[len] = '\0'; + if (sl->sl_ss.ss_family == AF_LOCAL) { + hname = LocalHostName; + date = 0; + } else { + hname = cvthname(sa); + unmapped(sa); + if (validate(sa, hname) == 0) + hname = NULL; + date = RemoteAddDate ? ADDDATE : 0; + } + if (hname != NULL) + printline(hname, line, date); + else + dprintf("Invalid msg from %s was ignored.", hname); + + return (0); +} + static void unmapped(struct sockaddr *sa) { @@ -792,21 +844,22 @@ printline(const char *hname, char *msg, /* * Read /dev/klog while data are available, split into lines. */ -static void -readklog(void) +static int +socklist_recv_file(struct socklist *sl) { char *p, *q, line[MAXLINE + 1]; int len, i; len = 0; for (;;) { - i = read(fklog, line + len, MAXLINE - 1 - len); + i = read(sl->sl_socket, line + len, MAXLINE - 1 - len); if (i > 0) { line[i + len] = '\0'; } else { if (i < 0 && errno != EINTR && errno != EAGAIN) { logerror("klog"); - fklog = -1; + close(sl->sl_socket); + sl->sl_socket = -1; } break; } @@ -825,6 +878,8 @@ readklog(void) } if (len > 0) printsys(line); + + return (len); } /* @@ -1225,7 +1280,9 @@ fprintlog(struct filed *f, int flags, co struct socklist *sl; STAILQ_FOREACH(sl, &shead, next) { - if (sl->sl_ss.ss_family == AF_LOCAL) + if (sl->sl_ss.ss_family == AF_LOCAL || + sl->sl_ss.ss_family == AF_UNSPEC || + sl->sl_socket < 0) continue; lsent = sendto(sl->sl_socket, line, l, 0, r->ai_addr, r->ai_addrlen); @@ -1591,7 +1648,6 @@ readconfigfile(FILE *cf, int allow_inclu /* * Foreach line in the conf table, open that file. */ - f = NULL; include_len = sizeof(include_str) -1; (void)strlcpy(host, "*", sizeof(host)); (void)strlcpy(prog, "*", sizeof(prog)); @@ -1693,13 +1749,9 @@ readconfigfile(FILE *cf, int allow_inclu } for (i = strlen(cline) - 1; i >= 0 && isspace(cline[i]); i--) cline[i] = '\0'; - f = (struct filed *)calloc(1, sizeof(*f)); - if (f == NULL) { - logerror("calloc"); - exit(1); - } - STAILQ_INSERT_TAIL(&fhead, f, next); - cfline(cline, f, prog, host); + f = cfline(cline, prog, host); + if (f != NULL) + addfile(f); } } @@ -1789,23 +1841,14 @@ init(int signo) /* open the configuration file */ if ((cf = fopen(ConfFile, "r")) == NULL) { dprintf("cannot open %s\n", ConfFile); - f = calloc(1, sizeof(*f)); - if (f == NULL) { - logerror("calloc"); - exit(1); - } - cfline("*.ERR\t/dev/console", f, "*", "*"); - STAILQ_INSERT_TAIL(&fhead, f, next); - - f = calloc(1, sizeof(*f)); - if (f == NULL) { - logerror("calloc"); - exit(1); - } - cfline("*.PANIC\t*", f, "*", "*"); - STAILQ_INSERT_TAIL(&fhead, f, next); - + f = cfline("*.ERR\t/dev/console", "*", "*"); + if (f != NULL) + addfile(f); + f = cfline("*.PANIC\t*", "*", "*"); + if (f != NULL) + addfile(f); Initialized = 1; + return; } @@ -1887,9 +1930,10 @@ init(int signo) /* * Crack a configuration file line */ -static void -cfline(const char *line, struct filed *f, const char *prog, const char *host) +static struct filed * +cfline(const char *line, const char *prog, const char *host) { + struct filed *f; struct addrinfo hints, *res; int error, i, pri, syncfile; const char *p, *q; @@ -1898,10 +1942,13 @@ cfline(const char *line, struct filed *f dprintf("cfline(\"%s\", f, \"%s\", \"%s\")\n", line, prog, host); + f = calloc(1, sizeof(*f)); + if (f == NULL) { + logerror("malloc"); + exit(1); + } errno = 0; /* keep strerror() stuff out of logerror messages */ - /* clear out file entry */ - memset(f, 0, sizeof(*f)); for (i = 0; i <= LOG_NFACILITIES; i++) f->f_pmask[i] = INTERNAL_NOPRI; @@ -1995,7 +2042,7 @@ cfline(const char *line, struct filed *f (void)snprintf(ebuf, sizeof ebuf, "unknown priority name \"%s\"", buf); logerror(ebuf); - return; + return (NULL); } } if (!pri_cmp) @@ -2025,7 +2072,7 @@ cfline(const char *line, struct filed *f "unknown facility name \"%s\"", buf); logerror(ebuf); - return; + return (NULL); } f->f_pmask[i >> 3] = pri; f->f_pcmp[i >> 3] = pri_cmp; @@ -2142,6 +2189,7 @@ cfline(const char *line, struct filed *f f->f_type = F_USERS; break; } + return (f); } @@ -2731,7 +2779,6 @@ static int socksetup(struct peer *pe) { struct addrinfo hints, *res, *res0; - struct socklist *sl; int error; char *cp; /* @@ -2853,13 +2900,12 @@ socksetup(struct peer *pe) dprintf("listening on inet socket\n"); } else dprintf("sending on inet socket\n"); - sl = calloc(1, sizeof(*sl)); - if (sl == NULL) - err(1, "malloc failed"); - sl->sl_socket = s; - memcpy(&sl->sl_ss, res->ai_addr, res->ai_addrlen); - sl->sl_peer = pe; - STAILQ_INSERT_TAIL(&shead, sl, next); + addsock(res->ai_addr, res->ai_addrlen, + &(struct socklist){ + .sl_socket = s, + .sl_peer = pe, + .sl_recv = socklist_recv_sock + }); } freeaddrinfo(res0); From owner-svn-src-head@freebsd.org Wed Dec 21 06:49:22 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4B72AC8A470; Wed, 21 Dec 2016 06:49:22 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 26274128E; Wed, 21 Dec 2016 06:49:22 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBL6nL9x001821; Wed, 21 Dec 2016 06:49:21 GMT (envelope-from hrs@FreeBSD.org) Received: (from hrs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBL6nLse001820; Wed, 21 Dec 2016 06:49:21 GMT (envelope-from hrs@FreeBSD.org) Message-Id: <201612210649.uBL6nLse001820@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hrs set sender to hrs@FreeBSD.org using -f From: Hiroki Sato Date: Wed, 21 Dec 2016 06:49:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310351 - head/usr.sbin/syslogd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Dec 2016 06:49:22 -0000 Author: hrs Date: Wed Dec 21 06:49:21 2016 New Revision: 310351 URL: https://svnweb.freebsd.org/changeset/base/310351 Log: - Initialize deadq_head statically. - Fix indent. - Add missing -S flag into usage(). - Use nitems() for an iov array instead of a macro. Modified: head/usr.sbin/syslogd/syslogd.c Modified: head/usr.sbin/syslogd/syslogd.c ============================================================================== --- head/usr.sbin/syslogd/syslogd.c Wed Dec 21 06:42:30 2016 (r310350) +++ head/usr.sbin/syslogd/syslogd.c Wed Dec 21 06:49:21 2016 (r310351) @@ -223,7 +223,8 @@ struct deadq_entry { int dq_timeout; TAILQ_ENTRY(deadq_entry) dq_entries; }; -static TAILQ_HEAD(, deadq_entry) deadq_head; +static TAILQ_HEAD(, deadq_entry) deadq_head = + TAILQ_HEAD_INITIALIZER(deadq_head); /* * The timeout to apply to processes waiting on the dead queue. Unit @@ -264,11 +265,12 @@ static STAILQ_HEAD(, allowedpeer) aphead * we move to the next interval until we reach the largest. */ static int repeatinterval[] = { 30, 120, 600 }; /* # of secs before flush */ -#define MAXREPEAT ((sizeof(repeatinterval) / sizeof(repeatinterval[0])) - 1) +#define MAXREPEAT (nitems(repeatinterval) - 1) #define REPEATTIME(f) ((f)->f_time + repeatinterval[(f)->f_repeatcount]) -#define BACKOFF(f) { if (++(f)->f_repeatcount > MAXREPEAT) \ - (f)->f_repeatcount = MAXREPEAT; \ - } +#define BACKOFF(f) do { \ + if (++(f)->f_repeatcount > MAXREPEAT) \ + (f)->f_repeatcount = MAXREPEAT; \ + } while (0) /* values for f_type */ #define F_UNUSED 0 /* unused entry */ @@ -637,8 +639,6 @@ main(int argc, char *argv[]) (void)signal(SIGPIPE, SIG_IGN); /* We'll catch EPIPE instead. */ (void)alarm(TIMERINTVL); - TAILQ_INIT(&deadq_head); - /* tuck my process id away */ pidfile_write(pfh); @@ -772,11 +772,12 @@ static void usage(void) { - fprintf(stderr, "%s\n%s\n%s\n%s\n", + fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n", "usage: syslogd [-468ACcdFknosTuv] [-a allowed_peer]", " [-b bind_address] [-f config_file]", " [-l [mode:]path] [-m mark_interval]", - " [-P pid_file] [-p log_socket]"); + " [-P pid_file] [-p log_socket]", + " [-S logpriv_socket]"); exit(1); } @@ -1325,7 +1326,7 @@ fprintlog(struct filed *f, int flags, co dprintf(" %s\n", f->fu_fname); v->iov_base = lf; v->iov_len = 1; - if (writev(f->f_file, iov, IOV_SIZE) < 0) { + if (writev(f->f_file, iov, nitems(iov)) < 0) { /* * If writev(2) fails for potentially transient errors * like the filesystem being full, ignore it. @@ -1355,7 +1356,7 @@ fprintlog(struct filed *f, int flags, co break; } } - if (writev(f->f_file, iov, IOV_SIZE) < 0) { + if (writev(f->f_file, iov, nitems(iov)) < 0) { int e = errno; close_filed(f); if (f->fu_pipe_pid > 0) @@ -1380,7 +1381,7 @@ fprintlog(struct filed *f, int flags, co v->iov_len = 2; errno = 0; /* ttymsg() only sometimes returns an errno */ - if ((msgret = ttymsg(iov, IOV_SIZE, f->fu_fname, 10))) { + if ((msgret = ttymsg(iov, nitems(iov), f->fu_fname, 10))) { f->f_type = F_UNUSED; logerror(msgret); } @@ -1391,7 +1392,7 @@ fprintlog(struct filed *f, int flags, co dprintf("\n"); v->iov_base = crlf; v->iov_len = 2; - wallmsg(f, iov, IOV_SIZE); + wallmsg(f, iov, nitems(iov)); break; } f->f_prevcount = 0; From owner-svn-src-head@freebsd.org Wed Dec 21 07:05:36 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0CAB8C8A85A; Wed, 21 Dec 2016 07:05:36 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 B6CE71A92; Wed, 21 Dec 2016 07:05:35 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBL75Yf7009912; Wed, 21 Dec 2016 07:05:34 GMT (envelope-from hrs@FreeBSD.org) Received: (from hrs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBL75YuY009911; Wed, 21 Dec 2016 07:05:34 GMT (envelope-from hrs@FreeBSD.org) Message-Id: <201612210705.uBL75YuY009911@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hrs set sender to hrs@FreeBSD.org using -f From: Hiroki Sato Date: Wed, 21 Dec 2016 07:05:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310352 - head/usr.sbin/syslogd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Dec 2016 07:05:36 -0000 Author: hrs Date: Wed Dec 21 07:05:34 2016 New Revision: 310352 URL: https://svnweb.freebsd.org/changeset/base/310352 Log: Simplify type casting of struct sockaddr_in. Modified: head/usr.sbin/syslogd/syslogd.c Modified: head/usr.sbin/syslogd/syslogd.c ============================================================================== --- head/usr.sbin/syslogd/syslogd.c Wed Dec 21 06:49:21 2016 (r310351) +++ head/usr.sbin/syslogd/syslogd.c Wed Dec 21 07:05:34 2016 (r310352) @@ -128,6 +128,7 @@ static const char include_ext[] = ".conf #define sstosa(ss) ((struct sockaddr *)(ss)) #define satosin6(sa) ((struct sockaddr_in6 *)(void *)(sa)) +#define sstosin(ss) ((struct sockaddr_in *)(ss)) #define satosin(sa) ((struct sockaddr_in *)(void *)(sa)) #define s6_addr32 __u6_addr.__u6_addr32 #define IN6_ARE_MASKED_ADDR_EQUAL(d, a, m) ( \ @@ -2368,7 +2369,7 @@ allowaddr(char *s) struct servent *se; int masklen = -1; struct addrinfo hints, *res; - struct in_addr *addrp, *maskp; + in_addr_t *addrp, *maskp; #ifdef INET6 int i; u_int32_t *addr6p, *mask6p; @@ -2434,28 +2435,27 @@ allowaddr(char *s) ap->a_mask.ss_family = res->ai_family; if (res->ai_family == AF_INET) { ap->a_mask.ss_len = sizeof(struct sockaddr_in); - maskp = &((struct sockaddr_in *)&ap->a_mask)->sin_addr; - addrp = &((struct sockaddr_in *)&ap->a_addr)->sin_addr; + maskp = &sstosin(&ap->a_mask)->sin_addr.s_addr; + addrp = &sstosin(&ap->a_addr)->sin_addr.s_addr; if (masklen < 0) { /* use default netmask */ - if (IN_CLASSA(ntohl(addrp->s_addr))) - maskp->s_addr = htonl(IN_CLASSA_NET); - else if (IN_CLASSB(ntohl(addrp->s_addr))) - maskp->s_addr = htonl(IN_CLASSB_NET); + if (IN_CLASSA(ntohl(*addrp))) + *maskp = htonl(IN_CLASSA_NET); + else if (IN_CLASSB(ntohl(*addrp))) + *maskp = htonl(IN_CLASSB_NET); else - maskp->s_addr = htonl(IN_CLASSC_NET); + *maskp = htonl(IN_CLASSC_NET); + } else if (masklen == 0) { + *maskp = 0; } else if (masklen <= 32) { /* convert masklen to netmask */ - if (masklen == 0) - maskp->s_addr = 0; - else - maskp->s_addr = htonl(~((1 << (32 - masklen)) - 1)); + *maskp = htonl(~((1 << (32 - masklen)) - 1)); } else { freeaddrinfo(res); return (-1); } /* Lose any host bits in the network number. */ - addrp->s_addr &= maskp->s_addr; + *addrp &= *maskp; } #ifdef INET6 else if (res->ai_family == AF_INET6 && masklen <= 128) { From owner-svn-src-head@freebsd.org Wed Dec 21 08:29:46 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2FE9CC89D83; Wed, 21 Dec 2016 08:29:46 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 F28181C69; Wed, 21 Dec 2016 08:29:45 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBL8TjLW041815; Wed, 21 Dec 2016 08:29:45 GMT (envelope-from ed@FreeBSD.org) Received: (from ed@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBL8Tijt041811; Wed, 21 Dec 2016 08:29:44 GMT (envelope-from ed@FreeBSD.org) Message-Id: <201612210829.uBL8Tijt041811@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ed set sender to ed@FreeBSD.org using -f From: Ed Schouten Date: Wed, 21 Dec 2016 08:29:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310354 - in head/usr.sbin: . prometheus_sysctl_exporter X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Dec 2016 08:29:46 -0000 Author: ed Date: Wed Dec 21 08:29:44 2016 New Revision: 310354 URL: https://svnweb.freebsd.org/changeset/base/310354 Log: Add a Prometheus exporter for sysctl values. Now that we have our sysctl tree annotated with aggregation labels, let's go ahead and provide a very simple utility for exporting the sysctl tree in Prometheus' format. It can either be used in conjunction with the Prometheus node exporter or run through inetd(8). The reason why I'm opting for having it in the base system is because it has a pretty strong integration with some of sysctl's innards, such as access to iterators, name lookups, metadata and type information. As I am investigating whether we can add histograms as native types to sysctl as well, this integration will only get stronger as we go along. That's why it would be safer to oversee the development of this exporter ourselves, as opposed to having it as an external project. This exporter is remarkably compact, especially when compared to the official Linux binary of the Prometheus node exporter (16 KB vs 12 MB). I guess this could be an interesting aspect for monitoring embedded FreeBSD-based systems. Differential Revision: https://reviews.freebsd.org/D8792 Added: head/usr.sbin/prometheus_sysctl_exporter/ head/usr.sbin/prometheus_sysctl_exporter/Makefile (contents, props changed) head/usr.sbin/prometheus_sysctl_exporter/prometheus_sysctl_exporter.8 (contents, props changed) head/usr.sbin/prometheus_sysctl_exporter/prometheus_sysctl_exporter.c (contents, props changed) Modified: head/usr.sbin/Makefile Modified: head/usr.sbin/Makefile ============================================================================== --- head/usr.sbin/Makefile Wed Dec 21 07:26:04 2016 (r310353) +++ head/usr.sbin/Makefile Wed Dec 21 08:29:44 2016 (r310354) @@ -62,6 +62,7 @@ SUBDIR= adduser \ periodic \ powerd \ procctl \ + prometheus_sysctl_exporter \ pstat \ pw \ pwd_mkdb \ Added: head/usr.sbin/prometheus_sysctl_exporter/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.sbin/prometheus_sysctl_exporter/Makefile Wed Dec 21 08:29:44 2016 (r310354) @@ -0,0 +1,8 @@ +# $FreeBSD$ + +PROG= prometheus_sysctl_exporter +MAN= prometheus_sysctl_exporter.8 + +LIBADD= m z + +.include Added: head/usr.sbin/prometheus_sysctl_exporter/prometheus_sysctl_exporter.8 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.sbin/prometheus_sysctl_exporter/prometheus_sysctl_exporter.8 Wed Dec 21 08:29:44 2016 (r310354) @@ -0,0 +1,106 @@ +.\" Copyright (c) 2016 Nuxi, https://nuxi.nl/ +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.Dd December 18, 2016 +.Dt PROMETHEUS_SYSCTL_EXPORTER 8 +.Os +.Sh NAME +.Nm prometheus_sysctl_exporter +.Nd print kernel state as Prometheus metrics +.Sh SYNOPSIS +.Nm prometheus_sysctl_exporter +.Op Fl dgh +.Op Ar prefix ... +.Sh DESCRIPTION +Prometheus is a monitoring system that gathers metrics from its targets +by fetching them through HTTP GET requests. +Metrics are identified by a name and an optional set of labels. +Sample values are required to be numerical. +.Pp +The +.Nm +utility prints the values of sysctl nodes to standard output, +formatted such that they can be scraped by Prometheus directly. +By default, +it prints metrics for all numerically representable nodes in the sysctl +namespace. +It is also possible to limit output to a smaller number of metrics by +specifying one or more prefixes as arguments. +.Pp +Metrics printed by this utility are named +.Ql sysctl_ , +followed by the name of the sysctl node having its +.Ql .\& +separators replaced by +.Ql _ . +Components on which it is desirable to aggregate (e.g., +names of devices) are omitted from the metric's name, +but are appended as labels instead. +.Pp +There are two different methods for exporting the output of +.Nm +to Prometheus. +The first method is to periodically invoke this utility through +.Xr cron 8 +and store its output in a textfile. +The metrics in this textfile can then be served over HTTP using the +Prometheus node exporter's textfile collector. +The second method is to run this utility through +.Xr inetd 8 . +TCP port 9124 has been allocated for this purpose. +.Pp +The following options are available: +.Bl -tag -width indent +.It Fl d +Print descriptions of metrics when available. +.It Fl g +Gzip compresses the HTTP response body. +.It Fl h +Precede the output with a HTTP response header. +This flag is required when running this utility through +.Xr inetd 8 . +.El +.Sh SEE ALSO +.Xr cron 8 , +.Xr inetd 8 , +.Xr sysctl 8 , +.Xr SYSCTL_ADD_NODE_WITH_LABEL 9 +.Pp +Prometheus project: +.Pa https://prometheus.io/ . +.Pp +Prometheus exposition formats: +.Pa https://prometheus.io/docs/instrumenting/exposition_formats/ . +.Pp +Prometheus node exporter: +.Pa https://github.com/prometheus/node_exporter . +.Pp +Prometheus default port allocations: +.Pa https://github.com/prometheus/prometheus/wiki/Default-port-allocations . +.Sh HISTORY +.Nm +first appeared in +.Fx 12.0 . +.Sh AUTHORS +.An Nuxi : Pa https://nuxi.nl/ . Added: head/usr.sbin/prometheus_sysctl_exporter/prometheus_sysctl_exporter.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.sbin/prometheus_sysctl_exporter/prometheus_sysctl_exporter.c Wed Dec 21 08:29:44 2016 (r310354) @@ -0,0 +1,652 @@ +/*- + * Copyright (c) 2016 Nuxi, https://nuxi.nl/ + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Cursor for iterating over all of the system's sysctl OIDs. + */ +struct oid { + int id[CTL_MAXNAME]; + size_t len; +}; + +/* Initializes the cursor to point to start of the tree. */ +static void +oid_get_root(struct oid *o) +{ + + o->id[0] = 1; + o->len = 1; +} + +/* Obtains the OID for a sysctl by name. */ +static void +oid_get_by_name(struct oid *o, const char *name) +{ + + o->len = nitems(o->id); + if (sysctlnametomib(name, o->id, &o->len) != 0) + err(1, "sysctl(%s)", name); +} + +/* Returns whether an OID is placed below another OID. */ +static bool +oid_is_beneath(struct oid *oa, struct oid *ob) +{ + + return (oa->len >= ob->len && + memcmp(oa->id, ob->id, ob->len * sizeof(oa->id[0])) == 0); +} + +/* Advances the cursor to the next OID. */ +static bool +oid_get_next(const struct oid *cur, struct oid *next) +{ + int lookup[CTL_MAXNAME + 2]; + size_t nextsize; + + lookup[0] = 0; + lookup[1] = 2; + memcpy(lookup + 2, cur->id, cur->len * sizeof(lookup[0])); + nextsize = sizeof(next->id); + if (sysctl(lookup, 2 + cur->len, &next->id, &nextsize, 0, 0) != 0) { + if (errno == ENOENT) + return (false); + err(1, "sysctl(next)"); + } + next->len = nextsize / sizeof(next->id[0]); + return (true); +} + +/* + * OID formatting metadata. + */ +struct oidformat { + unsigned int kind; + char format[BUFSIZ]; +}; + +/* Returns whether the OID represents a temperature value. */ +static bool +oidformat_is_temperature(const struct oidformat *of) +{ + + return (of->format[0] == 'I' && of->format[1] == 'K'); +} + +/* Returns whether the OID represents a timeval structure. */ +static bool +oidformat_is_timeval(const struct oidformat *of) +{ + + return (strcmp(of->format, "S,timeval") == 0); +} + +/* Fetches the formatting metadata for an OID. */ +static bool +oid_get_format(const struct oid *o, struct oidformat *of) +{ + int lookup[CTL_MAXNAME + 2]; + size_t oflen; + + lookup[0] = 0; + lookup[1] = 4; + memcpy(lookup + 2, o->id, o->len * sizeof(lookup[0])); + oflen = sizeof(*of); + if (sysctl(lookup, 2 + o->len, of, &oflen, 0, 0) != 0) { + if (errno == ENOENT) + return (false); + err(1, "sysctl(oidfmt)"); + } + return (true); +} + +/* + * Container for holding the value of an OID. + */ +struct oidvalue { + enum { SIGNED, UNSIGNED, FLOAT } type; + union { + intmax_t s; + uintmax_t u; + double f; + } value; +}; + +/* Extracts the value of an OID, converting it to a floating-point number. */ +static double +oidvalue_get_float(const struct oidvalue *ov) +{ + + switch (ov->type) { + case SIGNED: + return (ov->value.s); + case UNSIGNED: + return (ov->value.u); + case FLOAT: + return (ov->value.f); + default: + assert(0 && "Unknown value type"); + } +} + +/* Sets the value of an OID as a signed integer. */ +static void +oidvalue_set_signed(struct oidvalue *ov, intmax_t s) +{ + + ov->type = SIGNED; + ov->value.s = s; +} + +/* Sets the value of an OID as an unsigned integer. */ +static void +oidvalue_set_unsigned(struct oidvalue *ov, uintmax_t u) +{ + + ov->type = UNSIGNED; + ov->value.u = u; +} + +/* Sets the value of an OID as a floating-point number. */ +static void +oidvalue_set_float(struct oidvalue *ov, double f) +{ + + ov->type = FLOAT; + ov->value.f = f; +} + +/* Prints the value of an OID to a file stream. */ +static void +oidvalue_print(const struct oidvalue *ov, FILE *fp) +{ + + switch (ov->type) { + case SIGNED: + fprintf(fp, "%jd", ov->value.s); + break; + case UNSIGNED: + fprintf(fp, "%ju", ov->value.u); + break; + case FLOAT: + switch (fpclassify(ov->value.f)) { + case FP_INFINITE: + if (signbit(ov->value.f)) + fprintf(fp, "-Inf"); + else + fprintf(fp, "+Inf"); + break; + case FP_NAN: + fprintf(fp, "Nan"); + break; + default: + fprintf(fp, "%.6f", ov->value.f); + break; + } + break; + } +} + +/* Fetches the value of an OID. */ +static bool +oid_get_value(const struct oid *o, const struct oidformat *of, + struct oidvalue *ov) +{ + + switch (of->kind & CTLTYPE) { +#define GET_VALUE(ctltype, type) \ + case (ctltype): { \ + type value; \ + size_t valuesize; \ + \ + valuesize = sizeof(value); \ + if (sysctl(o->id, o->len, &value, &valuesize, 0, 0) != 0) \ + return (false); \ + if ((type)-1 > 0) \ + oidvalue_set_unsigned(ov, value); \ + else \ + oidvalue_set_signed(ov, value); \ + break; \ + } + GET_VALUE(CTLTYPE_INT, int); + GET_VALUE(CTLTYPE_UINT, unsigned int); + GET_VALUE(CTLTYPE_LONG, long); + GET_VALUE(CTLTYPE_ULONG, unsigned long); + GET_VALUE(CTLTYPE_S8, int8_t); + GET_VALUE(CTLTYPE_U8, uint8_t); + GET_VALUE(CTLTYPE_S16, int16_t); + GET_VALUE(CTLTYPE_U16, uint16_t); + GET_VALUE(CTLTYPE_S32, int32_t); + GET_VALUE(CTLTYPE_U32, uint32_t); + GET_VALUE(CTLTYPE_S64, int64_t); + GET_VALUE(CTLTYPE_U64, uint64_t); +#undef GET_VALUE + case CTLTYPE_OPAQUE: + if (oidformat_is_timeval(of)) { + struct timeval tv; + size_t tvsize; + + tvsize = sizeof(tv); + if (sysctl(o->id, o->len, &tv, &tvsize, 0, 0) != 0) + return (false); + oidvalue_set_float(ov, + (double)tv.tv_sec + (double)tv.tv_usec / 1000000); + return (true); + } else if (strcmp(of->format, "S,loadavg") == 0) { + struct loadavg la; + size_t lasize; + + /* + * Only return the one minute load average, as + * the others can be inferred using avg_over_time(). + */ + lasize = sizeof(la); + if (sysctl(o->id, o->len, &la, &lasize, 0, 0) != 0) + return (false); + oidvalue_set_float(ov, + (double)la.ldavg[0] / (double)la.fscale); + return (true); + } + return (false); + default: + return (false); + } + + /* Convert temperatures from decikelvin to degrees Celcius. */ + if (oidformat_is_temperature(of)) { + double v; + int e; + + v = oidvalue_get_float(ov); + if (v < 0) { + oidvalue_set_float(ov, NAN); + } else { + e = of->format[2] >= '0' && of->format[2] <= '9' ? + of->format[2] - '0' : 1; + oidvalue_set_float(ov, v / pow(10, e) - 273.15); + } + } + return (true); +} + +/* + * The full name of an OID, stored as a series of components. + */ +struct oidname { + struct oid oid; + char names[BUFSIZ]; + char labels[BUFSIZ]; +}; + +/* + * Initializes the OID name object with an empty value. + */ +static void +oidname_init(struct oidname *on) +{ + + on->oid.len = 0; +} + +/* Fetches the name and labels of an OID, reusing the previous results. */ +static void +oid_get_name(const struct oid *o, struct oidname *on) +{ + int lookup[CTL_MAXNAME + 2]; + char *c, *label; + size_t i, len; + + /* Fetch the name and split it up in separate components. */ + lookup[0] = 0; + lookup[1] = 1; + memcpy(lookup + 2, o->id, o->len * sizeof(lookup[0])); + len = sizeof(on->names); + if (sysctl(lookup, 2 + o->len, on->names, &len, 0, 0) != 0) + err(1, "sysctl(name)"); + for (c = strchr(on->names, '.'); c != NULL; c = strchr(c + 1, '.')) + *c = '\0'; + + /* No need to fetch labels for components that we already have. */ + label = on->labels; + for (i = 0; i < o->len && i < on->oid.len && o->id[i] == on->oid.id[i]; + ++i) + label += strlen(label) + 1; + + /* Fetch the remaining labels. */ + lookup[1] = 6; + for (; i < o->len; ++i) { + len = on->labels + sizeof(on->labels) - label; + if (sysctl(lookup, 2 + i + 1, label, &len, 0, 0) == 0) { + label += len; + } else if (errno == ENOENT) { + *label++ = '\0'; + } else { + err(1, "sysctl(oidlabel)"); + } + } + on->oid = *o; +} + +/* Prints the name and labels of an OID to a file stream. */ +static void +oidname_print(const struct oidname *on, const struct oidformat *of, + FILE *fp) +{ + const char *name, *label; + size_t i; + char separator; + + /* Print the name of the metric. */ + fprintf(fp, "sysctl"); + name = on->names; + label = on->labels; + for (i = 0; i < on->oid.len; ++i) { + if (*label == '\0') { + assert(name[strspn(name, + "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "0123456789_")] == '\0'); + fprintf(fp, "_%s", name); + } + name += strlen(name) + 1; + label += strlen(label) + 1; + } + if (oidformat_is_temperature(of)) + fprintf(fp, "_celcius"); + else if (oidformat_is_timeval(of)) + fprintf(fp, "_seconds"); + + /* Print the labels of the metric. */ + name = on->names; + label = on->labels; + separator = '{'; + for (i = 0; i < on->oid.len; ++i) { + if (*label != '\0') { + assert(name[strspn(name, + "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "0123456789_-")] == '\0'); + assert(label[strspn(label, + "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "0123456789_")] == '\0'); + fprintf(fp, "%c%s=\"%s\"", separator, label, name); + separator = ','; + } + name += strlen(name) + 1; + label += strlen(label) + 1; + } + if (separator != '{') + fputc('}', fp); +} + +/* Returns whether the OID name has any labels associated to it. */ +static bool +oidname_has_labels(const struct oidname *on) +{ + size_t i; + + for (i = 0; i < on->oid.len; ++i) + if (on->labels[i] != 0) + return (true); + return (false); +} + +/* + * The description of an OID. + */ +struct oiddescription { + char description[BUFSIZ]; +}; + +/* + * Fetches the description of an OID. + */ +static bool +oid_get_description(const struct oid *o, struct oiddescription *od) +{ + int lookup[CTL_MAXNAME + 2]; + char *newline; + size_t odlen; + + lookup[0] = 0; + lookup[1] = 5; + memcpy(lookup + 2, o->id, o->len * sizeof(lookup[0])); + odlen = sizeof(od->description); + if (sysctl(lookup, 2 + o->len, &od->description, &odlen, 0, 0) != 0) { + if (errno == ENOENT) + return (false); + err(1, "sysctl(oiddescr)"); + } + + newline = strchr(od->description, '\n'); + if (newline != NULL) + *newline = '\0'; + + return (*od->description != '\0'); +} + +/* Prints the description of an OID to a file stream. */ +static void +oiddescription_print(const struct oiddescription *od, FILE *fp) +{ + + fprintf(fp, "%s", od->description); +} + +static void +oid_print(const struct oid *o, struct oidname *on, bool print_description, + FILE *fp) +{ + struct oidformat of; + struct oidvalue ov; + struct oiddescription od; + + if (!oid_get_format(o, &of) || !oid_get_value(o, &of, &ov)) + return; + oid_get_name(o, on); + + /* + * Print the line with the description. Prometheus expects a + * single unique description for every metric, which cannot be + * guaranteed by sysctl if labels are present. Omit the + * description if labels are present. + */ + if (print_description && !oidname_has_labels(on) && + oid_get_description(o, &od)) { + fprintf(fp, "# HELP "); + oidname_print(on, &of, fp); + fputc(' ', fp); + oiddescription_print(&od, fp); + fputc('\n', fp); + } + + /* Print the line with the value. */ + oidname_print(on, &of, fp); + fputc(' ', fp); + oidvalue_print(&ov, fp); + fputc('\n', fp); +} + +/* Gzip compresses a buffer of memory. */ +static bool +buf_gzip(const char *in, size_t inlen, char *out, size_t *outlen) +{ + z_stream stream = { + .next_in = __DECONST(unsigned char *, in), + .avail_in = inlen, + .next_out = (unsigned char *)out, + .avail_out = *outlen, + }; + + if (deflateInit2(&stream, Z_DEFAULT_COMPRESSION, Z_DEFLATED, + MAX_WBITS + 16, 8, Z_DEFAULT_STRATEGY) != Z_OK || + deflate(&stream, Z_FINISH) != Z_STREAM_END) { + return (false); + } + *outlen = stream.total_out; + return (deflateEnd(&stream) == Z_OK); +} + +static void +usage(void) +{ + + fprintf(stderr, + "usage: prometheus_sysctl_exporter [-dgh] [prefix ...]\n"); + exit(1); +} + +int +main(int argc, char *argv[]) +{ + struct oidname on; + char *http_buf; + FILE *fp; + size_t http_buflen; + int ch; + bool gzip_mode, http_mode, print_descriptions; + + /* Parse command line flags. */ + gzip_mode = http_mode = print_descriptions = false; + while ((ch = getopt(argc, argv, "dgh")) != -1) { + switch (ch) { + case 'd': + print_descriptions = true; + break; + case 'g': + gzip_mode = true; + break; + case 'h': + http_mode = true; + break; + default: + usage(); + } + } + argc -= optind; + argv += optind; + + /* HTTP output: cache metrics in buffer. */ + if (http_mode) { + fp = open_memstream(&http_buf, &http_buflen); + if (fp == NULL) + err(1, "open_memstream"); + } else { + fp = stdout; + } + + oidname_init(&on); + if (argc == 0) { + struct oid o; + + /* Print all OIDs. */ + oid_get_root(&o); + do { + oid_print(&o, &on, print_descriptions, fp); + } while (oid_get_next(&o, &o)); + } else { + int i; + + /* Print only trees provided as arguments. */ + for (i = 0; i < argc; ++i) { + struct oid o, root; + + oid_get_by_name(&root, argv[i]); + o = root; + do { + oid_print(&o, &on, print_descriptions, fp); + } while (oid_get_next(&o, &o) && + oid_is_beneath(&o, &root)); + } + } + + if (http_mode) { + const char *content_encoding = ""; + + if (ferror(fp) || fclose(fp) != 0) + err(1, "Cannot generate output"); + + /* Gzip compress the output. */ + if (gzip_mode) { + char *buf; + size_t buflen; + + buflen = http_buflen; + buf = malloc(buflen); + if (buf == NULL) + err(1, "Cannot allocate compression buffer"); + if (buf_gzip(http_buf, http_buflen, buf, &buflen)) { + content_encoding = "Content-Encoding: gzip\r\n"; + free(http_buf); + http_buf = buf; + http_buflen = buflen; + } else { + free(buf); + } + } + + /* Print HTTP header and metrics. */ + dprintf(STDOUT_FILENO, + "HTTP/1.1 200 OK\r\n" + "Connection: close\r\n" + "%s" + "Content-Length: %zu\r\n" + "Content-Type: text/plain; version=0.0.4\r\n" + "\r\n", + content_encoding, http_buflen); + write(STDOUT_FILENO, http_buf, http_buflen); + free(http_buf); + + /* Drain output. */ + if (shutdown(STDIN_FILENO, SHUT_WR) == 0) { + char buf[1024]; + + while (read(STDIN_FILENO, buf, sizeof(buf)) > 0) { + } + } + } + return (0); +} From owner-svn-src-head@freebsd.org Wed Dec 21 08:32:22 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 29616C89FB5; Wed, 21 Dec 2016 08:32:22 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 ED88A1097; Wed, 21 Dec 2016 08:32:21 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBL8WLCs044769; Wed, 21 Dec 2016 08:32:21 GMT (envelope-from ed@FreeBSD.org) Received: (from ed@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBL8WLOQ044767; Wed, 21 Dec 2016 08:32:21 GMT (envelope-from ed@FreeBSD.org) Message-Id: <201612210832.uBL8WLOQ044767@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ed set sender to ed@FreeBSD.org using -f From: Ed Schouten Date: Wed, 21 Dec 2016 08:32:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310355 - head/etc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Dec 2016 08:32:22 -0000 Author: ed Date: Wed Dec 21 08:32:20 2016 New Revision: 310355 URL: https://svnweb.freebsd.org/changeset/base/310355 Log: Add an example inetd(8) entry for the Prometheus sysctl exporter. I went through the process of allocating a default port number for this exporter, TCP 9124. This means that we can add an entry to the services file as well. List of Prometheus default port numbers: https://github.com/prometheus/prometheus/wiki/Default-port-allocations Modified: head/etc/inetd.conf head/etc/services Modified: head/etc/inetd.conf ============================================================================== --- head/etc/inetd.conf Wed Dec 21 08:29:44 2016 (r310354) +++ head/etc/inetd.conf Wed Dec 21 08:32:20 2016 (r310355) @@ -117,3 +117,7 @@ #netbios-ssn stream tcp nowait root /usr/local/sbin/smbd smbd #netbios-ns dgram udp wait root /usr/local/sbin/nmbd nmbd #swat stream tcp nowait/400 root /usr/local/sbin/swat swat +# +# Example entry for the Prometheus sysctl metrics exporter +# +#prom-sysctl stream tcp nowait nobody /usr/sbin/prometheus_sysctl_exporter prometheus_sysctl_exporter -dgh Modified: head/etc/services ============================================================================== --- head/etc/services Wed Dec 21 08:29:44 2016 (r310354) +++ head/etc/services Wed Dec 21 08:32:20 2016 (r310355) @@ -2450,6 +2450,7 @@ aurora 9084/sctp #IBM AURORA Performan aurora 9084/tcp #IBM AURORA Performance Visualizer aurora 9084/udp #IBM AURORA Performance Visualizer jetdirect 9100/tcp #HP JetDirect card +prom-sysctl 9124/tcp #prometheus_sysctl_exporter(8) git 9418/tcp #git pack transfer service git 9418/udp #git pack transfer service man 9535/tcp From owner-svn-src-head@freebsd.org Wed Dec 21 09:05:32 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 02812C8A43D; Wed, 21 Dec 2016 09:05:32 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 B7888151A; Wed, 21 Dec 2016 09:05:31 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBL95UG8057637; Wed, 21 Dec 2016 09:05:30 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBL95U8R057635; Wed, 21 Dec 2016 09:05:30 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201612210905.uBL95U8R057635@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 21 Dec 2016 09:05:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310356 - in head: sys/cam/ctl usr.sbin/ctladm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Dec 2016 09:05:32 -0000 Author: mav Date: Wed Dec 21 09:05:30 2016 New Revision: 310356 URL: https://svnweb.freebsd.org/changeset/base/310356 Log: Add support for locally assigned RFC 4122 UUID LUN identifiers. MFC after: 2 weeks Modified: head/sys/cam/ctl/ctl.c head/usr.sbin/ctladm/ctladm.8 Modified: head/sys/cam/ctl/ctl.c ============================================================================== --- head/sys/cam/ctl/ctl.c Wed Dec 21 08:32:20 2016 (r310355) +++ head/sys/cam/ctl/ctl.c Wed Dec 21 09:05:30 2016 (r310356) @@ -4371,6 +4371,8 @@ hex2bin(const char *str, uint8_t *buf, i str += 2; buf_size *= 2; for (i = 0; str[i] != 0 && i < buf_size; i++) { + while (str[i] == '-') /* Skip dashes in UUIDs. */ + str++; c = str[i]; if (isdigit(c)) c -= '0'; @@ -4406,7 +4408,7 @@ ctl_alloc_lun(struct ctl_softc *ctl_soft struct ctl_lun *nlun, *lun; struct scsi_vpd_id_descriptor *desc; struct scsi_vpd_id_t10 *t10id; - const char *eui, *naa, *scsiname, *vendor, *value; + const char *eui, *naa, *scsiname, *uuid, *vendor, *value; int lun_number, i, lun_malloced; int devidlen, idlen1, idlen2 = 0, len; @@ -4458,6 +4460,10 @@ ctl_alloc_lun(struct ctl_softc *ctl_soft if (naa != NULL) { len += sizeof(struct scsi_vpd_id_descriptor) + 16; } + uuid = ctl_get_opt(&be_lun->options, "uuid"); + if (uuid != NULL) { + len += sizeof(struct scsi_vpd_id_descriptor) + 18; + } lun->lun_devid = malloc(sizeof(struct ctl_devid) + len, M_CTL, M_WAITOK | M_ZERO); desc = (struct scsi_vpd_id_descriptor *)lun->lun_devid->data; @@ -4504,6 +4510,16 @@ ctl_alloc_lun(struct ctl_softc *ctl_soft desc->length = desc->length > 8 ? 16 : 8; len -= 16 - desc->length; } + if (uuid != NULL) { + desc = (struct scsi_vpd_id_descriptor *)(&desc->identifier[0] + + desc->length); + desc->proto_codeset = SVPD_ID_CODESET_BINARY; + desc->id_type = SVPD_ID_PIV | SVPD_ID_ASSOC_LUN | + SVPD_ID_TYPE_UUID; + desc->identifier[0] = 0x10; + hex2bin(uuid, &desc->identifier[2], 16); + desc->length = 18; + } lun->lun_devid->len = len; mtx_lock(&ctl_softc->ctl_lock); Modified: head/usr.sbin/ctladm/ctladm.8 ============================================================================== --- head/usr.sbin/ctladm/ctladm.8 Wed Dec 21 08:32:20 2016 (r310355) +++ head/usr.sbin/ctladm/ctladm.8 Wed Dec 21 09:05:30 2016 (r310356) @@ -35,7 +35,7 @@ .\" $Id: //depot/users/kenm/FreeBSD-test2/usr.sbin/ctladm/ctladm.8#3 $ .\" $FreeBSD$ .\" -.Dd October 15, 2016 +.Dd December 21, 2016 .Dt CTLADM 8 .Os .Sh NAME @@ -859,9 +859,12 @@ Specifies LUN SCSI name string. Specifies LUN EUI-64 identifier. .It Va naa Specifies LUN NAA identifier. -Either EUI or NAA identifier should be set to UNIQUE value to allow +.It Va uuid +Specifies LUN locally assigned RFC 4122 UUID identifier. +EUI, NAA or UUID identifier should be set to UNIQUE value to allow EXTENDED COPY command access the LUN. Non-unique LUN identifiers may lead to data corruption. +Some initiators may not support later introduced UUID identifiers. .It Va ha_role Setting to "primary" or "secondary" overrides default role of the node in HA cluster, set by kern.cam.ctl.ha_role sysctl. From owner-svn-src-head@freebsd.org Wed Dec 21 09:36:24 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F1AF6C8ABAF; Wed, 21 Dec 2016 09:36:24 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 CC4041706; Wed, 21 Dec 2016 09:36:24 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBL9aODx069886; Wed, 21 Dec 2016 09:36:24 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBL9aNOh069883; Wed, 21 Dec 2016 09:36:23 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201612210936.uBL9aNOh069883@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 21 Dec 2016 09:36:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310360 - in head/sys/cam: . scsi X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Dec 2016 09:36:25 -0000 Author: mav Date: Wed Dec 21 09:36:23 2016 New Revision: 310360 URL: https://svnweb.freebsd.org/changeset/base/310360 Log: Report UUID and MD5 LUN IDs. MFC after: 2 weeks Modified: head/sys/cam/cam_xpt.c head/sys/cam/scsi/scsi_all.c head/sys/cam/scsi/scsi_all.h Modified: head/sys/cam/cam_xpt.c ============================================================================== --- head/sys/cam/cam_xpt.c Wed Dec 21 09:22:06 2016 (r310359) +++ head/sys/cam/cam_xpt.c Wed Dec 21 09:36:23 2016 (r310360) @@ -1115,7 +1115,7 @@ xpt_denounce_periph(struct cam_periph *p int xpt_getattr(char *buf, size_t len, const char *attr, struct cam_path *path) { - int ret = -1, l; + int ret = -1, l, o; struct ccb_dev_advinfo cdai; struct scsi_vpd_id_descriptor *idd; @@ -1155,6 +1155,12 @@ xpt_getattr(char *buf, size_t len, const if (idd == NULL) idd = scsi_get_devid((struct scsi_vpd_device_id *)cdai.buf, cdai.provsiz, scsi_devid_is_lun_eui64); + if (idd == NULL) + idd = scsi_get_devid((struct scsi_vpd_device_id *)cdai.buf, + cdai.provsiz, scsi_devid_is_lun_uuid); + if (idd == NULL) + idd = scsi_get_devid((struct scsi_vpd_device_id *)cdai.buf, + cdai.provsiz, scsi_devid_is_lun_md5); } else idd = NULL; if (idd == NULL) @@ -1181,6 +1187,17 @@ xpt_getattr(char *buf, size_t len, const buf[l] = 0; } else ret = EFAULT; + } else if ((idd->id_type & SVPD_ID_TYPE_MASK) == SVPD_ID_TYPE_UUID + && idd->identifier[0] == 0x10) { + if ((idd->length - 2) * 2 + 4 < len) { + for (l = 2, o = 0; l < idd->length; l++) { + o += sprintf(buf + o, "%02x", + idd->identifier[l]); + if (l == 4 || l == 6 || l == 8 || l == 10) + o += sprintf(buf + o, "-"); + } + } else + ret = EFAULT; } else { if (idd->length * 2 < len) { for (l = 0; l < idd->length; l++) Modified: head/sys/cam/scsi/scsi_all.c ============================================================================== --- head/sys/cam/scsi/scsi_all.c Wed Dec 21 09:22:06 2016 (r310359) +++ head/sys/cam/scsi/scsi_all.c Wed Dec 21 09:36:23 2016 (r310360) @@ -5691,6 +5691,32 @@ scsi_devid_is_lun_name(uint8_t *bufp) } int +scsi_devid_is_lun_md5(uint8_t *bufp) +{ + struct scsi_vpd_id_descriptor *descr; + + descr = (struct scsi_vpd_id_descriptor *)bufp; + if ((descr->id_type & SVPD_ID_ASSOC_MASK) != SVPD_ID_ASSOC_LUN) + return 0; + if ((descr->id_type & SVPD_ID_TYPE_MASK) != SVPD_ID_TYPE_MD5_LUN_ID) + return 0; + return 1; +} + +int +scsi_devid_is_lun_uuid(uint8_t *bufp) +{ + struct scsi_vpd_id_descriptor *descr; + + descr = (struct scsi_vpd_id_descriptor *)bufp; + if ((descr->id_type & SVPD_ID_ASSOC_MASK) != SVPD_ID_ASSOC_LUN) + return 0; + if ((descr->id_type & SVPD_ID_TYPE_MASK) != SVPD_ID_TYPE_UUID) + return 0; + return 1; +} + +int scsi_devid_is_port_naa(uint8_t *bufp) { struct scsi_vpd_id_descriptor *descr; Modified: head/sys/cam/scsi/scsi_all.h ============================================================================== --- head/sys/cam/scsi/scsi_all.h Wed Dec 21 09:22:06 2016 (r310359) +++ head/sys/cam/scsi/scsi_all.h Wed Dec 21 09:36:23 2016 (r310360) @@ -3782,6 +3782,8 @@ int scsi_devid_is_lun_eui64(uint8_t *bu int scsi_devid_is_lun_naa(uint8_t *bufp); int scsi_devid_is_lun_name(uint8_t *bufp); int scsi_devid_is_lun_t10(uint8_t *bufp); +int scsi_devid_is_lun_md5(uint8_t *bufp); +int scsi_devid_is_lun_uuid(uint8_t *bufp); int scsi_devid_is_port_naa(uint8_t *bufp); struct scsi_vpd_id_descriptor * scsi_get_devid(struct scsi_vpd_device_id *id, uint32_t len, From owner-svn-src-head@freebsd.org Wed Dec 21 09:49:17 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AF606C8AE25; Wed, 21 Dec 2016 09:49:17 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 7F1C41CB8; Wed, 21 Dec 2016 09:49:17 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBL9nGKE074047; Wed, 21 Dec 2016 09:49:16 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBL9nGZl074046; Wed, 21 Dec 2016 09:49:16 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201612210949.uBL9nGZl074046@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 21 Dec 2016 09:49:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310361 - head/sys/cam X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Dec 2016 09:49:17 -0000 Author: mav Date: Wed Dec 21 09:49:16 2016 New Revision: 310361 URL: https://svnweb.freebsd.org/changeset/base/310361 Log: Fix UUID formatting added in r310360. Oops! MFC after: 2 weeks Modified: head/sys/cam/cam_xpt.c Modified: head/sys/cam/cam_xpt.c ============================================================================== --- head/sys/cam/cam_xpt.c Wed Dec 21 09:36:23 2016 (r310360) +++ head/sys/cam/cam_xpt.c Wed Dec 21 09:49:16 2016 (r310361) @@ -1191,10 +1191,10 @@ xpt_getattr(char *buf, size_t len, const && idd->identifier[0] == 0x10) { if ((idd->length - 2) * 2 + 4 < len) { for (l = 2, o = 0; l < idd->length; l++) { + if (l == 6 || l == 8 || l == 10 || l == 12) + o += sprintf(buf + o, "-"); o += sprintf(buf + o, "%02x", idd->identifier[l]); - if (l == 4 || l == 6 || l == 8 || l == 10) - o += sprintf(buf + o, "-"); } } else ret = EFAULT; From owner-svn-src-head@freebsd.org Wed Dec 21 14:06:45 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D5B3BC8A1A8; Wed, 21 Dec 2016 14:06:45 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 96AE62F8; Wed, 21 Dec 2016 14:06:45 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBLE6i64082253; Wed, 21 Dec 2016 14:06:44 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBLE6isw082252; Wed, 21 Dec 2016 14:06:44 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201612211406.uBLE6isw082252@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Wed, 21 Dec 2016 14:06:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310365 - head/contrib/llvm/projects/libunwind/src X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Dec 2016 14:06:45 -0000 Author: emaste Date: Wed Dec 21 14:06:44 2016 New Revision: 310365 URL: https://svnweb.freebsd.org/changeset/base/310365 Log: libunwind: make __{de,}register_frame compatible with libgcc API The libgcc __register_frame and __deregister_frame functions take a pointer to a set of FDE/CIEs, terminated by an entry where length is 0. In Apple's libunwind implementation the pointer is taken to be to a single FDE. I suspect this was just an Apple bug, compensated by Apple- specific code in LLVM. See lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp and http://lists.llvm.org/pipermail/llvm-dev/2013-April/061737.html for more detail. This change is based on the LLVM RTDyldMemoryManager.cpp. It should later be changed to be alignment-safe. Reported by: dim Reviewed by: dim MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D8869 Modified: head/contrib/llvm/projects/libunwind/src/UnwindLevel1-gcc-ext.c Modified: head/contrib/llvm/projects/libunwind/src/UnwindLevel1-gcc-ext.c ============================================================================== --- head/contrib/llvm/projects/libunwind/src/UnwindLevel1-gcc-ext.c Wed Dec 21 11:34:16 2016 (r310364) +++ head/contrib/llvm/projects/libunwind/src/UnwindLevel1-gcc-ext.c Wed Dec 21 14:06:44 2016 (r310365) @@ -224,6 +224,47 @@ _LIBUNWIND_EXPORT uintptr_t _Unwind_GetI #if _LIBUNWIND_SUPPORT_DWARF_UNWIND +#ifdef __FreeBSD__ + +// Based on LLVM's lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp +// and XXX should be fixed to be alignment-safe. +static void processFDE(const char *addr, bool isDeregister) { + uint64_t length; + while ((length = *((const uint32_t *)addr)) != 0) { + const char *p = addr + 4; + if (length == 0xffffffff) { + length = *((const uint64_t *)p); + p += 8; + } + uint32_t offset = *((const uint32_t *)p); + if (offset != 0) { + if (isDeregister) + _unw_remove_dynamic_fde((unw_word_t)(uintptr_t)addr); + else + _unw_add_dynamic_fde((unw_word_t)(uintptr_t)addr); + } + addr = p + length; + } +} + +/// Called by programs with dynamic code generators that want to register +/// dynamically generated FDEs, with a libgcc-compatible API. + +_LIBUNWIND_EXPORT void __register_frame(const void *addr) { + _LIBUNWIND_TRACE_API("__register_frame(%p)", addr); + processFDE(addr, false); +} + +/// Called by programs with dynamic code generators that want to unregister +/// dynamically generated FDEs, with a libgcc-compatible API. +_LIBUNWIND_EXPORT void __deregister_frame(const void *addr) { + _LIBUNWIND_TRACE_API("__deregister_frame(%p)", addr); + processFDE(addr, true); +} + + +#else + /// Called by programs with dynamic code generators that want /// to register a dynamically generated FDE. /// This function has existed on Mac OS X since 10.4, but @@ -243,6 +284,7 @@ _LIBUNWIND_EXPORT void __deregister_fram _unw_remove_dynamic_fde((unw_word_t)(uintptr_t) fde); } +#endif // The following register/deregister functions are gcc extensions. // They have existed on Mac OS X, but have never worked because Mac OS X From owner-svn-src-head@freebsd.org Wed Dec 21 15:17:48 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B57D9C8A9FC; Wed, 21 Dec 2016 15:17:48 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 82C5514AB; Wed, 21 Dec 2016 15:17:48 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBLFHlDn012204; Wed, 21 Dec 2016 15:17:47 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBLFHl02012201; Wed, 21 Dec 2016 15:17:47 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201612211517.uBLFHl02012201@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 21 Dec 2016 15:17:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310366 - head/sys/cam/ctl X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Dec 2016 15:17:48 -0000 Author: mav Date: Wed Dec 21 15:17:47 2016 New Revision: 310366 URL: https://svnweb.freebsd.org/changeset/base/310366 Log: Add support for SITUA bit in Logical Block Provisioning mode page. VMware tries to enable this bit to avoid multiple threshold notifications in case of multiple initiators connected to the same LUN. Unfortunately their code sends MODE SELECT(6) request with parameter length hardcoded for the page without any thresholds. Since we have four threshold and our page is bigger, this attempt fails, that is correct in my understanding. So all we can do about this now is to report proper error code and hope VMware fix their code one day. MFC after: 2 weeks Modified: head/sys/cam/ctl/ctl.c head/sys/cam/ctl/ctl_error.c head/sys/cam/ctl/ctl_private.h Modified: head/sys/cam/ctl/ctl.c ============================================================================== --- head/sys/cam/ctl/ctl.c Wed Dec 21 14:06:44 2016 (r310365) +++ head/sys/cam/ctl/ctl.c Wed Dec 21 15:17:47 2016 (r310366) @@ -332,7 +332,7 @@ const static struct ctl_logical_block_pr /*page_code*/SMS_INFO_EXCEPTIONS_PAGE | SMPH_SPF, /*subpage_code*/0x02, /*page_length*/{CTL_LBPM_LEN >> 8, CTL_LBPM_LEN}, - /*flags*/0, + /*flags*/SLBPP_SITUA, /*reserved*/{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, /*descr*/{}}, {{/*flags*/0, @@ -6075,11 +6075,7 @@ do_next_page: * the mode page header, or if they didn't specify enough data in * the CDB to avoid truncating this page, kick out the request. */ - if ((page_len != (page_index->page_len - page_len_offset - - page_len_size)) - || (*len_left < page_index->page_len)) { - - + if (page_len != page_index->page_len - page_len_offset - page_len_size) { ctl_set_invalid_field(ctsio, /*sks_valid*/ 1, /*command*/ 0, @@ -6090,6 +6086,12 @@ do_next_page: ctl_done((union ctl_io *)ctsio); return (CTL_RETVAL_COMPLETE); } + if (*len_left < page_index->page_len) { + free(ctsio->kern_data_ptr, M_CTL); + ctl_set_param_len_error(ctsio); + ctl_done((union ctl_io *)ctsio); + return (CTL_RETVAL_COMPLETE); + } /* * Run through the mode page, checking to make sure that the bits @@ -9326,13 +9328,6 @@ ctl_request_sense(struct ctl_scsiio *cts ua_type = ctl_build_ua(lun, initidx, sense_ptr, sense_format); if (ua_type != CTL_UA_NONE) have_error = 1; - if (ua_type == CTL_UA_LUN_CHANGE) { - mtx_unlock(&lun->lun_lock); - mtx_lock(&softc->ctl_lock); - ctl_clr_ua_allluns(softc, initidx, ua_type); - mtx_unlock(&softc->ctl_lock); - mtx_lock(&lun->lun_lock); - } } if (have_error == 0) { /* Modified: head/sys/cam/ctl/ctl_error.c ============================================================================== --- head/sys/cam/ctl/ctl_error.c Wed Dec 21 14:06:44 2016 (r310365) +++ head/sys/cam/ctl/ctl_error.c Wed Dec 21 15:17:47 2016 (r310366) @@ -515,6 +515,7 @@ ctl_build_ua(struct ctl_lun *lun, uint32 uint32_t p, i; mtx_assert(&lun->lun_lock, MA_OWNED); + mtx_assert(&lun->ctl_softc->ctl_lock, MA_NOTOWNED); p = initidx / CTL_MAX_INIT_PER_PORT; if ((ua = lun->pending_ua[p]) == NULL) { mtx_unlock(&lun->lun_lock); @@ -547,6 +548,17 @@ ctl_build_ua(struct ctl_lun *lun, uint32 /* We're reporting this UA, so clear it */ ua[i] &= ~ua_to_clear; + if (ua_to_build == CTL_UA_LUN_CHANGE) { + mtx_unlock(&lun->lun_lock); + mtx_lock(&lun->ctl_softc->ctl_lock); + ctl_clr_ua_allluns(lun->ctl_softc, initidx, ua_to_build); + mtx_unlock(&lun->ctl_softc->ctl_lock); + mtx_lock(&lun->lun_lock); + } else if (ua_to_build == CTL_UA_THIN_PROV_THRES && + (lun->MODE_LBP.main.flags & SLBPP_SITUA) != 0) { + ctl_clr_ua_all(lun, -1, ua_to_build); + } + return (ua_to_build); } Modified: head/sys/cam/ctl/ctl_private.h ============================================================================== --- head/sys/cam/ctl/ctl_private.h Wed Dec 21 14:06:44 2016 (r310365) +++ head/sys/cam/ctl/ctl_private.h Wed Dec 21 15:17:47 2016 (r310366) @@ -290,7 +290,7 @@ static const struct ctl_page_index page_ CTL_PAGE_FLAG_ALL, NULL, ctl_ie_page_handler}, {SMS_INFO_EXCEPTIONS_PAGE | SMPH_SPF, 0x02, sizeof(struct ctl_logical_block_provisioning_page), NULL, - CTL_PAGE_FLAG_DIRECT, NULL, NULL}, + CTL_PAGE_FLAG_DIRECT, NULL, ctl_default_page_handler}, {SMS_CDDVD_CAPS_PAGE, 0, sizeof(struct scsi_cddvd_capabilities_page), NULL, CTL_PAGE_FLAG_CDROM, NULL, NULL}, From owner-svn-src-head@freebsd.org Wed Dec 21 15:27:00 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 453CDC8AF9E; Wed, 21 Dec 2016 15:27:00 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 14EBE1CA7; Wed, 21 Dec 2016 15:27:00 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBLFQxbk016213; Wed, 21 Dec 2016 15:26:59 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBLFQxca016212; Wed, 21 Dec 2016 15:26:59 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201612211526.uBLFQxca016212@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Wed, 21 Dec 2016 15:26:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310367 - head/bin/pax X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Dec 2016 15:27:00 -0000 Author: pfg Date: Wed Dec 21 15:26:59 2016 New Revision: 310367 URL: https://svnweb.freebsd.org/changeset/base/310367 Log: pax(1): Fix a bug with archives smaller than 512 bytes. The problem here is that the archive is too short (< 512 bytes). The buffer routines, try to read at least 512 bytes, even when we try to determine what format file we have, which is wrong. Obtained from: NetBSD (CVS rev 1.26) MFC after: 5 days Modified: head/bin/pax/buf_subs.c Modified: head/bin/pax/buf_subs.c ============================================================================== --- head/bin/pax/buf_subs.c Wed Dec 21 15:17:47 2016 (r310366) +++ head/bin/pax/buf_subs.c Wed Dec 21 15:26:59 2016 (r310367) @@ -852,10 +852,13 @@ buf_fill(void) /* * errors require resync, EOF goes to next archive + * but in case we have not determined yet the format, + * this means that we have a very short file, so we + * are done again. */ if (cnt < 0) break; - if (ar_next() < 0) { + if (frmt == NULL || ar_next() < 0) { fini = 1; return(0); } From owner-svn-src-head@freebsd.org Wed Dec 21 15:45:24 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B13CFC8A68D; Wed, 21 Dec 2016 15:45:24 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 757DA1BD3; Wed, 21 Dec 2016 15:45:24 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBLFjNMj024758; Wed, 21 Dec 2016 15:45:23 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBLFjNgp024757; Wed, 21 Dec 2016 15:45:23 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201612211545.uBLFjNgp024757@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Wed, 21 Dec 2016 15:45:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310371 - head/sys/dev/bhnd/tools X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Dec 2016 15:45:24 -0000 Author: emaste Date: Wed Dec 21 15:45:23 2016 New Revision: 310371 URL: https://svnweb.freebsd.org/changeset/base/310371 Log: bhnd: remove srand() to ensure deterministic output r310342 fixed non-deterministic nvram_map_gen.awk output and thus a non- reproducible bhnd(4) build by using a unique sort key. Go one step further and also remove the srand() call. There's no reason we want non-deterministic behaviour from this script. PR: 215422 Reported by: gjb (non-reproducibility of bhnd) Reported by: lidl (srand as the cause) Reviewed by: landonf Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D8857 Modified: head/sys/dev/bhnd/tools/nvram_map_gen.awk Modified: head/sys/dev/bhnd/tools/nvram_map_gen.awk ============================================================================== --- head/sys/dev/bhnd/tools/nvram_map_gen.awk Wed Dec 21 15:40:16 2016 (r310370) +++ head/sys/dev/bhnd/tools/nvram_map_gen.awk Wed Dec 21 15:45:23 2016 (r310371) @@ -52,9 +52,6 @@ function main(_i) { AWK_REQ_HEX_PARSING=1 } - # Seed rand() - srand() - # Output type OUT_T = null OUT_T_HEADER = "HEADER" From owner-svn-src-head@freebsd.org Wed Dec 21 16:04:22 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E1C02C8AEDA; Wed, 21 Dec 2016 16:04:22 +0000 (UTC) (envelope-from rb743@hermes.cam.ac.uk) Received: from ppsw-43.csi.cam.ac.uk (ppsw-43.csi.cam.ac.uk [131.111.8.143]) by mx1.freebsd.org (Postfix) with ESMTP id AD3EE18FF; Wed, 21 Dec 2016 16:04:22 +0000 (UTC) (envelope-from rb743@hermes.cam.ac.uk) X-Cam-AntiVirus: no malware found X-Cam-ScannerInfo: http://help.uis.cam.ac.uk/email-scanner-virus Received: from sc1.bsdpad.com ([163.172.212.18]:16575) by ppsw-43.csi.cam.ac.uk (smtp.hermes.cam.ac.uk [131.111.8.159]:587) with esmtpsa (LOGIN:rb743) (TLSv1:ECDHE-RSA-AES256-SHA:256) id 1cJjNH-000328-mT (Exim 4.86_36-e07b163) (return-path ); Wed, 21 Dec 2016 16:04:15 +0000 Date: Wed, 21 Dec 2016 16:02:53 +0000 From: Ruslan Bukin To: John Baldwin Cc: Ruslan Bukin , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r310330 - in head: share/man/man4 sys/conf sys/dev/xdma Message-ID: <20161221160253.GA4455@bsdpad.com> References: <201612201802.uBKI27oN091165@repo.freebsd.org> <1904181.V85ZRTRTAB@ralph.baldwin.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1904181.V85ZRTRTAB@ralph.baldwin.cx> User-Agent: Mutt/1.6.1 (2016-04-27) Sender: "R. Bukin" X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Dec 2016 16:04:23 -0000 On Tue, Dec 20, 2016 at 12:50:11PM -0800, John Baldwin wrote: > On Tuesday, December 20, 2016 06:02:07 PM Ruslan Bukin wrote: > > Author: br > > Date: Tue Dec 20 18:02:07 2016 > > New Revision: 310330 > > URL: https://svnweb.freebsd.org/changeset/base/310330 > > > > Log: > > Add xDMA -- the DMA abstraction layer, initial verison. > > > > xDMA is a DMA framework designed to abstract the interaction > > between device drivers and DMA engines. > > > > Project wiki: https://wiki.freebsd.org/xdma > > > > Sponsored by: DARPA, AFRL > > Differential Revision: https://reviews.freebsd.org/D8807 > > It probably would have been a good idea to get some design review of this on > arch@ before committing. In particular, I believe from earlier discussions > that you want to build a general framework that things like ioat(4) can hook > into. arch@ would give you a broader audience for working out the > abstractions and interfaces. > Yep, you probably right. I found lack of interest from the list of reviewers I added on phabricator, so decided to go, but may be list was not 100% pervasive. Anyway it is just 673 lines of code and I continue working on it. I plan to add scatter-gathering type of transfer and SoftDMA(®) driver, so any review of this or upcoming changes would be appreciated. Ruslan From owner-svn-src-head@freebsd.org Wed Dec 21 17:32:08 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D2439C8A745; Wed, 21 Dec 2016 17:32:08 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: from mail-wj0-x22b.google.com (mail-wj0-x22b.google.com [IPv6:2a00:1450:400c:c01::22b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7B9A11324; Wed, 21 Dec 2016 17:32:08 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: by mail-wj0-x22b.google.com with SMTP id xy5so208075321wjc.0; Wed, 21 Dec 2016 09:32:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=SgPdBKpVTOKs72eaqztjUX7CoJfIYmIIFBR/xGw7QFM=; b=nCZVXyRwFOQBO+1p4IPnszJCr4MgsP1NuzivwRtgW4DTVgor5TGWDkLnzuljaE3gh6 rUj6cMaIAyqkdo5etgG2410MdOqxBNG6cp2lx8SCtWDj/UEQATcXtt110SHFE3laRtMn t1u07fLOz/tijCXmi3rnvELLE7g44t8ay3ph1pr4KHjfP20zvKzQNxlfbmVKs16K8eXo kEQ0NIdfwR/wqvrFMJuIuqRThLlg+ii51uFuKvTtJ2DfnkQhUOq9eod0a1otV50FXg2v GrDORDEtRraP96tYbsHPMUcPrfzOa1DXHn6nbVgTlOwZOKe/RVA+VuDpd8/GITOR4/Kz cYCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=SgPdBKpVTOKs72eaqztjUX7CoJfIYmIIFBR/xGw7QFM=; b=Ux/UlsJttYxEtTQb3RbRS/38gL1wENV0Jfq7g3tjEjmV3FCh5XR61iO5qQTyoRl/5T Zz2DhhUHxtaoaP9tLCmT+/QnxNgOP4aLgNzwMeHvfxnnLVHENb4JPqFskxJJEoXirIYU tNPETgU1CDdxGUZ/8m0ImVXCfYEwJvB4dxvVkA8RaWdzvfDGavNf3tw80xPZBO3/BX3F BHGRIvODIKH3r+F2T/XjRKIhGe5N9qf6kuH9utGMtVtBommLuiH+73xXF116gdwD8bFT M5x5m/TLhULSJRpbLImtcb1UrZmig5Ynw4EllN1f4h60O2j17zlBBm/D/cVt3T/UuOmE 40aQ== X-Gm-Message-State: AIkVDXK7gf3l6s6gzPiLs4FJFfPR6xc+NLCF6Q3cTUCQnjZ3wtDoSIWoRQd+TG6wfXjsGbe+dNCzvSvs4Xo7dw== X-Received: by 10.194.205.34 with SMTP id ld2mr5339983wjc.211.1482341525673; Wed, 21 Dec 2016 09:32:05 -0800 (PST) MIME-Version: 1.0 Received: by 10.194.44.1 with HTTP; Wed, 21 Dec 2016 09:32:05 -0800 (PST) In-Reply-To: <201612210829.uBL8Tijt041811@repo.freebsd.org> References: <201612210829.uBL8Tijt041811@repo.freebsd.org> From: Adrian Chadd Date: Wed, 21 Dec 2016 09:32:05 -0800 Message-ID: Subject: Re: svn commit: r310354 - in head/usr.sbin: . prometheus_sysctl_exporter To: Ed Schouten Cc: "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Dec 2016 17:32:08 -0000 heh, in an ideal world we'd not call this "prometheus", it'd just be the way we export sysctl data via 'sysctl' in a machine parsable format. Ok, since it's HTTP/gzip, maybe a separate standalone program is cool, but it doesn't have to be specific to prometheus. :-) That way anyone wanting to write a plugin for consuming freebsd data can just use this program as the API contract. Maybe just "sysctl_export" would be fine. I'd like to encourage other consumers to use it, including existing ones that currently do all the silly hijinx. :) What do you think? -adrian On 21 December 2016 at 00:29, Ed Schouten wrote: > Author: ed > Date: Wed Dec 21 08:29:44 2016 > New Revision: 310354 > URL: https://svnweb.freebsd.org/changeset/base/310354 > > Log: > Add a Prometheus exporter for sysctl values. > > Now that we have our sysctl tree annotated with aggregation labels, > let's go ahead and provide a very simple utility for exporting the > sysctl tree in Prometheus' format. It can either be used in conjunction > with the Prometheus node exporter or run through inetd(8). > > The reason why I'm opting for having it in the base system is because it > has a pretty strong integration with some of sysctl's innards, such as > access to iterators, name lookups, metadata and type information. As I > am investigating whether we can add histograms as native types to sysctl > as well, this integration will only get stronger as we go along. That's > why it would be safer to oversee the development of this exporter > ourselves, as opposed to having it as an external project. > > This exporter is remarkably compact, especially when compared to the > official Linux binary of the Prometheus node exporter (16 KB vs 12 MB). > I guess this could be an interesting aspect for monitoring embedded > FreeBSD-based systems. > > Differential Revision: https://reviews.freebsd.org/D8792 > > Added: > head/usr.sbin/prometheus_sysctl_exporter/ > head/usr.sbin/prometheus_sysctl_exporter/Makefile (contents, props changed) > head/usr.sbin/prometheus_sysctl_exporter/prometheus_sysctl_exporter.8 (contents, props changed) > head/usr.sbin/prometheus_sysctl_exporter/prometheus_sysctl_exporter.c (contents, props changed) > Modified: > head/usr.sbin/Makefile > > Modified: head/usr.sbin/Makefile > ============================================================================== > --- head/usr.sbin/Makefile Wed Dec 21 07:26:04 2016 (r310353) > +++ head/usr.sbin/Makefile Wed Dec 21 08:29:44 2016 (r310354) > @@ -62,6 +62,7 @@ SUBDIR= adduser \ > periodic \ > powerd \ > procctl \ > + prometheus_sysctl_exporter \ > pstat \ > pw \ > pwd_mkdb \ > > Added: head/usr.sbin/prometheus_sysctl_exporter/Makefile > ============================================================================== > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > +++ head/usr.sbin/prometheus_sysctl_exporter/Makefile Wed Dec 21 08:29:44 2016 (r310354) > @@ -0,0 +1,8 @@ > +# $FreeBSD$ > + > +PROG= prometheus_sysctl_exporter > +MAN= prometheus_sysctl_exporter.8 > + > +LIBADD= m z > + > +.include > > Added: head/usr.sbin/prometheus_sysctl_exporter/prometheus_sysctl_exporter.8 > ============================================================================== > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > +++ head/usr.sbin/prometheus_sysctl_exporter/prometheus_sysctl_exporter.8 Wed Dec 21 08:29:44 2016 (r310354) > @@ -0,0 +1,106 @@ > +.\" Copyright (c) 2016 Nuxi, https://nuxi.nl/ > +.\" > +.\" Redistribution and use in source and binary forms, with or without > +.\" modification, are permitted provided that the following conditions > +.\" are met: > +.\" 1. Redistributions of source code must retain the above copyright > +.\" notice, this list of conditions and the following disclaimer. > +.\" 2. Redistributions in binary form must reproduce the above copyright > +.\" notice, this list of conditions and the following disclaimer in the > +.\" documentation and/or other materials provided with the distribution. > +.\" > +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > +.\" SUCH DAMAGE. > +.\" > +.\" $FreeBSD$ > +.Dd December 18, 2016 > +.Dt PROMETHEUS_SYSCTL_EXPORTER 8 > +.Os > +.Sh NAME > +.Nm prometheus_sysctl_exporter > +.Nd print kernel state as Prometheus metrics > +.Sh SYNOPSIS > +.Nm prometheus_sysctl_exporter > +.Op Fl dgh > +.Op Ar prefix ... > +.Sh DESCRIPTION > +Prometheus is a monitoring system that gathers metrics from its targets > +by fetching them through HTTP GET requests. > +Metrics are identified by a name and an optional set of labels. > +Sample values are required to be numerical. > +.Pp > +The > +.Nm > +utility prints the values of sysctl nodes to standard output, > +formatted such that they can be scraped by Prometheus directly. > +By default, > +it prints metrics for all numerically representable nodes in the sysctl > +namespace. > +It is also possible to limit output to a smaller number of metrics by > +specifying one or more prefixes as arguments. > +.Pp > +Metrics printed by this utility are named > +.Ql sysctl_ , > +followed by the name of the sysctl node having its > +.Ql .\& > +separators replaced by > +.Ql _ . > +Components on which it is desirable to aggregate (e.g., > +names of devices) are omitted from the metric's name, > +but are appended as labels instead. > +.Pp > +There are two different methods for exporting the output of > +.Nm > +to Prometheus. > +The first method is to periodically invoke this utility through > +.Xr cron 8 > +and store its output in a textfile. > +The metrics in this textfile can then be served over HTTP using the > +Prometheus node exporter's textfile collector. > +The second method is to run this utility through > +.Xr inetd 8 . > +TCP port 9124 has been allocated for this purpose. > +.Pp > +The following options are available: > +.Bl -tag -width indent > +.It Fl d > +Print descriptions of metrics when available. > +.It Fl g > +Gzip compresses the HTTP response body. > +.It Fl h > +Precede the output with a HTTP response header. > +This flag is required when running this utility through > +.Xr inetd 8 . > +.El > +.Sh SEE ALSO > +.Xr cron 8 , > +.Xr inetd 8 , > +.Xr sysctl 8 , > +.Xr SYSCTL_ADD_NODE_WITH_LABEL 9 > +.Pp > +Prometheus project: > +.Pa https://prometheus.io/ . > +.Pp > +Prometheus exposition formats: > +.Pa https://prometheus.io/docs/instrumenting/exposition_formats/ . > +.Pp > +Prometheus node exporter: > +.Pa https://github.com/prometheus/node_exporter . > +.Pp > +Prometheus default port allocations: > +.Pa https://github.com/prometheus/prometheus/wiki/Default-port-allocations . > +.Sh HISTORY > +.Nm > +first appeared in > +.Fx 12.0 . > +.Sh AUTHORS > +.An Nuxi : Pa https://nuxi.nl/ . > > Added: head/usr.sbin/prometheus_sysctl_exporter/prometheus_sysctl_exporter.c > ============================================================================== > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > +++ head/usr.sbin/prometheus_sysctl_exporter/prometheus_sysctl_exporter.c Wed Dec 21 08:29:44 2016 (r310354) > @@ -0,0 +1,652 @@ > +/*- > + * Copyright (c) 2016 Nuxi, https://nuxi.nl/ > + * > + * Redistribution and use in source and binary forms, with or without > + * modification, are permitted provided that the following conditions > + * are met: > + * 1. Redistributions of source code must retain the above copyright > + * notice, this list of conditions and the following disclaimer. > + * 2. Redistributions in binary form must reproduce the above copyright > + * notice, this list of conditions and the following disclaimer in the > + * documentation and/or other materials provided with the distribution. > + * > + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > + * SUCH DAMAGE. > + */ > + > +#include > +__FBSDID("$FreeBSD$"); > + > +#include > +#include > +#include > +#include > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +/* > + * Cursor for iterating over all of the system's sysctl OIDs. > + */ > +struct oid { > + int id[CTL_MAXNAME]; > + size_t len; > +}; > + > +/* Initializes the cursor to point to start of the tree. */ > +static void > +oid_get_root(struct oid *o) > +{ > + > + o->id[0] = 1; > + o->len = 1; > +} > + > +/* Obtains the OID for a sysctl by name. */ > +static void > +oid_get_by_name(struct oid *o, const char *name) > +{ > + > + o->len = nitems(o->id); > + if (sysctlnametomib(name, o->id, &o->len) != 0) > + err(1, "sysctl(%s)", name); > +} > + > +/* Returns whether an OID is placed below another OID. */ > +static bool > +oid_is_beneath(struct oid *oa, struct oid *ob) > +{ > + > + return (oa->len >= ob->len && > + memcmp(oa->id, ob->id, ob->len * sizeof(oa->id[0])) == 0); > +} > + > +/* Advances the cursor to the next OID. */ > +static bool > +oid_get_next(const struct oid *cur, struct oid *next) > +{ > + int lookup[CTL_MAXNAME + 2]; > + size_t nextsize; > + > + lookup[0] = 0; > + lookup[1] = 2; > + memcpy(lookup + 2, cur->id, cur->len * sizeof(lookup[0])); > + nextsize = sizeof(next->id); > + if (sysctl(lookup, 2 + cur->len, &next->id, &nextsize, 0, 0) != 0) { > + if (errno == ENOENT) > + return (false); > + err(1, "sysctl(next)"); > + } > + next->len = nextsize / sizeof(next->id[0]); > + return (true); > +} > + > +/* > + * OID formatting metadata. > + */ > +struct oidformat { > + unsigned int kind; > + char format[BUFSIZ]; > +}; > + > +/* Returns whether the OID represents a temperature value. */ > +static bool > +oidformat_is_temperature(const struct oidformat *of) > +{ > + > + return (of->format[0] == 'I' && of->format[1] == 'K'); > +} > + > +/* Returns whether the OID represents a timeval structure. */ > +static bool > +oidformat_is_timeval(const struct oidformat *of) > +{ > + > + return (strcmp(of->format, "S,timeval") == 0); > +} > + > +/* Fetches the formatting metadata for an OID. */ > +static bool > +oid_get_format(const struct oid *o, struct oidformat *of) > +{ > + int lookup[CTL_MAXNAME + 2]; > + size_t oflen; > + > + lookup[0] = 0; > + lookup[1] = 4; > + memcpy(lookup + 2, o->id, o->len * sizeof(lookup[0])); > + oflen = sizeof(*of); > + if (sysctl(lookup, 2 + o->len, of, &oflen, 0, 0) != 0) { > + if (errno == ENOENT) > + return (false); > + err(1, "sysctl(oidfmt)"); > + } > + return (true); > +} > + > +/* > + * Container for holding the value of an OID. > + */ > +struct oidvalue { > + enum { SIGNED, UNSIGNED, FLOAT } type; > + union { > + intmax_t s; > + uintmax_t u; > + double f; > + } value; > +}; > + > +/* Extracts the value of an OID, converting it to a floating-point number. */ > +static double > +oidvalue_get_float(const struct oidvalue *ov) > +{ > + > + switch (ov->type) { > + case SIGNED: > + return (ov->value.s); > + case UNSIGNED: > + return (ov->value.u); > + case FLOAT: > + return (ov->value.f); > + default: > + assert(0 && "Unknown value type"); > + } > +} > + > +/* Sets the value of an OID as a signed integer. */ > +static void > +oidvalue_set_signed(struct oidvalue *ov, intmax_t s) > +{ > + > + ov->type = SIGNED; > + ov->value.s = s; > +} > + > +/* Sets the value of an OID as an unsigned integer. */ > +static void > +oidvalue_set_unsigned(struct oidvalue *ov, uintmax_t u) > +{ > + > + ov->type = UNSIGNED; > + ov->value.u = u; > +} > + > +/* Sets the value of an OID as a floating-point number. */ > +static void > +oidvalue_set_float(struct oidvalue *ov, double f) > +{ > + > + ov->type = FLOAT; > + ov->value.f = f; > +} > + > +/* Prints the value of an OID to a file stream. */ > +static void > +oidvalue_print(const struct oidvalue *ov, FILE *fp) > +{ > + > + switch (ov->type) { > + case SIGNED: > + fprintf(fp, "%jd", ov->value.s); > + break; > + case UNSIGNED: > + fprintf(fp, "%ju", ov->value.u); > + break; > + case FLOAT: > + switch (fpclassify(ov->value.f)) { > + case FP_INFINITE: > + if (signbit(ov->value.f)) > + fprintf(fp, "-Inf"); > + else > + fprintf(fp, "+Inf"); > + break; > + case FP_NAN: > + fprintf(fp, "Nan"); > + break; > + default: > + fprintf(fp, "%.6f", ov->value.f); > + break; > + } > + break; > + } > +} > + > +/* Fetches the value of an OID. */ > +static bool > +oid_get_value(const struct oid *o, const struct oidformat *of, > + struct oidvalue *ov) > +{ > + > + switch (of->kind & CTLTYPE) { > +#define GET_VALUE(ctltype, type) \ > + case (ctltype): { \ > + type value; \ > + size_t valuesize; \ > + \ > + valuesize = sizeof(value); \ > + if (sysctl(o->id, o->len, &value, &valuesize, 0, 0) != 0) \ > + return (false); \ > + if ((type)-1 > 0) \ > + oidvalue_set_unsigned(ov, value); \ > + else \ > + oidvalue_set_signed(ov, value); \ > + break; \ > + } > + GET_VALUE(CTLTYPE_INT, int); > + GET_VALUE(CTLTYPE_UINT, unsigned int); > + GET_VALUE(CTLTYPE_LONG, long); > + GET_VALUE(CTLTYPE_ULONG, unsigned long); > + GET_VALUE(CTLTYPE_S8, int8_t); > + GET_VALUE(CTLTYPE_U8, uint8_t); > + GET_VALUE(CTLTYPE_S16, int16_t); > + GET_VALUE(CTLTYPE_U16, uint16_t); > + GET_VALUE(CTLTYPE_S32, int32_t); > + GET_VALUE(CTLTYPE_U32, uint32_t); > + GET_VALUE(CTLTYPE_S64, int64_t); > + GET_VALUE(CTLTYPE_U64, uint64_t); > +#undef GET_VALUE > + case CTLTYPE_OPAQUE: > + if (oidformat_is_timeval(of)) { > + struct timeval tv; > + size_t tvsize; > + > + tvsize = sizeof(tv); > + if (sysctl(o->id, o->len, &tv, &tvsize, 0, 0) != 0) > + return (false); > + oidvalue_set_float(ov, > + (double)tv.tv_sec + (double)tv.tv_usec / 1000000); > + return (true); > + } else if (strcmp(of->format, "S,loadavg") == 0) { > + struct loadavg la; > + size_t lasize; > + > + /* > + * Only return the one minute load average, as > + * the others can be inferred using avg_over_time(). > + */ > + lasize = sizeof(la); > + if (sysctl(o->id, o->len, &la, &lasize, 0, 0) != 0) > + return (false); > + oidvalue_set_float(ov, > + (double)la.ldavg[0] / (double)la.fscale); > + return (true); > + } > + return (false); > + default: > + return (false); > + } > + > + /* Convert temperatures from decikelvin to degrees Celcius. */ > + if (oidformat_is_temperature(of)) { > + double v; > + int e; > + > + v = oidvalue_get_float(ov); > + if (v < 0) { > + oidvalue_set_float(ov, NAN); > + } else { > + e = of->format[2] >= '0' && of->format[2] <= '9' ? > + of->format[2] - '0' : 1; > + oidvalue_set_float(ov, v / pow(10, e) - 273.15); > + } > + } > + return (true); > +} > + > +/* > + * The full name of an OID, stored as a series of components. > + */ > +struct oidname { > + struct oid oid; > + char names[BUFSIZ]; > + char labels[BUFSIZ]; > +}; > + > +/* > + * Initializes the OID name object with an empty value. > + */ > +static void > +oidname_init(struct oidname *on) > +{ > + > + on->oid.len = 0; > +} > + > +/* Fetches the name and labels of an OID, reusing the previous results. */ > +static void > +oid_get_name(const struct oid *o, struct oidname *on) > +{ > + int lookup[CTL_MAXNAME + 2]; > + char *c, *label; > + size_t i, len; > + > + /* Fetch the name and split it up in separate components. */ > + lookup[0] = 0; > + lookup[1] = 1; > + memcpy(lookup + 2, o->id, o->len * sizeof(lookup[0])); > + len = sizeof(on->names); > + if (sysctl(lookup, 2 + o->len, on->names, &len, 0, 0) != 0) > + err(1, "sysctl(name)"); > + for (c = strchr(on->names, '.'); c != NULL; c = strchr(c + 1, '.')) > + *c = '\0'; > + > + /* No need to fetch labels for components that we already have. */ > + label = on->labels; > + for (i = 0; i < o->len && i < on->oid.len && o->id[i] == on->oid.id[i]; > + ++i) > + label += strlen(label) + 1; > + > + /* Fetch the remaining labels. */ > + lookup[1] = 6; > + for (; i < o->len; ++i) { > + len = on->labels + sizeof(on->labels) - label; > + if (sysctl(lookup, 2 + i + 1, label, &len, 0, 0) == 0) { > + label += len; > + } else if (errno == ENOENT) { > + *label++ = '\0'; > + } else { > + err(1, "sysctl(oidlabel)"); > + } > + } > + on->oid = *o; > +} > + > +/* Prints the name and labels of an OID to a file stream. */ > +static void > +oidname_print(const struct oidname *on, const struct oidformat *of, > + FILE *fp) > +{ > + const char *name, *label; > + size_t i; > + char separator; > + > + /* Print the name of the metric. */ > + fprintf(fp, "sysctl"); > + name = on->names; > + label = on->labels; > + for (i = 0; i < on->oid.len; ++i) { > + if (*label == '\0') { > + assert(name[strspn(name, > + "abcdefghijklmnopqrstuvwxyz" > + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" > + "0123456789_")] == '\0'); > + fprintf(fp, "_%s", name); > + } > + name += strlen(name) + 1; > + label += strlen(label) + 1; > + } > + if (oidformat_is_temperature(of)) > + fprintf(fp, "_celcius"); > + else if (oidformat_is_timeval(of)) > + fprintf(fp, "_seconds"); > + > + /* Print the labels of the metric. */ > + name = on->names; > + label = on->labels; > + separator = '{'; > + for (i = 0; i < on->oid.len; ++i) { > + if (*label != '\0') { > + assert(name[strspn(name, > + "abcdefghijklmnopqrstuvwxyz" > + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" > + "0123456789_-")] == '\0'); > + assert(label[strspn(label, > + "abcdefghijklmnopqrstuvwxyz" > + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" > + "0123456789_")] == '\0'); > + fprintf(fp, "%c%s=\"%s\"", separator, label, name); > + separator = ','; > + } > + name += strlen(name) + 1; > + label += strlen(label) + 1; > + } > + if (separator != '{') > + fputc('}', fp); > +} > + > +/* Returns whether the OID name has any labels associated to it. */ > +static bool > +oidname_has_labels(const struct oidname *on) > +{ > + size_t i; > + > + for (i = 0; i < on->oid.len; ++i) > + if (on->labels[i] != 0) > + return (true); > + return (false); > +} > + > +/* > + * The description of an OID. > + */ > +struct oiddescription { > + char description[BUFSIZ]; > +}; > + > +/* > + * Fetches the description of an OID. > + */ > +static bool > +oid_get_description(const struct oid *o, struct oiddescription *od) > +{ > + int lookup[CTL_MAXNAME + 2]; > + char *newline; > + size_t odlen; > + > + lookup[0] = 0; > + lookup[1] = 5; > + memcpy(lookup + 2, o->id, o->len * sizeof(lookup[0])); > + odlen = sizeof(od->description); > + if (sysctl(lookup, 2 + o->len, &od->description, &odlen, 0, 0) != 0) { > + if (errno == ENOENT) > + return (false); > + err(1, "sysctl(oiddescr)"); > + } > + > + newline = strchr(od->description, '\n'); > + if (newline != NULL) > + *newline = '\0'; > + > + return (*od->description != '\0'); > +} > + > +/* Prints the description of an OID to a file stream. */ > +static void > +oiddescription_print(const struct oiddescription *od, FILE *fp) > +{ > + > + fprintf(fp, "%s", od->description); > +} > + > +static void > +oid_print(const struct oid *o, struct oidname *on, bool print_description, > + FILE *fp) > +{ > + struct oidformat of; > + struct oidvalue ov; > + struct oiddescription od; > + > + if (!oid_get_format(o, &of) || !oid_get_value(o, &of, &ov)) > + return; > + oid_get_name(o, on); > + > + /* > + * Print the line with the description. Prometheus expects a > + * single unique description for every metric, which cannot be > + * guaranteed by sysctl if labels are present. Omit the > + * description if labels are present. > + */ > + if (print_description && !oidname_has_labels(on) && > + oid_get_description(o, &od)) { > + fprintf(fp, "# HELP "); > + oidname_print(on, &of, fp); > + fputc(' ', fp); > + oiddescription_print(&od, fp); > + fputc('\n', fp); > + } > + > + /* Print the line with the value. */ > + oidname_print(on, &of, fp); > + fputc(' ', fp); > + oidvalue_print(&ov, fp); > + fputc('\n', fp); > +} > + > +/* Gzip compresses a buffer of memory. */ > +static bool > +buf_gzip(const char *in, size_t inlen, char *out, size_t *outlen) > +{ > + z_stream stream = { > + .next_in = __DECONST(unsigned char *, in), > + .avail_in = inlen, > + .next_out = (unsigned char *)out, > + .avail_out = *outlen, > + }; > + > + if (deflateInit2(&stream, Z_DEFAULT_COMPRESSION, Z_DEFLATED, > + MAX_WBITS + 16, 8, Z_DEFAULT_STRATEGY) != Z_OK || > + deflate(&stream, Z_FINISH) != Z_STREAM_END) { > + return (false); > + } > + *outlen = stream.total_out; > + return (deflateEnd(&stream) == Z_OK); > +} > + > +static void > +usage(void) > +{ > + > + fprintf(stderr, > + "usage: prometheus_sysctl_exporter [-dgh] [prefix ...]\n"); > + exit(1); > +} > + > +int > +main(int argc, char *argv[]) > +{ > + struct oidname on; > + char *http_buf; > + FILE *fp; > + size_t http_buflen; > + int ch; > + bool gzip_mode, http_mode, print_descriptions; > + > + /* Parse command line flags. */ > + gzip_mode = http_mode = print_descriptions = false; > + while ((ch = getopt(argc, argv, "dgh")) != -1) { > + switch (ch) { > + case 'd': > + print_descriptions = true; > + break; > + case 'g': > + gzip_mode = true; > + break; > + case 'h': > + http_mode = true; > + break; > + default: > + usage(); > + } > + } > + argc -= optind; > + argv += optind; > + > + /* HTTP output: cache metrics in buffer. */ > + if (http_mode) { > + fp = open_memstream(&http_buf, &http_buflen); > + if (fp == NULL) > + err(1, "open_memstream"); > + } else { > + fp = stdout; > + } > + > + oidname_init(&on); > + if (argc == 0) { > + struct oid o; > + > + /* Print all OIDs. */ > + oid_get_root(&o); > + do { > + oid_print(&o, &on, print_descriptions, fp); > + } while (oid_get_next(&o, &o)); > + } else { > + int i; > + > + /* Print only trees provided as arguments. */ > + for (i = 0; i < argc; ++i) { > + struct oid o, root; > + > + oid_get_by_name(&root, argv[i]); > + o = root; > + do { > + oid_print(&o, &on, print_descriptions, fp); > + } while (oid_get_next(&o, &o) && > + oid_is_beneath(&o, &root)); > + } > + } > + > + if (http_mode) { > + const char *content_encoding = ""; > + > + if (ferror(fp) || fclose(fp) != 0) > + err(1, "Cannot generate output"); > + > + /* Gzip compress the output. */ > + if (gzip_mode) { > + char *buf; > + size_t buflen; > + > + buflen = http_buflen; > + buf = malloc(buflen); > + if (buf == NULL) > + err(1, "Cannot allocate compression buffer"); > + if (buf_gzip(http_buf, http_buflen, buf, &buflen)) { > + content_encoding = "Content-Encoding: gzip\r\n"; > + free(http_buf); > + http_buf = buf; > + http_buflen = buflen; > + } else { > + free(buf); > + } > + } > + > + /* Print HTTP header and metrics. */ > + dprintf(STDOUT_FILENO, > + "HTTP/1.1 200 OK\r\n" > + "Connection: close\r\n" > + "%s" > + "Content-Length: %zu\r\n" > + "Content-Type: text/plain; version=0.0.4\r\n" > + "\r\n", > + content_encoding, http_buflen); > + write(STDOUT_FILENO, http_buf, http_buflen); > + free(http_buf); > + > + /* Drain output. */ > + if (shutdown(STDIN_FILENO, SHUT_WR) == 0) { > + char buf[1024]; > + > + while (read(STDIN_FILENO, buf, sizeof(buf)) > 0) { > + } > + } > + } > + return (0); > +} > From owner-svn-src-head@freebsd.org Wed Dec 21 18:04:57 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0C38BC8A0B6; Wed, 21 Dec 2016 18:04:57 +0000 (UTC) (envelope-from biancalana@gmail.com) Received: from mail-it0-x22f.google.com (mail-it0-x22f.google.com [IPv6:2607:f8b0:4001:c0b::22f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C740E13C6; Wed, 21 Dec 2016 18:04:56 +0000 (UTC) (envelope-from biancalana@gmail.com) Received: by mail-it0-x22f.google.com with SMTP id 75so84466536ite.1; Wed, 21 Dec 2016 10:04:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=f3jsIBrMisGK9X9ii5Tlg7l9dT018oavrSqbnbr7geg=; b=X+pZWPXfVHq3D2V5ra1LgQJpOVgd01sOIVB/eko9VITqqML5lbbopcmYbgC2cJ1fBP UcSCX/hJjFzcmvv/T3LmSsGx0hplAX1FjD7/UjbDREqU9hy/sFl1CMBPkcNrAXCdvku6 D1SGY1KYb1Mk4S/YW5qT55SizoL1mCSL/oFFExxoWBtIOsLvxyVSXLoWRTg//vJHgeZM 0rXeGOXqmgewu5avPjhWRTOTIAv7fCBMwq+etKYnkzCiNrI/+YRxReddAcey1BmSkM1q V/c1nDY12Ls+ChMm1UgHvjyrYkxDjTY3ICwJBnTKOsmrGutjJaHU4dV3/FT73ZUiu20o pj1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=f3jsIBrMisGK9X9ii5Tlg7l9dT018oavrSqbnbr7geg=; b=I5TPEwwZloGMBXRre/fe8N9ZxC4lcTJbWLDpGeKu/uKb9a+6+fgydvwmcJ1oxz2w36 /PL/ysBOCWpD2Z7Rr9KelNxDG8VYqr+J9a/HcoGQxyIzj0cebxa5AFsiA2OIaugtHwO0 cZvSdGE6Vlgr+llTV/41vJVU5jNQ7tFsowl0Z1Wc7cC4EhFvW5BiZEC+QU3+T9rnDJmj 0+2FWlPa3WqwsDFExmLYMWUshYrv3/8mRyR4BK8GhlSMy7NYwT9QqGBbprZ/juP680YF ES0YKLHfQGJyzjDGQsjdBc5yqiLRB61Nn1revaRzIdqwcLD3Q3dUDaSY/93QBtySqG8p skWQ== X-Gm-Message-State: AIkVDXIP3I2O/iNPnoPrGi7wZAYXToSupmU4Ne1/2qxajGmZc9OLmqh/bClVJkrIvsjcKgvvupSEDtnRiRB1xg== X-Received: by 10.36.133.133 with SMTP id r127mr8776889itd.37.1482343495080; Wed, 21 Dec 2016 10:04:55 -0800 (PST) MIME-Version: 1.0 Received: by 10.64.207.225 with HTTP; Wed, 21 Dec 2016 10:04:54 -0800 (PST) In-Reply-To: References: <201612210829.uBL8Tijt041811@repo.freebsd.org> From: Alexandre Biancalana Date: Wed, 21 Dec 2016 16:04:54 -0200 Message-ID: Subject: Re: svn commit: r310354 - in head/usr.sbin: . prometheus_sysctl_exporter To: Adrian Chadd Cc: Ed Schouten , "svn-src-head@freebsd.org" , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Dec 2016 18:04:57 -0000 +1 On Wed, Dec 21, 2016 at 3:32 PM, Adrian Chadd wrote: > heh, > > in an ideal world we'd not call this "prometheus", it'd just be the > way we export sysctl data via 'sysctl' in a machine parsable format. > Ok, since it's HTTP/gzip, maybe a separate standalone program is cool, > but it doesn't have to be specific to prometheus. :-) > > That way anyone wanting to write a plugin for consuming freebsd data > can just use this program as the API contract. > > Maybe just "sysctl_export" would be fine. I'd like to encourage other > consumers to use it, including existing ones that currently do all the > silly hijinx. :) > > > +1 From owner-svn-src-head@freebsd.org Wed Dec 21 19:07:04 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 502AEC8B41C for ; Wed, 21 Dec 2016 19:07:04 +0000 (UTC) (envelope-from ed@nuxi.nl) Received: from mail-yb0-x231.google.com (mail-yb0-x231.google.com [IPv6:2607:f8b0:4002:c09::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0EB7C1439 for ; Wed, 21 Dec 2016 19:07:04 +0000 (UTC) (envelope-from ed@nuxi.nl) Received: by mail-yb0-x231.google.com with SMTP id d59so75702137ybi.1 for ; Wed, 21 Dec 2016 11:07:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuxi-nl.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Q0w/zXpp8NUdfrw83aBc2iVscTfrephNbCYPwhlobnY=; b=wXXBKPlxYfS931wBTvnoSQDxZap+yiB+UEPrC4ZhU1EprBZTzxYip+IT+4jtJze+eI wlgvCwvreazqObMnb2iBh5ROhNJkLo1MVMEJTZJHh1UDp1vp33cJlHUMM1hXUof0yCD4 WpsfMsOnIYfdRTKn5zKgwmZFcpXDx889iR3sbt18ECpM6Zp+vQ5idOok5QS2km3dcv1B FVwiIl9cCEkQoRNrwunbwzkwJazDXOQvaK0TMHa/oO/jeO4bJXIh9G9+reNpKfTpW1tq IYm/Hnq4osAnHHaOCnW5OQoUWk1YACbC0/jKHjYYLOhPhn2P93HbARdob3FZHWa7OIyx yR3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Q0w/zXpp8NUdfrw83aBc2iVscTfrephNbCYPwhlobnY=; b=hPwZJ3XZe8QhFQqYOAgkK30UEX8XG/TJSU4w234e3DMNF1Qcjb63xsT+oiajlwkWQj oxzJKNa0Vb++YKDlI+aS0zPO5BcVVOJ2zLfIOwGOkL2GoGCWj1Ri3nSpigMKboLClYc9 N0FufbwCm57fRLv3JioAnc2EqO8JupWIlt8PR3wLL6f5mNTt4HGUafqpra2SNs9i693O jr+MV4VuE4jh0NEM9yuXl+A2H6IYhL7MvlI71kF1WJc7J0gwvCzmrLwkA1uX4HLStBgN a6KDyZW5bMyMUgYbeBrYDOxD2i/lCyEp/YKMvK1kFiqDCtkEjjR8F5sZBHM9hphsQR/Z CoRg== X-Gm-Message-State: AIkVDXJ8f3+eVe8XojzitoIQE+xMODDLnXsKyI2mS0pfs5R/lQMg/YWVx//+hpF4lFHa4z4C9YXpDkbtmffseQ== X-Received: by 10.37.210.197 with SMTP id j188mr3667513ybg.168.1482347223062; Wed, 21 Dec 2016 11:07:03 -0800 (PST) MIME-Version: 1.0 Received: by 10.129.2.139 with HTTP; Wed, 21 Dec 2016 11:06:32 -0800 (PST) In-Reply-To: References: <201612210829.uBL8Tijt041811@repo.freebsd.org> From: Ed Schouten Date: Wed, 21 Dec 2016 20:06:32 +0100 Message-ID: Subject: Re: svn commit: r310354 - in head/usr.sbin: . prometheus_sysctl_exporter To: Adrian Chadd Cc: Ed Schouten , "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Dec 2016 19:07:04 -0000 Hi Adrian, 2016-12-21 18:32 GMT+01:00 Adrian Chadd : > Maybe just "sysctl_export" would be fine. Good point. Almost all Prometheus metrics exporters use this naming scheme: ~80%: ${foo}_exporter ~20%: prometheus_${foo}_exporter Examples; - https://github.com/prometheus/node_exporter - https://github.com/ewr/elasticsearch_exporter - https://github.com/jonnenauha/prometheus_varnish_exporter The reason why I went for the 'prometheus_' prefix was mainly because of the following totally subjective reasons: - I didn't want to wreck tab completion. Right now if you type in 'sysc' and press tab, it tends to complete to 'sysctl'. - This tool is part of the base system, meaning that it will be present even if the user did nothing special. This is why I wanted the name to be a bit more self-documenting. - Thinking ahead: what if we're going to add exporters for other things as well? E.g., for Sendmail, sshd, ftpd, HAST, etc. In that case it would be nicer if those exporters shared a common prefix. That said, if people truly think it's a good idea to call this sysctl_exporter instead, then I wouldn't mind renaming it. Thoughts? Opinions? -- Ed Schouten Nuxi, 's-Hertogenbosch, the Netherlands KvK-nr.: 62051717 From owner-svn-src-head@freebsd.org Wed Dec 21 19:13:33 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C8BE0C8B5CC; Wed, 21 Dec 2016 19:13:33 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: from mail-wm0-x22f.google.com (mail-wm0-x22f.google.com [IPv6:2a00:1450:400c:c09::22f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 70DDA1900; Wed, 21 Dec 2016 19:13:33 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: by mail-wm0-x22f.google.com with SMTP id g23so156933288wme.1; Wed, 21 Dec 2016 11:13:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=3WXEB4SP4iQynwcaXXnxPgKFTbQMGg8iVIkaiZJ0g1M=; b=cy/lQ8VucWvwV/5MV7AoEVCPZU6lS4yJNMBTwv26II+Qy5YaQiv3D+OuKStNR3BK8v Wx1cuayZJs0rBRp6Apcne55/k1DMhItuDgJT82EaUSlb5uChDeoXCAbZy41wr9Z63fm+ 42O4GOWjF07NmvtH4TKINbn3v3GbB2WBE9nnJa1IF4cLZbHxkdeGs7eex8/DFT8/unpa eTDFdMJ7C7CtQmpoXwpSJC6/3tQLEF0JkJE60W46Bwzzhvx5oD8qfu0C1xELr/Vif+tV 9kzLogQMU5Hzk+CHUioz/YODqG1KAatTHQYpJ1gE6DEwJIAxWDYU7UcnGn2teYksHxnS AENQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=3WXEB4SP4iQynwcaXXnxPgKFTbQMGg8iVIkaiZJ0g1M=; b=rdr/AusiDGbNrQVdH0Qz+PMH4QwNQr9ccGl7kvFDueQZnMs3SdtwRrzlx/8qD6ZdCi knUYh24QKEai35rdwxIBiebtrXEadn3L40E9n/jIitpKd/62e31lAajJ4ZBs5Y3KEqZm vWGpeip/CegQPHhL3/whauX6uLUZAdb8Vz/wAK/YgzBCNfGeGhejyAzIP3hZB+rm39CB 6OeCWPsH85lpxgIPr4ZrHiWDqFh/YwO4EQnaUYI6PneKQfSwBFVjJ+ydbUjiHEC3rXKk SAQ+pXfaVbqEorSG2IK+PyLseP2DAlayCxX+mHpQp/AxN9tevoRjKoNHvFZcSng//a2I g15w== X-Gm-Message-State: AIkVDXILcdZZN661ifIYcO9u2hHf3mw+PdQFTOYeogEAHOwL9aLM6y4U1J/HSSudS9sMAjG1mW5XHGdR2u7I7Q== X-Received: by 10.28.69.217 with SMTP id l86mr8044454wmi.129.1482347611891; Wed, 21 Dec 2016 11:13:31 -0800 (PST) MIME-Version: 1.0 Received: by 10.194.44.1 with HTTP; Wed, 21 Dec 2016 11:13:31 -0800 (PST) In-Reply-To: References: <201612210829.uBL8Tijt041811@repo.freebsd.org> From: Adrian Chadd Date: Wed, 21 Dec 2016 11:13:31 -0800 Message-ID: Subject: Re: svn commit: r310354 - in head/usr.sbin: . prometheus_sysctl_exporter To: Ed Schouten Cc: Ed Schouten , "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Dec 2016 19:13:33 -0000 My suggestion is "let's flesh out the toolsets a bit first, we can rename them before 12.0". If you really want a namespace that you can tabcomplete, then my bikeshed is painted "stats_export_XXX". I have other comments, like "should this really be doing HTTP / gzip output?" instead of say, using JSON or something else as an intermediary format. I have some half-finished patches to libstatfoo that allow either plain-text or JSON output, and the JSON output includes changes to describe the value (int, ordinal, dB, dBm, dBi, 802.11 rate, etc). -adrian From owner-svn-src-head@freebsd.org Wed Dec 21 19:32:30 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A8BA7C8BBD4; Wed, 21 Dec 2016 19:32:30 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from mail.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6525B136A; Wed, 21 Dec 2016 19:32:30 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by mail.baldwin.cx (Postfix) with ESMTPSA id A44B610AA28; Wed, 21 Dec 2016 14:32:27 -0500 (EST) From: John Baldwin To: Julian Elischer Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r310336 - head/sys/kern Date: Wed, 21 Dec 2016 11:28:25 -0800 Message-ID: <148295416.6HGrYZ2Ojd@ralph.baldwin.cx> User-Agent: KMail/4.14.10 (FreeBSD/11.0-PRERELEASE; KDE/4.14.10; amd64; ; ) In-Reply-To: References: <201612201944.uBKJiiMg034231@repo.freebsd.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mail.baldwin.cx); Wed, 21 Dec 2016 14:32:27 -0500 (EST) X-Virus-Scanned: clamav-milter 0.99.2 at mail.baldwin.cx X-Virus-Status: Clean X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Dec 2016 19:32:30 -0000 On Wednesday, December 21, 2016 02:40:09 PM Julian Elischer wrote: > On 21/12/2016 3:44 AM, John Baldwin wrote: > > Author: jhb > > Date: Tue Dec 20 19:44:44 2016 > > New Revision: 310336 > > URL: https://svnweb.freebsd.org/changeset/base/310336 > > > > Log: > > Don't spin in pause() during early boot for kthreads other than thread0. > > > > pause() uses a spin loop to simulate a sleep during early boot. However, > > we only need this for thread0 to get far enough in the boot process to > > enable timers (at which point pause() can sleep). For other kthreads, > > sleeping in pause() is ok as the callout will be scheduled and will > > eventually fire once thread0 initializes timers. > > maybe we just need to depend on a variable "have_timers" > that is independent of the cold/hot/whatever settings. > first code to enable a timer sets it. Eventually I think some cold checks will devolve to that (and/or cold will just go away). We aren't quite at that point yet however (though we are getting closer). -- John Baldwin From owner-svn-src-head@freebsd.org Wed Dec 21 19:53:10 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E4979C8BF5B; Wed, 21 Dec 2016 19:53:10 +0000 (UTC) (envelope-from etnapierala@gmail.com) Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 725B31C67; Wed, 21 Dec 2016 19:53:10 +0000 (UTC) (envelope-from etnapierala@gmail.com) Received: by mail-wm0-x242.google.com with SMTP id m203so32312900wma.3; Wed, 21 Dec 2016 11:53:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:mail-followup-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=sJ6d9Rgr4VESNrGVaQonFmMIplNLPUIfj67Fwg0u3HY=; b=W5P1TM0+DCK+3pDDZKP7uIxniuX4Q3V/vdtgIlYhCqBf6atBkOqTQ6rlZtIWK0hFhl oDThsUovR3hNhMDtkOuGffeBdI8pMsulrIUz8eHAjti71PXIXhuqX/s9x2oxykcOoPI4 O4GyjfwC3SpWnEc16gGPnRfIJ0ZdQO8c0hB89HVoQbAfeIANufgv8Wn56Mr8lbgBMBHO l9Z5rTQKC1UjbKux47iJ/ahzTkA7Bj9Y8W4BTyrBlEa4hGH10Iatch/qTCobX8egrBP6 ofKXZv/withpQDmx1gZypRW4zXPfqiFFBa/NSu5ysAAn3Vz9Jg9SzlqgCsgAkwT0BPBe FSww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=sJ6d9Rgr4VESNrGVaQonFmMIplNLPUIfj67Fwg0u3HY=; b=YwxWL4A4ifakqHyIFXjtLPXkBM/T7juBjMDff/hWJmrU5oWBHYnqyyJccvvOeQ+eEN W/eU8whBbm94ctrmZnelJyr5OXZGDQvOYCHUTPbs8Dh8V+zrIsaG1kHhkwyQPs6ig/Lb gLcutkLH0Yheao49RP9Tyr5Tt02I4ubOod5cskH1ouLcBVYTKrefhkt2LrlXxUW6hYFc 1yVs6J/VBEEX625ajVZeY7fYvQVTaYOmPjgVk0SXxvUem9NQLvuEhcUf9f+0yZ7UDzCi MX4WUZdS/mRt8W+CmcD6TDlASu/G+MbMSUCrvWjVFlWt/19eIwhGRlqqaqlbRYARS1K6 U4iw== X-Gm-Message-State: AIkVDXLaBW7qB/lx62EbQDtjxMbERHzyzsk0cUezCQni1duhIv2XVPJ0d2M4pxMzImiDMQ== X-Received: by 10.28.174.194 with SMTP id x185mr6332400wme.4.1482349987883; Wed, 21 Dec 2016 11:53:07 -0800 (PST) Received: from brick (abvn235.neoplus.adsl.tpnet.pl. [83.8.211.235]) by smtp.gmail.com with ESMTPSA id w7sm28553311wmd.24.2016.12.21.11.53.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Dec 2016 11:53:07 -0800 (PST) Sender: =?UTF-8?Q?Edward_Tomasz_Napiera=C5=82a?= Date: Wed, 21 Dec 2016 20:53:04 +0100 From: Edward Tomasz =?utf-8?Q?Napiera=C5=82a?= To: Ed Schouten Cc: Adrian Chadd , Ed Schouten , "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Subject: Re: svn commit: r310354 - in head/usr.sbin: . prometheus_sysctl_exporter Message-ID: <20161221195304.GA3396@brick> Mail-Followup-To: Ed Schouten , Adrian Chadd , Ed Schouten , "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" References: <201612210829.uBL8Tijt041811@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.7.2 (2016-11-26) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Dec 2016 19:53:11 -0000 On 1221T2006, Ed Schouten wrote: > Hi Adrian, > > 2016-12-21 18:32 GMT+01:00 Adrian Chadd : > > Maybe just "sysctl_export" would be fine. > > Good point. Almost all Prometheus metrics exporters use this naming scheme: > > ~80%: ${foo}_exporter > ~20%: prometheus_${foo}_exporter > > Examples; > > - https://github.com/prometheus/node_exporter > - https://github.com/ewr/elasticsearch_exporter > - https://github.com/jonnenauha/prometheus_varnish_exporter > > The reason why I went for the 'prometheus_' prefix was mainly because > of the following totally subjective reasons: > > - I didn't want to wreck tab completion. Right now if you type in > 'sysc' and press tab, it tends to complete to 'sysctl'. That's a very good reason; it could also be fixed by moving it from sbin/ to libexec/. > - This tool is part of the base system, meaning that it will be > present even if the user did nothing special. This is why I wanted the > name to be a bit more self-documenting. > - Thinking ahead: what if we're going to add exporters for other > things as well? E.g., for Sendmail, sshd, ftpd, HAST, etc. In that > case it would be nicer if those exporters shared a common prefix. Another advantage of having the "prometheus" in the name is that it's easily googlable, and it clearly indicates the "protocol" (in the wide meaning) one is supposed to use to talk to it. From owner-svn-src-head@freebsd.org Wed Dec 21 20:19:13 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BDACEC8A39A; Wed, 21 Dec 2016 20:19:13 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 8D03F16BB; Wed, 21 Dec 2016 20:19:13 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBLKJCND034477; Wed, 21 Dec 2016 20:19:12 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBLKJCBF034475; Wed, 21 Dec 2016 20:19:12 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201612212019.uBLKJCBF034475@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 21 Dec 2016 20:19:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310373 - in head/sys/cam: ctl scsi X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Dec 2016 20:19:13 -0000 Author: mav Date: Wed Dec 21 20:19:12 2016 New Revision: 310373 URL: https://svnweb.freebsd.org/changeset/base/310373 Log: Add support for REPORTING OPTIONS == 3 in REPORT SUPPORTED OPERATION CODES. MFC after: 2 weeks Modified: head/sys/cam/ctl/ctl.c head/sys/cam/scsi/scsi_all.h Modified: head/sys/cam/ctl/ctl.c ============================================================================== --- head/sys/cam/ctl/ctl.c Wed Dec 21 18:42:04 2016 (r310372) +++ head/sys/cam/ctl/ctl.c Wed Dec 21 20:19:12 2016 (r310373) @@ -7371,6 +7371,8 @@ ctl_report_supported_opcodes(struct ctl_ ctl_done((union ctl_io *)ctsio); return (CTL_RETVAL_COMPLETE); } + /* FALLTHROUGH */ + case RSO_OPTIONS_OC_ASA: total_len = sizeof(struct scsi_report_supported_opcodes_one) + 32; break; default: @@ -7459,6 +7461,18 @@ fill_one: } else one->support = 1; break; + case RSO_OPTIONS_OC_ASA: + one = (struct scsi_report_supported_opcodes_one *) + ctsio->kern_data_ptr; + entry = &ctl_cmd_table[opcode]; + if (entry->flags & CTL_CMD_FLAG_SA5) { + entry = &((const struct ctl_cmd_entry *) + entry->execute)[service_action]; + } else if (service_action != 0) { + one->support = 1; + break; + } + goto fill_one; } ctl_set_success(ctsio); Modified: head/sys/cam/scsi/scsi_all.h ============================================================================== --- head/sys/cam/scsi/scsi_all.h Wed Dec 21 18:42:04 2016 (r310372) +++ head/sys/cam/scsi/scsi_all.h Wed Dec 21 20:19:12 2016 (r310373) @@ -1456,6 +1456,7 @@ struct scsi_report_supported_opcodes #define RSO_OPTIONS_ALL 0x00 #define RSO_OPTIONS_OC 0x01 #define RSO_OPTIONS_OC_SA 0x02 +#define RSO_OPTIONS_OC_ASA 0x03 uint8_t requested_opcode; uint8_t requested_service_action[2]; uint8_t length[4]; From owner-svn-src-head@freebsd.org Wed Dec 21 22:02:23 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5D9CBC8A316; Wed, 21 Dec 2016 22:02:23 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mailout.stack.nl (mailout05.stack.nl [IPv6:2001:610:1108:5010::202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mailout.stack.nl", Issuer "CA Cert Signing Authority" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 272301BE2; Wed, 21 Dec 2016 22:02:23 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mailout.stack.nl (Postfix) with ESMTP id 98F4D32; Wed, 21 Dec 2016 23:02:12 +0100 (CET) Received: by snail.stack.nl (Postfix, from userid 1677) id 85B5C28494; Wed, 21 Dec 2016 23:02:12 +0100 (CET) Date: Wed, 21 Dec 2016 23:02:12 +0100 From: Jilles Tjoelker To: Conrad Meyer Cc: Adrian Chadd , src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Subject: Re: svn commit: r310138 - head/lib/libc/stdio Message-ID: <20161221220212.GA97256@stack.nl> References: <201612160144.uBG1ipjW016736@repo.freebsd.org> <49460793.UcUNovQMDa@ralph.baldwin.cx> <1482281779.48539.41.camel@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Dec 2016 22:02:23 -0000 On Tue, Dec 20, 2016 at 06:04:31PM -0800, Conrad Meyer wrote: > On Tue, Dec 20, 2016 at 5:56 PM, Adrian Chadd wrote: > > Here's my reason for removal. > > Plenty of us are looking to be able to build bits of the BSD source > > tree as part of other non FreeBSD systems, especially if they're > > involved in bootstrapping. > Understood, however: > > That means that it needs to be compilable > > by a non-FreeBSD-modified compiler. Ideally this means we'd stick to > > mostly POSIX options source code that we can compile with unmodified > > compilers, and we push non-standard stuff into otherly-named > > functions. > Yeah, this isn't actually a problem. printf("%b", foo) compiles fine > with non-modified compilers. It compiles only if you disable format string warnings that should not be disabled for any serious software development, in my humble opinion. It will build, but not in a way I can call "fine". This indeed makes it very hard to justify extensions to format strings. Special formatting will need to use new functions. -- Jilles Tjoelker From owner-svn-src-head@freebsd.org Wed Dec 21 22:21:33 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 13877C8A99B; Wed, 21 Dec 2016 22:21:33 +0000 (UTC) (envelope-from ronald-lists@klop.ws) Received: from smarthost1.greenhost.nl (smarthost1.greenhost.nl [195.190.28.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C9BBF1731; Wed, 21 Dec 2016 22:21:31 +0000 (UTC) (envelope-from ronald-lists@klop.ws) Received: from smtp.greenhost.nl ([213.108.104.138]) by smarthost1.greenhost.nl with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1cJpGE-00061T-JR; Wed, 21 Dec 2016 23:21:22 +0100 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org, "Andrew Turner" Subject: Re: svn commit: r310124 - head/sys/boot/arm/uboot References: <201612151736.uBFHatUL016048@repo.freebsd.org> Date: Wed, 21 Dec 2016 23:21:21 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: "Ronald Klop" Message-ID: In-Reply-To: <201612151736.uBFHatUL016048@repo.freebsd.org> User-Agent: Opera Mail/12.16 (FreeBSD) X-Authenticated-As-Hash: 398f5522cb258ce43cb679602f8cfe8b62a256d1 X-Virus-Scanned: by clamav at smarthost1.samage.net X-Spam-Level: / X-Spam-Score: -0.2 X-Spam-Status: No, score=-0.2 required=5.0 tests=ALL_TRUSTED, BAYES_50 autolearn=disabled version=3.4.0 X-Scan-Signature: 2394e6fd9f1e9f86011669f8146dc264 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Dec 2016 22:21:33 -0000 Hello, Is this 12-CURRENT only or also applicable to 11-STABLE? Regards, Ronald. On Thu, 15 Dec 2016 18:36:55 +0100, Andrew Turner wrote: > Author: andrew > Date: Thu Dec 15 17:36:54 2016 > New Revision: 310124 > URL: https://svnweb.freebsd.org/changeset/base/310124 > > Log: > Add -fPIC to the ubldr build. Without this the self relocation code > will > try to use an absolute address in a switch statement, jumping to an > invalid > memory location. > Sponsored by: ABT Systems Ltd > > Modified: > head/sys/boot/arm/uboot/Makefile > > Modified: head/sys/boot/arm/uboot/Makefile > ============================================================================== > --- head/sys/boot/arm/uboot/Makefile Thu Dec 15 17:34:18 2016 (r310123) > +++ head/sys/boot/arm/uboot/Makefile Thu Dec 15 17:36:54 2016 (r310124) > @@ -109,6 +109,8 @@ CFLAGS+= -I${.OBJDIR}/../../uboot/lib > # where to get libstand from > CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/ > +CFLAGS+= -fPIC > + > # clang doesn't understand %D as a specifier to printf > NO_WERROR.clang= > _______________________________________________ > svn-src-all@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/svn-src-all > To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org" From owner-svn-src-head@freebsd.org Wed Dec 21 22:35:28 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4F88FC8ACB9; Wed, 21 Dec 2016 22:35:28 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 0506F1E94; Wed, 21 Dec 2016 22:35:27 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBLMZRhD093010; Wed, 21 Dec 2016 22:35:27 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBLMZRkq093009; Wed, 21 Dec 2016 22:35:27 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201612212235.uBLMZRkq093009@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Wed, 21 Dec 2016 22:35:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310375 - head/sys/dev/iwn X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Dec 2016 22:35:28 -0000 Author: gonzo Date: Wed Dec 21 22:35:26 2016 New Revision: 310375 URL: https://svnweb.freebsd.org/changeset/base/310375 Log: [iwn] Several fixes for DMA part of iwn(4) - Perform DMS sync when accessing/initializing ICT table - Fix some DMA sync operations to use matching tags Reviewed by: avos MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D8804 Modified: head/sys/dev/iwn/if_iwn.c Modified: head/sys/dev/iwn/if_iwn.c ============================================================================== --- head/sys/dev/iwn/if_iwn.c Wed Dec 21 22:04:44 2016 (r310374) +++ head/sys/dev/iwn/if_iwn.c Wed Dec 21 22:35:26 2016 (r310375) @@ -2120,6 +2120,9 @@ iwn5000_ict_reset(struct iwn_softc *sc) memset(sc->ict, 0, IWN_ICT_SIZE); sc->ict_cur = 0; + bus_dmamap_sync(sc->ict_dma.tag, sc->ict_dma.map, + BUS_DMASYNC_PREWRITE); + /* Set physical address of ICT table (4KB aligned). */ DPRINTF(sc, IWN_DEBUG_RESET, "%s: enabling ICT\n", __func__); IWN_WRITE(sc, IWN_DRAM_INT_TBL, IWN_DRAM_INT_TBL_ENABLE | @@ -4100,6 +4103,8 @@ iwn_intr(void *arg) /* Read interrupts from ICT (fast) or from registers (slow). */ if (sc->sc_flags & IWN_FLAG_USE_ICT) { + bus_dmamap_sync(sc->ict_dma.tag, sc->ict_dma.map, + BUS_DMASYNC_POSTREAD); tmp = 0; while (sc->ict[sc->ict_cur] != 0) { tmp |= sc->ict[sc->ict_cur]; @@ -4635,7 +4640,7 @@ iwn_tx_data(struct iwn_softc *sc, struct } bus_dmamap_sync(ring->data_dmat, data->map, BUS_DMASYNC_PREWRITE); - bus_dmamap_sync(ring->data_dmat, ring->cmd_dma.map, + bus_dmamap_sync(ring->cmd_dma.tag, ring->cmd_dma.map, BUS_DMASYNC_PREWRITE); bus_dmamap_sync(ring->desc_dma.tag, ring->desc_dma.map, BUS_DMASYNC_PREWRITE); @@ -4828,7 +4833,7 @@ iwn_tx_data_raw(struct iwn_softc *sc, st } bus_dmamap_sync(ring->data_dmat, data->map, BUS_DMASYNC_PREWRITE); - bus_dmamap_sync(ring->data_dmat, ring->cmd_dma.map, + bus_dmamap_sync(ring->cmd_dma.tag, ring->cmd_dma.map, BUS_DMASYNC_PREWRITE); bus_dmamap_sync(ring->desc_dma.tag, ring->desc_dma.map, BUS_DMASYNC_PREWRITE); @@ -5161,7 +5166,7 @@ iwn_cmd(struct iwn_softc *sc, int code, bus_dmamap_sync(ring->data_dmat, data->map, BUS_DMASYNC_PREWRITE); } else { - bus_dmamap_sync(ring->data_dmat, ring->cmd_dma.map, + bus_dmamap_sync(ring->cmd_dma.tag, ring->cmd_dma.map, BUS_DMASYNC_PREWRITE); } bus_dmamap_sync(ring->desc_dma.tag, ring->desc_dma.map, From owner-svn-src-head@freebsd.org Wed Dec 21 22:47:11 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C5EBCC8AFE3; Wed, 21 Dec 2016 22:47:11 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 8831B13C6; Wed, 21 Dec 2016 22:47:11 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBLMlAHt096970; Wed, 21 Dec 2016 22:47:10 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBLMlAv8096969; Wed, 21 Dec 2016 22:47:10 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201612212247.uBLMlAv8096969@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: glebius set sender to glebius@FreeBSD.org using -f From: Gleb Smirnoff Date: Wed, 21 Dec 2016 22:47:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310376 - head/sys/netinet X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Dec 2016 22:47:11 -0000 Author: glebius Date: Wed Dec 21 22:47:10 2016 New Revision: 310376 URL: https://svnweb.freebsd.org/changeset/base/310376 Log: Remove assigned only variable. Modified: head/sys/netinet/tcp_syncache.c Modified: head/sys/netinet/tcp_syncache.c ============================================================================== --- head/sys/netinet/tcp_syncache.c Wed Dec 21 22:35:26 2016 (r310375) +++ head/sys/netinet/tcp_syncache.c Wed Dec 21 22:47:10 2016 (r310376) @@ -1170,7 +1170,7 @@ syncache_add(struct in_conninfo *inc, st struct syncache_head *sch; struct mbuf *ipopts = NULL; u_int ltflags; - int win, sb_hiwat, ip_ttl, ip_tos; + int win, ip_ttl, ip_tos; char *s; int rv = 0; #ifdef INET6 @@ -1208,7 +1208,6 @@ syncache_add(struct in_conninfo *inc, st ip_ttl = inp->inp_ip_ttl; ip_tos = inp->inp_ip_tos; win = sbspace(&so->so_rcv); - sb_hiwat = so->so_rcv.sb_hiwat; ltflags = (tp->t_flags & (TF_NOOPT | TF_SIGNATURE)); #ifdef TCP_RFC7413 From owner-svn-src-head@freebsd.org Wed Dec 21 23:54:13 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 744B7C8BE80; Wed, 21 Dec 2016 23:54:13 +0000 (UTC) (envelope-from gavin@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 36B0113BB; Wed, 21 Dec 2016 23:54:13 +0000 (UTC) (envelope-from gavin@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBLNsCfd025144; Wed, 21 Dec 2016 23:54:12 GMT (envelope-from gavin@FreeBSD.org) Received: (from gavin@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBLNsCDi025143; Wed, 21 Dec 2016 23:54:12 GMT (envelope-from gavin@FreeBSD.org) Message-Id: <201612212354.uBLNsCDi025143@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gavin set sender to gavin@FreeBSD.org using -f From: Gavin Atkinson Date: Wed, 21 Dec 2016 23:54:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310379 - head/sys/dev/ow X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Dec 2016 23:54:13 -0000 Author: gavin Date: Wed Dec 21 23:54:12 2016 New Revision: 310379 URL: https://svnweb.freebsd.org/changeset/base/310379 Log: ow_temp: Correct typo in comment Modified: head/sys/dev/ow/ow_temp.c Modified: head/sys/dev/ow/ow_temp.c ============================================================================== --- head/sys/dev/ow/ow_temp.c Wed Dec 21 23:16:58 2016 (r310378) +++ head/sys/dev/ow/ow_temp.c Wed Dec 21 23:54:12 2016 (r310379) @@ -164,7 +164,7 @@ ow_temp_event_thread(void *arg) if (scratch[7]) { /* * Formula from DS18S20 datasheet, page 6 - * DS18S20 datahseet says count_per_c is 16, DS1820 does not + * DS18S20 datasheet says count_per_c is 16, DS1820 does not */ sc->temp = (int16_t)((scratch[0] & 0xfe) | (scratch[1] << 8)) << 3; From owner-svn-src-head@freebsd.org Thu Dec 22 00:09:55 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 43DEFC8B4E7; Thu, 22 Dec 2016 00:09:55 +0000 (UTC) (envelope-from gavin@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 05DC71BD7; Thu, 22 Dec 2016 00:09:54 +0000 (UTC) (envelope-from gavin@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBM09s45029259; Thu, 22 Dec 2016 00:09:54 GMT (envelope-from gavin@FreeBSD.org) Received: (from gavin@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBM09s5M029258; Thu, 22 Dec 2016 00:09:54 GMT (envelope-from gavin@FreeBSD.org) Message-Id: <201612220009.uBM09s5M029258@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gavin set sender to gavin@FreeBSD.org using -f From: Gavin Atkinson Date: Thu, 22 Dec 2016 00:09:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310381 - head/sys/dev/ow X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 00:09:55 -0000 Author: gavin Date: Thu Dec 22 00:09:53 2016 New Revision: 310381 URL: https://svnweb.freebsd.org/changeset/base/310381 Log: ow_temp: Update the temperature visible via the sysctl atomically, rather than using it as temporary calculation space. Modified: head/sys/dev/ow/ow_temp.c Modified: head/sys/dev/ow/ow_temp.c ============================================================================== --- head/sys/dev/ow/ow_temp.c Wed Dec 21 23:59:58 2016 (r310380) +++ head/sys/dev/ow/ow_temp.c Thu Dec 22 00:09:53 2016 (r310381) @@ -137,7 +137,7 @@ ow_temp_event_thread(void *arg) struct ow_temp_softc *sc; uint8_t scratch[8 + 1]; uint8_t crc; - int retries, rv; + int retries, rv, tmp; sc = arg; pause("owtstart", device_get_unit(sc->dev) * hz / 100); // 10ms stagger @@ -166,14 +166,14 @@ ow_temp_event_thread(void *arg) * Formula from DS18S20 datasheet, page 6 * DS18S20 datasheet says count_per_c is 16, DS1820 does not */ - sc->temp = (int16_t)((scratch[0] & 0xfe) | + tmp = (int16_t)((scratch[0] & 0xfe) | (scratch[1] << 8)) << 3; - sc->temp += 16 - scratch[6] - 4; /* count_per_c == 16 */ + tmp += 16 - scratch[6] - 4; /* count_per_c == 16 */ } else - sc->temp = (int16_t)(scratch[0] | (scratch[1] << 8)) << 3; + tmp = (int16_t)(scratch[0] | (scratch[1] << 8)) << 3; } else - sc->temp = (int16_t)(scratch[0] | (scratch[1] << 8)); - sc->temp = sc->temp * 1000 / 16 + 273150; + tmp = (int16_t)(scratch[0] | (scratch[1] << 8)); + sc->temp = tmp * 1000 / 16 + 273150; break; } sc->bad_crc++; From owner-svn-src-head@freebsd.org Thu Dec 22 00:19:30 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4EF9CC8B695; Thu, 22 Dec 2016 00:19:30 +0000 (UTC) (envelope-from hiren@strugglingcoder.info) Received: from mail.strugglingcoder.info (strugglingcoder.info [104.236.146.68]) by mx1.freebsd.org (Postfix) with ESMTP id 3FA8E9E; Thu, 22 Dec 2016 00:19:29 +0000 (UTC) (envelope-from hiren@strugglingcoder.info) Received: from localhost (unknown [10.1.1.3]) (Authenticated sender: hiren@strugglingcoder.info) by mail.strugglingcoder.info (Postfix) with ESMTPA id 1345517474; Wed, 21 Dec 2016 16:19:29 -0800 (PST) Date: Wed, 21 Dec 2016 16:19:28 -0800 From: hiren panchasara To: Gleb Smirnoff Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r309745 - in head: share/man/man9 sys/kern sys/sys Message-ID: <20161222001928.GZ82166@strugglingcoder.info> References: <201612091758.uB9HwYC0087384@repo.freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="LG5jgFgJbJFFiAfj" Content-Disposition: inline In-Reply-To: <201612091758.uB9HwYC0087384@repo.freebsd.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 00:19:30 -0000 --LG5jgFgJbJFFiAfj Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 12/09/16 at 05:58P, Gleb Smirnoff wrote: > Author: glebius > Date: Fri Dec 9 17:58:34 2016 > New Revision: 309745 > URL: https://svnweb.freebsd.org/changeset/base/309745 >=20 > Log: > Provide counter_ratecheck(), a MP-friendly substitution to ppsratecheck= (). > When rated event happens at a very quick rate, the ppsratecheck() is not > only racy, but also becomes a performance bottleneck. > =20 > Together with: rrs, jtl Glebius, Is it possible for you to MFC this and the following fix to it to 11? Cheers, Hiren --LG5jgFgJbJFFiAfj Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQF8BAABCgBmBQJYWxwOXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXRBNEUyMEZBMUQ4Nzg4RjNGMTdFNjZGMDI4 QjkyNTBFMTU2M0VERkU1AAoJEIuSUOFWPt/l4fsIAIaLAya5tD8BwlnGK7rNccwp K35nNJJtnrcmm4hkeIpu6ndWJ/k6eSayTWbxITkusPKXQU4sGLGcek7hzSvnHgHy 9kYY4AjwuxYTtrHWKxwSoSKXkjY/Zx9fpIFMxAcAWn1VrFwkN4S1xwWjqLc5+pCc av1V9i3z9mYiwNbmNacdwQMGXz3N5hJMYmw5KHnEqq5cP74lkbNTq+eCvr6fjGEH FYwICJlGRde0q3R5mMZcQ+RDmVuPSQhA6owtyiRScwzIjWP0RfXhZ0ZyfcrmIQKG rqrOWGk4aXL2GwCMl1QTNzxdMxwAB+P/CAkvlCE1uWAamozoGzXHN0qOZsUjAhY= =jCT9 -----END PGP SIGNATURE----- --LG5jgFgJbJFFiAfj-- From owner-svn-src-head@freebsd.org Thu Dec 22 00:35:14 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0BBBCC8BB49; Thu, 22 Dec 2016 00:35:14 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 B698AC10; Thu, 22 Dec 2016 00:35:13 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBM0ZCIF041158; Thu, 22 Dec 2016 00:35:12 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBM0ZCHg041156; Thu, 22 Dec 2016 00:35:12 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201612220035.uBM0ZCHg041156@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Thu, 22 Dec 2016 00:35:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310382 - head/sbin/tunefs X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 00:35:14 -0000 Author: brooks Date: Thu Dec 22 00:35:12 2016 New Revision: 310382 URL: https://svnweb.freebsd.org/changeset/base/310382 Log: Convert tunefs use to nmount(2) Reviewed by: jhb, emaste Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D8822 Modified: head/sbin/tunefs/Makefile head/sbin/tunefs/tunefs.c Modified: head/sbin/tunefs/Makefile ============================================================================== --- head/sbin/tunefs/Makefile Thu Dec 22 00:09:53 2016 (r310381) +++ head/sbin/tunefs/Makefile Thu Dec 22 00:35:12 2016 (r310382) @@ -3,9 +3,14 @@ PACKAGE=runtime PROG= tunefs +SRCS= tunefs.c getmntopts.c LIBADD= ufs MAN= tunefs.8 +MOUNT= ${SRCTOP}/sbin/mount +CFLAGS+= -I${MOUNT} +.PATH: ${MOUNT} + WARNS= 3 .include Modified: head/sbin/tunefs/tunefs.c ============================================================================== --- head/sbin/tunefs/tunefs.c Thu Dec 22 00:09:53 2016 (r310381) +++ head/sbin/tunefs/tunefs.c Thu Dec 22 00:35:12 2016 (r310382) @@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -93,9 +94,11 @@ main(int argc, char *argv[]) int kvalue, Lflag, lflag, mflag, mvalue, Nflag, nflag, oflag, ovalue; int pflag, sflag, svalue, Svalue, tflag; int ch, found_arg, i; + int iovlen = 0; const char *chg[2]; - struct ufs_args args; struct statfs stfs; + struct iovec *iov = NULL; + char errmsg[255] = {0}; if (argc < 3) usage(); @@ -556,10 +559,16 @@ main(int argc, char *argv[]) goto err; ufs_disk_close(&disk); if (active) { - bzero(&args, sizeof(args)); - if (mount("ufs", on, - stfs.f_flags | MNT_UPDATE | MNT_RELOAD, &args) < 0) - err(9, "%s: reload", special); + build_iovec_argf(&iov, &iovlen, "fstype", "ufs"); + build_iovec_argf(&iov, &iovlen, "fspath", "%s", on); + build_iovec(&iov, &iovlen, "errmsg", errmsg, sizeof(errmsg)); + if (nmount(iov, iovlen, + stfs.f_flags | MNT_UPDATE | MNT_RELOAD) < 0) { + if (errmsg[0]) + err(9, "%s: reload: %s", special, errmsg); + else + err(9, "%s: reload", special); + } warnx("file system reloaded"); } exit(0); From owner-svn-src-head@freebsd.org Thu Dec 22 04:54:37 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CA0A5C8C5F3 for ; Thu, 22 Dec 2016 04:54:37 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-it0-x244.google.com (mail-it0-x244.google.com [IPv6:2607:f8b0:4001:c0b::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 94EAFF9A for ; Thu, 22 Dec 2016 04:54:37 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-it0-x244.google.com with SMTP id b123so19745489itb.2 for ; Wed, 21 Dec 2016 20:54:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=QIfpzdF2wynGF0HCBwLRm5d/rjKYGmtJ2/qzg9jB8LM=; b=XlvupZsXWOFth2Ym40vMLwwLoGhcjBZX9DdDSiO/pv4J3YIdQhgJ2BpIKCerp1h8cV bUmAX5wyGV7vBgqOILh1s45oQJVOMWguodK+YAyuPSdlbKPgWPgtBBxHGzujXsNOZw+Z 21lLZDcDtfDNWkvNnhFZDErPxmLSgavK+jOoNx7O0FHr4XDRhQUkYW4VXZdzLJbXpbOa f8vv7Qsvo8AkcA5Q/4P2c/4r8QByQBRn6xp4KwdwQ2YDCLfTo4tOK2zdsuSGcyiRcQYJ UnR6Ea48QGfbE5Ad4e12DV+FR8z7V7BzobwNiI2UNPH5utNUXhz9G+3ZkNFFaGFtPLhM B8DQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=QIfpzdF2wynGF0HCBwLRm5d/rjKYGmtJ2/qzg9jB8LM=; b=K6ORu68KBb8e1iKCftjwBq21aDrQHo49lxAexX8HzezVryEgPzue9k506swyQt9LIq Vb5BGQHihLP5K5Yue2FeqQov3DhQ/8784/EHvGxUbWRFBF7IWkQN7NUpiNnnLFLPMpxg oj0q1rZQlvNVcmH9badEnxawlnjx5pqpQzpR4me9IMI37zKnILE38E5hNVK0T3Dqt7rp I0snrmzBQJzHRZSnnOqgZXB/AcR15wIzSle/L6Wb4tfN67jY9oN2+whEHuUHEgL6N3V+ 1v0StKfDekqYY9zLu8VwuLgqBf9HRDARqQuLuAsBZzk9+Y8diIyYYdDUmZZi9XnOuV5s D2dw== X-Gm-Message-State: AIkVDXJsy0eX2IrPkCIPu0v77ZK/muzprGvAuASVH/qEVw6s9luG2rkKSB62fW9q4BRfg7TRMfVUytyQuVMldg== X-Received: by 10.36.58.16 with SMTP id m16mr8258559itm.85.1482382476989; Wed, 21 Dec 2016 20:54:36 -0800 (PST) MIME-Version: 1.0 Sender: wlosh@bsdimp.com Received: by 10.79.22.135 with HTTP; Wed, 21 Dec 2016 20:54:36 -0800 (PST) X-Originating-IP: [69.53.245.200] In-Reply-To: References: <201612210829.uBL8Tijt041811@repo.freebsd.org> From: Warner Losh Date: Wed, 21 Dec 2016 21:54:36 -0700 X-Google-Sender-Auth: jg8uwx5qzHbKI9Q2qK6VXYjogI0 Message-ID: Subject: Re: svn commit: r310354 - in head/usr.sbin: . prometheus_sysctl_exporter To: Ed Schouten Cc: Adrian Chadd , Ed Schouten , "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 04:54:37 -0000 On Wed, Dec 21, 2016 at 12:06 PM, Ed Schouten wrote: > Hi Adrian, > > 2016-12-21 18:32 GMT+01:00 Adrian Chadd : >> Maybe just "sysctl_export" would be fine. > > Good point. Almost all Prometheus metrics exporters use this naming scheme: > > ~80%: ${foo}_exporter > ~20%: prometheus_${foo}_exporter > > Examples; > > - https://github.com/prometheus/node_exporter > - https://github.com/ewr/elasticsearch_exporter > - https://github.com/jonnenauha/prometheus_varnish_exporter > > The reason why I went for the 'prometheus_' prefix was mainly because > of the following totally subjective reasons: > > - I didn't want to wreck tab completion. Right now if you type in > 'sysc' and press tab, it tends to complete to 'sysctl'. > - This tool is part of the base system, meaning that it will be > present even if the user did nothing special. This is why I wanted the > name to be a bit more self-documenting. > - Thinking ahead: what if we're going to add exporters for other > things as well? E.g., for Sendmail, sshd, ftpd, HAST, etc. In that > case it would be nicer if those exporters shared a common prefix. > > That said, if people truly think it's a good idea to call this > sysctl_exporter instead, then I wouldn't mind renaming it. > > Thoughts? Opinions? sysctl_ anything will have my rage filled tab completion beeps sending hate your way for years to come. Please don't do that :) Warner From owner-svn-src-head@freebsd.org Thu Dec 22 05:23:39 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B1BE0C8CFF3; Thu, 22 Dec 2016 05:23:39 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 72A051DCB; Thu, 22 Dec 2016 05:23:39 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBM5Nc3s058812; Thu, 22 Dec 2016 05:23:38 GMT (envelope-from hrs@FreeBSD.org) Received: (from hrs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBM5NcNr058811; Thu, 22 Dec 2016 05:23:38 GMT (envelope-from hrs@FreeBSD.org) Message-Id: <201612220523.uBM5NcNr058811@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hrs set sender to hrs@FreeBSD.org using -f From: Hiroki Sato Date: Thu, 22 Dec 2016 05:23:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310383 - head/usr.sbin/syslogd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 05:23:39 -0000 Author: hrs Date: Thu Dec 22 05:23:38 2016 New Revision: 310383 URL: https://svnweb.freebsd.org/changeset/base/310383 Log: - Simplify masklen->netmask conversion for AF_INET6. - Use iov[N] by array index instead of using pointer v = &iov[0] to make the compiler catch an out-of-range access of the array. Modified: head/usr.sbin/syslogd/syslogd.c Modified: head/usr.sbin/syslogd/syslogd.c ============================================================================== --- head/usr.sbin/syslogd/syslogd.c Thu Dec 22 00:35:12 2016 (r310382) +++ head/usr.sbin/syslogd/syslogd.c Thu Dec 22 05:23:38 2016 (r310383) @@ -127,9 +127,10 @@ static const char include_ext[] = ".conf #define MAXUNAMES 20 /* maximum number of user names */ #define sstosa(ss) ((struct sockaddr *)(ss)) -#define satosin6(sa) ((struct sockaddr_in6 *)(void *)(sa)) -#define sstosin(ss) ((struct sockaddr_in *)(ss)) +#define sstosin(ss) ((struct sockaddr_in *)(void *)(ss)) #define satosin(sa) ((struct sockaddr_in *)(void *)(sa)) +#define sstosin6(ss) ((struct sockaddr_in6 *)(void *)(ss)) +#define satosin6(sa) ((struct sockaddr_in6 *)(void *)(sa)) #define s6_addr32 __u6_addr.__u6_addr32 #define IN6_ARE_MASKED_ADDR_EQUAL(d, a, m) ( \ (((d)->s6_addr32[0] ^ (a)->s6_addr32[0]) & (m)->s6_addr32[0]) == 0 && \ @@ -1147,37 +1148,40 @@ static void fprintlog(struct filed *f, int flags, const char *msg) { struct iovec iov[IOV_SIZE]; - struct iovec *v; struct addrinfo *r; int l, lsent = 0; char line[MAXLINE + 1], repbuf[80], greetings[200], *wmsg = NULL; char nul[] = "", space[] = " ", lf[] = "\n", crlf[] = "\r\n"; const char *msgret; - v = iov; if (f->f_type == F_WALL) { - v->iov_base = greetings; /* The time displayed is not synchornized with the other log * destinations (like messages). Following fragment was using * ctime(&now), which was updating the time every 30 sec. * With f_lasttime, time is synchronized correctly. */ - v->iov_len = snprintf(greetings, sizeof greetings, - "\r\n\7Message from syslogd@%s at %.24s ...\r\n", - f->f_prevhost, f->f_lasttime); - if (v->iov_len >= sizeof greetings) - v->iov_len = sizeof greetings - 1; - v++; - v->iov_base = nul; - v->iov_len = 0; - v++; + iov[0] = (struct iovec){ + .iov_base = greetings, + .iov_len = snprintf(greetings, sizeof(greetings), + "\r\n\7Message from syslogd@%s " + "at %.24s ...\r\n", + f->f_prevhost, f->f_lasttime) + }; + if (iov[0].iov_len >= sizeof(greetings)) + iov[0].iov_len = sizeof(greetings) - 1; + iov[1] = (struct iovec){ + .iov_base = nul, + .iov_len = 0 + }; } else { - v->iov_base = f->f_lasttime; - v->iov_len = strlen(f->f_lasttime); - v++; - v->iov_base = space; - v->iov_len = 1; - v++; + iov[0] = (struct iovec){ + .iov_base = f->f_lasttime, + .iov_len = strlen(f->f_lasttime) + }; + iov[1] = (struct iovec){ + .iov_base = space, + .iov_len = 1 + }; } if (LogFacPri) { @@ -1214,39 +1218,46 @@ fprintlog(struct filed *f, int flags, co p_s = p_n; } snprintf(fp_buf, sizeof fp_buf, "<%s.%s> ", f_s, p_s); - v->iov_base = fp_buf; - v->iov_len = strlen(fp_buf); + iov[2] = (struct iovec){ + .iov_base = fp_buf, + .iov_len = strlen(fp_buf) + }; } else { - v->iov_base = nul; - v->iov_len = 0; - } - v++; - - v->iov_base = f->f_prevhost; - v->iov_len = strlen(v->iov_base); - v++; - v->iov_base = space; - v->iov_len = 1; - v++; - + iov[2] = (struct iovec){ + .iov_base = nul, + .iov_len = 0 + }; + } + iov[3] = (struct iovec){ + .iov_base = f->f_prevhost, + .iov_len = strlen(f->f_prevhost) + }; + iov[4] = (struct iovec){ + .iov_base = space, + .iov_len = 1 + }; if (msg) { wmsg = strdup(msg); /* XXX iov_base needs a `const' sibling. */ if (wmsg == NULL) { logerror("strdup"); exit(1); } - v->iov_base = wmsg; - v->iov_len = strlen(msg); + iov[5] = (struct iovec){ + .iov_base = wmsg, + .iov_len = strlen(msg) + }; } else if (f->f_prevcount > 1) { - v->iov_base = repbuf; - v->iov_len = snprintf(repbuf, sizeof repbuf, - "last message repeated %d times", f->f_prevcount); + iov[5] = (struct iovec){ + .iov_base = repbuf, + .iov_len = snprintf(repbuf, sizeof(repbuf), + "last message repeated %d times", f->f_prevcount) + }; } else { - v->iov_base = f->f_prevline; - v->iov_len = f->f_prevlen; + iov[5] = (struct iovec){ + .iov_base = f->f_prevline, + .iov_len = f->f_prevlen + }; } - v++; - dprintf("Logging to %s", TypeNames[f->f_type]); f->f_time = now; @@ -1325,8 +1336,10 @@ fprintlog(struct filed *f, int flags, co case F_FILE: dprintf(" %s\n", f->fu_fname); - v->iov_base = lf; - v->iov_len = 1; + iov[6] = (struct iovec){ + .iov_base = lf, + .iov_len = 1 + }; if (writev(f->f_file, iov, nitems(iov)) < 0) { /* * If writev(2) fails for potentially transient errors @@ -1347,8 +1360,10 @@ fprintlog(struct filed *f, int flags, co case F_PIPE: dprintf(" %s\n", f->fu_pipe_pname); - v->iov_base = lf; - v->iov_len = 1; + iov[6] = (struct iovec){ + .iov_base = lf, + .iov_len = 1 + }; if (f->fu_pipe_pid == 0) { if ((f->f_file = p_open(f->fu_pipe_pname, &f->fu_pipe_pid)) < 0) { @@ -1378,9 +1393,10 @@ fprintlog(struct filed *f, int flags, co case F_TTY: dprintf(" %s%s\n", _PATH_DEV, f->fu_fname); - v->iov_base = crlf; - v->iov_len = 2; - + iov[6] = (struct iovec){ + .iov_base = crlf, + .iov_len = 2 + }; errno = 0; /* ttymsg() only sometimes returns an errno */ if ((msgret = ttymsg(iov, nitems(iov), f->fu_fname, 10))) { f->f_type = F_UNUSED; @@ -1391,8 +1407,10 @@ fprintlog(struct filed *f, int flags, co case F_USERS: case F_WALL: dprintf("\n"); - v->iov_base = crlf; - v->iov_len = 2; + iov[6] = (struct iovec){ + .iov_base = crlf, + .iov_len = 2 + }; wallmsg(f, iov, nitems(iov)); break; } @@ -2371,8 +2389,7 @@ allowaddr(char *s) struct addrinfo hints, *res; in_addr_t *addrp, *maskp; #ifdef INET6 - int i; - u_int32_t *addr6p, *mask6p; + uint32_t *addr6p, *mask6p; #endif char ip[NI_MAXHOST]; @@ -2433,8 +2450,8 @@ allowaddr(char *s) memcpy(&ap->a_addr, res->ai_addr, res->ai_addrlen); memset(&ap->a_mask, 0, sizeof(ap->a_mask)); ap->a_mask.ss_family = res->ai_family; + ap->a_mask.ss_len = res->ai_addrlen; if (res->ai_family == AF_INET) { - ap->a_mask.ss_len = sizeof(struct sockaddr_in); maskp = &sstosin(&ap->a_mask)->sin_addr.s_addr; addrp = &sstosin(&ap->a_addr)->sin_addr.s_addr; if (masklen < 0) { @@ -2459,24 +2476,23 @@ allowaddr(char *s) } #ifdef INET6 else if (res->ai_family == AF_INET6 && masklen <= 128) { - ap->a_mask.ss_len = sizeof(struct sockaddr_in6); if (masklen < 0) masklen = 128; - mask6p = (u_int32_t *)&((struct sockaddr_in6 *)&ap->a_mask)->sin6_addr; + mask6p = (uint32_t *)&sstosin6(&ap->a_mask)->sin6_addr.s6_addr32[0]; + addr6p = (uint32_t *)&sstosin6(&ap->a_addr)->sin6_addr.s6_addr32[0]; /* convert masklen to netmask */ while (masklen > 0) { if (masklen < 32) { - *mask6p = htonl(~(0xffffffff >> masklen)); + *mask6p = + htonl(~(0xffffffff >> masklen)); + *addr6p &= *mask6p; break; + } else { + *mask6p++ = 0xffffffff; + addr6p++; + masklen -= 32; } - *mask6p++ = 0xffffffff; - masklen -= 32; } - /* Lose any host bits in the network number. */ - mask6p = (u_int32_t *)&((struct sockaddr_in6 *)&ap->a_mask)->sin6_addr; - addr6p = (u_int32_t *)&((struct sockaddr_in6 *)&ap->a_addr)->sin6_addr; - for (i = 0; i < 4; i++) - addr6p[i] &= mask6p[i]; } #endif else { From owner-svn-src-head@freebsd.org Thu Dec 22 05:28:31 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EE611C8C283; Thu, 22 Dec 2016 05:28:31 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 BDCBAFD; Thu, 22 Dec 2016 05:28:31 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBM5SUOr059017; Thu, 22 Dec 2016 05:28:30 GMT (envelope-from hrs@FreeBSD.org) Received: (from hrs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBM5SUr1059016; Thu, 22 Dec 2016 05:28:30 GMT (envelope-from hrs@FreeBSD.org) Message-Id: <201612220528.uBM5SUr1059016@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hrs set sender to hrs@FreeBSD.org using -f From: Hiroki Sato Date: Thu, 22 Dec 2016 05:28:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310384 - head/usr.sbin/syslogd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 05:28:32 -0000 Author: hrs Date: Thu Dec 22 05:28:30 2016 New Revision: 310384 URL: https://svnweb.freebsd.org/changeset/base/310384 Log: Fix debug log in the case of AF_INET6. Modified: head/usr.sbin/syslogd/syslogd.c Modified: head/usr.sbin/syslogd/syslogd.c ============================================================================== --- head/usr.sbin/syslogd/syslogd.c Thu Dec 22 05:23:38 2016 (r310383) +++ head/usr.sbin/syslogd/syslogd.c Thu Dec 22 05:28:30 2016 (r310384) @@ -1262,17 +1262,23 @@ fprintlog(struct filed *f, int flags, co f->f_time = now; switch (f->f_type) { - int port; case F_UNUSED: dprintf("\n"); break; case F_FORW: - port = ntohs(satosin(f->fu_forw_addr->ai_addr)->sin_port); - if (port != 514) { - dprintf(" %s:%d\n", f->fu_forw_hname, port); - } else { - dprintf(" %s\n", f->fu_forw_hname); + dprintf(" %s", f->fu_forw_hname); + switch (f->fu_forw_addr->ai_addr->sa_family) { + case AF_INET: + dprintf(":%d\n", + ntohs(satosin(f->fu_forw_addr->ai_addr)->sin_port)); + break; +#ifdef INET6 + case AF_INET6: + dprintf(":%d\n", + ntohs(satosin6(f->fu_forw_addr->ai_addr)->sin6_port)); + break; +#endif } /* check for local vs remote messages */ if (strcasecmp(f->f_prevhost, LocalHostName)) From owner-svn-src-head@freebsd.org Thu Dec 22 05:55:46 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 284E1C8CDF0; Thu, 22 Dec 2016 05:55:46 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 02C1412E0; Thu, 22 Dec 2016 05:55:45 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBM5tjsu071125; Thu, 22 Dec 2016 05:55:45 GMT (envelope-from hrs@FreeBSD.org) Received: (from hrs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBM5tjKC071124; Thu, 22 Dec 2016 05:55:45 GMT (envelope-from hrs@FreeBSD.org) Message-Id: <201612220555.uBM5tjKC071124@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hrs set sender to hrs@FreeBSD.org using -f From: Hiroki Sato Date: Thu, 22 Dec 2016 05:55:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310385 - head/usr.sbin/syslogd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 05:55:46 -0000 Author: hrs Date: Thu Dec 22 05:55:44 2016 New Revision: 310385 URL: https://svnweb.freebsd.org/changeset/base/310385 Log: Initialize a structure by using a compound literal to avoid forgetting to zero unspecified members. Modified: head/usr.sbin/syslogd/syslogd.c Modified: head/usr.sbin/syslogd/syslogd.c ============================================================================== --- head/usr.sbin/syslogd/syslogd.c Thu Dec 22 05:28:30 2016 (r310384) +++ head/usr.sbin/syslogd/syslogd.c Thu Dec 22 05:55:44 2016 (r310385) @@ -425,7 +425,6 @@ main(int argc, char *argv[]) int ch, i, s, fdsrmax = 0, bflag = 0, pflag = 0, Sflag = 0; fd_set *fdsr = NULL; struct timeval tv, *tvp; - struct sigaction sact; struct peer *pe; struct socklist *sl; sigset_t mask; @@ -633,10 +632,11 @@ main(int argc, char *argv[]) */ sigemptyset(&mask); sigaddset(&mask, SIGHUP); - sact.sa_handler = reapchild; - sact.sa_mask = mask; - sact.sa_flags = SA_RESTART; - (void)sigaction(SIGCHLD, &sact, NULL); + (void)sigaction(SIGCHLD, &(struct sigaction){ + .sa_handler = reapchild, + .sa_mask = mask, + .sa_flags = SA_RESTART + }, NULL); (void)signal(SIGALRM, domark); (void)signal(SIGPIPE, SIG_IGN); /* We'll catch EPIPE instead. */ (void)alarm(TIMERINTVL); @@ -650,10 +650,11 @@ main(int argc, char *argv[]) /* prevent SIGHUP and SIGCHLD handlers from running in parallel */ sigemptyset(&mask); sigaddset(&mask, SIGCHLD); - sact.sa_handler = init; - sact.sa_mask = mask; - sact.sa_flags = SA_RESTART; - (void)sigaction(SIGHUP, &sact, NULL); + (void)sigaction(SIGHUP, &(struct sigaction){ + .sa_handler = init, + .sa_mask = mask, + .sa_flags = SA_RESTART + }, NULL); tvp = &tv; tv.tv_sec = tv.tv_usec = 0; @@ -750,7 +751,7 @@ static void unmapped(struct sockaddr *sa) { struct sockaddr_in6 *sin6; - struct sockaddr_in sin4; + struct sockaddr_in sin; if (sa == NULL || sa->sa_family != AF_INET6 || @@ -759,15 +760,14 @@ unmapped(struct sockaddr *sa) sin6 = satosin6(sa); if (!IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) return; - - memset(&sin4, 0, sizeof(sin4)); - sin4.sin_family = AF_INET; - sin4.sin_len = sizeof(sin4); - memcpy(&sin4.sin_addr, &sin6->sin6_addr.s6_addr[12], - sizeof(sin4.sin_addr)); - sin4.sin_port = sin6->sin6_port; - - memcpy(sa, &sin4, sin4.sin_len); + sin = (struct sockaddr_in){ + .sin_family = AF_INET, + .sin_len = sizeof(sin), + .sin_port = sin6->sin6_port + }; + memcpy(&sin.sin_addr, &sin6->sin6_addr.s6_addr[12], + sizeof(sin.sin_addr)); + memcpy(sa, &sin, sizeof(sin)); } static void @@ -2154,9 +2154,10 @@ cfline(const char *line, const char *pro else p = NULL; - memset(&hints, 0, sizeof(hints)); - hints.ai_family = family; - hints.ai_socktype = SOCK_DGRAM; + hints = (struct addrinfo){ + .ai_family = family, + .ai_socktype = SOCK_DGRAM + }; error = getaddrinfo(f->fu_forw_hname, p ? p : "syslog", &hints, &res); if (error) { @@ -2447,16 +2448,18 @@ allowaddr(char *s) cp2 = NULL; } #endif - memset(&hints, 0, sizeof(hints)); - hints.ai_family = PF_UNSPEC; - hints.ai_socktype = SOCK_DGRAM; - hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST; + hints = (struct addrinfo){ + .ai_family = PF_UNSPEC, + .ai_socktype = SOCK_DGRAM, + .ai_flags = AI_PASSIVE | AI_NUMERICHOST + }; if (getaddrinfo(s, NULL, &hints, &res) == 0) { ap->isnumeric = 1; memcpy(&ap->a_addr, res->ai_addr, res->ai_addrlen); - memset(&ap->a_mask, 0, sizeof(ap->a_mask)); - ap->a_mask.ss_family = res->ai_family; - ap->a_mask.ss_len = res->ai_addrlen; + ap->a_mask = (struct sockaddr_storage){ + .ss_family = res->ai_family, + .ss_len = res->ai_addrlen + }; if (res->ai_family == AF_INET) { maskp = &sstosin(&ap->a_mask)->sin_addr.s_addr; addrp = &sstosin(&ap->a_addr)->sin_addr.s_addr; @@ -2567,10 +2570,11 @@ validate(struct sockaddr *sa, const char return (1); (void)strlcpy(name, hname, sizeof(name)); - memset(&hints, 0, sizeof(hints)); - hints.ai_family = PF_UNSPEC; - hints.ai_socktype = SOCK_DGRAM; - hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST; + hints = (struct addrinfo){ + .ai_family = PF_UNSPEC, + .ai_socktype = SOCK_DGRAM, + .ai_flags = AI_PASSIVE | AI_NUMERICHOST + }; if (getaddrinfo(name, NULL, &hints, &res) == 0) freeaddrinfo(res); else if (strchr(name, '.') == NULL) { @@ -2751,9 +2755,10 @@ deadq_enter(pid_t pid, const char *name) logerror("malloc"); exit(1); } - - p->dq_pid = pid; - p->dq_timeout = DQ_TIMO_INIT; + *p = (struct deadq_entry){ + .dq_pid = pid, + .dq_timeout = DQ_TIMO_INIT + }; TAILQ_INSERT_TAIL(&deadq_head, p, dq_entries); } @@ -2831,11 +2836,11 @@ socksetup(struct peer *pe) } #endif } - memset(&hints, 0, sizeof(hints)); - hints.ai_family = AF_UNSPEC; - hints.ai_socktype = SOCK_DGRAM; - hints.ai_flags = AI_PASSIVE; - + hints = (struct addrinfo){ + .ai_family = AF_UNSPEC, + .ai_socktype = SOCK_DGRAM, + .ai_flags = AI_PASSIVE + }; dprintf("Try %s\n", pe->pe_name); if (pe->pe_serv == NULL) pe->pe_serv = "syslog"; @@ -2847,7 +2852,6 @@ socksetup(struct peer *pe) } for (res = res0; res != NULL; res = res->ai_next) { int s; - int on = 1; if (res->ai_family == AF_LOCAL) unlink(pe->pe_name); @@ -2868,7 +2872,7 @@ socksetup(struct peer *pe) #ifdef INET6 if (res->ai_family == AF_INET6) { if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, - (char *)&on, sizeof(on)) < 0) { + &(int){1}, sizeof(int)) < 0) { logerror("setsockopt(IPV6_V6ONLY)"); close(s); error++; @@ -2877,7 +2881,7 @@ socksetup(struct peer *pe) } #endif if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, - (char *)&on, sizeof(on)) < 0) { + &(int){1}, sizeof(int)) < 0) { logerror("setsockopt(SO_REUSEADDR)"); close(s); error++; @@ -2938,11 +2942,10 @@ socksetup(struct peer *pe) static void increase_rcvbuf(int fd) { - socklen_t len, slen; - - slen = sizeof(len); + socklen_t len; - if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &len, &slen) == 0) { + if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &len, + &(socklen_t){sizeof(len)}) == 0) { if (len < RCVBUF_MINSIZE) { len = RCVBUF_MINSIZE; setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &len, sizeof(len)); From owner-svn-src-head@freebsd.org Thu Dec 22 05:57:47 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 35547C8CF50; Thu, 22 Dec 2016 05:57:47 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 04F6C152F; Thu, 22 Dec 2016 05:57:46 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBM5vkUg071232; Thu, 22 Dec 2016 05:57:46 GMT (envelope-from hrs@FreeBSD.org) Received: (from hrs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBM5vkbO071231; Thu, 22 Dec 2016 05:57:46 GMT (envelope-from hrs@FreeBSD.org) Message-Id: <201612220557.uBM5vkbO071231@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hrs set sender to hrs@FreeBSD.org using -f From: Hiroki Sato Date: Thu, 22 Dec 2016 05:57:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310386 - head/usr.sbin/syslogd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 05:57:47 -0000 Author: hrs Date: Thu Dec 22 05:57:45 2016 New Revision: 310386 URL: https://svnweb.freebsd.org/changeset/base/310386 Log: Add a missing "default:" case. Modified: head/usr.sbin/syslogd/syslogd.c Modified: head/usr.sbin/syslogd/syslogd.c ============================================================================== --- head/usr.sbin/syslogd/syslogd.c Thu Dec 22 05:55:44 2016 (r310385) +++ head/usr.sbin/syslogd/syslogd.c Thu Dec 22 05:57:45 2016 (r310386) @@ -1279,6 +1279,8 @@ fprintlog(struct filed *f, int flags, co ntohs(satosin6(f->fu_forw_addr->ai_addr)->sin6_port)); break; #endif + default: + dprintf("\n"); } /* check for local vs remote messages */ if (strcasecmp(f->f_prevhost, LocalHostName)) From owner-svn-src-head@freebsd.org Thu Dec 22 10:11:04 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C8A11C8A4E7; Thu, 22 Dec 2016 10:11:04 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 8AE1313A7; Thu, 22 Dec 2016 10:11:04 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBMAB3tc072110; Thu, 22 Dec 2016 10:11:03 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBMAB3vW072109; Thu, 22 Dec 2016 10:11:03 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201612221011.uBMAB3vW072109@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Thu, 22 Dec 2016 10:11:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310387 - head/sys/dev/mlx5/mlx5_en X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 10:11:04 -0000 Author: hselasky Date: Thu Dec 22 10:11:03 2016 New Revision: 310387 URL: https://svnweb.freebsd.org/changeset/base/310387 Log: Add more comments regarding collection of statistics counters. Sponsored by: Mellanox Technologies MFC after: 1 week Modified: head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Modified: head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c ============================================================================== --- head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Thu Dec 22 05:57:45 2016 (r310386) +++ head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Thu Dec 22 10:11:03 2016 (r310387) @@ -306,6 +306,12 @@ mlx5e_update_carrier_work(struct work_st PRIV_UNLOCK(priv); } +/* + * This function reads the physical port counters from the firmware + * using a pre-defined layout defined by various MLX5E_PPORT_XXX() + * macros. The output is converted from big-endian 64-bit values into + * host endian ones and stored in the "priv->stats.pport" structure. + */ static void mlx5e_update_pport_counters(struct mlx5e_priv *priv) { @@ -319,20 +325,27 @@ mlx5e_update_pport_counters(struct mlx5e unsigned x; unsigned y; + /* allocate firmware request structures */ in = mlx5_vzalloc(sz); out = mlx5_vzalloc(sz); if (in == NULL || out == NULL) goto free_out; + /* + * Get pointer to the 64-bit counter set which is located at a + * fixed offset in the output firmware request structure: + */ ptr = (uint64_t *)MLX5_ADDR_OF(ppcnt_reg, out, counter_set); MLX5_SET(ppcnt_reg, in, local_port, 1); + /* read IEEE802_3 counter group using predefined counter layout */ MLX5_SET(ppcnt_reg, in, grp, MLX5_IEEE_802_3_COUNTERS_GROUP); mlx5_core_access_reg(mdev, in, sz, out, sz, MLX5_REG_PPCNT, 0, 0); for (x = y = 0; x != MLX5E_PPORT_IEEE802_3_STATS_NUM; x++, y++) s->arg[y] = be64toh(ptr[x]); + /* read RFC2819 counter group using predefined counter layout */ MLX5_SET(ppcnt_reg, in, grp, MLX5_RFC_2819_COUNTERS_GROUP); mlx5_core_access_reg(mdev, in, sz, out, sz, MLX5_REG_PPCNT, 0, 0); for (x = 0; x != MLX5E_PPORT_RFC2819_STATS_NUM; x++, y++) @@ -341,20 +354,29 @@ mlx5e_update_pport_counters(struct mlx5e MLX5E_PPORT_RFC2819_STATS_DEBUG_NUM; x++, y++) s_debug->arg[y] = be64toh(ptr[x]); + /* read RFC2863 counter group using predefined counter layout */ MLX5_SET(ppcnt_reg, in, grp, MLX5_RFC_2863_COUNTERS_GROUP); mlx5_core_access_reg(mdev, in, sz, out, sz, MLX5_REG_PPCNT, 0, 0); for (x = 0; x != MLX5E_PPORT_RFC2863_STATS_DEBUG_NUM; x++, y++) s_debug->arg[y] = be64toh(ptr[x]); + /* read physical layer stats counter group using predefined counter layout */ MLX5_SET(ppcnt_reg, in, grp, MLX5_PHYSICAL_LAYER_COUNTERS_GROUP); mlx5_core_access_reg(mdev, in, sz, out, sz, MLX5_REG_PPCNT, 0, 0); for (x = 0; x != MLX5E_PPORT_PHYSICAL_LAYER_STATS_DEBUG_NUM; x++, y++) s_debug->arg[y] = be64toh(ptr[x]); free_out: + /* free firmware request structures */ kvfree(in); kvfree(out); } +/* + * This function is called regularly to collect all statistics + * counters from the firmware. The values can be viewed through the + * sysctl interface. Execution is serialized using the priv's global + * configuration lock. + */ static void mlx5e_update_stats_work(struct work_struct *work) { From owner-svn-src-head@freebsd.org Thu Dec 22 10:12:20 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E400BC8A6ED; Thu, 22 Dec 2016 10:12:20 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 ACBB6167D; Thu, 22 Dec 2016 10:12:20 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBMACJV2075663; Thu, 22 Dec 2016 10:12:19 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBMACJQB075662; Thu, 22 Dec 2016 10:12:19 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201612221012.uBMACJQB075662@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Thu, 22 Dec 2016 10:12:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310388 - head/sys/dev/mlx5/mlx5_en X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 10:12:21 -0000 Author: hselasky Date: Thu Dec 22 10:12:19 2016 New Revision: 310388 URL: https://svnweb.freebsd.org/changeset/base/310388 Log: Make a read only pointer constant. Sponsored by: Mellanox Technologies MFC after: 1 week Modified: head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Modified: head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c ============================================================================== --- head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Thu Dec 22 10:11:03 2016 (r310387) +++ head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Thu Dec 22 10:12:19 2016 (r310388) @@ -320,7 +320,7 @@ mlx5e_update_pport_counters(struct mlx5e struct mlx5e_port_stats_debug *s_debug = &priv->stats.port_stats_debug; u32 *in; u32 *out; - u64 *ptr; + const u64 *ptr; unsigned sz = MLX5_ST_SZ_BYTES(ppcnt_reg); unsigned x; unsigned y; @@ -335,7 +335,7 @@ mlx5e_update_pport_counters(struct mlx5e * Get pointer to the 64-bit counter set which is located at a * fixed offset in the output firmware request structure: */ - ptr = (uint64_t *)MLX5_ADDR_OF(ppcnt_reg, out, counter_set); + ptr = (const uint64_t *)MLX5_ADDR_OF(ppcnt_reg, out, counter_set); MLX5_SET(ppcnt_reg, in, local_port, 1); From owner-svn-src-head@freebsd.org Thu Dec 22 11:10:12 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id ADDA5C8B99B; Thu, 22 Dec 2016 11:10:12 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 71A6714C6; Thu, 22 Dec 2016 11:10:12 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBMBABx5095989; Thu, 22 Dec 2016 11:10:11 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBMBABC9095987; Thu, 22 Dec 2016 11:10:11 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201612221110.uBMBABC9095987@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 22 Dec 2016 11:10:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310389 - head/sys/cam/ctl X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 11:10:12 -0000 Author: mav Date: Thu Dec 22 11:10:11 2016 New Revision: 310389 URL: https://svnweb.freebsd.org/changeset/base/310389 Log: Fix REPORT SUPPORTED OPERATION CODES for READ/WRITE BUFFER commands. Specifications require MODE parameter of those commands to be treated the same as SERVICE ACTION parameter of other commands. MFC after: 2 weeks Modified: head/sys/cam/ctl/ctl.c head/sys/cam/ctl/ctl_cmd_table.c Modified: head/sys/cam/ctl/ctl.c ============================================================================== --- head/sys/cam/ctl/ctl.c Thu Dec 22 10:12:19 2016 (r310388) +++ head/sys/cam/ctl/ctl.c Thu Dec 22 11:10:11 2016 (r310389) @@ -5517,19 +5517,6 @@ ctl_read_buffer(struct ctl_scsiio *ctsio return (CTL_RETVAL_COMPLETE); } - if ((byte2 & RWB_MODE) != RWB_MODE_DATA && - (byte2 & RWB_MODE) != RWB_MODE_ECHO_DESCR && - (byte2 & RWB_MODE) != RWB_MODE_DESCR) { - ctl_set_invalid_field(ctsio, - /*sks_valid*/ 1, - /*command*/ 1, - /*field*/ 1, - /*bit_valid*/ 1, - /*bit*/ 4); - ctl_done((union ctl_io *)ctsio); - return (CTL_RETVAL_COMPLETE); - } - if (buffer_offset > CTL_WRITE_BUFFER_SIZE || buffer_offset + len > CTL_WRITE_BUFFER_SIZE) { ctl_set_invalid_field(ctsio, @@ -5580,17 +5567,6 @@ ctl_write_buffer(struct ctl_scsiio *ctsi lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; cdb = (struct scsi_write_buffer *)ctsio->cdb; - if ((cdb->byte2 & RWB_MODE) != RWB_MODE_DATA) { - ctl_set_invalid_field(ctsio, - /*sks_valid*/ 1, - /*command*/ 1, - /*field*/ 1, - /*bit_valid*/ 1, - /*bit*/ 4); - ctl_done((union ctl_io *)ctsio); - return (CTL_RETVAL_COMPLETE); - } - len = scsi_3btoul(cdb->length); buffer_offset = scsi_3btoul(cdb->offset); Modified: head/sys/cam/ctl/ctl_cmd_table.c ============================================================================== --- head/sys/cam/ctl/ctl_cmd_table.c Thu Dec 22 10:12:19 2016 (r310388) +++ head/sys/cam/ctl/ctl_cmd_table.c Thu Dec 22 11:10:11 2016 (r310389) @@ -62,6 +62,215 @@ * tables. */ +/* 3B WRITE BUFFER */ +const struct ctl_cmd_entry ctl_cmd_table_3b[32] = +{ +/* 00 WRITE BUFFER HDR DATA */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 01 WRITE BUFFER VENDOR */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 02 WRITE BUFFER DATA */ +{ctl_write_buffer, CTL_SERIDX_MD_SEL, CTL_CMD_FLAG_OK_ON_BOTH | + CTL_CMD_FLAG_OK_ON_NO_MEDIA | + CTL_CMD_FLAG_OK_ON_STANDBY | + CTL_FLAG_DATA_OUT, + CTL_LUN_PAT_NONE, + 10, {0x02, 0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07}}, + +/* 03 WRITE BUFFER DESCR */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 04 WRITE BUFFER DOWNLOAD */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 05 WRITE BUFFER DOWNLOAD SAVE */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 06 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 07 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 08 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 09 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 0A WRITE BUFFER ECHO */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 0B WRITE BUFFER ECHO DESCRIPTOR */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 0C */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 0D */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 0E */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 0F */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 10 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 11 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 12 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 13 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 14 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 15 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 16 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 17 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 18 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 19 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 1A */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 1B */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 1C WRITE BUFFER ERROR HISTORY */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 1d-1f */ +}; + +/* 3C READ BUFFER(10) */ +const struct ctl_cmd_entry ctl_cmd_table_3c[32] = +{ +/* 00 READ BUFFER(10) HDR DATA */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 01 READ BUFFER(10) VENDOR */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 02 READ BUFFER(10) DATA */ +{ctl_read_buffer, CTL_SERIDX_MD_SNS, CTL_CMD_FLAG_OK_ON_BOTH | + CTL_CMD_FLAG_OK_ON_NO_MEDIA | + CTL_CMD_FLAG_OK_ON_STANDBY | + CTL_FLAG_DATA_IN | + CTL_CMD_FLAG_ALLOW_ON_PR_WRESV, + CTL_LUN_PAT_NONE, + 10, {0x02, 0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07}}, + +/* 03 READ BUFFER(10) DESCR */ +{ctl_read_buffer, CTL_SERIDX_MD_SNS, CTL_CMD_FLAG_OK_ON_BOTH | + CTL_CMD_FLAG_OK_ON_NO_MEDIA | + CTL_CMD_FLAG_OK_ON_STANDBY | + CTL_FLAG_DATA_IN | + CTL_CMD_FLAG_ALLOW_ON_PR_WRESV, + CTL_LUN_PAT_NONE, + 10, {0x03, 0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07}}, + +/* 04 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 05 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 06 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 07 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 08 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 09 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 0A READ BUFFER(10) ECHO */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 0B READ BUFFER(10) ECHO DESCRIPTOR */ +{ctl_read_buffer, CTL_SERIDX_MD_SNS, CTL_CMD_FLAG_OK_ON_BOTH | + CTL_CMD_FLAG_OK_ON_NO_MEDIA | + CTL_CMD_FLAG_OK_ON_STANDBY | + CTL_FLAG_DATA_IN | + CTL_CMD_FLAG_ALLOW_ON_PR_WRESV, + CTL_LUN_PAT_NONE, + 10, {0x0b, 0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07}}, + +/* 0C */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 0D */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 0E */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 0F */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 10 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 11 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 12 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 13 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 14 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 15 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 16 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 17 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 18 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 19 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 1A */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 1B */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 1C READ BUFFER(10) ERROR HISTORY */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 1d-1f */ +}; + /* 5E PERSISTENT RESERVE IN */ const struct ctl_cmd_entry ctl_cmd_table_5e[32] = { @@ -367,6 +576,118 @@ const struct ctl_cmd_entry ctl_cmd_table 16, {0x08, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff, 0xff, 0xff, 0, 0x07}}, }; +/* 9B READ BUFFER(16) */ +const struct ctl_cmd_entry ctl_cmd_table_9b[32] = +{ +/* 00 READ BUFFER(16) HDR DATA */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 01 READ BUFFER(16) VENDOR */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 02 READ BUFFER(16) DATA */ +{ctl_read_buffer, CTL_SERIDX_MD_SNS, CTL_CMD_FLAG_OK_ON_BOTH | + CTL_CMD_FLAG_OK_ON_NO_MEDIA | + CTL_CMD_FLAG_OK_ON_STANDBY | + CTL_FLAG_DATA_IN, + CTL_LUN_PAT_NONE, + 16, {0x02, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0x07}}, + +/* 03 READ BUFFER(16) DESCR */ +{ctl_read_buffer, CTL_SERIDX_MD_SNS, CTL_CMD_FLAG_OK_ON_BOTH | + CTL_CMD_FLAG_OK_ON_NO_MEDIA | + CTL_CMD_FLAG_OK_ON_STANDBY | + CTL_FLAG_DATA_IN, + CTL_LUN_PAT_NONE, + 16, {0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0x07}}, + +/* 04 READ BUFFER(16) */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 05 READ BUFFER(16) */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 06 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 07 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 08 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 09 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 0A READ BUFFER(16) ECHO */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 0B READ BUFFER(16) ECHO DESCRIPTOR */ +{ctl_read_buffer, CTL_SERIDX_MD_SNS, CTL_CMD_FLAG_OK_ON_BOTH | + CTL_CMD_FLAG_OK_ON_NO_MEDIA | + CTL_CMD_FLAG_OK_ON_STANDBY | + CTL_FLAG_DATA_IN, + CTL_LUN_PAT_NONE, + 16, {0x0b, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0x07}}, + +/* 0C */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 0D */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 0E */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 0F */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 10 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 11 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 12 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 13 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 14 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 15 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 16 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 17 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 18 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 19 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 1A */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 1B */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 1C READ BUFFER(16) ERROR HISTORY */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 1d-1f */ +}; + + /* 9E SERVICE ACTION IN(16) */ const struct ctl_cmd_entry ctl_cmd_table_9e[32] = { @@ -782,21 +1103,12 @@ const struct ctl_cmd_entry ctl_cmd_table {NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, /* 3B WRITE BUFFER */ -{ctl_write_buffer, CTL_SERIDX_MD_SEL, CTL_CMD_FLAG_OK_ON_BOTH | - CTL_CMD_FLAG_OK_ON_NO_MEDIA | - CTL_CMD_FLAG_OK_ON_STANDBY | - CTL_FLAG_DATA_OUT, - CTL_LUN_PAT_NONE, - 10, {0x1f, 0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07}}, +{__DECONST(ctl_opfunc *, ctl_cmd_table_3b), CTL_SERIDX_INVLD, CTL_CMD_FLAG_SA5, + CTL_LUN_PAT_NONE}, /* 3C READ BUFFER */ -{ctl_read_buffer, CTL_SERIDX_MD_SNS, CTL_CMD_FLAG_OK_ON_BOTH | - CTL_CMD_FLAG_OK_ON_NO_MEDIA | - CTL_CMD_FLAG_OK_ON_STANDBY | - CTL_FLAG_DATA_IN | - CTL_CMD_FLAG_ALLOW_ON_PR_WRESV, - CTL_LUN_PAT_NONE, - 10, {0x1f, 0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07}}, +{__DECONST(ctl_opfunc *, ctl_cmd_table_3c), CTL_SERIDX_INVLD, CTL_CMD_FLAG_SA5, + CTL_LUN_PAT_NONE}, /* 3D UPDATE BLOCK */ {NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, @@ -1154,14 +1466,8 @@ const struct ctl_cmd_entry ctl_cmd_table {NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, /* 9B READ BUFFER(16) */ -{ctl_read_buffer, CTL_SERIDX_MD_SNS, CTL_CMD_FLAG_OK_ON_BOTH | - CTL_CMD_FLAG_OK_ON_NO_MEDIA | - CTL_CMD_FLAG_OK_ON_STANDBY | - CTL_FLAG_DATA_IN | - CTL_CMD_FLAG_ALLOW_ON_PR_WRESV, - CTL_LUN_PAT_NONE, - 10, {0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0x07}}, +{__DECONST(ctl_opfunc *, ctl_cmd_table_9b), CTL_SERIDX_INVLD, CTL_CMD_FLAG_SA5, + CTL_LUN_PAT_NONE}, /* 9C WRITE ATOMIC (16) */ {ctl_read_write, CTL_SERIDX_WRITE, CTL_CMD_FLAG_OK_ON_DIRECT| CTL_FLAG_DATA_OUT, From owner-svn-src-head@freebsd.org Thu Dec 22 12:18:42 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3C77CC8B8B4; Thu, 22 Dec 2016 12:18:42 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 1735F1D57; Thu, 22 Dec 2016 12:18:42 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBMCIfr3024341; Thu, 22 Dec 2016 12:18:41 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBMCIft4024338; Thu, 22 Dec 2016 12:18:41 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201612221218.uBMCIft4024338@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 22 Dec 2016 12:18:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310390 - in head/sys/cam: ctl scsi X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 12:18:42 -0000 Author: mav Date: Thu Dec 22 12:18:40 2016 New Revision: 310390 URL: https://svnweb.freebsd.org/changeset/base/310390 Log: Add support for REPD bit in RSTMF command. We have no real timeout values to report there, but its better then error. MFC after: 2 weeks Modified: head/sys/cam/ctl/ctl.c head/sys/cam/ctl/ctl_cmd_table.c head/sys/cam/scsi/scsi_all.h Modified: head/sys/cam/ctl/ctl.c ============================================================================== --- head/sys/cam/ctl/ctl.c Thu Dec 22 11:10:11 2016 (r310389) +++ head/sys/cam/ctl/ctl.c Thu Dec 22 12:18:40 2016 (r310390) @@ -7462,7 +7462,7 @@ int ctl_report_supported_tmf(struct ctl_scsiio *ctsio) { struct scsi_report_supported_tmf *cdb; - struct scsi_report_supported_tmf_data *data; + struct scsi_report_supported_tmf_ext_data *data; int retval; int alloc_len, total_len; @@ -7472,7 +7472,10 @@ ctl_report_supported_tmf(struct ctl_scsi retval = CTL_RETVAL_COMPLETE; - total_len = sizeof(struct scsi_report_supported_tmf_data); + if (cdb->options & RST_REPD) + total_len = sizeof(struct scsi_report_supported_tmf_ext_data); + else + total_len = sizeof(struct scsi_report_supported_tmf_data); alloc_len = scsi_4btoul(cdb->length); ctsio->kern_data_ptr = malloc(total_len, M_CTL, M_WAITOK | M_ZERO); @@ -7491,10 +7494,11 @@ ctl_report_supported_tmf(struct ctl_scsi ctsio->kern_data_resid = 0; ctsio->kern_rel_offset = 0; - data = (struct scsi_report_supported_tmf_data *)ctsio->kern_data_ptr; + data = (struct scsi_report_supported_tmf_ext_data *)ctsio->kern_data_ptr; data->byte1 |= RST_ATS | RST_ATSS | RST_CTSS | RST_LURS | RST_QTS | RST_TRS; data->byte2 |= RST_QAES | RST_QTSS | RST_ITNRS; + data->length = total_len - 4; ctl_set_success(ctsio); ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; Modified: head/sys/cam/ctl/ctl_cmd_table.c ============================================================================== --- head/sys/cam/ctl/ctl_cmd_table.c Thu Dec 22 11:10:11 2016 (r310389) +++ head/sys/cam/ctl/ctl_cmd_table.c Thu Dec 22 12:18:40 2016 (r310390) @@ -824,7 +824,7 @@ const struct ctl_cmd_entry ctl_cmd_table CTL_FLAG_DATA_IN | CTL_CMD_FLAG_ALLOW_ON_PR_RESV, CTL_LUN_PAT_NONE, - 12, {0x0d, 0, 0, 0, 0, 0xff, 0xff, 0xff, 0xff, 0, 0x07}}, + 12, {0x0d, 0x80, 0, 0, 0, 0xff, 0xff, 0xff, 0xff, 0, 0x07}}, /* 0E */ {NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, Modified: head/sys/cam/scsi/scsi_all.h ============================================================================== --- head/sys/cam/scsi/scsi_all.h Thu Dec 22 11:10:11 2016 (r310389) +++ head/sys/cam/scsi/scsi_all.h Thu Dec 22 12:18:40 2016 (r310390) @@ -1482,6 +1482,10 @@ struct scsi_report_supported_opcodes_des uint8_t flags; #define RSO_SERVACTV 0x01 #define RSO_CTDP 0x02 +#define RSO_CDLP_MASK 0x0c +#define RSO_CDLP_NO 0x00 +#define RSO_CDLP_A 0x04 +#define RSO_CDLP_B 0x08 uint8_t cdb_length[2]; struct scsi_report_supported_opcodes_timeout timeout[0]; }; @@ -1497,6 +1501,10 @@ struct scsi_report_supported_opcodes_one uint8_t reserved; uint8_t support; #define RSO_ONE_CTDP 0x80 +#define RSO_ONE_CDLP_MASK 0x18 +#define RSO_ONE_CDLP_NO 0x00 +#define RSO_ONE_CDLP_A 0x08 +#define RSO_ONE_CDLP_B 0x10 #define RSO_ONE_SUP_MASK 0x07 #define RSO_ONE_SUP_UNAVAIL 0x00 #define RSO_ONE_SUP_NOT_SUP 0x01 @@ -1510,7 +1518,9 @@ struct scsi_report_supported_tmf { uint8_t opcode; uint8_t service_action; - uint8_t reserved[4]; + uint8_t options; +#define RST_REPD 0x80 + uint8_t reserved[3]; uint8_t length[4]; uint8_t reserved1; uint8_t control; @@ -1531,7 +1541,34 @@ struct scsi_report_supported_tmf_data #define RST_ITNRS 0x01 #define RST_QTSS 0x02 #define RST_QAES 0x04 - uint8_t reserved[2]; + uint8_t reserved; + uint8_t length; +}; + +struct scsi_report_supported_tmf_ext_data +{ + uint8_t byte1; + uint8_t byte2; + uint8_t reserved; + uint8_t length; + uint8_t byte5; +#define RST_TMFTMOV 0x01 + uint8_t reserved2; + uint8_t byte7; +#define RST_WAKETS 0x01 +#define RST_TRTS 0x02 +#define RST_QTTS 0x04 +#define RST_LURTS 0x08 +#define RST_CTSTS 0x10 +#define RST_CACATS 0x20 +#define RST_ATSTS 0x40 +#define RST_ATTS 0x80 + uint8_t byte8; +#define RST_ITNRTS 0x01 +#define RST_QTSTS 0x02 +#define RST_QAETS 0x04 + uint8_t long_timeout[4]; + uint8_t short_timeout[4]; }; struct scsi_report_timestamp From owner-svn-src-head@freebsd.org Thu Dec 22 13:46:18 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B7278C8A289; Thu, 22 Dec 2016 13:46:18 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 913C918D6; Thu, 22 Dec 2016 13:46:18 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBMDkHhr060781; Thu, 22 Dec 2016 13:46:17 GMT (envelope-from hrs@FreeBSD.org) Received: (from hrs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBMDkH4h060780; Thu, 22 Dec 2016 13:46:17 GMT (envelope-from hrs@FreeBSD.org) Message-Id: <201612221346.uBMDkH4h060780@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hrs set sender to hrs@FreeBSD.org using -f From: Hiroki Sato Date: Thu, 22 Dec 2016 13:46:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310393 - head/usr.sbin/syslogd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 13:46:18 -0000 Author: hrs Date: Thu Dec 22 13:46:17 2016 New Revision: 310393 URL: https://svnweb.freebsd.org/changeset/base/310393 Log: - Fix a use-after-free bug when dq_timeout == 1 and sending SIGTERM to the process failed. It is an unusual situation but it can happen. - Split deadq_remove() into deadq_remove() and deadq_removebypid(). - Normalize variable names of struct deadq_entry *. Modified: head/usr.sbin/syslogd/syslogd.c Modified: head/usr.sbin/syslogd/syslogd.c ============================================================================== --- head/usr.sbin/syslogd/syslogd.c Thu Dec 22 13:38:50 2016 (r310392) +++ head/usr.sbin/syslogd/syslogd.c Thu Dec 22 13:46:17 2016 (r310393) @@ -236,9 +236,6 @@ static TAILQ_HEAD(, deadq_entry) deadq_h #define DQ_TIMO_INIT 2 -typedef struct deadq_entry *dq_t; - - /* * Struct to hold records of network addresses that are allowed to log * to us. @@ -334,7 +331,8 @@ static int addsock(struct sockaddr *, so static struct filed *cfline(const char *, const char *, const char *); static const char *cvthname(struct sockaddr *); static void deadq_enter(pid_t, const char *); -static int deadq_remove(pid_t); +static int deadq_remove(struct deadq_entry *); +static int deadq_removebypid(pid_t); static int decode(const char *, const CODE *); static void die(int) __dead2; static void dodie(int); @@ -1509,7 +1507,7 @@ reapchild(int signo __unused) continue; /* First, look if it's a process from the dead queue. */ - if (deadq_remove(pid)) + if (deadq_removebypid(pid)) continue; /* Now, look in list of active processes. */ @@ -2252,7 +2250,7 @@ static void markit(void) { struct filed *f; - dq_t q, next; + struct deadq_entry *dq, *dq0; now = time((time_t *)NULL); MarkSeq += TIMERINTVL; @@ -2273,14 +2271,12 @@ markit(void) } /* Walk the dead queue, and see if we should signal somebody. */ - for (q = TAILQ_FIRST(&deadq_head); q != NULL; q = next) { - next = TAILQ_NEXT(q, dq_entries); - - switch (q->dq_timeout) { + TAILQ_FOREACH_SAFE(dq, &deadq_head, dq_entries, dq0) { + switch (dq->dq_timeout) { case 0: /* Already signalled once, try harder now. */ - if (kill(q->dq_pid, SIGKILL) != 0) - (void)deadq_remove(q->dq_pid); + if (kill(dq->dq_pid, SIGKILL) != 0) + (void)deadq_remove(dq); break; case 1: @@ -2292,12 +2288,13 @@ markit(void) * didn't even really exist, in case we simply * drop it from the dead queue). */ - if (kill(q->dq_pid, SIGTERM) != 0) - (void)deadq_remove(q->dq_pid); - /* FALLTHROUGH */ - + if (kill(dq->dq_pid, SIGTERM) != 0) + (void)deadq_remove(dq); + else + dq->dq_timeout--; + break; default: - q->dq_timeout--; + dq->dq_timeout--; } } MarkSet = 0; @@ -2738,7 +2735,7 @@ p_open(const char *prog, pid_t *rpid) static void deadq_enter(pid_t pid, const char *name) { - dq_t p; + struct deadq_entry *dq; int status; /* @@ -2752,36 +2749,42 @@ deadq_enter(pid_t pid, const char *name) return; } - p = malloc(sizeof(struct deadq_entry)); - if (p == NULL) { + dq = malloc(sizeof(*dq)); + if (dq == NULL) { logerror("malloc"); exit(1); } - *p = (struct deadq_entry){ + *dq = (struct deadq_entry){ .dq_pid = pid, .dq_timeout = DQ_TIMO_INIT }; - TAILQ_INSERT_TAIL(&deadq_head, p, dq_entries); + TAILQ_INSERT_TAIL(&deadq_head, dq, dq_entries); } static int -deadq_remove(pid_t pid) +deadq_remove(struct deadq_entry *dq) { - dq_t q; - - TAILQ_FOREACH(q, &deadq_head, dq_entries) { - if (q->dq_pid == pid) - break; - } - if (q != NULL) { - TAILQ_REMOVE(&deadq_head, q, dq_entries); - free(q); + if (dq != NULL) { + TAILQ_REMOVE(&deadq_head, dq, dq_entries); + free(dq); return (1); } return (0); } +static int +deadq_removebypid(pid_t pid) +{ + struct deadq_entry *dq; + + TAILQ_FOREACH(dq, &deadq_head, dq_entries) { + if (dq->dq_pid == pid) + break; + } + return (deadq_remove(dq)); +} + static void log_deadchild(pid_t pid, int status, const char *name) { From owner-svn-src-head@freebsd.org Thu Dec 22 15:01:07 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B2B34C8B87B; Thu, 22 Dec 2016 15:01:07 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 81EA31418; Thu, 22 Dec 2016 15:01:07 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBMF16X5090886; Thu, 22 Dec 2016 15:01:06 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBMF16LR090885; Thu, 22 Dec 2016 15:01:06 GMT (envelope-from manu@FreeBSD.org) Message-Id: <201612221501.uBMF16LR090885@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Thu, 22 Dec 2016 15:01:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310414 - head/sys/arm/allwinner/clk X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 15:01:07 -0000 Author: manu Date: Thu Dec 22 15:01:06 2016 New Revision: 310414 URL: https://svnweb.freebsd.org/changeset/base/310414 Log: Allwinner clk: factor M for mod clock is 4 bits, not 5 MFC after: 1 week Modified: head/sys/arm/allwinner/clk/aw_modclk.c Modified: head/sys/arm/allwinner/clk/aw_modclk.c ============================================================================== --- head/sys/arm/allwinner/clk/aw_modclk.c Thu Dec 22 14:27:07 2016 (r310413) +++ head/sys/arm/allwinner/clk/aw_modclk.c Thu Dec 22 15:01:06 2016 (r310414) @@ -56,9 +56,9 @@ __FBSDID("$FreeBSD$"); #define CLK_RATIO_N (0x3 << 16) #define CLK_RATIO_N_SHIFT 16 #define CLK_RATIO_N_MAX 0x3 -#define CLK_RATIO_M (0x1f << 0) +#define CLK_RATIO_M (0xf << 0) #define CLK_RATIO_M_SHIFT 0 -#define CLK_RATIO_M_MAX 0x1f +#define CLK_RATIO_M_MAX 0xf static struct ofw_compat_data compat_data[] = { { "allwinner,sun4i-a10-mod0-clk", 1 }, From owner-svn-src-head@freebsd.org Thu Dec 22 15:48:55 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A3ACDC8B7F5; Thu, 22 Dec 2016 15:48:55 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 7345013D7; Thu, 22 Dec 2016 15:48:55 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBMFmsWE010708; Thu, 22 Dec 2016 15:48:54 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBMFmsgm010707; Thu, 22 Dec 2016 15:48:54 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201612221548.uBMFmsgm010707@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Thu, 22 Dec 2016 15:48:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310417 - head/sys/boot/forth X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 15:48:55 -0000 Author: asomers Date: Thu Dec 22 15:48:54 2016 New Revision: 310417 URL: https://svnweb.freebsd.org/changeset/base/310417 Log: Add a dumpdev example to /boot/defaults/loader.conf Submitted by: rgrimes MFC after: 4 weeks Sponsored by: Spectra Logic Corp Modified: head/sys/boot/forth/loader.conf Modified: head/sys/boot/forth/loader.conf ============================================================================== --- head/sys/boot/forth/loader.conf Thu Dec 22 15:46:12 2016 (r310416) +++ head/sys/boot/forth/loader.conf Thu Dec 22 15:48:54 2016 (r310417) @@ -101,6 +101,7 @@ module_path="/boot/modules" # Set the mo #prompt="\\${interpret}" # Set the command prompt #root_disk_unit="0" # Force the root disk unit number #rootdev="disk1s1a" # Set the root filesystem +#dumpdev="disk1s1b" # Set a dump device early in the boot process #tftp.blksize="1428" # Set the RFC 2348 TFTP block size. # If the TFTP server does not support RFC 2348, # the block size is set to 512. If the value From owner-svn-src-head@freebsd.org Thu Dec 22 16:09:46 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2B120C8C066; Thu, 22 Dec 2016 16:09:46 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 053FF37C; Thu, 22 Dec 2016 16:09:45 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBMG9jNK019187; Thu, 22 Dec 2016 16:09:45 GMT (envelope-from royger@FreeBSD.org) Received: (from royger@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBMG9i3l019183; Thu, 22 Dec 2016 16:09:44 GMT (envelope-from royger@FreeBSD.org) Message-Id: <201612221609.uBMG9i3l019183@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: royger set sender to royger@FreeBSD.org using -f From: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Date: Thu, 22 Dec 2016 16:09:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310418 - in head/sys: dev/xen/evtchn x86/xen xen X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 16:09:46 -0000 Author: royger Date: Thu Dec 22 16:09:44 2016 New Revision: 310418 URL: https://svnweb.freebsd.org/changeset/base/310418 Log: xen: fix IPI setup with EARLY_AP_STARTUP Current Xen IPI setup functions require that the caller provide a device in order to obtain the name of the interrupt from it. With early AP startup this device is no longer available at the point where IPIs are bound, and a KASSERT would trigger: panic: NULL pcpu device_t cpuid = 0 KDB: stack backtrace: db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xffffffff82233a20 vpanic() at vpanic+0x186/frame 0xffffffff82233aa0 kassert_panic() at kassert_panic+0x126/frame 0xffffffff82233b10 xen_setup_cpus() at xen_setup_cpus+0x5b/frame 0xffffffff82233b50 mi_startup() at mi_startup+0x118/frame 0xffffffff82233b70 btext() at btext+0x2c Fix this by no longer requiring the presence of a device in order to bind IPIs, and simply use the "cpuX" format where X is the CPU identifier in order to describe the interrupt. Reported by: sbruno, cperciva Tested by: sbruno X-MFC-With: r310177 Sponsored by: Citrix Systems R&D Modified: head/sys/dev/xen/evtchn/evtchn_dev.c head/sys/x86/xen/xen_apic.c head/sys/x86/xen/xen_intr.c head/sys/xen/xen_intr.h Modified: head/sys/dev/xen/evtchn/evtchn_dev.c ============================================================================== --- head/sys/dev/xen/evtchn/evtchn_dev.c Thu Dec 22 15:48:54 2016 (r310417) +++ head/sys/dev/xen/evtchn/evtchn_dev.c Thu Dec 22 16:09:44 2016 (r310418) @@ -373,9 +373,9 @@ evtchn_bind_user_port(struct per_user_da mtx_lock(&u->bind_mutex); RB_INSERT(evtchn_tree, &u->evtchns, evtchn); mtx_unlock(&u->bind_mutex); - error = xen_intr_add_handler(evtchn_dev, evtchn_filter, - evtchn_interrupt, evtchn, INTR_TYPE_MISC | INTR_MPSAFE, - evtchn->handle); + error = xen_intr_add_handler(device_get_nameunit(evtchn_dev), + evtchn_filter, evtchn_interrupt, evtchn, + INTR_TYPE_MISC | INTR_MPSAFE, evtchn->handle); if (error != 0) { xen_intr_unbind(&evtchn->handle); mtx_lock(&u->bind_mutex); Modified: head/sys/x86/xen/xen_apic.c ============================================================================== --- head/sys/x86/xen/xen_apic.c Thu Dec 22 15:48:54 2016 (r310417) +++ head/sys/x86/xen/xen_apic.c Thu Dec 22 16:09:44 2016 (r310418) @@ -500,12 +500,9 @@ xen_cpu_ipi_init(int cpu) { xen_intr_handle_t *ipi_handle; const struct xen_ipi_handler *ipi; - device_t dev; int idx, rc; ipi_handle = DPCPU_ID_GET(cpu, ipi_handle); - dev = pcpu_find(cpu)->pc_device; - KASSERT((dev != NULL), ("NULL pcpu device_t")); for (ipi = xen_ipis, idx = 0; idx < nitems(xen_ipis); ipi++, idx++) { @@ -514,7 +511,7 @@ xen_cpu_ipi_init(int cpu) continue; } - rc = xen_intr_alloc_and_bind_ipi(dev, cpu, ipi->filter, + rc = xen_intr_alloc_and_bind_ipi(cpu, ipi->filter, INTR_TYPE_TTY, &ipi_handle[idx]); if (rc != 0) panic("Unable to allocate a XEN IPI port"); Modified: head/sys/x86/xen/xen_intr.c ============================================================================== --- head/sys/x86/xen/xen_intr.c Thu Dec 22 15:48:54 2016 (r310417) +++ head/sys/x86/xen/xen_intr.c Thu Dec 22 16:09:44 2016 (r310418) @@ -392,7 +392,7 @@ xen_intr_release_isrc(struct xenisrc *is */ static int xen_intr_bind_isrc(struct xenisrc **isrcp, evtchn_port_t local_port, - enum evtchn_type type, device_t intr_owner, driver_filter_t filter, + enum evtchn_type type, const char *intr_owner, driver_filter_t filter, driver_intr_t handler, void *arg, enum intr_type flags, xen_intr_handle_t *port_handlep) { @@ -401,8 +401,8 @@ xen_intr_bind_isrc(struct xenisrc **isrc *isrcp = NULL; if (port_handlep == NULL) { - device_printf(intr_owner, - "xen_intr_bind_isrc: Bad event handle\n"); + printf("%s: xen_intr_bind_isrc: Bad event handle\n", + intr_owner); return (EINVAL); } @@ -1175,8 +1175,9 @@ xen_intr_bind_local_port(device_t dev, e struct xenisrc *isrc; int error; - error = xen_intr_bind_isrc(&isrc, local_port, EVTCHN_TYPE_PORT, dev, - filter, handler, arg, flags, port_handlep); + error = xen_intr_bind_isrc(&isrc, local_port, EVTCHN_TYPE_PORT, + device_get_nameunit(dev), filter, handler, arg, flags, + port_handlep); if (error != 0) return (error); @@ -1210,8 +1211,8 @@ xen_intr_alloc_and_bind_local_port(devic } error = xen_intr_bind_isrc(&isrc, alloc_unbound.port, EVTCHN_TYPE_PORT, - dev, filter, handler, arg, flags, - port_handlep); + device_get_nameunit(dev), filter, handler, arg, flags, + port_handlep); if (error != 0) { evtchn_close_t close = { .port = alloc_unbound.port }; if (HYPERVISOR_event_channel_op(EVTCHNOP_close, &close)) @@ -1245,8 +1246,8 @@ xen_intr_bind_remote_port(device_t dev, } error = xen_intr_bind_isrc(&isrc, bind_interdomain.local_port, - EVTCHN_TYPE_PORT, dev, filter, handler, - arg, flags, port_handlep); + EVTCHN_TYPE_PORT, device_get_nameunit(dev), filter, handler, arg, + flags, port_handlep); if (error) { evtchn_close_t close = { .port = bind_interdomain.local_port }; if (HYPERVISOR_event_channel_op(EVTCHNOP_close, &close)) @@ -1285,8 +1286,9 @@ xen_intr_bind_virq(device_t dev, u_int v return (-error); } - error = xen_intr_bind_isrc(&isrc, bind_virq.port, EVTCHN_TYPE_VIRQ, dev, - filter, handler, arg, flags, port_handlep); + error = xen_intr_bind_isrc(&isrc, bind_virq.port, EVTCHN_TYPE_VIRQ, + device_get_nameunit(dev), filter, handler, arg, flags, + port_handlep); #ifdef SMP if (error == 0) @@ -1325,14 +1327,15 @@ xen_intr_bind_virq(device_t dev, u_int v } int -xen_intr_alloc_and_bind_ipi(device_t dev, u_int cpu, - driver_filter_t filter, enum intr_type flags, - xen_intr_handle_t *port_handlep) +xen_intr_alloc_and_bind_ipi(u_int cpu, driver_filter_t filter, + enum intr_type flags, xen_intr_handle_t *port_handlep) { #ifdef SMP int vcpu_id = pcpu_find(cpu)->pc_vcpu_id; struct xenisrc *isrc; struct evtchn_bind_ipi bind_ipi = { .vcpu = vcpu_id }; + /* Same size as the one used by intr_handler->ih_name. */ + char name[MAXCOMLEN + 1]; int error; /* Ensure the target CPU is ready to handle evtchn interrupts. */ @@ -1348,12 +1351,10 @@ xen_intr_alloc_and_bind_ipi(device_t dev return (-error); } - error = xen_intr_bind_isrc(&isrc, bind_ipi.port, EVTCHN_TYPE_IPI, - dev, filter, NULL, NULL, flags, - port_handlep); - if (error == 0) - error = intr_event_bind(isrc->xi_intsrc.is_event, cpu); + snprintf(name, sizeof(name), "cpu%u", cpu); + error = xen_intr_bind_isrc(&isrc, bind_ipi.port, EVTCHN_TYPE_IPI, + name, filter, NULL, NULL, flags, port_handlep); if (error != 0) { evtchn_close_t close = { .port = bind_ipi.port }; @@ -1549,7 +1550,7 @@ xen_intr_port(xen_intr_handle_t handle) } int -xen_intr_add_handler(device_t dev, driver_filter_t filter, +xen_intr_add_handler(const char *name, driver_filter_t filter, driver_intr_t handler, void *arg, enum intr_type flags, xen_intr_handle_t handle) { @@ -1560,12 +1561,12 @@ xen_intr_add_handler(device_t dev, drive if (isrc == NULL || isrc->xi_cookie != NULL) return (EINVAL); - error = intr_add_handler(device_get_nameunit(dev), isrc->xi_vector, - filter, handler, arg, flags|INTR_EXCL, &isrc->xi_cookie); + error = intr_add_handler(name, isrc->xi_vector,filter, handler, arg, + flags|INTR_EXCL, &isrc->xi_cookie); if (error != 0) { - device_printf(dev, - "xen_intr_add_handler: intr_add_handler failed: %d\n", - error); + printf( + "%s: xen_intr_add_handler: intr_add_handler failed: %d\n", + name, error); } return (error); Modified: head/sys/xen/xen_intr.h ============================================================================== --- head/sys/xen/xen_intr.h Thu Dec 22 15:48:54 2016 (r310417) +++ head/sys/xen/xen_intr.h Thu Dec 22 16:09:44 2016 (r310418) @@ -143,7 +143,6 @@ int xen_intr_bind_virq(device_t dev, u_i * interupts and, if successful, associate the port with the specified * interrupt handler. * - * \param dev The device making this bind request. * \param cpu The cpu receiving the IPI. * \param filter The interrupt filter servicing this IPI. * \param irqflags Interrupt handler flags. See sys/bus.h. @@ -152,7 +151,7 @@ int xen_intr_bind_virq(device_t dev, u_i * * \returns 0 on success, otherwise an errno. */ -int xen_intr_alloc_and_bind_ipi(device_t dev, u_int cpu, +int xen_intr_alloc_and_bind_ipi(u_int cpu, driver_filter_t filter, enum intr_type irqflags, xen_intr_handle_t *handlep); @@ -259,7 +258,7 @@ int xen_release_msi(int vector); * * \returns 0 on success, otherwise an errno. */ -int xen_intr_add_handler(device_t dev, driver_filter_t filter, +int xen_intr_add_handler(const char *name, driver_filter_t filter, driver_intr_t handler, void *arg, enum intr_type flags, xen_intr_handle_t handle); From owner-svn-src-head@freebsd.org Thu Dec 22 17:21:09 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C1BBFC8C4E5; Thu, 22 Dec 2016 17:21:09 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from mail.baldwin.cx (bigwig.baldwin.cx [96.47.65.170]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9965D1D0F; Thu, 22 Dec 2016 17:21:08 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by mail.baldwin.cx (Postfix) with ESMTPSA id BE39010A745; Thu, 22 Dec 2016 12:21:00 -0500 (EST) From: John Baldwin To: Roger Pau =?ISO-8859-1?Q?Monn=E9?= Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r310418 - in head/sys: dev/xen/evtchn x86/xen xen Date: Thu, 22 Dec 2016 09:20:52 -0800 Message-ID: <1571704.dT3ioqCDCL@ralph.baldwin.cx> User-Agent: KMail/4.14.10 (FreeBSD/11.0-PRERELEASE; KDE/4.14.10; amd64; ; ) In-Reply-To: <201612221609.uBMG9i3l019183@repo.freebsd.org> References: <201612221609.uBMG9i3l019183@repo.freebsd.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mail.baldwin.cx); Thu, 22 Dec 2016 12:21:00 -0500 (EST) X-Virus-Scanned: clamav-milter 0.99.2 at mail.baldwin.cx X-Virus-Status: Clean X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 17:21:09 -0000 On Thursday, December 22, 2016 04:09:44 PM Roger Pau Monn=E9 wrote: > Author: royger > Date: Thu Dec 22 16:09:44 2016 > New Revision: 310418 > URL: https://svnweb.freebsd.org/changeset/base/310418 >=20 > Log: > xen: fix IPI setup with EARLY_AP_STARTUP > =20 > Current Xen IPI setup functions require that the caller provide a d= evice in > order to obtain the name of the interrupt from it. With early AP st= artup this > device is no longer available at the point where IPIs are bound, an= d a KASSERT > would trigger: > =20 > panic: NULL pcpu device_t > cpuid =3D 0 > KDB: stack backtrace: > db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffff= fff82233a20 > vpanic() at vpanic+0x186/frame 0xffffffff82233aa0 > kassert_panic() at kassert_panic+0x126/frame 0xffffffff82233b10 > xen_setup_cpus() at xen_setup_cpus+0x5b/frame 0xffffffff82233b50 > mi_startup() at mi_startup+0x118/frame 0xffffffff82233b70 > btext() at btext+0x2c > =20 > Fix this by no longer requiring the presence of a device in order t= o bind IPIs, > and simply use the "cpuX" format where X is the CPU identifier in o= rder to > describe the interrupt. Thanks for fixing this! > Modified: head/sys/xen/xen_intr.h > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=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/xen/xen_intr.h=09Thu Dec 22 15:48:54 2016=09(r310417) > +++ head/sys/xen/xen_intr.h=09Thu Dec 22 16:09:44 2016=09(r310418) > @@ -143,7 +143,6 @@ int xen_intr_bind_virq(device_t dev, u_i > * interupts and, if successful, associate the port with the specifi= ed > * interrupt handler. > * > - * \param dev The device making this bind request. > * \param cpu The cpu receiving the IPI. > * \param filter The interrupt filter servicing this IPI. > * \param irqflags Interrupt handler flags. See sys/bus.h. > @@ -152,7 +151,7 @@ int xen_intr_bind_virq(device_t dev, u_i > * > * \returns 0 on success, otherwise an errno. > */ > -int xen_intr_alloc_and_bind_ipi(device_t dev, u_int cpu, > +int xen_intr_alloc_and_bind_ipi(u_int cpu, > =09driver_filter_t filter, enum intr_type irqflags, > =09xen_intr_handle_t *handlep); > =20 > @@ -259,7 +258,7 @@ int xen_release_msi(int vector); > * > * \returns 0 on success, otherwise an errno. > */ > -int xen_intr_add_handler(device_t dev, driver_filter_t filter, > +int xen_intr_add_handler(const char *name, driver_filter_t filter, > =09driver_intr_t handler, void *arg, enum intr_type flags, > =09xen_intr_handle_t handle); Does the doxygen comment above this function need the name arg added? --=20 John Baldwin From owner-svn-src-head@freebsd.org Thu Dec 22 17:37:41 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5FF3BC8CC7B; Thu, 22 Dec 2016 17:37:41 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 20BE2779; Thu, 22 Dec 2016 17:37:41 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBMHbeQW055344; Thu, 22 Dec 2016 17:37:40 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBMHbeb7055342; Thu, 22 Dec 2016 17:37:40 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201612221737.uBMHbeb7055342@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Thu, 22 Dec 2016 17:37:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310420 - head/libexec/rtld-elf X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 17:37:41 -0000 Author: markj Date: Thu Dec 22 17:37:39 2016 New Revision: 310420 URL: https://svnweb.freebsd.org/changeset/base/310420 Log: rtld: Fix a race between dl_iterate_phdr() and dlclose(). Add a transient reference count to ensure that the phdr argument to the callback remains valid while the bind lock is dropped. Reviewed by: kib MFC after: 2 weeks Sponsored by: Dell EMC Isilon Modified: head/libexec/rtld-elf/rtld.c head/libexec/rtld-elf/rtld.h Modified: head/libexec/rtld-elf/rtld.c ============================================================================== --- head/libexec/rtld-elf/rtld.c Thu Dec 22 16:19:05 2016 (r310419) +++ head/libexec/rtld-elf/rtld.c Thu Dec 22 17:37:39 2016 (r310420) @@ -87,6 +87,8 @@ static char *errmsg_save(void); static void *fill_search_info(const char *, size_t, void *); static char *find_library(const char *, const Obj_Entry *, int *); static const char *gethints(bool); +static void hold_object(Obj_Entry *); +static void unhold_object(Obj_Entry *); static void init_dag(Obj_Entry *); static void init_pagesizes(Elf_Auxinfo **aux_info); static void init_rtld(caddr_t, Elf_Auxinfo **); @@ -112,6 +114,7 @@ static void objlist_put_after(Objlist *, static void objlist_remove(Objlist *, Obj_Entry *); static int parse_libdir(const char *); static void *path_enumerate(const char *, path_enum_proc, void *); +static void release_object(Obj_Entry *); static int relocate_object_dag(Obj_Entry *root, bool bind_now, Obj_Entry *rtldobj, int flags, RtldLockState *lockstate); static int relocate_object(Obj_Entry *obj, bool bind_now, Obj_Entry *rtldobj, @@ -1852,6 +1855,23 @@ globallist_next(const Obj_Entry *obj) } } +/* Prevent the object from being unmapped while the bind lock is dropped. */ +static void +hold_object(Obj_Entry *obj) +{ + + obj->holdcount++; +} + +static void +unhold_object(Obj_Entry *obj) +{ + + assert(obj->holdcount > 0); + if (--obj->holdcount == 0 && obj->unholdfree) + release_object(obj); +} + static void process_z(Obj_Entry *root) { @@ -2417,6 +2437,7 @@ objlist_call_fini(Objlist *list, Obj_Ent * won't be unloaded although its fini function has been * called. */ + hold_object(elm->obj); lock_release(rtld_bind_lock, lockstate); /* @@ -2444,6 +2465,7 @@ objlist_call_fini(Objlist *list, Obj_Ent call_initfini_pointer(elm->obj, elm->obj->fini); } wlock_acquire(rtld_bind_lock, lockstate); + unhold_object(elm->obj); /* No need to free anything if process is going down. */ if (root != NULL) free(elm); @@ -2497,6 +2519,7 @@ objlist_call_init(Objlist *list, RtldLoc * without better locking. */ elm->obj->init_done = true; + hold_object(elm->obj); lock_release(rtld_bind_lock, lockstate); /* @@ -2523,6 +2546,7 @@ objlist_call_init(Objlist *list, RtldLoc } } wlock_acquire(rtld_bind_lock, lockstate); + unhold_object(elm->obj); } errmsg_restore(saved_msg); } @@ -3553,11 +3577,13 @@ dl_iterate_phdr(__dl_iterate_hdr_callbac for (obj = globallist_curr(TAILQ_FIRST(&obj_list)); obj != NULL;) { TAILQ_INSERT_AFTER(&obj_list, obj, &marker, next); rtld_fill_dl_phdr_info(obj, &phdr_info); + hold_object(obj); lock_release(rtld_bind_lock, &bind_lockstate); error = callback(&phdr_info, sizeof phdr_info, param); wlock_acquire(rtld_bind_lock, &bind_lockstate); + unhold_object(obj); obj = globallist_next(&marker); TAILQ_REMOVE(&obj_list, &marker, next); if (error != 0) { @@ -3812,6 +3838,19 @@ _r_debug_postinit(struct link_map *m) __compiler_membar(); } +static void +release_object(Obj_Entry *obj) +{ + + if (obj->holdcount > 0) { + obj->unholdfree = true; + return; + } + munmap(obj->mapbase, obj->mapsize); + linkmap_delete(obj); + obj_free(obj); +} + /* * Get address of the pointer variable in the main program. * Prefer non-weak symbol over the weak one. @@ -4399,12 +4438,16 @@ unload_object(Obj_Entry *root) LD_UTRACE(UTRACE_UNLOAD_OBJECT, obj, obj->mapbase, obj->mapsize, 0, obj->path); dbg("unloading \"%s\"", obj->path); - unload_filtees(root); - munmap(obj->mapbase, obj->mapsize); - linkmap_delete(obj); + /* + * Unlink the object now to prevent new references from + * being acquired while the bind lock is dropped in + * recursive dlclose() invocations. + */ TAILQ_REMOVE(&obj_list, obj, next); obj_count--; - obj_free(obj); + + unload_filtees(root); + release_object(obj); } } Modified: head/libexec/rtld-elf/rtld.h ============================================================================== --- head/libexec/rtld-elf/rtld.h Thu Dec 22 16:19:05 2016 (r310419) +++ head/libexec/rtld-elf/rtld.h Thu Dec 22 17:37:39 2016 (r310420) @@ -142,7 +142,8 @@ typedef struct Struct_Obj_Entry { TAILQ_ENTRY(Struct_Obj_Entry) next; char *path; /* Pathname of underlying file (%) */ char *origin_path; /* Directory path of origin file */ - int refcount; + int refcount; /* DAG references */ + int holdcount; /* Count of transient references */ int dl_refcount; /* Number of times loaded by dlopen */ /* These items are computed by map_object() or by digest_phdr(). */ @@ -265,6 +266,7 @@ typedef struct Struct_Obj_Entry { bool valid_hash_gnu : 1; /* A valid GNU hash tag is available */ bool dlopened : 1; /* dlopen()-ed (vs. load statically) */ bool marker : 1; /* marker on the global obj list */ + bool unholdfree : 1; /* unmap upon last unhold */ struct link_map linkmap; /* For GDB and dlinfo() */ Objlist dldags; /* Object belongs to these dlopened DAGs (%) */ From owner-svn-src-head@freebsd.org Thu Dec 22 17:41:33 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 82A00C8B2DF; Thu, 22 Dec 2016 17:41:33 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 45098D5C; Thu, 22 Dec 2016 17:41:33 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBMHfWrh058580; Thu, 22 Dec 2016 17:41:32 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBMHfWjt058578; Thu, 22 Dec 2016 17:41:32 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201612221741.uBMHfWjt058578@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Thu, 22 Dec 2016 17:41:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310421 - head/libexec/rtld-elf X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 17:41:33 -0000 Author: markj Date: Thu Dec 22 17:41:32 2016 New Revision: 310421 URL: https://svnweb.freebsd.org/changeset/base/310421 Log: rtld: Ensure that dlopen() cannot obtain a reference on a doomed object. rtld drops the bind lock to call fini functions in an object prior to unmapping it. The new "doomed" state flag prevents the acquisition of new references for an object while the lock is dropped. Reviewed by: kib MFC after: 2 weeks Sponsored by: Dell EMC Isilon Modified: head/libexec/rtld-elf/rtld.c head/libexec/rtld-elf/rtld.h Modified: head/libexec/rtld-elf/rtld.c ============================================================================== --- head/libexec/rtld-elf/rtld.c Thu Dec 22 17:37:39 2016 (r310420) +++ head/libexec/rtld-elf/rtld.c Thu Dec 22 17:41:32 2016 (r310421) @@ -2229,7 +2229,7 @@ load_object(const char *name, int fd_u, fd = -1; if (name != NULL) { TAILQ_FOREACH(obj, &obj_list, next) { - if (obj->marker) + if (obj->marker || obj->doomed) continue; if (object_match_name(obj, name)) return (obj); @@ -2276,7 +2276,7 @@ load_object(const char *name, int fd_u, return NULL; } TAILQ_FOREACH(obj, &obj_list, next) { - if (obj->marker) + if (obj->marker || obj->doomed) continue; if (obj->ino == sb.st_ino && obj->dev == sb.st_dev) break; @@ -2418,6 +2418,9 @@ objlist_call_fini(Objlist *list, Obj_Ent assert(root == NULL || root->refcount == 1); + if (root != NULL) + root->doomed = true; + /* * Preserve the current error message since a fini function might * call into the dynamic linker and overwrite it. @@ -2430,16 +2433,11 @@ objlist_call_fini(Objlist *list, Obj_Ent continue; /* Remove object from fini list to prevent recursive invocation. */ STAILQ_REMOVE(list, elm, Struct_Objlist_Entry, link); - /* - * XXX: If a dlopen() call references an object while the - * fini function is in progress, we might end up trying to - * unload the referenced object in dlclose() or the object - * won't be unloaded although its fini function has been - * called. - */ + /* Ensure that new references cannot be acquired. */ + elm->obj->doomed = true; + hold_object(elm->obj); lock_release(rtld_bind_lock, lockstate); - /* * It is legal to have both DT_FINI and DT_FINI_ARRAY defined. * When this happens, DT_FINI_ARRAY is processed first. Modified: head/libexec/rtld-elf/rtld.h ============================================================================== --- head/libexec/rtld-elf/rtld.h Thu Dec 22 17:37:39 2016 (r310420) +++ head/libexec/rtld-elf/rtld.h Thu Dec 22 17:41:32 2016 (r310421) @@ -267,6 +267,7 @@ typedef struct Struct_Obj_Entry { bool dlopened : 1; /* dlopen()-ed (vs. load statically) */ bool marker : 1; /* marker on the global obj list */ bool unholdfree : 1; /* unmap upon last unhold */ + bool doomed : 1; /* Object cannot be referenced */ struct link_map linkmap; /* For GDB and dlinfo() */ Objlist dldags; /* Object belongs to these dlopened DAGs (%) */ From owner-svn-src-head@freebsd.org Thu Dec 22 17:44:28 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AC958C8B555; Thu, 22 Dec 2016 17:44:28 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 63D4D11A5; Thu, 22 Dec 2016 17:44:28 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBMHiRhl059463; Thu, 22 Dec 2016 17:44:27 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBMHiRFW059462; Thu, 22 Dec 2016 17:44:27 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201612221744.uBMHiRFW059462@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Thu, 22 Dec 2016 17:44:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310422 - head/libexec/rtld-elf X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 17:44:28 -0000 Author: markj Date: Thu Dec 22 17:44:27 2016 New Revision: 310422 URL: https://svnweb.freebsd.org/changeset/base/310422 Log: rtld: Fix a couple of bugs around the unloading of ELF filters. - Pass the correct object to unload_filtees(). - Use a marker to restart iteration after unload_filtees() has returned. It calls dlclose() and may recursively remove entries from the global object list, so TAILQ_FOREACH_SAFE is not sufficient. Reviewed by: kib MFC after: 2 weeks Sponsored by: Dell EMC Isilon Modified: head/libexec/rtld-elf/rtld.c Modified: head/libexec/rtld-elf/rtld.c ============================================================================== --- head/libexec/rtld-elf/rtld.c Thu Dec 22 17:41:32 2016 (r310421) +++ head/libexec/rtld-elf/rtld.c Thu Dec 22 17:44:27 2016 (r310422) @@ -90,6 +90,7 @@ static const char *gethints(bool); static void hold_object(Obj_Entry *); static void unhold_object(Obj_Entry *); static void init_dag(Obj_Entry *); +static void init_marker(Obj_Entry *); static void init_pagesizes(Elf_Auxinfo **aux_info); static void init_rtld(caddr_t, Elf_Auxinfo **); static void initlist_add_neededs(Needed_Entry *, Objlist *); @@ -1829,6 +1830,14 @@ init_dag(Obj_Entry *root) root->dag_inited = true; } +static void +init_marker(Obj_Entry *marker) +{ + + bzero(marker, sizeof(*marker)); + marker->marker = true; +} + Obj_Entry * globallist_curr(const Obj_Entry *obj) { @@ -3566,8 +3575,7 @@ dl_iterate_phdr(__dl_iterate_hdr_callbac RtldLockState bind_lockstate, phdr_lockstate; int error; - bzero(&marker, sizeof(marker)); - marker.marker = true; + init_marker(&marker); error = 0; wlock_acquire(rtld_phdr_lock, &phdr_lockstate); @@ -4419,7 +4427,7 @@ trace_loaded_objects(Obj_Entry *obj) static void unload_object(Obj_Entry *root) { - Obj_Entry *obj, *obj1; + Obj_Entry marker, *obj, *next; assert(root->refcount == 0); @@ -4430,7 +4438,8 @@ unload_object(Obj_Entry *root) unlink_object(root); /* Unmap all objects that are no longer referenced. */ - TAILQ_FOREACH_SAFE(obj, &obj_list, next, obj1) { + for (obj = TAILQ_FIRST(&obj_list); obj != NULL; obj = next) { + next = TAILQ_NEXT(obj, next); if (obj->marker || obj->refcount != 0) continue; LD_UTRACE(UTRACE_UNLOAD_OBJECT, obj, obj->mapbase, @@ -4444,7 +4453,16 @@ unload_object(Obj_Entry *root) TAILQ_REMOVE(&obj_list, obj, next); obj_count--; - unload_filtees(root); + if (obj->filtees_loaded) { + if (next != NULL) { + init_marker(&marker); + TAILQ_INSERT_BEFORE(next, &marker, next); + unload_filtees(obj); + next = TAILQ_NEXT(&marker, next); + TAILQ_REMOVE(&obj_list, &marker, next); + } else + unload_filtees(obj); + } release_object(obj); } } From owner-svn-src-head@freebsd.org Thu Dec 22 17:51:45 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E9E23C8B93D; Thu, 22 Dec 2016 17:51:45 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 B9AE41742; Thu, 22 Dec 2016 17:51:45 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBMHpi1V062787; Thu, 22 Dec 2016 17:51:44 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBMHpim4062786; Thu, 22 Dec 2016 17:51:44 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201612221751.uBMHpim4062786@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Thu, 22 Dec 2016 17:51:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310423 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 17:51:46 -0000 Author: markj Date: Thu Dec 22 17:51:44 2016 New Revision: 310423 URL: https://svnweb.freebsd.org/changeset/base/310423 Log: Revert part of r300109. The removal of TAILQ_FOREACH_SAFE introduced a small race: when the last thread on a sleepqueue is awoken, it reclaims the sleepqueue and may begin executing on a different CPU before sleepq_resume_thread() returns. This leaves a window during which it may go back to sleep and incorrectly be awoken again by the caller of sleepq_broadcast(). Reported and tested by: pho MFC after: 3 days Sponsored by: Dell EMC Isilon Modified: head/sys/kern/subr_sleepqueue.c Modified: head/sys/kern/subr_sleepqueue.c ============================================================================== --- head/sys/kern/subr_sleepqueue.c Thu Dec 22 17:44:27 2016 (r310422) +++ head/sys/kern/subr_sleepqueue.c Thu Dec 22 17:51:44 2016 (r310423) @@ -880,7 +880,7 @@ int sleepq_broadcast(void *wchan, int flags, int pri, int queue) { struct sleepqueue *sq; - struct thread *td; + struct thread *td, *tdn; int wakeup_swapper; CTR2(KTR_PROC, "sleepq_broadcast(%p, %d)", wchan, flags); @@ -894,7 +894,7 @@ sleepq_broadcast(void *wchan, int flags, /* Resume all blocked threads on the sleep queue. */ wakeup_swapper = 0; - while ((td = TAILQ_FIRST(&sq->sq_blocked[queue])) != NULL) { + TAILQ_FOREACH_SAFE(td, &sq->sq_blocked[queue], td_slpq, tdn) { thread_lock(td); wakeup_swapper |= sleepq_resume_thread(sq, td, pri); thread_unlock(td); From owner-svn-src-head@freebsd.org Thu Dec 22 18:05:24 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 32FC7C8BF18; Thu, 22 Dec 2016 18:05:24 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 01BB810E; Thu, 22 Dec 2016 18:05:23 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBMI5NxT067879; Thu, 22 Dec 2016 18:05:23 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBMI5NVC067875; Thu, 22 Dec 2016 18:05:23 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201612221805.uBMI5NVC067875@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Thu, 22 Dec 2016 18:05:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310424 - head/share/man/man4 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 18:05:24 -0000 Author: jhb Date: Thu Dec 22 18:05:22 2016 New Revision: 310424 URL: https://svnweb.freebsd.org/changeset/base/310424 Log: Replace passive voice with active voice and other tweaks. - Drop uses of 'will'. - Replace 'to use' with active voice. - Tidy language around interrupt types and clarify that INTx doesn't work on VFs. - Drop leading articles from sysctl/tunable descriptions. - Tweak the wording of several sysctl/tunable descriptions. Submitted by: wblock (1, 2, 4) Sponsored by: Chelsio Communications MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D8812 Modified: head/share/man/man4/cxgbe.4 head/share/man/man4/cxgbev.4 Modified: head/share/man/man4/cxgbe.4 ============================================================================== --- head/share/man/man4/cxgbe.4 Thu Dec 22 17:51:44 2016 (r310423) +++ head/share/man/man4/cxgbe.4 Thu Dec 22 18:05:22 2016 (r310424) @@ -31,7 +31,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 5, 2016 +.Dd December 22, 2016 .Dt CXGBE 4 .Os .Sh NAME @@ -80,9 +80,9 @@ driver uses different names for devices Loader tunables with the hw.cxgbe prefix apply to all cards. The driver provides sysctl MIBs for both ports and parent devices using the names above. -For example, a T5 adapter will provide port MIBs under dev.cxl and +For example, a T5 adapter provides port MIBs under dev.cxl and adapter-wide MIBs under dev.t5nex. -References to sysctl MIBs in the remainder of this page will use +References to sysctl MIBs in the remainder of this page use dev. for port MIBs and dev. for adapter-wide MIBs. .Pp For more information on configuring this device, see @@ -169,38 +169,38 @@ prompt before booting the kernel or stor .Xr loader.conf 5 . .Bl -tag -width indent .It Va hw.cxgbe.ntxq10g -The number of tx queues to use for a 10Gb or higher-speed port. +Number of tx queues used for a 10Gb or higher-speed port. The default is 16 or the number of CPU cores in the system, whichever is less. .It Va hw.cxgbe.nrxq10g -The number of rx queues to use for a 10Gb or higher-speed port. +Number of rx queues used for a 10Gb or higher-speed port. The default is 8 or the number of CPU cores in the system, whichever is less. .It Va hw.cxgbe.ntxq1g -The number of tx queues to use for a 1Gb port. +Number of tx queues used for a 1Gb port. The default is 4 or the number of CPU cores in the system, whichever is less. .It Va hw.cxgbe.nrxq1g -The number of rx queues to use for a 1Gb port. +Number of rx queues used for a 1Gb port. The default is 2 or the number of CPU cores in the system, whichever is less. .It Va hw.cxgbe.nofldtxq10g -The number of TOE tx queues to use for a 10Gb or higher-speed port. +Number of TOE tx queues used for a 10Gb or higher-speed port. The default is 8 or the number of CPU cores in the system, whichever is less. .It Va hw.cxgbe.nofldrxq10g -The number of TOE rx queues to use for a 10Gb or higher-speed port. +Number of TOE rx queues used for a 10Gb or higher-speed port. The default is 2 or the number of CPU cores in the system, whichever is less. .It Va hw.cxgbe.nofldtxq1g -The number of TOE tx queues to use for a 1Gb port. +Number of TOE tx queues used for a 1Gb port. The default is 2 or the number of CPU cores in the system, whichever is less. .It Va hw.cxgbe.nofldrxq1g -The number of TOE rx queues to use for a 1Gb port. +Number of TOE rx queues used for a 1Gb port. The default is 1. .It Va hw.cxgbe.num_vis -The number of virtual interfaces (VIs) created for each port. +Number of virtual interfaces (VIs) created for each port. Each virtual interface creates a separate network interface. The first virtual interface on each port is required and represents the primary network interface on the port. @@ -211,7 +211,7 @@ for rx and tx as well an additional pair The default is 1. .It Va hw.cxgbe.holdoff_timer_idx_10G .It Va hw.cxgbe.holdoff_timer_idx_1G -The timer index value to use to delay interrupts. +Timer index value used to delay interrupts. The holdoff timer list has the values 1, 5, 10, 50, 100, and 200 by default (all values are in microseconds) and the index selects a value from this list. @@ -220,8 +220,8 @@ Different interfaces can be assigned dif dev..X.holdoff_tmr_idx sysctl. .It Va hw.cxgbe.holdoff_pktc_idx_10G .It Va hw.cxgbe.holdoff_pktc_idx_1G -The packet-count index value to use to delay interrupts. -The packet-count list has the values 1, 8, 16, and 32 by default +Packet-count index value used to delay interrupts. +The packet-count list has the values 1, 8, 16, and 32 by default, and the index selects a value from this list. The default value is -1 which means packet counting is disabled and interrupts are generated based solely on the holdoff timer value. @@ -230,8 +230,7 @@ dev..X.holdoff_pktc_idx sysctl. This sysctl works only when the interface has never been marked up (as done by ifconfig up). .It Va hw.cxgbe.qsize_txq -The size, in number of entries, of the descriptor ring used for a tx -queue. +Number of entries in a transmit queue's descriptor ring. A buf_ring of the same size is also allocated for additional software queuing. See @@ -242,19 +241,17 @@ dev..X.qsize_txq sysctl. This sysctl works only when the interface has never been marked up (as done by ifconfig up). .It Va hw.cxgbe.qsize_rxq -The size, in number of entries, of the descriptor ring used for an -rx queue. +Number of entries in a receive queue's descriptor ring. The default value is 1024. Different interfaces can be assigned different values via the dev..X.qsize_rxq sysctl. This sysctl works only when the interface has never been marked up (as done by ifconfig up). .It Va hw.cxgbe.interrupt_types -The interrupt types that the driver is allowed to use. -Bit 0 represents INTx (line interrupts), bit 1 MSI, bit 2 MSI-X. +Permitted interrupt types. +Bit 0 represents INTx (line interrupts), bit 1 MSI, and bit 2 MSI-X. The default is 7 (all allowed). -The driver will select the best possible type out of the allowed types by -itself. +The driver selects the best possible type out of the allowed types. .It Va hw.cxgbe.fw_install 0 prohibits the driver from installing a firmware on the card. 1 allows the driver to install a new firmware if internal driver @@ -265,7 +262,7 @@ long as it is compatible with the driver the one already on the card. The default is 1. .It Va hw.cxgbe.fl_pktshift -The number of bytes of padding inserted before the beginning of an Ethernet +Number of padding bytes inserted before the beginning of an Ethernet frame in the receive buffer. The default value of 2 ensures that the Ethernet payload (usually the IP header) is at a 4 byte aligned address. @@ -309,8 +306,8 @@ Each of these must be set to one of the (usually 2048, 4096, 9216, and 16384) and largest_rx_cluster must be greater than or equal to safest_rx_cluster. The defaults are 16384 and 4096 respectively. -The driver will never attempt to allocate a receive buffer larger than -largest_rx_cluster and will fall back to allocating buffers of +The driver never attempts to allocate a receive buffer larger than +largest_rx_cluster and falls back to allocating buffers of safest_rx_cluster size if an allocation larger than safest_rx_cluster fails. Note that largest_rx_cluster merely establishes a ceiling -- the driver is allowed to allocate buffers of smaller sizes. Modified: head/share/man/man4/cxgbev.4 ============================================================================== --- head/share/man/man4/cxgbev.4 Thu Dec 22 17:51:44 2016 (r310423) +++ head/share/man/man4/cxgbev.4 Thu Dec 22 18:05:22 2016 (r310424) @@ -31,7 +31,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 5, 2016 +.Dd December 22, 2016 .Dt CXGBEV 4 .Os .Sh NAME @@ -81,9 +81,9 @@ The Physical Function driver for Chelsio tunables. The driver provides sysctl MIBs for both ports and parent devices using the names above. -For example, a T5 VF will provide port MIBs under dev.cxlv and +For example, a T5 VF provides port MIBs under dev.cxlv and parent device MIBs under dev.t5vf. -References to sysctl MIBs in the remainder of this page will use +References to sysctl MIBs in the remainder of this page use dev. for port MIBs and dev. for parent device MIBs. .Pp For more information on configuring this device, see @@ -173,24 +173,24 @@ prompt before booting the kernel or stor .Xr loader.conf 5 . .Bl -tag -width indent .It Va hw.cxgbe.ntxq10g -The number of tx queues to use for a 10Gb or higher-speed port. +Number of tx queues used for a 10Gb or higher-speed port. The default is 16 or the number of CPU cores in the system, whichever is less. .It Va hw.cxgbe.nrxq10g -The number of rx queues to use for a 10Gb or higher-speed port. +Number of rx queues used for a 10Gb or higher-speed port. The default is 8 or the number of CPU cores in the system, whichever is less. .It Va hw.cxgbe.ntxq1g -The number of tx queues to use for a 1Gb port. +Number of tx queues used for a 1Gb port. The default is 4 or the number of CPU cores in the system, whichever is less. .It Va hw.cxgbe.nrxq1g -The number of rx queues to use for a 1Gb port. +Number of rx queues used for a 1Gb port. The default is 2 or the number of CPU cores in the system, whichever is less. .It Va hw.cxgbe.holdoff_timer_idx_10G .It Va hw.cxgbe.holdoff_timer_idx_1G -The timer index value to use to delay interrupts. +Timer index value used to delay interrupts. The holdoff timer list has the values 1, 5, 10, 50, 100, and 200 by default (all values are in microseconds) and the index selects a value from this list. @@ -199,8 +199,8 @@ Different interfaces can be assigned dif dev..X.holdoff_tmr_idx sysctl. .It Va hw.cxgbe.holdoff_pktc_idx_10G .It Va hw.cxgbe.holdoff_pktc_idx_1G -The packet-count index value to use to delay interrupts. -The packet-count list has the values 1, 8, 16, and 32 by default +Packet-count index value used to delay interrupts. +The packet-count list has the values 1, 8, 16, and 32 by default, and the index selects a value from this list. The default value is -1 which means packet counting is disabled and interrupts are generated based solely on the holdoff timer value. @@ -209,8 +209,7 @@ dev..X.holdoff_pktc_idx sysctl. This sysctl works only when the interface has never been marked up (as done by ifconfig up). .It Va hw.cxgbe.qsize_txq -The size, in number of entries, of the descriptor ring used for a tx -queue. +Number of entries in a transmit queue's descriptor ring. A buf_ring of the same size is also allocated for additional software queuing. See @@ -221,21 +220,21 @@ dev..X.qsize_txq sysctl. This sysctl works only when the interface has never been marked up (as done by ifconfig up). .It Va hw.cxgbe.qsize_rxq -The size, in number of entries, of the descriptor ring used for an -rx queue. +Number of entries in a receive queue's descriptor ring. The default value is 1024. Different interfaces can be assigned different values via the dev..X.qsize_rxq sysctl. This sysctl works only when the interface has never been marked up (as done by ifconfig up). .It Va hw.cxgbe.interrupt_types -The interrupt types that the driver is allowed to use. -Bit 0 represents INTx (line interrupts), bit 1 MSI, bit 2 MSI-X. +Permitted interrupt types. +Bit 0 represents INTx (line interrupts), bit 1 MSI, and bit 2 MSI-X. The default is 7 (all allowed). -The driver will select the best possible type out of the allowed types by -itself. +The driver selects the best possible type out of the allowed types. +Note that Virtual Functions do not support INTx interrupts and fail +to attach if neither MSI nor MSI-X are enabled. .It Va hw.cxgbe.fl_pktshift -The number of bytes of padding inserted before the beginning of an Ethernet +Number of padding bytes inserted before the beginning of an Ethernet frame in the receive buffer. The default value of 2 ensures that the Ethernet payload (usually the IP header) is at a 4 byte aligned address. @@ -262,8 +261,8 @@ Each of these must be set to one of the (usually 2048, 4096, 9216, and 16384) and largest_rx_cluster must be greater than or equal to safest_rx_cluster. The defaults are 16384 and 4096 respectively. -The driver will never attempt to allocate a receive buffer larger than -largest_rx_cluster and will fall back to allocating buffers of +The driver never attempts to allocate a receive buffer larger than +largest_rx_cluster and falls back to allocating buffers of safest_rx_cluster size if an allocation larger than safest_rx_cluster fails. Note that largest_rx_cluster merely establishes a ceiling -- the driver is allowed to allocate buffers of smaller sizes. @@ -271,8 +270,8 @@ allowed to allocate buffers of smaller s .Pp Certain settings and resources for Virtual Functions are dictated by the parent Physical Function driver. -For example, the Physical Function driver limits the number of queues a -Virtual Function is permitted to use. +For example, the Physical Function driver limits the number of queues +available to a Virtual Function. Some of these limits can be adjusted in the firmware configuration file used with the Physical Function driver. .Pp @@ -290,7 +289,7 @@ to 1 .Pc . .Pp The VF driver currently depends on the PF driver. -As a result, loading the VF driver will also load the PF driver as a +As a result, loading the VF driver also loads the PF driver as a dependency. .Sh SUPPORT For general information and support, From owner-svn-src-head@freebsd.org Thu Dec 22 18:26:22 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C9306C8C6D6; Thu, 22 Dec 2016 18:26:22 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 986B11093; Thu, 22 Dec 2016 18:26:22 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBMIQLK8076249; Thu, 22 Dec 2016 18:26:21 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBMIQLFQ076247; Thu, 22 Dec 2016 18:26:21 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201612221826.uBMIQLFQ076247@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Thu, 22 Dec 2016 18:26:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310425 - in head/sys/dev/mlx4: mlx4_core mlx4_ib X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 18:26:22 -0000 Author: emaste Date: Thu Dec 22 18:26:21 2016 New Revision: 310425 URL: https://svnweb.freebsd.org/changeset/base/310425 Log: mlx: avoid use of __DATE__ to make build reproducible Reviewed by: hselasky Differential Revision: https://reviews.freebsd.org/D8886 Modified: head/sys/dev/mlx4/mlx4_core/mlx4.h head/sys/dev/mlx4/mlx4_ib/mlx4_ib_main.c Modified: head/sys/dev/mlx4/mlx4_core/mlx4.h ============================================================================== --- head/sys/dev/mlx4/mlx4_core/mlx4.h Thu Dec 22 18:05:22 2016 (r310424) +++ head/sys/dev/mlx4/mlx4_core/mlx4.h Thu Dec 22 18:26:21 2016 (r310425) @@ -52,7 +52,7 @@ #define DRV_NAME "mlx4_core" #define PFX DRV_NAME ": " #define DRV_VERSION "2.1.6" -#define DRV_RELDATE __DATE__ +#define DRV_RELDATE "Sep 30 2016" #define DRV_STACK_NAME "Linux-MLNX_OFED" #define DRV_STACK_VERSION "2.1" Modified: head/sys/dev/mlx4/mlx4_ib/mlx4_ib_main.c ============================================================================== --- head/sys/dev/mlx4/mlx4_ib/mlx4_ib_main.c Thu Dec 22 18:05:22 2016 (r310424) +++ head/sys/dev/mlx4/mlx4_ib/mlx4_ib_main.c Thu Dec 22 18:26:21 2016 (r310425) @@ -59,7 +59,7 @@ #define DRV_NAME MLX4_IB_DRV_NAME #define DRV_VERSION "1.0" -#define DRV_RELDATE __DATE__ +#define DRV_RELDATE "Sep 30 2016" #define MLX4_IB_DRIVER_PROC_DIR_NAME "driver/mlx4_ib" #define MLX4_IB_MRS_PROC_DIR_NAME "mrs" From owner-svn-src-head@freebsd.org Thu Dec 22 18:30:30 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C3545C8C84F; Thu, 22 Dec 2016 18:30:30 +0000 (UTC) (envelope-from julian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 92FCA1369; Thu, 22 Dec 2016 18:30:30 +0000 (UTC) (envelope-from julian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBMIUTtd076459; Thu, 22 Dec 2016 18:30:29 GMT (envelope-from julian@FreeBSD.org) Received: (from julian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBMIUTNK076458; Thu, 22 Dec 2016 18:30:29 GMT (envelope-from julian@FreeBSD.org) Message-Id: <201612221830.uBMIUTNK076458@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: julian set sender to julian@FreeBSD.org using -f From: Julian Elischer Date: Thu, 22 Dec 2016 18:30:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310426 - head/share/zoneinfo X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 18:30:30 -0000 Author: julian Date: Thu Dec 22 18:30:29 2016 New Revision: 310426 URL: https://svnweb.freebsd.org/changeset/base/310426 Log: If you are going to be run individually to make a new timezone set then ensure the destination directories exist. Especially if you define OLDTIMEZONES because the mtree pass doesn't do it for you. MFC after: 1 week Sponsored by: Panzura Modified: head/share/zoneinfo/Makefile Modified: head/share/zoneinfo/Makefile ============================================================================== --- head/share/zoneinfo/Makefile Thu Dec 22 18:26:21 2016 (r310425) +++ head/share/zoneinfo/Makefile Thu Dec 22 18:30:29 2016 (r310426) @@ -85,6 +85,8 @@ zoneinfo: yearistype ${TDATA} beforeinstall: install-zoneinfo install-zoneinfo: + mkdir -p ${DESTDIR}/usr/share/zoneinfo + cd ${DESTDIR}/usr/share/zoneinfo; mkdir -p ${TZBUILDSUBDIRS} cd ${TZBUILDDIR} && \ find -s * -type f -print -exec ${INSTALL} ${TAG_ARGS} \ -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \ From owner-svn-src-head@freebsd.org Thu Dec 22 18:33:36 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8C597C8CAA9; Thu, 22 Dec 2016 18:33:36 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebi.us (glebi.us [96.95.210.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "cell.glebi.us", Issuer "cell.glebi.us" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 7637C17FC; Thu, 22 Dec 2016 18:33:36 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebi.us (localhost [127.0.0.1]) by cell.glebi.us (8.15.2/8.15.2) with ESMTPS id uBMIXZ7G082168 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 22 Dec 2016 10:33:35 -0800 (PST) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.glebi.us (8.15.2/8.15.2/Submit) id uBMIXZvE082167; Thu, 22 Dec 2016 10:33:35 -0800 (PST) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.glebi.us: glebius set sender to glebius@FreeBSD.org using -f Date: Thu, 22 Dec 2016 10:33:34 -0800 From: Gleb Smirnoff To: hiren panchasara Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r309745 - in head: share/man/man9 sys/kern sys/sys Message-ID: <20161222183334.GP9389@FreeBSD.org> References: <201612091758.uB9HwYC0087384@repo.freebsd.org> <20161222001928.GZ82166@strugglingcoder.info> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161222001928.GZ82166@strugglingcoder.info> User-Agent: Mutt/1.7.0 (2016-08-17) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 18:33:36 -0000 Hi! On Wed, Dec 21, 2016 at 04:19:28PM -0800, hiren panchasara wrote: h> On 12/09/16 at 05:58P, Gleb Smirnoff wrote: h> > Author: glebius h> > Date: Fri Dec 9 17:58:34 2016 h> > New Revision: 309745 h> > URL: https://svnweb.freebsd.org/changeset/base/309745 h> > h> > Log: h> > Provide counter_ratecheck(), a MP-friendly substitution to ppsratecheck(). h> > When rated event happens at a very quick rate, the ppsratecheck() is not h> > only racy, but also becomes a performance bottleneck. h> > h> > Together with: rrs, jtl h> h> Is it possible for you to MFC this and the following fix to it to 11? Have you tried it and found useful? If yes, you are welcome to merge it. My current work involves only FreeBSD head, I don't have any STABLE production boxes, that's why I am very conservative with my MFCs: I do only obvious conservative bugfixes, not performance improvements. -- Totus tuus, Glebius. From owner-svn-src-head@freebsd.org Thu Dec 22 18:39:18 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 706DCC8CD54; Thu, 22 Dec 2016 18:39:18 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from mail.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5115A1C9B; Thu, 22 Dec 2016 18:39:18 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by mail.baldwin.cx (Postfix) with ESMTPSA id 31A6010A761; Thu, 22 Dec 2016 13:39:17 -0500 (EST) From: John Baldwin To: Mark Johnston Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r310423 - head/sys/kern Date: Thu, 22 Dec 2016 10:39:12 -0800 Message-ID: <6562460.a4qdZuDa0s@ralph.baldwin.cx> User-Agent: KMail/4.14.10 (FreeBSD/11.0-PRERELEASE; KDE/4.14.10; amd64; ; ) In-Reply-To: <201612221751.uBMHpim4062786@repo.freebsd.org> References: <201612221751.uBMHpim4062786@repo.freebsd.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mail.baldwin.cx); Thu, 22 Dec 2016 13:39:17 -0500 (EST) X-Virus-Scanned: clamav-milter 0.99.2 at mail.baldwin.cx X-Virus-Status: Clean X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 18:39:18 -0000 On Thursday, December 22, 2016 05:51:44 PM Mark Johnston wrote: > Author: markj > Date: Thu Dec 22 17:51:44 2016 > New Revision: 310423 > URL: https://svnweb.freebsd.org/changeset/base/310423 > > Log: > Revert part of r300109. > > The removal of TAILQ_FOREACH_SAFE introduced a small race: when the last > thread on a sleepqueue is awoken, it reclaims the sleepqueue and may begin > executing on a different CPU before sleepq_resume_thread() returns. This > leaves a window during which it may go back to sleep and incorrectly be > awoken again by the caller of sleepq_broadcast(). This is very subtle. The issue is that the last sleepq_resume_thread transfers ownership of 'sq' from the wait channel that the sleepq_broadcast has locked, to the thread being resumed. I thought about using a local TAILQ_HEAD and using TAILQ_CONCAT to move the list of threads out of the sleep queue and then walking that list. However, a comment explaining this transfer of ownership (and that we can't safely access 'sq' after the last thread is resumed) is probably sufficient (but necessary I think). Do you feel like adding one? -- John Baldwin From owner-svn-src-head@freebsd.org Thu Dec 22 18:49:58 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0ACCAC8D31C; Thu, 22 Dec 2016 18:49:58 +0000 (UTC) (envelope-from hiren@strugglingcoder.info) Received: from mail.strugglingcoder.info (strugglingcoder.info [104.236.146.68]) by mx1.freebsd.org (Postfix) with ESMTP id E98949B8; Thu, 22 Dec 2016 18:49:57 +0000 (UTC) (envelope-from hiren@strugglingcoder.info) Received: from localhost (unknown [10.1.1.3]) (Authenticated sender: hiren@strugglingcoder.info) by mail.strugglingcoder.info (Postfix) with ESMTPA id 9219E177F3; Thu, 22 Dec 2016 10:49:56 -0800 (PST) Date: Thu, 22 Dec 2016 10:49:56 -0800 From: hiren panchasara To: Gleb Smirnoff Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r309745 - in head: share/man/man9 sys/kern sys/sys Message-ID: <20161222184956.GD82166@strugglingcoder.info> References: <201612091758.uB9HwYC0087384@repo.freebsd.org> <20161222001928.GZ82166@strugglingcoder.info> <20161222183334.GP9389@FreeBSD.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Zljh9u/ceMLi+8mf" Content-Disposition: inline In-Reply-To: <20161222183334.GP9389@FreeBSD.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 18:49:58 -0000 --Zljh9u/ceMLi+8mf Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 12/22/16 at 10:33P, Gleb Smirnoff wrote: > Hi! >=20 > On Wed, Dec 21, 2016 at 04:19:28PM -0800, hiren panchasara wrote: > h> On 12/09/16 at 05:58P, Gleb Smirnoff wrote: > h> > Author: glebius > h> > Date: Fri Dec 9 17:58:34 2016 > h> > New Revision: 309745 > h> > URL: https://svnweb.freebsd.org/changeset/base/309745 > h> >=20 > h> > Log: > h> > Provide counter_ratecheck(), a MP-friendly substitution to ppsrate= check(). > h> > When rated event happens at a very quick rate, the ppsratecheck() = is not > h> > only racy, but also becomes a performance bottleneck. > h> > =20 > h> > Together with: rrs, jtl > h>=20 > h> Is it possible for you to MFC this and the following fix to it to 11? >=20 > Have you tried it and found useful? If yes, you are welcome to merge it. As you stated yourself in the commit message, this is a clear bug and an opportunity for performance enhancement. Do you feel this bug won't be in 11 and systems running on 11 won't have similar performance gains as those running on -head? Specially when 11 is the latest released version that many (like myself) would be running in the production. >=20 > My current work involves only FreeBSD head, I don't have any STABLE produ= ction > boxes, that's why I am very conservative with my MFCs: I do only obvious > conservative bugfixes, not performance improvements. The obvious reason we encourage original submitter to do MFCs is that (s)he is intimately familiar with the changes.=20 I can understand your point of not having any 11 based systems to test. I'll test this on our $work prod and do the MFC myself. Thanks for the original fix. Cheers, Hiren --Zljh9u/ceMLi+8mf Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQF8BAABCgBmBQJYXCBGXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXRBNEUyMEZBMUQ4Nzg4RjNGMTdFNjZGMDI4 QjkyNTBFMTU2M0VERkU1AAoJEIuSUOFWPt/lp0oH/3ghdQFFPUoBGLPGajuwAxpl YimyXcya96wh14xr+k6F5Gm/77WIPl0CwWHnr5A7zLpgJVpewH09A2CP4U9j6hAL rFo3Hu7CoKMwt23cVft5mVNh+pObmLZC9h/82xOyJqOA6sumKhOGwwjJjXn8S5+q xZqQ4Oc2zeD0KxbJU8CL+gUhAt4IMNVMAWKxV4KikK8X5snEM1QFZ/ns50gtnlQi TDnjNXpg69IflINufLO00+/kC/lNls1QQMhSTsY6SElJZJ6X+eH+sCragf6bHgvM Gw/qiwh3ni/12auEAhfQ0AVCPrgU27dWSHoPJ305FpwBdTZ6eY1m/VtL10ZRQgw= =Yxuq -----END PGP SIGNATURE----- --Zljh9u/ceMLi+8mf-- From owner-svn-src-head@freebsd.org Thu Dec 22 19:19:40 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 153D0C8DD90; Thu, 22 Dec 2016 19:19:40 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-qt0-x243.google.com (mail-qt0-x243.google.com [IPv6:2607:f8b0:400d:c0d::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C64DD1CD7; Thu, 22 Dec 2016 19:19:39 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by mail-qt0-x243.google.com with SMTP id 3so4644657qtr.2; Thu, 22 Dec 2016 11:19:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=0d+Murcr8TY6GCYjcuNlhgXUE+4M1ScE8+ItgGwEi6U=; b=vNaa051gwlk8+L3et4o3FulWnQfGwVVuyiySzQRYuns6xKk35MGb8Biwtq6WpyqOBK t6opxNdvU11jaOutzhGdoXKr3xQ7gdStvFlHPTyxf/E11UZNFiKFtf8xx/qUd+piggkD h2EVVV3flDFDXCv5qJxvkpWl0FHV8UnLcdPR8bSePgEpUUIut2GoNA7Ip5qlhhdHiAXA ihf7/OzR9NjpHSfmD3+CsWO4CGR18XcaOsYpvoTfz7IirYB5y45HIF1g7dc/6eWB6q3N M1uTOc2YQHa3H1ou0rCGBKW5a5Fx7U7ys6VMZz23yUlQQjxs7cSzfWQ3eChJ44PsCvjY JDKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=0d+Murcr8TY6GCYjcuNlhgXUE+4M1ScE8+ItgGwEi6U=; b=CzkSPCdFMyRDeWUksH3M7L131swH+0JFjGnSteaHQROr9xiDnIdZrEVTMcOkDV+nKa jEztFhZwkEP+F8CCnaiV2MVY7f7bdKBa7mSimr/s+/94Ez/DuYxxyr1kMZH/Yb31YW2/ cd1k9k+G4tnplepINNuNKRo+563wFIWNHzi3uAIh4VW0UZZaUSs5XPrp7MBirPk/7Xzq BcKVMO4dp7q/GsBajgxJYdgnFQ9H+ZWaJ6aFqv+ctube+1Koj0IiRPf43x5UpHS5k663 22kGNmRwShMLDWCz4tb+7ly+hpSUg0WPQHCkk4LWCsNDqqj5Mm60R2ZwyKHzsLoXaBiH WDLQ== X-Gm-Message-State: AIkVDXKa4/PXZ111Gu/W7W7PgrhtgnWa/cfD0/5eRBfIBDRMIYlhmPCqQgJbURcTTpH6Ig== X-Received: by 10.200.41.9 with SMTP id y9mr12269673qty.26.1482434378787; Thu, 22 Dec 2016 11:19:38 -0800 (PST) Received: from wkstn-mjohnston.west.isilon.com (c-76-104-201-218.hsd1.wa.comcast.net. [76.104.201.218]) by smtp.gmail.com with ESMTPSA id y22sm18597334qtb.26.2016.12.22.11.19.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Dec 2016 11:19:38 -0800 (PST) Sender: Mark Johnston Date: Thu, 22 Dec 2016 11:26:01 -0800 From: Mark Johnston To: John Baldwin Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r310423 - head/sys/kern Message-ID: <20161222192601.GA78778@wkstn-mjohnston.west.isilon.com> References: <201612221751.uBMHpim4062786@repo.freebsd.org> <6562460.a4qdZuDa0s@ralph.baldwin.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6562460.a4qdZuDa0s@ralph.baldwin.cx> User-Agent: Mutt/1.7.2 (2016-11-26) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 19:19:40 -0000 On Thu, Dec 22, 2016 at 10:39:12AM -0800, John Baldwin wrote: > On Thursday, December 22, 2016 05:51:44 PM Mark Johnston wrote: > > Author: markj > > Date: Thu Dec 22 17:51:44 2016 > > New Revision: 310423 > > URL: https://svnweb.freebsd.org/changeset/base/310423 > > > > Log: > > Revert part of r300109. > > > > The removal of TAILQ_FOREACH_SAFE introduced a small race: when the last > > thread on a sleepqueue is awoken, it reclaims the sleepqueue and may begin > > executing on a different CPU before sleepq_resume_thread() returns. This > > leaves a window during which it may go back to sleep and incorrectly be > > awoken again by the caller of sleepq_broadcast(). > > This is very subtle. :( > The issue is that the last sleepq_resume_thread transfers > ownership of 'sq' from the wait channel that the sleepq_broadcast has locked, > to the thread being resumed. Right, that's what I meant by "reclaims the sleepqueue." One other requirement for hitting the race is that the thread goes back to sleep on a wait channel that hashes to a different sleepchain, else the sleepchain lock held by the sleepq_broadcast() caller is, I believe, sufficient to prevent the reuse of the sleepqueue before the loop has terminated. > I thought about using a local TAILQ_HEAD and > using TAILQ_CONCAT to move the list of threads out of the sleep queue and then > walking that list. However, a comment explaining this transfer of ownership > (and that we can't safely access 'sq' after the last thread is resumed) is > probably sufficient (but necessary I think). Do you feel like adding one? How about: Index: subr_sleepqueue.c =================================================================== --- subr_sleepqueue.c (revision 310423) +++ subr_sleepqueue.c (working copy) @@ -892,7 +892,12 @@ KASSERT(sq->sq_type == (flags & SLEEPQ_TYPE), ("%s: mismatch between sleep/wakeup and cv_*", __func__)); - /* Resume all blocked threads on the sleep queue. */ + /* + * Resume all blocked threads on the sleep queue. The last thread will + * be given ownership of sq and may re-enqueue itself before + * sleepq_resume_thread() returns, so we must cache the "next" queue + * item at the beginning of the final iteration. + */ wakeup_swapper = 0; TAILQ_FOREACH_SAFE(td, &sq->sq_blocked[queue], td_slpq, tdn) { thread_lock(td); From owner-svn-src-head@freebsd.org Thu Dec 22 19:42:55 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8F272C8D47B for ; Thu, 22 Dec 2016 19:42:55 +0000 (UTC) (envelope-from ed@nuxi.nl) Received: from mail-yw0-x231.google.com (mail-yw0-x231.google.com [IPv6:2607:f8b0:4002:c05::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5CF67F30 for ; Thu, 22 Dec 2016 19:42:55 +0000 (UTC) (envelope-from ed@nuxi.nl) Received: by mail-yw0-x231.google.com with SMTP id v81so17925573ywb.2 for ; Thu, 22 Dec 2016 11:42:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuxi-nl.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-transfer-encoding; bh=xx2uty5DmqTGvyFg777yzTFvDWwjapNmTzx8WJw76yU=; b=KIGZ1aUEXG8npRTIvxtCL6M7J0AD9CMFjb43BKKQQoK2NzVYyICpzNIBVREsKvGiTg 1JFAuFS3ik8UrNyBru+gsCh6CTS+REfKoL5YwfHzVtoY0PghJwmUXeiqT2QyOsQ9uGQF QmK3B2b0mlyejVx3oSP4ZDecfsmvw3qwctWRBbnvbUkjwkL39xoxjinV7OYrYXRvoPLM vfb1pA1A5UYYkyyjYJ1XX+Ov3FAp1D1tdcGBuvYqtNdXwizjDjQStGYU+d+s8Ly5jptI QCctHp+UCtzTrJqkn2cD7mUJE39F1B6Chc4/NWvmSfEnH8KSnTUdEF7aQaD/Ag3Egfvt 0alA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-transfer-encoding; bh=xx2uty5DmqTGvyFg777yzTFvDWwjapNmTzx8WJw76yU=; b=gknrFMPy1TIwCYoNsG/lkBT0/i5+NAE/1rO8uxB3O+OqKBdQXzmxiVVBFdX1jVHgkG KLOzWNS+l32ZksH9gQPq1Z6oTVtt/iFU/EqNxuuKv43bX9sV/pzZjuR2tdIFIRWlRDDR IHsuCbbpABgdKTh8RyHGLQZm4v6mhMbptSCjiZa92HD2JSrXQ99P/trIPR4B276NIcNq Ry2HCMgxy0vheoTUsQh0FFA3dhayUgLSOTJAru2PoXpBLHBTcIvRCIu8KsR46pZR8LQo /P5aVvrfLspUFEUQwAff/ZSatHd8qZj9ofFWR6tl7cNI2yAJsP4vKCncsz3TRxa+SgIG Beog== X-Gm-Message-State: AIkVDXKyH/a95O59xn0FOHJ1yY3tdiJqsE6R9rViV8WDO7Pj6YBTrNMgNoCHqzCuTVWeBYO5Rz5L+92ixwKMdA== X-Received: by 10.13.221.215 with SMTP id g206mr9674883ywe.350.1482435774391; Thu, 22 Dec 2016 11:42:54 -0800 (PST) MIME-Version: 1.0 Received: by 10.129.2.139 with HTTP; Thu, 22 Dec 2016 11:42:24 -0800 (PST) In-Reply-To: <20161221195304.GA3396@brick> References: <201612210829.uBL8Tijt041811@repo.freebsd.org> <20161221195304.GA3396@brick> From: Ed Schouten Date: Thu, 22 Dec 2016 20:42:24 +0100 Message-ID: Subject: Re: svn commit: r310354 - in head/usr.sbin: . prometheus_sysctl_exporter To: Ed Schouten , Adrian Chadd , Ed Schouten , "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 19:42:55 -0000 Hey! 2016-12-21 20:53 GMT+01:00 Edward Tomasz Napiera=C5=82a = : > That's a very good reason; it could also be fixed by moving > it from sbin/ to libexec/. I'm not sure that doing that is a good idea. You can also invoke this exporter through cron(8), so that it can be collected by the Prometheus node exporter. Another use case is invoking it from within a CGI script, so that it can be embedded in an existing web service. Storing the executable under /usr/libexec would therefore be a bit weird. > Another advantage of having the "prometheus" in the name is that it's > easily googlable, and it clearly indicates the "protocol" (in the wide > meaning) one is supposed to use to talk to it. Agreed. Let's leave it the way it is right now, as I don't feel like upsetting Warner. ;-) --=20 Ed Schouten Nuxi, 's-Hertogenbosch, the Netherlands KvK-nr.: 62051717 From owner-svn-src-head@freebsd.org Thu Dec 22 19:45:12 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1A2B7C8D50F for ; Thu, 22 Dec 2016 19:45:12 +0000 (UTC) (envelope-from ed@nuxi.nl) Received: from mail-yb0-x229.google.com (mail-yb0-x229.google.com [IPv6:2607:f8b0:4002:c09::229]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id CF0591117 for ; Thu, 22 Dec 2016 19:45:11 +0000 (UTC) (envelope-from ed@nuxi.nl) Received: by mail-yb0-x229.google.com with SMTP id w19so14016802ybb.2 for ; Thu, 22 Dec 2016 11:45:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuxi-nl.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=lOSLWGl/2UDjhL/n8Tkwii0ukSDpQefoLjPdK3QJdq0=; b=Jm6dtFFqOz0RK/xvtFbY4eI6S5sFyZKpx3pTJnhcDGldcfo5zSIAoWRAkI8vw7hu0W BOVIkMZAaWxIhMOoF+NOGnQoChjezYKoye5cUHDXmVc8BWWMsSFvnGWWOd/Dwm7q+puH OHQvA8peV//UN60oCrkIfDBz2ZVJZ1xopfmGrIK9RgdOQW1XRhcSw+CE+dlPe7zXDQxL E46rURIq9vBMkV0gGzce/+YoaBfeMu2tKaOdMQkpdW6LyymlVfqmQEXL/Z+6bJ3IwLKX WYzvWEv6UsTvuLiJG7SXkkorT3c6nDTu9UXjC20qX1piFjHtj/RIkBIhvlgPZq8wt6Ow jaTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=lOSLWGl/2UDjhL/n8Tkwii0ukSDpQefoLjPdK3QJdq0=; b=basEIKTcA0td6xdDOSooY/7XEbAiYO4WvVx5iccRpDtWfbXXFuDZlwOnjj35oIaRNS 7/2fhjk3ywL5XqEFQ5LPNHHOjbwJq0P/Js3V7iguqeo3dpP74wqnD/epNvs/vD+SJJDI yZynKcBF85FdtqtWQpvC8vxG66TQSOc17qMpqCHYY773qOYGMCErwt773MPJQOsV7iae LhrGkMEFP3UYGhtAUvuzy21I64hUPFhva8r43r72n86vnSkdQ2sRuPMe0iqm0c5Yr6EK eJ6mBuAa4d9ScXfi+FAq1fNyakjDDzSG5fM9MPr8KCMoGTo28BpPlf+yQxPKwzEQ0mL0 3Z9w== X-Gm-Message-State: AIkVDXL+qtug0Fnp7G9Wml8UGAqDXDzpjYSb3B6MDn4bYThDIwYOxhxub4RIJ7Qx0ncqHxI3HCVb+JK/HWhp0A== X-Received: by 10.37.173.96 with SMTP id l32mr7637996ybe.25.1482435911144; Thu, 22 Dec 2016 11:45:11 -0800 (PST) MIME-Version: 1.0 Received: by 10.129.2.139 with HTTP; Thu, 22 Dec 2016 11:44:40 -0800 (PST) In-Reply-To: <201612221826.uBMIQLFQ076247@repo.freebsd.org> References: <201612221826.uBMIQLFQ076247@repo.freebsd.org> From: Ed Schouten Date: Thu, 22 Dec 2016 20:44:40 +0100 Message-ID: Subject: Re: svn commit: r310425 - in head/sys/dev/mlx4: mlx4_core mlx4_ib To: Ed Maste Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 19:45:12 -0000 2016-12-22 19:26 GMT+01:00 Ed Maste : > Log: > mlx: avoid use of __DATE__ to make build reproducible Out of curiosity, are we planning on adding -Wdate-time or -Werror=date-time to our default CFLAGS? If so, awesome! -- Ed Schouten Nuxi, 's-Hertogenbosch, the Netherlands KvK-nr.: 62051717 From owner-svn-src-head@freebsd.org Thu Dec 22 20:01:06 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EBBE5C8DAA6; Thu, 22 Dec 2016 20:01:06 +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 C637F1BBA; Thu, 22 Dec 2016 20:01:06 +0000 (UTC) (envelope-from brooks@spindle.one-eyed-alien.net) Received: by spindle.one-eyed-alien.net (Postfix, from userid 3001) id 81B7C5A9F12; Thu, 22 Dec 2016 19:52:11 +0000 (UTC) Date: Thu, 22 Dec 2016 19:52:11 +0000 From: Brooks Davis To: Ed Schouten Cc: Adrian Chadd , Ed Schouten , "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Subject: Re: svn commit: r310354 - in head/usr.sbin: . prometheus_sysctl_exporter Message-ID: <20161222195211.GA50719@spindle.one-eyed-alien.net> References: <201612210829.uBL8Tijt041811@repo.freebsd.org> <20161221195304.GA3396@brick> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="2fHTh5uZTiUOsy+g" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.7.2 (2016-11-26) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 20:01:07 -0000 --2fHTh5uZTiUOsy+g Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Dec 22, 2016 at 08:42:24PM +0100, Ed Schouten wrote: > Hey! >=20 > 2016-12-21 20:53 GMT+01:00 Edward Tomasz Napiera??a : > > That's a very good reason; it could also be fixed by moving > > it from sbin/ to libexec/. >=20 > I'm not sure that doing that is a good idea. You can also invoke this > exporter through cron(8), so that it can be collected by the > Prometheus node exporter. Another use case is invoking it from within > a CGI script, so that it can be embedded in an existing web service. > Storing the executable under /usr/libexec would therefore be a bit > weird. To me, those use cases argue for /usr/libexec which is for things humans don't run. -- Brooks --2fHTh5uZTiUOsy+g Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAEBAgAGBQJYXC7qAAoJEKzQXbSebgfAX9UH/1ELT5mqiPt052WQlJV1Uxcv 7IKxlDpPVRjAvgptYxKuC6QzbRbsH23ODDZnrQ/O5AirsZNmDvQFZAHhj1qd+nN9 rDN9X9z98Y4gXDrhJfSfnPZVkFBzWXXu+JpV31hit3+ZyfS8wJf4Mb7HvsGmNYYG Byg6SBsJzRO7QvjrQA/oNLj2nelI24WRfYbIepf4cERRvQ4w5vbKv11E8ZX0HjBu 81AKzi7wEzpDbIPj1TZ+FitaLnzqVBVDxtkl0nv4XVx9+kBFCdBWzuNAT9QbcW0k OHAL5aBj4uMffHJWmH4uZvznB0VQFgGpex0qLKqeLdfnSrxWyLNfNpAv37KWx9Q= =uUN5 -----END PGP SIGNATURE----- --2fHTh5uZTiUOsy+g-- From owner-svn-src-head@freebsd.org Thu Dec 22 20:07:54 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8EEC3C8DF53 for ; Thu, 22 Dec 2016 20:07:54 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from nm26.bullet.mail.ne1.yahoo.com (nm26.bullet.mail.ne1.yahoo.com [98.138.90.89]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5AFF4392 for ; Thu, 22 Dec 2016 20:07:54 +0000 (UTC) (envelope-from pfg@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1482437267; bh=ZBl5FvOPPsyo2LVmJGFoNzzxZQi5TztR514ONn7g1DA=; h=Subject:To:References:From:Date:In-Reply-To:From:Subject; b=BWrrWMFLCXaTvNME4gBNB96jXcNG9Dupq1EdNkOLmtke1DTgCwRwp/C52lEgc5lDrjDFOmlyKD2bfw3pT/VEQiM84MoID3IoUVVmpNIOlfb74LN826XNzpOwGhm+ZTdxWhDYCJZ3PELbK+2FEF8JBtVSMQu4e2A/NyfLJzhc/FJSGXE6dqxgsoYQZgrsSRwdt9C9IAvbVQhmYZk3IMjKuovvcgeROs/y/z8ZAFOtaIcaxAhuObc7t99caBcyum0/yuh0LXajrU9dt6Lh5TCkoDXgAE530owZQFhqxeMPi+xdIea4Uk6f2CFmdV0Es9cn5eck/zbuQ/Jts5Dw3GMMng== Received: from [98.138.101.128] by nm26.bullet.mail.ne1.yahoo.com with NNFMP; 22 Dec 2016 20:07:47 -0000 Received: from [98.138.104.116] by tm16.bullet.mail.ne1.yahoo.com with NNFMP; 22 Dec 2016 20:07:47 -0000 Received: from [127.0.0.1] by smtp225.mail.ne1.yahoo.com with NNFMP; 22 Dec 2016 20:07:44 -0000 X-Yahoo-Newman-Id: 270394.99934.bm@smtp225.mail.ne1.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: MLlX9vMVM1nxDPYn20KvjQ56.URWEN.F1glGXfTLIoYqGu1 Ri6RoAQsRYip0ZIQrnxG1xOewurtWK9NI_tkzYiIB4MmFRae1tfV.OuU0dVG DX.W.iSmGwDj2fk30c5g4DFkI3bYcNDM8U0tSNAVGeZQKFDjuLwsyzS6r9zm KfuwHq6ih.jKfMoQHwY_pniYwbgDqaLpz2_gpAYsOYEVWwj3cDgicH.db5MI ym4Dm7p9FxI57bUS026kEkIRyNcOlhkVJi_.xULWD8qwkyQgy2BUKGSFP1qn G3vXG_XdCBZ.FhomO0Bx5TqhMZ8B4pRjliVi9_1J_gmJwojEzreowGUB5sJs _FkJntwMx3awEe58IcmAgfcukApoqYhn7HEKcSO5qVnuOkfCMpD2V4wPsk3a XcNXkwFLHsN9i7F.NIWijC2evD4p8QV9TxOTGegI7rq3WXOGHk8qLkTzSNvD 4_5m0JoWkZGQdPQQlEWNEABe9Fm8k4z2_6vh.j7anQpcDHH_d52ezH.zxHz9 4G3aoOzmqvrojQ6QN8XphAuYZI0diRjhg0Ab6NZsxkwCAKQwo X-Yahoo-SMTP: xcjD0guswBAZaPPIbxpWwLcp9Unf Subject: Re: svn commit: r310425 - in head/sys/dev/mlx4: mlx4_core mlx4_ib To: Ed Maste , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201612221826.uBMIQLFQ076247@repo.freebsd.org> From: Pedro Giffuni Message-ID: Date: Thu, 22 Dec 2016 15:09:09 -0500 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <201612221826.uBMIQLFQ076247@repo.freebsd.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 20:07:54 -0000 On 22/12/2016 13:26, Ed Maste wrote: > Author: emaste > Date: Thu Dec 22 18:26:21 2016 > New Revision: 310425 > URL: https://svnweb.freebsd.org/changeset/base/310425 > > Log: > mlx: avoid use of __DATE__ to make build reproducible > > Reviewed by: hselasky > Differential Revision: https://reviews.freebsd.org/D8886 Hmm ... Sadly opengrok[*] reveals many uses of __DATE__. I am wondering if there is some way to have it replaced with the SVN Date keyword. Pedro. * http://src.illumos.org/source/search?q=__DATE__&defs=&refs=&path=&hist=&project=freebsd-head > Modified: > head/sys/dev/mlx4/mlx4_core/mlx4.h > head/sys/dev/mlx4/mlx4_ib/mlx4_ib_main.c > > Modified: head/sys/dev/mlx4/mlx4_core/mlx4.h > ============================================================================== > --- head/sys/dev/mlx4/mlx4_core/mlx4.h Thu Dec 22 18:05:22 2016 (r310424) > +++ head/sys/dev/mlx4/mlx4_core/mlx4.h Thu Dec 22 18:26:21 2016 (r310425) > @@ -52,7 +52,7 @@ > #define DRV_NAME "mlx4_core" > #define PFX DRV_NAME ": " > #define DRV_VERSION "2.1.6" > -#define DRV_RELDATE __DATE__ > +#define DRV_RELDATE "Sep 30 2016" > > #define DRV_STACK_NAME "Linux-MLNX_OFED" > #define DRV_STACK_VERSION "2.1" > > Modified: head/sys/dev/mlx4/mlx4_ib/mlx4_ib_main.c > ============================================================================== > --- head/sys/dev/mlx4/mlx4_ib/mlx4_ib_main.c Thu Dec 22 18:05:22 2016 (r310424) > +++ head/sys/dev/mlx4/mlx4_ib/mlx4_ib_main.c Thu Dec 22 18:26:21 2016 (r310425) > @@ -59,7 +59,7 @@ > > #define DRV_NAME MLX4_IB_DRV_NAME > #define DRV_VERSION "1.0" > -#define DRV_RELDATE __DATE__ > +#define DRV_RELDATE "Sep 30 2016" > > #define MLX4_IB_DRIVER_PROC_DIR_NAME "driver/mlx4_ib" > #define MLX4_IB_MRS_PROC_DIR_NAME "mrs" > From owner-svn-src-head@freebsd.org Thu Dec 22 20:28:07 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 77504C8CEF7; Thu, 22 Dec 2016 20:28:07 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 470741E2F; Thu, 22 Dec 2016 20:28:07 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBMKS6fQ025290; Thu, 22 Dec 2016 20:28:06 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBMKS6VO025289; Thu, 22 Dec 2016 20:28:06 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201612222028.uBMKS6VO025289@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Thu, 22 Dec 2016 20:28:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310428 - head/sys/mips/malta X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 20:28:07 -0000 Author: jhb Date: Thu Dec 22 20:28:06 2016 New Revision: 310428 URL: https://svnweb.freebsd.org/changeset/base/310428 Log: Fix dump_avail[] for MALTA platforms to include the kernel. dump_avail[] is supposed to be a superset of phys_avail[] that describes all of the memory ranges that should be included in a full dump. minidumps don't consider pages described by dump_avail[] to be valid and thus they are excluded via the is_dumpable() function. Most MIPS platforms (including MALTA) set dump_avail[] to be identical to phys_avail[]. In particular, phys_avail[] doesn't include the kernel itself, so pages for the kernel and it's global variables are not considered dumpable and not included in the dump. Fix this by setting dump_avail[0] to the first memory address (0) rather than the end of the kernel. Several other MIPS platforms have the same bug, though I am only able to test malta in qemu. The correct fix is to set dump_avail[] to describe RAM and in particular to not set dump_avail[0] to the end of the kernel (kernel_kseg0_end). Sponsored by: DARPA / AFRL Modified: head/sys/mips/malta/malta_machdep.c Modified: head/sys/mips/malta/malta_machdep.c ============================================================================== --- head/sys/mips/malta/malta_machdep.c Thu Dec 22 20:16:10 2016 (r310427) +++ head/sys/mips/malta/malta_machdep.c Thu Dec 22 20:28:06 2016 (r310428) @@ -191,7 +191,7 @@ mips_init(unsigned long memsize, uint64_ /* phys_avail regions are in bytes */ phys_avail[0] = MIPS_KSEG0_TO_PHYS(kernel_kseg0_end); phys_avail[1] = memsize; - dump_avail[0] = phys_avail[0]; + dump_avail[0] = 0; dump_avail[1] = phys_avail[1]; /* Only specify the extended region if it's set */ From owner-svn-src-head@freebsd.org Thu Dec 22 20:56:09 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D37BAC8D684; Thu, 22 Dec 2016 20:56:09 +0000 (UTC) (envelope-from carpeddiem@gmail.com) Received: from mail-it0-x243.google.com (mail-it0-x243.google.com [IPv6:2607:f8b0:4001:c0b::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9CECAEEB; Thu, 22 Dec 2016 20:56:09 +0000 (UTC) (envelope-from carpeddiem@gmail.com) Received: by mail-it0-x243.google.com with SMTP id 75so22150773ite.1; Thu, 22 Dec 2016 12:56:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=+g3LzCztI93SwgwiiP7+DQhW2SHsYrGkNU8PDZCPXSY=; b=cn2Vyy3Bu956JQAyMR1ZnyFY5IcGk2LszZ+m3mT2u2IkYwNbzwG4oyhQtCS5dfvE6R 7KFETpXOtzehH5lB3ATdq4SuFyEuayqEOSTcwFejINzxvNqmeqD0RaiELMkghbJ//uuJ 3IoDlmdXu4bSCXYfHPDy20MEeD5foe43w0+VMFMIvhE7aXPF8FLXL0up1OOU+nTqFM2e jxEZTXAkCFg5jv85yxgh/wAZqdvalHJpqWROmbGXKgquQVSz+Gs4KuJdQWyftqhx/vRM ra9SjR2xS77SJTb5ISJzatZRro2f2zekX3eWU50sntLJgts3vetK9T/WLRSztri2KCuF +cNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=+g3LzCztI93SwgwiiP7+DQhW2SHsYrGkNU8PDZCPXSY=; b=H5nshCL4BqO6bvkS+g8FoF/gtUepljF8A1j7wbPaCY25U/BieRSxluaWj48uE868dX GAAyPdwS6qtGStotkDJqpakFqiEOh4frtdkzvQiDpzPhFC8Tm1bdyrEKXv+/3r5vsaJK gImX70dH+qDh8k6/b5z98mNoDZ5use62EimnP7b5iWv/vggbgIQwQDuTiE5w9lObRvl5 4VKvkfA8GYsw5AUTHMw06rPptLBG43uUsyRr9QSa9CcijzBY4UPihKgi8qhe7o4s7eTT vFIjvBLsKZZpf7O/6x8b6lAugPdLFs+b5gOA+CbsgdmfZ5aGDj5A84cQ5Zff2lEyKgUX Pu7Q== X-Gm-Message-State: AIkVDXJ9nmPwTpXg90M1tlhnMIaUILngbwlnZ1teweWWQ6Sg2iqrbndaXkamkQdygYfeaD8Z7yqtUwzYuOu8LQ== X-Received: by 10.36.77.5 with SMTP id l5mr11485066itb.83.1482440168743; Thu, 22 Dec 2016 12:56:08 -0800 (PST) MIME-Version: 1.0 Sender: carpeddiem@gmail.com Received: by 10.107.175.133 with HTTP; Thu, 22 Dec 2016 12:55:48 -0800 (PST) In-Reply-To: References: <201612221826.uBMIQLFQ076247@repo.freebsd.org> From: Ed Maste Date: Thu, 22 Dec 2016 15:55:48 -0500 X-Google-Sender-Auth: lrygBWPj69TyYGuXRcHIAiHhKio Message-ID: Subject: Re: svn commit: r310425 - in head/sys/dev/mlx4: mlx4_core mlx4_ib To: Pedro Giffuni Cc: "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 20:56:09 -0000 On 22 December 2016 at 15:09, Pedro Giffuni wrote: > > On 22/12/2016 13:26, Ed Maste wrote: >> >> Author: emaste >> Date: Thu Dec 22 18:26:21 2016 >> New Revision: 310425 >> URL: https://svnweb.freebsd.org/changeset/base/310425 >> >> Log: >> mlx: avoid use of __DATE__ to make build reproducible >> Reviewed by: hselasky >> Differential Revision: https://reviews.freebsd.org/D8886 > > Hmm ... > Sadly opengrok[*] reveals many uses of __DATE__. Many of these are not an issue for a reproducible base system though: they're in comments, in source under tools/ or contrib code that's not built, or are the implementation of __DATE__ support in some compiler or text processor. I believe that on amd64 it was only this now-removed instance in mlx(4) and the one in iasl (see https://reviews.freebsd.org/D8856) that affected base system reproducibility. > I am wondering if there is some way to have it replaced with the SVN Date > keyword. I don't like the idea of deriving it from an SVN keyword, since it then doesn't work for FreeBSD developers or downstream projects using git or other version control tools. The kernel version uniquely identifies the source from which it was built, and in my opinion it's preferable to just remove this sort of metadata. Here I went with just pinning it to the last date the src was updated as this vendor code and produces a user-facing string, but perhaps Mellanox can be convinced to just remove the DRV_RELDATE. Posted in https://reviews.freebsd.org/D8888. From owner-svn-src-head@freebsd.org Thu Dec 22 20:58:00 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 215BAC8D701; Thu, 22 Dec 2016 20:58:00 +0000 (UTC) (envelope-from carpeddiem@gmail.com) Received: from mail-it0-x241.google.com (mail-it0-x241.google.com [IPv6:2607:f8b0:4001:c0b::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DABDA10A9; Thu, 22 Dec 2016 20:57:59 +0000 (UTC) (envelope-from carpeddiem@gmail.com) Received: by mail-it0-x241.google.com with SMTP id 75so22155208ite.1; Thu, 22 Dec 2016 12:57:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=PVB9KJGh5Wbdjqs4OQvpwhhJ8sJHWWMLBMljR7+9E28=; b=Zn5nEnJKQUwjswkLRAkz+Lq6leyTw7AK+2hpvKwFhRwZ2XiIxwBU4i2/ok1ywYFFdc EywbFvLHHm9uD5i86t1SzYZtE1+fxlYH2wxfx0cwvTi3DyPpFTBuVNtT42dAWqU2mZDz nYVvzFbbhey15WEdwvu6OG4NjhV24/rirVWcZbwippcgS9ivKPLj3H3sQ55iPTKyYmIz HiY6QxHJxlPbZB7uUh2i6f5Ba25u7Oeb8BoK/PYxZzTKlfX0zpvSz7XRGEHJeV7YiMkZ AdNcCsDLCDMyncMP9ZrQzjCv1L7Wq4jTUODiKGjnFQrCdLTfusFaHUVKy2veqyJ+YdJk APjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=PVB9KJGh5Wbdjqs4OQvpwhhJ8sJHWWMLBMljR7+9E28=; b=ufzKc3Ucep+TEpwujpDRsxxF5381bVTKf1vRTsIMWBPW5DFP0ZobbEASL8zfdOI+V8 CQFs5pOo54JGzn3QkdXdMuCCi0Hn1uGUbgkqcbDnZ5ntTfhDNpszYqCjv4ccK0mOYPm0 hKyXuvGpEl/eWDN0XuNtSI3HcDGI7MZ6FKcFPzpEX1ufgSkc3OjhPPvqjSsJSxWtxYSJ t6QmzVEPRHWPzWozuqot/lbpkf1hhpjQ683YuuMV1Hedby4u1YIfms1VMRqrbSv6hOBL YFVopCXun74Hkol/kyfkft7a/Mxjba+WWc2O7cadGVUM3vC+4EYWOqb7itBieElMCseD EBLg== X-Gm-Message-State: AIkVDXLjaTQtOGmgoQWYPKq2oGKUhol5Z3PgveR9IkF4nlFzdUv5sJK3tUbsgQgcWsToXjCVMBv/axcPw6I/fw== X-Received: by 10.36.108.17 with SMTP id w17mr10919103itb.108.1482440279381; Thu, 22 Dec 2016 12:57:59 -0800 (PST) MIME-Version: 1.0 Sender: carpeddiem@gmail.com Received: by 10.107.175.133 with HTTP; Thu, 22 Dec 2016 12:57:38 -0800 (PST) In-Reply-To: References: <201612221826.uBMIQLFQ076247@repo.freebsd.org> From: Ed Maste Date: Thu, 22 Dec 2016 15:57:38 -0500 X-Google-Sender-Auth: ZwTEFqFcPnM_izyqToo7yTj8szA Message-ID: Subject: Re: svn commit: r310425 - in head/sys/dev/mlx4: mlx4_core mlx4_ib To: Ed Schouten Cc: src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 20:58:00 -0000 On 22 December 2016 at 14:44, Ed Schouten wrote: > 2016-12-22 19:26 GMT+01:00 Ed Maste : >> Log: >> mlx: avoid use of __DATE__ to make build reproducible > > Out of curiosity, are we planning on adding -Wdate-time or > -Werror=date-time to our default CFLAGS? If so, awesome! I hadn't thought of it, but good idea. Maybe something like this for now: --- a/share/mk/bsd.sys.mk +++ b/share/mk/bsd.sys.mk @@ -88,6 +88,9 @@ CWARNFLAGS.clang+= -Wno-parentheses .if defined(NO_WARRAY_BOUNDS) CWARNFLAGS.clang+= -Wno-array-bounds .endif # NO_WARRAY_BOUNDS +.if ${MK_REPRODUCIBLE_BUILD} != no +CWARNFLAGS.clang+= -Wdate-time +.endif # MK_REPRODUCIBLE_BUILD .endif # WARNS From owner-svn-src-head@freebsd.org Thu Dec 22 21:01:57 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5BB30C8D8A9; Thu, 22 Dec 2016 21:01:57 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 1BD0E155A; Thu, 22 Dec 2016 21:01:57 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBML1uBk040639; Thu, 22 Dec 2016 21:01:56 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBML1uFn040638; Thu, 22 Dec 2016 21:01:56 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201612222101.uBML1uFn040638@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Thu, 22 Dec 2016 21:01:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310429 - head/sys/dev/usb/wlan X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 21:01:57 -0000 Author: adrian Date: Thu Dec 22 21:01:56 2016 New Revision: 310429 URL: https://svnweb.freebsd.org/changeset/base/310429 Log: [rsu] convert rsu to use the ieee80211_rx_stats struct to pass up RSSI, PHY and rate information. I don't yet know which RX descriptor bits map to shortgi, long-gi, short-preamble, long-preamble, STBC, LDPC, HT40, etc - so I can't easily add those just yet. There's apparently no per-frame RX RSSI information exposed so we also just use the results from the previous calibration task. This also tidies up how the per-mbuf RSSI is pushed into the frame - now that it's attached to the mbuf via rx_stats, we don't have to do any silly hijinx to get it out of the frame processing path. Tested: * RTL8712, 1x1 cut 3, STA mode Modified: head/sys/dev/usb/wlan/if_rsu.c Modified: head/sys/dev/usb/wlan/if_rsu.c ============================================================================== --- head/sys/dev/usb/wlan/if_rsu.c Thu Dec 22 20:28:06 2016 (r310428) +++ head/sys/dev/usb/wlan/if_rsu.c Thu Dec 22 21:01:56 2016 (r310429) @@ -238,8 +238,7 @@ static struct mbuf * rsu_rx_copy_to_mbuf struct r92s_rx_stat *, int); static uint32_t rsu_get_tsf_low(struct rsu_softc *); static uint32_t rsu_get_tsf_high(struct rsu_softc *); -static struct ieee80211_node * rsu_rx_frame(struct rsu_softc *, struct mbuf *, - int8_t *); +static struct ieee80211_node * rsu_rx_frame(struct rsu_softc *, struct mbuf *); static struct mbuf * rsu_rx_multi_frame(struct rsu_softc *, uint8_t *, int); static struct mbuf * rsu_rxeof(struct usb_xfer *, struct rsu_data *); @@ -2344,14 +2343,16 @@ rsu_get_tsf_high(struct rsu_softc *sc) } static struct ieee80211_node * -rsu_rx_frame(struct rsu_softc *sc, struct mbuf *m, int8_t *rssi_p) +rsu_rx_frame(struct rsu_softc *sc, struct mbuf *m) { struct ieee80211com *ic = &sc->sc_ic; struct ieee80211_frame_min *wh; + struct ieee80211_rx_stats rxs; struct r92s_rx_stat *stat; uint32_t rxdw0, rxdw3; uint8_t cipher, rate; int infosz; + int rssi; stat = mtod(m, struct r92s_rx_stat *); rxdw0 = le32toh(stat->rxdw0); @@ -2363,10 +2364,10 @@ rsu_rx_frame(struct rsu_softc *sc, struc /* Get RSSI from PHY status descriptor if present. */ if (infosz != 0 && (rxdw0 & R92S_RXDW0_PHYST)) - *rssi_p = rsu_get_rssi(sc, rate, &stat[1]); + rssi = rsu_get_rssi(sc, rate, &stat[1]); else { /* Cheat and get the last calibrated RSSI */ - *rssi_p = rsu_hwrssi_to_rssi(sc, sc->sc_currssi); + rssi = rsu_hwrssi_to_rssi(sc, sc->sc_currssi); } if (ieee80211_radiotap_active(ic)) { @@ -2402,7 +2403,7 @@ rsu_rx_frame(struct rsu_softc *sc, struc tap->wr_rate = 0x80 | (rate - 12); } - tap->wr_dbm_antsignal = *rssi_p; + tap->wr_dbm_antsignal = rssi; tap->wr_chan_freq = htole16(ic->ic_curchan->ic_freq); tap->wr_chan_flags = htole16(ic->ic_curchan->ic_flags); }; @@ -2441,6 +2442,78 @@ rsu_rx_frame(struct rsu_softc *sc, struc } } + /* RX flags */ + + /* Set channel flags for input path */ + bzero(&rxs, sizeof(rxs)); + + /* normal RSSI */ + rxs.r_flags |= IEEE80211_R_NF | IEEE80211_R_RSSI; + rxs.c_rssi = rssi; + rxs.c_nf = -96; + + /* Rate */ + if (!(rxdw3 & R92S_RXDW3_HTC)) { + switch (rate) { + /* CCK. */ + case 0: + rxs.c_rate = 2; + rxs.c_pktflags |= IEEE80211_RX_F_CCK; + break; + case 1: + rxs.c_rate = 4; + rxs.c_pktflags |= IEEE80211_RX_F_CCK; + break; + case 2: + rxs.c_rate = 11; + rxs.c_pktflags |= IEEE80211_RX_F_CCK; + break; + case 3: + rxs.c_rate = 22; + rxs.c_pktflags |= IEEE80211_RX_F_CCK; + break; + /* OFDM. */ + case 4: + rxs.c_rate = 12; + rxs.c_pktflags |= IEEE80211_RX_F_OFDM; + break; + case 5: + rxs.c_rate = 18; + rxs.c_pktflags |= IEEE80211_RX_F_OFDM; + break; + case 6: + rxs.c_rate = 24; + rxs.c_pktflags |= IEEE80211_RX_F_OFDM; + break; + case 7: + rxs.c_rate = 36; + rxs.c_pktflags |= IEEE80211_RX_F_OFDM; + break; + case 8: + rxs.c_rate = 48; + rxs.c_pktflags |= IEEE80211_RX_F_OFDM; + break; + case 9: + rxs.c_rate = 72; + rxs.c_pktflags |= IEEE80211_RX_F_OFDM; + break; + case 10: + rxs.c_rate = 96; + rxs.c_pktflags |= IEEE80211_RX_F_OFDM; + break; + case 11: + rxs.c_rate = 108; + rxs.c_pktflags |= IEEE80211_RX_F_OFDM; + break; + } + } else if (rate >= 12) { /* MCS0~15. */ + /* Bit 7 set means HT MCS instead of rate. */ + rxs.c_rate = (rate - 12); + rxs.c_pktflags |= IEEE80211_RX_F_HT; + } + + (void) ieee80211_add_rx_params(m, &rxs); + /* Drop descriptor. */ m_adj(m, sizeof(*stat) + infosz); wh = mtod(m, struct ieee80211_frame_min *); @@ -2550,7 +2623,6 @@ rsu_bulk_rx_callback(struct usb_xfer *xf struct ieee80211_node *ni; struct mbuf *m = NULL, *next; struct rsu_data *data; - int8_t rssi; RSU_ASSERT_LOCKED(sc); @@ -2584,16 +2656,16 @@ tr_setup: next = m->m_next; m->m_next = NULL; - ni = rsu_rx_frame(sc, m, &rssi); + ni = rsu_rx_frame(sc, m); RSU_UNLOCK(sc); if (ni != NULL) { if (ni->ni_flags & IEEE80211_NODE_HT) m->m_flags |= M_AMPDU; - (void)ieee80211_input(ni, m, rssi, -96); + (void)ieee80211_input_mimo(ni, m); ieee80211_free_node(ni); } else - (void)ieee80211_input_all(ic, m, rssi, -96); + (void)ieee80211_input_mimo_all(ic, m); RSU_LOCK(sc); m = next; From owner-svn-src-head@freebsd.org Thu Dec 22 21:11:43 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5CC9AC8DB72; Thu, 22 Dec 2016 21:11:43 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 2591B19F5; Thu, 22 Dec 2016 21:11:43 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBMLBg4M043376; Thu, 22 Dec 2016 21:11:42 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBMLBgi3043375; Thu, 22 Dec 2016 21:11:42 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201612222111.uBMLBgi3043375@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Thu, 22 Dec 2016 21:11:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310430 - head/sys/conf X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 21:11:43 -0000 Author: ian Date: Thu Dec 22 21:11:42 2016 New Revision: 310430 URL: https://svnweb.freebsd.org/changeset/base/310430 Log: Use ${.OBJDIR} to refer to the kernel build object dir, instead of trying to recreate it from ${MAKEOBJDIRPREFIX} and ${SRC_BASE} and ${KERNCONF}, the latter being especially problematic when KERNCONF is set to the names of multiple kernel configs. Modified: head/sys/conf/kern.post.mk Modified: head/sys/conf/kern.post.mk ============================================================================== --- head/sys/conf/kern.post.mk Thu Dec 22 21:01:56 2016 (r310429) +++ head/sys/conf/kern.post.mk Thu Dec 22 21:11:42 2016 (r310430) @@ -63,7 +63,7 @@ OSRELDATE!= awk '/^\#define[[:space:]]*_ ${MAKEOBJDIRPREFIX}${SRC_BASE}/include/osreldate.h .endif # Keep the related ports builds in the obj directory so that they are only rebuilt once per kernel build -WRKDIRPREFIX?= ${MAKEOBJDIRPREFIX}${SRC_BASE}/sys/${KERNCONF} +WRKDIRPREFIX?= ${.OBJDIR} PORTSMODULESENV=\ env \ -u CC \ From owner-svn-src-head@freebsd.org Thu Dec 22 22:02:06 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7DC7FC8D971; Thu, 22 Dec 2016 22:02:06 +0000 (UTC) (envelope-from baptiste.daroussin@gmail.com) Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 06E901CE6; Thu, 22 Dec 2016 22:02:06 +0000 (UTC) (envelope-from baptiste.daroussin@gmail.com) Received: by mail-wm0-x243.google.com with SMTP id c85so317745wmi.1; Thu, 22 Dec 2016 14:02:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=MKSrveDDU7+FIhZXC26llknjw3U8LOhywM8q9juIJVY=; b=WWgcQI6vKwotyCEQkiT/Mgh2cw/5XaOg747sDUSIJ9YTz/Q8DglFzqyuWmS9geCDcX IPreavhBqqf0cXtKlJQYCOkQpcPbfGncMtCwitlxAaxZC9BqujCu2yM7S0xsfOMJg8ep kJwvM0r2viwRQlGynZu842pmzDBWFr44FCXysxvKN7qHJfttHEPyHlomsAkGTlBIQ/B9 llw/Z9C4FDezDGztBfU8D7IkHKjnSx2/6B9wHnkJGJkPLJwJ4t9+dygkoM2YSaMZJabh TWyKsFOBQvE1xRLypAf1SFAFOPHKCYGh9quFDMF09dYRO4Fdn4hrlE00jK6fR3JKjxzM Qrmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=MKSrveDDU7+FIhZXC26llknjw3U8LOhywM8q9juIJVY=; b=FyFZzixgGePU0V6aGST6vyu7UKZpMeMI/xwBKm01MDZaGkF4N3hUX7Ix2oIEW4qK9b o8OImDLJEmSMpop9AwzSFa01taEzMnNaRopjbhpxXgGvLc3NRShGVorw3SN0tDkZS/PK /O3DLCYSNl1+J7TgJhKBNUI4VBwcVe1aK+NDC0DiXYIiDTcSf1COAt5AvgUfol3HiFzz 6sgSUR9B0DfqGyZKY7IQoaMYX8sltXDPe8uinDfPXFkklSKEernTa2hBPp4UHGDNasYO fI3tnYDJSLrv8WZMGzR/ZAcrDeiyRNtSWguUSRCRyerzPRg/ORtVewHsQyvlbp3zOlPD zvvA== X-Gm-Message-State: AIkVDXKFgPS7Wyfmrvuu4g+pmOtGx5TBDhV01Dfu8TnjrH8R40u6wG/S7osz3mXpzfdqjw== X-Received: by 10.28.25.135 with SMTP id 129mr12978806wmz.122.1482444124126; Thu, 22 Dec 2016 14:02:04 -0800 (PST) Received: from ivaldir.etoilebsd.net ([2001:41d0:8:db4c::1]) by smtp.gmail.com with ESMTPSA id b15sm34128594wma.5.2016.12.22.14.02.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Dec 2016 14:02:03 -0800 (PST) Sender: Baptiste Daroussin Date: Thu, 22 Dec 2016 23:02:02 +0100 From: Baptiste Daroussin To: Ed Maste Cc: Ed Schouten , src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Subject: Re: svn commit: r310425 - in head/sys/dev/mlx4: mlx4_core mlx4_ib Message-ID: <20161222220202.y4us772z6hd43nni@ivaldir.etoilebsd.net> References: <201612221826.uBMIQLFQ076247@repo.freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="dcexskdpxwkelirr" Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20161126 (1.7.1) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 22:02:06 -0000 --dcexskdpxwkelirr Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Dec 22, 2016 at 03:57:38PM -0500, Ed Maste wrote: > On 22 December 2016 at 14:44, Ed Schouten wrote: > > 2016-12-22 19:26 GMT+01:00 Ed Maste : > >> Log: > >> mlx: avoid use of __DATE__ to make build reproducible > > > > Out of curiosity, are we planning on adding -Wdate-time or > > -Werror=3Ddate-time to our default CFLAGS? If so, awesome! >=20 > I hadn't thought of it, but good idea. Maybe something like this for now: >=20 > --- a/share/mk/bsd.sys.mk > +++ b/share/mk/bsd.sys.mk > @@ -88,6 +88,9 @@ CWARNFLAGS.clang+=3D -Wno-parentheses > .if defined(NO_WARRAY_BOUNDS) > CWARNFLAGS.clang+=3D -Wno-array-bounds > .endif # NO_WARRAY_BOUNDS > +.if ${MK_REPRODUCIBLE_BUILD} !=3D no > +CWARNFLAGS.clang+=3D -Wdate-time > +.endif # MK_REPRODUCIBLE_BUILD > .endif # WARNS >=20 +1 Bapt --dcexskdpxwkelirr Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEgOTj3suS2urGXVU3Y4mL3PG3PloFAlhcTVMACgkQY4mL3PG3 PlppJg/9E2icSMeBbRlzNpa5FSV43VGlLi9653qXNoiIx317uWc6BYYXW6f8C5tn oUDIxOt3VUCX1qwHePcB7a6V75GzgF9Elu72akduNuMSuhm44LWB/WZ1aW0/51AJ KC5qhHc5WUB4mpk93WH55Bcw+ljxgmNmmL1662LdgCVDPxvAeQowaqz9FivHsXWL QkEvhLUuWcGzaDZ30JYUA+Yg3iFCZG53zfUMvn+Z39XP1HZ+4Qj0SGQtCnolBAZJ kTasdBwdPvIKMHhlGrDuEneWitbcSI/VebkvB3zv5eXpvYJldIqnd1qeJg5DshBL am/SF0MxTWF0wsaYmQAo+X8KrbBYKCIZauQLcTDGbzi+HUT2yWNXitpnHbqpeY4u Dpg3PatkpPSVuO5i3l2eiHz1v3a7LDKaIdY/O08gczgmVshGuAw/tix8G6zlPAXE 0dyAVcGm6B+brsP0UC1KwD2IlcuN8ABgNdWLucWs+rNUDplmhIc/kSJFD1yOP3E4 rktHVwuJmMvei6AjGFc0SsuIY06Jzvy56RxLaFtaR4+tBo0gDZLh3Zk0+BzVKBNP cI1khLE84ex2El1sp1O10ScZK8U2+1OFEkgAaXP5riIksWSfHOAcMH5QfPNMCHTc FZNB6Ac1hG6XBIjOTRL51cXVcRq8/kw96vr2qBbwksEdHeUDdxE= =i88t -----END PGP SIGNATURE----- --dcexskdpxwkelirr-- From owner-svn-src-head@freebsd.org Thu Dec 22 22:02:48 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E18E6C8D9D1; Thu, 22 Dec 2016 22:02:48 +0000 (UTC) (envelope-from baptiste.daroussin@gmail.com) Received: from mail-wj0-x244.google.com (mail-wj0-x244.google.com [IPv6:2a00:1450:400c:c01::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6E03D1EA4; Thu, 22 Dec 2016 22:02:48 +0000 (UTC) (envelope-from baptiste.daroussin@gmail.com) Received: by mail-wj0-x244.google.com with SMTP id j10so38004621wjb.3; Thu, 22 Dec 2016 14:02:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=IY7qokueCFgDVb5VajLeRFt012GAaoa7xz6W2IrXgw0=; b=kjkhH4Fv/ABEBKg8NMK5u9z73Wp4srqKg7Kl/8sw8/os1POaP0Rt+YlSFLIGczgave BGr3Tptxu/fLckrSjvnj2CGfCoNh9Lqw8uHTnypQsmGkCP33Fla6HkHbQh/1vw2i0nja clnYuEHoNgHn6BP/n36wkwXDrRbpvdSv3lxFH5mKaOiIUmPGbrm61ukmHWza4HcFetsY vBKWL5HswzdNAJUyNmzgH2eRpCGMXMH5n50R8xeSDpYVUGIiQm2AxL7Nlvrr7Vr/d0uO plr7NXHuCbE6xTo/2La00GWkznCL2ryywPvn+SvUSxyuR+HlkDIkEr4oVy4WaqIEtAv5 ulPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=IY7qokueCFgDVb5VajLeRFt012GAaoa7xz6W2IrXgw0=; b=f9ebZqCtUvdW27dyrfW306YPAR2JFthULOMCqjsJisud7aX4QRBh6SInPQ3xau0U9N dhCzu0PCR8jSGCBMEXzKTmnga61jmhbem8Ao46J7KdHIRtnWqGWL8W0VpRhBjKc+xoQH wGc83TO3i6qqKvyp2p5xAL0wxPxBIeKpZ+Vcms9MSSWk2sTNGQrWPtd2Sb4otOkEF3BA PMI3aW+3yPJ6C73txdl0qwt+KmDstwc1lHyU/IutrW4U/Q9gDd3/tHLZbuqaTCzpRR01 amQ0kvK0K2USKfYmWjnC/cSVYqwxK1kY7+LrN3Lq7ELILlo7E/jjTyXzzYafYzmn7O4G dm/A== X-Gm-Message-State: AIkVDXJlowo5ke7kRT5US2vvN1bovcLq9vOvCAVExPnyNot7EWp71eMZFqtwz6MNr4YIfw== X-Received: by 10.195.30.43 with SMTP id kb11mr10594508wjd.131.1482444166958; Thu, 22 Dec 2016 14:02:46 -0800 (PST) Received: from ivaldir.etoilebsd.net ([2001:41d0:8:db4c::1]) by smtp.gmail.com with ESMTPSA id jz1sm12082115wjc.38.2016.12.22.14.02.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Dec 2016 14:02:46 -0800 (PST) Sender: Baptiste Daroussin Date: Thu, 22 Dec 2016 23:02:45 +0100 From: Baptiste Daroussin To: Jilles Tjoelker Cc: Conrad Meyer , Adrian Chadd , src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Subject: Re: svn commit: r310138 - head/lib/libc/stdio Message-ID: <20161222220245.zolanf4f2sii352d@ivaldir.etoilebsd.net> References: <201612160144.uBG1ipjW016736@repo.freebsd.org> <49460793.UcUNovQMDa@ralph.baldwin.cx> <1482281779.48539.41.camel@freebsd.org> <20161221220212.GA97256@stack.nl> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="bg2nhnfsemzw6v7m" Content-Disposition: inline In-Reply-To: <20161221220212.GA97256@stack.nl> User-Agent: NeoMutt/20161126 (1.7.1) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 22:02:49 -0000 --bg2nhnfsemzw6v7m Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Dec 21, 2016 at 11:02:12PM +0100, Jilles Tjoelker wrote: > On Tue, Dec 20, 2016 at 06:04:31PM -0800, Conrad Meyer wrote: > > On Tue, Dec 20, 2016 at 5:56 PM, Adrian Chadd = wrote: > > > Here's my reason for removal. >=20 > > > Plenty of us are looking to be able to build bits of the BSD source > > > tree as part of other non FreeBSD systems, especially if they're > > > involved in bootstrapping. >=20 > > Understood, however: >=20 > > > That means that it needs to be compilable > > > by a non-FreeBSD-modified compiler. Ideally this means we'd stick to > > > mostly POSIX options source code that we can compile with unmodified > > > compilers, and we push non-standard stuff into otherly-named > > > functions. >=20 > > Yeah, this isn't actually a problem. printf("%b", foo) compiles fine > > with non-modified compilers. >=20 > It compiles only if you disable format string warnings that should not > be disabled for any serious software development, in my humble opinion. > It will build, but not in a way I can call "fine". >=20 > This indeed makes it very hard to justify extensions to format strings. > Special formatting will need to use new functions. >=20 I think it is pretty clear that there are too many people requesting the re= vert for the revert not to be done. Bapt --bg2nhnfsemzw6v7m Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEgOTj3suS2urGXVU3Y4mL3PG3PloFAlhcTYUACgkQY4mL3PG3 PloNzQ//cdILmxq3LHUWwwNStzEKSKdKkTGuHu18dJ7UJaong0WWdrgPIf8oOQN9 G5HGoL7Ehv47fkq5Bztek+uka5lKt/VZ0KMpbqLc3wPaE0r/aFVkiqjSL2ozrEKQ zVz5pWmZJXzVN7geEmyhJnvKQuNQmZ2u32wbnPbCD1A1qwuT1vK5M1N0GRSDPLlz AM9Wxzv0aB8rPWtpYV8vlo6PbkMVhI15dMgFC1CS5mEMXKlfArOFhd8pTni6C7Jt 6PWQn2jRJl/DgekLbqULuPrWv+SQdbsYO5jLJxCljg/XznplWGe1J0PQCj1gRrDB BbJZYIUXYQ1LNCdy7YLdBwqrDfbPyQa26gf+NbFJwre9zjMKAmkYor630tGGV1Kq vnin17jfzacNAm09R0Qp3/trqj1CGZdahx2QP207RWz6TcFRvm89zFGhbqwPSp7c ya8DxVwr7Ekgm8umq/Z4mrzoPpM8Tcx1KG1lezx/jVjHYf0LwpzhoC7+3p2i21Gz Ho9L+WTGlOim4+ty5TIG3tZHaKjtkrfPyzKMJDd79ew+5ukGCSbaSj+xLyTRVuBE BrTx2/b3ervP+87dhF7bdypbj3H1E9zoSxKm3lXpRVNm14L8t3JoulI+arPMucQa s81NvbPeYrX8hhGi1lTglKlnu1yqOXV3Hv/TSM7v0nMDX0EL8A8= =OjtK -----END PGP SIGNATURE----- --bg2nhnfsemzw6v7m-- From owner-svn-src-head@freebsd.org Thu Dec 22 22:30:43 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BC525C8D10B; Thu, 22 Dec 2016 22:30:43 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 8C09BBC6; Thu, 22 Dec 2016 22:30:43 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBMMUgCX075129; Thu, 22 Dec 2016 22:30:42 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBMMUge9075128; Thu, 22 Dec 2016 22:30:42 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612222230.uBMMUge9075128@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Thu, 22 Dec 2016 22:30:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310433 - head/lib/libc/stdio X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 22:30:43 -0000 Author: ngie Date: Thu Dec 22 22:30:42 2016 New Revision: 310433 URL: https://svnweb.freebsd.org/changeset/base/310433 Log: Revert r310138 Adding %b support to vfprintf for parity with kernel space requires more discussion/review. In particular, many parties were concerned over introducing a non-standard format qualifier to *printf(3) which didn't already exist in other OSes, e.g. Linux, thus making code which used %b harder to port to other operating systems. Requested by: many Modified: head/lib/libc/stdio/vfprintf.c Modified: head/lib/libc/stdio/vfprintf.c ============================================================================== --- head/lib/libc/stdio/vfprintf.c Thu Dec 22 21:56:41 2016 (r310432) +++ head/lib/libc/stdio/vfprintf.c Thu Dec 22 22:30:42 2016 (r310433) @@ -611,37 +611,6 @@ reswitch: switch (ch) { case 'z': flags |= SIZET; goto rflag; - case 'b': - { - const char *q; - int anybitset, bit; - - ulval = (u_int)GETARG(int); - cp = GETARG(char *); - - q = __ultoa(ulval, buf + BUF, *cp++, 0, xdigs_lower); - PRINT(q, buf + BUF - q); - - if (ulval == 0) - break; - - for (anybitset = 0; *cp;) { - bit = *cp++; - if (ulval & (1 << (bit - 1))) { - PRINT(anybitset ? "," : "<", 1); - q = cp; - for (; (bit = *cp) > ' '; ++cp) - continue; - PRINT(q, cp - q); - anybitset = 1; - } else - for (; *cp > ' '; ++cp) - continue; - } - if (anybitset) - PRINT(">", 1); - } - continue; case 'C': flags |= LONGINT; /*FALLTHROUGH*/ From owner-svn-src-head@freebsd.org Thu Dec 22 23:02:32 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 49CD2C8D914; Thu, 22 Dec 2016 23:02:32 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-wj0-f175.google.com (mail-wj0-f175.google.com [209.85.210.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D93F5178; Thu, 22 Dec 2016 23:02:31 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-wj0-f175.google.com with SMTP id sd9so54616403wjb.1; Thu, 22 Dec 2016 15:02:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc; bh=dVnlVaTtPTPl6WwAKMmAqg+Ia5+kpbcwLAyF549M6/I=; b=ICQayQKVFkXvNHpxsOsZ7+2gW6Nimc5hoGEJCoHZp0moex31s1m9zUlhy+PFURoPph rxqiKcOttUR5ym0xWdnfD1IYZkAvIc2YTsi9pY4IIa5vXO4PpgJsf4w91FIuqor3YZH0 BSzk1YJAbKQh3kbXFlBNepBmA4m//EvbItxMKYILezf4zvM15AURA+e6mbHicwjD6aZr 7OVdmgaXKcOhsdocu7xWLPnO/avlZOU3D/yjb3DS8HK82xc2Ljges6XQtX5hP1eVWpbB 5IceE6MEzWlaVw/7rzvZT2/X0bKXelGYP0PhM3Awoj8+W0iHEmHpz9uPKG5y1JLdyGvf bzAw== X-Gm-Message-State: AIkVDXJKF7jb5jAUF4pHgUpx4TN0hUIrcW3KXT7f/Ps1h9UGEAPyEQh4umHcBSUGw2A2Hw== X-Received: by 10.194.148.134 with SMTP id ts6mr10929930wjb.220.1482446350537; Thu, 22 Dec 2016 14:39:10 -0800 (PST) Received: from mail-wj0-f173.google.com (mail-wj0-f173.google.com. [209.85.210.173]) by smtp.gmail.com with ESMTPSA id gj6sm37722117wjb.29.2016.12.22.14.39.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Dec 2016 14:39:10 -0800 (PST) Received: by mail-wj0-f173.google.com with SMTP id c11so34304919wjx.3; Thu, 22 Dec 2016 14:39:10 -0800 (PST) X-Received: by 10.194.222.202 with SMTP id qo10mr10899228wjc.115.1482446350283; Thu, 22 Dec 2016 14:39:10 -0800 (PST) MIME-Version: 1.0 Reply-To: cem@freebsd.org Received: by 10.194.29.72 with HTTP; Thu, 22 Dec 2016 14:39:09 -0800 (PST) In-Reply-To: <201612222230.uBMMUge9075128@repo.freebsd.org> References: <201612222230.uBMMUge9075128@repo.freebsd.org> From: Conrad Meyer Date: Thu, 22 Dec 2016 14:39:09 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r310433 - head/lib/libc/stdio To: Ngie Cooper Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 23:02:32 -0000 This was unjustified and inappropriate. On Thu, Dec 22, 2016 at 2:30 PM, Ngie Cooper wrote: > Author: ngie > Date: Thu Dec 22 22:30:42 2016 > New Revision: 310433 > URL: https://svnweb.freebsd.org/changeset/base/310433 > > Log: > Revert r310138 > > Adding %b support to vfprintf for parity with kernel space requires > more discussion/review. > > In particular, many parties were concerned over introducing a > non-standard format qualifier to *printf(3) which didn't already > exist in other OSes, e.g. Linux, thus making code which used %b > harder to port to other operating systems. > > Requested by: many > > Modified: > head/lib/libc/stdio/vfprintf.c > > Modified: head/lib/libc/stdio/vfprintf.c > ============================================================================== > --- head/lib/libc/stdio/vfprintf.c Thu Dec 22 21:56:41 2016 (r310432) > +++ head/lib/libc/stdio/vfprintf.c Thu Dec 22 22:30:42 2016 (r310433) > @@ -611,37 +611,6 @@ reswitch: switch (ch) { > case 'z': > flags |= SIZET; > goto rflag; > - case 'b': > - { > - const char *q; > - int anybitset, bit; > - > - ulval = (u_int)GETARG(int); > - cp = GETARG(char *); > - > - q = __ultoa(ulval, buf + BUF, *cp++, 0, xdigs_lower); > - PRINT(q, buf + BUF - q); > - > - if (ulval == 0) > - break; > - > - for (anybitset = 0; *cp;) { > - bit = *cp++; > - if (ulval & (1 << (bit - 1))) { > - PRINT(anybitset ? "," : "<", 1); > - q = cp; > - for (; (bit = *cp) > ' '; ++cp) > - continue; > - PRINT(q, cp - q); > - anybitset = 1; > - } else > - for (; *cp > ' '; ++cp) > - continue; > - } > - if (anybitset) > - PRINT(">", 1); > - } > - continue; > case 'C': > flags |= LONGINT; > /*FALLTHROUGH*/ > From owner-svn-src-head@freebsd.org Thu Dec 22 23:16:18 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 260FEC8DE32; Thu, 22 Dec 2016 23:16:18 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: from mail-pg0-x242.google.com (mail-pg0-x242.google.com [IPv6:2607:f8b0:400e:c05::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E7FC8CC3; Thu, 22 Dec 2016 23:16:17 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: by mail-pg0-x242.google.com with SMTP id g1so19791098pgn.0; Thu, 22 Dec 2016 15:16:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=ifgxMxLuqcU0+WHSuHeYrD/z+RoDy5xE/sfz4xW4s7o=; b=Ujniz1U79WDBMajw3BQB0koAhpQKklt29QHyZhY0RRSfQHlJpzERP5M3q+ZQdp16Uj yXSXCbMXob4W59m7q5+008sHxqzAAlhA9lfrcJ4EEnYCIBztA8vhsLn0cr3ZmtIX8uJO QNMRm0K4bys6o9o0oss0Dq+IUK1DkTlw4UFpxIpyoxR0h+ENyPT655X/rQEU1SSK6+0M UWF+OhhERf93ncfOfAeuac/PZkq0lqreGcGZogyu2mvAZf60nnQhIzh9vUS2EaP6Kv7W oiBmeTdiCTBEzvAOKdep0m++2IgwMF7sW3uNjHkgcFrN/Wb5t9Lg0ltsG8r32x84aOGk MSyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=ifgxMxLuqcU0+WHSuHeYrD/z+RoDy5xE/sfz4xW4s7o=; b=q0N9U5Ft2yYND0uZYeMa38vcNnrncf4TLq8ZK3Z6k1GTresh00JpbuR75ZB4Gmrfxy jw8yFeyamYUKPdQ1wLJm5lbH90v/DsC8v34EjVKfNVmhasxRZwGN1GPxfjmph0v0Zg9q Opj36UBSZEAtDm/u9N4W44EQBjYNYMczAim4GonMgjor+wddrVVnOSLMwVEcaWZfEn/k 8UbRJ0a9HYcW39+kCF+s5qLaEuXuyz/9gsqHXQn2PTEgI0alcBYSfeiExQEAy3/95Do2 hJJuMCH4wNb4c0PAH4Hpm5gHKkTawCO1mALk5WUdzGO7X8aYB0J1WmEbV2q/Sux9VR6G 4sSA== X-Gm-Message-State: AIkVDXINuMPU/o6qAL5nL5p5KFHVaoOPhsp3m4fU/MK7LXhLRtK/fbMnz3s+E9gqHMiytQ== X-Received: by 10.99.19.65 with SMTP id 1mr21210911pgt.71.1482448577290; Thu, 22 Dec 2016 15:16:17 -0800 (PST) Received: from fuji-wireless.local (c-73-19-52-228.hsd1.wa.comcast.net. [73.19.52.228]) by smtp.gmail.com with ESMTPSA id c71sm57436173pga.22.2016.12.22.15.16.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Dec 2016 15:16:16 -0800 (PST) From: "Ngie Cooper (yaneurabeya)" Message-Id: Mime-Version: 1.0 (Mac OS X Mail 10.2 \(3259\)) Subject: Re: svn commit: r310433 - head/lib/libc/stdio Date: Thu, 22 Dec 2016 15:16:15 -0800 In-Reply-To: Cc: Ngie Cooper , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org To: cem@freebsd.org References: <201612222230.uBMMUge9075128@repo.freebsd.org> X-Mailer: Apple Mail (2.3259) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 23:16:18 -0000 > On Dec 22, 2016, at 2:39 PM, Conrad Meyer wrote: >=20 > This was unjustified and inappropriate. Conrad, =46rom the committer=E2=80=99s guide ( = https://www.freebsd.org/doc/en_US.ISO8859-1/articles/committers-guide/arti= cle.html#developer.relations = ): If you are unsure about a commit for any reason at all, have it reviewed = by -hackers before committing. Better to have it flamed then and there = rather than when it is part of the repository. If you do happen to = commit something which results in controversy erupting, you may also = wish to consider backing the change out again until the matter is = settled. Remember =E2=80=93 with a version control system we can always = change it back. Per the commit message, the change wasn=E2=80=99t reviewed = before commit (" Reviewed by: no one, unfortunately=E2=80=9D). More = than a handful of people requested that the commit be reverted/changed. = There wasn=E2=80=99t an issue with the content created =E2=80=94 there = was just an issue with how %b was implemented (especially when it = impedes being able to cross-compile FreeBSD on other operating systems = or port code to those operating systems). Dmitriy=E2=80=99s comment about adding snprintb(3) from NetBSD = makes a lot of sense and will reintroduce the code that you added here, = and I fully agree and support his suggestion. For what it=E2=80=99s worth from personal experience, it=E2=80=99s= really a pain when non-standard things get leaked into FreeBSD, or when = you have to port software to other operating systems that use = non-standard interfaces (I usually have to do this moving Linux code to = FreeBSD). Take the format -fformat* string functionality in OneFS =E2=80=94= it=E2=80=99s unfortunate that we can=E2=80=99t use a standard compiler = to compile OneFS out of the box and instead have to bootstrap a compiler = which is intelligent enough to understand how the custom format strings = work, just to compile user space/a kernel. Thank you, -Ngie= From owner-svn-src-head@freebsd.org Thu Dec 22 23:32:24 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EEDC9C8D4A1; Thu, 22 Dec 2016 23:32:24 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-wj0-f195.google.com (mail-wj0-f195.google.com [209.85.210.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8E4901796; Thu, 22 Dec 2016 23:32:24 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-wj0-f195.google.com with SMTP id kp2so38166459wjc.0; Thu, 22 Dec 2016 15:32:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc:content-transfer-encoding; bh=Z8PoypfFiMnhZtC6FASHCoCDRe+0tFYUNb61hXcp8ss=; b=F62VtFJB8bLMKdeJ62J0Y/FU9xHTUewyV4F2Ygkhxm0XxHq0OKkEQq2X9dJX8TquG9 1V+Vqru9VTTsHnc/LPHekHx6nj07lAOLwVrvzRHl5Sdp7UzsPhjYTMR5ujs57wwMZev5 deAe6T3fx+VksY8Sobbnnr4dVoeDi/P7egZ7xqac2OyxyDQNQroOwc/CWdi+mfnZ+q/l xWKGBy0Gpz1BAqZqK+zpsuQmN1TR4exQMFajYERs1K9DzTpTbI/tairn7qj62/gRBmBQ xktY55o/DJ79inIqt3nEVa3FjTwnpWd5tCvz/p56bojlZvEMKGZGgGJjRwnwOiPsXxqY WMQg== X-Gm-Message-State: AIkVDXLV/nU69LU/3r4mkqQn0A0yp/WWzBNWWukAq9fx8ylzRYS5KdZF+89o+oAzDEZo2A== X-Received: by 10.194.141.98 with SMTP id rn2mr10983970wjb.1.1482449542383; Thu, 22 Dec 2016 15:32:22 -0800 (PST) Received: from mail-wm0-f41.google.com (mail-wm0-f41.google.com. [74.125.82.41]) by smtp.gmail.com with ESMTPSA id k11sm34230552wmf.24.2016.12.22.15.32.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Dec 2016 15:32:22 -0800 (PST) Received: by mail-wm0-f41.google.com with SMTP id k184so3090838wme.1; Thu, 22 Dec 2016 15:32:22 -0800 (PST) X-Received: by 10.28.88.11 with SMTP id m11mr13039997wmb.45.1482449542026; Thu, 22 Dec 2016 15:32:22 -0800 (PST) MIME-Version: 1.0 Reply-To: cem@freebsd.org Received: by 10.194.29.72 with HTTP; Thu, 22 Dec 2016 15:32:21 -0800 (PST) In-Reply-To: References: <201612222230.uBMMUge9075128@repo.freebsd.org> From: Conrad Meyer Date: Thu, 22 Dec 2016 15:32:21 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r310433 - head/lib/libc/stdio To: "Ngie Cooper (yaneurabeya)" Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 23:32:25 -0000 On Thu, Dec 22, 2016 at 3:16 PM, Ngie Cooper (yaneurabeya) wrote: > > On Dec 22, 2016, at 2:39 PM, Conrad Meyer wrote: > > This was unjustified and inappropriate. > > > Conrad, > > From the committer=E2=80=99s guide ( > https://www.freebsd.org/doc/en_US.ISO8859-1/articles/committers-guide/art= icle.html#developer.relations > ): > > If you are unsure about a commit for any reason at all, have it reviewed = by > -hackers before committing. Better to have it flamed then and there rathe= r > than when it is part of the repository. If you do happen to commit someth= ing > which results in controversy erupting, you may also wish to consider back= ing > the change out again until the matter is settled. Remember =E2=80=93 with= a version > control system we can always change it back. > > Per the commit message, the change wasn=E2=80=99t reviewed before commit = (" Reviewed > by: no one, unfortunately=E2=80=9D). More than a handful of people reques= ted that > the commit be reverted/changed. There wasn=E2=80=99t an issue with the co= ntent > created =E2=80=94 there was just an issue with how %b was implemented (es= pecially > when it impedes being able to cross-compile FreeBSD on other operating > systems or port code to those operating systems). > Dmitriy=E2=80=99s comment about adding snprintb(3) from NetBSD makes a lo= t of sense > and will reintroduce the code that you added here, and I fully agree and > support his suggestion. > For what it=E2=80=99s worth from personal experience, it=E2=80=99s really= a pain when > non-standard things get leaked into FreeBSD, or when you have to port > software to other operating systems that use non-standard interfaces (I > usually have to do this moving Linux code to FreeBSD). Take the format > -fformat* string functionality in OneFS =E2=80=94 it=E2=80=99s unfortunat= e that we can=E2=80=99t use > a standard compiler to compile OneFS out of the box and instead have to > bootstrap a compiler which is intelligent enough to understand how the > custom format strings work, just to compile user space/a kernel. > Thank you, > -Ngie Ngie, The revert was unjustified and inappropriate, period. You haven't justified it here either. The guide refers to reverting your own commits, not others'. Please stop helping. Conrad From owner-svn-src-head@freebsd.org Thu Dec 22 23:37:19 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DB87BC8D5E2; Thu, 22 Dec 2016 23:37:19 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: from mail-pg0-x243.google.com (mail-pg0-x243.google.com [IPv6:2607:f8b0:400e:c05::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A759219B8; Thu, 22 Dec 2016 23:37:19 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: by mail-pg0-x243.google.com with SMTP id n5so416568pgh.3; Thu, 22 Dec 2016 15:37:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:mime-version:from:in-reply-to:date:cc:message-id:references :to; bh=ouqEHNImw7nCBucUqJc4oNrpb5GmBOHcE+QTSgYW/yg=; b=DHOB7nFWCyScprE1i1AgDJtPeBmScBLQITaqNaSAmWjSOa1plQy6xjfJ7cvhK7jhfA Zlm39MRN9/F4g8WCpd8yszu4L/C9U+d83EA73SdgCNRFbQU5ITtrWqUOTLS/rjdC3Vrf Kh7NHGPuNqOiZl4MtvaKrQUmH7xuatwKdU8YQ4lpsBz2CxfT6IQ/kDArKBx7HnUtdi6Q WSk5JDuUdvbc9/CeYZ5xMbNm18NXAOmZUzvduO4j95NttOCYNC0RjLJ2q0b9BmrBcPGQ eNEatNU+or22M7VCWqHBw1mVBlo5H7xnopjzRCljnw3V/H+56VFbWLLxnYN1P4nA0LpZ U6xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:mime-version:from:in-reply-to:date:cc :message-id:references:to; bh=ouqEHNImw7nCBucUqJc4oNrpb5GmBOHcE+QTSgYW/yg=; b=r5Up91jndGD+pEhanOSWUzOF/dROm2SHBKBcYHT/MEmrlXhu3C/1hFTwwXb1yx6xP1 SyG5tfd+A4SjHs1pEiI5vfEkPB9cHtFTDAQXfhIVF+agcQysZnScU6EaTUuZ2zgSy8gd TuaSnzFg1y7zhBEyK4xHiaWocas9ECMT2lBd3pNbQAtgf+LW5jzM0mjrqAYY6r27BTd4 SSV5YJ+3Z/FJt1j05/3qLlhcUEkJ1eFcuQwscaBcTxPDcVKZPk/eJXtFU07Jz1pc/0Ty YcfCryvoAn+byKSlwsfMkWiE1gi62yle1BjcXMEfekOuRSZUHcQ9GUwRG/P73FRgSXCl +kAA== X-Gm-Message-State: AIkVDXIz9CD/RK4NqORZml/FfrXRnCqH0quWVxnUPRtcJtbVtezPt/RNVVdFjiD09OeZ+w== X-Received: by 10.84.143.162 with SMTP id 31mr24303225plz.2.1482449838934; Thu, 22 Dec 2016 15:37:18 -0800 (PST) Received: from [192.168.20.12] (c-73-19-52-228.hsd1.wa.comcast.net. [73.19.52.228]) by smtp.gmail.com with ESMTPSA id 72sm57252405pfw.37.2016.12.22.15.37.18 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Dec 2016 15:37:18 -0800 (PST) Subject: Re: svn commit: r310433 - head/lib/libc/stdio Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Content-Type: multipart/signed; boundary="Apple-Mail=_C1D28C36-72D4-4C33-943C-6990684F6C35"; protocol="application/pgp-signature"; micalg=pgp-sha512 X-Pgp-Agent: GPGMail From: "Ngie Cooper (yaneurabeya)" In-Reply-To: Date: Thu, 22 Dec 2016 15:37:16 -0800 Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Message-Id: References: <201612222230.uBMMUge9075128@repo.freebsd.org> To: cem@freebsd.org X-Mailer: Apple Mail (2.3124) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 23:37:20 -0000 --Apple-Mail=_C1D28C36-72D4-4C33-943C-6990684F6C35 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii > Ngie, > > The revert was unjustified and inappropriate, period. You haven't > justified it here either. The guide refers to reverting your own > commits, not others'. Please stop helping. Ok. Got it. --Apple-Mail=_C1D28C36-72D4-4C33-943C-6990684F6C35 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iQIcBAEBCgAGBQJYXGOtAAoJEPWDqSZpMIYVW/4P/3bLOWj/zqZCXWyWW4EUVjRQ zWufmWWka84Kw9V7a8nEo5NN2DxJ/RqyYkZ34CH1AERvXoZFePwPx7iyWnG9pmpE STpQCT3mwH2wl+AOMVJKgzIIk8pC+zKQpXAg97raoiiVOuPa+zq1oJC/QRAdtEWZ QahvprZ15rW7PnSiuFf8V75r2zRXny9NuzXEljJvmq6RcLeWRWrHV4E6B0Zv5v1r Arq8/vhGC4vfdySEkzC4fk9OpKSr/o47LaT/yJmfmIc3Pa+pMT86YAqqeeeX54ya zYN5mLSDpOr3TJz88cbs0zumCxCKBRFIPuR4X+t05LIGX/WQw12naVyQqgvr/asN QyMQO58Xva7K4FkWHqznMolNaytvOw7OA1TrsS78nG4IOftyuwxB7k0grNRPusIE AQL/cohkq7no1dtpaNYD6OVBeYU7A6BFYZ3lX1+2fPnftIvlCDetLOKyD7uALPzh XE668739KkfyZCTwMU1uIbqL1Bw+LVnuCo4F43jpBAZYcRX9NDRx3IJFB/Yl6TrP 787l5oc5BE3ipceGf39Jzf8Ccg4DSvNWL5pOgGikTsMbHpJVn8VF5zyCSC4GYVoz LF75BjOnn/Frie6vu84SBQXkrT3aXsAHXWaUZxFtBuD3R6ZiX8qD0xH5nI7+mmUc 0lp2wVivmIMLygF3mMhn =5l7z -----END PGP SIGNATURE----- --Apple-Mail=_C1D28C36-72D4-4C33-943C-6990684F6C35-- From owner-svn-src-head@freebsd.org Thu Dec 22 23:39:13 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 45EE4C8D681; Thu, 22 Dec 2016 23:39:13 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 06A451B60; Thu, 22 Dec 2016 23:39:12 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBMNdClO004706; Thu, 22 Dec 2016 23:39:12 GMT (envelope-from hrs@FreeBSD.org) Received: (from hrs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBMNdCGf004704; Thu, 22 Dec 2016 23:39:12 GMT (envelope-from hrs@FreeBSD.org) Message-Id: <201612222339.uBMNdCGf004704@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hrs set sender to hrs@FreeBSD.org using -f From: Hiroki Sato Date: Thu, 22 Dec 2016 23:39:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310434 - head/usr.bin/logger X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 23:39:13 -0000 Author: hrs Date: Thu Dec 22 23:39:11 2016 New Revision: 310434 URL: https://svnweb.freebsd.org/changeset/base/310434 Log: - Add -S option to specify the source address/port for UDP communication. - Document -S option. - Document that -h option supports AF_LOCAL. - Split preparation of UDP sockets in logmessage() into socksetup(). Modified: head/usr.bin/logger/logger.1 head/usr.bin/logger/logger.c Modified: head/usr.bin/logger/logger.1 ============================================================================== --- head/usr.bin/logger/logger.1 Thu Dec 22 22:30:42 2016 (r310433) +++ head/usr.bin/logger/logger.1 Thu Dec 22 23:39:11 2016 (r310434) @@ -28,7 +28,7 @@ .\" @(#)logger.1 8.1 (Berkeley) 6/6/93 .\" $FreeBSD$ .\" -.Dd March 21, 2015 +.Dd December 23, 2016 .Dt LOGGER 1 .Os .Sh NAME @@ -41,6 +41,7 @@ .Op Fl h Ar host .Op Fl P Ar port .Op Fl p Ar pri +.Op Fl S Ar addr Ns \&: Ns Ar port .Op Fl t Ar tag .Op Ar message ... .Sh DESCRIPTION @@ -80,6 +81,28 @@ This option is ignored when a message is Send the message to the remote system .Ar host instead of logging it locally. +Note that +.Nm +currently supports +.Li AF_INET +.Pq IPv4 , +.Li AF_INET6 +.Pq IPv6 , +and +.Li AF_LOCAL +.Pq Unix-domain socket +address families. +The following address formats are valid in +.Ar host : +.Pp +.Bl -tag -width "AF_LOCAL" -compact +.It Li AF_INET +192.168.2.1 +.It Li AF_INET6 +2001:db8::1 +.It Li AF_LOCAL +.Pa /var/run/log +.El .It Fl P Ar port Send the message to the specified .Ar port @@ -101,6 +124,20 @@ level in the .Ar local3 facility. The default is ``user.notice.'' +.It Fl S Ar addr Ns \&: Ns Ar port +Specify source address and/or source port when using +.Fl h +option. +The same address will be used for all of the remote addresses +when +.Fl A +flag is enabled. +Note that a numeric IPv6 address in +.Ar addr +must be enclosed with +.Qq \&[ +and +.Qq \&] . .It Fl t Ar tag Mark every line in the log with the specified .Ar tag Modified: head/usr.bin/logger/logger.c ============================================================================== --- head/usr.bin/logger/logger.c Thu Dec 22 22:30:42 2016 (r310433) +++ head/usr.bin/logger/logger.c Thu Dec 22 23:39:11 2016 (r310434) @@ -57,18 +57,22 @@ __FBSDID("$FreeBSD$"); #define SYSLOG_NAMES #include +#define sstosa(ss) ((struct sockaddr *)(void *)ss) + +struct socks { + int sk_sock; + int sk_addrlen; + struct sockaddr_storage sk_addr; +}; + static int decode(char *, const CODE *); static int pencode(char *); -static void logmessage(int, const char *, const char *, const char *, +static ssize_t socksetup(const char *, const char *, const char *, + struct socks **); +static void logmessage(int, const char *, struct socks *, ssize_t, const char *); static void usage(void); -struct socks { - int sock; - int addrlen; - struct sockaddr_storage addr; -}; - #ifdef INET6 static int family = PF_UNSPEC; /* protocol family (IPv4, IPv6 or both) */ #else @@ -85,17 +89,20 @@ static int send_to_all = 0; /* send mess int main(int argc, char *argv[]) { + struct socks *socks; + ssize_t nsock; int ch, logflags, pri; char *tag, *host, buf[1024]; - const char *svcname; + const char *svcname, *src; tag = NULL; host = NULL; svcname = "syslog"; + src = NULL; pri = LOG_USER | LOG_NOTICE; logflags = 0; unsetenv("TZ"); - while ((ch = getopt(argc, argv, "46Af:h:iP:p:st:")) != -1) + while ((ch = getopt(argc, argv, "46Af:h:iP:p:S:st:")) != -1) switch((char)ch) { case '4': family = PF_INET; @@ -128,6 +135,9 @@ main(int argc, char *argv[]) case 's': /* log to standard error */ logflags |= LOG_PERROR; break; + case 'S': /* source address */ + src = optarg; + break; case 't': /* tag */ tag = optarg; break; @@ -138,6 +148,16 @@ main(int argc, char *argv[]) argc -= optind; argv += optind; + if (host) { + nsock = socksetup(src, host, svcname, &socks); + if (nsock <= 0) + errx(1, "socket"); + } else { + if (src) + errx(1, "-h option is missing."); + nsock = 0; + } + if (tag == NULL) tag = getlogin(); /* setup for logging */ @@ -153,11 +173,11 @@ main(int argc, char *argv[]) for (p = buf, endp = buf + sizeof(buf) - 2; *argv;) { len = strlen(*argv); if (p + len > endp && p > buf) { - logmessage(pri, tag, host, svcname, buf); + logmessage(pri, tag, socks, nsock, buf); p = buf; } if (len > sizeof(buf) - 1) - logmessage(pri, tag, host, svcname, *argv++); + logmessage(pri, tag, socks, nsock, *argv++); else { if (p != buf) *p++ = ' '; @@ -166,78 +186,162 @@ main(int argc, char *argv[]) } } if (p != buf) - logmessage(pri, tag, host, svcname, buf); + logmessage(pri, tag, socks, nsock, buf); } else while (fgets(buf, sizeof(buf), stdin) != NULL) - logmessage(pri, tag, host, svcname, buf); + logmessage(pri, tag, socks, nsock, buf); exit(0); } +static ssize_t +socksetup(const char *src, const char *dst, const char *svcname, + struct socks **socks) +{ + struct addrinfo hints, *res, *res0; + struct sockaddr_storage *ss_src[AF_MAX]; + struct socks *sk; + ssize_t nsock = 0; + int error, maxs; + + memset(&ss_src[0], 0, sizeof(ss_src)); + if (src) { + char *p, *p0, *hs, *hbuf, *sbuf; + + hbuf = sbuf = NULL; + p0 = p = strdup(src); + if (p0 == NULL) + err(1, "strdup failed"); + hs = p0; /* point to search ":" */ +#ifdef INET6 + /* -S option supports IPv6 addr in "[2001:db8::1]:service". */ + if (*p0 == '[') { + p = strchr(p0, ']'); + if (p == NULL) + errx(1, "\"]\" not found in src addr"); + *p = '\0'; + /* hs points just after ']' (':' or '\0'). */ + hs = p + 1; + /* + * p points just after '[' while it points hs + * in the case of []. + */ + p = ((p0 + 1) == (hs - 1)) ? hs : p0 + 1; + } +#endif + if (*p != '\0') { + /* (p == hs) means ":514" or "[]:514". */ + hbuf = (p == hs && *p == ':') ? NULL : p; + p = strchr(hs, ':'); + if (p != NULL) { + *p = '\0'; + sbuf = (*(p + 1) != '\0') ? p + 1 : NULL; + } + } + hints = (struct addrinfo){ + .ai_family = family, + .ai_socktype = SOCK_DGRAM, + .ai_flags = AI_PASSIVE + }; + error = getaddrinfo(hbuf, sbuf, &hints, &res0); + if (error) + errx(1, "%s: %s", gai_strerror(error), src); + for (res = res0; res; res = res->ai_next) { + switch (res->ai_family) { + case AF_INET: +#ifdef INET6 + case AF_INET6: +#endif + if (ss_src[res->ai_family] != NULL) + continue; + ss_src[res->ai_family] = + malloc(sizeof(struct sockaddr_storage)); + if (ss_src[res->ai_family] == NULL) + err(1, "malloc failed"); + memcpy(ss_src[res->ai_family], res->ai_addr, + res->ai_addrlen); + } + } + freeaddrinfo(res0); + free(p0); + } + + /* resolve hostname */ + hints = (struct addrinfo){ + .ai_family = family, + .ai_socktype = SOCK_DGRAM + }; + error = getaddrinfo(dst, svcname, &hints, &res0); + if (error == EAI_SERVICE) { + warnx("%s/udp: unknown service", svcname); + error = getaddrinfo(dst, "514", &hints, &res); + } + if (error) + errx(1, "%s: %s", gai_strerror(error), dst); + /* count max number of sockets we may open */ + maxs = 0; + for (res = res0; res; res = res->ai_next) + maxs++; + sk = calloc(maxs, sizeof(*sk)); + if (sk == NULL) + errx(1, "couldn't allocate memory for sockets"); + for (res = res0; res; res = res->ai_next) { + int s; + + s = socket(res->ai_family, res->ai_socktype, + res->ai_protocol); + if (s < 0) + continue; + if (src && ss_src[res->ai_family] == NULL) + errx(1, "address family mismatch"); + + if (ss_src[res->ai_family]) { + error = bind(s, sstosa(ss_src[res->ai_family]), + ss_src[res->ai_family]->ss_len); + if (error < 0) + err(1, "bind"); + } + sk[nsock] = (struct socks){ + .sk_addrlen = res->ai_addrlen, + .sk_sock = s + }; + memcpy(&sk[nsock].sk_addr, res->ai_addr, res->ai_addrlen); + nsock++; + } + freeaddrinfo(res0); + + *socks = sk; + return (nsock); +} + /* * Send the message to syslog, either on the local host, or on a remote host */ static void -logmessage(int pri, const char *tag, const char *host, const char *svcname, - const char *buf) +logmessage(int pri, const char *tag, struct socks *sk, ssize_t nsock, + const char *buf) { - static struct socks *socks; - static int nsock = 0; - struct addrinfo hints, *res, *r; char *line; - int maxs, len, sock, error, i, lsent; + int len, i, lsent; - if (host == NULL) { + if (nsock == 0) { syslog(pri, "%s", buf); return; } - - if (nsock <= 0) { /* set up socket stuff */ - /* resolve hostname */ - memset(&hints, 0, sizeof(hints)); - hints.ai_family = family; - hints.ai_socktype = SOCK_DGRAM; - error = getaddrinfo(host, svcname, &hints, &res); - if (error == EAI_SERVICE) { - warnx("%s/udp: unknown service", svcname); - error = getaddrinfo(host, "514", &hints, &res); - } - if (error) - errx(1, "%s: %s", gai_strerror(error), host); - /* count max number of sockets we may open */ - for (maxs = 0, r = res; r; r = r->ai_next, maxs++); - socks = malloc(maxs * sizeof(struct socks)); - if (!socks) - errx(1, "couldn't allocate memory for sockets"); - for (r = res; r; r = r->ai_next) { - sock = socket(r->ai_family, r->ai_socktype, - r->ai_protocol); - if (sock < 0) - continue; - memcpy(&socks[nsock].addr, r->ai_addr, r->ai_addrlen); - socks[nsock].addrlen = r->ai_addrlen; - socks[nsock++].sock = sock; - } - freeaddrinfo(res); - if (nsock <= 0) - errx(1, "socket"); - } - if ((len = asprintf(&line, "<%d>%s: %s", pri, tag, buf)) == -1) errx(1, "asprintf"); lsent = -1; - for (i = 0; i < nsock; ++i) { - lsent = sendto(socks[i].sock, line, len, 0, - (struct sockaddr *)&socks[i].addr, - socks[i].addrlen); + for (i = 0; i < nsock; i++) { + lsent = sendto(sk[i].sk_sock, line, len, 0, + sstosa(&sk[i].sk_addr), sk[i].sk_addrlen); if (lsent == len && !send_to_all) break; } if (lsent != len) { if (lsent == -1) - warn ("sendto"); + warn("sendto"); else - warnx ("sendto: short send - %d bytes", lsent); + warnx("sendto: short send - %d bytes", lsent); } free(line); @@ -290,7 +394,7 @@ usage(void) { (void)fprintf(stderr, "usage: %s\n", "logger [-46Ais] [-f file] [-h host] [-P port] [-p pri] [-t tag]\n" - " [message ...]" + " [-S addr:port] [message ...]" ); exit(1); } From owner-svn-src-head@freebsd.org Thu Dec 22 23:59:55 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F260CC8DDBF; Thu, 22 Dec 2016 23:59:54 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 A2A30AB6; Thu, 22 Dec 2016 23:59:54 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBMNxrvb013288; Thu, 22 Dec 2016 23:59:53 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBMNxrh0013287; Thu, 22 Dec 2016 23:59:53 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201612222359.uBMNxrh0013287@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Thu, 22 Dec 2016 23:59:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310435 - head/sys/net80211 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 22 Dec 2016 23:59:55 -0000 Author: adrian Date: Thu Dec 22 23:59:53 2016 New Revision: 310435 URL: https://svnweb.freebsd.org/changeset/base/310435 Log: [net80211] WEP offload support. Yes, the ath10k NIC actually also does do WEP TX/RX offload. Tested: * ath10k driver port, WEP STA mode. Modified: head/sys/net80211/ieee80211_crypto_wep.c Modified: head/sys/net80211/ieee80211_crypto_wep.c ============================================================================== --- head/sys/net80211/ieee80211_crypto_wep.c Thu Dec 22 23:39:11 2016 (r310434) +++ head/sys/net80211/ieee80211_crypto_wep.c Thu Dec 22 23:59:53 2016 (r310435) @@ -180,10 +180,22 @@ wep_encap(struct ieee80211_key *k, struc { struct wep_ctx *ctx = k->wk_private; struct ieee80211com *ic = ctx->wc_ic; + struct ieee80211_frame *wh; uint8_t *ivp; int hdrlen; + int is_mgmt; hdrlen = ieee80211_hdrspace(ic, mtod(m, void *)); + wh = mtod(m, struct ieee80211_frame *); + is_mgmt = IEEE80211_IS_MGMT(wh); + + /* + * Check to see if IV is required. + */ + if (is_mgmt && (k->wk_flags & IEEE80211_KEY_NOIVMGT)) + return 1; + if ((! is_mgmt) && (k->wk_flags & IEEE80211_KEY_NOIV)) + return 1; /* * Copy down 802.11 header and add the IV + KeyID. @@ -228,9 +240,15 @@ wep_decap(struct ieee80211_key *k, struc struct wep_ctx *ctx = k->wk_private; struct ieee80211vap *vap = ctx->wc_vap; struct ieee80211_frame *wh; + const struct ieee80211_rx_stats *rxs; wh = mtod(m, struct ieee80211_frame *); + rxs = ieee80211_get_rx_params_ptr(m); + + if ((rxs != NULL) && (rxs->c_pktflags & IEEE80211_RX_F_IV_STRIP)) + goto finish; + /* * Check if the device handled the decrypt in hardware. * If so we just strip the header; otherwise we need to @@ -249,6 +267,9 @@ wep_decap(struct ieee80211_key *k, struc */ ovbcopy(mtod(m, void *), mtod(m, uint8_t *) + wep.ic_header, hdrlen); m_adj(m, wep.ic_header); + +finish: + /* XXX TODO: do we have to strip this for offload devices? */ m_adj(m, -wep.ic_trailer); return 1; From owner-svn-src-head@freebsd.org Fri Dec 23 00:05:14 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 84A57C8B058 for ; Fri, 23 Dec 2016 00:05:14 +0000 (UTC) (envelope-from mailing-machine@vniz.net) Received: from mail-lf0-f66.google.com (mail-lf0-f66.google.com [209.85.215.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 178D2103D for ; Fri, 23 Dec 2016 00:05:13 +0000 (UTC) (envelope-from mailing-machine@vniz.net) Received: by mail-lf0-f66.google.com with SMTP id t196so1405761lff.3 for ; Thu, 22 Dec 2016 16:05:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=uCvqWoD+F0lkfVLjtRrrGW05TVbuaf6p2UDwhJdSnJQ=; b=pkf9JJD7mHGbNwuHssdAhQTJJT+uZK3dlDZsmmaZgpAIc1qbCMjFR1jSxcErUpTeXU hhHKmoLIDgF9gipX6WPH2KZ9unUYSEyrgCK4dfY2+1AO4Y6ttqZMa7KNj2iaThQgEcDu ++KsYs5k+D3Y/HpT6cm3wmMnXVfKF/G8rkJkRDdkox8k+9FArnVxEQROI/cRkrGIS+A4 IoAZ+xGoXqLUOdg48fwqM0IGY7zKIgm/6eyado77mUs5dv+WtJ7+ufdQShrSpbgfyPba aFMKMUzrdiwBXvojv3QB+FlyTRKWsWeQX87ngEkMioVUbC3EzEn7dSWBcfcZIX1JUFyj 3m0A== X-Gm-Message-State: AIkVDXL0WNDHF69D6JtYLHpWSaVfvPvX5gsRqK19PgF9pwmM6u8N+7IAws59klap4ATxNw== X-Received: by 10.46.74.10 with SMTP id x10mr5195152lja.8.1482451505724; Thu, 22 Dec 2016 16:05:05 -0800 (PST) Received: from [192.168.1.2] ([89.169.173.68]) by smtp.gmail.com with ESMTPSA id p9sm556125lfd.49.2016.12.22.16.05.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Dec 2016 16:05:05 -0800 (PST) Subject: Re: svn commit: r310433 - head/lib/libc/stdio To: cem@freebsd.org, Ngie Cooper References: <201612222230.uBMMUge9075128@repo.freebsd.org> Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org From: Andrey Chernov Message-ID: Date: Fri, 23 Dec 2016 03:05:04 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Fri, 23 Dec 2016 00:05:14 -0000 On 23.12.2016 1:39, Conrad Meyer wrote: > This was unjustified and inappropriate. I don't think so. While being able to back it out or fix it by another way by yourself, you just doing nothing for several days. Your personal reasons of inability to act properly so long time weights less than project consistency at whole, so backing it out from anybody is justified and appropriate in such situations. > On Thu, Dec 22, 2016 at 2:30 PM, Ngie Cooper wrote: >> Author: ngie >> Date: Thu Dec 22 22:30:42 2016 >> New Revision: 310433 >> URL: https://svnweb.freebsd.org/changeset/base/310433 >> >> Log: >> Revert r310138 >> >> Adding %b support to vfprintf for parity with kernel space requires >> more discussion/review. >> >> In particular, many parties were concerned over introducing a >> non-standard format qualifier to *printf(3) which didn't already >> exist in other OSes, e.g. Linux, thus making code which used %b >> harder to port to other operating systems. >> >> Requested by: many >> >> Modified: >> head/lib/libc/stdio/vfprintf.c >> >> Modified: head/lib/libc/stdio/vfprintf.c >> ============================================================================== >> --- head/lib/libc/stdio/vfprintf.c Thu Dec 22 21:56:41 2016 (r310432) >> +++ head/lib/libc/stdio/vfprintf.c Thu Dec 22 22:30:42 2016 (r310433) >> @@ -611,37 +611,6 @@ reswitch: switch (ch) { >> case 'z': >> flags |= SIZET; >> goto rflag; >> - case 'b': >> - { >> - const char *q; >> - int anybitset, bit; >> - >> - ulval = (u_int)GETARG(int); >> - cp = GETARG(char *); >> - >> - q = __ultoa(ulval, buf + BUF, *cp++, 0, xdigs_lower); >> - PRINT(q, buf + BUF - q); >> - >> - if (ulval == 0) >> - break; >> - >> - for (anybitset = 0; *cp;) { >> - bit = *cp++; >> - if (ulval & (1 << (bit - 1))) { >> - PRINT(anybitset ? "," : "<", 1); >> - q = cp; >> - for (; (bit = *cp) > ' '; ++cp) >> - continue; >> - PRINT(q, cp - q); >> - anybitset = 1; >> - } else >> - for (; *cp > ' '; ++cp) >> - continue; >> - } >> - if (anybitset) >> - PRINT(">", 1); >> - } >> - continue; >> case 'C': >> flags |= LONGINT; >> /*FALLTHROUGH*/ >> > From owner-svn-src-head@freebsd.org Fri Dec 23 01:18:37 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B3867C8C403; Fri, 23 Dec 2016 01:18:37 +0000 (UTC) (envelope-from hiren@strugglingcoder.info) Received: from mail.strugglingcoder.info (strugglingcoder.info [104.236.146.68]) by mx1.freebsd.org (Postfix) with ESMTP id A3DBD10EC; Fri, 23 Dec 2016 01:18:37 +0000 (UTC) (envelope-from hiren@strugglingcoder.info) Received: from localhost (unknown [10.1.1.3]) (Authenticated sender: hiren@strugglingcoder.info) by mail.strugglingcoder.info (Postfix) with ESMTPA id B64BF17A00; Thu, 22 Dec 2016 17:18:31 -0800 (PST) Date: Thu, 22 Dec 2016 17:18:31 -0800 From: hiren panchasara To: Andrey Chernov Cc: cem@freebsd.org, Ngie Cooper , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r310433 - head/lib/libc/stdio Message-ID: <20161223011831.GI82166@strugglingcoder.info> References: <201612222230.uBMMUge9075128@repo.freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="dYuLH7fbMjVsPkFl" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Fri, 23 Dec 2016 01:18:37 -0000 --dYuLH7fbMjVsPkFl Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 12/23/16 at 03:05P, Andrey Chernov wrote: > On 23.12.2016 1:39, Conrad Meyer wrote: > > This was unjustified and inappropriate. >=20 > I don't think so. While being able to back it out or fix it by another > way by yourself, you just doing nothing for several days. Your personal > reasons of inability to act properly so long time weights less than > project consistency at whole, so backing it out from anybody is > justified and appropriate in such situations. Conrad, As Andrey rightly said, you didn't respond to all raised concerns neither did you revert your commit (which was the majority vote anyways). So I'd say, it is totally justified and appropriate. Cheers, Hiren --dYuLH7fbMjVsPkFl Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQF8BAABCgBmBQJYXHtkXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXRBNEUyMEZBMUQ4Nzg4RjNGMTdFNjZGMDI4 QjkyNTBFMTU2M0VERkU1AAoJEIuSUOFWPt/lpccH/3vo2cFoLe0r3e7P746ns8oR U2eHFsnjJguaCeUQ9Q9se9SlNDP5wxCGZBAjMyp0SN33zkLd3339h1SjSUeI+V34 XkXrh0ZzvEhbh9+rDJGfk4v7oHZo18Cwc9DQi+RRybAhEnAt3FTuTbPO4klwSJri UXKB4NPGS9AGyhaPEImRvGAApiJMzqVyTr+LUajQtH1vTpGQu8Tx4jmg3O5GHCoP 5Co/VZWsUvcHhlvmRQnTUeQJT76VpU1m+kYI621Bcj+tzTQsOQR7sjQTToFnPZBW rUr6oidrd6FbG2y0Cmte1JhapuRzqWNvoHlSGJEIwhgUOxVa0XMFp6ARC+7EGFI= =fZ4z -----END PGP SIGNATURE----- --dYuLH7fbMjVsPkFl-- From owner-svn-src-head@freebsd.org Fri Dec 23 02:57:01 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C9088C8DCB8; Fri, 23 Dec 2016 02:57:01 +0000 (UTC) (envelope-from sjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 97AAC1B6A; Fri, 23 Dec 2016 02:57:01 +0000 (UTC) (envelope-from sjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBN2v0po085650; Fri, 23 Dec 2016 02:57:00 GMT (envelope-from sjg@FreeBSD.org) Received: (from sjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBN2v0tO085644; Fri, 23 Dec 2016 02:57:00 GMT (envelope-from sjg@FreeBSD.org) Message-Id: <201612230257.uBN2v0tO085644@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sjg set sender to sjg@FreeBSD.org using -f From: "Simon J. Gerraty" Date: Fri, 23 Dec 2016 02:57:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310437 - head/share/mk X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Fri, 23 Dec 2016 02:57:01 -0000 Author: sjg Date: Fri Dec 23 02:57:00 2016 New Revision: 310437 URL: https://svnweb.freebsd.org/changeset/base/310437 Log: Update meta* from bmake-20161212 Modified: head/share/mk/dirdeps.mk head/share/mk/gendirdeps.mk head/share/mk/meta.stage.mk head/share/mk/meta2deps.py head/share/mk/meta2deps.sh Modified: head/share/mk/dirdeps.mk ============================================================================== --- head/share/mk/dirdeps.mk Fri Dec 23 00:38:43 2016 (r310436) +++ head/share/mk/dirdeps.mk Fri Dec 23 02:57:00 2016 (r310437) @@ -1,5 +1,5 @@ # $FreeBSD$ -# $Id: dirdeps.mk,v 1.73 2016/08/15 19:28:13 sjg Exp $ +# $Id: dirdeps.mk,v 1.84 2016/11/27 02:44:34 sjg Exp $ # Copyright (c) 2010-2013, Juniper Networks, Inc. # All rights reserved. @@ -57,9 +57,12 @@ # .MAKE.DEPENDFILE_PREFIX) to refer to these makefiles to # distinguish them from others. # -# Each Makefile.depend file sets DEP_RELDIR to be the -# the RELDIR (path relative to SRCTOP) for its directory, and -# since each Makefile.depend file includes dirdeps.mk, this +# Before each Makefile.depend file is read, we set +# DEP_RELDIR to be the the RELDIR (path relative to SRCTOP) for +# its directory, and DEP_MACHINE etc according to the . +# represented by the suffix of the corresponding target. +# +# Since each Makefile.depend file includes dirdeps.mk, this # processing is recursive and results in .MAKE.LEVEL 0 learning the # dependencies of the tree wrt the initial directory (_DEP_RELDIR). # @@ -111,6 +114,29 @@ # # as we may need it to find Makefile.depend* # TARGET_SPEC = ${TARGET_SPEC_VARS:@v@${$v:U}@:ts,} # +# The following variables can influence the initial DIRDEPS +# computation with regard to the TARGET_SPECs that will be +# built. +# Most should also be considered by init.mk +# +# ONLY_TARGET_SPEC_LIST +# Defines a list of TARGET_SPECs for which the current +# directory can be built. +# If ALL_MACHINES is defined, we build for all the +# TARGET_SPECs listed. +# +# ONLY_MACHINE_LIST +# As for ONLY_TARGET_SPEC_LIST but only specifies +# MACHINEs. +# +# NOT_TARGET_SPEC_LIST +# A list of TARGET_SPECs for which the current +# directory should not be built. +# +# NOT_MACHINE_LIST +# A list of MACHINEs the current directory should not be +# built for. +# # touch this at your peril _DIRDEP_USE_LEVEL?= 0 @@ -172,9 +198,13 @@ DEP_$v ?= ${$v} # we compute below are fully qualified wrt DEP_TARGET_SPEC. # The makefiles may only partially specify (eg. MACHINE only), # so we need to construct a set of modifiers to fill in the gaps. -# jot 10 should output 1 2 3 .. 10 -JOT ?= jot -_tspec_x := ${${JOT} ${TARGET_SPEC_VARS:[#]}:L:sh} +.if ${TARGET_SPEC_VARS:[#]} > 10 +# seriously? better have jot(1) or equivalent to produce suitable sequence +_tspec_x := ${${JOT:Ujot} ${TARGET_SPEC_VARS:[#]}:L:sh} +.else +# we can provide the sequence ourselves +_tspec_x := ${1 2 3 4 5 6 7 8 9 10:L:[1..${TARGET_SPEC_VARS:[#]}]} +.endif # this handles unqualified entries M_dep_qual_fixes = C;(/[^/.,]+)$$;\1.$${DEP_TARGET_SPEC}; # there needs to be at least one item missing for these to make sense @@ -288,6 +318,18 @@ _DEP_RELDIR := ${DEP_RELDIR} .endif +# DIRDEPS_CACHE can be very handy for debugging. +# Also if repeatedly building the same target, +# we can avoid the overhead of re-computing the tree dependencies. +MK_DIRDEPS_CACHE ?= no +BUILD_DIRDEPS_CACHE ?= no +BUILD_DIRDEPS ?= yes + +.if ${MK_DIRDEPS_CACHE} == "yes" +# this is where we will cache all our work +DIRDEPS_CACHE ?= ${_OBJDIR:tA}/dirdeps.cache${.TARGETS:Nall:O:u:ts-:S,/,_,g:S,^,.,:N.} +.endif + # pickup customizations # as below you can use !target(_DIRDEP_USE) to protect things # which should only be done once. @@ -306,8 +348,10 @@ SKIP_DIR.host += ${SKIP_HOSTDIR} DEP_SKIP_DIR = ${SKIP_DIR} \ ${SKIP_DIR.${DEP_TARGET_SPEC}:U} \ - ${SKIP_DIR.${DEP_MACHINE}:U} \ - ${SKIP_DIRDEPS.${DEP_MACHINE}:U} + ${TARGET_SPEC_VARS:@v@${SKIP_DIR.${DEP_$v}:U}@} \ + ${SKIP_DIRDEPS.${DEP_TARGET_SPEC}:U} \ + ${TARGET_SPEC_VARS:@v@${SKIP_DIRDEPS.${DEP_$v}:U}@} + NSkipDir = ${DEP_SKIP_DIR:${M_ListToSkip}} @@ -345,7 +389,7 @@ _DIRDEP_USE: .USE .MAKE .ifdef ALL_MACHINES # this is how you limit it to only the machines we have been built for # previously. -.if empty(ONLY_MACHINE_LIST) +.if empty(ONLY_TARGET_SPEC_LIST) && empty(ONLY_MACHINE_LIST) .if !empty(ALL_MACHINE_LIST) # ALL_MACHINE_LIST is the list of all legal machines - ignore anything else _machine_list != cd ${_CURDIR} && 'ls' -1 ${ALL_MACHINE_LIST:O:u:@m@${.MAKE.DEPENDFILE:T:R}.$m@} 2> /dev/null; echo @@ -354,7 +398,7 @@ _machine_list != 'ls' -1 ${_CURDIR}/${.M .endif _only_machines := ${_machine_list:${NIgnoreFiles:UN*.bak}:E:O:u} .else -_only_machines := ${ONLY_MACHINE_LIST} +_only_machines := ${ONLY_TARGET_SPEC_LIST:U} ${ONLY_MACHINE_LIST:U} .endif .if empty(_only_machines) @@ -363,30 +407,35 @@ _only_machines := ${TARGET_MACHINE:U${AL .endif .else # ! ALL_MACHINES -# if ONLY_MACHINE_LIST is set, we are limited to that +# if ONLY_TARGET_SPEC_LIST or ONLY_MACHINE_LIST is set, we are limited to that. +# Note that ONLY_TARGET_SPEC_LIST should be fully qualified. # if TARGET_MACHINE is set - it is really the same as ONLY_MACHINE_LIST # otherwise DEP_MACHINE is it - so DEP_MACHINE will match. +_only_machines := ${ONLY_TARGET_SPEC_LIST:U:M${DEP_MACHINE},*} +.if empty(_only_machines) _only_machines := ${ONLY_MACHINE_LIST:U${TARGET_MACHINE:U${DEP_MACHINE}}:M${DEP_MACHINE}} .endif +.endif .if !empty(NOT_MACHINE_LIST) _only_machines := ${_only_machines:${NOT_MACHINE_LIST:${M_ListToSkip}}} .endif +.if !empty(NOT_TARGET_SPEC_LIST) +# we must first qualify +_dm := ${DEP_MACHINE} +_only_machines := ${_only_machines:M*,*} ${_only_machines:N*,*:@DEP_MACHINE@${DEP_TARGET_SPEC}@:S,^,.,:${M_dep_qual_fixes:ts:}:O:u:S,^.,,} +DEP_MACHINE := ${_dm} +_only_machines := ${_only_machines:${NOT_TARGET_SPEC_LIST:${M_ListToSkip}}} +.endif +# clean up +_only_machines := ${_only_machines:O:u} # make sure we have a starting place? DIRDEPS ?= ${RELDIR} .endif # target -# if repeatedly building the same target, -# we can avoid the overhead of re-computing the tree dependencies. -MK_DIRDEPS_CACHE ?= no -BUILD_DIRDEPS_CACHE ?= no -BUILD_DIRDEPS ?= yes - .if !defined(NO_DIRDEPS) && !defined(NO_DIRDEPS_BELOW) .if ${MK_DIRDEPS_CACHE} == "yes" -# this is where we will cache all our work -DIRDEPS_CACHE?= ${_OBJDIR:tA}/dirdeps.cache${.TARGETS:Nall:O:u:ts-:S,/,_,g:S,^,.,:N.} # just ensure this exists build-dirdeps: @@ -421,6 +470,7 @@ ${DIRDEPS_CACHE}: .META .NOMETA_CMP } > ${.TARGET}.new +@MAKELEVEL=${.MAKE.LEVEL} DIRDEPS_CACHE=${DIRDEPS_CACHE} \ DIRDEPS="${DIRDEPS}" \ + TARGET_SPEC=${TARGET_SPEC} \ MAKEFLAGS= ${.MAKE} -C ${_CURDIR} -f ${BUILD_DIRDEPS_MAKEFILE} \ ${BUILD_DIRDEPS_TARGETS} BUILD_DIRDEPS_CACHE=yes \ .MAKE.DEPENDFILE=.none \ @@ -490,8 +540,10 @@ _machines := ${_machines:O:u} _dm := ${DEP_MACHINE} # apply the same filtering that we do when qualifying DIRDEPS. # M_dep_qual_fixes expects .${MACHINE}* so add (and remove) '.' -_machines := ${_machines:@DEP_MACHINE@${DEP_TARGET_SPEC}@:S,^,.,:${M_dep_qual_fixes:ts:}:O:u:S,^.,,} +# Again we expect that any already qualified machines are fully qualified. +_machines := ${_machines:M*,*} ${_machines:N*,*:@DEP_MACHINE@${DEP_TARGET_SPEC}@:S,^,.,:${M_dep_qual_fixes:ts:}:O:u:S,^.,,} DEP_MACHINE := ${_dm} +_machines := ${_machines:O:u} .endif # reset each time through @@ -523,7 +575,7 @@ _build_dirs += ${_machines:N${DEP_TARGET # these we reset each time through as they can depend on DEP_MACHINE DEP_DIRDEPS_FILTER = \ ${DIRDEPS_FILTER.${DEP_TARGET_SPEC}:U} \ - ${DIRDEPS_FILTER.${DEP_MACHINE}:U} \ + ${TARGET_SPEC_VARS:@v@${DIRDEPS_FILTER.${DEP_$v}:U}@} \ ${DIRDEPS_FILTER:U} .if empty(DEP_DIRDEPS_FILTER) # something harmless @@ -622,6 +674,19 @@ _dirdeps_checked.$d: .endif # Note: _build_all_dirs is fully qualifed so d:R is always the directory .if exists(${d:R}) +# we pass _DEP_TARGET_SPEC to tell the next step what we want +_DEP_TARGET_SPEC := ${d:E} +# some makefiles may still look at this +_DEP_MACHINE := ${d:E:C/,.*//} +# set these too in case Makefile.depend* uses them +.if ${TARGET_SPEC_VARS:[#]} > 1 +_dtspec := ${_DEP_TARGET_SPEC:S/,/ /g} +.for i in ${_tspec_x} +DEP_${TARGET_SPEC_VARS:[$i]} := ${_dtspec:[$i]} +.endfor +.else +DEP_MACHINE := ${_DEP_MACHINE} +.endif # Warning: there is an assumption here that MACHINE is always # the first entry in TARGET_SPEC_VARS. # If TARGET_SPEC and MACHINE are insufficient, you have a problem. @@ -632,10 +697,6 @@ _qm := ${_m:C;(\.depend)$;\1.${d:E};:${M .if ${_debug_search} .info Looking for ${_qm} .endif -# we pass _DEP_TARGET_SPEC to tell the next step what we want -_DEP_TARGET_SPEC := ${d:E} -# some makefiles may still look at this -_DEP_MACHINE := ${d:E:C/,.*//} # set this "just in case" # we can skip :tA since we computed the path above DEP_RELDIR := ${_m:H:S,${SRCTOP}/,,} @@ -688,7 +749,7 @@ _src != cd ${.CURDIR} && for m in ${.MAK _src?= ${.MAKE.DEPENDFILE} -.MAKE.DEPENDFILE_BOOTSTRAP_SED+= -e 's,${_src:E},${MACHINE},g' +.MAKE.DEPENDFILE_BOOTSTRAP_SED+= -e 's/${_src:E:C/,.*//}/${MACHINE}/g' # just create Makefile.depend* for this dir bootstrap-this: .NOTMAIN Modified: head/share/mk/gendirdeps.mk ============================================================================== --- head/share/mk/gendirdeps.mk Fri Dec 23 00:38:43 2016 (r310436) +++ head/share/mk/gendirdeps.mk Fri Dec 23 02:57:00 2016 (r310437) @@ -1,5 +1,5 @@ # $FreeBSD$ -# $Id: gendirdeps.mk,v 1.30 2016/02/27 00:20:39 sjg Exp $ +# $Id: gendirdeps.mk,v 1.33 2016/10/11 22:37:28 sjg Exp $ # Copyright (c) 2010-2013, Juniper Networks, Inc. # All rights reserved. @@ -147,6 +147,9 @@ M2D_OBJROOTS += ${OBJTOP} ${_OBJROOT} ${ .if defined(SB_OBJROOT) M2D_OBJROOTS += ${SB_OBJROOT} .endif +.if defined(STAGE_ROOT) +M2D_OBJROOTS += ${STAGE_ROOT} +.endif .if ${.MAKE.DEPENDFILE_PREFERENCE:U${.MAKE.DEPENDFILE}:M*.${MACHINE}} == "" # meta2deps.py only groks objroot # so we need to give it what it expects Modified: head/share/mk/meta.stage.mk ============================================================================== --- head/share/mk/meta.stage.mk Fri Dec 23 00:38:43 2016 (r310436) +++ head/share/mk/meta.stage.mk Fri Dec 23 02:57:00 2016 (r310437) @@ -1,5 +1,5 @@ # $FreeBSD$ -# $Id: meta.stage.mk,v 1.45 2016/05/26 03:59:09 sjg Exp $ +# $Id: meta.stage.mk,v 1.47 2016/12/07 23:07:49 sjg Exp $ # # @(#) Copyright (c) 2011, Simon J. Gerraty # @@ -59,7 +59,7 @@ GENDIRDEPS_FILTER += Nnot-empty-is-impor LN_CP_SCRIPT = LnCp() { \ rm -f $$2 2> /dev/null; \ - { [ -z "$$mode" ] && ln $$1 $$2 2> /dev/null; } || \ + { [ -z "$$mode" ] && ${LN:Uln} $$1 $$2 2> /dev/null; } || \ cp -p $$1 $$2; } # a staging conflict should cause an error @@ -220,19 +220,29 @@ stage_symlinks: .dirdep .if !empty(STAGE_AS_SETS) CLEANFILES += ${STAGE_AS_SETS:@s@stage*$s@} -STAGE_TARGETS += stage_as +STAGE_TARGETS += stage_as stage_as_and_symlink # sometimes things need to be renamed as they are staged # each ${file} will be staged as ${STAGE_AS_${file:T}} # one could achieve the same with SYMLINKS +# stage_as_and_symlink makes the original name a symlink to the new name +# it is the same as using stage_as and stage_symlinks but ensures +# both operations happen together .for s in ${STAGE_AS_SETS:O:u} STAGE_AS.$s ?= ${.ALLSRC:N.dirdep:Nstage_*} +STAGE_AS_AND_SYMLINK.$s ?= ${.ALLSRC:N.dirdep:Nstage_*} stage_as: stage_as.$s stage_as.$s: .dirdep @${STAGE_AS_SCRIPT}; StageAs ${FLAGS.$@} ${STAGE_FILES_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_AS.$s:@f@$f ${STAGE_AS_${f:tA}:U${STAGE_AS_${f:T}:U${f:T}}}@} @touch $@ +stage_as_and_symlink: stage_as_and_symlink.$s +stage_as_and_symlink.$s: .dirdep + @${STAGE_AS_SCRIPT}; StageAs ${FLAGS.$@} ${STAGE_FILES_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_AS_AND_SYMLINK.$s:@f@$f ${STAGE_AS_${f:tA}:U${STAGE_AS_${f:T}:U${f:T}}}@} + @${STAGE_LINKS_SCRIPT}; StageLinks -s ${STAGE_FILES_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_AS_AND_SYMLINK.$s:@f@${STAGE_AS_${f:tA}:U${STAGE_AS_${f:T}:U${f:T}}} $f@} + @touch $@ + .endfor .endif Modified: head/share/mk/meta2deps.py ============================================================================== --- head/share/mk/meta2deps.py Fri Dec 23 00:38:43 2016 (r310436) +++ head/share/mk/meta2deps.py Fri Dec 23 02:57:00 2016 (r310437) @@ -1,4 +1,3 @@ -# $FreeBSD$ #!/usr/bin/env python from __future__ import print_function @@ -38,7 +37,8 @@ We only pay attention to a subset of the """ RCSid: - $Id: meta2deps.py,v 1.19 2016/04/02 20:45:40 sjg Exp $ + $FreeBSD$ + $Id: meta2deps.py,v 1.22 2016/12/12 19:07:42 sjg Exp $ Copyright (c) 2011-2013, Juniper Networks, Inc. All rights reserved. @@ -114,7 +114,7 @@ def abspath(path, cwd, last_dir=None, de if rpath: path = rpath if (path.find('/') < 0 or - path.find('./') > 0 or + path.find('./') > 0 or path.endswith('/..') or os.path.islink(path)): return os.path.realpath(path) @@ -154,38 +154,38 @@ class MetaFile: """if name is set we will parse it now. conf can have the follwing keys: - SRCTOPS list of tops of the src tree(s). + SRCTOPS list of tops of the src tree(s). - CURDIR the src directory 'bmake' was run from. + CURDIR the src directory 'bmake' was run from. - RELDIR the relative path from SRCTOP to CURDIR + RELDIR the relative path from SRCTOP to CURDIR - MACHINE the machine we built for. - set to 'none' if we are not cross-building. - More specifically if machine cannot be deduced from objdirs. + MACHINE the machine we built for. + set to 'none' if we are not cross-building. + More specifically if machine cannot be deduced from objdirs. TARGET_SPEC - Sometimes MACHINE isn't enough. + Sometimes MACHINE isn't enough. HOST_TARGET - when we build for the pseudo machine 'host' - the object tree uses HOST_TARGET rather than MACHINE. + when we build for the pseudo machine 'host' + the object tree uses HOST_TARGET rather than MACHINE. OBJROOTS a list of the common prefix for all obj dirs it might - end in '/' or '-'. + end in '/' or '-'. - DPDEPS names an optional file to which per file dependencies - will be appended. - For example if 'some/path/foo.h' is read from SRCTOP - then 'DPDEPS_some/path/foo.h +=' "RELDIR" is output. - This can allow 'bmake' to learn all the dirs within - the tree that depend on 'foo.h' - - EXCLUDES - A list of paths to ignore. - ccache(1) can otherwise be trouble. + DPDEPS names an optional file to which per file dependencies + will be appended. + For example if 'some/path/foo.h' is read from SRCTOP + then 'DPDEPS_some/path/foo.h +=' "RELDIR" is output. + This can allow 'bmake' to learn all the dirs within + the tree that depend on 'foo.h' + + EXCLUDES + A list of paths to ignore. + ccache(1) can otherwise be trouble. - debug desired debug level + debug desired debug level debug_out open file to send debug output to (sys.stderr) @@ -229,8 +229,9 @@ class MetaFile: if objroot.endswith(e): # this is not what we want - fix it objroot = objroot[0:-len(e)] - if e.endswith('/'): - objroot += '/' + + if objroot[-1] != '/': + objroot += '/' if not objroot in self.objroots: self.objroots.append(objroot) _objroot = os.path.realpath(objroot) @@ -293,6 +294,9 @@ class MetaFile: return None for f in sort_unique(self.file_deps): print('DPDEPS_%s += %s' % (f, self.reldir), file=out) + # these entries provide for reverse DIRDEPS lookup + for f in self.obj_deps: + print('DEPDIRS_%s += %s' % (f, self.reldir), file=out) def seenit(self, dir): """rememer that we have seen dir.""" @@ -360,28 +364,28 @@ class MetaFile: def parse(self, name=None, file=None): """A meta file looks like: - # Meta data file "path" - CMD "command-line" - CWD "cwd" - TARGET "target" - -- command output -- - -- filemon acquired metadata -- - # buildmon version 3 - V 3 - C "pid" "cwd" - E "pid" "path" - F "pid" "child" - R "pid" "path" - W "pid" "path" - X "pid" "status" - D "pid" "path" - L "pid" "src" "target" - M "pid" "old" "new" - S "pid" "path" - # Bye bye + # Meta data file "path" + CMD "command-line" + CWD "cwd" + TARGET "target" + -- command output -- + -- filemon acquired metadata -- + # buildmon version 3 + V 3 + C "pid" "cwd" + E "pid" "path" + F "pid" "child" + R "pid" "path" + W "pid" "path" + X "pid" "status" + D "pid" "path" + L "pid" "src" "target" + M "pid" "old" "new" + S "pid" "path" + # Bye bye - We go to some effort to avoid processing a dependency more than once. - Of the above record types only C,E,F,L,R,V and W are of interest. + We go to some effort to avoid processing a dependency more than once. + Of the above record types only C,E,F,L,R,V and W are of interest. """ version = 0 # unknown @@ -431,7 +435,6 @@ class MetaFile: pid = int(w[1]) if pid != last_pid: if last_pid: - pid_cwd[last_pid] = cwd pid_last_dir[last_pid] = self.last_dir cwd = getv(pid_cwd, pid, self.cwd) self.last_dir = getv(pid_last_dir, pid, self.cwd) @@ -448,7 +451,8 @@ class MetaFile: cwd = abspath(w[2], cwd, None, self.debug, self.debug_out) if cwd.endswith('/.'): cwd = cwd[0:-2] - self.last_dir = cwd + self.last_dir = pid_last_dir[pid] = cwd + pid_cwd[pid] = cwd if self.debug > 1: print("cwd=", cwd, file=self.debug_out) continue @@ -545,6 +549,9 @@ class MetaFile: ddep = self.find_obj(objroot, dir, path, w[2]) if ddep: self.add(self.obj_deps, ddep, 'obj') + if self.dpdeps and objroot.endswith('/stage/'): + sp = '/'.join(path.replace(objroot,'').split('/')[1:]) + self.add(self.file_deps, sp, 'file') else: # don't waste time looking again self.seenit(w[2]) Modified: head/share/mk/meta2deps.sh ============================================================================== --- head/share/mk/meta2deps.sh Fri Dec 23 00:38:43 2016 (r310436) +++ head/share/mk/meta2deps.sh Fri Dec 23 02:57:00 2016 (r310437) @@ -1,4 +1,3 @@ -# $FreeBSD$ #!/bin/sh # NAME: @@ -53,7 +52,7 @@ # $SB/obj-i386/bsd/gnu/lib/csu # $SB/obj-i386/bsd/gnu/lib/libgcc # $SB/obj-i386/bsd/include -# $SB/obj-i386/bsd/lib/csu/i386-elf +# $SB/obj-i386/bsd/lib/csu/i386 # $SB/obj-i386/bsd/lib/libc # $SB/src/bsd/include # $SB/src/bsd/sys/i386/include @@ -78,7 +77,8 @@ # RCSid: -# $Id: meta2deps.sh,v 1.9 2015/04/03 18:23:25 sjg Exp $ +# $FreeBSD$ +# $Id: meta2deps.sh,v 1.12 2016/12/13 20:44:16 sjg Exp $ # Copyright (c) 2010-2013, Juniper Networks, Inc. # All rights reserved. @@ -256,7 +256,7 @@ meta2deps() { *) case "$lpid" in "") ;; - *) eval ldir_$lpid=$ldir cwd_$lpid=$cwd;; + *) eval ldir_$lpid=$ldir;; esac eval ldir=\${ldir_$pid:-$CWD} cwd=\${cwd_$pid:-$CWD} lpid=$pid @@ -272,9 +272,11 @@ meta2deps() { esac # watch out for temp dirs that no longer exist test -d ${cwd:-/dev/null/no/such} || cwd=$CWD + eval cwd_$pid=$cwd continue ;; - F,*) eval cwd_$path=$cwd ldir_$path=$ldir + F,*) # $path is new pid + eval cwd_$path=$cwd ldir_$path=$ldir continue ;; *) dir=${path%/*} From owner-svn-src-head@freebsd.org Fri Dec 23 03:20:35 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9D78DC8C6D6; Fri, 23 Dec 2016 03:20:35 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 5F49C131E; Fri, 23 Dec 2016 03:20:35 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBN3KYkT095324; Fri, 23 Dec 2016 03:20:34 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBN3KY8N095321; Fri, 23 Dec 2016 03:20:34 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201612230320.uBN3KY8N095321@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Fri, 23 Dec 2016 03:20:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310443 - head/sys/mips/mips X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Fri, 23 Dec 2016 03:20:35 -0000 Author: jhb Date: Fri Dec 23 03:20:34 2016 New Revision: 310443 URL: https://svnweb.freebsd.org/changeset/base/310443 Log: MFamd64: Various fixes for MIPS minidumps. - Honor PG_NODUMP by not dumping pages with this flag set. - Pat the watchdog during dumps to avoid a watchdog reset while writing out a dump. - Reformat the output during a dump to update every 10% done rather than every 2MB dumped. - Include UMA small pages and pages holding PV entries in minidumps. Sponsored by: DARPA / AFRL Modified: head/sys/mips/mips/minidump_machdep.c head/sys/mips/mips/pmap.c head/sys/mips/mips/uma_machdep.c Modified: head/sys/mips/mips/minidump_machdep.c ============================================================================== --- head/sys/mips/mips/minidump_machdep.c Fri Dec 23 03:19:48 2016 (r310442) +++ head/sys/mips/mips/minidump_machdep.c Fri Dec 23 03:20:34 2016 (r310443) @@ -37,8 +37,11 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include +#include +#include #include #include #include @@ -62,7 +65,7 @@ static off_t dumplo; static off_t origdumplo; /* Handle chunked writes. */ -static uint64_t counter, progress; +static uint64_t counter, progress, dumpsize; /* Just auxiliary bufffer */ static char tmpbuffer[PAGE_SIZE]; @@ -73,8 +76,11 @@ CTASSERT(sizeof(*vm_page_dump) == 4); static int is_dumpable(vm_paddr_t pa) { + vm_page_t m; int i; + if ((m = vm_phys_paddr_to_vm_page(pa)) != NULL) + return ((m->flags & PG_NODUMP) == 0); for (i = 0; dump_avail[i] != 0 || dump_avail[i + 1] != 0; i += 2) { if (pa >= dump_avail[i] && pa < dump_avail[i + 1]) return (1); @@ -104,7 +110,40 @@ dump_drop_page(vm_paddr_t pa) atomic_clear_int(&vm_page_dump[idx], 1ul << bit); } -#define PG2MB(pgs) (((pgs) + (1 << 8) - 1) >> 8) +static struct { + int min_per; + int max_per; + int visited; +} progress_track[10] = { + { 0, 10, 0}, + { 10, 20, 0}, + { 20, 30, 0}, + { 30, 40, 0}, + { 40, 50, 0}, + { 50, 60, 0}, + { 60, 70, 0}, + { 70, 80, 0}, + { 80, 90, 0}, + { 90, 100, 0} +}; + +static void +report_progress(uint64_t progress, uint64_t dumpsize) +{ + int sofar, i; + + sofar = 100 - ((progress * 100) / dumpsize); + for (i = 0; i < nitems(progress_track); i++) { + if (sofar < progress_track[i].min_per || + sofar > progress_track[i].max_per) + continue; + if (progress_track[i].visited) + return; + progress_track[i].visited = 1; + printf("..%d%%", sofar); + return; + } +} static int write_buffer(struct dumperinfo *di, char *ptr, size_t sz) @@ -126,10 +165,12 @@ write_buffer(struct dumperinfo *di, char progress -= len; if (counter >> 22) { - printf(" %jd", PG2MB(progress >> PAGE_SHIFT)); + report_progress(progress, dumpsize); counter &= (1<<22) - 1; } + wdog_kern_pat(WD_LASTVAL); + if (ptr) { error = dump_write(di, ptr, 0, dumplo, len); if (error) @@ -156,7 +197,6 @@ int minidumpsys(struct dumperinfo *di) { struct minidumphdr mdhdr; - uint64_t dumpsize; uint32_t ptesize; uint32_t bits; vm_paddr_t pa; @@ -247,9 +287,8 @@ minidumpsys(struct dumperinfo *di) mkdumpheader(&kdh, KERNELDUMPMAGIC, KERNELDUMP_MIPS_VERSION, dumpsize, kerneldumpcrypto_dumpkeysize(di->kdc), di->blocksize); - printf("Physical memory: %ju MB\n", - (uintmax_t)ptoa((uintmax_t)physmem) / 1048576); - printf("Dumping %llu MB:", (long long)dumpsize >> 20); + printf("Dumping %llu out of %ju MB:", (long long)dumpsize >> 20, + ptoa((uintmax_t)physmem) / 1048576); /* Dump leader */ error = dump_write_header(di, &kdh, 0, dumplo); Modified: head/sys/mips/mips/pmap.c ============================================================================== --- head/sys/mips/mips/pmap.c Fri Dec 23 03:19:48 2016 (r310442) +++ head/sys/mips/mips/pmap.c Fri Dec 23 03:20:34 2016 (r310443) @@ -1484,6 +1484,7 @@ pmap_pv_reclaim(pmap_t locked_pmap) /* Entire chunk is free; return it. */ m_pc = PHYS_TO_VM_PAGE(MIPS_DIRECT_TO_PHYS( (vm_offset_t)pc)); + dump_drop_page(m_pc->phys_addr); break; } } @@ -1545,6 +1546,7 @@ free_pv_chunk(struct pv_chunk *pc) PV_STAT(pc_chunk_frees++); /* entire chunk is free, return it */ m = PHYS_TO_VM_PAGE(MIPS_DIRECT_TO_PHYS((vm_offset_t)pc)); + dump_drop_page(m->phys_addr); vm_page_unwire(m, PQ_NONE); vm_page_free(m); } @@ -1605,6 +1607,7 @@ retry: } PV_STAT(pc_chunk_count++); PV_STAT(pc_chunk_allocs++); + dump_add_page(m->phys_addr); pc = (struct pv_chunk *)MIPS_PHYS_TO_DIRECT(VM_PAGE_TO_PHYS(m)); pc->pc_pmap = pmap; pc->pc_map[0] = pc_freemask[0] & ~1ul; /* preallocated bit 0 */ Modified: head/sys/mips/mips/uma_machdep.c ============================================================================== --- head/sys/mips/mips/uma_machdep.c Fri Dec 23 03:19:48 2016 (r310442) +++ head/sys/mips/mips/uma_machdep.c Fri Dec 23 03:20:34 2016 (r310443) @@ -68,6 +68,8 @@ uma_small_alloc(uma_zone_t zone, vm_size } pa = VM_PAGE_TO_PHYS(m); + if ((wait & M_NODUMP) == 0) + dump_add_page(pa); va = (void *)MIPS_PHYS_TO_DIRECT(pa); if ((wait & M_ZERO) && (m->flags & PG_ZERO) == 0) bzero(va, PAGE_SIZE); @@ -81,6 +83,7 @@ uma_small_free(void *mem, vm_size_t size vm_paddr_t pa; pa = MIPS_DIRECT_TO_PHYS((vm_offset_t)mem); + dump_drop_page(pa); m = PHYS_TO_VM_PAGE(pa); m->wire_count--; vm_page_free(m); From owner-svn-src-head@freebsd.org Fri Dec 23 03:27:12 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 71694C8CBA0; Fri, 23 Dec 2016 03:27:12 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 4C1AB1A78; Fri, 23 Dec 2016 03:27:12 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBN3RB1k099446; Fri, 23 Dec 2016 03:27:11 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBN3RBC1099442; Fri, 23 Dec 2016 03:27:11 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201612230327.uBN3RBC1099442@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Fri, 23 Dec 2016 03:27:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310445 - in head/sys/mips: include mips X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Fri, 23 Dec 2016 03:27:12 -0000 Author: jhb Date: Fri Dec 23 03:27:11 2016 New Revision: 310445 URL: https://svnweb.freebsd.org/changeset/base/310445 Log: Teach DDB how to unwind across a kernel stack overflow. Kernel stack overflows in MIPS call panic() directly from an assembly handler after storing the interrupted context's registers in a trapframe. Rather than inferring the location of ra, sp, and pc from the instruction stream, recognize the pc of a kernel stack overflow and pull the registers from the trapframe. Sponsored by: DARPA / AFRL Modified: head/sys/mips/include/trap.h head/sys/mips/mips/db_trace.c head/sys/mips/mips/exception.S Modified: head/sys/mips/include/trap.h ============================================================================== --- head/sys/mips/include/trap.h Fri Dec 23 03:23:14 2016 (r310444) +++ head/sys/mips/include/trap.h Fri Dec 23 03:27:11 2016 (r310445) @@ -111,6 +111,7 @@ void trapDump(char *msg); void MipsFPTrap(u_int, u_int, u_int); void MipsKernGenException(void); void MipsKernIntr(void); +void MipsKStackOverflow(void); void MipsTLBInvalidException(void); void MipsTLBMissException(void); void MipsUserGenException(void); Modified: head/sys/mips/mips/db_trace.c ============================================================================== --- head/sys/mips/mips/db_trace.c Fri Dec 23 03:23:14 2016 (r310444) +++ head/sys/mips/mips/db_trace.c Fri Dec 23 03:27:11 2016 (r310445) @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -157,7 +158,6 @@ loop: valid_args[2] = 0; valid_args[3] = 0; next_ra = 0; -/* Jump here after a nonstandard (interrupt handler) frame */ stksize = 0; subr = 0; if (frames++ > 100) { @@ -213,6 +213,15 @@ loop: ra = 0; goto done; } + + /* + * For a kernel stack overflow, skip to the output and + * afterwards pull the previous registers out of the trapframe + * instead of decoding the function prologue. + */ + if (pc == (uintptr_t)MipsKStackOverflow) + goto done; + /* * Find the beginning of the current subroutine by scanning * backwards from the current PC for the end of the previous @@ -389,7 +398,21 @@ done: (uintmax_t)(u_register_t) sp, stksize); - if (ra) { + if (pc == (uintptr_t)MipsKStackOverflow) { +#define TF_REG(base, reg) ((base) + CALLFRAME_SIZ + ((reg) * SZREG)) +#if defined(__mips_n64) || defined(__mips_n32) + pc = kdbpeekd((int *)TF_REG(sp, PC)); + ra = kdbpeekd((int *)TF_REG(sp, RA)); + sp = kdbpeekd((int *)TF_REG(sp, SP)); +#else + pc = kdbpeek((int *)TF_REG(sp, PC)); + ra = kdbpeek((int *)TF_REG(sp, RA)); + sp = kdbpeek((int *)TF_REG(sp, SP)); +#endif +#undef TF_REG + (*printfn) ("--- Kernel Stack Overflow ---\n"); + goto loop; + } else if (ra) { if (pc == ra && stksize == 0) (*printfn) ("stacktrace: loop!\n"); else { Modified: head/sys/mips/mips/exception.S ============================================================================== --- head/sys/mips/mips/exception.S Fri Dec 23 03:23:14 2016 (r310444) +++ head/sys/mips/mips/exception.S Fri Dec 23 03:27:11 2016 (r310445) @@ -1019,6 +1019,8 @@ tlb_insert_random: * of this handler. Otherwise the ddb backtrace code will think that * the panic() was called from MipsTLBMissException. */ + .globl MipsKStackOverflow +MipsKStackOverflow: nop .set pop From owner-svn-src-head@freebsd.org Fri Dec 23 03:40:14 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 31371C8D056; Fri, 23 Dec 2016 03:40:14 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from mail.baldwin.cx (bigwig.baldwin.cx [96.47.65.170]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 01CD614A8; Fri, 23 Dec 2016 03:40:14 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by mail.baldwin.cx (Postfix) with ESMTPSA id 0EC0810AA64; Thu, 22 Dec 2016 22:40:13 -0500 (EST) From: John Baldwin To: Mark Johnston Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r310423 - head/sys/kern Date: Thu, 22 Dec 2016 16:40:38 -0800 Message-ID: <2625364.T1Fo1rRtxp@ralph.baldwin.cx> User-Agent: KMail/4.14.10 (FreeBSD/11.0-PRERELEASE; KDE/4.14.10; amd64; ; ) In-Reply-To: <20161222192601.GA78778@wkstn-mjohnston.west.isilon.com> References: <201612221751.uBMHpim4062786@repo.freebsd.org> <6562460.a4qdZuDa0s@ralph.baldwin.cx> <20161222192601.GA78778@wkstn-mjohnston.west.isilon.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mail.baldwin.cx); Thu, 22 Dec 2016 22:40:13 -0500 (EST) X-Virus-Scanned: clamav-milter 0.99.2 at mail.baldwin.cx X-Virus-Status: Clean X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Fri, 23 Dec 2016 03:40:14 -0000 On Thursday, December 22, 2016 11:26:01 AM Mark Johnston wrote: > On Thu, Dec 22, 2016 at 10:39:12AM -0800, John Baldwin wrote: > > On Thursday, December 22, 2016 05:51:44 PM Mark Johnston wrote: > > > Author: markj > > > Date: Thu Dec 22 17:51:44 2016 > > > New Revision: 310423 > > > URL: https://svnweb.freebsd.org/changeset/base/310423 > > > > > > Log: > > > Revert part of r300109. > > > > > > The removal of TAILQ_FOREACH_SAFE introduced a small race: when the last > > > thread on a sleepqueue is awoken, it reclaims the sleepqueue and may begin > > > executing on a different CPU before sleepq_resume_thread() returns. This > > > leaves a window during which it may go back to sleep and incorrectly be > > > awoken again by the caller of sleepq_broadcast(). > > > > This is very subtle. > > :( That also means debugging this was a nice catch. :) > > The issue is that the last sleepq_resume_thread transfers > > ownership of 'sq' from the wait channel that the sleepq_broadcast has locked, > > to the thread being resumed. > > Right, that's what I meant by "reclaims the sleepqueue." One other > requirement for hitting the race is that the thread goes back to sleep > on a wait channel that hashes to a different sleepchain, else the > sleepchain lock held by the sleepq_broadcast() caller is, I believe, > sufficient to prevent the reuse of the sleepqueue before the loop has > terminated. > > > I thought about using a local TAILQ_HEAD and > > using TAILQ_CONCAT to move the list of threads out of the sleep queue and then > > walking that list. However, a comment explaining this transfer of ownership > > (and that we can't safely access 'sq' after the last thread is resumed) is > > probably sufficient (but necessary I think). Do you feel like adding one? > > How about: > > Index: subr_sleepqueue.c > =================================================================== > --- subr_sleepqueue.c (revision 310423) > +++ subr_sleepqueue.c (working copy) > @@ -892,7 +892,12 @@ > KASSERT(sq->sq_type == (flags & SLEEPQ_TYPE), > ("%s: mismatch between sleep/wakeup and cv_*", __func__)); > > - /* Resume all blocked threads on the sleep queue. */ > + /* > + * Resume all blocked threads on the sleep queue. The last thread will > + * be given ownership of sq and may re-enqueue itself before > + * sleepq_resume_thread() returns, so we must cache the "next" queue > + * item at the beginning of the final iteration. > + */ > wakeup_swapper = 0; > TAILQ_FOREACH_SAFE(td, &sq->sq_blocked[queue], td_slpq, tdn) { > thread_lock(td); That looks great, thanks! -- John Baldwin From owner-svn-src-head@freebsd.org Fri Dec 23 04:38:28 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7A6AFC8DF9A; Fri, 23 Dec 2016 04:38:28 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 4A10D1153; Fri, 23 Dec 2016 04:38:28 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBN4cRSc029538; Fri, 23 Dec 2016 04:38:27 GMT (envelope-from hrs@FreeBSD.org) Received: (from hrs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBN4cRas029537; Fri, 23 Dec 2016 04:38:27 GMT (envelope-from hrs@FreeBSD.org) Message-Id: <201612230438.uBN4cRas029537@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hrs set sender to hrs@FreeBSD.org using -f From: Hiroki Sato Date: Fri, 23 Dec 2016 04:38:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310452 - head/usr.bin/logger X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Fri, 23 Dec 2016 04:38:28 -0000 Author: hrs Date: Fri Dec 23 04:38:27 2016 New Revision: 310452 URL: https://svnweb.freebsd.org/changeset/base/310452 Log: mdoc fixes. Modified: head/usr.bin/logger/logger.1 Modified: head/usr.bin/logger/logger.1 ============================================================================== --- head/usr.bin/logger/logger.1 Fri Dec 23 04:37:11 2016 (r310451) +++ head/usr.bin/logger/logger.1 Fri Dec 23 04:38:27 2016 (r310452) @@ -116,14 +116,18 @@ If an unknown service name is used, prints a warning and falls back to port 514. .It Fl p Ar pri Enter the message with the specified priority. -The priority may be specified numerically or as a ``facility.level'' +The priority may be specified numerically or as a +.Li facility.level pair. -For example, ``\-p local3.info'' logs the message(s) as +For example, +.Dq Fl p Li local3.info +logs the message(s) as .Ar info Ns rmational level in the .Ar local3 facility. -The default is ``user.notice.'' +The default is +.Dq Li user.notice . .It Fl S Ar addr Ns \&: Ns Ar port Specify source address and/or source port when using .Fl h @@ -135,9 +139,9 @@ flag is enabled. Note that a numeric IPv6 address in .Ar addr must be enclosed with -.Qq \&[ +.Dq \&[ and -.Qq \&] . +.Dq \&] . .It Fl t Ar tag Mark every line in the log with the specified .Ar tag From owner-svn-src-head@freebsd.org Fri Dec 23 04:59:24 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 382DCC8C581; Fri, 23 Dec 2016 04:59:24 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 ED0231EA8; Fri, 23 Dec 2016 04:59:23 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBN4xNpo039515; Fri, 23 Dec 2016 04:59:23 GMT (envelope-from hrs@FreeBSD.org) Received: (from hrs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBN4xNcl039514; Fri, 23 Dec 2016 04:59:23 GMT (envelope-from hrs@FreeBSD.org) Message-Id: <201612230459.uBN4xNcl039514@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hrs set sender to hrs@FreeBSD.org using -f From: Hiroki Sato Date: Fri, 23 Dec 2016 04:59:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310453 - head/usr.sbin/syslogd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Fri, 23 Dec 2016 04:59:24 -0000 Author: hrs Date: Fri Dec 23 04:59:22 2016 New Revision: 310453 URL: https://svnweb.freebsd.org/changeset/base/310453 Log: mdoc and style fixes. Modified: head/usr.sbin/syslogd/syslogd.8 Modified: head/usr.sbin/syslogd/syslogd.8 ============================================================================== --- head/usr.sbin/syslogd/syslogd.8 Fri Dec 23 04:38:27 2016 (r310452) +++ head/usr.sbin/syslogd/syslogd.8 Fri Dec 23 04:59:22 2016 (r310453) @@ -40,7 +40,7 @@ .Op Fl a Ar allowed_peer .Op Fl b Ar bind_address .Op Fl f Ar config_file -.Op Fl l Oo Ar mode \&: Oc Ns Ar path +.Op Fl l Oo Ar mode Ns \&: Oc Ns Ar path .Op Fl m Ar mark_interval .Op Fl P Ar pid_file .Op Fl p Ar log_socket @@ -48,7 +48,9 @@ .Sh DESCRIPTION The .Nm -utility reads and logs messages to the system console, log files, other +utility reads and logs messages to the system console, +log files, +other machines and/or users as specified by its configuration file. .Pp The options are as follows: @@ -64,7 +66,8 @@ to use IPv6 addresses only. .It Fl 8 Tells .Nm -not to interfere with 8-bit data. Normally +not to interfere with 8-bit data. +Normally .Nm will replace C1 control characters .Pq ISO 8859 and Unicode characters @@ -137,11 +140,13 @@ is IPv4 address, a missing .Ar masklen will be substituted by the historic class A or class B netmasks if .Ar ipaddr -belongs into the address range of class A or B, respectively, or -by 24 otherwise. +belongs into the address range of class A or B, +respectively, +or by 24 otherwise. If .Ar ipaddr -is IPv6 address, a missing +is IPv6 address, +a missing .Ar masklen will be substituted by 128. .It Xo @@ -191,29 +196,31 @@ is This option can be specified multiple times to bind to multiple addresses and/or ports. .It Fl C -Create log files that do not exist (permission is set to -.Li 0600 ) . +Create log files that do not exist +.Pq permission is set to Ql Li 0600 . .It Fl c Disable the compression of repeated instances of the same line into a single line of the form .Dq Li "last message repeated N times" when the output is a pipe to another program. -If specified twice, disable this compression in all cases. +If specified twice, +disable this compression in all cases. .It Fl d Put .Nm into debugging mode. This is probably only of use to developers working on .Nm . -.It Fl f +.It Fl f Ar config_file Specify the pathname of an alternate configuration file; the default is .Pa /etc/syslog.conf . .It Fl F Run .Nm -in the foreground, rather than going into daemon mode. This is useful if -some other process uses +in the foreground, +rather than going into daemon mode. +This is useful if some other process uses .Xr fork 2 and .Xr exec 3 @@ -230,52 +237,75 @@ Usually the .Dq kern facility is reserved for messages read directly from .Pa /dev/klog . -.It Fl m +.It Fl m Ar mark_interval Select the number of minutes between .Dq mark -messages; the default is 20 minutes. +messages; +the default is 20 minutes. .It Fl N -Disable binding on UDP sockets. RFC 3164 recommends that outgoing -syslogd messages should originate from the privileged port, this -option +Disable binding on UDP sockets. +RFC 3164 recommends that outgoing +.Nm +messages should originate from the privileged port, +this option .Em disables -the recommended behavior. This option inherits +the recommended behavior. +This option inherits .Fl s . .It Fl n -Disable dns query for every request. +Disable DNS query for every request. .It Fl o Prefix kernel messages with the full kernel boot file as determined by .Xr getbootfile 3 . Without this, the kernel message prefix is always .Dq Li kernel: . -.It Fl p +.It Fl p Ar log_socket Specify the pathname of an alternate log socket to be used instead; the default is .Pa /var/run/log . -.It Fl P +When a single +.Fl p +options are specified, +the default pathname is replaced with the specified one. +When two or more +.Fl p +options are specified, +the remaining pathnames are treated as additional log sockets. +.It Fl P Ar pid_file Specify an alternative file in which to store the process ID. The default is .Pa /var/run/syslog.pid . -.It Fl S +.It Fl S Ar logpriv_socket Specify the pathname of an alternate log socket for privileged -applications to be used instead; the default is +applications to be used instead; +the default is .Pa /var/run/logpriv . -.It Fl l +When a single +.Fl S +options are specified, +the default pathname is replaced with the specified one. +When two or more +.Fl S +options are specified, +the remaining pathnames are treated as additional log sockets. +.It Fl l Oo Ar mode Ns \&: Oc Ns Ar path Specify a location where .Nm should place an additional log socket. The primary use for this is to place additional log sockets in .Pa /var/run/log of various chroot filespaces. -File permissions for socket can be specified in octal representation -before socket name, delimited with a colon. -Path to socket location must be absolute. +File permissions for socket can be specified in octal representation in +.Ar mode , +delimited with a colon. +The socket location must be specified as an absolute pathname in +.Ar path . .It Fl s Operate in secure mode. Do not log messages from remote machines. -If -specified twice, no network socket will be opened at all, which also -disables logging to remote machines. +If specified twice, +no network socket will be opened at all, +which also disables logging to remote machines. .It Fl T Always use the local time and date for messages received from the network, instead of the timestamp field supplied in the message by the remote host. @@ -284,14 +314,16 @@ or are unable to generate a correct time .It Fl u Unique priority logging. Only log messages at the specified priority. -Without this option, messages at the stated priority or higher are logged. +Without this option, +messages at the stated priority or higher are logged. This option changes the default comparison from .Dq => to .Dq = . .It Fl v Verbose logging. -If specified once, the numeric facility and priority are +If specified once, +the numeric facility and priority are logged with each locally-written message. If specified more than once, the names of the facility and priority are logged with each locally-written @@ -318,7 +350,7 @@ from an Internet domain socket specified .Pa /etc/services , and from the special device .Pa /dev/klog -(to read kernel messages). +.Pq to read kernel messages . .Pp The .Nm @@ -333,8 +365,10 @@ This can be used to kill or reconfigure The message sent to .Nm should consist of a single line. -The message can contain a priority code, which should be a preceding -decimal number in angle braces, for example, +The message can contain a priority code, +which should be a preceding +decimal number in angle braces, +for example, .Sq Aq 5 . This priority code should map into the priorities defined in the include file @@ -342,9 +376,10 @@ include file .Pp For security reasons, .Nm -will not append to log files that do not exist (unless -.Fl C -option is specified); +will not append to log files that do not exist +.Po unless Fl C +option is specified +.Pc ; therefore, they must be created manually before running .Nm . .Pp @@ -393,23 +428,23 @@ options are extensions. .Sh BUGS The ability to log messages received in UDP packets is equivalent to -an unauthenticated remote disk-filling service, and should probably be -disabled by default. +an unauthenticated remote disk-filling service, +and should probably be disabled by default. Some sort of .No inter- Ns Nm syslogd authentication mechanism ought to be worked out. -To prevent the worst -abuse, use of the +To prevent the worst abuse, +use of the .Fl a option is therefore highly recommended. .Pp The .Fl a -matching algorithm does not pretend to be very efficient; use of numeric -IP addresses is faster than domain name comparison. -Since the allowed -peer list is being walked linearly, peer groups where frequent messages -are being anticipated from should be put early into the +matching algorithm does not pretend to be very efficient; +use of numeric IP addresses is faster than domain name comparison. +Since the allowed peer list is being walked linearly, +peer groups where frequent messages are being anticipated +from should be put early into the .Fl a list. .Pp From owner-svn-src-head@freebsd.org Fri Dec 23 05:02:18 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E77ABC8C7C4; Fri, 23 Dec 2016 05:02:18 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 B009512BF; Fri, 23 Dec 2016 05:02:18 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBN52HYg041970; Fri, 23 Dec 2016 05:02:17 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBN52Hmq041969; Fri, 23 Dec 2016 05:02:17 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201612230502.uBN52Hmq041969@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Fri, 23 Dec 2016 05:02:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310454 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Fri, 23 Dec 2016 05:02:19 -0000 Author: markj Date: Fri Dec 23 05:02:17 2016 New Revision: 310454 URL: https://svnweb.freebsd.org/changeset/base/310454 Log: Add a comment explaining the race fixed by r310423. Suggested and reviewed by: jhb X-MFC With: r310423 Modified: head/sys/kern/subr_sleepqueue.c Modified: head/sys/kern/subr_sleepqueue.c ============================================================================== --- head/sys/kern/subr_sleepqueue.c Fri Dec 23 04:59:22 2016 (r310453) +++ head/sys/kern/subr_sleepqueue.c Fri Dec 23 05:02:17 2016 (r310454) @@ -892,7 +892,12 @@ sleepq_broadcast(void *wchan, int flags, KASSERT(sq->sq_type == (flags & SLEEPQ_TYPE), ("%s: mismatch between sleep/wakeup and cv_*", __func__)); - /* Resume all blocked threads on the sleep queue. */ + /* + * Resume all blocked threads on the sleep queue. The last thread will + * be given ownership of sq and may re-enqueue itself before + * sleepq_resume_thread() returns, so we must cache the "next" queue + * item at the beginning of the final iteration. + */ wakeup_swapper = 0; TAILQ_FOREACH_SAFE(td, &sq->sq_blocked[queue], td_slpq, tdn) { thread_lock(td); From owner-svn-src-head@freebsd.org Fri Dec 23 05:07:30 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1FB8FC8C860; Fri, 23 Dec 2016 05:07:30 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 D8A9814F1; Fri, 23 Dec 2016 05:07:29 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBN57Tmb043572; Fri, 23 Dec 2016 05:07:29 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBN57Tln043571; Fri, 23 Dec 2016 05:07:29 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612230507.uBN57Tln043571@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Fri, 23 Dec 2016 05:07:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310455 - head/contrib/bsnmp/snmpd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Fri, 23 Dec 2016 05:07:30 -0000 Author: ngie Date: Fri Dec 23 05:07:28 2016 New Revision: 310455 URL: https://svnweb.freebsd.org/changeset/base/310455 Log: Clarify failure in snmp_output(..) with call to snmp_pdu_decode - Explicitly test snmp_pdu_encode against SNMP_CODE_OK instead of assuming any non-zero value is bad. - Print out the code before calling abort() to give the end-user something actionable to debug without having to recompile the binary, since the core might not have these details. MFC after: 1 week Modified: head/contrib/bsnmp/snmpd/main.c Modified: head/contrib/bsnmp/snmpd/main.c ============================================================================== --- head/contrib/bsnmp/snmpd/main.c Fri Dec 23 05:02:17 2016 (r310454) +++ head/contrib/bsnmp/snmpd/main.c Fri Dec 23 05:07:28 2016 (r310455) @@ -282,12 +282,13 @@ snmp_output(struct snmp_pdu *pdu, u_char const char *dest) { struct asn_buf resp_b; + enum snmp_code code; resp_b.asn_ptr = sndbuf; resp_b.asn_len = snmpd.txbuf; - if (snmp_pdu_encode(pdu, &resp_b) != 0) { - syslog(LOG_ERR, "cannot encode message"); + if ((code = snmp_pdu_encode(pdu, &resp_b)) != SNMP_CODE_OK) { + syslog(LOG_ERR, "cannot encode message (code=%d)", code); abort(); } if (debug.dump_pdus) { From owner-svn-src-head@freebsd.org Fri Dec 23 06:29:25 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A43EBC8DAD9; Fri, 23 Dec 2016 06:29:25 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 667D51218; Fri, 23 Dec 2016 06:29:25 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBN6TO4n075216; Fri, 23 Dec 2016 06:29:24 GMT (envelope-from hrs@FreeBSD.org) Received: (from hrs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBN6TODs075215; Fri, 23 Dec 2016 06:29:24 GMT (envelope-from hrs@FreeBSD.org) Message-Id: <201612230629.uBN6TODs075215@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hrs set sender to hrs@FreeBSD.org using -f From: Hiroki Sato Date: Fri, 23 Dec 2016 06:29:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310456 - head/usr.sbin/syslogd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Fri, 23 Dec 2016 06:29:25 -0000 Author: hrs Date: Fri Dec 23 06:29:24 2016 New Revision: 310456 URL: https://svnweb.freebsd.org/changeset/base/310456 Log: - More ifdef INET and INET6. - Use STDERR_FILENO + 1 instead of "3". - Fix dprintf() in cvthname(). Modified: head/usr.sbin/syslogd/syslogd.c Modified: head/usr.sbin/syslogd/syslogd.c ============================================================================== --- head/usr.sbin/syslogd/syslogd.c Fri Dec 23 05:07:28 2016 (r310455) +++ head/usr.sbin/syslogd/syslogd.c Fri Dec 23 06:29:24 2016 (r310456) @@ -748,6 +748,7 @@ socklist_recv_sock(struct socklist *sl) static void unmapped(struct sockaddr *sa) { +#if defined(INET) && defined(INET6) struct sockaddr_in6 *sin6; struct sockaddr_in sin; @@ -766,6 +767,10 @@ unmapped(struct sockaddr *sa) memcpy(&sin.sin_addr, &sin6->sin6_addr.s6_addr[12], sizeof(sin.sin_addr)); memcpy(sa, &sin, sizeof(sin)); +#else + if (sa == NULL) + return; +#endif } static void @@ -1533,24 +1538,23 @@ cvthname(struct sockaddr *f) sigset_t omask, nmask; static char hname[NI_MAXHOST], ip[NI_MAXHOST]; - dprintf("cvthname(%d) len = %d, %zu\n", f->sa_family, f->sa_len, sizeof(struct sockaddr_in6)); + dprintf("cvthname(%d) len = %d\n", f->sa_family, f->sa_len); error = getnameinfo(f, f->sa_len, ip, sizeof(ip), NULL, 0, NI_NUMERICHOST); - dprintf("cvthname(%s)\n", ip); - if (error) { dprintf("Malformed from address %s\n", gai_strerror(error)); return ("???"); } + dprintf("cvthname(%s)\n", ip); + if (!resolve) return (ip); sigemptyset(&nmask); sigaddset(&nmask, SIGHUP); sigprocmask(SIG_BLOCK, &nmask, &omask); - error = getnameinfo((struct sockaddr *)f, - ((struct sockaddr *)f)->sa_len, - hname, sizeof hname, NULL, 0, NI_NAMEREQD); + error = getnameinfo(f, f->sa_len, hname, sizeof(hname), + NULL, 0, NI_NAMEREQD); sigprocmask(SIG_SETMASK, &omask, NULL); if (error) { dprintf("Host name for your address (%s) unknown\n", ip); @@ -2393,7 +2397,9 @@ allowaddr(char *s) struct servent *se; int masklen = -1; struct addrinfo hints, *res; +#ifdef INET in_addr_t *addrp, *maskp; +#endif #ifdef INET6 uint32_t *addr6p, *mask6p; #endif @@ -2459,7 +2465,9 @@ allowaddr(char *s) .ss_family = res->ai_family, .ss_len = res->ai_addrlen }; - if (res->ai_family == AF_INET) { + switch (res->ai_family) { +#ifdef INET + case AF_INET: maskp = &sstosin(&ap->a_mask)->sin_addr.s_addr; addrp = &sstosin(&ap->a_addr)->sin_addr.s_addr; if (masklen < 0) { @@ -2481,9 +2489,14 @@ allowaddr(char *s) } /* Lose any host bits in the network number. */ *addrp &= *maskp; - } + break; +#endif #ifdef INET6 - else if (res->ai_family == AF_INET6 && masklen <= 128) { + case AF_INET6: + if (masklen > 128) { + freeaddrinfo(res); + return (-1); + } if (masklen < 0) masklen = 128; mask6p = (uint32_t *)&sstosin6(&ap->a_mask)->sin6_addr.s6_addr32[0]; @@ -2501,9 +2514,9 @@ allowaddr(char *s) masklen -= 32; } } - } + break; #endif - else { + default: freeaddrinfo(res); return (-1); } @@ -2527,12 +2540,12 @@ allowaddr(char *s) printf("allowaddr: rule "); if (ap->isnumeric) { printf("numeric, "); - getnameinfo((struct sockaddr *)&ap->a_addr, - ((struct sockaddr *)&ap->a_addr)->sa_len, + getnameinfo(sstosa(&ap->a_addr), + (sstosa(&ap->a_addr))->sa_len, ip, sizeof ip, NULL, 0, NI_NUMERICHOST); printf("addr = %s, ", ip); - getnameinfo((struct sockaddr *)&ap->a_mask, - ((struct sockaddr *)&ap->a_mask)->sa_len, + getnameinfo(sstosa(&ap->a_mask), + (sstosa(&ap->a_mask))->sa_len, ip, sizeof ip, NULL, 0, NI_NUMERICHOST); printf("mask = %s; ", ip); } else { @@ -2552,7 +2565,9 @@ validate(struct sockaddr *sa, const char int i; char name[NI_MAXHOST], ip[NI_MAXHOST], port[NI_MAXSERV]; struct allowedpeer *ap; +#ifdef INET struct sockaddr_in *sin4, *a4p = NULL, *m4p = NULL; +#endif #ifdef INET6 struct sockaddr_in6 *sin6, *a6p = NULL, *m6p = NULL; #endif @@ -2602,7 +2617,8 @@ validate(struct sockaddr *sa, const char dprintf("rejected in rule %d due to address family mismatch.\n", i); continue; } - if (ap->a_addr.ss_family == AF_INET) { +#ifdef INET + else if (ap->a_addr.ss_family == AF_INET) { sin4 = satosin(sa); a4p = satosin(&ap->a_addr); m4p = satosin(&ap->a_mask); @@ -2612,6 +2628,7 @@ validate(struct sockaddr *sa, const char continue; } } +#endif #ifdef INET6 else if (ap->a_addr.ss_family == AF_INET6) { sin6 = satosin6(sa); @@ -2702,7 +2719,7 @@ p_open(const char *prog, pid_t *rpid) dup2(pfd[0], STDIN_FILENO); dup2(nulldesc, STDOUT_FILENO); dup2(nulldesc, STDERR_FILENO); - closefrom(3); + closefrom(STDERR_FILENO + 1); (void)execvp(_PATH_BSHELL, argv); _exit(255); From owner-svn-src-head@freebsd.org Fri Dec 23 06:35:20 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0EADAC8DE14; Fri, 23 Dec 2016 06:35:20 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 D29571702; Fri, 23 Dec 2016 06:35:19 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBN6ZJqS078953; Fri, 23 Dec 2016 06:35:19 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBN6ZJAY078952; Fri, 23 Dec 2016 06:35:19 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612230635.uBN6ZJAY078952@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Fri, 23 Dec 2016 06:35:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310457 - head/etc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Fri, 23 Dec 2016 06:35:20 -0000 Author: ngie Date: Fri Dec 23 06:35:18 2016 New Revision: 310457 URL: https://svnweb.freebsd.org/changeset/base/310457 Log: Clean up trailing whitespace No functional change MFC after: 3 days Modified: head/etc/snmpd.config Modified: head/etc/snmpd.config ============================================================================== --- head/etc/snmpd.config Fri Dec 23 06:29:24 2016 (r310456) +++ head/etc/snmpd.config Fri Dec 23 06:35:18 2016 (r310457) @@ -127,7 +127,7 @@ snmpEnableAuthenTraps = 2 # The following block creates a user with name "bsnmp" and sets privacy # and encryption options to SHA256 message digests and AES encryption # for this user. -# +# # usmUserStatus.$(engine).$(user1) = 5 # usmUserAuthProtocol.$(engine).$(user1) = $(HMACSHAAuthProtocol) # usmUserAuthKeyChange.$(engine).$(user1) = $(user1passwd) @@ -170,7 +170,7 @@ snmpEnableAuthenTraps = 2 # vacmSecurityToGroupStatus.$(securityModelUSM).$(read) = 4 # vacmGroupName.$(securityModelUSM).$(read) = $(write) -# +# # The OID of the .iso.org.dod.internet subtree # # internetoid := 1.3.6.1 @@ -193,7 +193,7 @@ snmpEnableAuthenTraps = 2 # vacmAccessReadViewName.$(read)."".$(securityModelSNMPv1).$(noAuthNoPriv) = "internet" # -# Read-write access for SNMPv2 users +# Read-write access for SNMPv2 users # # vacmAccessStatus.$(write)."".$(securityModelSNMPv2c).$(noAuthNoPriv) = 4 # vacmAccessReadViewName.$(write)."".$(securityModelSNMPv2c).$(noAuthNoPriv) = "internet" From owner-svn-src-head@freebsd.org Fri Dec 23 06:56:50 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 28596C8C333; Fri, 23 Dec 2016 06:56:50 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 02FCE1F91; Fri, 23 Dec 2016 06:56:49 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBN6unbL087318; Fri, 23 Dec 2016 06:56:49 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBN6unvP087317; Fri, 23 Dec 2016 06:56:49 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612230656.uBN6unvP087317@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Fri, 23 Dec 2016 06:56:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310458 - head/etc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Fri, 23 Dec 2016 06:56:50 -0000 Author: ngie Date: Fri Dec 23 06:56:48 2016 New Revision: 310458 URL: https://svnweb.freebsd.org/changeset/base/310458 Log: Group all loadable modules in the %default section This will allow new users to uncomment the modules and have things work with less head scratching, in the event they decide to uncomment any of the section separators, e.g. %usm or %vcm, as the module loading is only effective in the %default section. MFC after: 1 week Modified: head/etc/snmpd.config Modified: head/etc/snmpd.config ============================================================================== --- head/etc/snmpd.config Fri Dec 23 06:35:18 2016 (r310457) +++ head/etc/snmpd.config Fri Dec 23 06:56:48 2016 (r310458) @@ -112,12 +112,63 @@ sysObjectId = 1.3.6.1.4.1.12325.1.1.2.1 snmpEnableAuthenTraps = 2 +# Uncomment `begemotSnmpdModulePath.".." = ".."' entries below to enable +# modules + +# +# Bridge module +# This requires the mibII module. +# +#begemotSnmpdModulePath."bridge" = "/usr/lib/snmp_bridge.so" + +# +# Host resources module +# This requires the mibII module. +# +#begemotSnmpdModulePath."hostres" = "/usr/lib/snmp_hostres.so" + +# +# LM75 Sensor module +# +#begemotSnmpdModulePath."lm75" = "/usr/lib/snmp_lm75.so" + +# +# MIB-2 module +# +begemotSnmpdModulePath."mibII" = "/usr/lib/snmp_mibII.so" + +# +# Netgraph module +# +#begemotSnmpdModulePath."netgraph" = "/usr/lib/snmp_netgraph.so" + +# +# pf(4) module +# +#begemotSnmpdModulePath."pf" = "/usr/lib/snmp_pf.so" + +# +# SNMPv3 Notification Targets +# +# begemotSnmpdModulePath."target" = "/usr/lib/snmp_target.so" + # # SNMPv3 User-based security module - must be loaded for SNMPv3 USM # #begemotSnmpdModulePath."usm" = "/usr/lib/snmp_usm.so" # +# SNMPv3 View-based Access Control module +# +#begemotSnmpdModulePath."vacm" = "/usr/lib/snmp_vacm.so" + +# +# Wireless module +# This requires the mibII module. +# +#begemotSnmpdModulePath."wlan" = "/usr/lib/snmp_wlan.so" + +# # SNMPv3 USM User definition. # @@ -147,11 +198,6 @@ snmpEnableAuthenTraps = 2 # # -# SNMPv3 View-based Access Control module -# -#begemotSnmpdModulePath."vacm" = "/usr/lib/snmp_vacm.so" - -# # Definition of view-based access control entries. # #%vacm @@ -215,11 +261,6 @@ snmpEnableAuthenTraps = 2 # vacmAccessWriteViewName.$(write)."".3.$(authPriv) = "restricted" # vacmAccessNotifyViewName.$(write)."".3.$(authPriv) = "restricted" -# -# SNMPv3 Notification Targets -# -# begemotSnmpdModulePath."target" = "/usr/lib/snmp_target.so" - #%target # Send notifications to target tag "test" # tag := "test" @@ -259,49 +300,12 @@ snmpEnableAuthenTraps = 2 # snmpTargetAddrParams.$(tagremote) = $(tag) # snmpTargetAddrRowStatus.$(tagremote) = 1 -# -# Load MIB-2 module -# -begemotSnmpdModulePath."mibII" = "/usr/lib/snmp_mibII.so" - # Force a polling rate for the 64-bit interface counters in case # the automatic computation is wrong (which may be the case if an interface # announces the wrong bit rate via its MIB). #%mibII #begemotIfForcePoll = 2000 - -# Netgraph module -# -#begemotSnmpdModulePath."netgraph" = "/usr/lib/snmp_netgraph.so" -# #%netgraph #begemotNgControlNodeName = "snmpd" -# -# LM75 Sensor module -# -#begemotSnmpdModulePath."lm75" = "/usr/lib/snmp_lm75.so" - -# -# pf(4) module -# -#begemotSnmpdModulePath."pf" = "/usr/lib/snmp_pf.so" - -# -# Host resources module -# This requires the mibII module. -# -#begemotSnmpdModulePath."hostres" = "/usr/lib/snmp_hostres.so" - -# -# Bridge module -# This requires the mibII module. -# -#begemotSnmpdModulePath."bridge" = "/usr/lib/snmp_bridge.so" - -# -# Wireless module -# This requires the mibII module. -# -#begemotSnmpdModulePath."wlan" = "/usr/lib/snmp_wlan.so" From owner-svn-src-head@freebsd.org Fri Dec 23 07:55:14 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E4277C8D78B; Fri, 23 Dec 2016 07:55:14 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 B0E651D11; Fri, 23 Dec 2016 07:55:14 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBN7tDvT012486; Fri, 23 Dec 2016 07:55:13 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBN7tDx9012485; Fri, 23 Dec 2016 07:55:13 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612230755.uBN7tDx9012485@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Fri, 23 Dec 2016 07:55:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310459 - head/contrib/bsnmp/snmpd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Fri, 23 Dec 2016 07:55:15 -0000 Author: ngie Date: Fri Dec 23 07:55:13 2016 New Revision: 310459 URL: https://svnweb.freebsd.org/changeset/base/310459 Log: Sort #includes per style(9) No functional change MFC after: 3 days Modified: head/contrib/bsnmp/snmpd/action.c Modified: head/contrib/bsnmp/snmpd/action.c ============================================================================== --- head/contrib/bsnmp/snmpd/action.c Fri Dec 23 06:56:48 2016 (r310458) +++ head/contrib/bsnmp/snmpd/action.c Fri Dec 23 07:55:13 2016 (r310459) @@ -38,12 +38,12 @@ #include #include #include +#include +#include +#include #include #include -#include #include -#include -#include #include #include "snmpmod.h" From owner-svn-src-head@freebsd.org Fri Dec 23 08:41:29 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C6152C89806; Fri, 23 Dec 2016 08:41:29 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 870DA16CB; Fri, 23 Dec 2016 08:41:29 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBN8fSWP032227; Fri, 23 Dec 2016 08:41:28 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBN8fS6C032225; Fri, 23 Dec 2016 08:41:28 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201612230841.uBN8fS6C032225@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 23 Dec 2016 08:41:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310462 - head/sys/dev/hyperv/utilities X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Fri, 23 Dec 2016 08:41:29 -0000 Author: sephe Date: Fri Dec 23 08:41:28 2016 New Revision: 310462 URL: https://svnweb.freebsd.org/changeset/base/310462 Log: hyperv/ic: Fix version4 timesync message format. It is not compat w/ the old timesync message format, which the message type stays the same as the old timesync message. MFC after: 1 week Sponsored by: Microsoft Modified: head/sys/dev/hyperv/utilities/vmbus_icreg.h head/sys/dev/hyperv/utilities/vmbus_timesync.c Modified: head/sys/dev/hyperv/utilities/vmbus_icreg.h ============================================================================== --- head/sys/dev/hyperv/utilities/vmbus_icreg.h Fri Dec 23 08:31:29 2016 (r310461) +++ head/sys/dev/hyperv/utilities/vmbus_icreg.h Fri Dec 23 08:41:28 2016 (r310462) @@ -114,8 +114,17 @@ struct vmbus_icmsg_timesync { struct vmbus_icmsg_hdr ic_hdr; uint64_t ic_hvtime; uint64_t ic_vmtime; + uint64_t ic_rtt; + uint8_t ic_tsflags; /* VMBUS_ICMSG_TS_FLAG_ */ +} __packed; + +/* VMBUS_ICMSG_TYPE_TIMESYNC, MSGVER4 */ +struct vmbus_icmsg_timesync4 { + struct vmbus_icmsg_hdr ic_hdr; + uint64_t ic_hvtime; uint64_t ic_sent_tc; uint8_t ic_tsflags; /* VMBUS_ICMSG_TS_FLAG_ */ + uint8_t ic_rsvd[5]; } __packed; #define VMBUS_ICMSG_TS_FLAG_SYNC 0x01 Modified: head/sys/dev/hyperv/utilities/vmbus_timesync.c ============================================================================== --- head/sys/dev/hyperv/utilities/vmbus_timesync.c Fri Dec 23 08:31:29 2016 (r310461) +++ head/sys/dev/hyperv/utilities/vmbus_timesync.c Fri Dec 23 08:41:28 2016 (r310462) @@ -48,8 +48,11 @@ __FBSDID("$FreeBSD$"); #define VMBUS_TIMESYNC_MSGVER \ VMBUS_IC_VERSION(VMBUS_TIMESYNC_MSGVER_MAJOR, 0) +#define VMBUS_TIMESYNC_MSGVER4(sc) \ + VMBUS_ICVER_LE(VMBUS_IC_VERSION(4, 0), (sc)->ic_msgver) + #define VMBUS_TIMESYNC_DORTT(sc) \ - ((sc)->ic_msgver >= VMBUS_IC_VERSION(4, 0) && \ + (VMBUS_TIMESYNC_MSGVER4((sc)) &&\ (hyperv_features & CPUID_HV_MSR_TIME_REFCNT)) static int vmbus_timesync_probe(device_t); @@ -174,7 +177,6 @@ vmbus_timesync_cb(struct vmbus_channel * { struct vmbus_ic_softc *sc = xsc; struct vmbus_icmsg_hdr *hdr; - const struct vmbus_icmsg_timesync *msg; int dlen, error; uint64_t xactid; void *data; @@ -209,14 +211,28 @@ vmbus_timesync_cb(struct vmbus_channel * break; case VMBUS_ICMSG_TYPE_TIMESYNC: - if (dlen < sizeof(*msg)) { - device_printf(sc->ic_dev, "invalid timesync len %d\n", - dlen); - return; + if (VMBUS_TIMESYNC_MSGVER4(sc)) { + const struct vmbus_icmsg_timesync4 *msg4; + + if (dlen < sizeof(*msg4)) { + device_printf(sc->ic_dev, "invalid timesync4 " + "len %d\n", dlen); + return; + } + msg4 = data; + vmbus_timesync(sc, msg4->ic_hvtime, msg4->ic_sent_tc, + msg4->ic_tsflags); + } else { + const struct vmbus_icmsg_timesync *msg; + + if (dlen < sizeof(*msg)) { + device_printf(sc->ic_dev, "invalid timesync " + "len %d\n", dlen); + return; + } + msg = data; + vmbus_timesync(sc, msg->ic_hvtime, 0, msg->ic_tsflags); } - msg = data; - vmbus_timesync(sc, msg->ic_hvtime, msg->ic_sent_tc, - msg->ic_tsflags); break; default: From owner-svn-src-head@freebsd.org Fri Dec 23 08:52:11 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7382EC89D55; Fri, 23 Dec 2016 08:52:11 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 430381100; Fri, 23 Dec 2016 08:52:11 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBN8qA3b036881; Fri, 23 Dec 2016 08:52:10 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBN8qAiE036880; Fri, 23 Dec 2016 08:52:10 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201612230852.uBN8qAiE036880@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 23 Dec 2016 08:52:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310465 - head/sys/dev/hyperv/utilities X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Fri, 23 Dec 2016 08:52:11 -0000 Author: sephe Date: Fri Dec 23 08:52:10 2016 New Revision: 310465 URL: https://svnweb.freebsd.org/changeset/base/310465 Log: hyperv/ic: Allow applying the samples from hypervisor unconditionally. MFC after: 1 week Sponsored by: Microsoft Modified: head/sys/dev/hyperv/utilities/vmbus_timesync.c Modified: head/sys/dev/hyperv/utilities/vmbus_timesync.c ============================================================================== --- head/sys/dev/hyperv/utilities/vmbus_timesync.c Fri Dec 23 08:49:30 2016 (r310464) +++ head/sys/dev/hyperv/utilities/vmbus_timesync.c Fri Dec 23 08:52:10 2016 (r310465) @@ -139,7 +139,7 @@ vmbus_timesync(struct vmbus_ic_softc *sc } if ((tsflags & VMBUS_ICMSG_TS_FLAG_SAMPLE) && - vmbus_ts_sample_thresh > 0) { + vmbus_ts_sample_thresh >= 0) { int64_t diff; if (vmbus_ts_sample_verbose) { From owner-svn-src-head@freebsd.org Fri Dec 23 08:54:45 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4CED5C89EAA; Fri, 23 Dec 2016 08:54:45 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 1CC3D1394; Fri, 23 Dec 2016 08:54:45 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBN8siwF037209; Fri, 23 Dec 2016 08:54:44 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBN8si3Q037208; Fri, 23 Dec 2016 08:54:44 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612230854.uBN8si3Q037208@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Fri, 23 Dec 2016 08:54:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310466 - head/etc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Fri, 23 Dec 2016 08:54:45 -0000 Author: ngie Date: Fri Dec 23 08:54:44 2016 New Revision: 310466 URL: https://svnweb.freebsd.org/changeset/base/310466 Log: Don't hardcode $(securityModelUSM) (3) in the authPriv example under the %vacm section MFC after: 1 week Modified: head/etc/snmpd.config Modified: head/etc/snmpd.config ============================================================================== --- head/etc/snmpd.config Fri Dec 23 08:52:10 2016 (r310465) +++ head/etc/snmpd.config Fri Dec 23 08:54:44 2016 (r310466) @@ -256,10 +256,10 @@ begemotSnmpdModulePath."mibII" = "/usr/l # #Read-write-notify access to restricted for SNMPv3 USM users with authPriv # -# vacmAccessStatus.$(write)."".3.$(authPriv) = 4 -# vacmAccessReadViewName.$(write)."".3.$(authPriv) = "restricted" -# vacmAccessWriteViewName.$(write)."".3.$(authPriv) = "restricted" -# vacmAccessNotifyViewName.$(write)."".3.$(authPriv) = "restricted" +# vacmAccessStatus.$(write)."".$(securityModelUSM).$(authPriv) = 4 +# vacmAccessReadViewName.$(write)."".$(securityModelUSM).$(authPriv) = "restricted" +# vacmAccessWriteViewName.$(write)."".$(securityModelUSM).$(authPriv) = "restricted" +# vacmAccessNotifyViewName.$(write)."".$(securityModelUSM).$(authPriv) = "restricted" #%target # Send notifications to target tag "test" From owner-svn-src-head@freebsd.org Fri Dec 23 08:59:25 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 021E5C89FA1; Fri, 23 Dec 2016 08:59:25 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 C5A3215D9; Fri, 23 Dec 2016 08:59:24 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBN8xN4k037482; Fri, 23 Dec 2016 08:59:23 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBN8xNaP037481; Fri, 23 Dec 2016 08:59:23 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612230859.uBN8xNaP037481@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Fri, 23 Dec 2016 08:59:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310467 - head/etc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Fri, 23 Dec 2016 08:59:25 -0000 Author: ngie Date: Fri Dec 23 08:59:23 2016 New Revision: 310467 URL: https://svnweb.freebsd.org/changeset/base/310467 Log: Provide some guidance when dealing with sections and variables contained within them For example, using variables designated for %usm requires uncommenting %usm section header MFC after: 1 month Modified: head/etc/snmpd.config Modified: head/etc/snmpd.config ============================================================================== --- head/etc/snmpd.config Fri Dec 23 08:54:44 2016 (r310466) +++ head/etc/snmpd.config Fri Dec 23 08:59:23 2016 (r310467) @@ -116,6 +116,14 @@ snmpEnableAuthenTraps = 2 # modules # +# Control configuration for the modules in the module specific sections, e.g. +# the "usm" module (begemotSnmpdModulePath."usm") can be controlled in the +# %usm specific section. You must uncomment the section specific header in +# order to use the enclosed variables, e.g. `usmUserStatus.$(engine).$(user1)` +# can only be used if %usm is uncommented. +# + +# # Bridge module # This requires the mibII module. # From owner-svn-src-head@freebsd.org Fri Dec 23 10:23:37 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CC383C8D1BC; Fri, 23 Dec 2016 10:23:37 +0000 (UTC) (envelope-from theraven@FreeBSD.org) Received: from theravensnest.org (theraven.freebsd.your.org [216.14.102.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "cloud.theravensnest.org", Issuer "StartCom Class 1 DV Server CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A60951F9C; Fri, 23 Dec 2016 10:23:36 +0000 (UTC) (envelope-from theraven@FreeBSD.org) Received: from pc40.home (ABordeaux-656-1-243-246.w90-38.abo.wanadoo.fr [90.38.35.246]) (authenticated bits=0) by theravensnest.org (8.15.2/8.15.2) with ESMTPSA id uBNANBnx055998 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 23 Dec 2016 10:23:22 GMT (envelope-from theraven@FreeBSD.org) X-Authentication-Warning: theravensnest.org: Host ABordeaux-656-1-243-246.w90-38.abo.wanadoo.fr [90.38.35.246] claimed to be pc40.home Content-Type: multipart/signed; boundary="Apple-Mail=_FE5AB27D-9CFA-4009-A999-3BEFFE9DA562"; protocol="application/pkcs7-signature"; micalg=sha1 Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Subject: Re: svn commit: r310138 - head/lib/libc/stdio From: David Chisnall In-Reply-To: <20161222220245.zolanf4f2sii352d@ivaldir.etoilebsd.net> Date: Fri, 23 Dec 2016 11:23:08 +0100 Cc: Jilles Tjoelker , Conrad Meyer , Adrian Chadd , src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Message-Id: References: <201612160144.uBG1ipjW016736@repo.freebsd.org> <49460793.UcUNovQMDa@ralph.baldwin.cx> <1482281779.48539.41.camel@freebsd.org> <20161221220212.GA97256@stack.nl> <20161222220245.zolanf4f2sii352d@ivaldir.etoilebsd.net> To: Baptiste Daroussin X-Mailer: Apple Mail (2.3124) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Fri, 23 Dec 2016 10:23:37 -0000 --Apple-Mail=_FE5AB27D-9CFA-4009-A999-3BEFFE9DA562 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 On 22 Dec 2016, at 23:02, Baptiste Daroussin wrote: >=20 > I think it is pretty clear that there are too many people requesting = the revert > for the revert not to be done. Even if this feature is desired, the implementation in the patch is = broken and should be reverted until a correct implementation (one that = doesn=E2=80=99t break the first time user code calls register_printf_*) = is done. David --Apple-Mail=_FE5AB27D-9CFA-4009-A999-3BEFFE9DA562 Content-Disposition: attachment; filename=smime.p7s Content-Type: application/pkcs7-signature; name=smime.p7s Content-Transfer-Encoding: base64 MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIK5jCCBPww ggPkoAMCAQICECJrrb9nBol9MHok/UZg/AYwDQYJKoZIhvcNAQELBQAwdTELMAkGA1UEBhMCSUwx FjAUBgNVBAoTDVN0YXJ0Q29tIEx0ZC4xKTAnBgNVBAsTIFN0YXJ0Q29tIENlcnRpZmljYXRpb24g QXV0aG9yaXR5MSMwIQYDVQQDExpTdGFydENvbSBDbGFzcyAxIENsaWVudCBDQTAeFw0xNjA0MTkw OTI3NDJaFw0xNzA0MTkwOTI3NDJaMEQxHTAbBgNVBAMMFHRoZXJhdmVuQGZyZWVic2Qub3JnMSMw IQYJKoZIhvcNAQkBFhR0aGVyYXZlbkBmcmVlYnNkLm9yZzCCASIwDQYJKoZIhvcNAQEBBQADggEP ADCCAQoCggEBALsL5pEhrGjrswHVdMHWhgxb8ARKDYRePSqpDLmjJ40bpx+n1zrvIwjC2Vk2IpoD 04rg5Pog2IrhnX+Qk2NSXzBXWj2JAaTc9OtSeAY0BtgJYXONGONQbRKVy97QBdzd1SbMEzDrOgH5 UDI+5sF1PboOTmLyTAPI9273XdfZ0BnstUXs8NXr/7p9E5CWJOsO1iQcINbm4XiwC1PLNMeWUknE Nji/hFKwcE8IFtaUe1ymbw6yA3rBpDu3KewIRD1T66FPTZJeIzvUoBIqWd+GAOfCBG2QYmbc3y/x K2hCtcXThcB1uVFA2q39koLKA8wHyqv4Jhm3wzhAqKDsWK4bGW0CAwEAAaOCAbcwggGzMA4GA1Ud DwEB/wQEAwIEsDAdBgNVHSUEFjAUBggrBgEFBQcDAgYIKwYBBQUHAwQwCQYDVR0TBAIwADAdBgNV HQ4EFgQU5J3Kc8GeW8pEGxBkcMoA7eUOPRwwHwYDVR0jBBgwFoAUJIFsOWG+SQ+PtxtGK8kotSdI bWgwbwYIKwYBBQUHAQEEYzBhMCQGCCsGAQUFBzABhhhodHRwOi8vb2NzcC5zdGFydHNzbC5jb20w OQYIKwYBBQUHMAKGLWh0dHA6Ly9haWEuc3RhcnRzc2wuY29tL2NlcnRzL3NjYS5jbGllbnQxLmNy dDA4BgNVHR8EMTAvMC2gK6AphidodHRwOi8vY3JsLnN0YXJ0c3NsLmNvbS9zY2EtY2xpZW50MS5j cmwwHwYDVR0RBBgwFoEUdGhlcmF2ZW5AZnJlZWJzZC5vcmcwIwYDVR0SBBwwGoYYaHR0cDovL3d3 dy5zdGFydHNzbC5jb20vMEYGA1UdIAQ/MD0wOwYLKwYBBAGBtTcBAgUwLDAqBggrBgEFBQcCARYe aHR0cDovL3d3dy5zdGFydHNzbC5jb20vcG9saWN5MA0GCSqGSIb3DQEBCwUAA4IBAQBSBDH+kZf5 bZkNFcMSPdfnGC7F8utBIxs2bi3JQjsBoQTm1vnXdwgINSfO9At6iQZHoEyj8ZE6PcMFuEU0+bk0 aE8aYcW59WnxfWx943upZoMhX0YVaJcFK01EHFrddRAP44sh7Eu6JtdFuAG+6btDReMcg35Qm65X 7/280aVm7awadJ+IQs8r9qBVk2NFqkvHCETtJjNWXd7M6mcsfXstvykbubPQH/VNW/zrX6yzIcI4 aoz+Sn8RJmHNkk6cImqe1KvsdDLXmqCoeoMwos62pT18RaI//jwTdmnf5EHFMlevnxOr7rzA++71 OSZfdYf6+nvHOod1F721rNuy6lxFMIIF4jCCA8qgAwIBAgIQa6eKfQrXiNZRCvlZ5Oe04TANBgkq hkiG9w0BAQsFADB9MQswCQYDVQQGEwJJTDEWMBQGA1UEChMNU3RhcnRDb20gTHRkLjErMCkGA1UE CxMiU2VjdXJlIERpZ2l0YWwgQ2VydGlmaWNhdGUgU2lnbmluZzEpMCcGA1UEAxMgU3RhcnRDb20g Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTUxMjE2MDEwMDA1WhcNMzAxMjE2MDEwMDA1WjB1 MQswCQYDVQQGEwJJTDEWMBQGA1UEChMNU3RhcnRDb20gTHRkLjEpMCcGA1UECxMgU3RhcnRDb20g Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkxIzAhBgNVBAMTGlN0YXJ0Q29tIENsYXNzIDEgQ2xpZW50 IENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvX3a98OifYP2W4L921tfrh4bdcC1 Ga+YJKy7V3nYNewJHnzMlBsK0Hb8Dm4Wo3FZpylcYa1MJGT10QMGWaLER3xCIuRR+8eklf/EqeZW RLojJ7zBRtjMywPOCelrOU+DX12dKp+Ez4J6919rz1UudTO1GvZyCYJ/I7062uHsskM8b7gPxmcC oO1UHwwpgkvpCArJWGFoFzjLdsZbErJcS3HtAhlkbE/BKTMrdYg35Uo12SLBO5tbk8h2imbKTC8i Ms+pskrvI/AVlh6QoTTXk6xboVX6zgMgzxSVVLymQiygYYm0y5aMsvi2raFhC643SOGvErWWPPnS EfbeAD1xswIDAQABo4IBZDCCAWAwDgYDVR0PAQH/BAQDAgEGMB0GA1UdJQQWMBQGCCsGAQUFBwMC BggrBgEFBQcDBDASBgNVHRMBAf8ECDAGAQH/AgEAMDIGA1UdHwQrMCkwJ6AloCOGIWh0dHA6Ly9j cmwuc3RhcnRzc2wuY29tL3Nmc2NhLmNybDBmBggrBgEFBQcBAQRaMFgwJAYIKwYBBQUHMAGGGGh0 dHA6Ly9vY3NwLnN0YXJ0c3NsLmNvbTAwBggrBgEFBQcwAoYkaHR0cDovL2FpYS5zdGFydHNzbC5j b20vY2VydHMvY2EuY3J0MB0GA1UdDgQWBBQkgWw5Yb5JD4+3G0YrySi1J0htaDAfBgNVHSMEGDAW gBROC+8apEBbpRdphzDKNGhD0EGu8jA/BgNVHSAEODA2MDQGBFUdIAAwLDAqBggrBgEFBQcCARYe aHR0cDovL3d3dy5zdGFydHNzbC5jb20vcG9saWN5MA0GCSqGSIb3DQEBCwUAA4ICAQCL4/eH7AGL hK0PAQJbnOEjJyMEvTTwcAJuUh/bodjQl06u4putYOxdSyIjSP/sKt+31LmjG8+IO1WqykE4H/Lm 7NKezWVnCHuwb3ptgFmlwbMbGkU2MOZBtwzfKXdYUhFLhaE2uw5jXhXvLYitQay962wP5uPI6eAI hV4L8aaya1u4s7MnrTq0Rz25FuGNO79vTHYWj797tSRC8rM16js4yGKOLFpQvIg0F8IElv57b1st p+C7omqM5Qn15dePbSnqr8Jb65WtmJJbnv6rlqfY/aLuE/zmNAlzLmPgfMDStKIXdg+EoYBZTEo8 wBUaBxihfNbJ069ndQOxMNNqBelEMgpAtmjTbCuXFjqIwWq+XOx6ZV/Wh2FAmaLsSHlNvEjjSQMZ wE4EeHCdo66ZmEs/5JYlCeOkulKVQ6P3m5/XOj2jP17Q2AgmjP+11+sHN7PvrG0OwrQp9QMe3X+r n0G8MjtFfqBWvR9CgLIxzM3MJNxFdgdjS2rYnShP5uxvqwfZvhZVYCIkqdJhpYON0DvSodfiar0w iM79mySZJjzC0CTbiisBzS/BeBhqeo2wFfli/iw3hn1XKvAx0ty6w/scmBF0AYqmRHYj1TjMSw0l Al7AztLglqWjUPI+sukvadMRPxmtKXlS2nVR4an/Z16imsZ69+fFYH68c1CK7zmjozGCA04wggNK AgEBMIGJMHUxCzAJBgNVBAYTAklMMRYwFAYDVQQKEw1TdGFydENvbSBMdGQuMSkwJwYDVQQLEyBT dGFydENvbSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEjMCEGA1UEAxMaU3RhcnRDb20gQ2xhc3Mg MSBDbGllbnQgQ0ECECJrrb9nBol9MHok/UZg/AYwCQYFKw4DAhoFAKCCAZkwGAYJKoZIhvcNAQkD MQsGCSqGSIb3DQEHATAcBgkqhkiG9w0BCQUxDxcNMTYxMjIzMTAyMzA5WjAjBgkqhkiG9w0BCQQx FgQUN107XEeaddBJDh4Dz5kE/X6dwMIwgZoGCSsGAQQBgjcQBDGBjDCBiTB1MQswCQYDVQQGEwJJ TDEWMBQGA1UEChMNU3RhcnRDb20gTHRkLjEpMCcGA1UECxMgU3RhcnRDb20gQ2VydGlmaWNhdGlv biBBdXRob3JpdHkxIzAhBgNVBAMTGlN0YXJ0Q29tIENsYXNzIDEgQ2xpZW50IENBAhAia62/ZwaJ fTB6JP1GYPwGMIGcBgsqhkiG9w0BCRACCzGBjKCBiTB1MQswCQYDVQQGEwJJTDEWMBQGA1UEChMN U3RhcnRDb20gTHRkLjEpMCcGA1UECxMgU3RhcnRDb20gQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkx IzAhBgNVBAMTGlN0YXJ0Q29tIENsYXNzIDEgQ2xpZW50IENBAhAia62/ZwaJfTB6JP1GYPwGMA0G CSqGSIb3DQEBAQUABIIBALG2tLUcxTayMYoOCnxzaUgBbOAiaUKKy2EUwrKgasD4Irvd0jW1WnGs HW7Sztlijtsku+ZBT6NbObpVEAZIPNVyqIEoQkO0MPhOpSOaxt4UH6boUOBYtZ4VANALSxjc0Wn/ f3KhuLepicwiK6OwXi+HqThB6hFgJsWYHVMKd3ZjnOKnCBm01tN5KSbk25VavC5WqVOV8vbczpUl N+R1bEGK4Bx601m71nFPfHAv+oGQ6nLFJuu1LFtaOgC+43LYJ+0zqslbFIhjqIJ31vBR0p03jxgC 7cDiBjmaFRBMJQSA4EpGBMGcY681Ag3kxeLce/xwA9c2Hfpmx6PnQZE8gxgAAAAAAAA= --Apple-Mail=_FE5AB27D-9CFA-4009-A999-3BEFFE9DA562-- From owner-svn-src-head@freebsd.org Fri Dec 23 14:54:41 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6A2CCC8E63C; Fri, 23 Dec 2016 14:54:41 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 190341CD6; Fri, 23 Dec 2016 14:54:41 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBNEseBE085810; Fri, 23 Dec 2016 14:54:40 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBNEseZe085809; Fri, 23 Dec 2016 14:54:40 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201612231454.uBNEseZe085809@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 23 Dec 2016 14:54:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310478 - head/sys/cam/ctl X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Fri, 23 Dec 2016 14:54:41 -0000 Author: mav Date: Fri Dec 23 14:54:40 2016 New Revision: 310478 URL: https://svnweb.freebsd.org/changeset/base/310478 Log: Add place-holders for TAPE STREAM MIRRORING subcommands of XCOPY. We do not support tapes, so this is only a comments. MFC after: 2 weeks Modified: head/sys/cam/ctl/ctl_cmd_table.c Modified: head/sys/cam/ctl/ctl_cmd_table.c ============================================================================== --- head/sys/cam/ctl/ctl_cmd_table.c Fri Dec 23 14:44:40 2016 (r310477) +++ head/sys/cam/ctl/ctl_cmd_table.c Fri Dec 23 14:54:40 2016 (r310478) @@ -482,7 +482,7 @@ const struct ctl_cmd_entry ctl_cmd_table /* 15 */ {NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, -/* 16 */ +/* 16 SET TAPE STREAM MIRRORING */ {NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, /* 17 */ @@ -506,6 +506,11 @@ const struct ctl_cmd_entry ctl_cmd_table CTL_FLAG_DATA_NONE, CTL_LUN_PAT_NONE, 16, { 0x1c, 0xff, 0xff, 0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x07}}, + +/* 1D COPY OPERATION CLOSE */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 1e-1f */ }; /* 84 RECEIVE COPY STATUS */ @@ -574,6 +579,50 @@ const struct ctl_cmd_entry ctl_cmd_table CTL_CMD_FLAG_ALLOW_ON_PR_RESV, CTL_LUN_PAT_NONE, 16, {0x08, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff, 0xff, 0xff, 0, 0x07}}, + +/* 09 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 0A */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 0B */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 0C */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 0D */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 0E */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 0F */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 10 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 11 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 12 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 13 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 14 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 15 */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 16 REPORT TAPE STREAM MIRRORING */ +{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, + +/* 17-1f */ }; /* 9B READ BUFFER(16) */ From owner-svn-src-head@freebsd.org Fri Dec 23 15:14:57 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E81C5C8EABE; Fri, 23 Dec 2016 15:14:57 +0000 (UTC) (envelope-from jah@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 A24A4B5C; Fri, 23 Dec 2016 15:14:57 +0000 (UTC) (envelope-from jah@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBNFEuGi094302; Fri, 23 Dec 2016 15:14:56 GMT (envelope-from jah@FreeBSD.org) Received: (from jah@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBNFEuSh094299; Fri, 23 Dec 2016 15:14:56 GMT (envelope-from jah@FreeBSD.org) Message-Id: <201612231514.uBNFEuSh094299@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jah set sender to jah@FreeBSD.org using -f From: "Jason A. Harmening" Date: Fri, 23 Dec 2016 15:14:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310481 - in head/sys/i386: i386 include X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Fri, 23 Dec 2016 15:14:58 -0000 Author: jah Date: Fri Dec 23 15:14:56 2016 New Revision: 310481 URL: https://svnweb.freebsd.org/changeset/base/310481 Log: Move the objects used to create temporary mappings for i386 pmap zero and copy operations to the MD PCPU region. Change sysmap initialization to only allocate KVA pages for CPUs that are actually present. As a minor optimization, this also prevents false sharing between adjacent sysmap objects since the pcpu struct is already cacheline-aligned. While here, move pc_qmap_addr initialization for the BSP into pmap_bootstrap(), which allows use of pmap_quick* functions during early boot. Reviewed by: kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D8833 Modified: head/sys/i386/i386/pmap.c head/sys/i386/include/pcpu.h Modified: head/sys/i386/i386/pmap.c ============================================================================== --- head/sys/i386/i386/pmap.c Fri Dec 23 15:05:41 2016 (r310480) +++ head/sys/i386/i386/pmap.c Fri Dec 23 15:14:56 2016 (r310481) @@ -257,14 +257,6 @@ vm_offset_t pv_vafree; /* freelist sto /* * All those kernel PT submaps that BSD is so fond of */ -struct sysmaps { - struct mtx lock; - pt_entry_t *CMAP1; - pt_entry_t *CMAP2; - caddr_t CADDR1; - caddr_t CADDR2; -}; -static struct sysmaps sysmaps_pcpu[MAXCPU]; pt_entry_t *CMAP3; static pd_entry_t *KPTD; caddr_t ptvmmap = 0; @@ -379,7 +371,7 @@ pmap_bootstrap(vm_paddr_t firstaddr) { vm_offset_t va; pt_entry_t *pte, *unused; - struct sysmaps *sysmaps; + struct pcpu *pc; int i; /* @@ -441,16 +433,19 @@ pmap_bootstrap(vm_paddr_t firstaddr) va = virtual_avail; pte = vtopte(va); + /* + * Initialize temporary map objects on the current CPU for use + * during early boot. * CMAP1/CMAP2 are used for zeroing and copying pages. * CMAP3 is used for the boot-time memory test. */ - for (i = 0; i < MAXCPU; i++) { - sysmaps = &sysmaps_pcpu[i]; - mtx_init(&sysmaps->lock, "SYSMAPS", NULL, MTX_DEF); - SYSMAP(caddr_t, sysmaps->CMAP1, sysmaps->CADDR1, 1) - SYSMAP(caddr_t, sysmaps->CMAP2, sysmaps->CADDR2, 1) - } + pc = pcpu_find(curcpu); + mtx_init(&pc->pc_cmap_lock, "SYSMAPS", NULL, MTX_DEF); + SYSMAP(caddr_t, pc->pc_cmap_pte1, pc->pc_cmap_addr1, 1) + SYSMAP(caddr_t, pc->pc_cmap_pte2, pc->pc_cmap_addr2, 1) + SYSMAP(vm_offset_t, pte, pc->pc_qmap_addr, 1) + SYSMAP(caddr_t, CMAP3, CADDR3, 1); /* @@ -520,20 +515,33 @@ pmap_bootstrap(vm_paddr_t firstaddr) } static void -pmap_init_qpages(void) +pmap_init_reserved_pages(void) { struct pcpu *pc; + vm_offset_t pages; int i; CPU_FOREACH(i) { pc = pcpu_find(i); - pc->pc_qmap_addr = kva_alloc(PAGE_SIZE); - if (pc->pc_qmap_addr == 0) - panic("pmap_init_qpages: unable to allocate KVA"); + /* + * Skip if the mapping has already been initialized, + * i.e. this is the BSP. + */ + if (pc->pc_cmap_addr1 != 0) + continue; + mtx_init(&pc->pc_cmap_lock, "SYSMAPS", NULL, MTX_DEF); + pages = kva_alloc(PAGE_SIZE * 3); + if (pages == 0) + panic("%s: unable to allocate KVA", __func__); + pc->pc_cmap_pte1 = vtopte(pages); + pc->pc_cmap_pte2 = vtopte(pages + PAGE_SIZE); + pc->pc_cmap_addr1 = (caddr_t)pages; + pc->pc_cmap_addr2 = (caddr_t)(pages + PAGE_SIZE); + pc->pc_qmap_addr = pages + (PAGE_SIZE * 2); } } - -SYSINIT(qpages_init, SI_SUB_CPU, SI_ORDER_ANY, pmap_init_qpages, NULL); + +SYSINIT(rpages_init, SI_SUB_CPU, SI_ORDER_ANY, pmap_init_reserved_pages, NULL); /* * Setup the PAT MSR. @@ -4194,20 +4202,22 @@ pagezero(void *page) void pmap_zero_page(vm_page_t m) { - struct sysmaps *sysmaps; + pt_entry_t *cmap_pte2; + struct pcpu *pc; - sysmaps = &sysmaps_pcpu[PCPU_GET(cpuid)]; - mtx_lock(&sysmaps->lock); - if (*sysmaps->CMAP2) - panic("pmap_zero_page: CMAP2 busy"); sched_pin(); - *sysmaps->CMAP2 = PG_V | PG_RW | VM_PAGE_TO_PHYS(m) | PG_A | PG_M | + pc = pcpu_find(curcpu); + cmap_pte2 = pc->pc_cmap_pte2; + mtx_lock(&pc->pc_cmap_lock); + if (*cmap_pte2) + panic("pmap_zero_page: CMAP2 busy"); + *cmap_pte2 = PG_V | PG_RW | VM_PAGE_TO_PHYS(m) | PG_A | PG_M | pmap_cache_bits(m->md.pat_mode, 0); - invlcaddr(sysmaps->CADDR2); - pagezero(sysmaps->CADDR2); - *sysmaps->CMAP2 = 0; + invlcaddr(pc->pc_cmap_addr2); + pagezero(pc->pc_cmap_addr2); + *cmap_pte2 = 0; + mtx_unlock(&pc->pc_cmap_lock); sched_unpin(); - mtx_unlock(&sysmaps->lock); } /* @@ -4217,23 +4227,25 @@ pmap_zero_page(vm_page_t m) void pmap_zero_page_area(vm_page_t m, int off, int size) { - struct sysmaps *sysmaps; + pt_entry_t *cmap_pte2; + struct pcpu *pc; - sysmaps = &sysmaps_pcpu[PCPU_GET(cpuid)]; - mtx_lock(&sysmaps->lock); - if (*sysmaps->CMAP2) - panic("pmap_zero_page_area: CMAP2 busy"); sched_pin(); - *sysmaps->CMAP2 = PG_V | PG_RW | VM_PAGE_TO_PHYS(m) | PG_A | PG_M | + pc = pcpu_find(curcpu); + cmap_pte2 = pc->pc_cmap_pte2; + mtx_lock(&pc->pc_cmap_lock); + if (*cmap_pte2) + panic("pmap_zero_page_area: CMAP2 busy"); + *cmap_pte2 = PG_V | PG_RW | VM_PAGE_TO_PHYS(m) | PG_A | PG_M | pmap_cache_bits(m->md.pat_mode, 0); - invlcaddr(sysmaps->CADDR2); + invlcaddr(pc->pc_cmap_addr2); if (off == 0 && size == PAGE_SIZE) - pagezero(sysmaps->CADDR2); + pagezero(pc->pc_cmap_addr2); else - bzero((char *)sysmaps->CADDR2 + off, size); - *sysmaps->CMAP2 = 0; + bzero(pc->pc_cmap_addr2 + off, size); + *cmap_pte2 = 0; + mtx_unlock(&pc->pc_cmap_lock); sched_unpin(); - mtx_unlock(&sysmaps->lock); } /* @@ -4242,26 +4254,29 @@ pmap_zero_page_area(vm_page_t m, int off void pmap_copy_page(vm_page_t src, vm_page_t dst) { - struct sysmaps *sysmaps; + pt_entry_t *cmap_pte1, *cmap_pte2; + struct pcpu *pc; - sysmaps = &sysmaps_pcpu[PCPU_GET(cpuid)]; - mtx_lock(&sysmaps->lock); - if (*sysmaps->CMAP1) + sched_pin(); + pc = pcpu_find(curcpu); + cmap_pte1 = pc->pc_cmap_pte1; + cmap_pte2 = pc->pc_cmap_pte2; + mtx_lock(&pc->pc_cmap_lock); + if (*cmap_pte1) panic("pmap_copy_page: CMAP1 busy"); - if (*sysmaps->CMAP2) + if (*cmap_pte2) panic("pmap_copy_page: CMAP2 busy"); - sched_pin(); - *sysmaps->CMAP1 = PG_V | VM_PAGE_TO_PHYS(src) | PG_A | + *cmap_pte1 = PG_V | VM_PAGE_TO_PHYS(src) | PG_A | pmap_cache_bits(src->md.pat_mode, 0); - invlcaddr(sysmaps->CADDR1); - *sysmaps->CMAP2 = PG_V | PG_RW | VM_PAGE_TO_PHYS(dst) | PG_A | PG_M | + invlcaddr(pc->pc_cmap_addr1); + *cmap_pte2 = PG_V | PG_RW | VM_PAGE_TO_PHYS(dst) | PG_A | PG_M | pmap_cache_bits(dst->md.pat_mode, 0); - invlcaddr(sysmaps->CADDR2); - bcopy(sysmaps->CADDR1, sysmaps->CADDR2, PAGE_SIZE); - *sysmaps->CMAP1 = 0; - *sysmaps->CMAP2 = 0; + invlcaddr(pc->pc_cmap_addr2); + bcopy(pc->pc_cmap_addr1, pc->pc_cmap_addr2, PAGE_SIZE); + *cmap_pte1 = 0; + *cmap_pte2 = 0; + mtx_unlock(&pc->pc_cmap_lock); sched_unpin(); - mtx_unlock(&sysmaps->lock); } int unmapped_buf_allowed = 1; @@ -4270,19 +4285,22 @@ void pmap_copy_pages(vm_page_t ma[], vm_offset_t a_offset, vm_page_t mb[], vm_offset_t b_offset, int xfersize) { - struct sysmaps *sysmaps; vm_page_t a_pg, b_pg; char *a_cp, *b_cp; vm_offset_t a_pg_offset, b_pg_offset; + pt_entry_t *cmap_pte1, *cmap_pte2; + struct pcpu *pc; int cnt; - sysmaps = &sysmaps_pcpu[PCPU_GET(cpuid)]; - mtx_lock(&sysmaps->lock); - if (*sysmaps->CMAP1 != 0) + sched_pin(); + pc = pcpu_find(curcpu); + cmap_pte1 = pc->pc_cmap_pte1; + cmap_pte2 = pc->pc_cmap_pte2; + mtx_lock(&pc->pc_cmap_lock); + if (*cmap_pte1 != 0) panic("pmap_copy_pages: CMAP1 busy"); - if (*sysmaps->CMAP2 != 0) + if (*cmap_pte2 != 0) panic("pmap_copy_pages: CMAP2 busy"); - sched_pin(); while (xfersize > 0) { a_pg = ma[a_offset >> PAGE_SHIFT]; a_pg_offset = a_offset & PAGE_MASK; @@ -4290,23 +4308,23 @@ pmap_copy_pages(vm_page_t ma[], vm_offse b_pg = mb[b_offset >> PAGE_SHIFT]; b_pg_offset = b_offset & PAGE_MASK; cnt = min(cnt, PAGE_SIZE - b_pg_offset); - *sysmaps->CMAP1 = PG_V | VM_PAGE_TO_PHYS(a_pg) | PG_A | + *cmap_pte1 = PG_V | VM_PAGE_TO_PHYS(a_pg) | PG_A | pmap_cache_bits(a_pg->md.pat_mode, 0); - invlcaddr(sysmaps->CADDR1); - *sysmaps->CMAP2 = PG_V | PG_RW | VM_PAGE_TO_PHYS(b_pg) | PG_A | + invlcaddr(pc->pc_cmap_addr1); + *cmap_pte2 = PG_V | PG_RW | VM_PAGE_TO_PHYS(b_pg) | PG_A | PG_M | pmap_cache_bits(b_pg->md.pat_mode, 0); - invlcaddr(sysmaps->CADDR2); - a_cp = sysmaps->CADDR1 + a_pg_offset; - b_cp = sysmaps->CADDR2 + b_pg_offset; + invlcaddr(pc->pc_cmap_addr2); + a_cp = pc->pc_cmap_addr1 + a_pg_offset; + b_cp = pc->pc_cmap_addr2 + b_pg_offset; bcopy(a_cp, b_cp, cnt); a_offset += cnt; b_offset += cnt; xfersize -= cnt; } - *sysmaps->CMAP1 = 0; - *sysmaps->CMAP2 = 0; + *cmap_pte1 = 0; + *cmap_pte2 = 0; + mtx_unlock(&pc->pc_cmap_lock); sched_unpin(); - mtx_unlock(&sysmaps->lock); } /* @@ -5247,21 +5265,23 @@ pmap_page_set_memattr(vm_page_t m, vm_me static void pmap_flush_page(vm_page_t m) { - struct sysmaps *sysmaps; + pt_entry_t *cmap_pte2; + struct pcpu *pc; vm_offset_t sva, eva; bool useclflushopt; useclflushopt = (cpu_stdext_feature & CPUID_STDEXT_CLFLUSHOPT) != 0; if (useclflushopt || (cpu_feature & CPUID_CLFSH) != 0) { - sysmaps = &sysmaps_pcpu[PCPU_GET(cpuid)]; - mtx_lock(&sysmaps->lock); - if (*sysmaps->CMAP2) - panic("pmap_flush_page: CMAP2 busy"); sched_pin(); - *sysmaps->CMAP2 = PG_V | PG_RW | VM_PAGE_TO_PHYS(m) | + pc = pcpu_find(curcpu); + cmap_pte2 = pc->pc_cmap_pte2; + mtx_lock(&pc->pc_cmap_lock); + if (*cmap_pte2) + panic("pmap_flush_page: CMAP2 busy"); + *cmap_pte2 = PG_V | PG_RW | VM_PAGE_TO_PHYS(m) | PG_A | PG_M | pmap_cache_bits(m->md.pat_mode, 0); - invlcaddr(sysmaps->CADDR2); - sva = (vm_offset_t)sysmaps->CADDR2; + invlcaddr(pc->pc_cmap_addr2); + sva = (vm_offset_t)pc->pc_cmap_addr2; eva = sva + PAGE_SIZE; /* @@ -5280,9 +5300,9 @@ pmap_flush_page(vm_page_t m) } if (useclflushopt || cpu_vendor_id != CPU_VENDOR_INTEL) mfence(); - *sysmaps->CMAP2 = 0; + *cmap_pte2 = 0; + mtx_unlock(&pc->pc_cmap_lock); sched_unpin(); - mtx_unlock(&sysmaps->lock); } else pmap_invalidate_cache(); } Modified: head/sys/i386/include/pcpu.h ============================================================================== --- head/sys/i386/include/pcpu.h Fri Dec 23 15:05:41 2016 (r310480) +++ head/sys/i386/include/pcpu.h Fri Dec 23 15:14:56 2016 (r310481) @@ -36,6 +36,9 @@ #include #include +#include +#include + /* * The SMP parts are setup in pmap.c and locore.s for the BSP, and * mp_machdep.c sets up the data for the AP's to "see" when they awake. @@ -58,9 +61,14 @@ int pc_private_tss; /* Flag indicating private tss*/\ u_int pc_cmci_mask; /* MCx banks for CMCI */ \ u_int pc_vcpu_id; /* Xen vCPU ID */ \ + struct mtx pc_cmap_lock; \ + void *pc_cmap_pte1; \ + void *pc_cmap_pte2; \ + caddr_t pc_cmap_addr1; \ + caddr_t pc_cmap_addr2; \ vm_offset_t pc_qmap_addr; /* KVA for temporary mappings */\ uint32_t pc_smp_tlb_done; /* TLB op acknowledgement */ \ - char __pad[225] + char __pad[189] #ifdef _KERNEL From owner-svn-src-head@freebsd.org Fri Dec 23 16:36:21 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E7BABC8E1AA; Fri, 23 Dec 2016 16:36:21 +0000 (UTC) (envelope-from carpeddiem@gmail.com) Received: from mail-io0-x243.google.com (mail-io0-x243.google.com [IPv6:2607:f8b0:4001:c06::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B228115FF; Fri, 23 Dec 2016 16:36:21 +0000 (UTC) (envelope-from carpeddiem@gmail.com) Received: by mail-io0-x243.google.com with SMTP id m204so230825ioe.3; Fri, 23 Dec 2016 08:36:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=XHcyEuRONp66DoHE9PYDy903k8sHrcJV3Rf6q3HxOVU=; b=H8U2m066fHVN74g1ifHcUo1NXQmT8qRllG+AbgGZPO0xTSvvKj7dviY9w8vU81G6p2 ZxVz3fSddE0UscINSYTLvn1daov0ZS9u0NR9LX6ZtHAJXZWmSbCwqikNdEACwgQvlkT9 heqFNUGul2n79VRyNeXu1xbh53c2hpQdaJ/qFg6wtfrAeVLpWzSEJ2dJOMrugSULyerD d9uMEsNYI/lmT+WQWASTWogAKICT4Wx9dwYmqaOHxE8C88oG22bkKkB4esqZ7xP1HuxF LDkKhr9PtqxmAMd76bAnTTP8Sg7Gvc/sEKnLgwBZ04U9fYYhDE++39DQ6PJRfN9gb8SV GGDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=XHcyEuRONp66DoHE9PYDy903k8sHrcJV3Rf6q3HxOVU=; b=ljH02udzqJzNtiGGYHjZuza96fRm0mAN1oCXjlgPjpBS3chJp4nHSizXHTjCkgFlWz q1v8V+AkFYj9HwPO3vetBNSR0YFkp+Geyc7MLMNyfW93pQWvfKLyQgOriqJQlY3B78cP Wx4/Nx7Mt5AIN70bbMbxa3ei6AL5+s5EydSrKUNIUW5gfg2DI19oCcB1xgyc9BG2fH00 5Koes55PQ6YiECoqsqpDCgKhId5m4jh+jJYuql7AoPlV3b3qGXMjjnP1BqKPUMMo23Zw frF5Ysp7NpZWv2Ru7H4f0XrKAeEJBenRiNds5lefmlMtvd93rtdaNrBVV1MqofR12Q8c C6Vg== X-Gm-Message-State: AIkVDXLyA5pNMiX4EF3e0wMolcrp8zEqAUCkjYxQkMoKG1/RQphFnUBC30D57eyDwlABDVl+QQbHBguy5kkb7g== X-Received: by 10.107.18.193 with SMTP id 62mr16542832ios.155.1482510979958; Fri, 23 Dec 2016 08:36:19 -0800 (PST) MIME-Version: 1.0 Sender: carpeddiem@gmail.com Received: by 10.107.175.133 with HTTP; Fri, 23 Dec 2016 08:35:59 -0800 (PST) In-Reply-To: <201611180013.uAI0DU57087971@repo.freebsd.org> References: <201611180013.uAI0DU57087971@repo.freebsd.org> From: Ed Maste Date: Fri, 23 Dec 2016 11:35:59 -0500 X-Google-Sender-Auth: tdAKy7v4-50_ky7NfMAI8zaVZvA Message-ID: Subject: Re: svn commit: r308789 - head/sys/conf To: Gleb Smirnoff Cc: "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Fri, 23 Dec 2016 16:36:22 -0000 On 17 November 2016 at 19:13, Gleb Smirnoff wrote: > Author: glebius > Date: Fri Nov 18 00:13:30 2016 > New Revision: 308789 > URL: https://svnweb.freebsd.org/changeset/base/308789 > > Log: > If FreeBSD source tree is a subproject of a bigger project, then .git or > .hg may reside above FreeBSD sources root. Provide function findvcs() > that will climb up and seek for presence of a VCS directory. This can incorrectly find an unrelated .git directory and provide a git revision unrelated to the FreeBSD source being built. For example, a build from my Subversion tree now reports "FreeBSD 12.0-CURRENT #2 ad3f46a(master)" instead of "FreeBSD 12.0-CURRENT #5 r310482M". Can you explain your use case in a little more detail so that I can avoid breaking it with a change here? Do you commit FreeBSD snapshots into the "bigger project"? From owner-svn-src-head@freebsd.org Fri Dec 23 18:26:04 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 457B8C8ED96; Fri, 23 Dec 2016 18:26:04 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from mail.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B37C7A46; Fri, 23 Dec 2016 18:26:03 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by mail.baldwin.cx (Postfix) with ESMTPSA id 34B7F10A999; Fri, 23 Dec 2016 13:26:01 -0500 (EST) From: John Baldwin To: src-committers@freebsd.org Cc: svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r310445 - in head/sys/mips: include mips Date: Thu, 22 Dec 2016 19:49:11 -0800 Message-ID: <1808755.8aTbUPpvbL@ralph.baldwin.cx> User-Agent: KMail/4.14.10 (FreeBSD/11.0-PRERELEASE; KDE/4.14.10; amd64; ; ) In-Reply-To: <201612230327.uBN3RBC1099442@repo.freebsd.org> References: <201612230327.uBN3RBC1099442@repo.freebsd.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mail.baldwin.cx); Fri, 23 Dec 2016 13:26:01 -0500 (EST) X-Virus-Scanned: clamav-milter 0.99.2 at mail.baldwin.cx X-Virus-Status: Clean X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Fri, 23 Dec 2016 18:26:04 -0000 On Friday, December 23, 2016 03:27:11 AM John Baldwin wrote: > Author: jhb > Date: Fri Dec 23 03:27:11 2016 > New Revision: 310445 > URL: https://svnweb.freebsd.org/changeset/base/310445 > > Log: > Teach DDB how to unwind across a kernel stack overflow. > > Kernel stack overflows in MIPS call panic() directly from an assembly > handler after storing the interrupted context's registers in a > trapframe. Rather than inferring the location of ra, sp, and pc from > the instruction stream, recognize the pc of a kernel stack overflow > and pull the registers from the trapframe. > > Sponsored by: DARPA / AFRL We should possibly use this same logic for other subroutines that use trapframes. Trying to run a program that core dumps over NFS in my qemu mips64 machine triggers the stack overflow on a kernel built with gcc5.3 from ports. The DDB stack trace doesn't get very far: panic: kernel stack overflow - trapframe at 0xffffffff80699eb0 KDB: stack backtrace: db_trace_self+1c (?,?,?,?) ra ffffffff801620d8 sp ffffffff80699ac0 sz 16 ffffffff801620ac+2c (?,?,?,?) ra ffffffff80357788 sp ffffffff80699ad0 sz 800 ffffffff80357744+44 (?,?,?,?) ra ffffffff80304ff4 sp ffffffff80699df0 sz 16 vpanic+f4 (?,?,?,?) ra ffffffff80305d84 sp ffffffff80699e00 sz 48 panic+30 (?,ffffffff80699eb0,ffffffffffffffec,ffffffff802c901c) ra ffffffff805388bc sp ffffffff80699e30 sz 96 MipsTLBInvalidException+360 (?,?,?,?) ra 0 sp ffffffff80699e90 sz 0 --- Kernel Stack Overflow --- ffffffff802c9018+4 (?,?,?,?) ra ffffffff805544e4 sp c00000002a5b5fa0 sz 96 ffffffff80554400+e4 (?,?,?,?) ra ffffffff802c90f4 sp c00000002a5b6000 sz 48 ffffffff802c9018+dc (?,?,?,?) ra ffffffff805563dc sp c00000002a5b6030 sz 96 cpu_intr+248 (?,?,?,?) ra ffffffff80538110 sp c00000002a5b6090 sz 80 MipsKernIntr+188 (?,?,?,?) ra 0 sp c00000002a5b60e0 sz 368 pid 607 KDB: enter: panic (In particular, we probably should be using the trapframe logic employed here for MipsKernIntr.) I've patched kgdb to add a MIPS kernel target and taught it how to handle trapframes, etc. (and it can cross-debug, so I used an amd64 host to examine the dump) and it gives a more useful stack trace. Unfortunately, increasing the kstack size on MIPS as a workaround for this issue seems to be very hard as the code in cpu_switch() hard codes exactly two TLB entries to cover the kernel stack and PCB to avoid TLB faults during a context switch. I think if you create a kthread with a non-default kstack size on MIPS it's probably a ticking time bomb in that you might get a TLB miss when accessing the pcb. savectx () at /usr/home/john/work/git/freebsd/sys/mips/mips/swtch.S:171 171 SAVE_U_PCB_CONTEXT(ra, PCB_REG_PC, a0) (kgdb) where #0 savectx () at /usr/home/john/work/git/freebsd/sys/mips/mips/swtch.S:171 #1 0xffffffff80304dfc in doadump (textdump=textdump@entry=0) at /usr/home/john/work/git/freebsd/sys/kern/kern_shutdown.c:297 #2 0xffffffff8015d868 in db_dump (dummy=, dummy2=, dummy3=, dummy4=) at /usr/home/john/work/git/freebsd/sys/ddb/db_command.c:546 #3 0xffffffff8015e474 in db_command ( last_cmdp=last_cmdp@entry=0xffffffff8069e778 , cmd_table=, cmd_table@entry=0xffffffff8069e730 , dopager=dopager@entry=1) at /usr/home/john/work/git/freebsd/sys/ddb/db_command.c:453 #4 0xffffffff8015eab8 in db_command_loop () at /usr/home/john/work/git/freebsd/sys/ddb/db_command.c:506 #5 0xffffffff80162040 in db_trap (type=, code=) at /usr/home/john/work/git/freebsd/sys/ddb/db_main.c:248 #6 0xffffffff803583e8 in kdb_trap (type=type@entry=9, code=code@entry=0, tf=tf@entry=0xffffffff80699ca0 ) at /usr/home/john/work/git/freebsd/sys/kern/subr_kdb.c:654 #7 0xffffffff8054ba10 in trap (trapframe=0xffffffff80699ca0 ) at /usr/home/john/work/git/freebsd/sys/mips/mips/trap.c:828 #8 #9 kdb_enter (why=0xffffffff805b6138 "panic", msg=) at /usr/home/john/work/git/freebsd/sys/kern/subr_kdb.c:444 #10 0xffffffff8030503c in vpanic (fmt=, ap=ap@entry=0xffffffff80699e58 ) at /usr/home/john/work/git/freebsd/sys/kern/kern_shutdown.c:752 ---Type to continue, or q to quit--- #11 0xffffffff80305d84 in panic (fmt=) at /usr/home/john/work/git/freebsd/sys/kern/kern_shutdown.c:690 #12 #13 0xffffffff802c901c in intr_event_handle (ie=0x9800000000a42400, frame=frame@entry=0x0) at /usr/home/john/work/git/freebsd/sys/kern/kern_intr.c:1397 #14 0xffffffff805544e4 in gt_pci_intr (v=0x9800000000ab0800) at /usr/home/john/work/git/freebsd/sys/mips/malta/gt_pci.c:236 #15 0xffffffff802c90f4 in intr_event_handle (ie=0x9800000000a43900, frame=frame@entry=0xc00000002a5b6100) at /usr/home/john/work/git/freebsd/sys/kern/kern_intr.c:1436 #16 0xffffffff805563dc in cpu_intr (tf=0xc00000002a5b6100) at /usr/home/john/work/git/freebsd/sys/mips/mips/intr_machdep.c:264 #17 #18 le_pci_wrcsr (sc=0x9800000000ae9400, port=, val=) at /usr/home/john/work/git/freebsd/sys/dev/le/if_le_pci.c:187 #19 0xffffffff801893e4 in am79900_start_locked (sc=0x9800000000ae9400) at /usr/home/john/work/git/freebsd/sys/dev/le/am79900.c:594 #20 0xffffffff8018b1c0 in lance_start (ifp=) at /usr/home/john/work/git/freebsd/sys/dev/le/lance.c:243 #21 0xffffffff804137e4 in if_start (ifp=ifp@entry=0x9800000000ae4800) at /usr/home/john/work/git/freebsd/sys/net/if.c:3630 #22 0xffffffff80413998 in if_transmit (ifp=0x9800000000ae4800, m=) at /usr/home/john/work/git/freebsd/sys/net/if.c:3642 #23 0xffffffff804174fc in ether_output_frame ( ---Type to continue, or q to quit--- ifp=ifp@entry=0x9800000000ae4800, m=0x980000000162d100) at /usr/home/john/work/git/freebsd/sys/net/if_ethersubr.c:457 #24 0xffffffff80417b94 in ether_output (ifp=0x9800000000ae4800, m=0x980000000162d100, dst=0x98000000032878f0, ro=) at /usr/home/john/work/git/freebsd/sys/net/if_ethersubr.c:429 #25 0xffffffff8045cf28 in ip_output (m=m@entry=0x980000000162d100, opt=, ro=0x98000000032878d0, flags=, imo=, imo@entry=0x0, inp=) at /usr/home/john/work/git/freebsd/sys/netinet/ip_output.c:664 #26 0xffffffff80470348 in tcp_output (tp=0x9800000001f4f000) at /usr/home/john/work/git/freebsd/sys/netinet/tcp_output.c:1432 #27 0xffffffff80480d1c in tcp_usr_send (so=0x98000000032a8a20, flags=, m=0x9800000001621a00, nam=0x0, control=, td=0x9800000003275a60) at /usr/home/john/work/git/freebsd/sys/netinet/tcp_usrreq.c:956 #28 0xffffffff803a6ef8 in sosend_generic (so=0x98000000032a8a20, addr=, uio=0x0, top=0x9800000001621a00, control=, flags=, td=) at /usr/home/john/work/git/freebsd/sys/kern/uipc_socket.c:1359 #29 0xffffffff803a7060 in sosend (so=, addr=addr@entry=0x0, uio=uio@entry=0x0, top=top@entry=0x9800000001621a00, control=control@entry=0x0, flags=flags@entry=0, td=) at /usr/home/john/work/git/freebsd/sys/kern/uipc_socket.c:1403 #30 0xffffffff8049220c in clnt_vc_call (cl=, ext=0xc00000002a5b69e8, proc=, args=0x980000000162d200, resultsp=0xc00000002a5b6b40, utimeout=...) ---Type to continue, or q to quit--- at /usr/home/john/work/git/freebsd/sys/rpc/clnt_vc.c:398 #31 0xffffffff804908a4 in clnt_reconnect_call (cl=0x9800000001630400, ext=0xc00000002a5b69e8, proc=, args=0x980000000162d200, resultsp=0xc00000002a5b6b40, utimeout=...) at /usr/home/john/work/git/freebsd/sys/rpc/clnt_rc.c:271 #32 0xffffffff801dd360 in newnfs_request (nd=0xc00000002a5b6b40, nmp=0x980000000163b800, clp=clp@entry=0x0, nrp=0x980000000163b928, vp=0x98000000044aa000, td=td@entry=0x9800000003275a60, cred=cred@entry=0x9800000001670000, prog=prog@entry=100003, vers=3, retsum=retsum@entry=0x0, toplevel=toplevel@entry=1, xidp=xidp@entry=0x0, sep=sep@entry=0x0) at /usr/home/john/work/git/freebsd/sys/fs/nfs/nfs_commonkrpc.c:746 #33 0xffffffff8022c738 in nfscl_request (nd=nd@entry=0xc00000002a5b6b40, vp=vp@entry=0x98000000044aa000, p=p@entry=0x9800000003275a60, cred=cred@entry=0x9800000001670000, stuff=stuff@entry=0x0) at /usr/home/john/work/git/freebsd/sys/fs/nfsclient/nfs_clport.c:951 #34 0xffffffff802116a8 in nfsrpc_commit (vp=0x98000000044aa000, offset=offset@entry=65536, cnt=cnt@entry=65536, cred=cred@entry=0x9800000001670000, p=p@entry=0x9800000003275a60, nap=nap@entry=0xc00000002a5b6cc0, attrflagp=attrflagp@entry=0xc00000002a5b6d88, stuff=stuff@entry=0x0) at /usr/home/john/work/git/freebsd/sys/fs/nfsclient/nfs_clrpcops.c:3640 #35 0xffffffff80220e74 in ncl_commit (vp=vp@entry=0x98000000044aa000, offset=offset@entry=65536, cnt=, cred=cred@entry=0x9800000001670000, td=td@entry=0x9800000003275a60) at /usr/home/john/work/git/freebsd/sys/fs/nfsclient/nfs_clvnops.c:2553 ---Type to continue, or q to quit--- #36 0xffffffff8022130c in ncl_flush (vp=0x98000000044aa000, waitfor=, cred=cred@entry=0x0, td=0x9800000003275a60, commit=commit@entry=1, called_from_renewthread=called_from_renewthread@entry=0) at /usr/home/john/work/git/freebsd/sys/fs/nfsclient/nfs_clvnops.c:2774 #37 0xffffffff8022220c in nfs_fsync (ap=) at /usr/home/john/work/git/freebsd/sys/fs/nfsclient/nfs_clvnops.c:2619 #38 0xffffffff80559508 in VOP_FSYNC_APV (vop=, a=a@entry=0xc00000002a5b6fa0) at vnode_if.c:1331 #39 0xffffffff803bcbd4 in VOP_FSYNC (td=, waitfor=, vp=) at vnode_if.h:549 #40 bufsync (bo=, waitfor=) at /usr/home/john/work/git/freebsd/sys/kern/vfs_bio.c:4605 #41 0xffffffff803e6088 in bufobj_invalbuf (bo=bo@entry=0x98000000044aa0d0, flags=, slpflag=, slptimeo=) at /usr/home/john/work/git/freebsd/sys/kern/vfs_subr.c:1633 #42 0xffffffff803e63a8 in vinvalbuf (vp=vp@entry=0x98000000044aa000, flags=flags@entry=1, slpflag=slpflag@entry=0, slptimeo=slptimeo@entry=0) at /usr/home/john/work/git/freebsd/sys/kern/vfs_subr.c:1711 #43 0xffffffff8022df5c in ncl_vinvalbuf (vp=vp@entry=0x98000000044aa000, flags=flags@entry=1, td=td@entry=0x9800000003275a60, intrflg=, intrflg@entry=1) at /usr/home/john/work/git/freebsd/sys/fs/nfsclient/nfs_clbio.c:1387 #44 0xffffffff8021d5ec in nfs_setattr (ap=0xc00000002a5b7298) at /usr/home/john/work/git/freebsd/sys/fs/nfsclient/nfs_clvnops.c:937 #45 0xffffffff80558564 in VOP_SETATTR_APV (vop=, ---Type to continue, or q to quit--- a=a@entry=0xc00000002a5b7298) at vnode_if.c:799 #46 0xffffffff80230eac in VOP_SETATTR (cred=0x9800000001670000, vap=0xc00000002a5b71f0, vp=0x98000000044aa000) at vnode_if.h:335 #47 ncl_write (ap=) at /usr/home/john/work/git/freebsd/sys/fs/nfsclient/nfs_clbio.c:1280 #48 0xffffffff80558b70 in VOP_WRITE_APV (vop=, a=a@entry=0xc00000002a5b74f0) at vnode_if.c:1000 #49 0xffffffff803f9708 in VOP_WRITE (cred=, ioflag=, uio=0xc00000002a5b7690, vp=) at vnode_if.h:413 #50 vn_io_fault_doio (args=args@entry=0xc00000002a5b76d8, uio=uio@entry=0xc00000002a5b7690, td=td@entry=0x9800000003275a60) at /usr/home/john/work/git/freebsd/sys/kern/vfs_vnops.c:952 #51 0xffffffff803f9894 in vn_io_fault1 (vp=vp@entry=0x98000000044aa000, uio=uio@entry=0xc00000002a5b7690, args=args@entry=0xc00000002a5b76d8, td=td@entry=0x9800000003275a60) at /usr/home/john/work/git/freebsd/sys/kern/vfs_vnops.c:1060 #52 0xffffffff803fca30 in vn_rdwr (rw=rw@entry=UIO_WRITE, vp=vp@entry=0x98000000044aa000, base=base@entry=0x160085000, len=len@entry=16384, offset=offset@entry=131072, segflg=segflg@entry=UIO_USERSPACE, ioflg=ioflg@entry=16641, active_cred=active_cred@entry=0x9800000001670000, file_cred=file_cred@entry=0x0, aresid=aresid@entry=0xc00000002a5b77a0, td=td@entry=0x9800000003275a60) at /usr/home/john/work/git/freebsd/sys/kern/vfs_vnops.c:576 #53 0xffffffff803fcc68 in vn_rdwr_inchunks (rw=rw@entry=UIO_WRITE, ---Type to continue, or q to quit--- vp=0x98000000044aa000, base=0x160085000, len=16384, offset=131072, offset@entry=98304, segflg=segflg@entry=UIO_USERSPACE, ioflg=ioflg@entry=16641, active_cred=0x9800000001670000, file_cred=0x0, aresid=aresid@entry=0x0, td=0x9800000003275a60) at /usr/home/john/work/git/freebsd/sys/kern/vfs_vnops.c:641 #54 0xffffffff802954f4 in core_write (seg=UIO_USERSPACE, offset=98304, len=, base=, p=0xc00000002a5b7860) at /usr/home/john/work/git/freebsd/sys/kern/imgact_elf.c:1229 #55 core_output (tmpbuf=0x0, p=0xc00000002a5b7860, offset=98304, len=, base=) at /usr/home/john/work/git/freebsd/sys/kern/imgact_elf.c:1243 #56 elf64_coredump (td=, vp=0x98000000044aa000, limit=9223372036854775807, flags=) at /usr/home/john/work/git/freebsd/sys/kern/imgact_elf.c:1384 #57 0xffffffff8030805c in coredump (td=td@entry=0x9800000003275a60) at /usr/home/john/work/git/freebsd/sys/kern/kern_sig.c:3477 #58 0xffffffff8030b818 in sigexit (td=td@entry=0x9800000003275a60, sig=sig@entry=7) at /usr/home/john/work/git/freebsd/sys/kern/kern_sig.c:3072 #59 0xffffffff8030c19c in postsig (sig=sig@entry=7) at /usr/home/john/work/git/freebsd/sys/kern/kern_sig.c:2985 #60 0xffffffff8036f13c in ast (framep=0xc00000002a5b7d30) at /usr/home/john/work/git/freebsd/sys/kern/subr_trap.c:314 #61 #62 0x0000000120000ff4 in ?? () Backtrace stopped: previous frame identical to this frame (corrupt stack?) -- John Baldwin From owner-svn-src-head@freebsd.org Fri Dec 23 18:36:18 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 94570C8C0E6 for ; Fri, 23 Dec 2016 18:36:18 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-it0-x243.google.com (mail-it0-x243.google.com [IPv6:2607:f8b0:4001:c0b::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5C50E10C2 for ; Fri, 23 Dec 2016 18:36:18 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-it0-x243.google.com with SMTP id c20so24961513itb.0 for ; Fri, 23 Dec 2016 10:36:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=IbQo8UOhjyWPG3k63Z3qwa7YANX/0IiYRrkc2C6daDk=; b=hjuGXVSM2l2bG+VMTiK3FUhbZ3ElppmfGugM8WJ9t11R4cd9b+3dcwT9oi0gsbgRso zcnZg2mhgsl2m8SARnr3kusoSFEGu0WlIqH5BChowV2Vh0GtBzpYDAKM9wcIzAS5hnTo xONvN1JPRwiTESRpYFEWneNP/986oH2hdxxMi6YsA2bSFzk67DteY39tMG6kxUiFfdWa l+qPRenttyp5FrhLG6fk2xkpGuyWe29Ao+KhL83Vtb7p4cGa7Ei/IdckPBa0y7ZFUhEd gsTz9j5cHbR8KwEhoR+zaRFJpCQJEuheVFu5U04eyXREXAfQoh9+veBcTrU62OP7E2ww vIeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=IbQo8UOhjyWPG3k63Z3qwa7YANX/0IiYRrkc2C6daDk=; b=bmdYsD7Wy2eF+3NmvAWjatrH3Pa5Ekmrm7UVrGa/tGRDOyljEMUK4f3BYGmcuY82qk ofnKOzMfK08xqO9kmXgOVOycShThvJI9VvanxGMRFn0eRQGPnFndy9co55PRvjLKwH6E yc8cYMV2wuvQJENgmN8mbEYHBuDhNDhMNiBrsGSOKJ81KQZpIM2AdNRDLnjJpXRJ/6Ag OZB81l2k3Tj8sBd7CGbnEjfHbzIBvsi3qOccgp6VXVd9vAj2MTIdTaracUpSv3f+JD/p 4FSUDHCKoz/FHHdULxHLJHjK/Snt7Fju3liP0r0YRMouUCyjzGLD1+eLsnVQzhZhYWsA HPgw== X-Gm-Message-State: AIkVDXJVpriTQQJYXtDzjlPUuDXfk0oOHl3vw8CSdAe+O/drkpeX6aS4vYdlKCDVBoZ5Sa/D4Wqx1Oy+e56U2A== X-Received: by 10.36.200.68 with SMTP id w65mr16823524itf.85.1482518177362; Fri, 23 Dec 2016 10:36:17 -0800 (PST) MIME-Version: 1.0 Sender: wlosh@bsdimp.com Received: by 10.79.22.135 with HTTP; Fri, 23 Dec 2016 10:36:16 -0800 (PST) X-Originating-IP: [50.253.99.174] In-Reply-To: References: <201611180013.uAI0DU57087971@repo.freebsd.org> From: Warner Losh Date: Fri, 23 Dec 2016 11:36:16 -0700 X-Google-Sender-Auth: MO1wesfYsL7T0phbHCaiKCKkLRE Message-ID: Subject: Re: svn commit: r308789 - head/sys/conf To: Ed Maste Cc: Gleb Smirnoff , "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Fri, 23 Dec 2016 18:36:18 -0000 On Fri, Dec 23, 2016 at 9:35 AM, Ed Maste wrote: > On 17 November 2016 at 19:13, Gleb Smirnoff wrote: >> Author: glebius >> Date: Fri Nov 18 00:13:30 2016 >> New Revision: 308789 >> URL: https://svnweb.freebsd.org/changeset/base/308789 >> >> Log: >> If FreeBSD source tree is a subproject of a bigger project, then .git or >> .hg may reside above FreeBSD sources root. Provide function findvcs() >> that will climb up and seek for presence of a VCS directory. > > This can incorrectly find an unrelated .git directory and provide a > git revision unrelated to the FreeBSD source being built. For example, > a build from my Subversion tree now reports "FreeBSD 12.0-CURRENT #2 > ad3f46a(master)" instead of "FreeBSD 12.0-CURRENT #5 r310482M". > > Can you explain your use case in a little more detail so that I can > avoid breaking it with a change here? Do you commit FreeBSD snapshots > into the "bigger project"? This is done at work (Netflix). We import all the FreeBSD revisions from github into our repo, and then merge them into the top level FreeBSD directory from time to time using git's subtree functionality. We also pull in our ports tree this way (so we have a ports directory at the same level as our FreeBSD directory). So we don't have a $TOPSRC/.git like you would if you'd just cloned directly from github. Our .git directory lives in $TOPSRC/.git as a result. newvers.sh should find the 'deepest' SCM it can, and use that instead of apparently using the topmost (I'm surprised that you have FreeBSD under a directory that has a git checkout in it, btw, but I know that with my dotfile management repo, that sometimes happens by mistake). And if this somehow produces a 'tie', the tie should go to svn. Looking at how to fix this mess... woof. There's all kinds of crazy here. Support for: git, git + svn, hg, p4, svn and svnlite. Sometimes $VCS_cmd is defined if it exists at all on the system, other times it's only defined if it exists on the system AND we think the tree is under $VCS. But the base of all this woe is that findvcs is called on a per-vcs basis, rather than being called early to match one of N VCS signatures. It would be better off searching each directory for each file rather than finding any file at any level. Warner From owner-svn-src-head@freebsd.org Fri Dec 23 19:30:16 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 36653C8D172; Fri, 23 Dec 2016 19:30:16 +0000 (UTC) (envelope-from kan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 044C4DFE; Fri, 23 Dec 2016 19:30:15 +0000 (UTC) (envelope-from kan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBNJUFDD096156; Fri, 23 Dec 2016 19:30:15 GMT (envelope-from kan@FreeBSD.org) Received: (from kan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBNJUF3T096155; Fri, 23 Dec 2016 19:30:15 GMT (envelope-from kan@FreeBSD.org) Message-Id: <201612231930.uBNJUF3T096155@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kan set sender to kan@FreeBSD.org using -f From: Alexander Kabaev Date: Fri, 23 Dec 2016 19:30:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310486 - head/sys/mips/ingenic X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Fri, 23 Dec 2016 19:30:16 -0000 Author: kan Date: Fri Dec 23 19:30:14 2016 New Revision: 310486 URL: https://svnweb.freebsd.org/changeset/base/310486 Log: Pass memattrs to fb device so that user mappings can inherit them Reviewed by: jmcneill Modified: head/sys/mips/ingenic/jz4780_lcd.c Modified: head/sys/mips/ingenic/jz4780_lcd.c ============================================================================== --- head/sys/mips/ingenic/jz4780_lcd.c Fri Dec 23 19:28:15 2016 (r310485) +++ head/sys/mips/ingenic/jz4780_lcd.c Fri Dec 23 19:30:14 2016 (r310486) @@ -306,7 +306,10 @@ jzlcd_configure(struct jzlcd_softc *sc, sc->info.fb_stride = mode->hdisplay * (FB_BPP / NBBY); sc->info.fb_width = mode->hdisplay; sc->info.fb_height = mode->vdisplay; - +#ifdef VM_MEMATTR_WRITE_COMBINING + sc->info.fb_flags = FB_FLAG_MEMATTR; + sc->info.fb_memattr = VM_MEMATTR_WRITE_COMBINING; +#endif sc->fbdev = device_add_child(sc->dev, "fbd", device_get_unit(sc->dev)); if (sc->fbdev == NULL) { device_printf(sc->dev, "failed to add fbd child\n"); From owner-svn-src-head@freebsd.org Fri Dec 23 20:14:07 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2B92DC8DDE4; Fri, 23 Dec 2016 20:14:07 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 CACA05E8; Fri, 23 Dec 2016 20:14:06 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBNKE67c015811; Fri, 23 Dec 2016 20:14:06 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBNKE5O8015808; Fri, 23 Dec 2016 20:14:05 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201612232014.uBNKE5O8015808@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Fri, 23 Dec 2016 20:14:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310488 - in head/sys/dev/mlx4: mlx4_core mlx4_ib X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Fri, 23 Dec 2016 20:14:07 -0000 Author: emaste Date: Fri Dec 23 20:14:05 2016 New Revision: 310488 URL: https://svnweb.freebsd.org/changeset/base/310488 Log: mlx(4): remove date from log message Further to r310425, go one step further and just remove the date. Reviewed by: hselasky Differential Revision: https://reviews.freebsd.org/D8888 Modified: head/sys/dev/mlx4/mlx4_core/mlx4.h head/sys/dev/mlx4/mlx4_core/mlx4_main.c head/sys/dev/mlx4/mlx4_ib/mlx4_ib_main.c Modified: head/sys/dev/mlx4/mlx4_core/mlx4.h ============================================================================== --- head/sys/dev/mlx4/mlx4_core/mlx4.h Fri Dec 23 19:42:17 2016 (r310487) +++ head/sys/dev/mlx4/mlx4_core/mlx4.h Fri Dec 23 20:14:05 2016 (r310488) @@ -52,7 +52,6 @@ #define DRV_NAME "mlx4_core" #define PFX DRV_NAME ": " #define DRV_VERSION "2.1.6" -#define DRV_RELDATE "Sep 30 2016" #define DRV_STACK_NAME "Linux-MLNX_OFED" #define DRV_STACK_VERSION "2.1" Modified: head/sys/dev/mlx4/mlx4_core/mlx4_main.c ============================================================================== --- head/sys/dev/mlx4/mlx4_core/mlx4_main.c Fri Dec 23 19:42:17 2016 (r310487) +++ head/sys/dev/mlx4/mlx4_core/mlx4_main.c Fri Dec 23 20:14:05 2016 (r310488) @@ -174,7 +174,7 @@ MODULE_PARM_DESC(enable_64b_cqe_eqe, static char mlx4_version[] __devinitdata = DRV_NAME ": Mellanox ConnectX VPI driver v" - DRV_VERSION " (" DRV_RELDATE ")\n"; + DRV_VERSION "\n"; static int log_num_mac = 7; module_param_named(log_num_mac, log_num_mac, int, 0444); Modified: head/sys/dev/mlx4/mlx4_ib/mlx4_ib_main.c ============================================================================== --- head/sys/dev/mlx4/mlx4_ib/mlx4_ib_main.c Fri Dec 23 19:42:17 2016 (r310487) +++ head/sys/dev/mlx4/mlx4_ib/mlx4_ib_main.c Fri Dec 23 20:14:05 2016 (r310488) @@ -59,7 +59,6 @@ #define DRV_NAME MLX4_IB_DRV_NAME #define DRV_VERSION "1.0" -#define DRV_RELDATE "Sep 30 2016" #define MLX4_IB_DRIVER_PROC_DIR_NAME "driver/mlx4_ib" #define MLX4_IB_MRS_PROC_DIR_NAME "mrs" @@ -102,7 +101,7 @@ static spinlock_t dev_num_str_lock; static const char mlx4_ib_version[] = DRV_NAME ": Mellanox ConnectX InfiniBand driver v" - DRV_VERSION " (" DRV_RELDATE ")\n"; + DRV_VERSION "\n"; struct update_gid_work { struct work_struct work; From owner-svn-src-head@freebsd.org Fri Dec 23 20:59:40 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 06E7BC8EBFA; Fri, 23 Dec 2016 20:59:40 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: from mail-wm0-x22b.google.com (mail-wm0-x22b.google.com [IPv6:2a00:1450:400c:c09::22b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9AFB3F2; Fri, 23 Dec 2016 20:59:39 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: by mail-wm0-x22b.google.com with SMTP id k184so25605705wme.1; Fri, 23 Dec 2016 12:59:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=WwgRQobpuBvJ/QYpkFf6u3FJcLvRHfO09fWmkjspHvc=; b=Hb+Z1uiwN8ZVWPMAcwWhYsAl7Uap/QZqZQzK1grj90XJmJ6oZPzc7TIStfZqxdquSr CZv98J0Tt7Mq6skfi0twJGHiOE6A9PiTLCqb2VtR9Q4XVqzoVCVZ2gFdLc71fOM7mxLh 9CfORhnAepw/mlyWmtMbn8zwn9gzBwSN34iXcd+PWenrTBGscPzJA3n9A0AWOSCY5w8o jd843vnhaWPXPHCwV9w5QG8SUKUr1Uo1nk7gr/5GgLy220z4yUT6rfyvrNdqjsp0ImLL tAIo5j0wdziXy6GbshA/lYDN5i6dBPWENglEG904txnVfnQbb+pyvqQoGK2Bo9cAtxa/ Gxmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=WwgRQobpuBvJ/QYpkFf6u3FJcLvRHfO09fWmkjspHvc=; b=AvpIkKrcwRqfrgKt6pLQtQ/eBamLEfcbMM7aRulQlav0xQEUDEgW8/6nNPg4jsPmka oq5/LFwmPQP6GscZuHR13p/0s6kLaX77tpXc4nPdS2+BGgs0/aHFksegXRHN+jRnaXoh SP7eCKJ6Kqam8hfJKCaKRgeanN7wHAIVnFTr33A03AS5jnaph7alWCuGH3AuJuh1WY8h 7ClSIbQQjZ6Bl7xrRL5zhkbBcd/UjkQcvrhleDWq7KYrjp/l6rX1JYgvd+o+Q9XHxviQ 1N+FBd80hMlDsoc3+wWNQ0yV7+nyBxzwi1zdVTL1GP8McuH/aFaiei4TecLMVzWE4tMD gnYg== X-Gm-Message-State: AIkVDXK7LnkUHsgn7f2VMjmCcJGyJtYwaZ8okDiwbIJFyCJW9sw7XQ4TgODrtchJyT12M6tnhEmGTT30v8TyJw== X-Received: by 10.28.109.156 with SMTP id b28mr15119024wmi.116.1482526777802; Fri, 23 Dec 2016 12:59:37 -0800 (PST) MIME-Version: 1.0 Received: by 10.194.44.1 with HTTP; Fri, 23 Dec 2016 12:59:37 -0800 (PST) In-Reply-To: <1808755.8aTbUPpvbL@ralph.baldwin.cx> References: <201612230327.uBN3RBC1099442@repo.freebsd.org> <1808755.8aTbUPpvbL@ralph.baldwin.cx> From: Adrian Chadd Date: Fri, 23 Dec 2016 12:59:37 -0800 Message-ID: Subject: Re: svn commit: r310445 - in head/sys/mips: include mips To: John Baldwin Cc: "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Fri, 23 Dec 2016 20:59:40 -0000 That's a ... deeep stack. :( How big is each stackframe? -adrian On 22 December 2016 at 19:49, John Baldwin wrote: > On Friday, December 23, 2016 03:27:11 AM John Baldwin wrote: >> Author: jhb >> Date: Fri Dec 23 03:27:11 2016 >> New Revision: 310445 >> URL: https://svnweb.freebsd.org/changeset/base/310445 >> >> Log: >> Teach DDB how to unwind across a kernel stack overflow. >> >> Kernel stack overflows in MIPS call panic() directly from an assembly >> handler after storing the interrupted context's registers in a >> trapframe. Rather than inferring the location of ra, sp, and pc from >> the instruction stream, recognize the pc of a kernel stack overflow >> and pull the registers from the trapframe. >> >> Sponsored by: DARPA / AFRL > > We should possibly use this same logic for other subroutines that use > trapframes. Trying to run a program that core dumps over NFS in my > qemu mips64 machine triggers the stack overflow on a kernel built with > gcc5.3 from ports. The DDB stack trace doesn't get very far: > > panic: kernel stack overflow - trapframe at 0xffffffff80699eb0 > KDB: stack backtrace: > db_trace_self+1c (?,?,?,?) ra ffffffff801620d8 sp ffffffff80699ac0 sz 16 > ffffffff801620ac+2c (?,?,?,?) ra ffffffff80357788 sp ffffffff80699ad0 sz 800 > ffffffff80357744+44 (?,?,?,?) ra ffffffff80304ff4 sp ffffffff80699df0 sz 16 > vpanic+f4 (?,?,?,?) ra ffffffff80305d84 sp ffffffff80699e00 sz 48 > panic+30 (?,ffffffff80699eb0,ffffffffffffffec,ffffffff802c901c) ra ffffffff805388bc sp ffffffff80699e30 sz 96 > MipsTLBInvalidException+360 (?,?,?,?) ra 0 sp ffffffff80699e90 sz 0 > --- Kernel Stack Overflow --- > ffffffff802c9018+4 (?,?,?,?) ra ffffffff805544e4 sp c00000002a5b5fa0 sz 96 > ffffffff80554400+e4 (?,?,?,?) ra ffffffff802c90f4 sp c00000002a5b6000 sz 48 > ffffffff802c9018+dc (?,?,?,?) ra ffffffff805563dc sp c00000002a5b6030 sz 96 > cpu_intr+248 (?,?,?,?) ra ffffffff80538110 sp c00000002a5b6090 sz 80 > MipsKernIntr+188 (?,?,?,?) ra 0 sp c00000002a5b60e0 sz 368 > pid 607 > KDB: enter: panic > > (In particular, we probably should be using the trapframe logic employed > here for MipsKernIntr.) > > I've patched kgdb to add a MIPS kernel target and taught it how to handle > trapframes, etc. (and it can cross-debug, so I used an amd64 host to examine > the dump) and it gives a more useful stack trace. Unfortunately, increasing > the kstack size on MIPS as a workaround for this issue seems to be very > hard as the code in cpu_switch() hard codes exactly two TLB entries to cover > the kernel stack and PCB to avoid TLB faults during a context switch. I think > if you create a kthread with a non-default kstack size on MIPS it's probably > a ticking time bomb in that you might get a TLB miss when accessing the pcb. > > savectx () at /usr/home/john/work/git/freebsd/sys/mips/mips/swtch.S:171 > 171 SAVE_U_PCB_CONTEXT(ra, PCB_REG_PC, a0) > (kgdb) where > #0 savectx () at /usr/home/john/work/git/freebsd/sys/mips/mips/swtch.S:171 > #1 0xffffffff80304dfc in doadump (textdump=textdump@entry=0) > at /usr/home/john/work/git/freebsd/sys/kern/kern_shutdown.c:297 > #2 0xffffffff8015d868 in db_dump (dummy=, > dummy2=, dummy3=, dummy4=) > at /usr/home/john/work/git/freebsd/sys/ddb/db_command.c:546 > #3 0xffffffff8015e474 in db_command ( > last_cmdp=last_cmdp@entry=0xffffffff8069e778 , > cmd_table=, > cmd_table@entry=0xffffffff8069e730 , dopager=dopager@entry=1) > at /usr/home/john/work/git/freebsd/sys/ddb/db_command.c:453 > #4 0xffffffff8015eab8 in db_command_loop () > at /usr/home/john/work/git/freebsd/sys/ddb/db_command.c:506 > #5 0xffffffff80162040 in db_trap (type=, code=) > at /usr/home/john/work/git/freebsd/sys/ddb/db_main.c:248 > #6 0xffffffff803583e8 in kdb_trap (type=type@entry=9, code=code@entry=0, > tf=tf@entry=0xffffffff80699ca0 ) > at /usr/home/john/work/git/freebsd/sys/kern/subr_kdb.c:654 > #7 0xffffffff8054ba10 in trap (trapframe=0xffffffff80699ca0 ) > at /usr/home/john/work/git/freebsd/sys/mips/mips/trap.c:828 > #8 > #9 kdb_enter (why=0xffffffff805b6138 "panic", msg=) > at /usr/home/john/work/git/freebsd/sys/kern/subr_kdb.c:444 > #10 0xffffffff8030503c in vpanic (fmt=, > ap=ap@entry=0xffffffff80699e58 ) > at /usr/home/john/work/git/freebsd/sys/kern/kern_shutdown.c:752 > ---Type to continue, or q to quit--- > #11 0xffffffff80305d84 in panic (fmt=) > at /usr/home/john/work/git/freebsd/sys/kern/kern_shutdown.c:690 > #12 > #13 0xffffffff802c901c in intr_event_handle (ie=0x9800000000a42400, > frame=frame@entry=0x0) > at /usr/home/john/work/git/freebsd/sys/kern/kern_intr.c:1397 > #14 0xffffffff805544e4 in gt_pci_intr (v=0x9800000000ab0800) > at /usr/home/john/work/git/freebsd/sys/mips/malta/gt_pci.c:236 > #15 0xffffffff802c90f4 in intr_event_handle (ie=0x9800000000a43900, > frame=frame@entry=0xc00000002a5b6100) > at /usr/home/john/work/git/freebsd/sys/kern/kern_intr.c:1436 > #16 0xffffffff805563dc in cpu_intr (tf=0xc00000002a5b6100) > at /usr/home/john/work/git/freebsd/sys/mips/mips/intr_machdep.c:264 > #17 > #18 le_pci_wrcsr (sc=0x9800000000ae9400, port=, > val=) > at /usr/home/john/work/git/freebsd/sys/dev/le/if_le_pci.c:187 > #19 0xffffffff801893e4 in am79900_start_locked (sc=0x9800000000ae9400) > at /usr/home/john/work/git/freebsd/sys/dev/le/am79900.c:594 > #20 0xffffffff8018b1c0 in lance_start (ifp=) > at /usr/home/john/work/git/freebsd/sys/dev/le/lance.c:243 > #21 0xffffffff804137e4 in if_start (ifp=ifp@entry=0x9800000000ae4800) > at /usr/home/john/work/git/freebsd/sys/net/if.c:3630 > #22 0xffffffff80413998 in if_transmit (ifp=0x9800000000ae4800, > m=) at /usr/home/john/work/git/freebsd/sys/net/if.c:3642 > #23 0xffffffff804174fc in ether_output_frame ( > ---Type to continue, or q to quit--- > ifp=ifp@entry=0x9800000000ae4800, m=0x980000000162d100) > at /usr/home/john/work/git/freebsd/sys/net/if_ethersubr.c:457 > #24 0xffffffff80417b94 in ether_output (ifp=0x9800000000ae4800, > m=0x980000000162d100, dst=0x98000000032878f0, ro=) > at /usr/home/john/work/git/freebsd/sys/net/if_ethersubr.c:429 > #25 0xffffffff8045cf28 in ip_output (m=m@entry=0x980000000162d100, > opt=, ro=0x98000000032878d0, flags=, > imo=, imo@entry=0x0, inp=) > at /usr/home/john/work/git/freebsd/sys/netinet/ip_output.c:664 > #26 0xffffffff80470348 in tcp_output (tp=0x9800000001f4f000) > at /usr/home/john/work/git/freebsd/sys/netinet/tcp_output.c:1432 > #27 0xffffffff80480d1c in tcp_usr_send (so=0x98000000032a8a20, > flags=, m=0x9800000001621a00, nam=0x0, > control=, td=0x9800000003275a60) > at /usr/home/john/work/git/freebsd/sys/netinet/tcp_usrreq.c:956 > #28 0xffffffff803a6ef8 in sosend_generic (so=0x98000000032a8a20, > addr=, uio=0x0, top=0x9800000001621a00, > control=, flags=, td=) > at /usr/home/john/work/git/freebsd/sys/kern/uipc_socket.c:1359 > #29 0xffffffff803a7060 in sosend (so=, addr=addr@entry=0x0, > uio=uio@entry=0x0, top=top@entry=0x9800000001621a00, > control=control@entry=0x0, flags=flags@entry=0, td=) > at /usr/home/john/work/git/freebsd/sys/kern/uipc_socket.c:1403 > #30 0xffffffff8049220c in clnt_vc_call (cl=, > ext=0xc00000002a5b69e8, proc=, args=0x980000000162d200, > resultsp=0xc00000002a5b6b40, utimeout=...) > ---Type to continue, or q to quit--- > at /usr/home/john/work/git/freebsd/sys/rpc/clnt_vc.c:398 > #31 0xffffffff804908a4 in clnt_reconnect_call (cl=0x9800000001630400, > ext=0xc00000002a5b69e8, proc=, args=0x980000000162d200, > resultsp=0xc00000002a5b6b40, utimeout=...) > at /usr/home/john/work/git/freebsd/sys/rpc/clnt_rc.c:271 > #32 0xffffffff801dd360 in newnfs_request (nd=0xc00000002a5b6b40, > nmp=0x980000000163b800, clp=clp@entry=0x0, nrp=0x980000000163b928, > vp=0x98000000044aa000, td=td@entry=0x9800000003275a60, > cred=cred@entry=0x9800000001670000, prog=prog@entry=100003, vers=3, > retsum=retsum@entry=0x0, toplevel=toplevel@entry=1, xidp=xidp@entry=0x0, > sep=sep@entry=0x0) > at /usr/home/john/work/git/freebsd/sys/fs/nfs/nfs_commonkrpc.c:746 > #33 0xffffffff8022c738 in nfscl_request (nd=nd@entry=0xc00000002a5b6b40, > vp=vp@entry=0x98000000044aa000, p=p@entry=0x9800000003275a60, > cred=cred@entry=0x9800000001670000, stuff=stuff@entry=0x0) > at /usr/home/john/work/git/freebsd/sys/fs/nfsclient/nfs_clport.c:951 > #34 0xffffffff802116a8 in nfsrpc_commit (vp=0x98000000044aa000, > offset=offset@entry=65536, cnt=cnt@entry=65536, > cred=cred@entry=0x9800000001670000, p=p@entry=0x9800000003275a60, > nap=nap@entry=0xc00000002a5b6cc0, > attrflagp=attrflagp@entry=0xc00000002a5b6d88, stuff=stuff@entry=0x0) > at /usr/home/john/work/git/freebsd/sys/fs/nfsclient/nfs_clrpcops.c:3640 > #35 0xffffffff80220e74 in ncl_commit (vp=vp@entry=0x98000000044aa000, > offset=offset@entry=65536, cnt=, > cred=cred@entry=0x9800000001670000, td=td@entry=0x9800000003275a60) > at /usr/home/john/work/git/freebsd/sys/fs/nfsclient/nfs_clvnops.c:2553 > ---Type to continue, or q to quit--- > #36 0xffffffff8022130c in ncl_flush (vp=0x98000000044aa000, > waitfor=, cred=cred@entry=0x0, td=0x9800000003275a60, > commit=commit@entry=1, > called_from_renewthread=called_from_renewthread@entry=0) > at /usr/home/john/work/git/freebsd/sys/fs/nfsclient/nfs_clvnops.c:2774 > #37 0xffffffff8022220c in nfs_fsync (ap=) > at /usr/home/john/work/git/freebsd/sys/fs/nfsclient/nfs_clvnops.c:2619 > #38 0xffffffff80559508 in VOP_FSYNC_APV (vop=, > a=a@entry=0xc00000002a5b6fa0) at vnode_if.c:1331 > #39 0xffffffff803bcbd4 in VOP_FSYNC (td=, > waitfor=, vp=) at vnode_if.h:549 > #40 bufsync (bo=, waitfor=) > at /usr/home/john/work/git/freebsd/sys/kern/vfs_bio.c:4605 > #41 0xffffffff803e6088 in bufobj_invalbuf (bo=bo@entry=0x98000000044aa0d0, > flags=, slpflag=, slptimeo=) > at /usr/home/john/work/git/freebsd/sys/kern/vfs_subr.c:1633 > #42 0xffffffff803e63a8 in vinvalbuf (vp=vp@entry=0x98000000044aa000, > flags=flags@entry=1, slpflag=slpflag@entry=0, slptimeo=slptimeo@entry=0) > at /usr/home/john/work/git/freebsd/sys/kern/vfs_subr.c:1711 > #43 0xffffffff8022df5c in ncl_vinvalbuf (vp=vp@entry=0x98000000044aa000, > flags=flags@entry=1, td=td@entry=0x9800000003275a60, > intrflg=, intrflg@entry=1) > at /usr/home/john/work/git/freebsd/sys/fs/nfsclient/nfs_clbio.c:1387 > #44 0xffffffff8021d5ec in nfs_setattr (ap=0xc00000002a5b7298) > at /usr/home/john/work/git/freebsd/sys/fs/nfsclient/nfs_clvnops.c:937 > #45 0xffffffff80558564 in VOP_SETATTR_APV (vop=, > ---Type to continue, or q to quit--- > a=a@entry=0xc00000002a5b7298) at vnode_if.c:799 > #46 0xffffffff80230eac in VOP_SETATTR (cred=0x9800000001670000, > vap=0xc00000002a5b71f0, vp=0x98000000044aa000) at vnode_if.h:335 > #47 ncl_write (ap=) > at /usr/home/john/work/git/freebsd/sys/fs/nfsclient/nfs_clbio.c:1280 > #48 0xffffffff80558b70 in VOP_WRITE_APV (vop=, > a=a@entry=0xc00000002a5b74f0) at vnode_if.c:1000 > #49 0xffffffff803f9708 in VOP_WRITE (cred=, > ioflag=, uio=0xc00000002a5b7690, vp=) > at vnode_if.h:413 > #50 vn_io_fault_doio (args=args@entry=0xc00000002a5b76d8, > uio=uio@entry=0xc00000002a5b7690, td=td@entry=0x9800000003275a60) > at /usr/home/john/work/git/freebsd/sys/kern/vfs_vnops.c:952 > #51 0xffffffff803f9894 in vn_io_fault1 (vp=vp@entry=0x98000000044aa000, > uio=uio@entry=0xc00000002a5b7690, args=args@entry=0xc00000002a5b76d8, > td=td@entry=0x9800000003275a60) > at /usr/home/john/work/git/freebsd/sys/kern/vfs_vnops.c:1060 > #52 0xffffffff803fca30 in vn_rdwr (rw=rw@entry=UIO_WRITE, > vp=vp@entry=0x98000000044aa000, base=base@entry=0x160085000, > len=len@entry=16384, offset=offset@entry=131072, > segflg=segflg@entry=UIO_USERSPACE, ioflg=ioflg@entry=16641, > active_cred=active_cred@entry=0x9800000001670000, > file_cred=file_cred@entry=0x0, aresid=aresid@entry=0xc00000002a5b77a0, > td=td@entry=0x9800000003275a60) > at /usr/home/john/work/git/freebsd/sys/kern/vfs_vnops.c:576 > #53 0xffffffff803fcc68 in vn_rdwr_inchunks (rw=rw@entry=UIO_WRITE, > ---Type to continue, or q to quit--- > vp=0x98000000044aa000, base=0x160085000, len=16384, offset=131072, > offset@entry=98304, segflg=segflg@entry=UIO_USERSPACE, > ioflg=ioflg@entry=16641, active_cred=0x9800000001670000, file_cred=0x0, > aresid=aresid@entry=0x0, td=0x9800000003275a60) > at /usr/home/john/work/git/freebsd/sys/kern/vfs_vnops.c:641 > #54 0xffffffff802954f4 in core_write (seg=UIO_USERSPACE, offset=98304, > len=, base=, p=0xc00000002a5b7860) > at /usr/home/john/work/git/freebsd/sys/kern/imgact_elf.c:1229 > #55 core_output (tmpbuf=0x0, p=0xc00000002a5b7860, offset=98304, > len=, base=) > at /usr/home/john/work/git/freebsd/sys/kern/imgact_elf.c:1243 > #56 elf64_coredump (td=, vp=0x98000000044aa000, > limit=9223372036854775807, flags=) > at /usr/home/john/work/git/freebsd/sys/kern/imgact_elf.c:1384 > #57 0xffffffff8030805c in coredump (td=td@entry=0x9800000003275a60) > at /usr/home/john/work/git/freebsd/sys/kern/kern_sig.c:3477 > #58 0xffffffff8030b818 in sigexit (td=td@entry=0x9800000003275a60, > sig=sig@entry=7) > at /usr/home/john/work/git/freebsd/sys/kern/kern_sig.c:3072 > #59 0xffffffff8030c19c in postsig (sig=sig@entry=7) > at /usr/home/john/work/git/freebsd/sys/kern/kern_sig.c:2985 > #60 0xffffffff8036f13c in ast (framep=0xc00000002a5b7d30) > at /usr/home/john/work/git/freebsd/sys/kern/subr_trap.c:314 > #61 > #62 0x0000000120000ff4 in ?? () > Backtrace stopped: previous frame identical to this frame (corrupt stack?) > > -- > John Baldwin > From owner-svn-src-head@freebsd.org Fri Dec 23 21:56:10 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 41BCFC8EB8C; Fri, 23 Dec 2016 21:56:10 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 029E51E4A; Fri, 23 Dec 2016 21:56:09 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBNLu9XM056454; Fri, 23 Dec 2016 21:56:09 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBNLu9Bt056452; Fri, 23 Dec 2016 21:56:09 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201612232156.uBNLu9Bt056452@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 23 Dec 2016 21:56:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310489 - head/sys/cam/scsi X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Fri, 23 Dec 2016 21:56:10 -0000 Author: mav Date: Fri Dec 23 21:56:08 2016 New Revision: 310489 URL: https://svnweb.freebsd.org/changeset/base/310489 Log: Implement printing forwarded sense data. MFC after: 2 weeks Modified: head/sys/cam/scsi/scsi_all.c head/sys/cam/scsi/scsi_all.h Modified: head/sys/cam/scsi/scsi_all.c ============================================================================== --- head/sys/cam/scsi/scsi_all.c Fri Dec 23 20:14:05 2016 (r310488) +++ head/sys/cam/scsi/scsi_all.c Fri Dec 23 21:56:08 2016 (r310489) @@ -4711,6 +4711,26 @@ scsi_sense_ata_sbuf(struct sbuf *sb, str sbuf_printf(sb, "device: %02x, ", res->device); } +void +scsi_sense_forwarded_sbuf(struct sbuf *sb, struct scsi_sense_data *sense, + u_int sense_len, uint8_t *cdb, int cdb_len, + struct scsi_inquiry_data *inq_data, + struct scsi_sense_desc_header *header) +{ + struct scsi_sense_forwarded *forwarded; + const char *sense_key_desc; + const char *asc_desc; + int error_code, sense_key, asc, ascq; + + forwarded = (struct scsi_sense_forwarded *)header; + scsi_extract_sense_len((struct scsi_sense_data *)forwarded->sense_data, + forwarded->length - 2, &error_code, &sense_key, &asc, &ascq, 1); + scsi_sense_desc(sense_key, asc, ascq, NULL, &sense_key_desc, &asc_desc); + + sbuf_printf(sb, "Forwarded sense: %s asc:%x,%x (%s): ", + sense_key_desc, asc, ascq, asc_desc); +} + /* * Generic sense descriptor printing routine. This is used when we have * not yet implemented a specific printing routine for this descriptor. @@ -4758,7 +4778,8 @@ struct scsi_sense_desc_printer { {SSD_DESC_STREAM, scsi_sense_stream_sbuf}, {SSD_DESC_BLOCK, scsi_sense_block_sbuf}, {SSD_DESC_ATA, scsi_sense_ata_sbuf}, - {SSD_DESC_PROGRESS, scsi_sense_progress_sbuf} + {SSD_DESC_PROGRESS, scsi_sense_progress_sbuf}, + {SSD_DESC_FORWARDED, scsi_sense_forwarded_sbuf} }; void Modified: head/sys/cam/scsi/scsi_all.h ============================================================================== --- head/sys/cam/scsi/scsi_all.h Fri Dec 23 20:14:05 2016 (r310488) +++ head/sys/cam/scsi/scsi_all.h Fri Dec 23 21:56:08 2016 (r310489) @@ -3532,6 +3532,8 @@ struct scsi_sense_forwarded #define SSD_FORWARDED_SDS_UNK 0x00 #define SSD_FORWARDED_SDS_EXSRC 0x01 #define SSD_FORWARDED_SDS_EXDST 0x02 + uint8_t status; + uint8_t sense_data[]; }; /* @@ -3764,6 +3766,10 @@ void scsi_sense_ata_sbuf(struct sbuf *sb u_int sense_len, uint8_t *cdb, int cdb_len, struct scsi_inquiry_data *inq_data, struct scsi_sense_desc_header *header); +void scsi_sense_forwarded_sbuf(struct sbuf *sb, struct scsi_sense_data *sense, + u_int sense_len, uint8_t *cdb, int cdb_len, + struct scsi_inquiry_data *inq_data, + struct scsi_sense_desc_header *header); void scsi_sense_generic_sbuf(struct sbuf *sb, struct scsi_sense_data *sense, u_int sense_len, uint8_t *cdb, int cdb_len, struct scsi_inquiry_data *inq_data, From owner-svn-src-head@freebsd.org Fri Dec 23 22:54:57 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3111CC8E8A6 for ; Fri, 23 Dec 2016 22:54:57 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-io0-x243.google.com (mail-io0-x243.google.com [IPv6:2607:f8b0:4001:c06::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id F31631F2C for ; Fri, 23 Dec 2016 22:54:56 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-io0-x243.google.com with SMTP id f73so33546263ioe.2 for ; Fri, 23 Dec 2016 14:54:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=brkOsluyIM8rwWu4hm3RwHSA6efQ3LvVN045RNDv+L8=; b=LtVSKg+GxU6GyupTGRCtH/BueCs3Cgvb2B8AYkNfyCcWXOaNei1DOGEPv7OQd4ce/W 4k9yOXQUkKiBQpgGtTxihhiRiRat4Pa8MknF8PwnsKR52Oo+vk1mhW9wWo9nVX+Aib+k qEtJJj4++X5FygD+MXHiLSjRYDYF3+eIt1weh+sM8+QjeGFwJ5/DUpE/CaNbp2Mk4MNl y+WKJtltLZZ76b3KLThCS6ErvftsUl1M6dqs7Zgw4IGaFizvUoyQHluE5MGPkCGdfEzQ xo0yIwAkyxA4F1vQYWhGfZT+wvivsyUIIRYe1KHSzQwmWa5CkeKEgupANs/5Qe7Rv/WY MQnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=brkOsluyIM8rwWu4hm3RwHSA6efQ3LvVN045RNDv+L8=; b=cKxRxPKvunfhgugp7A4/oh/dIfI4/ht4630rAzbZ7+HFq9gcwDx8UH5rFYsS17IF7c IToCf1HAX95pTCALlpKCSRizLJmphQ66gVacdUv/lcp6yA1Mgt8iwXizikL7gdiNwJ2T d218Wo2lHcUIsqABHvFGd25PvULXS7JXFG0MtpkgyuOMNfZExqjbCqvNDXhsMoQK/lJ/ 6x7hKuWRwjsDm3qFqfWtqVyvTm+R/LHmLob7x/9ypeHK0WBgCFM5oGno/EN23LLm016F GwDc8uvzT924hXpgC5Pil1tZnKFO1MzfTADt/b2FSxC4AMFa75Y+Ytjh+sNpPfZMEXTN vS0g== X-Gm-Message-State: AIkVDXK//QBgxBOuG1L8KKPIdcWV8Jyl7CiAMFLBqhSAQRW8XE2eVpAPnc8e6XYVKX/RwiNky1efN6He/w+fHQ== X-Received: by 10.107.198.9 with SMTP id w9mr5043050iof.19.1482533696258; Fri, 23 Dec 2016 14:54:56 -0800 (PST) MIME-Version: 1.0 Sender: wlosh@bsdimp.com Received: by 10.79.22.135 with HTTP; Fri, 23 Dec 2016 14:54:55 -0800 (PST) X-Originating-IP: [50.253.99.174] In-Reply-To: References: <201611180013.uAI0DU57087971@repo.freebsd.org> From: Warner Losh Date: Fri, 23 Dec 2016 15:54:55 -0700 X-Google-Sender-Auth: rm1onL4KlLWspjwy9erwrJlwOYM Message-ID: Subject: Re: svn commit: r308789 - head/sys/conf To: Ed Maste Cc: Gleb Smirnoff , "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Fri, 23 Dec 2016 22:54:57 -0000 On Fri, Dec 23, 2016 at 11:36 AM, Warner Losh wrote: > On Fri, Dec 23, 2016 at 9:35 AM, Ed Maste wrote: >> On 17 November 2016 at 19:13, Gleb Smirnoff wrote: >>> Author: glebius >>> Date: Fri Nov 18 00:13:30 2016 >>> New Revision: 308789 >>> URL: https://svnweb.freebsd.org/changeset/base/308789 >>> >>> Log: >>> If FreeBSD source tree is a subproject of a bigger project, then .git or >>> .hg may reside above FreeBSD sources root. Provide function findvcs() >>> that will climb up and seek for presence of a VCS directory. >> >> This can incorrectly find an unrelated .git directory and provide a >> git revision unrelated to the FreeBSD source being built. For example, >> a build from my Subversion tree now reports "FreeBSD 12.0-CURRENT #2 >> ad3f46a(master)" instead of "FreeBSD 12.0-CURRENT #5 r310482M". >> >> Can you explain your use case in a little more detail so that I can >> avoid breaking it with a change here? Do you commit FreeBSD snapshots >> into the "bigger project"? > > This is done at work (Netflix). We import all the FreeBSD revisions > from github into our repo, and then merge them into the top level > FreeBSD directory from time to time using git's subtree functionality. > We also pull in our ports tree this way (so we have a ports directory > at the same level as our FreeBSD directory). So we don't have a > $TOPSRC/.git like you would if you'd just cloned directly from github. > Our .git directory lives in $TOPSRC/.git as a result. newvers.sh > should find the 'deepest' SCM it can, and use that instead of > apparently using the topmost (I'm surprised that you have FreeBSD > under a directory that has a git checkout in it, btw, but I know that > with my dotfile management repo, that sometimes happens by mistake). > And if this somehow produces a 'tie', the tie should go to svn. > > Looking at how to fix this mess... woof. There's all kinds of crazy > here. Support for: git, git + svn, hg, p4, svn and svnlite. Sometimes > $VCS_cmd is defined if it exists at all on the system, other times > it's only defined if it exists on the system AND we think the tree is > under $VCS. > > But the base of all this woe is that findvcs is called on a per-vcs > basis, rather than being called early to match one of N VCS > signatures. It would be better off searching each directory for each > file rather than finding any file at any level. After chatting with Ed on IRC, I've posted this review. https://reviews.freebsd.org/D8895 which should fix the issues. Warner From owner-svn-src-head@freebsd.org Fri Dec 23 23:14:55 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 76748C8EBCD; Fri, 23 Dec 2016 23:14:55 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 38C5BB78; Fri, 23 Dec 2016 23:14:55 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBNNEspL090211; Fri, 23 Dec 2016 23:14:54 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBNNEr73090201; Fri, 23 Dec 2016 23:14:53 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201612232314.uBNNEr73090201@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Fri, 23 Dec 2016 23:14:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310491 - in head/sys/fs: nfs nfsclient X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Fri, 23 Dec 2016 23:14:55 -0000 Author: rmacklem Date: Fri Dec 23 23:14:53 2016 New Revision: 310491 URL: https://svnweb.freebsd.org/changeset/base/310491 Log: Fix NFSv4.1 client recovery from NFS4ERR_BAD_SESSION errors. For most NFSv4.1 servers, a NFS4ERR_BAD_SESSION error is a rare failure that indicates that the server has lost session/open/lock state. However, recent testing by cperciva@ against the AmazonEFS server found several problems with client recovery from this due to it generating this failure frequently. Briefly, the problems fixed are: - If all session slots were in use at the time of the failure, some processes would continue to loop waiting for a slot on the old session forever. - If an RPC that doesn't use open/lock state failed with NFS4ERR_BAD_SESSION, it would fail the RPC/syscall instead of initiating recovery and then looping to retry the RPC. - If a successful reply to an RPC for an old session wasn't processed until after a new session was created for a NFS4ERR_BAD_SESSION error, it would erroneously update the new session and corrupt it. - The use of the first element of the session list in the nfs mount structure (which is always the current metadata session) was slightly racey. With changes for the above problems it became more racey, so all uses of this head pointer was wrapped with a NFSLOCKMNT()/NFSUNLOCKMNT(). - Although the kernel malloc() usually allocates more bytes than requested and, as such, this wouldn't have caused problems, the allocation of a session structure was 1 byte smaller than it should have been. (Null termination byte for the string not included in byte count.) There are probably still problems with a pNFS data server that fails with NFS4ERR_BAD_SESSION, but I have no server that does this to test against (the AmazonEFS server doesn't do pNFS), so I can't fix these yet. Although this patch is fairly large, it should only affect the handling of NFS4ERR_BAD_SESSION error replies from an NFSv4.1 server. Thanks go to cperciva@ for the extension testing he did to help isolate/fix these problems. Reported by: cperciva Tested by: cperciva MFC after: 3 months Differential Revision: https://reviews.freebsd.org/D8745 Modified: head/sys/fs/nfs/nfs.h head/sys/fs/nfs/nfs_commonkrpc.c head/sys/fs/nfs/nfs_commonport.c head/sys/fs/nfs/nfs_commonsubs.c head/sys/fs/nfs/nfsclstate.h head/sys/fs/nfsclient/nfs_clcomsubs.c head/sys/fs/nfsclient/nfs_clport.c head/sys/fs/nfsclient/nfs_clrpcops.c head/sys/fs/nfsclient/nfs_clstate.c head/sys/fs/nfsclient/nfs_clvfsops.c head/sys/fs/nfsclient/nfsmount.h Modified: head/sys/fs/nfs/nfs.h ============================================================================== --- head/sys/fs/nfs/nfs.h Fri Dec 23 22:42:14 2016 (r310490) +++ head/sys/fs/nfs/nfs.h Fri Dec 23 23:14:53 2016 (r310491) @@ -601,6 +601,7 @@ struct nfsrv_descript { uint8_t nd_sessionid[NFSX_V4SESSIONID]; /* Session id */ uint32_t nd_slotid; /* Slotid for this RPC */ SVCXPRT *nd_xprt; /* Server RPC handle */ + uint32_t *nd_sequence; /* Sequence Op. ptr */ }; #define nd_princlen nd_gssnamelen @@ -636,6 +637,7 @@ struct nfsrv_descript { #define ND_HASSEQUENCE 0x04000000 #define ND_CACHETHIS 0x08000000 #define ND_LASTOP 0x10000000 +#define ND_LOOPBADSESS 0x20000000 /* * ND_GSS should be the "or" of all GSS type authentications. @@ -649,6 +651,7 @@ struct nfsv4_opflag { int modifyfs; int lktype; int needsseq; + int loopbadsess; }; /* Modified: head/sys/fs/nfs/nfs_commonkrpc.c ============================================================================== --- head/sys/fs/nfs/nfs_commonkrpc.c Fri Dec 23 22:42:14 2016 (r310490) +++ head/sys/fs/nfs/nfs_commonkrpc.c Fri Dec 23 23:14:53 2016 (r310491) @@ -89,6 +89,7 @@ uint32_t nfscl_nfs4_done_probes[NFSV41_N NFSSTATESPINLOCK; NFSREQSPINLOCK; NFSDLOCKMUTEX; +NFSCLSTATEMUTEX; extern struct nfsstatsv1 nfsstatsv1; extern struct nfsreqhead nfsd_reqq; extern int nfscl_ticks; @@ -473,13 +474,13 @@ int newnfs_request(struct nfsrv_descript *nd, struct nfsmount *nmp, struct nfsclient *clp, struct nfssockreq *nrp, vnode_t vp, struct thread *td, struct ucred *cred, u_int32_t prog, u_int32_t vers, - u_char *retsum, int toplevel, u_int64_t *xidp, struct nfsclsession *sep) + u_char *retsum, int toplevel, u_int64_t *xidp, struct nfsclsession *dssep) { - u_int32_t retseq, retval, *tl; + uint32_t retseq, retval, slotseq, *tl; time_t waituntil; int i = 0, j = 0, opcnt, set_sigset = 0, slot; int trycnt, error = 0, usegssname = 0, secflavour = AUTH_SYS; - int freeslot, timeo; + int freeslot, maxslot, reterr, slotpos, timeo; u_int16_t procnum; u_int trylater_delay = 1; struct nfs_feedback_arg nf; @@ -491,7 +492,10 @@ newnfs_request(struct nfsrv_descript *nd char *srv_principal = NULL, *clnt_principal = NULL; sigset_t oldset; struct ucred *authcred; + struct nfsclsession *sep; + uint8_t sessionid[NFSX_V4SESSIONID]; + sep = dssep; if (xidp != NULL) *xidp = 0; /* Reject requests while attempting a forced unmount. */ @@ -803,7 +807,7 @@ tryagain: nd->nd_procnum != NFSV4PROC_CBNULL) { /* If sep == NULL, set it to the default in nmp. */ if (sep == NULL && nmp != NULL) - sep = NFSMNT_MDSSESSION(nmp); + sep = nfsmnt_mdssession(nmp); /* * and now the actual NFS xdr. */ @@ -847,18 +851,25 @@ tryagain: NFSX_V4SESSIONID + 4 * NFSX_UNSIGNED); mtx_lock(&sep->nfsess_mtx); - tl += NFSX_V4SESSIONID / NFSX_UNSIGNED; - retseq = fxdr_unsigned(uint32_t, *tl++); - slot = fxdr_unsigned(int, *tl++); - freeslot = slot; - if (retseq != sep->nfsess_slotseq[slot]) - printf("retseq diff 0x%x\n", retseq); - retval = fxdr_unsigned(uint32_t, *++tl); - if ((retval + 1) < sep->nfsess_foreslots) - sep->nfsess_foreslots = (retval + 1); - else if ((retval + 1) > sep->nfsess_foreslots) - sep->nfsess_foreslots = (retval < 64) ? - (retval + 1) : 64; + if (bcmp(tl, sep->nfsess_sessionid, + NFSX_V4SESSIONID) == 0) { + tl += NFSX_V4SESSIONID / NFSX_UNSIGNED; + retseq = fxdr_unsigned(uint32_t, *tl++); + slot = fxdr_unsigned(int, *tl++); + freeslot = slot; + if (retseq != sep->nfsess_slotseq[slot]) + printf("retseq diff 0x%x\n", + retseq); + retval = fxdr_unsigned(uint32_t, *++tl); + if ((retval + 1) < sep->nfsess_foreslots + ) + sep->nfsess_foreslots = (retval + + 1); + else if ((retval + 1) > + sep->nfsess_foreslots) + sep->nfsess_foreslots = (retval + < 64) ? (retval + 1) : 64; + } mtx_unlock(&sep->nfsess_mtx); /* Grab the op and status for the next one. */ @@ -871,6 +882,76 @@ tryagain: } } if (nd->nd_repstat != 0) { + if (nd->nd_repstat == NFSERR_BADSESSION && + nmp != NULL && dssep == NULL) { + /* + * If this is a client side MDS RPC, mark + * the MDS session defunct and initiate + * recovery, as required. + * The nfsess_defunct field is protected by + * the NFSLOCKMNT()/nm_mtx lock and not the + * nfsess_mtx lock to simplify its handling, + * for the MDS session. This lock is also + * sufficient for nfsess_sessionid, since it + * never changes in the structure. + */ + NFSCL_DEBUG(1, "Got badsession\n"); + NFSLOCKCLSTATE(); + NFSLOCKMNT(nmp); + sep = NFSMNT_MDSSESSION(nmp); + if (bcmp(sep->nfsess_sessionid, nd->nd_sequence, + NFSX_V4SESSIONID) == 0) { + /* Initiate recovery. */ + sep->nfsess_defunct = 1; + NFSCL_DEBUG(1, "Marked defunct\n"); + if (nmp->nm_clp != NULL) { + nmp->nm_clp->nfsc_flags |= + NFSCLFLAGS_RECOVER; + wakeup(nmp->nm_clp); + } + } + NFSUNLOCKCLSTATE(); + /* + * Sleep for up to 1sec waiting for a new + * session. + */ + mtx_sleep(&nmp->nm_sess, &nmp->nm_mtx, PZERO, + "nfsbadsess", hz); + /* + * Get the session again, in case a new one + * has been created during the sleep. + */ + sep = NFSMNT_MDSSESSION(nmp); + NFSUNLOCKMNT(nmp); + if ((nd->nd_flag & ND_LOOPBADSESS) != 0) { + reterr = nfsv4_sequencelookup(nmp, sep, + &slotpos, &maxslot, &slotseq, + sessionid); + if (reterr == 0) { + /* Fill in new session info. */ + NFSCL_DEBUG(1, + "Filling in new sequence\n"); + tl = nd->nd_sequence; + bcopy(sessionid, tl, + NFSX_V4SESSIONID); + tl += NFSX_V4SESSIONID / + NFSX_UNSIGNED; + *tl++ = txdr_unsigned(slotseq); + *tl++ = txdr_unsigned(slotpos); + *tl = txdr_unsigned(maxslot); + } + if (reterr == NFSERR_BADSESSION || + reterr == 0) { + NFSCL_DEBUG(1, + "Badsession looping\n"); + m_freem(nd->nd_mrep); + nd->nd_mrep = NULL; + goto tryagain; + } + nd->nd_repstat = reterr; + NFSCL_DEBUG(1, "Got err=%d\n", reterr); + } + } if (((nd->nd_repstat == NFSERR_DELAY || nd->nd_repstat == NFSERR_GRACE) && (nd->nd_flag & ND_NFSV4) && Modified: head/sys/fs/nfs/nfs_commonport.c ============================================================================== --- head/sys/fs/nfs/nfs_commonport.c Fri Dec 23 22:42:14 2016 (r310490) +++ head/sys/fs/nfs/nfs_commonport.c Fri Dec 23 23:14:53 2016 (r310491) @@ -129,6 +129,7 @@ struct mtx nfs_state_mutex; struct mtx nfs_nameid_mutex; struct mtx nfs_req_mutex; struct mtx nfs_slock_mutex; +struct mtx nfs_clstate_mutex; /* local functions */ static int nfssvc_call(struct thread *, struct nfssvc_args *, struct ucred *); @@ -647,6 +648,7 @@ newnfs_portinit(void) /* Initialize SMP locks used by both client and server. */ mtx_init(&newnfsd_mtx, "newnfsd_mtx", NULL, MTX_DEF); mtx_init(&nfs_state_mutex, "nfs_state_mutex", NULL, MTX_DEF); + mtx_init(&nfs_clstate_mutex, "nfs_clstate_mutex", NULL, MTX_DEF); } /* @@ -712,6 +714,7 @@ nfscommon_modevent(module_t mod, int typ mtx_destroy(&nfs_nameid_mutex); mtx_destroy(&newnfsd_mtx); mtx_destroy(&nfs_state_mutex); + mtx_destroy(&nfs_clstate_mutex); mtx_destroy(&nfs_sockl_mutex); mtx_destroy(&nfs_slock_mutex); mtx_destroy(&nfs_req_mutex); Modified: head/sys/fs/nfs/nfs_commonsubs.c ============================================================================== --- head/sys/fs/nfs/nfs_commonsubs.c Fri Dec 23 22:42:14 2016 (r310490) +++ head/sys/fs/nfs/nfs_commonsubs.c Fri Dec 23 23:14:53 2016 (r310491) @@ -90,65 +90,65 @@ extern int nfsrv_lughashsize; * Define it here, since it is used by both the client and server. */ struct nfsv4_opflag nfsv4_opflag[NFSV41_NOPS] = { - { 0, 0, 0, 0, LK_EXCLUSIVE, 1 }, /* undef */ - { 0, 0, 0, 0, LK_EXCLUSIVE, 1 }, /* undef */ - { 0, 0, 0, 0, LK_EXCLUSIVE, 1 }, /* undef */ - { 0, 1, 0, 0, LK_SHARED, 1 }, /* Access */ - { 0, 1, 0, 0, LK_EXCLUSIVE, 1 }, /* Close */ - { 0, 2, 0, 1, LK_EXCLUSIVE, 1 }, /* Commit */ - { 1, 2, 1, 1, LK_EXCLUSIVE, 1 }, /* Create */ - { 0, 0, 0, 0, LK_EXCLUSIVE, 1 }, /* Delegpurge */ - { 0, 1, 0, 0, LK_EXCLUSIVE, 1 }, /* Delegreturn */ - { 0, 1, 0, 0, LK_SHARED, 1 }, /* Getattr */ - { 0, 1, 0, 0, LK_EXCLUSIVE, 1 }, /* GetFH */ - { 2, 1, 1, 1, LK_EXCLUSIVE, 1 }, /* Link */ - { 0, 1, 0, 0, LK_EXCLUSIVE, 1 }, /* Lock */ - { 0, 1, 0, 0, LK_EXCLUSIVE, 1 }, /* LockT */ - { 0, 1, 0, 0, LK_EXCLUSIVE, 1 }, /* LockU */ - { 1, 2, 0, 0, LK_EXCLUSIVE, 1 }, /* Lookup */ - { 1, 2, 0, 0, LK_EXCLUSIVE, 1 }, /* Lookupp */ - { 0, 1, 0, 0, LK_EXCLUSIVE, 1 }, /* NVerify */ - { 1, 1, 0, 1, LK_EXCLUSIVE, 1 }, /* Open */ - { 1, 1, 0, 0, LK_EXCLUSIVE, 1 }, /* OpenAttr */ - { 0, 1, 0, 0, LK_EXCLUSIVE, 1 }, /* OpenConfirm */ - { 0, 1, 0, 0, LK_EXCLUSIVE, 1 }, /* OpenDowngrade */ - { 1, 0, 0, 0, LK_EXCLUSIVE, 1 }, /* PutFH */ - { 1, 0, 0, 0, LK_EXCLUSIVE, 1 }, /* PutPubFH */ - { 1, 0, 0, 0, LK_EXCLUSIVE, 1 }, /* PutRootFH */ - { 0, 1, 0, 0, LK_SHARED, 1 }, /* Read */ - { 0, 1, 0, 0, LK_SHARED, 1 }, /* Readdir */ - { 0, 1, 0, 0, LK_SHARED, 1 }, /* ReadLink */ - { 0, 2, 1, 1, LK_EXCLUSIVE, 1 }, /* Remove */ - { 2, 1, 1, 1, LK_EXCLUSIVE, 1 }, /* Rename */ - { 0, 0, 0, 0, LK_EXCLUSIVE, 1 }, /* Renew */ - { 0, 0, 0, 0, LK_EXCLUSIVE, 1 }, /* RestoreFH */ - { 0, 1, 0, 0, LK_EXCLUSIVE, 1 }, /* SaveFH */ - { 0, 1, 0, 0, LK_EXCLUSIVE, 1 }, /* SecInfo */ - { 0, 2, 1, 1, LK_EXCLUSIVE, 1 }, /* Setattr */ - { 0, 0, 0, 0, LK_EXCLUSIVE, 1 }, /* SetClientID */ - { 0, 0, 0, 0, LK_EXCLUSIVE, 1 }, /* SetClientIDConfirm */ - { 0, 1, 0, 0, LK_EXCLUSIVE, 1 }, /* Verify */ - { 0, 2, 1, 1, LK_EXCLUSIVE, 1 }, /* Write */ - { 0, 0, 0, 0, LK_EXCLUSIVE, 1 }, /* ReleaseLockOwner */ - { 0, 0, 0, 0, LK_EXCLUSIVE, 1 }, /* Backchannel Ctrl */ - { 0, 0, 0, 0, LK_EXCLUSIVE, 1 }, /* Bind Conn to Sess */ - { 0, 0, 0, 0, LK_EXCLUSIVE, 0 }, /* Exchange ID */ - { 0, 0, 0, 0, LK_EXCLUSIVE, 0 }, /* Create Session */ - { 0, 0, 0, 0, LK_EXCLUSIVE, 0 }, /* Destroy Session */ - { 0, 0, 0, 0, LK_EXCLUSIVE, 1 }, /* Free StateID */ - { 0, 0, 0, 0, LK_EXCLUSIVE, 1 }, /* Get Dir Deleg */ - { 0, 0, 0, 0, LK_EXCLUSIVE, 1 }, /* Get Device Info */ - { 0, 0, 0, 0, LK_EXCLUSIVE, 1 }, /* Get Device List */ - { 0, 1, 0, 0, LK_EXCLUSIVE, 1 }, /* Layout Commit */ - { 0, 1, 0, 0, LK_EXCLUSIVE, 1 }, /* Layout Get */ - { 0, 1, 0, 0, LK_EXCLUSIVE, 1 }, /* Layout Return */ - { 0, 0, 0, 0, LK_EXCLUSIVE, 1 }, /* Secinfo No name */ - { 0, 0, 0, 0, LK_EXCLUSIVE, 1 }, /* Sequence */ - { 0, 0, 0, 0, LK_EXCLUSIVE, 1 }, /* Set SSV */ - { 0, 0, 0, 0, LK_EXCLUSIVE, 1 }, /* Test StateID */ - { 0, 0, 0, 0, LK_EXCLUSIVE, 1 }, /* Want Delegation */ - { 0, 0, 0, 0, LK_EXCLUSIVE, 0 }, /* Destroy ClientID */ - { 0, 0, 0, 0, LK_EXCLUSIVE, 1 }, /* Reclaim Complete */ + { 0, 0, 0, 0, LK_EXCLUSIVE, 1, 1 }, /* undef */ + { 0, 0, 0, 0, LK_EXCLUSIVE, 1, 1 }, /* undef */ + { 0, 0, 0, 0, LK_EXCLUSIVE, 1, 1 }, /* undef */ + { 0, 1, 0, 0, LK_SHARED, 1, 1 }, /* Access */ + { 0, 1, 0, 0, LK_EXCLUSIVE, 1, 0 }, /* Close */ + { 0, 2, 0, 1, LK_EXCLUSIVE, 1, 1 }, /* Commit */ + { 1, 2, 1, 1, LK_EXCLUSIVE, 1, 1 }, /* Create */ + { 0, 0, 0, 0, LK_EXCLUSIVE, 1, 0 }, /* Delegpurge */ + { 0, 1, 0, 0, LK_EXCLUSIVE, 1, 0 }, /* Delegreturn */ + { 0, 1, 0, 0, LK_SHARED, 1, 1 }, /* Getattr */ + { 0, 1, 0, 0, LK_EXCLUSIVE, 1, 1 }, /* GetFH */ + { 2, 1, 1, 1, LK_EXCLUSIVE, 1, 1 }, /* Link */ + { 0, 1, 0, 0, LK_EXCLUSIVE, 1, 0 }, /* Lock */ + { 0, 1, 0, 0, LK_EXCLUSIVE, 1, 0 }, /* LockT */ + { 0, 1, 0, 0, LK_EXCLUSIVE, 1, 0 }, /* LockU */ + { 1, 2, 0, 0, LK_EXCLUSIVE, 1, 1 }, /* Lookup */ + { 1, 2, 0, 0, LK_EXCLUSIVE, 1, 1 }, /* Lookupp */ + { 0, 1, 0, 0, LK_EXCLUSIVE, 1, 1 }, /* NVerify */ + { 1, 1, 0, 1, LK_EXCLUSIVE, 1, 0 }, /* Open */ + { 1, 1, 0, 0, LK_EXCLUSIVE, 1, 0 }, /* OpenAttr */ + { 0, 1, 0, 0, LK_EXCLUSIVE, 1, 0 }, /* OpenConfirm */ + { 0, 1, 0, 0, LK_EXCLUSIVE, 1, 0 }, /* OpenDowngrade */ + { 1, 0, 0, 0, LK_EXCLUSIVE, 1, 1 }, /* PutFH */ + { 1, 0, 0, 0, LK_EXCLUSIVE, 1, 1 }, /* PutPubFH */ + { 1, 0, 0, 0, LK_EXCLUSIVE, 1, 1 }, /* PutRootFH */ + { 0, 1, 0, 0, LK_SHARED, 1, 0 }, /* Read */ + { 0, 1, 0, 0, LK_SHARED, 1, 1 }, /* Readdir */ + { 0, 1, 0, 0, LK_SHARED, 1, 1 }, /* ReadLink */ + { 0, 2, 1, 1, LK_EXCLUSIVE, 1, 1 }, /* Remove */ + { 2, 1, 1, 1, LK_EXCLUSIVE, 1, 1 }, /* Rename */ + { 0, 0, 0, 0, LK_EXCLUSIVE, 1, 0 }, /* Renew */ + { 0, 0, 0, 0, LK_EXCLUSIVE, 1, 1 }, /* RestoreFH */ + { 0, 1, 0, 0, LK_EXCLUSIVE, 1, 1 }, /* SaveFH */ + { 0, 1, 0, 0, LK_EXCLUSIVE, 1, 1 }, /* SecInfo */ + { 0, 2, 1, 1, LK_EXCLUSIVE, 1, 0 }, /* Setattr */ + { 0, 0, 0, 0, LK_EXCLUSIVE, 1, 1 }, /* SetClientID */ + { 0, 0, 0, 0, LK_EXCLUSIVE, 1, 1 }, /* SetClientIDConfirm */ + { 0, 1, 0, 0, LK_EXCLUSIVE, 1, 1 }, /* Verify */ + { 0, 2, 1, 1, LK_EXCLUSIVE, 1, 0 }, /* Write */ + { 0, 0, 0, 0, LK_EXCLUSIVE, 1, 0 }, /* ReleaseLockOwner */ + { 0, 0, 0, 0, LK_EXCLUSIVE, 1, 1 }, /* Backchannel Ctrl */ + { 0, 0, 0, 0, LK_EXCLUSIVE, 1, 1 }, /* Bind Conn to Sess */ + { 0, 0, 0, 0, LK_EXCLUSIVE, 0, 0 }, /* Exchange ID */ + { 0, 0, 0, 0, LK_EXCLUSIVE, 0, 0 }, /* Create Session */ + { 0, 0, 0, 0, LK_EXCLUSIVE, 0, 0 }, /* Destroy Session */ + { 0, 0, 0, 0, LK_EXCLUSIVE, 1, 0 }, /* Free StateID */ + { 0, 0, 0, 0, LK_EXCLUSIVE, 1, 1 }, /* Get Dir Deleg */ + { 0, 0, 0, 0, LK_EXCLUSIVE, 1, 1 }, /* Get Device Info */ + { 0, 0, 0, 0, LK_EXCLUSIVE, 1, 1 }, /* Get Device List */ + { 0, 1, 0, 0, LK_EXCLUSIVE, 1, 1 }, /* Layout Commit */ + { 0, 1, 0, 0, LK_EXCLUSIVE, 1, 1 }, /* Layout Get */ + { 0, 1, 0, 0, LK_EXCLUSIVE, 1, 0 }, /* Layout Return */ + { 0, 0, 0, 0, LK_EXCLUSIVE, 1, 1 }, /* Secinfo No name */ + { 0, 0, 0, 0, LK_EXCLUSIVE, 1, 0 }, /* Sequence */ + { 0, 0, 0, 0, LK_EXCLUSIVE, 1, 1 }, /* Set SSV */ + { 0, 0, 0, 0, LK_EXCLUSIVE, 1, 1 }, /* Test StateID */ + { 0, 0, 0, 0, LK_EXCLUSIVE, 1, 1 }, /* Want Delegation */ + { 0, 0, 0, 0, LK_EXCLUSIVE, 0, 0 }, /* Destroy ClientID */ + { 0, 0, 0, 0, LK_EXCLUSIVE, 1, 1 }, /* Reclaim Complete */ }; #endif /* !APPLEKEXT */ @@ -4130,22 +4130,35 @@ nfsv4_setsequence(struct nfsmount *nmp, error = nfsv4_sequencelookup(nmp, sep, &slotpos, &maxslot, &slotseq, sessionid); - if (error != 0) - return; - KASSERT(maxslot >= 0, ("nfscl_setsequence neg maxslot")); /* Build the Sequence arguments. */ NFSM_BUILD(tl, uint32_t *, NFSX_V4SESSIONID + 4 * NFSX_UNSIGNED); + nd->nd_sequence = tl; bcopy(sessionid, tl, NFSX_V4SESSIONID); tl += NFSX_V4SESSIONID / NFSX_UNSIGNED; nd->nd_slotseq = tl; - *tl++ = txdr_unsigned(slotseq); - *tl++ = txdr_unsigned(slotpos); - *tl++ = txdr_unsigned(maxslot); - if (dont_replycache == 0) - *tl = newnfs_true; - else - *tl = newnfs_false; + if (error == 0) { + *tl++ = txdr_unsigned(slotseq); + *tl++ = txdr_unsigned(slotpos); + *tl++ = txdr_unsigned(maxslot); + if (dont_replycache == 0) + *tl = newnfs_true; + else + *tl = newnfs_false; + } else { + /* + * There are two errors and the rest of the session can + * just be zeros. + * NFSERR_BADSESSION: This bad session should just generate + * the same error again when the RPC is retried. + * ESTALE: A forced dismount is in progress and will cause the + * RPC to fail later. + */ + *tl++ = 0; + *tl++ = 0; + *tl++ = 0; + *tl = 0; + } nd->nd_flag |= ND_HASSEQUENCE; } @@ -4161,6 +4174,13 @@ nfsv4_sequencelookup(struct nfsmount *nm maxslot = -1; mtx_lock(&sep->nfsess_mtx); do { + if (nmp != NULL && sep->nfsess_defunct != 0) { + /* Just return the bad session. */ + bcopy(sep->nfsess_sessionid, sessionid, + NFSX_V4SESSIONID); + mtx_unlock(&sep->nfsess_mtx); + return (NFSERR_BADSESSION); + } bitval = 1; for (i = 0; i < sep->nfsess_foreslots; i++) { if ((bitval & sep->nfsess_slots) == 0) { Modified: head/sys/fs/nfs/nfsclstate.h ============================================================================== --- head/sys/fs/nfs/nfsclstate.h Fri Dec 23 22:42:14 2016 (r310490) +++ head/sys/fs/nfs/nfsclstate.h Fri Dec 23 23:14:53 2016 (r310491) @@ -65,6 +65,7 @@ struct nfsclsession { uint16_t nfsess_foreslots; uint16_t nfsess_backslots; uint8_t nfsess_sessionid[NFSX_V4SESSIONID]; + uint8_t nfsess_defunct; /* Non-zero for old sessions */ }; /* Modified: head/sys/fs/nfsclient/nfs_clcomsubs.c ============================================================================== --- head/sys/fs/nfsclient/nfs_clcomsubs.c Fri Dec 23 22:42:14 2016 (r310490) +++ head/sys/fs/nfsclient/nfs_clcomsubs.c Fri Dec 23 23:14:53 2016 (r310491) @@ -200,13 +200,16 @@ nfscl_reqstart(struct nfsrv_descript *nd *tl = txdr_unsigned(opcnt); if ((nd->nd_flag & ND_NFSV41) != 0 && nfsv4_opflag[nfsv4_opmap[procnum].op].needsseq > 0) { + if (nfsv4_opflag[nfsv4_opmap[procnum].op].loopbadsess > + 0) + nd->nd_flag |= ND_LOOPBADSESS; NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED); *tl = txdr_unsigned(NFSV4OP_SEQUENCE); - if (sep == NULL) - nfsv4_setsequence(nmp, nd, - NFSMNT_MDSSESSION(nmp), + if (sep == NULL) { + sep = nfsmnt_mdssession(nmp); + nfsv4_setsequence(nmp, nd, sep, nfs_bigreply[procnum]); - else + } else nfsv4_setsequence(nmp, nd, sep, nfs_bigreply[procnum]); } Modified: head/sys/fs/nfsclient/nfs_clport.c ============================================================================== --- head/sys/fs/nfsclient/nfs_clport.c Fri Dec 23 22:42:14 2016 (r310490) +++ head/sys/fs/nfsclient/nfs_clport.c Fri Dec 23 23:14:53 2016 (r310491) @@ -82,7 +82,6 @@ extern short nfsv4_cbport; extern int nfscl_enablecallb; extern int nfs_numnfscbd; extern int nfscl_inited; -struct mtx nfs_clstate_mutex; struct mtx ncl_iod_mutex; NFSDLOCKMUTEX; @@ -1381,8 +1380,6 @@ nfscl_modevent(module_t mod, int type, v if (loaded) return (0); newnfs_portinit(); - mtx_init(&nfs_clstate_mutex, "nfs_clstate_mutex", NULL, - MTX_DEF); mtx_init(&ncl_iod_mutex, "ncl_iod_mutex", NULL, MTX_DEF); nfscl_init(); NFSD_LOCK(); @@ -1406,7 +1403,6 @@ nfscl_modevent(module_t mod, int type, v ncl_call_invalcaches = NULL; nfsd_call_nfscl = NULL; /* and get rid of the mutexes */ - mtx_destroy(&nfs_clstate_mutex); mtx_destroy(&ncl_iod_mutex); loaded = 0; break; Modified: head/sys/fs/nfsclient/nfs_clrpcops.c ============================================================================== --- head/sys/fs/nfsclient/nfs_clrpcops.c Fri Dec 23 22:42:14 2016 (r310490) +++ head/sys/fs/nfsclient/nfs_clrpcops.c Fri Dec 23 23:14:53 2016 (r310491) @@ -384,6 +384,7 @@ nfsrpc_openrpc(struct nfsmount *nmp, vno u_int32_t rflags, deleg; nfsattrbit_t attrbits; int error, ret, acesize, limitby; + struct nfsclsession *tsep; dp = *dpp; *dpp = NULL; @@ -392,8 +393,9 @@ nfsrpc_openrpc(struct nfsmount *nmp, vno *tl++ = txdr_unsigned(op->nfso_own->nfsow_seqid); *tl++ = txdr_unsigned(mode & NFSV4OPEN_ACCESSBOTH); *tl++ = txdr_unsigned((mode >> NFSLCK_SHIFT) & NFSV4OPEN_DENYBOTH); - *tl++ = NFSMNT_MDSSESSION(nmp)->nfsess_clientid.lval[0]; - *tl = NFSMNT_MDSSESSION(nmp)->nfsess_clientid.lval[1]; + tsep = nfsmnt_mdssession(nmp); + *tl++ = tsep->nfsess_clientid.lval[0]; + *tl = tsep->nfsess_clientid.lval[1]; (void) nfsm_strtom(nd, op->nfso_own->nfsow_owner, NFSV4CL_LOCKNAMELEN); NFSM_BUILD(tl, u_int32_t *, 2 * NFSX_UNSIGNED); *tl++ = txdr_unsigned(NFSV4OPEN_NOCREATE); @@ -557,7 +559,7 @@ nfsrpc_openrpc(struct nfsmount *nmp, vno } if (nd->nd_repstat != 0 && error == 0) error = nd->nd_repstat; - if (error == NFSERR_STALECLIENTID || error == NFSERR_BADSESSION) + if (error == NFSERR_STALECLIENTID) nfscl_initiate_recovery(op->nfso_own->nfsow_clp); nfsmout: if (!error) @@ -604,7 +606,7 @@ nfsrpc_opendowngrade(vnode_t vp, u_int32 } if (nd->nd_repstat && error == 0) error = nd->nd_repstat; - if (error == NFSERR_STALESTATEID || error == NFSERR_BADSESSION) + if (error == NFSERR_STALESTATEID) nfscl_initiate_recovery(op->nfso_own->nfsow_clp); nfsmout: mbuf_freem(nd->nd_mrep); @@ -762,7 +764,7 @@ nfsrpc_closerpc(struct nfsrv_descript *n if (nd->nd_repstat == 0) NFSM_DISSECT(tl, u_int32_t *, NFSX_STATEID); error = nd->nd_repstat; - if (error == NFSERR_STALESTATEID || error == NFSERR_BADSESSION) + if (error == NFSERR_STALESTATEID) nfscl_initiate_recovery(op->nfso_own->nfsow_clp); nfsmout: mbuf_freem(nd->nd_mrep); @@ -803,7 +805,7 @@ nfsrpc_openconfirm(vnode_t vp, u_int8_t op->nfso_stateid.other[2] = *tl; } error = nd->nd_repstat; - if (error == NFSERR_STALESTATEID || error == NFSERR_BADSESSION) + if (error == NFSERR_STALESTATEID) nfscl_initiate_recovery(op->nfso_own->nfsow_clp); nfsmout: mbuf_freem(nd->nd_mrep); @@ -828,33 +830,53 @@ nfsrpc_setclient(struct nfsmount *nmp, s nfsquad_t confirm; u_int32_t lease; static u_int32_t rev = 0; - struct nfsclds *dsp, *ndsp, *tdsp; + struct nfsclds *dsp; struct in6_addr a6; + struct nfsclsession *tsep; if (nfsboottime.tv_sec == 0) NFSSETBOOTTIME(nfsboottime); clp->nfsc_rev = rev++; if (NFSHASNFSV4N(nmp)) { + /* + * Either there was no previous session or the + * previous session has failed, so... + * do an ExchangeID followed by the CreateSession. + */ error = nfsrpc_exchangeid(nmp, clp, &nmp->nm_sockreq, NFSV4EXCH_USEPNFSMDS | NFSV4EXCH_USENONPNFS, &dsp, cred, p); NFSCL_DEBUG(1, "aft exch=%d\n", error); - if (error == 0) { + if (error == 0) error = nfsrpc_createsession(nmp, &dsp->nfsclds_sess, &nmp->nm_sockreq, dsp->nfsclds_sess.nfsess_sequenceid, 1, cred, p); - if (error == 0) { - NFSLOCKMNT(nmp); - TAILQ_FOREACH_SAFE(tdsp, &nmp->nm_sess, - nfsclds_list, ndsp) - nfscl_freenfsclds(tdsp); - TAILQ_INIT(&nmp->nm_sess); - TAILQ_INSERT_HEAD(&nmp->nm_sess, dsp, - nfsclds_list); - NFSUNLOCKMNT(nmp); - } else - nfscl_freenfsclds(dsp); - NFSCL_DEBUG(1, "aft createsess=%d\n", error); - } + if (error == 0) { + NFSLOCKMNT(nmp); + /* + * The old sessions cannot be safely free'd + * here, since they may still be used by + * in-progress RPCs. + */ + tsep = NULL; + if (TAILQ_FIRST(&nmp->nm_sess) != NULL) + tsep = NFSMNT_MDSSESSION(nmp); + TAILQ_INSERT_HEAD(&nmp->nm_sess, dsp, + nfsclds_list); + /* + * Wake up RPCs waiting for a slot on the + * old session. These will then fail with + * NFSERR_BADSESSION and be retried with the + * new session by nfsv4_setsequence(). + * Also wakeup() processes waiting for the + * new session. + */ + if (tsep != NULL) + wakeup(&tsep->nfsess_slots); + wakeup(&nmp->nm_sess); + NFSUNLOCKMNT(nmp); + } else + nfscl_freenfsclds(dsp); + NFSCL_DEBUG(1, "aft createsess=%d\n", error); if (error == 0 && reclaim == 0) { error = nfsrpc_reclaimcomplete(nmp, cred, p); NFSCL_DEBUG(1, "aft reclaimcomp=%d\n", error); @@ -875,6 +897,7 @@ nfsrpc_setclient(struct nfsmount *nmp, s mtx_init(&dsp->nfsclds_sess.nfsess_mtx, "nfssession", NULL, MTX_DEF); NFSLOCKMNT(nmp); TAILQ_INSERT_HEAD(&nmp->nm_sess, dsp, nfsclds_list); + tsep = NFSMNT_MDSSESSION(nmp); NFSUNLOCKMNT(nmp); nfscl_reqstart(nd, NFSPROC_SETCLIENTID, nmp, NULL, 0, NULL, NULL); @@ -936,8 +959,8 @@ nfsrpc_setclient(struct nfsmount *nmp, s return (error); if (nd->nd_repstat == 0) { NFSM_DISSECT(tl, u_int32_t *, 4 * NFSX_UNSIGNED); - NFSMNT_MDSSESSION(nmp)->nfsess_clientid.lval[0] = *tl++; - NFSMNT_MDSSESSION(nmp)->nfsess_clientid.lval[1] = *tl++; + tsep->nfsess_clientid.lval[0] = *tl++; + tsep->nfsess_clientid.lval[1] = *tl++; confirm.lval[0] = *tl++; confirm.lval[1] = *tl; mbuf_freem(nd->nd_mrep); @@ -949,8 +972,8 @@ nfsrpc_setclient(struct nfsmount *nmp, s nfscl_reqstart(nd, NFSPROC_SETCLIENTIDCFRM, nmp, NULL, 0, NULL, NULL); NFSM_BUILD(tl, u_int32_t *, 4 * NFSX_UNSIGNED); - *tl++ = NFSMNT_MDSSESSION(nmp)->nfsess_clientid.lval[0]; - *tl++ = NFSMNT_MDSSESSION(nmp)->nfsess_clientid.lval[1]; + *tl++ = tsep->nfsess_clientid.lval[0]; + *tl++ = tsep->nfsess_clientid.lval[1]; *tl++ = confirm.lval[0]; *tl = confirm.lval[1]; nd->nd_flag |= ND_USEGSSNAME; @@ -1111,7 +1134,7 @@ nfsrpc_setattr(vnode_t vp, struct vattr else error = nfsrpc_setaclrpc(vp, cred, p, aclp, &stateid, stuff); - if (error == NFSERR_STALESTATEID || error == NFSERR_BADSESSION) + if (error == NFSERR_STALESTATEID) nfscl_initiate_recovery(nmp->nm_clp); if (lckp != NULL) nfscl_lockderef(lckp); @@ -1368,7 +1391,7 @@ nfsrpc_read(vnode_t vp, struct uio *uiop &lckp); error = nfsrpc_readrpc(vp, uiop, newcred, &stateid, p, nap, attrflagp, stuff); - if (error == NFSERR_STALESTATEID || error == NFSERR_BADSESSION) + if (error == NFSERR_STALESTATEID) nfscl_initiate_recovery(nmp->nm_clp); if (lckp != NULL) nfscl_lockderef(lckp); @@ -1538,7 +1561,7 @@ nfsrpc_write(vnode_t vp, struct uio *uio else error = nfsrpc_writerpc(vp, uiop, iomode, must_commit, newcred, &stateid, p, nap, attrflagp, stuff); - if (error == NFSERR_STALESTATEID || error == NFSERR_BADSESSION) + if (error == NFSERR_STALESTATEID) nfscl_initiate_recovery(nmp->nm_clp); if (lckp != NULL) nfscl_lockderef(lckp); @@ -1964,6 +1987,7 @@ nfsrpc_createv4(vnode_t dvp, char *name, nfsv4stateid_t stateid; u_int32_t rflags; struct nfsmount *nmp; + struct nfsclsession *tsep; nmp = VFSTONFS(dvp->v_mount); np = VTONFS(dvp); @@ -1983,8 +2007,9 @@ nfsrpc_createv4(vnode_t dvp, char *name, *tl++ = txdr_unsigned(NFSV4OPEN_ACCESSWRITE | NFSV4OPEN_ACCESSREAD); *tl++ = txdr_unsigned(NFSV4OPEN_DENYNONE); - *tl++ = NFSMNT_MDSSESSION(nmp)->nfsess_clientid.lval[0]; - *tl = NFSMNT_MDSSESSION(nmp)->nfsess_clientid.lval[1]; + tsep = nfsmnt_mdssession(nmp); + *tl++ = tsep->nfsess_clientid.lval[0]; + *tl = tsep->nfsess_clientid.lval[1]; (void) nfsm_strtom(nd, owp->nfsow_owner, NFSV4CL_LOCKNAMELEN); NFSM_BUILD(tl, u_int32_t *, 2 * NFSX_UNSIGNED); *tl++ = txdr_unsigned(NFSV4OPEN_CREATE); @@ -2178,7 +2203,7 @@ nfsrpc_createv4(vnode_t dvp, char *name, } if (nd->nd_repstat != 0 && error == 0) error = nd->nd_repstat; - if (error == NFSERR_STALECLIENTID || error == NFSERR_BADSESSION) + if (error == NFSERR_STALECLIENTID) nfscl_initiate_recovery(owp->nfsow_clp); nfsmout: if (!error) @@ -3840,6 +3865,7 @@ nfsrpc_lockt(struct nfsrv_descript *nd, uint8_t own[NFSV4CL_LOCKNAMELEN + NFSX_V4FHMAX]; struct nfsnode *np; struct nfsmount *nmp; + struct nfsclsession *tsep; nmp = VFSTONFS(vp->v_mount); NFSCL_REQSTART(nd, NFSPROC_LOCKT, vp); @@ -3852,8 +3878,9 @@ nfsrpc_lockt(struct nfsrv_descript *nd, tl += 2; txdr_hyper(len, tl); tl += 2; - *tl++ = NFSMNT_MDSSESSION(nmp)->nfsess_clientid.lval[0]; - *tl = NFSMNT_MDSSESSION(nmp)->nfsess_clientid.lval[1]; + tsep = nfsmnt_mdssession(nmp); + *tl++ = tsep->nfsess_clientid.lval[0]; + *tl = tsep->nfsess_clientid.lval[1]; nfscl_filllockowner(id, own, flags); np = VTONFS(vp); NFSBCOPY(np->n_fhp->nfh_fh, &own[NFSV4CL_LOCKNAMELEN], @@ -3893,8 +3920,7 @@ nfsrpc_lockt(struct nfsrv_descript *nd, error = EBADRPC; if (!error) error = nfsm_advance(nd, NFSM_RNDUP(size), -1); - } else if (nd->nd_repstat == NFSERR_STALECLIENTID || - nd->nd_repstat == NFSERR_BADSESSION) + } else if (nd->nd_repstat == NFSERR_STALECLIENTID) nfscl_initiate_recovery(clp); nfsmout: mbuf_freem(nd->nd_mrep); @@ -3944,8 +3970,7 @@ nfsrpc_locku(struct nfsrv_descript *nd, lp->nfsl_stateid.other[0] = *tl++; lp->nfsl_stateid.other[1] = *tl++; lp->nfsl_stateid.other[2] = *tl; - } else if (nd->nd_repstat == NFSERR_STALESTATEID || - nd->nd_repstat == NFSERR_BADSESSION) + } else if (nd->nd_repstat == NFSERR_STALESTATEID) nfscl_initiate_recovery(lp->nfsl_open->nfso_own->nfsow_clp); nfsmout: mbuf_freem(nd->nd_mrep); @@ -3964,6 +3989,7 @@ nfsrpc_lock(struct nfsrv_descript *nd, s u_int32_t *tl; int error, size; uint8_t own[NFSV4CL_LOCKNAMELEN + NFSX_V4FHMAX]; + struct nfsclsession *tsep; nfscl_reqstart(nd, NFSPROC_LOCK, nmp, nfhp, fhlen, NULL, NULL); NFSM_BUILD(tl, u_int32_t *, 7 * NFSX_UNSIGNED); @@ -3989,8 +4015,9 @@ nfsrpc_lock(struct nfsrv_descript *nd, s *tl++ = lp->nfsl_open->nfso_stateid.other[1]; *tl++ = lp->nfsl_open->nfso_stateid.other[2]; *tl++ = txdr_unsigned(lp->nfsl_seqid); - *tl++ = NFSMNT_MDSSESSION(nmp)->nfsess_clientid.lval[0]; - *tl = NFSMNT_MDSSESSION(nmp)->nfsess_clientid.lval[1]; + tsep = nfsmnt_mdssession(nmp); + *tl++ = tsep->nfsess_clientid.lval[0]; + *tl = tsep->nfsess_clientid.lval[1]; NFSBCOPY(lp->nfsl_owner, own, NFSV4CL_LOCKNAMELEN); NFSBCOPY(nfhp, &own[NFSV4CL_LOCKNAMELEN], fhlen); (void)nfsm_strtom(nd, own, NFSV4CL_LOCKNAMELEN + fhlen); @@ -4031,8 +4058,7 @@ nfsrpc_lock(struct nfsrv_descript *nd, s error = EBADRPC; if (!error) error = nfsm_advance(nd, NFSM_RNDUP(size), -1); - } else if (nd->nd_repstat == NFSERR_STALESTATEID || - nd->nd_repstat == NFSERR_BADSESSION) + } else if (nd->nd_repstat == NFSERR_STALESTATEID) nfscl_initiate_recovery(lp->nfsl_open->nfso_own->nfsow_clp); nfsmout: mbuf_freem(nd->nd_mrep); @@ -4232,25 +4258,36 @@ nfsrpc_renew(struct nfsclclient *clp, st struct nfsmount *nmp; int error; struct nfssockreq *nrp; + struct nfsclsession *tsep; nmp = clp->nfsc_nmp; if (nmp == NULL) return (0); - nfscl_reqstart(nd, NFSPROC_RENEW, nmp, NULL, 0, NULL, - &dsp->nfsclds_sess); + if (dsp == NULL) + nfscl_reqstart(nd, NFSPROC_RENEW, nmp, NULL, 0, NULL, NULL); + else + nfscl_reqstart(nd, NFSPROC_RENEW, nmp, NULL, 0, NULL, + &dsp->nfsclds_sess); if (!NFSHASNFSV4N(nmp)) { /* NFSv4.1 just uses a Sequence Op and not a Renew. */ NFSM_BUILD(tl, u_int32_t *, 2 * NFSX_UNSIGNED); - *tl++ = NFSMNT_MDSSESSION(nmp)->nfsess_clientid.lval[0]; - *tl = NFSMNT_MDSSESSION(nmp)->nfsess_clientid.lval[1]; - } - nrp = dsp->nfsclds_sockp; + tsep = nfsmnt_mdssession(nmp); + *tl++ = tsep->nfsess_clientid.lval[0]; + *tl = tsep->nfsess_clientid.lval[1]; + } + nrp = NULL; + if (dsp != NULL) + nrp = dsp->nfsclds_sockp; if (nrp == NULL) /* If NULL, use the MDS socket. */ nrp = &nmp->nm_sockreq; nd->nd_flag |= ND_USEGSSNAME; - error = newnfs_request(nd, nmp, NULL, nrp, NULL, p, cred, - NFS_PROG, NFS_VER4, NULL, 1, NULL, &dsp->nfsclds_sess); + if (dsp == NULL) + error = newnfs_request(nd, nmp, NULL, nrp, NULL, p, cred, + NFS_PROG, NFS_VER4, NULL, 1, NULL, NULL); + else + error = newnfs_request(nd, nmp, NULL, nrp, NULL, p, cred, + NFS_PROG, NFS_VER4, NULL, 1, NULL, &dsp->nfsclds_sess); if (error) return (error); error = nd->nd_repstat; @@ -4269,6 +4306,7 @@ nfsrpc_rellockown(struct nfsmount *nmp, u_int32_t *tl; int error; uint8_t own[NFSV4CL_LOCKNAMELEN + NFSX_V4FHMAX]; + struct nfsclsession *tsep; if (NFSHASNFSV4N(nmp)) { /* For NFSv4.1, do a FreeStateID. */ @@ -4279,8 +4317,9 @@ nfsrpc_rellockown(struct nfsmount *nmp, nfscl_reqstart(nd, NFSPROC_RELEASELCKOWN, nmp, NULL, 0, NULL, NULL); NFSM_BUILD(tl, u_int32_t *, 2 * NFSX_UNSIGNED); - *tl++ = NFSMNT_MDSSESSION(nmp)->nfsess_clientid.lval[0]; - *tl = NFSMNT_MDSSESSION(nmp)->nfsess_clientid.lval[1]; + tsep = nfsmnt_mdssession(nmp); + *tl++ = tsep->nfsess_clientid.lval[0]; + *tl = tsep->nfsess_clientid.lval[1]; NFSBCOPY(lp->nfsl_owner, own, NFSV4CL_LOCKNAMELEN); NFSBCOPY(fh, &own[NFSV4CL_LOCKNAMELEN], fhlen); (void)nfsm_strtom(nd, own, NFSV4CL_LOCKNAMELEN + fhlen); @@ -4518,7 +4557,7 @@ nfsrpc_exchangeid(struct nfsmount *nmp, error = NFSERR_BADXDR; goto nfsmout; } - dsp = malloc(sizeof(struct nfsclds) + len, M_NFSCLDS, + dsp = malloc(sizeof(struct nfsclds) + len + 1, M_NFSCLDS, M_WAITOK | M_ZERO); dsp->nfsclds_expire = NFSD_MONOSEC + clp->nfsc_renew; dsp->nfsclds_servownlen = len; @@ -4661,10 +4700,12 @@ nfsrpc_destroysession(struct nfsmount *n struct nfsrv_descript nfsd; struct nfsrv_descript *nd = &nfsd; int error; + struct nfsclsession *tsep; nfscl_reqstart(nd, NFSPROC_DESTROYSESSION, nmp, NULL, 0, NULL, NULL); NFSM_BUILD(tl, uint32_t *, NFSX_V4SESSIONID); - bcopy(NFSMNT_MDSSESSION(nmp)->nfsess_sessionid, tl, NFSX_V4SESSIONID); + tsep = nfsmnt_mdssession(nmp); + bcopy(tsep->nfsess_sessionid, tl, NFSX_V4SESSIONID); nd->nd_flag |= ND_USEGSSNAME; error = newnfs_request(nd, nmp, NULL, &nmp->nm_sockreq, NULL, p, cred, NFS_PROG, NFS_VER4, NULL, 1, NULL, NULL); @@ -4686,11 +4727,13 @@ nfsrpc_destroyclient(struct nfsmount *nm struct nfsrv_descript nfsd; struct nfsrv_descript *nd = &nfsd; int error; + struct nfsclsession *tsep; nfscl_reqstart(nd, NFSPROC_DESTROYCLIENT, nmp, NULL, 0, NULL, NULL); NFSM_BUILD(tl, uint32_t *, 2 * NFSX_UNSIGNED); - *tl++ = NFSMNT_MDSSESSION(nmp)->nfsess_clientid.lval[0]; - *tl = NFSMNT_MDSSESSION(nmp)->nfsess_clientid.lval[1]; + tsep = nfsmnt_mdssession(nmp); + *tl++ = tsep->nfsess_clientid.lval[0]; + *tl = tsep->nfsess_clientid.lval[1]; nd->nd_flag |= ND_USEGSSNAME; error = newnfs_request(nd, nmp, NULL, &nmp->nm_sockreq, NULL, p, cred, NFS_PROG, NFS_VER4, NULL, 1, NULL, NULL); @@ -5158,6 +5201,7 @@ nfsrpc_getlayout(struct nfsmount *nmp, v struct nfsclflayouthead flh; int error = 0, islocked, layoutlen, recalled, retonclose; nfsv4stateid_t stateid; + struct nfsclsession *tsep; *lypp = NULL; /* @@ -5172,7 +5216,8 @@ nfsrpc_getlayout(struct nfsmount *nmp, v if (recalled != 0) return (EIO); LIST_INIT(&flh); - layoutlen = NFSMNT_MDSSESSION(nmp)->nfsess_maxcache - + tsep = nfsmnt_mdssession(nmp); + layoutlen = tsep->nfsess_maxcache - (NFSX_STATEID + 3 * NFSX_UNSIGNED); if (lyp == NULL) { stateid.seqid = 0; @@ -5269,7 +5314,8 @@ nfsrpc_fillsa(struct nfsmount *nmp, stru if (msad != NULL && msad->sin_family == AF_INET && ssd->sin_addr.s_addr == msad->sin_addr.s_addr && ssd->sin_port == msad->sin_port && - (tdsp->nfsclds_flags & NFSCLDS_DS) != 0) { + (tdsp->nfsclds_flags & NFSCLDS_DS) != 0 && + tdsp->nfsclds_sess.nfsess_defunct == 0) { *dspp = tdsp; NFSUNLOCKMNT(nmp); NFSCL_DEBUG(4, "fnd same addr\n"); @@ -5309,7 +5355,8 @@ nfsrpc_fillsa(struct nfsmount *nmp, stru IN6_ARE_ADDR_EQUAL(&ssd6->sin6_addr, &msad6->sin6_addr) && ssd6->sin6_port == msad6->sin6_port && - (tdsp->nfsclds_flags & NFSCLDS_DS) != 0) { + (tdsp->nfsclds_flags & NFSCLDS_DS) != 0 && + tdsp->nfsclds_sess.nfsess_defunct == 0) { *dspp = tdsp; NFSUNLOCKMNT(nmp); return (0); @@ -5862,7 +5909,8 @@ nfscl_getsameserver(struct nfsmount *nmp if (dsp->nfsclds_servownlen == newdsp->nfsclds_servownlen && dsp->nfsclds_servownlen != 0 && !NFSBCMP(dsp->nfsclds_serverown, newdsp->nfsclds_serverown, - dsp->nfsclds_servownlen)) { + dsp->nfsclds_servownlen) && + dsp->nfsclds_sess.nfsess_defunct == 0) { NFSCL_DEBUG(4, "fnd same fdsp=%p dsp=%p flg=0x%x\n", TAILQ_FIRST(&nmp->nm_sess), dsp, dsp->nfsclds_flags); Modified: head/sys/fs/nfsclient/nfs_clstate.c ============================================================================== --- head/sys/fs/nfsclient/nfs_clstate.c Fri Dec 23 22:42:14 2016 (r310490) +++ head/sys/fs/nfsclient/nfs_clstate.c Fri Dec 23 23:14:53 2016 (r310491) @@ -2470,8 +2470,11 @@ nfscl_renewthread(struct nfsclclient *cl if (recover_done_time < NFSD_MONOSEC) { recover_done_time = NFSD_MONOSEC + clp->nfsc_renew; + NFSCL_DEBUG(1, "Doing recovery..\n"); nfscl_recover(clp, cred, p); } else { + NFSCL_DEBUG(1, "Clear Recovery dt=%u ms=%jd\n", + recover_done_time, (intmax_t)NFSD_MONOSEC); NFSLOCKCLSTATE(); clp->nfsc_flags &= ~NFSCLFLAGS_RECOVER; NFSUNLOCKCLSTATE(); @@ -2481,8 +2484,7 @@ nfscl_renewthread(struct nfsclclient *cl (clp->nfsc_flags & NFSCLFLAGS_HASCLIENTID)) { clp->nfsc_expire = NFSD_MONOSEC + clp->nfsc_renew; clidrev = clp->nfsc_clientidrev; - error = nfsrpc_renew(clp, - TAILQ_FIRST(&clp->nfsc_nmp->nm_sess), cred, p); + error = nfsrpc_renew(clp, NULL, cred, p); if (error == NFSERR_CBPATHDOWN) cbpathdown = 1; else if (error == NFSERR_STALECLIENTID || @@ -2494,24 +2496,27 @@ nfscl_renewthread(struct nfsclclient *cl (void) nfscl_hasexpired(clp, clidrev, p); } - /* Do renews for any DS sessions. */ checkdsrenew: - NFSLOCKMNT(clp->nfsc_nmp); - /* Skip first entry, since the MDS is handled above. */ - dsp = TAILQ_FIRST(&clp->nfsc_nmp->nm_sess); - if (dsp != NULL) - dsp = TAILQ_NEXT(dsp, nfsclds_list); - while (dsp != NULL) { - if (dsp->nfsclds_expire <= NFSD_MONOSEC) { - dsp->nfsclds_expire = NFSD_MONOSEC + - clp->nfsc_renew; - NFSUNLOCKMNT(clp->nfsc_nmp); - (void)nfsrpc_renew(clp, dsp, cred, p); - goto checkdsrenew; + if (NFSHASNFSV4N(clp->nfsc_nmp)) { + /* Do renews for any DS sessions. */ + NFSLOCKMNT(clp->nfsc_nmp); + /* Skip first entry, since the MDS is handled above. */ + dsp = TAILQ_FIRST(&clp->nfsc_nmp->nm_sess); + if (dsp != NULL) + dsp = TAILQ_NEXT(dsp, nfsclds_list); + while (dsp != NULL) { + if (dsp->nfsclds_expire <= NFSD_MONOSEC && + dsp->nfsclds_sess.nfsess_defunct == 0) { + dsp->nfsclds_expire = NFSD_MONOSEC + + clp->nfsc_renew; + NFSUNLOCKMNT(clp->nfsc_nmp); + (void)nfsrpc_renew(clp, dsp, cred, p); + goto checkdsrenew; + } + dsp = TAILQ_NEXT(dsp, nfsclds_list); } - dsp = TAILQ_NEXT(dsp, nfsclds_list); + NFSUNLOCKMNT(clp->nfsc_nmp); } - NFSUNLOCKMNT(clp->nfsc_nmp); TAILQ_INIT(&dh); NFSLOCKCLSTATE(); @@ -3163,6 +3168,7 @@ nfscl_docb(struct nfsrv_descript *nd, NF int changed, gotone, laytype, recalltype; uint32_t iomode; struct nfsclrecalllayout *recallp = NULL; + struct nfsclsession *tsep; gotseq_ok = 0; nfsrvd_rephead(nd); @@ -3472,13 +3478,12 @@ nfscl_docb(struct nfsrv_descript *nd, NF error = NFSERR_SERVERFAULT; } else error = NFSERR_SEQUENCEPOS; - if (error == 0) + if (error == 0) { + tsep = nfsmnt_mdssession(clp->nfsc_nmp); error = nfsv4_seqsession(seqid, slotid, - highslot, - NFSMNT_MDSSESSION(clp->nfsc_nmp)-> - nfsess_cbslots, &rep, - NFSMNT_MDSSESSION(clp->nfsc_nmp)-> - nfsess_backslots); + highslot, tsep->nfsess_cbslots, &rep, + tsep->nfsess_backslots); + } NFSUNLOCKCLSTATE(); if (error == 0) { gotseq_ok = 1; @@ -3546,8 +3551,8 @@ out: NFSLOCKCLSTATE(); clp = nfscl_getclntsess(sessionid); if (clp != NULL) { - nfsv4_seqsess_cacherep(slotid, - NFSMNT_MDSSESSION(clp->nfsc_nmp)->nfsess_cbslots, + tsep = nfsmnt_mdssession(clp->nfsc_nmp); + nfsv4_seqsess_cacherep(slotid, tsep->nfsess_cbslots, NFSERR_OK, &rep); NFSUNLOCKCLSTATE(); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@freebsd.org Sat Dec 24 00:30:30 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EEB50C8EEC8; Sat, 24 Dec 2016 00:30:30 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 BE702F65; Sat, 24 Dec 2016 00:30:30 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBO0UTT3019743; Sat, 24 Dec 2016 00:30:29 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBO0UTTL019742; Sat, 24 Dec 2016 00:30:29 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201612240030.uBO0UTTL019742@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Sat, 24 Dec 2016 00:30:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310492 - head/sys/dev/spibus X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Sat, 24 Dec 2016 00:30:31 -0000 Author: gonzo Date: Sat Dec 24 00:30:29 2016 New Revision: 310492 URL: https://svnweb.freebsd.org/changeset/base/310492 Log: [spigen] Fix spigen attaching as a driver for SPI devices nodes in FDT Return BUS_PROBE_NOWILDCARD in probe method to make sure that spigen attaches only to the device created in identify method. Before this change spigen probe method used to return 0 which meant it competed with other drivers to be attached to the devices created for child nodes of SPI bus node in FDT. Reported by: Daniel Braniss MFC after: 1 week Modified: head/sys/dev/spibus/spigen.c Modified: head/sys/dev/spibus/spigen.c ============================================================================== --- head/sys/dev/spibus/spigen.c Fri Dec 23 23:14:53 2016 (r310491) +++ head/sys/dev/spibus/spigen.c Sat Dec 24 00:30:29 2016 (r310492) @@ -81,8 +81,10 @@ spigen_identify(driver_t *driver, device static int spigen_probe(device_t dev) { + device_set_desc(dev, "SPI Generic IO"); - return (0); + + return (BUS_PROBE_NOWILDCARD); } static int spigen_open(struct cdev *, int, int, struct thread *); From owner-svn-src-head@freebsd.org Sat Dec 24 02:31:27 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DAFFDC8DFC7; Sat, 24 Dec 2016 02:31:27 +0000 (UTC) (envelope-from kan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 B5A436E4; Sat, 24 Dec 2016 02:31:27 +0000 (UTC) (envelope-from kan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBO2VQdr068529; Sat, 24 Dec 2016 02:31:26 GMT (envelope-from kan@FreeBSD.org) Received: (from kan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBO2VQgA068527; Sat, 24 Dec 2016 02:31:26 GMT (envelope-from kan@FreeBSD.org) Message-Id: <201612240231.uBO2VQgA068527@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kan set sender to kan@FreeBSD.org using -f From: Alexander Kabaev Date: Sat, 24 Dec 2016 02:31:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310493 - head/sys/mips/ingenic X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Sat, 24 Dec 2016 02:31:28 -0000 Author: kan Date: Sat Dec 24 02:31:26 2016 New Revision: 310493 URL: https://svnweb.freebsd.org/changeset/base/310493 Log: Add driver for JZ4780 RTC device. Only support basic timekeeping for now. Added: head/sys/mips/ingenic/jz4780_rtc.c (contents, props changed) Modified: head/sys/mips/ingenic/files.jz4780 Modified: head/sys/mips/ingenic/files.jz4780 ============================================================================== --- head/sys/mips/ingenic/files.jz4780 Sat Dec 24 00:30:29 2016 (r310492) +++ head/sys/mips/ingenic/files.jz4780 Sat Dec 24 02:31:26 2016 (r310493) @@ -21,6 +21,7 @@ mips/ingenic/jz4780_machdep.c standard mips/ingenic/jz4780_nemc.c standard mips/ingenic/jz4780_pdma.c standard mips/ingenic/jz4780_pinctrl.c standard +mips/ingenic/jz4780_rtc.c standard mips/ingenic/jz4780_timer.c standard # Sound Added: head/sys/mips/ingenic/jz4780_rtc.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/mips/ingenic/jz4780_rtc.c Sat Dec 24 02:31:26 2016 (r310493) @@ -0,0 +1,234 @@ +/*- + * Copyright 2016 Alexander Kabaev + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Ingenic JZ4780 RTC driver + * + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include "clock_if.h" + +#define JZ_RTC_TIMEOUT 5000 + +#define JZ_RTCCR 0x00 +# define JZ_RTCCR_WRDY (1u << 7) +#define JZ_RTSR 0x04 +#define JZ_HSPR 0x34 +#define JZ_WENR 0x3C +# define JZ_WENR_PAT 0xa55a +# define JZ_WENR_WEN (1u <<31) + +struct jz4780_rtc_softc { + device_t dev; + struct resource *res[2]; +}; + +static struct resource_spec jz4780_rtc_spec[] = { + { SYS_RES_MEMORY, 0, RF_ACTIVE }, + { SYS_RES_IRQ, 0, RF_ACTIVE }, + { -1, 0 } +}; + +#define CSR_READ(sc, reg) bus_read_4((sc)->res[0], (reg)) +#define CSR_WRITE(sc, reg, val) bus_write_4((sc)->res[0], (reg), (val)) + +static int jz4780_rtc_probe(device_t dev); +static int jz4780_rtc_attach(device_t dev); +static int jz4780_rtc_detach(device_t dev); + +static int +jz4780_rtc_probe(device_t dev) +{ + + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + + if (!ofw_bus_is_compatible(dev, "ingenic,jz4780-rtc")) + return (ENXIO); + + device_set_desc(dev, "JZ4780 RTC"); + + return (BUS_PROBE_DEFAULT); +} + +/* Poll control register until RTC is ready to accept register writes */ +static int +jz4780_rtc_wait(struct jz4780_rtc_softc *sc) +{ + int timeout; + + timeout = JZ_RTC_TIMEOUT; + while (timeout-- > 0) { + if (CSR_READ(sc, JZ_RTCCR) & JZ_RTCCR_WRDY) + return (0); + } + return (EIO); +} + +/* + * Write RTC register. It appears that RTC goes into read-only mode at random, + * which suggests something is up with how it is powered up, so do the pattern + * writing dance every time just in case. + */ +static int +jz4780_rtc_write(struct jz4780_rtc_softc *sc, uint32_t reg, uint32_t val) +{ + int ret, timeout; + + ret = jz4780_rtc_wait(sc); + if (ret != 0) + return (ret); + + CSR_WRITE(sc, JZ_WENR, JZ_WENR_PAT); + + ret = jz4780_rtc_wait(sc); + if (ret) + return ret; + + timeout = JZ_RTC_TIMEOUT; + while (timeout-- > 0) { + if (CSR_READ(sc, JZ_WENR) & JZ_WENR_WEN) + break; + } + if (timeout < 0) + return (EIO); + + CSR_WRITE(sc, reg, val); + return 0; +} + +static int +jz4780_rtc_attach(device_t dev) +{ + struct jz4780_rtc_softc *sc = device_get_softc(dev); + uint32_t scratch; + int ret; + + sc->dev = dev; + + if (bus_alloc_resources(dev, jz4780_rtc_spec, sc->res)) { + device_printf(dev, "could not allocate resources for device\n"); + return (ENXIO); + } + + scratch = CSR_READ(sc, JZ_HSPR); + if (scratch != 0x12345678) { + ret = jz4780_rtc_write(sc, JZ_HSPR, 0x12345678); + if (ret == 0) + ret = jz4780_rtc_write(sc, JZ_RTSR, 0); + if (ret) { + device_printf(dev, "Unable to write RTC registers\n"); + jz4780_rtc_detach(dev); + return (ret); + } + } + clock_register(dev, 1000000); /* Register 1 HZ clock */ + return (0); +} + +static int +jz4780_rtc_detach(device_t dev) +{ + struct jz4780_rtc_softc *sc; + + sc = device_get_softc(dev); + bus_release_resources(dev, jz4780_rtc_spec, sc->res); + return (0); +} + +static int +jz4780_rtc_gettime(device_t dev, struct timespec *ts) +{ + struct jz4780_rtc_softc *sc; + uint32_t val1, val2; + int timeout; + + sc = device_get_softc(dev); + + timeout = JZ_RTC_TIMEOUT; + val2 = CSR_READ(sc, JZ_RTSR); + do { + val1 = val2; + val2 = CSR_READ(sc, JZ_RTSR); + } while (val1 != val2 && timeout-- >= 0); + + if (timeout < 0) + return (EIO); + + /* Convert secs to timespec directly */ + ts->tv_sec = val1; + ts->tv_nsec = 0; + return 0; +} + +static int +jz4780_rtc_settime(device_t dev, struct timespec *ts) +{ + struct jz4780_rtc_softc *sc; + + sc = device_get_softc(dev); + return jz4780_rtc_write(sc, JZ_RTSR, ts->tv_sec); +} + +static device_method_t jz4780_rtc_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, jz4780_rtc_probe), + DEVMETHOD(device_attach, jz4780_rtc_attach), + DEVMETHOD(device_detach, jz4780_rtc_detach), + + DEVMETHOD(clock_gettime, jz4780_rtc_gettime), + DEVMETHOD(clock_settime, jz4780_rtc_settime), + + DEVMETHOD_END +}; + +static driver_t jz4780_rtc_driver = { + "jz4780_rtc", + jz4780_rtc_methods, + sizeof(struct jz4780_rtc_softc), +}; + +static devclass_t jz4780_rtc_devclass; + +EARLY_DRIVER_MODULE(jz4780_rtc, simplebus, jz4780_rtc_driver, + jz4780_rtc_devclass, 0, 0, BUS_PASS_TIMER + BUS_PASS_ORDER_MIDDLE); From owner-svn-src-head@freebsd.org Sat Dec 24 07:13:34 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E080BC8EFFB; Sat, 24 Dec 2016 07:13:34 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 B02421F3C; Sat, 24 Dec 2016 07:13:34 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBO7DXFg085088; Sat, 24 Dec 2016 07:13:33 GMT (envelope-from hrs@FreeBSD.org) Received: (from hrs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBO7DXlD085087; Sat, 24 Dec 2016 07:13:33 GMT (envelope-from hrs@FreeBSD.org) Message-Id: <201612240713.uBO7DXlD085087@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hrs set sender to hrs@FreeBSD.org using -f From: Hiroki Sato Date: Sat, 24 Dec 2016 07:13:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310494 - head/usr.sbin/syslogd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Sat, 24 Dec 2016 07:13:35 -0000 Author: hrs Date: Sat Dec 24 07:13:33 2016 New Revision: 310494 URL: https://svnweb.freebsd.org/changeset/base/310494 Log: - Remove unused code. - Use closefrom(). Modified: head/usr.sbin/syslogd/syslogd.c Modified: head/usr.sbin/syslogd/syslogd.c ============================================================================== --- head/usr.sbin/syslogd/syslogd.c Sat Dec 24 02:31:26 2016 (r310493) +++ head/usr.sbin/syslogd/syslogd.c Sat Dec 24 07:13:33 2016 (r310494) @@ -357,7 +357,7 @@ static void usage(void); static int validate(struct sockaddr *, const char *); static void unmapped(struct sockaddr *); static void wallmsg(struct filed *, struct iovec *, const int iovlen); -static int waitdaemon(int, int, int); +static int waitdaemon(int); static void timedout(int); static void increase_rcvbuf(int); @@ -606,7 +606,7 @@ main(int argc, char *argv[]) } if ((!Foreground) && (!Debug)) { - ppid = waitdaemon(0, 0, 30); + ppid = waitdaemon(30); if (ppid < 0) { warn("could not become daemon"); pidfile_remove(pfh); @@ -2311,7 +2311,7 @@ markit(void) * Set a timer so we don't hang forever if it wedges. */ static int -waitdaemon(int nochdir, int noclose, int maxwait) +waitdaemon(int maxwait) { int fd; int status; @@ -2343,15 +2343,12 @@ waitdaemon(int nochdir, int noclose, int if (setsid() == -1) return (-1); - if (!nochdir) - (void)chdir("/"); - - if (!noclose && (fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) { + (void)chdir("/"); + if ((fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) { (void)dup2(fd, STDIN_FILENO); (void)dup2(fd, STDOUT_FILENO); (void)dup2(fd, STDERR_FILENO); - if (fd > 2) - (void)close (fd); + closefrom(STDERR_FILENO + 1); } return (getppid()); } From owner-svn-src-head@freebsd.org Sat Dec 24 09:57:33 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 40C72C8B098; Sat, 24 Dec 2016 09:57:33 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 02DD7BB3; Sat, 24 Dec 2016 09:57:32 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBO9vWBb049844; Sat, 24 Dec 2016 09:57:32 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBO9vWTZ049843; Sat, 24 Dec 2016 09:57:32 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201612240957.uBO9vWTZ049843@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sat, 24 Dec 2016 09:57:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310496 - head/sys/vm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Sat, 24 Dec 2016 09:57:33 -0000 Author: kib Date: Sat Dec 24 09:57:31 2016 New Revision: 310496 URL: https://svnweb.freebsd.org/changeset/base/310496 Log: Fix argument type and microoptimize swp_pager_meta_free(). The count argument natural type if vm_pindex_t, but due to the loop organization, it has to be signed type to detect the termination condition. Replace this logic by using distinguished counter for the processed pages, and terminate loop when the counter exceeds the argument. Completely process one swblock for all relevant indexes instead of doing relookup in hash when incrementing page index on the loop step. Do not drop hash mutex around iterations. Noted and reviewed by: alc Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Modified: head/sys/vm/swap_pager.c Modified: head/sys/vm/swap_pager.c ============================================================================== --- head/sys/vm/swap_pager.c Sat Dec 24 08:59:30 2016 (r310495) +++ head/sys/vm/swap_pager.c Sat Dec 24 09:57:31 2016 (r310496) @@ -410,7 +410,7 @@ static daddr_t swp_pager_getswapspace(in */ static struct swblock **swp_pager_hash(vm_object_t object, vm_pindex_t index); static void swp_pager_meta_build(vm_object_t, vm_pindex_t, daddr_t); -static void swp_pager_meta_free(vm_object_t, vm_pindex_t, daddr_t); +static void swp_pager_meta_free(vm_object_t, vm_pindex_t, vm_pindex_t); static void swp_pager_meta_free_all(vm_object_t); static daddr_t swp_pager_meta_ctl(vm_object_t, vm_pindex_t, int); @@ -1869,42 +1869,42 @@ done: * with resident pages. */ static void -swp_pager_meta_free(vm_object_t object, vm_pindex_t index, daddr_t count) +swp_pager_meta_free(vm_object_t object, vm_pindex_t index, vm_pindex_t count) { + struct swblock **pswap, *swap; + vm_pindex_t c; + daddr_t v; + int n, sidx; VM_OBJECT_ASSERT_LOCKED(object); - if (object->type != OBJT_SWAP) + if (object->type != OBJT_SWAP || count == 0) return; - while (count > 0) { - struct swblock **pswap; - struct swblock *swap; - - mtx_lock(&swhash_mtx); + mtx_lock(&swhash_mtx); + for (c = 0; c < count;) { pswap = swp_pager_hash(object, index); - - if ((swap = *pswap) != NULL) { - daddr_t v = swap->swb_pages[index & SWAP_META_MASK]; - - if (v != SWAPBLK_NONE) { - swp_pager_freeswapspace(v, 1); - swap->swb_pages[index & SWAP_META_MASK] = - SWAPBLK_NONE; - if (--swap->swb_count == 0) { - *pswap = swap->swb_hnext; - uma_zfree(swap_zone, swap); - --object->un_pager.swp.swp_bcount; - } + sidx = index & SWAP_META_MASK; + n = SWAP_META_PAGES - sidx; + index += n; + if ((swap = *pswap) == NULL) { + c += n; + continue; + } + for (; c < count && sidx < SWAP_META_PAGES; ++c, ++sidx) { + if ((v = swap->swb_pages[sidx]) == SWAPBLK_NONE) + continue; + swp_pager_freeswapspace(v, 1); + swap->swb_pages[sidx] = SWAPBLK_NONE; + if (--swap->swb_count == 0) { + *pswap = swap->swb_hnext; + uma_zfree(swap_zone, swap); + --object->un_pager.swp.swp_bcount; + c += SWAP_META_PAGES - sidx; + break; } - --count; - ++index; - } else { - int n = SWAP_META_PAGES - (index & SWAP_META_MASK); - count -= n; - index += n; } - mtx_unlock(&swhash_mtx); } + mtx_unlock(&swhash_mtx); } /* From owner-svn-src-head@freebsd.org Sat Dec 24 11:22:30 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 463A9C8E9AC; Sat, 24 Dec 2016 11:22:30 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 0189F14B9; Sat, 24 Dec 2016 11:22:29 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBOBMTMb086318; Sat, 24 Dec 2016 11:22:29 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBOBMSR7086315; Sat, 24 Dec 2016 11:22:28 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612241122.uBOBMSR7086315@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Sat, 24 Dec 2016 11:22:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310497 - in head/usr.sbin/bsnmpd/tools: bsnmptools libbsnmptools X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Sat, 24 Dec 2016 11:22:30 -0000 Author: ngie Date: Sat Dec 24 11:22:28 2016 New Revision: 310497 URL: https://svnweb.freebsd.org/changeset/base/310497 Log: Warning message cleanup - Use warn instead of warnx + strerror(errno) - Remove unnecessary trailing newline from a warnx call - Add missing spaces following "," in syslog and warn* calls MFC after: 2 weeks Modified: head/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c Modified: head/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c ============================================================================== --- head/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c Sat Dec 24 09:57:31 2016 (r310496) +++ head/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c Sat Dec 24 11:22:28 2016 (r310497) @@ -394,7 +394,7 @@ snmptool_get(struct snmp_toolinfo *snmpt GET_NONREP(snmptoolctx)); if (snmp_dialog(&req, &resp) == -1) { - warnx("Snmp dialog - %s", strerror(errno)); + warn("Snmp dialog"); break; } @@ -521,7 +521,7 @@ snmptool_walk(struct snmp_toolinfo *snmp snmp_pdu_free(&resp); } else - warnx("Snmp dialog - %s", strerror(errno)); + warn("Snmp dialog"); } if (snmp_object_remove(snmptoolctx, &root) < 0) { @@ -554,8 +554,7 @@ parse_oid_numeric(struct snmp_value *val errno = 0; suboid = strtoul(val, &endptr, 10); if (errno != 0) { - warnx("Value %s not supported - %s", val, - strerror(errno)); + warn("Value %s not supported", val); errno = saved_errno; return (-1); } @@ -634,7 +633,7 @@ parse_int(struct snmp_value *value, char v = strtol(val, &endptr, 10); if (errno != 0) { - warnx("Value %s not supported - %s", val, strerror(errno)); + warn("Value %s not supported", val); errno = saved_errno; return (-1); } @@ -682,7 +681,7 @@ parse_uint(struct snmp_value *value, cha v = strtoul(val, &endptr, 10); if (errno != 0) { - warnx("Value %s not supported - %s", val, strerror(errno)); + warn("Value %s not supported", val); errno = saved_errno; return (-1); } @@ -736,7 +735,7 @@ parse_uint64(struct snmp_value *value, c v = strtoull(val, &endptr, 10); if (errno != 0) { - warnx("Value %s not supported - %s", val, strerror(errno)); + warnx("Value %s not supported", val); errno = saved_errno; return (-1); } @@ -821,7 +820,7 @@ parse_pair_numoid_val(char *str, struct break; if (ptr[cnt] != '\0') { - warnx("Value string too long - %s",ptr); + warnx("Value string too long - %s", ptr); return (-1); } @@ -830,7 +829,7 @@ parse_pair_numoid_val(char *str, struct * to know syntax to check value boundaries. */ if (snmp_parse_numoid(oid_str, &(snmp_val->var)) < 0) { - warnx("Error parsing OID %s",oid_str); + warnx("Error parsing OID %s", oid_str); return (-1); } @@ -956,7 +955,7 @@ static int32_t add_octstring_syntax(struct snmp_value *dst, struct snmp_value *src) { if (src->v.octetstring.len > ASN_MAXOCTETSTRING) { - warnx("OctetString len too big - %u",src->v.octetstring.len); + warnx("OctetString len too big - %u", src->v.octetstring.len); return (-1); } @@ -1084,7 +1083,7 @@ snmptool_set(struct snmp_toolinfo *snmpt while ((snmp_pdu_add_bindings(snmptoolctx, snmpset_verify_vbind, snmpset_add_vbind, &req, SNMP_MAX_BINDINGS)) > 0) { if (snmp_dialog(&req, &resp)) { - warnx("Snmp dialog - %s", strerror(errno)); + warn("Snmp dialog"); break; } @@ -1229,7 +1228,7 @@ main(int argc, char ** argv) } if (snmp_open(NULL, NULL, NULL, NULL)) { - warnx("Failed to open snmp session: %s.", strerror(errno)); + warn("Failed to open snmp session"); snmp_tool_freeall(&snmptoolctx); exit(1); } @@ -1239,7 +1238,7 @@ main(int argc, char ** argv) if (ISSET_EDISCOVER(&snmptoolctx) && snmp_discover_engine(snmptoolctx.passwd) < 0) { - warnx("Unknown SNMP Engine ID: %s.", strerror(errno)); + warn("Unknown SNMP Engine ID"); rc = 1; goto cleanup; } @@ -1255,7 +1254,7 @@ main(int argc, char ** argv) snmp_get_local_keys(&snmp_client.user, snmp_client.engine.engine_id, snmp_client.engine.engine_len) != SNMP_CODE_OK) { - warnx("Failed to get keys: %s.", strerror(errno)); + warn("Failed to get keys"); rc = 1; goto cleanup; } Modified: head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c ============================================================================== --- head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c Sat Dec 24 09:57:31 2016 (r310496) +++ head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c Sat Dec 24 11:22:28 2016 (r310497) @@ -269,7 +269,7 @@ parse_octetstring(struct snmp_value *val value->v.octetstring.len = len; if((value->v.octetstring.octets = malloc(len)) == NULL) { - syslog(LOG_ERR,"malloc failed: %s", strerror(errno)); + syslog(LOG_ERR, "malloc failed: %s", strerror(errno)); return (-1); } @@ -570,7 +570,7 @@ parse_dateandtime(struct snmp_value *sv, date[10] = v; if ((sv->v.octetstring.octets = malloc(SNMP_DATETIME_OCTETS)) == NULL) { - warnx("malloc() failed - %s", strerror(errno)); + warn("malloc() failed"); return (-1); } @@ -626,7 +626,7 @@ snmp_addr2asn_oid(char *str, struct asn_ return (NULL); } if (*endptr != ':') { - warnx("Failed adding oid - %s",str); + warnx("Failed adding oid - %s", str); return (NULL); } if (snmp_suboid_append(oid, (asn_subid_t) v) < 0) @@ -679,7 +679,7 @@ parse_physaddress(struct snmp_value *sv, phys_addr[5] = v; if ((sv->v.octetstring.octets = malloc(SNMP_PHYSADDR_OCTETS)) == NULL) { - syslog(LOG_ERR,"malloc failed: %s", strerror(errno)); + syslog(LOG_ERR, "malloc failed: %s", strerror(errno)); return (-1); } @@ -743,7 +743,7 @@ snmp_ntp_ts2asn_oid(char *str, struct as errno = saved_errno; if (*endptr != '.') { - warnx("Failed adding oid - %s",str); + warnx("Failed adding oid - %s", str); return (NULL); } @@ -824,7 +824,7 @@ parse_ntp_ts(struct snmp_value *sv, char } if ((sv->v.octetstring.octets = malloc(SNMP_NTP_TS_OCTETS)) == NULL) { - syslog(LOG_ERR,"malloc failed: %s", strerror(errno)); + syslog(LOG_ERR, "malloc failed: %s", strerror(errno)); return (-1); } @@ -987,7 +987,7 @@ parse_bridge_id(struct snmp_value *sv, c bridge_id[7] = v; if ((sv->v.octetstring.octets = malloc(SNMP_BRIDGEID_OCTETS)) == NULL) { - syslog(LOG_ERR,"malloc failed: %s", strerror(errno)); + syslog(LOG_ERR, "malloc failed: %s", strerror(errno)); return (-1); } @@ -1098,7 +1098,7 @@ parse_bport_id(struct snmp_value *value, bport_id[1] = v; if ((value->v.octetstring.octets = malloc(SNMP_BPORT_OCTETS)) == NULL) { - syslog(LOG_ERR,"malloc failed: %s", strerror(errno)); + syslog(LOG_ERR, "malloc failed: %s", strerror(errno)); return (-1); } @@ -1178,7 +1178,7 @@ snmp_oct2inetaddr(uint32_t len, char *oc } if (inet_ntop(af, ip, buf, SNMP_INADDRS_STRSZ) == NULL) { - warnx("inet_ntop failed - %s", strerror(errno)); + warn("inet_ntop failed"); return (NULL); } @@ -1230,7 +1230,7 @@ snmp_bits2oct(char *str, struct asn_oid v = strtoull(str, &endptr, 16); if (errno != 0) { - warnx("Bad BITS value %s - %s", str, strerror(errno)); + warn("Bad BITS value %s", str); errno = saved_errno; return (NULL); } @@ -1270,7 +1270,7 @@ parse_bits(struct snmp_value *value, cha v = strtoull(string, &endptr, 16); if (errno != 0) { - warnx("Bad BITS value %s - %s", string, strerror(errno)); + warn("Bad BITS value %s", string); errno = saved_errno; return (-1); } Modified: head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c ============================================================================== --- head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c Sat Dec 24 09:57:31 2016 (r310496) +++ head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c Sat Dec 24 11:22:28 2016 (r310497) @@ -177,7 +177,7 @@ snmptool_init(struct snmp_toolinfo *snmp if ((slen = strlen(str)) > MAXSTR) slen = MAXSTR - 1; if ((snmptoolctx->passwd = malloc(slen + 1)) == NULL) { - warnx("malloc() failed - %s", strerror(errno)); + warn("malloc() failed"); return (-1); } if (slen > 0) @@ -252,12 +252,12 @@ add_filename(struct snmp_toolinfo *snmpt } if ((fstring = strdup(filename)) == NULL) { - warnx("strdup() failed - %s", strerror(errno)); + warn("strdup() failed"); return (-1); } if ((entry = calloc(1, sizeof(struct fname))) == NULL) { - warnx("calloc() failed - %s", strerror(errno)); + warn("calloc() failed"); free(fstring); return (-1); } @@ -668,8 +668,7 @@ parse_user_security(struct snmp_toolinfo errno = 0; snmp_client.engine.engine_boots = strtoul(val, NULL, 10); if (errno != 0) { - warnx("Bad 'engine-boots' value %s - %s", val, - strerror(errno)); + warn("Bad 'engine-boots' value %s", val); errno = saved_errno; return (-1); } @@ -684,8 +683,7 @@ parse_user_security(struct snmp_toolinfo errno = 0; snmp_client.engine.engine_time = strtoul(val, NULL, 10); if (errno != 0) { - warnx("Bad 'engine-time' value %s - %s", val, - strerror(errno)); + warn("Bad 'engine-time' value %s", val); errno = saved_errno; return (-1); } @@ -819,7 +817,7 @@ parse_timeout(char *opt_arg) v = strtol(opt_arg, NULL, 10); if (errno != 0) { - warnx( "Error parsing timeout value - %s", strerror(errno)); + warn("Error parsing timeout value"); errno = saved_errno; return (-1); } @@ -842,7 +840,7 @@ parse_retry(char *opt_arg) v = strtoul(opt_arg, NULL, 10); if (errno != 0) { - warnx("Error parsing retries count - %s", strerror(errno)); + warn("Error parsing retries count"); errno = saved_errno; return (-1); } @@ -865,7 +863,7 @@ parse_version(char *opt_arg) v = strtoul(opt_arg, NULL, 10); if (errno != 0) { - warnx("Error parsing version - %s", strerror(errno)); + warn("Error parsing version"); errno = saved_errno; return (-1); } @@ -917,7 +915,7 @@ parse_buflen(char *opt_arg) size = strtoul(opt_arg, NULL, 10); if (errno != 0) { - warnx("Error parsing buffer size - %s", strerror(errno)); + warn("Error parsing buffer size"); errno = saved_errno; return (-1); } @@ -1040,8 +1038,7 @@ snmp_int2asn_oid(char *str, struct asn_o v = strtol(str, &endptr, 10); if (errno != 0) { - warnx("Integer value %s not supported - %s", str, - strerror(errno)); + warn("Integer value %s not supported", str); errno = saved_errno; return (NULL); } @@ -1120,8 +1117,7 @@ snmp_uint2asn_oid(char *str, struct asn_ v = strtoul(str, &endptr, 10); if (errno != 0) { - warnx("Integer value %s not supported - %s\n", str, - strerror(errno)); + warn("Integer value %s not supported", str); errno = saved_errno; return (NULL); } @@ -1145,8 +1141,7 @@ snmp_cnt64_2asn_oid(char *str, struct as v = strtoull(str, &endptr, 10); if (errno != 0) { - warnx("Integer value %s not supported - %s", str, - strerror(errno)); + warn("Integer value %s not supported", str); errno = saved_errno; return (NULL); } From owner-svn-src-head@freebsd.org Sat Dec 24 11:23:20 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0CBA1C8EA0E; Sat, 24 Dec 2016 11:23:20 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 C1BD81667; Sat, 24 Dec 2016 11:23:19 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBOBNIXJ086393; Sat, 24 Dec 2016 11:23:18 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBOBNIhc086390; Sat, 24 Dec 2016 11:23:18 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612241123.uBOBNIhc086390@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Sat, 24 Dec 2016 11:23:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310498 - head/contrib/bsnmp/snmpd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Sat, 24 Dec 2016 11:23:20 -0000 Author: ngie Date: Sat Dec 24 11:23:18 2016 New Revision: 310498 URL: https://svnweb.freebsd.org/changeset/base/310498 Log: Allow SNMPv3 authNoPriv and noAuthNoPriv protocols to discover snmpEngineTime as discussed in RFC-5343 This fixes interoperability with net-snmp. Tested with the following invocations of snmpwalk (from net-snmp): - noAuthNoPriv: % snmpwalk -v 3 -n '' -u public localhost snmpEngineTime - authNoPriv: % snmpwalk -v 3 -n '' -u bsnmp -A bsnmptest -l authNoPriv -a sha localhost \ localhost snmpEngineTime - authPriv: % snmpwalk -v 3 -n '' -u bsnmp -A bsnmptest -l authPriv -a sha -x des \ -X bsnmptest localhost snmpEngineTime MFC after: 1 week Obtained from: Isilon OneFS (5ec6d772cacbc, with minor tweaks) Submitted by: Austin Voecks Sponsored by: Dell EMC Isilon Modified: head/contrib/bsnmp/snmpd/action.c head/contrib/bsnmp/snmpd/main.c head/contrib/bsnmp/snmpd/snmpd.h Modified: head/contrib/bsnmp/snmpd/action.c ============================================================================== --- head/contrib/bsnmp/snmpd/action.c Sat Dec 24 11:22:28 2016 (r310497) +++ head/contrib/bsnmp/snmpd/action.c Sat Dec 24 11:23:18 2016 (r310498) @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -219,6 +220,21 @@ save_boots: return (0); } +void +update_snmpd_engine_time(void) +{ + uint64_t etime; + + etime = (get_ticks() - start_tick) / 100ULL; + if (etime < INT32_MAX) + snmpd_engine.engine_time = etime; + else { + start_tick = get_ticks(); + (void)set_snmpd_engine(); + snmpd_engine.engine_time = start_tick; + } +} + /************************************************************* * * System group @@ -1118,7 +1134,7 @@ op_snmp_engine(struct snmp_context *ctx value->v.integer = snmpd_engine.engine_boots; break; case LEAF_snmpEngineTime: - snmpd_engine.engine_time = (get_ticks() - start_tick) / 100ULL; + update_snmpd_engine_time(); value->v.integer = snmpd_engine.engine_time; break; case LEAF_snmpEngineMaxMessageSize: Modified: head/contrib/bsnmp/snmpd/main.c ============================================================================== --- head/contrib/bsnmp/snmpd/main.c Sat Dec 24 11:22:28 2016 (r310497) +++ head/contrib/bsnmp/snmpd/main.c Sat Dec 24 11:23:18 2016 (r310498) @@ -53,7 +53,6 @@ #include #include #include -#include #ifdef USE_TCPWRAPPERS #include @@ -304,7 +303,6 @@ snmp_output(struct snmp_pdu *pdu, u_char static enum snmp_code snmp_pdu_auth_user(struct snmp_pdu *pdu) { - uint64_t etime; usm_user = NULL; /* un-authenticated snmpEngineId discovery */ @@ -312,6 +310,7 @@ snmp_pdu_auth_user(struct snmp_pdu *pdu) pdu->engine.engine_len = snmpd_engine.engine_len; memcpy(pdu->engine.engine_id, snmpd_engine.engine_id, snmpd_engine.engine_len); + update_snmpd_engine_time(); pdu->engine.engine_boots = snmpd_engine.engine_boots; pdu->engine.engine_time = snmpd_engine.engine_time; pdu->flags |= SNMP_MSG_AUTODISCOVER; @@ -334,21 +333,14 @@ snmp_pdu_auth_user(struct snmp_pdu *pdu) /* authenticated snmpEngineId discovery */ if ((pdu->flags & SNMP_MSG_AUTH_FLAG) != 0) { - etime = (get_ticks() - start_tick) / 100ULL; - if (etime < INT32_MAX) - snmpd_engine.engine_time = etime; - else { - start_tick = get_ticks(); - set_snmpd_engine(); - snmpd_engine.engine_time = start_tick; - } - + update_snmpd_engine_time(); pdu->user.auth_proto = usm_user->suser.auth_proto; memcpy(pdu->user.auth_key, usm_user->suser.auth_key, sizeof(pdu->user.auth_key)); if (pdu->engine.engine_boots == 0 && pdu->engine.engine_time == 0) { + update_snmpd_engine_time(); pdu->flags |= SNMP_MSG_AUTODISCOVER; return (SNMP_CODE_OK); } @@ -643,6 +635,7 @@ decoded: pdu->engine.engine_time == 0) { asn_append_oid(&(pdu->bindings[pdu->nbindings++].var), &oid_usmNotInTimeWindows); + update_snmpd_engine_time(); pdu->engine.engine_boots = snmpd_engine.engine_boots; pdu->engine.engine_time = snmpd_engine.engine_time; } Modified: head/contrib/bsnmp/snmpd/snmpd.h ============================================================================== --- head/contrib/bsnmp/snmpd/snmpd.h Sat Dec 24 11:22:28 2016 (r310497) +++ head/contrib/bsnmp/snmpd/snmpd.h Sat Dec 24 11:23:18 2016 (r310498) @@ -332,6 +332,7 @@ int init_actvals(void); extern char engine_file[]; int init_snmpd_engine(void); int set_snmpd_engine(void); +void update_snmpd_engine_time(void); int read_config(const char *, struct lmodule *); int define_macro(const char *name, const char *value); From owner-svn-src-head@freebsd.org Sat Dec 24 11:26:56 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 62CE1C8EA88; Sat, 24 Dec 2016 11:26:56 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 32975181D; Sat, 24 Dec 2016 11:26:56 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBOBQtxI086580; Sat, 24 Dec 2016 11:26:55 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBOBQt9P086579; Sat, 24 Dec 2016 11:26:55 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612241126.uBOBQt9P086579@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Sat, 24 Dec 2016 11:26:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310499 - head/contrib/bsnmp/lib X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Sat, 24 Dec 2016 11:26:56 -0000 Author: ngie Date: Sat Dec 24 11:26:55 2016 New Revision: 310499 URL: https://svnweb.freebsd.org/changeset/base/310499 Log: Sort #includes No functional change MFC after: 3 days Modified: head/contrib/bsnmp/lib/snmp.c Modified: head/contrib/bsnmp/lib/snmp.c ============================================================================== --- head/contrib/bsnmp/lib/snmp.c Sat Dec 24 11:23:18 2016 (r310498) +++ head/contrib/bsnmp/lib/snmp.c Sat Dec 24 11:26:55 2016 (r310499) @@ -38,19 +38,19 @@ */ #include #include +#include +#include +#include #include #include #include #include +#include #ifdef HAVE_STDINT_H #include #elif defined(HAVE_INTTYPES_H) #include #endif -#include -#include -#include -#include #include "asn1.h" #include "snmp.h" From owner-svn-src-head@freebsd.org Sat Dec 24 11:30:25 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D21E9C8EB14; Sat, 24 Dec 2016 11:30:25 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 9661A19B7; Sat, 24 Dec 2016 11:30:25 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBOBUOtV086772; Sat, 24 Dec 2016 11:30:24 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBOBUOAq086771; Sat, 24 Dec 2016 11:30:24 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612241130.uBOBUOAq086771@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Sat, 24 Dec 2016 11:30:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310500 - head/contrib/bsnmp/lib X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Sat, 24 Dec 2016 11:30:25 -0000 Author: ngie Date: Sat Dec 24 11:30:24 2016 New Revision: 310500 URL: https://svnweb.freebsd.org/changeset/base/310500 Log: Minor style(9) fixes - Trailing whitespace cleanup - Sort variables in snmp_dialog(..) by alignment No functional change MFC after: 1 week Modified: head/contrib/bsnmp/lib/snmpclient.c Modified: head/contrib/bsnmp/lib/snmpclient.c ============================================================================== --- head/contrib/bsnmp/lib/snmpclient.c Sat Dec 24 11:26:55 2016 (r310499) +++ head/contrib/bsnmp/lib/snmpclient.c Sat Dec 24 11:30:24 2016 (r310500) @@ -1214,7 +1214,7 @@ snmp_next_reqid(struct snmp_client * c) int32_t i; i = c->next_reqid; - if (c->next_reqid >= c->max_reqid) + if (c->next_reqid >= c->max_reqid) c->next_reqid = c->min_reqid; else c->next_reqid++; @@ -1230,7 +1230,7 @@ snmp_send_packet(struct snmp_pdu * pdu) u_char *buf; struct asn_buf b; ssize_t ret; - + if ((buf = malloc(snmp_client.txbuflen)) == NULL) { seterr(&snmp_client, "%s", strerror(errno)); return (-1); @@ -1684,9 +1684,9 @@ snmp_dialog(struct snmp_v1_pdu *req, str struct timeval tv = snmp_client.timeout; struct timeval end; struct snmp_pdu pdu; - u_int i; - int32_t reqid; int ret; + int32_t reqid; + u_int i; /* * Make a copy of the request and replace the syntaxes by NULL From owner-svn-src-head@freebsd.org Sat Dec 24 11:41:18 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 46A99C8ED04; Sat, 24 Dec 2016 11:41:18 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 E32D81E91; Sat, 24 Dec 2016 11:41:17 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBOBfHuK091519; Sat, 24 Dec 2016 11:41:17 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBOBfHYw091518; Sat, 24 Dec 2016 11:41:17 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612241141.uBOBfHYw091518@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Sat, 24 Dec 2016 11:41:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310501 - head/contrib/bsnmp/lib X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Sat, 24 Dec 2016 11:41:18 -0000 Author: ngie Date: Sat Dec 24 11:41:16 2016 New Revision: 310501 URL: https://svnweb.freebsd.org/changeset/base/310501 Log: Be more strict about IpAddress type in snmp_value_parse(..) - Use inet_pton with AF_INET instead of doing longhand with sscanf. - Use gethostbyname2 with AF_INET to ensure that the hostname isn't accidentally parsed with another address family, e.g. AF_INET6. NB: IpAddress per RFC-2578 is IPv4 only. Work is in progress to add the InetAddress type and friends documented in RFC-4001 and elsewhere (which supports IPv4, IPv6, and more). MFC after: 2 weeks Modified: head/contrib/bsnmp/lib/snmp.c Modified: head/contrib/bsnmp/lib/snmp.c ============================================================================== --- head/contrib/bsnmp/lib/snmp.c Sat Dec 24 11:30:24 2016 (r310500) +++ head/contrib/bsnmp/lib/snmp.c Sat Dec 24 11:41:16 2016 (r310501) @@ -51,6 +51,8 @@ #elif defined(HAVE_INTTYPES_H) #include #endif +#include +#include #include "asn1.h" #include "snmp.h" @@ -1384,29 +1386,16 @@ snmp_value_parse(const char *str, enum s case SNMP_SYNTAX_IPADDRESS: { struct hostent *he; - u_long ip[4]; - int n; - if (sscanf(str, "%lu.%lu.%lu.%lu%n", &ip[0], &ip[1], &ip[2], - &ip[3], &n) == 4 && (size_t)n == strlen(str) && - ip[0] <= 0xff && ip[1] <= 0xff && - ip[2] <= 0xff && ip[3] <= 0xff) { - v->ipaddress[0] = (u_char)ip[0]; - v->ipaddress[1] = (u_char)ip[1]; - v->ipaddress[2] = (u_char)ip[2]; - v->ipaddress[3] = (u_char)ip[3]; + if (inet_pton(AF_INET, str, &v->ipaddress) == 1) return (0); - } - - if ((he = gethostbyname(str)) == NULL) + if ((he = gethostbyname2(str, AF_INET)) == NULL) return (-1); if (he->h_addrtype != AF_INET) return (-1); - v->ipaddress[0] = he->h_addr[0]; - v->ipaddress[1] = he->h_addr[1]; - v->ipaddress[2] = he->h_addr[2]; - v->ipaddress[3] = he->h_addr[3]; + memcpy(v->ipaddress, he->h_addr, sizeof(v->ipaddress)); + return (0); } From owner-svn-src-head@freebsd.org Sat Dec 24 11:49:26 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D1D06C8EFEF; Sat, 24 Dec 2016 11:49:26 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 A17247AF; Sat, 24 Dec 2016 11:49:26 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBOBnPVn094811; Sat, 24 Dec 2016 11:49:25 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBOBnPFd094810; Sat, 24 Dec 2016 11:49:25 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612241149.uBOBnPFd094810@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Sat, 24 Dec 2016 11:49:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310503 - head/contrib/bsnmp/snmp_target X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Sat, 24 Dec 2016 11:49:26 -0000 Author: ngie Date: Sat Dec 24 11:49:25 2016 New Revision: 310503 URL: https://svnweb.freebsd.org/changeset/base/310503 Log: style(9): delete stray trailing whitespace after break statement MFC after: 3 days Modified: head/contrib/bsnmp/snmp_target/target_snmp.c Modified: head/contrib/bsnmp/snmp_target/target_snmp.c ============================================================================== --- head/contrib/bsnmp/snmp_target/target_snmp.c Sat Dec 24 11:47:47 2016 (r310502) +++ head/contrib/bsnmp/snmp_target/target_snmp.c Sat Dec 24 11:49:25 2016 (r310503) @@ -299,7 +299,7 @@ op_snmp_target_addrs(struct snmp_context return (target_delete_address(addrs)); break; default: - break; + break; } return (SNMP_ERR_NOERROR); From owner-svn-src-head@freebsd.org Sat Dec 24 12:50:19 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 00DEEC8EF18; Sat, 24 Dec 2016 12:50:19 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 C40221077; Sat, 24 Dec 2016 12:50:18 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBOCoHeK019981; Sat, 24 Dec 2016 12:50:17 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBOCoH8C019980; Sat, 24 Dec 2016 12:50:17 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612241250.uBOCoH8C019980@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Sat, 24 Dec 2016 12:50:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310504 - head/usr.sbin/syslogd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Sat, 24 Dec 2016 12:50:19 -0000 Author: ngie Date: Sat Dec 24 12:50:17 2016 New Revision: 310504 URL: https://svnweb.freebsd.org/changeset/base/310504 Log: Unbreak syslogd after r310494 Don't close all file descriptors greater than STDERR_FILENO (2) in waitdaemon(..) -- only close fd (file descriptor for /dev/null used in subsequent calls to dup2) if it's greater than STDERR_FILENO. Reported by: subbsd@gmail.com, danny@cs.huji.ac.il Pointyhat to: hrs X-MFC with: r310494 Modified: head/usr.sbin/syslogd/syslogd.c Modified: head/usr.sbin/syslogd/syslogd.c ============================================================================== --- head/usr.sbin/syslogd/syslogd.c Sat Dec 24 11:49:25 2016 (r310503) +++ head/usr.sbin/syslogd/syslogd.c Sat Dec 24 12:50:17 2016 (r310504) @@ -2348,7 +2348,8 @@ waitdaemon(int maxwait) (void)dup2(fd, STDIN_FILENO); (void)dup2(fd, STDOUT_FILENO); (void)dup2(fd, STDERR_FILENO); - closefrom(STDERR_FILENO + 1); + if (fd > STDERR_FILENO) + (void)close(fd); } return (getppid()); } From owner-svn-src-head@freebsd.org Sat Dec 24 13:07:16 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2EDFEC8EB0D; Sat, 24 Dec 2016 13:07:16 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: from mail-pg0-x244.google.com (mail-pg0-x244.google.com [IPv6:2607:f8b0:400e:c05::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id F007210EA; Sat, 24 Dec 2016 13:07:15 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: by mail-pg0-x244.google.com with SMTP id i5so3689526pgh.2; Sat, 24 Dec 2016 05:07:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:mime-version:from:in-reply-to:date:cc:message-id:references :to; bh=n7OkXlwPcktNLnJkacayhGlxd5rtvfy4AcIUw2J7rmA=; b=El5iwS3m4lMkOP90I7bjBS4cpCfHwtIkiBSaqTat4m8TTu29XVX3F7QCN6SklMJJ86 RFETGn4H7ksB2XQaMD0eZhmECxGYnFpFAW7yKiN2FBfH7H7bNcC+EK0vx5gSk6j5xxap 3Uj9f5tr2yTRccknem6EY3lCG/iVXshqKK5J4dEloPzgWOK3oND7IITYmwokynbQEdD8 zJrRHp4qh2Yt68HonelLKAFF74uxodV2sIB9bWXIcH50+2wN4XychUewV6YEfIeoe2IQ DxWa7rdqVOpaa6LbxLJUWYz1AV+l4wO2rYTzNFV4P3vjUJBn+IHO5d4AyVwRbdQk/Jp/ XL3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:mime-version:from:in-reply-to:date:cc :message-id:references:to; bh=n7OkXlwPcktNLnJkacayhGlxd5rtvfy4AcIUw2J7rmA=; b=Hww67dt74NSCzVIcVN9E+yowsEsi5cZ5gElv6G4D2YWVgMvJpGRugawNKn2v3v2obg BhvPpHlE0ox7/xyal6vTnrgJRa1ZoHB5IWGfat5gKOC+ujbjqx6d1iHQ6xypLFBiI0QH BlGnrUevQUoOfT5n1yWy+oTl+IxDaObXWh9xiT36r+kLyNu8+WlwjKaSRQ2LsCEgbAIE SIhVYeCcRd08PUDdAn3gxOZPvrmus3rwCJPbykhuw/6nlwLVUjUfJDPKHJu5Y/1F3d0O eb77uKrzKpXMrNNNUC2/ANPcNA5acQc8+1MS4qLvLkyZ1sMPi8A3Klm8gd4HzpgHfwWP i7GA== X-Gm-Message-State: AIkVDXKd4YKgcxCeYN490uDE0ZJAm6x3pEMS3QUq9vsRR7PD8c98XX1od2vfLRAbpj34YA== X-Received: by 10.99.135.200 with SMTP id i191mr34371934pge.162.1482584835541; Sat, 24 Dec 2016 05:07:15 -0800 (PST) Received: from [192.168.20.12] (c-73-19-52-228.hsd1.wa.comcast.net. [73.19.52.228]) by smtp.gmail.com with ESMTPSA id t3sm27035152pfb.60.2016.12.24.05.07.14 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 24 Dec 2016 05:07:14 -0800 (PST) Subject: Re: svn commit: r309774 - head/contrib/netbsd-tests/fs/tmpfs Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Content-Type: multipart/signed; boundary="Apple-Mail=_D0346E5E-0F45-40F3-8517-A0C671F064F8"; protocol="application/pgp-signature"; micalg=pgp-sha512 X-Pgp-Agent: GPGMail From: "Ngie Cooper (yaneurabeya)" In-Reply-To: <20161210103511.GO54029@kib.kiev.ua> Date: Sat, 24 Dec 2016 05:07:14 -0800 Cc: Ngie Cooper , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Message-Id: <060D8CAD-E4A1-4984-AD97-FDF0B96A004A@gmail.com> References: <201612092250.uB9MohnP008576@repo.freebsd.org> <20161210103511.GO54029@kib.kiev.ua> To: Konstantin Belousov X-Mailer: Apple Mail (2.3124) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Sat, 24 Dec 2016 13:07:16 -0000 --Apple-Mail=_D0346E5E-0F45-40F3-8517-A0C671F064F8 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Dec 10, 2016, at 02:35, Konstantin Belousov = wrote: =E2=80=A6 > Why this test is under fs/tmpfs ? I was not able to see how tmpfs is > used for this test. test_mount (the first command executed in the testcases), sets up a = tmpfs mount. Thus, the test is ensuring that md(4) devices (or vnd(4) in = the case of NetBSD) can be backed on tmpfs mounts. Thanks! -Ngie --Apple-Mail=_D0346E5E-0F45-40F3-8517-A0C671F064F8 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iQIcBAEBCgAGBQJYXnMCAAoJEPWDqSZpMIYVgLwQAIY0bQlMX6C/mL2LDvVRQ2n6 4hx/0Jdcyur4H1Rjus9MACsQKAr6U/cCIiGoxWp4zUqWEyWXfcFdv29fXlqSONhf TtwkLo1Td/rhCIpI1jWa0m5pzDaa0YprXDlbxsPh+N2jDVRuKCuk9wIsuwQP2hXH rR2+2eG5ti8BxDiakDdBe14bqM+AYd3v3Z9b+KVimC2nnG5xF2OzL2aL8Nzdq3HQ Asc9AgK5KLctDkhScXSQsH619BvJW/JxSYyd7tHwjQvncj+OP68d0mw7ITzsyOnJ oiolBrJUWlXUEFtEIjamaqYQIrVwPXFeowG0s9G4nStS122OlWSn+2wP4BOiRL38 XtXcRsxOfSmUGGgQ3yy5jNN2R5rbTQe4g1B2S3Xo2epgQbVEr0DlJ0OYBEZohTKE yf/ZcxsnQuhzfhdeU7OxJUziQ6NOfrYVtODFgz/081/kzTF3DNirT7N8D8Bp2O8n Qsf7RhYa+cC5RTb5kuHcZYf29kqcM/dHARBbK2aJ1l6VuxaD3IjBWUBCKZ/mNnAq F2dp6uUaq262KllUTA2jKJsvXnC4jzK12VJ0oyYIZvxLZtrdZP3SDH/KYNp4KAz4 y2XxrkZPXIneZQEd4PwAAZadcm97HGEk3AensGr5L37WmbRzzCwTAGfqE9RonuZR XRmVWRVFFX19X8NKR+Fv =pC8p -----END PGP SIGNATURE----- --Apple-Mail=_D0346E5E-0F45-40F3-8517-A0C671F064F8-- From owner-svn-src-head@freebsd.org Sat Dec 24 13:55:00 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 288F2C8FA46; Sat, 24 Dec 2016 13:55:00 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from mail.allbsd.org (gatekeeper.allbsd.org [IPv6:2001:2f0:104:e001::32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.allbsd.org", Issuer "RapidSSL SHA256 CA - G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9D21FFDE; Sat, 24 Dec 2016 13:54:59 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from mail-d.allbsd.org (p2027-ipbf1605funabasi.chiba.ocn.ne.jp [123.225.191.27]) (authenticated bits=56) by mail.allbsd.org (8.15.2/8.15.2) with ESMTPSA id uBODsZWP081360 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) (Client CN "/OU=GT07882699/OU=See+20www.rapidssl.com/resources/cps+20+28c+2915/OU=Domain+20Control+20Validated+20-+20RapidSSL+28R+29/CN=*.allbsd.org", Issuer "/C=US/O=GeoTrust+20Inc./CN=RapidSSL+20SHA256+20CA+20-+20G3"); Sat, 24 Dec 2016 22:54:55 +0900 (JST) (envelope-from hrs@FreeBSD.org) Received: from alph.allbsd.org (alph.allbsd.org [192.168.0.10]) by mail-d.allbsd.org (8.15.2/8.15.2) with ESMTPS id uBODrIZ2005918 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sat, 24 Dec 2016 22:53:18 +0900 (JST) (envelope-from hrs@FreeBSD.org) Received: from localhost (localhost [IPv6:::1]) (authenticated bits=0) by alph.allbsd.org (8.15.2/8.15.2) with ESMTPA id uBODrGAF005914; Sat, 24 Dec 2016 22:53:17 +0900 (JST) (envelope-from hrs@FreeBSD.org) Date: Sat, 24 Dec 2016 22:52:21 +0900 (JST) Message-Id: <20161224.225221.1424676865406190118.hrs@allbsd.org> To: ngie@FreeBSD.org Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r310504 - head/usr.sbin/syslogd From: Hiroki Sato In-Reply-To: <201612241250.uBOCoH8C019980@repo.freebsd.org> References: <201612241250.uBOCoH8C019980@repo.freebsd.org> X-PGPkey-fingerprint: BDB3 443F A5DD B3D0 A530 FFD7 4F2C D3D8 2793 CF2D X-Mailer: Mew version 6.7 on Emacs 25.1 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Multipart/Signed; protocol="application/pgp-signature"; micalg=pgp-sha1; boundary="--Security_Multipart(Sat_Dec_24_22_52_21_2016_960)--" Content-Transfer-Encoding: 7bit X-Virus-Scanned: clamav-milter 0.99 at gatekeeper.allbsd.org X-Virus-Status: Clean X-Greylist: Sender DNS name whitelisted, not delayed by milter-greylist-4.4.3 (mail.allbsd.org [133.31.130.32]); Sat, 24 Dec 2016 22:54:56 +0900 (JST) X-Spam-Status: No, score=-99.9 required=13.0 tests=CONTENT_TYPE_PRESENT, QENCPTR1,USER_IN_WHITELIST autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on gatekeeper.allbsd.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Sat, 24 Dec 2016 13:55:00 -0000 ----Security_Multipart(Sat_Dec_24_22_52_21_2016_960)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Ngie Cooper wrote in <201612241250.uBOCoH8C019980@repo.freebsd.org>: ng> Author: ngie ng> Date: Sat Dec 24 12:50:17 2016 ng> New Revision: 310504 ng> URL: https://svnweb.freebsd.org/changeset/base/310504 ng> ng> Log: ng> Unbreak syslogd after r310494 ng> ng> Don't close all file descriptors greater than STDERR_FILENO (2) in ng> waitdaemon(..) -- only close fd (file descriptor for /dev/null used in ng> subsequent calls to dup2) if it's greater than STDERR_FILENO. ng> ng> Reported by: subbsd@gmail.com, danny@cs.huji.ac.il ng> Pointyhat to: hrs ng> X-MFC with: r310494 Thanks! -- Hiroki ----Security_Multipart(Sat_Dec_24_22_52_21_2016_960)-- Content-Type: application/pgp-signature Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEABECAAYFAlhefZUACgkQTyzT2CeTzy20+gCfZPr0uOkfw3mrhXkfiw7RnDK5 FwkAoLbMjOUaPH5aQ3TfnS/+DG0uD34l =Eeir -----END PGP SIGNATURE----- ----Security_Multipart(Sat_Dec_24_22_52_21_2016_960)---- From owner-svn-src-head@freebsd.org Sat Dec 24 17:42:36 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 43EEDC8F201; Sat, 24 Dec 2016 17:42:36 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 0C4F31C8E; Sat, 24 Dec 2016 17:42:35 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBOHgZmD045297; Sat, 24 Dec 2016 17:42:35 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBOHgYQp045291; Sat, 24 Dec 2016 17:42:34 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201612241742.uBOHgYQp045291@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sat, 24 Dec 2016 17:42:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310524 - in head/sys/cam: ctl scsi X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Sat, 24 Dec 2016 17:42:36 -0000 Author: mav Date: Sat Dec 24 17:42:34 2016 New Revision: 310524 URL: https://svnweb.freebsd.org/changeset/base/310524 Log: Improve length handling when writing sense data. - Allow maximal sense size limitation via Control Extension mode page. - When sense size limited, include descriptors atomically: whole or none. - Set new SDAT_OVFL bit if some descriptors don't fit the limit. - Report real written sense length instead of static maximal 252 bytes. MFC after: 2 weeks Modified: head/sys/cam/ctl/ctl.c head/sys/cam/ctl/ctl_error.c head/sys/cam/ctl/ctl_error.h head/sys/cam/ctl/ctl_private.h head/sys/cam/scsi/scsi_all.c head/sys/cam/scsi/scsi_all.h Modified: head/sys/cam/ctl/ctl.c ============================================================================== --- head/sys/cam/ctl/ctl.c Sat Dec 24 14:50:13 2016 (r310523) +++ head/sys/cam/ctl/ctl.c Sat Dec 24 17:42:34 2016 (r310524) @@ -278,7 +278,7 @@ const static struct scsi_control_ext_pag /*page_length*/{CTL_CEM_LEN >> 8, CTL_CEM_LEN}, /*flags*/0, /*prio*/0, - /*max_sense*/0 + /*max_sense*/0xff }; const static struct scsi_info_exceptions_page ie_page_default = { @@ -9220,6 +9220,7 @@ ctl_request_sense(struct ctl_scsiio *cts struct ctl_lun *lun; uint32_t initidx; int have_error; + u_int sense_len = SSD_FULL_SIZE; scsi_sense_data_type sense_format; ctl_ua_type ua_type; uint8_t asc = 0, ascq = 0; @@ -9263,7 +9264,7 @@ ctl_request_sense(struct ctl_scsiio *cts ((lun->flags & CTL_LUN_PRIMARY_SC) == 0 && softc->ha_link < CTL_HA_LINK_UNKNOWN)) { /* "Logical unit not supported" */ - ctl_set_sense_data(sense_ptr, NULL, sense_format, + ctl_set_sense_data(sense_ptr, &sense_len, NULL, sense_format, /*current_error*/ 1, /*sense_key*/ SSD_KEY_ILLEGAL_REQUEST, /*asc*/ 0x25, @@ -9319,7 +9320,8 @@ ctl_request_sense(struct ctl_scsiio *cts } else #endif if (have_error == 0) { - ua_type = ctl_build_ua(lun, initidx, sense_ptr, sense_format); + ua_type = ctl_build_ua(lun, initidx, sense_ptr, &sense_len, + sense_format); if (ua_type != CTL_UA_NONE) have_error = 1; } @@ -9331,7 +9333,7 @@ ctl_request_sense(struct ctl_scsiio *cts asc = lun->ie_asc; ascq = lun->ie_ascq; } - ctl_set_sense_data(sense_ptr, lun, sense_format, + ctl_set_sense_data(sense_ptr, &sense_len, lun, sense_format, /*current_error*/ 1, /*sense_key*/ SSD_KEY_NO_SENSE, /*asc*/ asc, @@ -11635,14 +11637,15 @@ ctl_scsiio_precheck(struct ctl_softc *so */ if ((entry->flags & CTL_CMD_FLAG_NO_SENSE) == 0) { ctl_ua_type ua_type; + u_int sense_len = 0; ua_type = ctl_build_ua(lun, initidx, &ctsio->sense_data, - SSD_TYPE_NONE); + &sense_len, SSD_TYPE_NONE); if (ua_type != CTL_UA_NONE) { mtx_unlock(&lun->lun_lock); ctsio->scsi_status = SCSI_STATUS_CHECK_COND; ctsio->io_hdr.status = CTL_SCSI_ERROR | CTL_AUTOSENSE; - ctsio->sense_len = SSD_FULL_SIZE; + ctsio->sense_len = sense_len; ctl_done((union ctl_io *)ctsio); return (retval); } Modified: head/sys/cam/ctl/ctl_error.c ============================================================================== --- head/sys/cam/ctl/ctl_error.c Sat Dec 24 14:50:13 2016 (r310523) +++ head/sys/cam/ctl/ctl_error.c Sat Dec 24 17:42:34 2016 (r310524) @@ -65,9 +65,9 @@ __FBSDID("$FreeBSD$"); #include void -ctl_set_sense_data_va(struct scsi_sense_data *sense_data, void *lunptr, - scsi_sense_data_type sense_format, int current_error, - int sense_key, int asc, int ascq, va_list ap) +ctl_set_sense_data_va(struct scsi_sense_data *sense_data, u_int *sense_len, + void *lunptr, scsi_sense_data_type sense_format, int current_error, + int sense_key, int asc, int ascq, va_list ap) { struct ctl_lun *lun; @@ -89,20 +89,30 @@ ctl_set_sense_data_va(struct scsi_sense_ sense_format = SSD_TYPE_FIXED; } - scsi_set_sense_data_va(sense_data, sense_format, current_error, - sense_key, asc, ascq, ap); + /* + * Determine maximum sense data length to return. + */ + if (*sense_len == 0) { + if ((lun != NULL) && (lun->MODE_CTRLE.max_sense != 0)) + *sense_len = lun->MODE_CTRLE.max_sense; + else + *sense_len = SSD_FULL_SIZE; + } + + scsi_set_sense_data_va(sense_data, sense_len, sense_format, + current_error, sense_key, asc, ascq, ap); } void -ctl_set_sense_data(struct scsi_sense_data *sense_data, void *lunptr, - scsi_sense_data_type sense_format, int current_error, - int sense_key, int asc, int ascq, ...) +ctl_set_sense_data(struct scsi_sense_data *sense_data, u_int *sense_len, + void *lunptr, scsi_sense_data_type sense_format, int current_error, + int sense_key, int asc, int ascq, ...) { va_list ap; va_start(ap, ascq); - ctl_set_sense_data_va(sense_data, lunptr, sense_format, current_error, - sense_key, asc, ascq, ap); + ctl_set_sense_data_va(sense_data, sense_len, lunptr, sense_format, + current_error, sense_key, asc, ascq, ap); va_end(ap); } @@ -112,6 +122,7 @@ ctl_set_sense(struct ctl_scsiio *ctsio, { va_list ap; struct ctl_lun *lun; + u_int sense_len; /* * The LUN can't go away until all of the commands have been @@ -121,7 +132,8 @@ ctl_set_sense(struct ctl_scsiio *ctsio, lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; va_start(ap, ascq); - ctl_set_sense_data_va(&ctsio->sense_data, + sense_len = 0; + ctl_set_sense_data_va(&ctsio->sense_data, &sense_len, lun, SSD_TYPE_NONE, current_error, @@ -132,7 +144,7 @@ ctl_set_sense(struct ctl_scsiio *ctsio, va_end(ap); ctsio->scsi_status = SCSI_STATUS_CHECK_COND; - ctsio->sense_len = SSD_FULL_SIZE; + ctsio->sense_len = sense_len; ctsio->io_hdr.status = CTL_SCSI_ERROR | CTL_AUTOSENSE; } @@ -148,6 +160,7 @@ ctl_sense_to_desc(struct scsi_sense_data { struct scsi_sense_stream stream_sense; int current_error; + u_int sense_len; uint8_t stream_bits; bzero(sense_dest, sizeof(*sense_dest)); @@ -173,7 +186,8 @@ ctl_sense_to_desc(struct scsi_sense_data * value is set in the fixed sense data, set it in the descriptor * data. Otherwise, skip it. */ - ctl_set_sense_data((struct scsi_sense_data *)sense_dest, + sense_len = SSD_FULL_SIZE; + ctl_set_sense_data((struct scsi_sense_data *)sense_dest, &sense_len, /*lun*/ NULL, /*sense_format*/ SSD_TYPE_DESC, current_error, @@ -233,6 +247,7 @@ ctl_sense_to_fixed(struct scsi_sense_dat int info_size = 0, cmd_size = 0, fru_size = 0; int sks_size = 0, stream_size = 0; int pos; + u_int sense_len; if ((sense_src->error_code & SSD_ERRCODE) == SSD_DESC_CURRENT_ERROR) current_error = 1; @@ -318,7 +333,8 @@ ctl_sense_to_fixed(struct scsi_sense_dat } } - ctl_set_sense_data((struct scsi_sense_data *)sense_dest, + sense_len = SSD_FULL_SIZE; + ctl_set_sense_data((struct scsi_sense_data *)sense_dest, &sense_len, /*lun*/ NULL, /*sense_format*/ SSD_TYPE_FIXED, current_error, @@ -501,12 +517,13 @@ ctl_build_qae(struct ctl_lun *lun, uint3 resp[0] |= 0x20; resp[1] = asc; resp[2] = ascq; - return (ua); + return (ua_to_build); } ctl_ua_type ctl_build_ua(struct ctl_lun *lun, uint32_t initidx, - struct scsi_sense_data *sense, scsi_sense_data_type sense_format) + struct scsi_sense_data *sense, u_int *sense_len, + scsi_sense_data_type sense_format) { ctl_ua_type *ua; ctl_ua_type ua_to_build, ua_to_clear; @@ -540,7 +557,7 @@ ctl_build_ua(struct ctl_lun *lun, uint32 info = NULL; ctl_ua_to_ascq(lun, ua_to_build, &asc, &ascq, &ua_to_clear, &info); - ctl_set_sense_data(sense, lun, sense_format, /*current_error*/ 1, + ctl_set_sense_data(sense, sense_len, lun, sense_format, 1, /*sense_key*/ SSD_KEY_UNIT_ATTENTION, asc, ascq, ((info != NULL) ? SSD_ELEM_INFO : SSD_ELEM_SKIP), 8, info, SSD_ELEM_NONE); Modified: head/sys/cam/ctl/ctl_error.h ============================================================================== --- head/sys/cam/ctl/ctl_error.h Sat Dec 24 14:50:13 2016 (r310523) +++ head/sys/cam/ctl/ctl_error.h Sat Dec 24 17:42:34 2016 (r310524) @@ -45,12 +45,12 @@ struct ctl_lun; -void ctl_set_sense_data_va(struct scsi_sense_data *sense_data, void *lun, - scsi_sense_data_type sense_format, int current_error, - int sense_key, int asc, int ascq, va_list ap); -void ctl_set_sense_data(struct scsi_sense_data *sense_data, void *lun, - scsi_sense_data_type sense_format, int current_error, - int sense_key, int asc, int ascq, ...); +void ctl_set_sense_data_va(struct scsi_sense_data *sense_data, u_int *sense_len, + void *lun, scsi_sense_data_type sense_format, int current_error, + int sense_key, int asc, int ascq, va_list ap); +void ctl_set_sense_data(struct scsi_sense_data *sense_data, u_int *sense_len, + void *lun, scsi_sense_data_type sense_format, int current_error, + int sense_key, int asc, int ascq, ...); void ctl_set_sense(struct ctl_scsiio *ctsio, int current_error, int sense_key, int asc, int ascq, ...); void ctl_sense_to_desc(struct scsi_sense_data_fixed *sense_src, @@ -60,7 +60,8 @@ void ctl_sense_to_fixed(struct scsi_sens void ctl_set_ua(struct ctl_scsiio *ctsio, int asc, int ascq); ctl_ua_type ctl_build_qae(struct ctl_lun *lun, uint32_t initidx, uint8_t *resp); ctl_ua_type ctl_build_ua(struct ctl_lun *lun, uint32_t initidx, - struct scsi_sense_data *sense, scsi_sense_data_type sense_format); + struct scsi_sense_data *sense, u_int *sense_len, + scsi_sense_data_type sense_format); void ctl_set_overlapped_cmd(struct ctl_scsiio *ctsio); void ctl_set_overlapped_tag(struct ctl_scsiio *ctsio, uint8_t tag); void ctl_set_invalid_field(struct ctl_scsiio *ctsio, int sks_valid, int command, Modified: head/sys/cam/ctl/ctl_private.h ============================================================================== --- head/sys/cam/ctl/ctl_private.h Sat Dec 24 14:50:13 2016 (r310523) +++ head/sys/cam/ctl/ctl_private.h Sat Dec 24 17:42:34 2016 (r310524) @@ -285,7 +285,7 @@ static const struct ctl_page_index page_ CTL_PAGE_FLAG_ALL, NULL, ctl_default_page_handler}, {SMS_CONTROL_MODE_PAGE | SMPH_SPF, 0x01, sizeof(struct scsi_control_ext_page), NULL, - CTL_PAGE_FLAG_ALL, NULL, NULL}, + CTL_PAGE_FLAG_ALL, NULL, ctl_default_page_handler}, {SMS_INFO_EXCEPTIONS_PAGE, 0, sizeof(struct scsi_info_exceptions_page), NULL, CTL_PAGE_FLAG_ALL, NULL, ctl_ie_page_handler}, {SMS_INFO_EXCEPTIONS_PAGE | SMPH_SPF, 0x02, Modified: head/sys/cam/scsi/scsi_all.c ============================================================================== --- head/sys/cam/scsi/scsi_all.c Sat Dec 24 14:50:13 2016 (r310523) +++ head/sys/cam/scsi/scsi_all.c Sat Dec 24 17:42:34 2016 (r310524) @@ -3742,341 +3742,300 @@ scsi_find_desc(struct scsi_sense_data_de } /* - * Fill in SCSI sense data with the specified parameters. This routine can - * fill in either fixed or descriptor type sense data. + * Fill in SCSI descriptor sense data with the specified parameters. */ -void -scsi_set_sense_data_va(struct scsi_sense_data *sense_data, - scsi_sense_data_type sense_format, int current_error, - int sense_key, int asc, int ascq, va_list ap) +static void +scsi_set_sense_data_desc_va(struct scsi_sense_data *sense_data, + u_int *sense_len, scsi_sense_data_type sense_format, int current_error, + int sense_key, int asc, int ascq, va_list ap) { - int descriptor_sense; + struct scsi_sense_data_desc *sense; scsi_sense_elem_type elem_type; + int space, len; + uint8_t *desc, *data; - /* - * Determine whether to return fixed or descriptor format sense - * data. If the user specifies SSD_TYPE_NONE for some reason, - * they'll just get fixed sense data. - */ - if (sense_format == SSD_TYPE_DESC) - descriptor_sense = 1; - else - descriptor_sense = 0; - - /* - * Zero the sense data, so that we don't pass back any garbage data - * to the user. - */ memset(sense_data, 0, sizeof(*sense_data)); + sense = (struct scsi_sense_data_desc *)sense_data; + if (current_error != 0) + sense->error_code = SSD_DESC_CURRENT_ERROR; + else + sense->error_code = SSD_DESC_DEFERRED_ERROR; + sense->sense_key = sense_key; + sense->add_sense_code = asc; + sense->add_sense_code_qual = ascq; + sense->flags = 0; + + desc = &sense->sense_desc[0]; + space = *sense_len - offsetof(struct scsi_sense_data_desc, sense_desc); + while ((elem_type = va_arg(ap, scsi_sense_elem_type)) != + SSD_ELEM_NONE) { + if (elem_type >= SSD_ELEM_MAX) { + printf("%s: invalid sense type %d\n", __func__, + elem_type); + break; + } + len = va_arg(ap, int); + data = va_arg(ap, uint8_t *); - if (descriptor_sense != 0) { - struct scsi_sense_data_desc *sense; - - sense = (struct scsi_sense_data_desc *)sense_data; - /* - * The descriptor sense format eliminates the use of the - * valid bit. - */ - if (current_error != 0) - sense->error_code = SSD_DESC_CURRENT_ERROR; - else - sense->error_code = SSD_DESC_DEFERRED_ERROR; - sense->sense_key = sense_key; - sense->add_sense_code = asc; - sense->add_sense_code_qual = ascq; - /* - * Start off with no extra length, since the above data - * fits in the standard descriptor sense information. - */ - sense->extra_len = 0; - while ((elem_type = (scsi_sense_elem_type)va_arg(ap, - scsi_sense_elem_type)) != SSD_ELEM_NONE) { - int sense_len, len_to_copy; - uint8_t *data; - - if (elem_type >= SSD_ELEM_MAX) { - printf("%s: invalid sense type %d\n", __func__, - elem_type); + switch (elem_type) { + case SSD_ELEM_SKIP: + break; + case SSD_ELEM_DESC: + if (space < len) { + sense->flags |= SSDD_SDAT_OVFL; break; } + bcopy(data, desc, len); + desc += len; + space -= len; + break; + case SSD_ELEM_SKS: { + struct scsi_sense_sks *sks = (void *)desc; - sense_len = (int)va_arg(ap, int); - len_to_copy = MIN(sense_len, SSD_EXTRA_MAX - - sense->extra_len); - data = (uint8_t *)va_arg(ap, uint8_t *); - - /* - * We've already consumed the arguments for this one. - */ - if (elem_type == SSD_ELEM_SKIP) - continue; - - switch (elem_type) { - case SSD_ELEM_DESC: { - - /* - * This is a straight descriptor. All we - * need to do is copy the data in. - */ - bcopy(data, &sense->sense_desc[ - sense->extra_len], len_to_copy); - sense->extra_len += len_to_copy; + if (len > sizeof(sks->sense_key_spec)) + break; + if (space < sizeof(*sks)) { + sense->flags |= SSDD_SDAT_OVFL; break; } - case SSD_ELEM_SKS: { - struct scsi_sense_sks sks; - - bzero(&sks, sizeof(sks)); + sks->desc_type = SSD_DESC_SKS; + sks->length = sizeof(*sks) - + (offsetof(struct scsi_sense_sks, length) + 1); + bcopy(data, &sks->sense_key_spec, len); + desc += sizeof(*sks); + space -= sizeof(*sks); + break; + } + case SSD_ELEM_COMMAND: { + struct scsi_sense_command *cmd = (void *)desc; - /* - * This is already-formatted sense key - * specific data. We just need to fill out - * the header and copy everything in. - */ - bcopy(data, &sks.sense_key_spec, - MIN(len_to_copy, - sizeof(sks.sense_key_spec))); - - sks.desc_type = SSD_DESC_SKS; - sks.length = sizeof(sks) - - offsetof(struct scsi_sense_sks, reserved1); - bcopy(&sks,&sense->sense_desc[sense->extra_len], - sizeof(sks)); - sense->extra_len += sizeof(sks); + if (len > sizeof(cmd->command_info)) + break; + if (space < sizeof(*cmd)) { + sense->flags |= SSDD_SDAT_OVFL; break; } - case SSD_ELEM_INFO: - case SSD_ELEM_COMMAND: { - struct scsi_sense_command cmd; - struct scsi_sense_info info; - uint8_t *data_dest; - uint8_t *descriptor; - int descriptor_size, i, copy_len; - - bzero(&cmd, sizeof(cmd)); - bzero(&info, sizeof(info)); - - /* - * Command or information data. The - * operate in pretty much the same way. - */ - if (elem_type == SSD_ELEM_COMMAND) { - len_to_copy = MIN(len_to_copy, - sizeof(cmd.command_info)); - descriptor = (uint8_t *)&cmd; - descriptor_size = sizeof(cmd); - data_dest =(uint8_t *)&cmd.command_info; - cmd.desc_type = SSD_DESC_COMMAND; - cmd.length = sizeof(cmd) - - offsetof(struct scsi_sense_command, - reserved); - } else { - len_to_copy = MIN(len_to_copy, - sizeof(info.info)); - descriptor = (uint8_t *)&info; - descriptor_size = sizeof(cmd); - data_dest = (uint8_t *)&info.info; - info.desc_type = SSD_DESC_INFO; - info.byte2 = SSD_INFO_VALID; - info.length = sizeof(info) - - offsetof(struct scsi_sense_info, - byte2); - } - - /* - * Copy this in reverse because the spec - * (SPC-4) says that when 4 byte quantities - * are stored in this 8 byte field, the - * first four bytes shall be 0. - * - * So we fill the bytes in from the end, and - * if we have less than 8 bytes to copy, - * the initial, most significant bytes will - * be 0. - */ - for (i = sense_len - 1; i >= 0 && - len_to_copy > 0; i--, len_to_copy--) - data_dest[len_to_copy - 1] = data[i]; + cmd->desc_type = SSD_DESC_COMMAND; + cmd->length = sizeof(*cmd) - + (offsetof(struct scsi_sense_command, length) + 1); + bcopy(data, &cmd->command_info[ + sizeof(cmd->command_info) - len], len); + desc += sizeof(*cmd); + space -= sizeof(*cmd); + break; + } + case SSD_ELEM_INFO: { + struct scsi_sense_info *info = (void *)desc; - /* - * This calculation looks much like the - * initial len_to_copy calculation, but - * we have to do it again here, because - * we're looking at a larger amount that - * may or may not fit. It's not only the - * data the user passed in, but also the - * rest of the descriptor. - */ - copy_len = MIN(descriptor_size, - SSD_EXTRA_MAX - sense->extra_len); - bcopy(descriptor, &sense->sense_desc[ - sense->extra_len], copy_len); - sense->extra_len += copy_len; + if (len > sizeof(info->info)) break; - } - case SSD_ELEM_FRU: { - struct scsi_sense_fru fru; - int copy_len; - - bzero(&fru, sizeof(fru)); - - fru.desc_type = SSD_DESC_FRU; - fru.length = sizeof(fru) - - offsetof(struct scsi_sense_fru, reserved); - fru.fru = *data; - - copy_len = MIN(sizeof(fru), SSD_EXTRA_MAX - - sense->extra_len); - bcopy(&fru, &sense->sense_desc[ - sense->extra_len], copy_len); - sense->extra_len += copy_len; + if (space < sizeof(*info)) { + sense->flags |= SSDD_SDAT_OVFL; break; } - case SSD_ELEM_STREAM: { - struct scsi_sense_stream stream_sense; - int copy_len; - - bzero(&stream_sense, sizeof(stream_sense)); - stream_sense.desc_type = SSD_DESC_STREAM; - stream_sense.length = sizeof(stream_sense) - - offsetof(struct scsi_sense_stream, reserved); - stream_sense.byte3 = *data; - - copy_len = MIN(sizeof(stream_sense), - SSD_EXTRA_MAX - sense->extra_len); - bcopy(&stream_sense, &sense->sense_desc[ - sense->extra_len], copy_len); - sense->extra_len += copy_len; + info->desc_type = SSD_DESC_INFO; + info->length = sizeof(*info) - + (offsetof(struct scsi_sense_info, length) + 1); + info->byte2 = SSD_INFO_VALID; + bcopy(data, &info->info[sizeof(info->info) - len], len); + desc += sizeof(*info); + space -= sizeof(*info); + break; + } + case SSD_ELEM_FRU: { + struct scsi_sense_fru *fru = (void *)desc; + + if (len > sizeof(fru->fru)) break; - } - default: - /* - * We shouldn't get here, but if we do, do - * nothing. We've already consumed the - * arguments above. - */ + if (space < sizeof(*fru)) { + sense->flags |= SSDD_SDAT_OVFL; break; } + fru->desc_type = SSD_DESC_FRU; + fru->length = sizeof(*fru) - + (offsetof(struct scsi_sense_fru, length) + 1); + fru->fru = *data; + desc += sizeof(*fru); + space -= sizeof(*fru); + break; } - } else { - struct scsi_sense_data_fixed *sense; - - sense = (struct scsi_sense_data_fixed *)sense_data; - - if (current_error != 0) - sense->error_code = SSD_CURRENT_ERROR; - else - sense->error_code = SSD_DEFERRED_ERROR; + case SSD_ELEM_STREAM: { + struct scsi_sense_stream *stream = (void *)desc; - sense->flags = sense_key; - sense->add_sense_code = asc; - sense->add_sense_code_qual = ascq; - /* - * We've set the ASC and ASCQ, so we have 6 more bytes of - * valid data. If we wind up setting any of the other - * fields, we'll bump this to 10 extra bytes. - */ - sense->extra_len = 6; - - while ((elem_type = (scsi_sense_elem_type)va_arg(ap, - scsi_sense_elem_type)) != SSD_ELEM_NONE) { - int sense_len, len_to_copy; - uint8_t *data; - - if (elem_type >= SSD_ELEM_MAX) { - printf("%s: invalid sense type %d\n", __func__, - elem_type); + if (len > sizeof(stream->byte3)) + break; + if (space < sizeof(*stream)) { + sense->flags |= SSDD_SDAT_OVFL; break; } + stream->desc_type = SSD_DESC_STREAM; + stream->length = sizeof(*stream) - + (offsetof(struct scsi_sense_stream, length) + 1); + stream->byte3 = *data; + desc += sizeof(*stream); + space -= sizeof(*stream); + break; + } + default: /* - * If we get in here, just bump the extra length to - * 10 bytes. That will encompass anything we're - * going to set here. + * We shouldn't get here, but if we do, do nothing. + * We've already consumed the arguments above. */ - sense->extra_len = 10; - sense_len = (int)va_arg(ap, int); - data = (uint8_t *)va_arg(ap, uint8_t *); + break; + } + } + sense->extra_len = desc - &sense->sense_desc[0]; + *sense_len = offsetof(struct scsi_sense_data_desc, extra_len) + 1 + + sense->extra_len; +} - switch (elem_type) { - case SSD_ELEM_SKS: - /* - * The user passed in pre-formatted sense - * key specific data. - */ - bcopy(data, &sense->sense_key_spec[0], - MIN(sizeof(sense->sense_key_spec), - sense_len)); - break; - case SSD_ELEM_INFO: - case SSD_ELEM_COMMAND: { - uint8_t *data_dest; - int i; - - if (elem_type == SSD_ELEM_COMMAND) { - data_dest = &sense->cmd_spec_info[0]; - len_to_copy = MIN(sense_len, - sizeof(sense->cmd_spec_info)); - } else { - data_dest = &sense->info[0]; - len_to_copy = MIN(sense_len, - sizeof(sense->info)); - - /* Set VALID bit only if no overflow. */ - for (i = 0; i < sense_len - len_to_copy; - i++) { - if (data[i] != 0) - break; - } - if (i >= sense_len - len_to_copy) { - sense->error_code |= - SSD_ERRCODE_VALID; - } - } +/* + * Fill in SCSI fixed sense data with the specified parameters. + */ +static void +scsi_set_sense_data_fixed_va(struct scsi_sense_data *sense_data, + u_int *sense_len, scsi_sense_data_type sense_format, int current_error, + int sense_key, int asc, int ascq, va_list ap) +{ + struct scsi_sense_data_fixed *sense; + scsi_sense_elem_type elem_type; + uint8_t *data; + int len; - /* - * Copy this in reverse so that if we have - * less than 4 bytes to fill, the least - * significant bytes will be at the end. - * If we have more than 4 bytes, only the - * least significant bytes will be included. - */ - for (i = sense_len - 1; i >= 0 && - len_to_copy > 0; i--, len_to_copy--) - data_dest[len_to_copy - 1] = data[i]; + memset(sense_data, 0, sizeof(*sense_data)); + sense = (struct scsi_sense_data_fixed *)sense_data; + if (current_error != 0) + sense->error_code = SSD_CURRENT_ERROR; + else + sense->error_code = SSD_DEFERRED_ERROR; + sense->flags = sense_key & SSD_KEY; + sense->extra_len = 0; + if (*sense_len >= 13) { + sense->add_sense_code = asc; + sense->extra_len = MAX(sense->extra_len, 5); + } else + sense->flags |= SSD_SDAT_OVFL; + if (*sense_len >= 14) { + sense->add_sense_code_qual = ascq; + sense->extra_len = MAX(sense->extra_len, 6); + } else + sense->flags |= SSD_SDAT_OVFL; + while ((elem_type = va_arg(ap, scsi_sense_elem_type)) != + SSD_ELEM_NONE) { + if (elem_type >= SSD_ELEM_MAX) { + printf("%s: invalid sense type %d\n", __func__, + elem_type); + break; + } + len = va_arg(ap, int); + data = va_arg(ap, uint8_t *); + + switch (elem_type) { + case SSD_ELEM_SKIP: + break; + case SSD_ELEM_SKS: + if (len > sizeof(sense->sense_key_spec)) break; - } - case SSD_ELEM_FRU: - sense->fru = *data; + if (*sense_len < 18) { + sense->flags |= SSD_SDAT_OVFL; break; - case SSD_ELEM_STREAM: - sense->flags |= *data; + } + bcopy(data, &sense->sense_key_spec[0], len); + sense->extra_len = MAX(sense->extra_len, 10); + break; + case SSD_ELEM_COMMAND: + if (*sense_len < 12) { + sense->flags |= SSD_SDAT_OVFL; break; - case SSD_ELEM_DESC: - default: - - /* - * If the user passes in descriptor sense, - * we can't handle that in fixed format. - * So just skip it, and any unknown argument - * types. - */ + } + if (len > sizeof(sense->cmd_spec_info)) { + data += len - sizeof(sense->cmd_spec_info); + len -= len - sizeof(sense->cmd_spec_info); + } + bcopy(data, &sense->cmd_spec_info[ + sizeof(sense->cmd_spec_info) - len], len); + sense->extra_len = MAX(sense->extra_len, 4); + break; + case SSD_ELEM_INFO: + /* Set VALID bit only if no overflow. */ + sense->error_code |= SSD_ERRCODE_VALID; + while (len > sizeof(sense->info)) { + if (data[0] != 0) + sense->error_code &= ~SSD_ERRCODE_VALID; + data ++; + len --; + } + bcopy(data, &sense->info[sizeof(sense->info) - len], len); + break; + case SSD_ELEM_FRU: + if (*sense_len < 15) { + sense->flags |= SSD_SDAT_OVFL; break; } + sense->fru = *data; + sense->extra_len = MAX(sense->extra_len, 7); + break; + case SSD_ELEM_STREAM: + sense->flags |= *data & + (SSD_ILI | SSD_EOM | SSD_FILEMARK); + break; + default: + + /* + * We can't handle that in fixed format. Skip it. + */ + break; } } + *sense_len = offsetof(struct scsi_sense_data_fixed, extra_len) + 1 + + sense->extra_len; +} + +/* + * Fill in SCSI sense data with the specified parameters. This routine can + * fill in either fixed or descriptor type sense data. + */ +void +scsi_set_sense_data_va(struct scsi_sense_data *sense_data, u_int *sense_len, + scsi_sense_data_type sense_format, int current_error, + int sense_key, int asc, int ascq, va_list ap) +{ + + if (*sense_len > SSD_FULL_SIZE) + *sense_len = SSD_FULL_SIZE; + if (sense_format == SSD_TYPE_DESC) + scsi_set_sense_data_desc_va(sense_data, sense_len, + sense_format, current_error, sense_key, asc, ascq, ap); + else + scsi_set_sense_data_fixed_va(sense_data, sense_len, + sense_format, current_error, sense_key, asc, ascq, ap); +} + +void +scsi_set_sense_data(struct scsi_sense_data *sense_data, + scsi_sense_data_type sense_format, int current_error, + int sense_key, int asc, int ascq, ...) +{ + va_list ap; + u_int sense_len = SSD_FULL_SIZE; + + va_start(ap, ascq); + scsi_set_sense_data_va(sense_data, &sense_len, sense_format, + current_error, sense_key, asc, ascq, ap); + va_end(ap); } void -scsi_set_sense_data(struct scsi_sense_data *sense_data, +scsi_set_sense_data_len(struct scsi_sense_data *sense_data, u_int *sense_len, scsi_sense_data_type sense_format, int current_error, - int sense_key, int asc, int ascq, ...) + int sense_key, int asc, int ascq, ...) { va_list ap; va_start(ap, ascq); - scsi_set_sense_data_va(sense_data, sense_format, current_error, - sense_key, asc, ascq, ap); + scsi_set_sense_data_va(sense_data, sense_len, sense_format, + current_error, sense_key, asc, ascq, ap); va_end(ap); } Modified: head/sys/cam/scsi/scsi_all.h ============================================================================== --- head/sys/cam/scsi/scsi_all.h Sat Dec 24 14:50:13 2016 (r310523) +++ head/sys/cam/scsi/scsi_all.h Sat Dec 24 17:42:34 2016 (r310524) @@ -3196,11 +3196,12 @@ struct scsi_sense_data_fixed #define SSD_KEY_BLANK_CHECK 0x08 #define SSD_KEY_Vendor_Specific 0x09 #define SSD_KEY_COPY_ABORTED 0x0a -#define SSD_KEY_ABORTED_COMMAND 0x0b +#define SSD_KEY_ABORTED_COMMAND 0x0b #define SSD_KEY_EQUAL 0x0c #define SSD_KEY_VOLUME_OVERFLOW 0x0d #define SSD_KEY_MISCOMPARE 0x0e -#define SSD_KEY_COMPLETED 0x0f +#define SSD_KEY_COMPLETED 0x0f +#define SSD_SDAT_OVFL 0x10 #define SSD_ILI 0x20 #define SSD_EOM 0x40 #define SSD_FILEMARK 0x80 @@ -3238,7 +3239,9 @@ struct scsi_sense_data_desc uint8_t sense_key; uint8_t add_sense_code; uint8_t add_sense_code_qual; - uint8_t reserved[3]; + uint8_t flags; +#define SSDD_SDAT_OVFL 0x80 + uint8_t reserved[2]; /* * Note that SPC-4, section 4.5.2.1 says that the extra_len field * must be less than or equal to 244. @@ -3706,13 +3709,15 @@ void scsi_desc_iterate(struct scsi_sense void *), void *arg); uint8_t *scsi_find_desc(struct scsi_sense_data_desc *sense, u_int sense_len, uint8_t desc_type); -void scsi_set_sense_data(struct scsi_sense_data *sense_data, +void scsi_set_sense_data(struct scsi_sense_data *sense_data, scsi_sense_data_type sense_format, int current_error, int sense_key, int asc, int ascq, ...) ; +void scsi_set_sense_data_len(struct scsi_sense_data *sense_data, + u_int *sense_len, scsi_sense_data_type sense_format, int current_error, + int sense_key, int asc, int ascq, ...) ; void scsi_set_sense_data_va(struct scsi_sense_data *sense_data, - scsi_sense_data_type sense_format, - int current_error, int sense_key, int asc, - int ascq, va_list ap); + u_int *sense_len, scsi_sense_data_type sense_format, + int current_error, int sense_key, int asc, int ascq, va_list ap); int scsi_get_sense_info(struct scsi_sense_data *sense_data, u_int sense_len, uint8_t info_type, uint64_t *info, int64_t *signed_info); From owner-svn-src-head@freebsd.org Sat Dec 24 22:51:04 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8FBFAC8FDCA; Sat, 24 Dec 2016 22:51:04 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 5293B1AD0; Sat, 24 Dec 2016 22:51:04 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBOMp2Yp067914; Sat, 24 Dec 2016 22:51:02 GMT (envelope-from hrs@FreeBSD.org) Received: (from hrs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBOMp2bu067913; Sat, 24 Dec 2016 22:51:02 GMT (envelope-from hrs@FreeBSD.org) Message-Id: <201612242251.uBOMp2bu067913@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hrs set sender to hrs@FreeBSD.org using -f From: Hiroki Sato Date: Sat, 24 Dec 2016 22:51:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310527 - head/usr.bin/logger X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Sat, 24 Dec 2016 22:51:04 -0000 Author: hrs Date: Sat Dec 24 22:51:02 2016 New Revision: 310527 URL: https://svnweb.freebsd.org/changeset/base/310527 Log: Fix gcc build. Spotted by: lidl Modified: head/usr.bin/logger/logger.c Modified: head/usr.bin/logger/logger.c ============================================================================== --- head/usr.bin/logger/logger.c Sat Dec 24 20:36:27 2016 (r310526) +++ head/usr.bin/logger/logger.c Sat Dec 24 22:51:02 2016 (r310527) @@ -99,6 +99,7 @@ main(int argc, char *argv[]) host = NULL; svcname = "syslog"; src = NULL; + socks = NULL; pri = LOG_USER | LOG_NOTICE; logflags = 0; unsetenv("TZ"); From owner-svn-src-head@freebsd.org Sat Dec 24 23:29:52 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0213FC8FEE7; Sat, 24 Dec 2016 23:29:52 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 AC0021147; Sat, 24 Dec 2016 23:29:51 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBONTodl083192; Sat, 24 Dec 2016 23:29:50 GMT (envelope-from hrs@FreeBSD.org) Received: (from hrs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBONToT3083191; Sat, 24 Dec 2016 23:29:50 GMT (envelope-from hrs@FreeBSD.org) Message-Id: <201612242329.uBONToT3083191@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hrs set sender to hrs@FreeBSD.org using -f From: Hiroki Sato Date: Sat, 24 Dec 2016 23:29:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310528 - head/usr.sbin/syslogd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Sat, 24 Dec 2016 23:29:52 -0000 Author: hrs Date: Sat Dec 24 23:29:50 2016 New Revision: 310528 URL: https://svnweb.freebsd.org/changeset/base/310528 Log: - Fix -N flag (NoBind) for AF_LOCAL sockets. - Do setsockopt(SO_RCVBUF) for AF_LOCAL sockets regardless of -s flag. Modified: head/usr.sbin/syslogd/syslogd.c Modified: head/usr.sbin/syslogd/syslogd.c ============================================================================== --- head/usr.sbin/syslogd/syslogd.c Sat Dec 24 22:51:02 2016 (r310527) +++ head/usr.sbin/syslogd/syslogd.c Sat Dec 24 23:29:50 2016 (r310528) @@ -2873,9 +2873,8 @@ socksetup(struct peer *pe) for (res = res0; res != NULL; res = res->ai_next) { int s; - if (res->ai_family == AF_LOCAL) - unlink(pe->pe_name); - else if (SecureMode > 1) { + if (res->ai_family != AF_LOCAL && + SecureMode > 1) { /* Only AF_LOCAL in secure mode. */ continue; } @@ -2907,26 +2906,36 @@ socksetup(struct peer *pe) error++; continue; } + /* - * RFC 3164 recommends that client side message - * should come from the privileged syslogd port. + * Bind INET and UNIX-domain sockets. + * + * A UNIX-domain socket is always bound to a pathname + * regardless of -N flag. * - * If the system administrator choose not to obey + * For INET sockets, RFC 3164 recommends that client + * side message should come from the privileged syslogd port. + * + * If the system administrator chooses not to obey * this, we can skip the bind() step so that the * system will choose a port for us. */ - if (NoBind == 0) { + if (res->ai_family == AF_LOCAL) + unlink(pe->pe_name); + if (res->ai_family == AF_LOCAL || + NoBind == 0 || pe->pe_name != NULL) { if (bind(s, res->ai_addr, res->ai_addrlen) < 0) { logerror("bind"); close(s); error++; continue; } - if (SecureMode == 0) + if (res->ai_family == AF_LOCAL || + SecureMode == 0) increase_rcvbuf(s); } if (res->ai_family == AF_LOCAL && - chmod(pe->pe_name, pe->pe_mode) < 0) { + chmod(pe->pe_name, pe->pe_mode) < 0) { dprintf("chmod %s: %s\n", pe->pe_name, strerror(errno)); close(s); @@ -2936,7 +2945,7 @@ socksetup(struct peer *pe) dprintf("new socket fd is %d\n", s); listen(s, 5); dprintf("shutdown\n"); - if (SecureMode) { + if (SecureMode || res->ai_family == AF_LOCAL) { /* Forbid communication in secure mode. */ if (shutdown(s, SHUT_RD) < 0 && errno != ENOTCONN) { @@ -2944,9 +2953,9 @@ socksetup(struct peer *pe) if (!Debug) die(0); } - dprintf("listening on inet socket\n"); + dprintf("listening on socket\n"); } else - dprintf("sending on inet socket\n"); + dprintf("sending on socket\n"); addsock(res->ai_addr, res->ai_addrlen, &(struct socklist){ .sl_socket = s, From owner-svn-src-head@freebsd.org Sat Dec 24 23:43:15 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 434A4C8F346; Sat, 24 Dec 2016 23:43:15 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 12EBB1A06; Sat, 24 Dec 2016 23:43:15 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBONhEpI091129; Sat, 24 Dec 2016 23:43:14 GMT (envelope-from avos@FreeBSD.org) Received: (from avos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBONhEZ1091128; Sat, 24 Dec 2016 23:43:14 GMT (envelope-from avos@FreeBSD.org) Message-Id: <201612242343.uBONhEZ1091128@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avos set sender to avos@FreeBSD.org using -f From: Andriy Voskoboinyk Date: Sat, 24 Dec 2016 23:43:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310529 - head/sys/net80211 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Sat, 24 Dec 2016 23:43:15 -0000 Author: avos Date: Sat Dec 24 23:43:14 2016 New Revision: 310529 URL: https://svnweb.freebsd.org/changeset/base/310529 Log: net80211: fix 'pending CAC -> RUN transition lost' bug. Ensure that CAC -> RUN state transition will be requested for every vap only once. Modified: head/sys/net80211/ieee80211_proto.c Modified: head/sys/net80211/ieee80211_proto.c ============================================================================== --- head/sys/net80211/ieee80211_proto.c Sat Dec 24 23:29:50 2016 (r310528) +++ head/sys/net80211/ieee80211_proto.c Sat Dec 24 23:43:14 2016 (r310529) @@ -1840,7 +1840,7 @@ ieee80211_cac_completeswitch(struct ieee ieee80211_new_state_locked(vap0, IEEE80211_S_RUN, 0); TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) - if (vap->iv_state == IEEE80211_S_CAC) + if (vap->iv_state == IEEE80211_S_CAC && vap != vap0) ieee80211_new_state_locked(vap, IEEE80211_S_RUN, 0); IEEE80211_UNLOCK(ic); } From owner-svn-src-head@freebsd.org Sat Dec 24 23:51:28 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 85768C8F449; Sat, 24 Dec 2016 23:51:28 +0000 (UTC) (envelope-from jamie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 602681DB2; Sat, 24 Dec 2016 23:51:28 +0000 (UTC) (envelope-from jamie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBONpRq3092200; Sat, 24 Dec 2016 23:51:27 GMT (envelope-from jamie@FreeBSD.org) Received: (from jamie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBONpRZC092199; Sat, 24 Dec 2016 23:51:27 GMT (envelope-from jamie@FreeBSD.org) Message-Id: <201612242351.uBONpRZC092199@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jamie set sender to jamie@FreeBSD.org using -f From: Jamie Gritton Date: Sat, 24 Dec 2016 23:51:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310530 - head/usr.sbin/jls X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Sat, 24 Dec 2016 23:51:28 -0000 Author: jamie Date: Sat Dec 24 23:51:27 2016 New Revision: 310530 URL: https://svnweb.freebsd.org/changeset/base/310530 Log: Improve IP address list representation in libxo output. Extract decision-making about special-case printing of certain jail parameters into a function. Refactor emitting of IPv4 and IPv6 address lists into a function. Resulting user-facing changes: XO_VERSION is bumped to 2. In verbose mode (-v), IPv4 and IPv6-Addresses are now properly emitted as separate lists. This only affects the output in encoding styles, i.e. xml and json. { { "__version": "1", "__version": "2", "jail-information": { "jail-information": { "jail": [ "jail": [ { { "jid": 166, "jid": 166, "hostname": "foo.com", "hostname": "foo.com", "path": "/var/jail/foo", "path": "/var/jail/foo", "name": "foo", "name": "foo", "state": "ACTIVE", "state": "ACTIVE", "cpusetid": 2, "cpusetid": 2, "ipv4_addrs": [ "ipv4_addrs": [ "10.1.1.1", "10.1.1.1", "10.1.1.2", "10.1.1.2", "10.1.1.3", | "10.1.1.3" > ], > "ipv6_addrs": [ "fe80::1000:1", "fe80::1000:1", "fe80::1000:2" "fe80::1000:2" ] ] } } ] ] } } } } In -n mode, ip4.addr and ip6.addr are formatted in the encoding styles' native list types, e.g. instead of comma-separated lists, JSON arrays are printed. jls -n all --libxo json ... "ip4.addr": [ "10.1.1.1", "10.1.1.2", "10.1.1.3" ], "ip4.saddrsel": true, "ip6.addr": [ "fe80::1000:1", "fe80::1000:2" ], ... jls -n all --libxo xml ... 10.1.1.1 10.1.1.2 10.1.1.3 true fe80::1000:1 fe80::1000:2 ... PR: 215008 Submitted by: Christian Schwarz Differential Revision: https://reviews.freebsd.org/D8766 Modified: head/usr.sbin/jls/jls.c Modified: head/usr.sbin/jls/jls.c ============================================================================== --- head/usr.sbin/jls/jls.c Sat Dec 24 23:43:14 2016 (r310529) +++ head/usr.sbin/jls/jls.c Sat Dec 24 23:51:27 2016 (r310530) @@ -51,7 +51,7 @@ __FBSDID("$FreeBSD$"); #define JP_USER 0x01000000 #define JP_OPT 0x02000000 -#define JLS_XO_VERSION "1" +#define JLS_XO_VERSION "2" #define PRINT_DEFAULT 0x01 #define PRINT_HEADER 0x02 @@ -77,7 +77,10 @@ static int sort_param(const void *a, con static char *noname(const char *name); static char *nononame(const char *name); static int print_jail(int pflags, int jflags); +static int special_print(int pflags, struct jailparam *param); static void quoted_print(int pflags, char *name, char *value); +static void emit_ip_addr_list(int af_family, const char *list_name, + struct jailparam *param); int main(int argc, char **argv) @@ -379,8 +382,7 @@ print_jail(int pflags, int jflags) { char *nname, *xo_nname; char **param_values; - int i, ai, jid, count, n, spc; - char ipbuf[INET6_ADDRSTRLEN]; + int i, jid, n, spc; jid = jailparam_get(params, nparams, jflags); if (jid < 0) @@ -401,29 +403,13 @@ print_jail(int pflags, int jflags) n = 6; #ifdef INET if (ip4_ok && !strcmp(params[n].jp_name, "ip4.addr")) { - count = params[n].jp_valuelen / sizeof(struct in_addr); - for (ai = 0; ai < count; ai++) - if (inet_ntop(AF_INET, - &((struct in_addr *)params[n].jp_value)[ai], - ipbuf, sizeof(ipbuf)) == NULL) - xo_err(1, "inet_ntop"); - else { - xo_emit("{P: }{l:ipv4_addrs}{P:\n}", ipbuf); - } + emit_ip_addr_list(AF_INET, "ipv4_addrs", params + n); n++; } #endif #ifdef INET6 if (ip6_ok && !strcmp(params[n].jp_name, "ip6.addr")) { - count = params[n].jp_valuelen / sizeof(struct in6_addr); - for (ai = 0; ai < count; ai++) - if (inet_ntop(AF_INET6, - &((struct in6_addr *) - params[n].jp_value)[ai], - ipbuf, sizeof(ipbuf)) == NULL) - xo_err(1, "inet_ntop"); - else - xo_emit("{P: }{l:ipv6_addrs}{P:\n}", ipbuf); + emit_ip_addr_list(AF_INET6, "ipv6_addrs", params + n); n++; } #endif @@ -499,14 +485,8 @@ print_jail(int pflags, int jflags) } xo_emit("{d:%s}=", params[i].jp_name); } - if (params[i].jp_valuelen == 0) { - if (pflags & PRINT_QUOTED) - xo_emit("{P:\"\"}"); - else if (!(pflags & PRINT_NAMEVAL)) - xo_emit("{P:-}"); - } else { + if (!special_print(pflags, params + i)) quoted_print(pflags, params[i].jp_name, param_values[i]); - } } xo_emit("{P:\n}"); for (i = 0; i < nparams; i++) @@ -553,3 +533,70 @@ quoted_print(int pflags, char *name, cha if (qc && pflags & PRINT_QUOTED) xo_emit("{P:/%c}", qc); } + +static int +special_print(int pflags, struct jailparam *param) +{ + int ip_as_list; + + switch (xo_get_style(NULL)) { + case XO_STYLE_JSON: + case XO_STYLE_XML: + ip_as_list = 1; + break; + default: + ip_as_list = 0; + } + + if (!ip_as_list && param->jp_valuelen == 0) { + if (pflags & PRINT_QUOTED) + xo_emit("{P:\"\"}"); + else if (!(pflags & PRINT_NAMEVAL)) + xo_emit("{P:-}"); + } else if (ip_as_list && !strcmp(param->jp_name, "ip4.addr")) { + emit_ip_addr_list(AF_INET, param->jp_name, param); + } else if (ip_as_list && !strcmp(param->jp_name, "ip6.addr")) { + emit_ip_addr_list(AF_INET6, param->jp_name, param); + } else { + return 0; + } + + return 1; +} + +static void +emit_ip_addr_list(int af_family, const char *list_name, struct jailparam *param) +{ + char ipbuf[INET6_ADDRSTRLEN]; + size_t addr_len; + const char *emit_str; + int ai, count; + + switch (af_family) { + case AF_INET: + addr_len = sizeof(struct in_addr); + emit_str = "{P: }{ql:ipv4_addr}{P:\n}"; + break; + case AF_INET6: + addr_len = sizeof(struct in6_addr); + emit_str = "{P: }{ql:ipv6_addr}{P:\n}"; + break; + default: + xo_err(1, "unsupported af_family"); + return; + } + + count = param->jp_valuelen / addr_len; + + xo_open_list(list_name); + for (ai = 0; ai < count; ai++) { + if (inet_ntop(af_family, + ((uint8_t *)param->jp_value) + addr_len * ai, + ipbuf, sizeof(ipbuf)) == NULL) { + xo_err(1, "inet_ntop"); + } else { + xo_emit(emit_str, ipbuf); + } + } + xo_close_list(list_name); +}