From owner-svn-src-stable-10@freebsd.org Sun Jul 17 12:29:00 2016 Return-Path: Delivered-To: svn-src-stable-10@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 0AA55B9A5A4 for ; Sun, 17 Jul 2016 12:29:00 +0000 (UTC) (envelope-from eanakainiseis@vulcan.dionysusbird.eu) Received: from vulcan.dionysusbird.eu (static.88-198-26-74.clients.your-server.de [88.198.26.74]) (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 ABDDB1630 for ; Sun, 17 Jul 2016 12:28:56 +0000 (UTC) (envelope-from eanakainiseis@vulcan.dionysusbird.eu) Received: from eanakainiseis by vulcan.dionysusbird.eu with local (Exim 4.87) (envelope-from ) id 1bOk1N-0000yx-H1 for svn-src-stable-10@freebsd.org; Sun, 17 Jul 2016 14:14:05 +0300 To: svn-src-stable-10@freebsd.org Subject: Delivery Notification, ID 000224701 X-PHP-Originating-Script: 1021:post.php(3) : regexp code(1) : eval()'d code(17) : eval()'d code Date: Sun, 17 Jul 2016 11:14:05 +0000 From: "FedEx International Next Flight" Reply-To: "FedEx International Next Flight" Message-ID: X-Priority: 3 MIME-Version: 1.0 Sender: X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - vulcan.dionysusbird.eu X-AntiAbuse: Original Domain - freebsd.org X-AntiAbuse: Originator/Caller UID/GID - [1021 993] / [47 12] X-AntiAbuse: Sender Address Domain - vulcan.dionysusbird.eu X-Get-Message-Sender-Via: vulcan.dionysusbird.eu: authenticated_id: eanakainiseis/from_h X-Authenticated-Sender: vulcan.dionysusbird.eu: alvin.gray@eanakainiseis.gr X-Source: X-Source-Args: X-Source-Dir: Content-Type: text/plain; charset=us-ascii X-Content-Filtered-By: Mailman/MimeDel 2.1.22 X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Jul 2016 12:29:00 -0000 Dear Customer, Your parcel has arrived at July 14. Courier was unable to deliver the parcel to you. Shipment Label is attached to this email. Warm regards, Alvin Gray, FedEx Delivery Agent. From owner-svn-src-stable-10@freebsd.org Sun Jul 17 14:12:35 2016 Return-Path: Delivered-To: svn-src-stable-10@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 DD2D3B9C141; Sun, 17 Jul 2016 14:12:35 +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 955FA1D7F; Sun, 17 Jul 2016 14:12:35 +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 u6HECYek037155; Sun, 17 Jul 2016 14:12:34 GMT (envelope-from jamie@FreeBSD.org) Received: (from jamie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6HECY3f037154; Sun, 17 Jul 2016 14:12:34 GMT (envelope-from jamie@FreeBSD.org) Message-Id: <201607171412.u6HECY3f037154@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jamie set sender to jamie@FreeBSD.org using -f From: Jamie Gritton Date: Sun, 17 Jul 2016 14:12:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r302956 - stable/10/etc/rc.d X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Jul 2016 14:12:36 -0000 Author: jamie Date: Sun Jul 17 14:12:34 2016 New Revision: 302956 URL: https://svnweb.freebsd.org/changeset/base/302956 Log: MFC r302855: Wait for jails to complete startup if jail_parallel_start is YES, instead of assuming they'll take less than one second. PR: 203172 Submitted by: dmitry2004@yandex.ru Modified: stable/10/etc/rc.d/jail Directory Properties: stable/10/ (props changed) Modified: stable/10/etc/rc.d/jail ============================================================================== --- stable/10/etc/rc.d/jail Sun Jul 17 14:07:51 2016 (r302955) +++ stable/10/etc/rc.d/jail Sun Jul 17 14:12:34 2016 (r302956) @@ -422,7 +422,7 @@ jail_status() jail_start() { - local _j _jv _jid _jl _id _name + local _j _jv _jid _id _name if [ $# = 0 ]; then return @@ -452,29 +452,30 @@ jail_start() # Start jails in parallel and then check jail id when # jail_parallel_start is YES. # - _jl= for _j in $@; do _j=$(echo $_j | tr /. _) _jv=$(echo -n $_j | tr -c '[:alnum:]' _) parse_options $_j $_jv || continue - _jl="$_jl $_j" eval rc_flags=\${jail_${_jv}_flags:-$jail_flags} eval command=\${jail_${_jv}_program:-$jail_program} command_args="-i -f $_conf -c $_j" - $command $rc_flags $command_args \ - >/dev/null 2>&1 /var/run/jail_${_j}.id - else - echo " cannot start jail " \ - "\"${_hostname:-${_j}}\": " - fi + ( + _tmp=`mktemp -t jail_${_j}` || exit 3 + if $command $rc_flags $command_args \ + >> $_tmp 2>&1 /var/run/jail_${_j}.id + else + echo " cannot start jail " \ + "\"${_hostname:-${_j}}\": " + cat $_tmp + fi + rm -f $_tmp + ) & done + wait else # # Start jails one-by-one when jail_parallel_start is NO. From owner-svn-src-stable-10@freebsd.org Sun Jul 17 14:15:10 2016 Return-Path: Delivered-To: svn-src-stable-10@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 1C48FB9C20B; Sun, 17 Jul 2016 14:15:10 +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 EC09111D3; Sun, 17 Jul 2016 14:15:09 +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 u6HEF9HV037361; Sun, 17 Jul 2016 14:15:09 GMT (envelope-from jamie@FreeBSD.org) Received: (from jamie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6HEF8Bl037358; Sun, 17 Jul 2016 14:15:08 GMT (envelope-from jamie@FreeBSD.org) Message-Id: <201607171415.u6HEF8Bl037358@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jamie set sender to jamie@FreeBSD.org using -f From: Jamie Gritton Date: Sun, 17 Jul 2016 14:15:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r302958 - stable/10/usr.sbin/jail X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Jul 2016 14:15:10 -0000 Author: jamie Date: Sun Jul 17 14:15:08 2016 New Revision: 302958 URL: https://svnweb.freebsd.org/changeset/base/302958 Log: MFC r302856: Fix up the order in which jail creation processes are run, to preserve the config file's order in the non-parallel-start case. PR: 209112 Modified: stable/10/usr.sbin/jail/command.c stable/10/usr.sbin/jail/jailp.h stable/10/usr.sbin/jail/state.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/jail/command.c ============================================================================== --- stable/10/usr.sbin/jail/command.c Sun Jul 17 14:13:47 2016 (r302957) +++ stable/10/usr.sbin/jail/command.c Sun Jul 17 14:15:08 2016 (r302958) @@ -92,9 +92,13 @@ next_command(struct cfjail *j) int create_failed, stopping; if (paralimit == 0) { - requeue(j, &runnable); + if (j->flags & JF_FROM_RUNQ) + requeue_head(j, &runnable); + else + requeue(j, &runnable); return 1; } + j->flags &= ~JF_FROM_RUNQ; create_failed = (j->flags & (JF_STOP | JF_FAILED)) == JF_FAILED; stopping = (j->flags & JF_STOP) != 0; comparam = *j->comparam; @@ -160,20 +164,23 @@ next_command(struct cfjail *j) int finish_command(struct cfjail *j) { + struct cfjail *rj; int error; if (!(j->flags & JF_SLEEPQ)) return 0; j->flags &= ~JF_SLEEPQ; - if (*j->comparam == IP_STOP_TIMEOUT) - { + if (*j->comparam == IP_STOP_TIMEOUT) { j->flags &= ~JF_TIMEOUT; j->pstatus = 0; return 0; } paralimit++; - if (!TAILQ_EMPTY(&runnable)) - requeue(TAILQ_FIRST(&runnable), &ready); + if (!TAILQ_EMPTY(&runnable)) { + rj = TAILQ_FIRST(&runnable); + rj->flags |= JF_FROM_RUNQ; + requeue(rj, &ready); + } error = 0; if (j->flags & JF_TIMEOUT) { j->flags &= ~JF_TIMEOUT; @@ -259,7 +266,7 @@ next_proc(int nonblock) } /* - * Run a single command for a jail, possible inside the jail. + * Run a single command for a jail, possibly inside the jail. */ static int run_command(struct cfjail *j) Modified: stable/10/usr.sbin/jail/jailp.h ============================================================================== --- stable/10/usr.sbin/jail/jailp.h Sun Jul 17 14:13:47 2016 (r302957) +++ stable/10/usr.sbin/jail/jailp.h Sun Jul 17 14:15:08 2016 (r302958) @@ -64,6 +64,7 @@ #define JF_PERSIST 0x0100 /* Jail is temporarily persistent */ #define JF_TIMEOUT 0x0200 /* A command (or process kill) timed out */ #define JF_SLEEPQ 0x0400 /* Waiting on a command and/or timeout */ +#define JF_FROM_RUNQ 0x0800 /* Has already been on the run queue */ #define JF_OP_MASK (JF_START | JF_SET | JF_STOP) #define JF_RESTART (JF_START | JF_STOP) @@ -223,6 +224,7 @@ extern struct cfjail *next_jail(void); extern int start_state(const char *target, int docf, unsigned state, int running); extern void requeue(struct cfjail *j, struct cfjails *queue); +extern void requeue_head(struct cfjail *j, struct cfjails *queue); extern void yyerror(const char *); extern int yylex(void); Modified: stable/10/usr.sbin/jail/state.c ============================================================================== --- stable/10/usr.sbin/jail/state.c Sun Jul 17 14:13:47 2016 (r302957) +++ stable/10/usr.sbin/jail/state.c Sun Jul 17 14:15:08 2016 (r302958) @@ -398,6 +398,14 @@ requeue(struct cfjail *j, struct cfjails } } +void +requeue_head(struct cfjail *j, struct cfjails *queue) +{ + TAILQ_REMOVE(j->queue, j, tq); + TAILQ_INSERT_HEAD(queue, j, tq); + j->queue = queue; +} + /* * Add a dependency edge between two jails. */ From owner-svn-src-stable-10@freebsd.org Sun Jul 17 14:16:22 2016 Return-Path: Delivered-To: svn-src-stable-10@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 E1CF3B9C269; Sun, 17 Jul 2016 14:16:22 +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 ADAD31345; Sun, 17 Jul 2016 14:16:22 +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 u6HEGLs1037478; Sun, 17 Jul 2016 14:16:21 GMT (envelope-from jamie@FreeBSD.org) Received: (from jamie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6HEGLWi037477; Sun, 17 Jul 2016 14:16:21 GMT (envelope-from jamie@FreeBSD.org) Message-Id: <201607171416.u6HEGLWi037477@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jamie set sender to jamie@FreeBSD.org using -f From: Jamie Gritton Date: Sun, 17 Jul 2016 14:16:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r302959 - stable/10/etc/rc.d X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Jul 2016 14:16:23 -0000 Author: jamie Date: Sun Jul 17 14:16:21 2016 New Revision: 302959 URL: https://svnweb.freebsd.org/changeset/base/302959 Log: MFC r302857: Start jails non-parallel if jail_parallel_start is NO. This was true for an explicitly specified jail list; now it's also true for all jails. PR: 209112 Modified: stable/10/etc/rc.d/jail Directory Properties: stable/10/ (props changed) Modified: stable/10/etc/rc.d/jail ============================================================================== --- stable/10/etc/rc.d/jail Sun Jul 17 14:15:08 2016 (r302958) +++ stable/10/etc/rc.d/jail Sun Jul 17 14:16:21 2016 (r302959) @@ -433,6 +433,9 @@ jail_start() command=$jail_program rc_flags=$jail_flags command_args="-f $jail_conf -c" + if ! checkyesno jail_parallel_start; then + command_args="$command_args -p1" + fi _tmp=`mktemp -t jail` || exit 3 if $command $rc_flags $command_args >> $_tmp 2>&1; then $jail_jls jid name | while read _id _name; do @@ -440,7 +443,7 @@ jail_start() echo $_id > /var/run/jail_${_name}.id done else - tail -1 $_tmp + cat $_tmp fi rm -f $_tmp echo '.' @@ -527,7 +530,7 @@ jail_stop() _tmp=`mktemp -t jail` || exit 3 $command $rc_flags $command_args $_j >> $_tmp 2>&1 if $jail_jls -j $_j > /dev/null 2>&1; then - tail -1 $_tmp + cat $_tmp else rm -f /var/run/jail_${_j}.id fi @@ -550,7 +553,7 @@ jail_stop() _tmp=`mktemp -t jail` || exit 3 $command -q -f $_conf -r $_j >> $_tmp 2>&1 if $jail_jls -j $_j > /dev/null 2>&1; then - tail -1 $_tmp + cat $_tmp else rm -f /var/run/jail_${_j}.id fi From owner-svn-src-stable-10@freebsd.org Sun Jul 17 15:07:35 2016 Return-Path: Delivered-To: svn-src-stable-10@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 330E1B9CD22; Sun, 17 Jul 2016 15:07:35 +0000 (UTC) (envelope-from dchagin@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 DE0AC1D3C; Sun, 17 Jul 2016 15:07:34 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6HF7XaG056238; Sun, 17 Jul 2016 15:07:33 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6HF7XJ4056230; Sun, 17 Jul 2016 15:07:33 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201607171507.u6HF7XJ4056230@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Sun, 17 Jul 2016 15:07:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r302962 - in stable/10/sys: amd64/linux amd64/linux32 compat/linux i386/linux X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Jul 2016 15:07:35 -0000 Author: dchagin Date: Sun Jul 17 15:07:33 2016 New Revision: 302962 URL: https://svnweb.freebsd.org/changeset/base/302962 Log: MFC r302515: Implement Linux personality() system call mainly due to READ_IMPLIES_EXEC flag. In Linux if this flag is set, PROT_READ implies PROT_EXEC for mmap(). Linux/i386 set this flag automatically if the binary requires executable stack. READ_IMPLIES_EXEC flag will be used in the next Linux mmap() commit. Added: stable/10/sys/compat/linux/linux_persona.h - copied unchanged from r302515, head/sys/compat/linux/linux_persona.h Modified: stable/10/sys/amd64/linux/syscalls.master stable/10/sys/amd64/linux32/syscalls.master stable/10/sys/compat/linux/linux_emul.c stable/10/sys/compat/linux/linux_emul.h stable/10/sys/compat/linux/linux_misc.c stable/10/sys/i386/linux/syscalls.master Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/amd64/linux/syscalls.master ============================================================================== --- stable/10/sys/amd64/linux/syscalls.master Sun Jul 17 14:45:15 2016 (r302961) +++ stable/10/sys/amd64/linux/syscalls.master Sun Jul 17 15:07:33 2016 (r302962) @@ -270,7 +270,7 @@ 133 AUE_MKNOD STD { int linux_mknod(char *path, l_int mode, \ l_dev_t dev); } 134 AUE_USELIB UNIMPL uselib -135 AUE_PERSONALITY STD { int linux_personality(l_ulong per); } +135 AUE_PERSONALITY STD { int linux_personality(l_uint per); } 136 AUE_NULL STD { int linux_ustat(l_dev_t dev, \ struct l_ustat *ubuf); } 137 AUE_STATFS STD { int linux_statfs(char *path, \ Modified: stable/10/sys/amd64/linux32/syscalls.master ============================================================================== --- stable/10/sys/amd64/linux32/syscalls.master Sun Jul 17 14:45:15 2016 (r302961) +++ stable/10/sys/amd64/linux32/syscalls.master Sun Jul 17 15:07:33 2016 (r302962) @@ -238,7 +238,7 @@ 134 AUE_BDFLUSH STD { int linux_bdflush(void); } 135 AUE_NULL STD { int linux_sysfs(l_int option, \ l_ulong arg1, l_ulong arg2); } -136 AUE_PERSONALITY STD { int linux_personality(l_ulong per); } +136 AUE_PERSONALITY STD { int linux_personality(l_uint per); } 137 AUE_NULL UNIMPL afs_syscall 138 AUE_SETFSUID STD { int linux_setfsuid16(l_uid16_t uid); } 139 AUE_SETFSGID STD { int linux_setfsgid16(l_gid16_t gid); } Modified: stable/10/sys/compat/linux/linux_emul.c ============================================================================== --- stable/10/sys/compat/linux/linux_emul.c Sun Jul 17 14:45:15 2016 (r302961) +++ stable/10/sys/compat/linux/linux_emul.c Sun Jul 17 15:07:33 2016 (r302962) @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include @@ -127,7 +128,7 @@ linux_proc_init(struct thread *td, struc /* epoll should be destroyed in a case of exec. */ pem = pem_find(p); KASSERT(pem != NULL, ("proc_exit: proc emuldata not found.\n")); - + pem->persona = 0; if (pem->epoll != NULL) { emd = pem->epoll; pem->epoll = NULL; @@ -220,6 +221,9 @@ linux_proc_exec(void *arg __unused, stru { struct thread *td = curthread; struct thread *othertd; +#if defined(__amd64__) + struct linux_pemuldata *pem; +#endif /* * In a case of execing from linux binary properly detach @@ -243,6 +247,17 @@ linux_proc_exec(void *arg __unused, stru linux_proc_init(td, NULL, 0); else linux_proc_init(td, td, 0); +#if defined(__amd64__) + /* + * An IA32 executable which has executable stack will have the + * READ_IMPLIES_EXEC personality flag set automatically. + */ + if (SV_PROC_FLAG(td->td_proc, SV_ILP32) && + imgp->stack_prot & VM_PROT_EXECUTE) { + pem = pem_find(p); + pem->persona |= LINUX_READ_IMPLIES_EXEC; + } +#endif } } Modified: stable/10/sys/compat/linux/linux_emul.h ============================================================================== --- stable/10/sys/compat/linux/linux_emul.h Sun Jul 17 14:45:15 2016 (r302961) +++ stable/10/sys/compat/linux/linux_emul.h Sun Jul 17 15:07:33 2016 (r302962) @@ -67,6 +67,7 @@ struct linux_pemuldata { uint32_t flags; /* process emuldata flags */ struct sx pem_sx; /* lock for this struct */ void *epoll; /* epoll data */ + uint32_t persona; /* process execution domain */ }; #define LINUX_PEM_XLOCK(p) sx_xlock(&(p)->pem_sx) Modified: stable/10/sys/compat/linux/linux_misc.c ============================================================================== --- stable/10/sys/compat/linux/linux_misc.c Sun Jul 17 14:45:15 2016 (r302961) +++ stable/10/sys/compat/linux/linux_misc.c Sun Jul 17 15:07:33 2016 (r302962) @@ -1198,15 +1198,23 @@ linux_mknodat(struct thread *td, struct int linux_personality(struct thread *td, struct linux_personality_args *args) { + struct linux_pemuldata *pem; + struct proc *p = td->td_proc; + uint32_t old; + #ifdef DEBUG if (ldebug(personality)) - printf(ARGS(personality, "%lu"), (unsigned long)args->per); + printf(ARGS(personality, "%u"), args->per); #endif - if (args->per != 0) - return (EINVAL); - /* Yes Jim, it's still a Linux... */ - td->td_retval[0] = 0; + PROC_LOCK(p); + pem = pem_find(p); + old = pem->persona; + if (args->per != 0xffffffff) + pem->persona = args->per; + PROC_UNLOCK(p); + + td->td_retval[0] = old; return (0); } Copied: stable/10/sys/compat/linux/linux_persona.h (from r302515, head/sys/compat/linux/linux_persona.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/sys/compat/linux/linux_persona.h Sun Jul 17 15:07:33 2016 (r302962, copy of r302515, head/sys/compat/linux/linux_persona.h) @@ -0,0 +1,56 @@ +/* + * $FreeBSD$ + */ + +#ifndef LINUX_PERSONALITY_H +#define LINUX_PERSONALITY_H + +/* + * Flags for bug emulation. + * + * These occupy the top three bytes. + */ +enum { + LINUX_UNAME26 = 0x0020000, + LINUX_ADDR_NO_RANDOMIZE = 0x0040000, /* disable randomization + * of VA space + */ + LINUX_FDPIC_FUNCPTRS = 0x0080000, /* userspace function + * ptrs point to descriptors + * (signal handling) + */ + LINUX_MMAP_PAGE_ZERO = 0x0100000, + LINUX_ADDR_COMPAT_LAYOUT = 0x0200000, + LINUX_READ_IMPLIES_EXEC = 0x0400000, + LINUX_ADDR_LIMIT_32BIT = 0x0800000, + LINUX_SHORT_INODE = 0x1000000, + LINUX_WHOLE_SECONDS = 0x2000000, + LINUX_STICKY_TIMEOUTS = 0x4000000, + LINUX_ADDR_LIMIT_3GB = 0x8000000, +}; + +/* + * Security-relevant compatibility flags that must be + * cleared upon setuid or setgid exec: + */ +#define LINUX_PER_CLEAR_ON_SETID (LINUX_READ_IMPLIES_EXEC | \ + LINUX_ADDR_NO_RANDOMIZE | \ + LINUX_ADDR_COMPAT_LAYOUT | \ + LINUX_MMAP_PAGE_ZERO) + +/* + * Personality types. + * + * These go in the low byte. Avoid using the top bit, it will + * conflict with error returns. + */ +enum { + LINUX_PER_LINUX = 0x0000, + LINUX_PER_LINUX_32BIT = 0x0000 | LINUX_ADDR_LIMIT_32BIT, + LINUX_PER_LINUX_FDPIC = 0x0000 | LINUX_FDPIC_FUNCPTRS, + LINUX_PER_LINUX32 = 0x0008, + LINUX_PER_LINUX32_3GB = 0x0008 | LINUX_ADDR_LIMIT_3GB, + LINUX_PER_MASK = 0x00ff, +}; + +#endif /* LINUX_PERSONALITY_H */ Modified: stable/10/sys/i386/linux/syscalls.master ============================================================================== --- stable/10/sys/i386/linux/syscalls.master Sun Jul 17 14:45:15 2016 (r302961) +++ stable/10/sys/i386/linux/syscalls.master Sun Jul 17 15:07:33 2016 (r302962) @@ -240,7 +240,7 @@ 134 AUE_BDFLUSH STD { int linux_bdflush(void); } 135 AUE_NULL STD { int linux_sysfs(l_int option, \ l_ulong arg1, l_ulong arg2); } -136 AUE_PERSONALITY STD { int linux_personality(l_ulong per); } +136 AUE_PERSONALITY STD { int linux_personality(l_uint per); } 137 AUE_NULL UNIMPL afs_syscall 138 AUE_SETFSUID STD { int linux_setfsuid16(l_uid16_t uid); } 139 AUE_SETFSGID STD { int linux_setfsgid16(l_gid16_t gid); } From owner-svn-src-stable-10@freebsd.org Sun Jul 17 15:11:26 2016 Return-Path: Delivered-To: svn-src-stable-10@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 AAFF1B9CDBA; Sun, 17 Jul 2016 15:11:26 +0000 (UTC) (envelope-from dchagin@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 6D65E1F2F; Sun, 17 Jul 2016 15:11:26 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6HFBPTI059022; Sun, 17 Jul 2016 15:11:25 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6HFBOAE059005; Sun, 17 Jul 2016 15:11:24 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201607171511.u6HFBOAE059005@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Sun, 17 Jul 2016 15:11:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r302963 - in stable/10/sys: amd64/linux amd64/linux32 i386/linux X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Jul 2016 15:11:26 -0000 Author: dchagin Date: Sun Jul 17 15:11:23 2016 New Revision: 302963 URL: https://svnweb.freebsd.org/changeset/base/302963 Log: Regen for r302962 (Linux personality), record mergeinfo for r320516. Modified: stable/10/sys/amd64/linux/linux_proto.h stable/10/sys/amd64/linux/linux_syscall.h stable/10/sys/amd64/linux/linux_syscalls.c stable/10/sys/amd64/linux/linux_sysent.c stable/10/sys/amd64/linux/linux_systrace_args.c stable/10/sys/amd64/linux32/linux32_proto.h stable/10/sys/amd64/linux32/linux32_syscall.h stable/10/sys/amd64/linux32/linux32_syscalls.c stable/10/sys/amd64/linux32/linux32_sysent.c stable/10/sys/amd64/linux32/linux32_systrace_args.c stable/10/sys/i386/linux/linux_proto.h stable/10/sys/i386/linux/linux_syscall.h stable/10/sys/i386/linux/linux_syscalls.c stable/10/sys/i386/linux/linux_sysent.c stable/10/sys/i386/linux/linux_systrace_args.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/amd64/linux/linux_proto.h ============================================================================== --- stable/10/sys/amd64/linux/linux_proto.h Sun Jul 17 15:07:33 2016 (r302962) +++ stable/10/sys/amd64/linux/linux_proto.h Sun Jul 17 15:11:23 2016 (r302963) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: stable/10/sys/amd64/linux/syscalls.master 294368 2016-01-20 01:09:53Z jhb + * created from FreeBSD: stable/10/sys/amd64/linux/syscalls.master 302962 2016-07-17 15:07:33Z dchagin */ #ifndef _LINUX_SYSPROTO_H_ @@ -499,7 +499,7 @@ struct linux_mknod_args { char dev_l_[PADL_(l_dev_t)]; l_dev_t dev; char dev_r_[PADR_(l_dev_t)]; }; struct linux_personality_args { - char per_l_[PADL_(l_ulong)]; l_ulong per; char per_r_[PADR_(l_ulong)]; + char per_l_[PADL_(l_uint)]; l_uint per; char per_r_[PADR_(l_uint)]; }; struct linux_ustat_args { char dev_l_[PADL_(l_dev_t)]; l_dev_t dev; char dev_r_[PADR_(l_dev_t)]; Modified: stable/10/sys/amd64/linux/linux_syscall.h ============================================================================== --- stable/10/sys/amd64/linux/linux_syscall.h Sun Jul 17 15:07:33 2016 (r302962) +++ stable/10/sys/amd64/linux/linux_syscall.h Sun Jul 17 15:11:23 2016 (r302963) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: stable/10/sys/amd64/linux/syscalls.master 294368 2016-01-20 01:09:53Z jhb + * created from FreeBSD: stable/10/sys/amd64/linux/syscalls.master 302962 2016-07-17 15:07:33Z dchagin */ #define LINUX_SYS_read 0 Modified: stable/10/sys/amd64/linux/linux_syscalls.c ============================================================================== --- stable/10/sys/amd64/linux/linux_syscalls.c Sun Jul 17 15:07:33 2016 (r302962) +++ stable/10/sys/amd64/linux/linux_syscalls.c Sun Jul 17 15:11:23 2016 (r302963) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: stable/10/sys/amd64/linux/syscalls.master 294368 2016-01-20 01:09:53Z jhb + * created from FreeBSD: stable/10/sys/amd64/linux/syscalls.master 302962 2016-07-17 15:07:33Z dchagin */ const char *linux_syscallnames[] = { Modified: stable/10/sys/amd64/linux/linux_sysent.c ============================================================================== --- stable/10/sys/amd64/linux/linux_sysent.c Sun Jul 17 15:07:33 2016 (r302962) +++ stable/10/sys/amd64/linux/linux_sysent.c Sun Jul 17 15:11:23 2016 (r302963) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: stable/10/sys/amd64/linux/syscalls.master 294368 2016-01-20 01:09:53Z jhb + * created from FreeBSD: stable/10/sys/amd64/linux/syscalls.master 302962 2016-07-17 15:07:33Z dchagin */ #include Modified: stable/10/sys/amd64/linux/linux_systrace_args.c ============================================================================== --- stable/10/sys/amd64/linux/linux_systrace_args.c Sun Jul 17 15:07:33 2016 (r302962) +++ stable/10/sys/amd64/linux/linux_systrace_args.c Sun Jul 17 15:11:23 2016 (r302963) @@ -1120,7 +1120,7 @@ systrace_args(int sysnum, void *params, /* linux_personality */ case 135: { struct linux_personality_args *p = params; - iarg[0] = p->per; /* l_ulong */ + iarg[0] = p->per; /* l_uint */ *n_args = 1; break; } @@ -4112,7 +4112,7 @@ systrace_entry_setargdesc(int sysnum, in case 135: switch(ndx) { case 0: - p = "l_ulong"; + p = "l_uint"; break; default: break; Modified: stable/10/sys/amd64/linux32/linux32_proto.h ============================================================================== --- stable/10/sys/amd64/linux32/linux32_proto.h Sun Jul 17 15:07:33 2016 (r302962) +++ stable/10/sys/amd64/linux32/linux32_proto.h Sun Jul 17 15:11:23 2016 (r302963) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: stable/10/sys/amd64/linux32/syscalls.master 297300 2016-03-27 06:10:51Z dchagin + * created from FreeBSD: stable/10/sys/amd64/linux32/syscalls.master 302962 2016-07-17 15:07:33Z dchagin */ #ifndef _LINUX32_SYSPROTO_H_ @@ -427,7 +427,7 @@ struct linux_sysfs_args { char arg2_l_[PADL_(l_ulong)]; l_ulong arg2; char arg2_r_[PADR_(l_ulong)]; }; struct linux_personality_args { - char per_l_[PADL_(l_ulong)]; l_ulong per; char per_r_[PADR_(l_ulong)]; + char per_l_[PADL_(l_uint)]; l_uint per; char per_r_[PADR_(l_uint)]; }; struct linux_setfsuid16_args { char uid_l_[PADL_(l_uid16_t)]; l_uid16_t uid; char uid_r_[PADR_(l_uid16_t)]; Modified: stable/10/sys/amd64/linux32/linux32_syscall.h ============================================================================== --- stable/10/sys/amd64/linux32/linux32_syscall.h Sun Jul 17 15:07:33 2016 (r302962) +++ stable/10/sys/amd64/linux32/linux32_syscall.h Sun Jul 17 15:11:23 2016 (r302963) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: stable/10/sys/amd64/linux32/syscalls.master 297300 2016-03-27 06:10:51Z dchagin + * created from FreeBSD: stable/10/sys/amd64/linux32/syscalls.master 302962 2016-07-17 15:07:33Z dchagin */ #define LINUX32_SYS_linux_exit 1 Modified: stable/10/sys/amd64/linux32/linux32_syscalls.c ============================================================================== --- stable/10/sys/amd64/linux32/linux32_syscalls.c Sun Jul 17 15:07:33 2016 (r302962) +++ stable/10/sys/amd64/linux32/linux32_syscalls.c Sun Jul 17 15:11:23 2016 (r302963) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: stable/10/sys/amd64/linux32/syscalls.master 297300 2016-03-27 06:10:51Z dchagin + * created from FreeBSD: stable/10/sys/amd64/linux32/syscalls.master 302962 2016-07-17 15:07:33Z dchagin */ const char *linux32_syscallnames[] = { Modified: stable/10/sys/amd64/linux32/linux32_sysent.c ============================================================================== --- stable/10/sys/amd64/linux32/linux32_sysent.c Sun Jul 17 15:07:33 2016 (r302962) +++ stable/10/sys/amd64/linux32/linux32_sysent.c Sun Jul 17 15:11:23 2016 (r302963) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: stable/10/sys/amd64/linux32/syscalls.master 297300 2016-03-27 06:10:51Z dchagin + * created from FreeBSD: stable/10/sys/amd64/linux32/syscalls.master 302962 2016-07-17 15:07:33Z dchagin */ #include "opt_compat.h" Modified: stable/10/sys/amd64/linux32/linux32_systrace_args.c ============================================================================== --- stable/10/sys/amd64/linux32/linux32_systrace_args.c Sun Jul 17 15:07:33 2016 (r302962) +++ stable/10/sys/amd64/linux32/linux32_systrace_args.c Sun Jul 17 15:11:23 2016 (r302963) @@ -910,7 +910,7 @@ systrace_args(int sysnum, void *params, /* linux_personality */ case 136: { struct linux_personality_args *p = params; - iarg[0] = p->per; /* l_ulong */ + iarg[0] = p->per; /* l_uint */ *n_args = 1; break; } @@ -3715,7 +3715,7 @@ systrace_entry_setargdesc(int sysnum, in case 136: switch(ndx) { case 0: - p = "l_ulong"; + p = "l_uint"; break; default: break; Modified: stable/10/sys/i386/linux/linux_proto.h ============================================================================== --- stable/10/sys/i386/linux/linux_proto.h Sun Jul 17 15:07:33 2016 (r302962) +++ stable/10/sys/i386/linux/linux_proto.h Sun Jul 17 15:11:23 2016 (r302963) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: stable/10/sys/i386/linux/syscalls.master 297300 2016-03-27 06:10:51Z dchagin + * created from FreeBSD: stable/10/sys/i386/linux/syscalls.master 302962 2016-07-17 15:07:33Z dchagin */ #ifndef _LINUX_SYSPROTO_H_ @@ -435,7 +435,7 @@ struct linux_sysfs_args { char arg2_l_[PADL_(l_ulong)]; l_ulong arg2; char arg2_r_[PADR_(l_ulong)]; }; struct linux_personality_args { - char per_l_[PADL_(l_ulong)]; l_ulong per; char per_r_[PADR_(l_ulong)]; + char per_l_[PADL_(l_uint)]; l_uint per; char per_r_[PADR_(l_uint)]; }; struct linux_setfsuid16_args { char uid_l_[PADL_(l_uid16_t)]; l_uid16_t uid; char uid_r_[PADR_(l_uid16_t)]; Modified: stable/10/sys/i386/linux/linux_syscall.h ============================================================================== --- stable/10/sys/i386/linux/linux_syscall.h Sun Jul 17 15:07:33 2016 (r302962) +++ stable/10/sys/i386/linux/linux_syscall.h Sun Jul 17 15:11:23 2016 (r302963) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: stable/10/sys/i386/linux/syscalls.master 297300 2016-03-27 06:10:51Z dchagin + * created from FreeBSD: stable/10/sys/i386/linux/syscalls.master 302962 2016-07-17 15:07:33Z dchagin */ #define LINUX_SYS_linux_exit 1 Modified: stable/10/sys/i386/linux/linux_syscalls.c ============================================================================== --- stable/10/sys/i386/linux/linux_syscalls.c Sun Jul 17 15:07:33 2016 (r302962) +++ stable/10/sys/i386/linux/linux_syscalls.c Sun Jul 17 15:11:23 2016 (r302963) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: stable/10/sys/i386/linux/syscalls.master 297300 2016-03-27 06:10:51Z dchagin + * created from FreeBSD: stable/10/sys/i386/linux/syscalls.master 302962 2016-07-17 15:07:33Z dchagin */ const char *linux_syscallnames[] = { Modified: stable/10/sys/i386/linux/linux_sysent.c ============================================================================== --- stable/10/sys/i386/linux/linux_sysent.c Sun Jul 17 15:07:33 2016 (r302962) +++ stable/10/sys/i386/linux/linux_sysent.c Sun Jul 17 15:11:23 2016 (r302963) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: stable/10/sys/i386/linux/syscalls.master 297300 2016-03-27 06:10:51Z dchagin + * created from FreeBSD: stable/10/sys/i386/linux/syscalls.master 302962 2016-07-17 15:07:33Z dchagin */ #include Modified: stable/10/sys/i386/linux/linux_systrace_args.c ============================================================================== --- stable/10/sys/i386/linux/linux_systrace_args.c Sun Jul 17 15:07:33 2016 (r302962) +++ stable/10/sys/i386/linux/linux_systrace_args.c Sun Jul 17 15:11:23 2016 (r302963) @@ -948,7 +948,7 @@ systrace_args(int sysnum, void *params, /* linux_personality */ case 136: { struct linux_personality_args *p = params; - iarg[0] = p->per; /* l_ulong */ + iarg[0] = p->per; /* l_uint */ *n_args = 1; break; } @@ -3849,7 +3849,7 @@ systrace_entry_setargdesc(int sysnum, in case 136: switch(ndx) { case 0: - p = "l_ulong"; + p = "l_uint"; break; default: break; From owner-svn-src-stable-10@freebsd.org Sun Jul 17 15:23:34 2016 Return-Path: Delivered-To: svn-src-stable-10@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 8ED7BB9C198; Sun, 17 Jul 2016 15:23:34 +0000 (UTC) (envelope-from dchagin@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 404561979; Sun, 17 Jul 2016 15:23:34 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6HFNXO2063719; Sun, 17 Jul 2016 15:23:33 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6HFNWUe063706; Sun, 17 Jul 2016 15:23:32 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201607171523.u6HFNWUe063706@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Sun, 17 Jul 2016 15:23:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r302964 - in stable/10/sys: amd64/linux amd64/linux32 compat/linux conf i386/linux modules/linux modules/linux_common X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Jul 2016 15:23:34 -0000 Author: dchagin Date: Sun Jul 17 15:23:32 2016 New Revision: 302964 URL: https://svnweb.freebsd.org/changeset/base/302964 Log: MFC r302517: Fix a copy/paste bug introduced during X86_64 Linuxulator work. FreeBSD support NX bit on X86_64 processors out of the box, for i386 emulation use READ_IMPLIES_EXEC flag, introduced in r302515. While here move common part of mmap() and mprotect() code to the files in compat/linux to reduce code dupcliation between Linuxulator's. MFC r302518, r302626: Add linux_mmap.c to the appropriate conf/files. Added: stable/10/sys/compat/linux/linux_mmap.c - copied, changed from r302517, head/sys/compat/linux/linux_mmap.c stable/10/sys/compat/linux/linux_mmap.h - copied unchanged from r302517, head/sys/compat/linux/linux_mmap.h Modified: stable/10/sys/amd64/linux/linux.h stable/10/sys/amd64/linux/linux_machdep.c stable/10/sys/amd64/linux32/linux.h stable/10/sys/amd64/linux32/linux32_machdep.c stable/10/sys/conf/files.amd64 stable/10/sys/conf/files.i386 stable/10/sys/conf/files.pc98 stable/10/sys/i386/linux/linux.h stable/10/sys/i386/linux/linux_machdep.c stable/10/sys/modules/linux/Makefile stable/10/sys/modules/linux_common/Makefile Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/amd64/linux/linux.h ============================================================================== --- stable/10/sys/amd64/linux/linux.h Sun Jul 17 15:11:23 2016 (r302963) +++ stable/10/sys/amd64/linux/linux.h Sun Jul 17 15:23:32 2016 (r302964) @@ -139,13 +139,6 @@ struct l_rlimit { l_ulong rlim_max; }; -/* mmap options */ -#define LINUX_MAP_SHARED 0x0001 -#define LINUX_MAP_PRIVATE 0x0002 -#define LINUX_MAP_FIXED 0x0010 -#define LINUX_MAP_ANON 0x0020 -#define LINUX_MAP_GROWSDOWN 0x0100 - /* * stat family of syscalls */ Modified: stable/10/sys/amd64/linux/linux_machdep.c ============================================================================== --- stable/10/sys/amd64/linux/linux_machdep.c Sun Jul 17 15:11:23 2016 (r302963) +++ stable/10/sys/amd64/linux/linux_machdep.c Sun Jul 17 15:23:32 2016 (r302964) @@ -83,6 +83,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -122,181 +123,19 @@ linux_set_upcall_kse(struct thread *td, return (0); } -#define STACK_SIZE (2 * 1024 * 1024) -#define GUARD_SIZE (4 * PAGE_SIZE) - int linux_mmap2(struct thread *td, struct linux_mmap2_args *args) { - struct proc *p = td->td_proc; - struct mmap_args /* { - caddr_t addr; - size_t len; - int prot; - int flags; - int fd; - long pad; - off_t pos; - } */ bsd_args; - int error; - struct file *fp; - cap_rights_t rights; - - LINUX_CTR6(mmap2, "0x%lx, %ld, %ld, 0x%08lx, %ld, 0x%lx", - args->addr, args->len, args->prot, - args->flags, args->fd, args->pgoff); - - error = 0; - bsd_args.flags = 0; - fp = NULL; - - /* - * Linux mmap(2): - * You must specify exactly one of MAP_SHARED and MAP_PRIVATE - */ - if (! ((args->flags & LINUX_MAP_SHARED) ^ - (args->flags & LINUX_MAP_PRIVATE))) - return (EINVAL); - - if (args->flags & LINUX_MAP_SHARED) - bsd_args.flags |= MAP_SHARED; - if (args->flags & LINUX_MAP_PRIVATE) - bsd_args.flags |= MAP_PRIVATE; - if (args->flags & LINUX_MAP_FIXED) - bsd_args.flags |= MAP_FIXED; - if (args->flags & LINUX_MAP_ANON) - bsd_args.flags |= MAP_ANON; - else - bsd_args.flags |= MAP_NOSYNC; - if (args->flags & LINUX_MAP_GROWSDOWN) - bsd_args.flags |= MAP_STACK; - - /* - * PROT_READ, PROT_WRITE, or PROT_EXEC implies PROT_READ and PROT_EXEC - * on Linux/i386. We do this to ensure maximum compatibility. - * Linux/ia64 does the same in i386 emulation mode. - */ - bsd_args.prot = args->prot; - if (bsd_args.prot & (PROT_READ | PROT_WRITE | PROT_EXEC)) - bsd_args.prot |= PROT_READ | PROT_EXEC; - - /* Linux does not check file descriptor when MAP_ANONYMOUS is set. */ - bsd_args.fd = (bsd_args.flags & MAP_ANON) ? -1 : args->fd; - if (bsd_args.fd != -1) { - /* - * Linux follows Solaris mmap(2) description: - * The file descriptor fildes is opened with - * read permission, regardless of the - * protection options specified. - */ - - error = fget(td, bsd_args.fd, - cap_rights_init(&rights, CAP_MMAP), &fp); - if (error != 0 ) - return (error); - if (fp->f_type != DTYPE_VNODE) { - fdrop(fp, td); - return (EINVAL); - } - - /* Linux mmap() just fails for O_WRONLY files */ - if (!(fp->f_flag & FREAD)) { - fdrop(fp, td); - return (EACCES); - } - - fdrop(fp, td); - } - if (args->flags & LINUX_MAP_GROWSDOWN) { - /* - * The Linux MAP_GROWSDOWN option does not limit auto - * growth of the region. Linux mmap with this option - * takes as addr the inital BOS, and as len, the initial - * region size. It can then grow down from addr without - * limit. However, Linux threads has an implicit internal - * limit to stack size of STACK_SIZE. Its just not - * enforced explicitly in Linux. But, here we impose - * a limit of (STACK_SIZE - GUARD_SIZE) on the stack - * region, since we can do this with our mmap. - * - * Our mmap with MAP_STACK takes addr as the maximum - * downsize limit on BOS, and as len the max size of - * the region. It then maps the top SGROWSIZ bytes, - * and auto grows the region down, up to the limit - * in addr. - * - * If we don't use the MAP_STACK option, the effect - * of this code is to allocate a stack region of a - * fixed size of (STACK_SIZE - GUARD_SIZE). - */ - - if ((caddr_t)PTRIN(args->addr) + args->len > - p->p_vmspace->vm_maxsaddr) { - /* - * Some Linux apps will attempt to mmap - * thread stacks near the top of their - * address space. If their TOS is greater - * than vm_maxsaddr, vm_map_growstack() - * will confuse the thread stack with the - * process stack and deliver a SEGV if they - * attempt to grow the thread stack past their - * current stacksize rlimit. To avoid this, - * adjust vm_maxsaddr upwards to reflect - * the current stacksize rlimit rather - * than the maximum possible stacksize. - * It would be better to adjust the - * mmap'ed region, but some apps do not check - * mmap's return value. - */ - PROC_LOCK(p); - p->p_vmspace->vm_maxsaddr = (char *)USRSTACK - - lim_cur(p, RLIMIT_STACK); - PROC_UNLOCK(p); - } - - /* - * This gives us our maximum stack size and a new BOS. - * If we're using VM_STACK, then mmap will just map - * the top SGROWSIZ bytes, and let the stack grow down - * to the limit at BOS. If we're not using VM_STACK - * we map the full stack, since we don't have a way - * to autogrow it. - */ - if (args->len > STACK_SIZE - GUARD_SIZE) { - bsd_args.addr = (caddr_t)PTRIN(args->addr); - bsd_args.len = args->len; - } else { - bsd_args.addr = (caddr_t)PTRIN(args->addr) - - (STACK_SIZE - GUARD_SIZE - args->len); - bsd_args.len = STACK_SIZE - GUARD_SIZE; - } - } else { - bsd_args.addr = (caddr_t)PTRIN(args->addr); - bsd_args.len = args->len; - } - bsd_args.pos = (off_t)args->pgoff; - - error = sys_mmap(td, &bsd_args); - - LINUX_CTR2(mmap2, "return: %d (%p)", - error, td->td_retval[0]); - return (error); + return (linux_mmap_common(td, PTROUT(args->addr), args->len, args->prot, + args->flags, args->fd, args->pgoff)); } int linux_mprotect(struct thread *td, struct linux_mprotect_args *uap) { - struct mprotect_args bsd_args; - - LINUX_CTR(mprotect); - bsd_args.addr = uap->addr; - bsd_args.len = uap->len; - bsd_args.prot = uap->prot; - if (bsd_args.prot & (PROT_READ | PROT_WRITE | PROT_EXEC)) - bsd_args.prot |= PROT_READ | PROT_EXEC; - return (sys_mprotect(td, &bsd_args)); + return (linux_mprotect_common(td, PTROUT(uap->addr), uap->len, uap->prot)); } int Modified: stable/10/sys/amd64/linux32/linux.h ============================================================================== --- stable/10/sys/amd64/linux32/linux.h Sun Jul 17 15:11:23 2016 (r302963) +++ stable/10/sys/amd64/linux32/linux.h Sun Jul 17 15:23:32 2016 (r302964) @@ -165,13 +165,6 @@ struct l_rusage { l_long ru_nivcsw; } __packed; -/* mmap options */ -#define LINUX_MAP_SHARED 0x0001 -#define LINUX_MAP_PRIVATE 0x0002 -#define LINUX_MAP_FIXED 0x0010 -#define LINUX_MAP_ANON 0x0020 -#define LINUX_MAP_GROWSDOWN 0x0100 - struct l_mmap_argv { l_uintptr_t addr; l_size_t len; Modified: stable/10/sys/amd64/linux32/linux32_machdep.c ============================================================================== --- stable/10/sys/amd64/linux32/linux32_machdep.c Sun Jul 17 15:11:23 2016 (r302963) +++ stable/10/sys/amd64/linux32/linux32_machdep.c Sun Jul 17 15:23:32 2016 (r302964) @@ -70,6 +70,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -84,9 +85,6 @@ struct l_old_select_argv { l_uintptr_t timeout; } __packed; -static int linux_mmap_common(struct thread *td, l_uintptr_t addr, - l_size_t len, l_int prot, l_int flags, l_int fd, - l_loff_t pos); static void bsd_to_linux_rusage(struct rusage *ru, struct l_rusage *lru) @@ -448,9 +446,6 @@ linux_set_upcall_kse(struct thread *td, return (0); } -#define STACK_SIZE (2 * 1024 * 1024) -#define GUARD_SIZE (4 * PAGE_SIZE) - int linux_mmap2(struct thread *td, struct linux_mmap2_args *args) { @@ -489,184 +484,11 @@ linux_mmap(struct thread *td, struct lin (uint32_t)linux_args.pgoff)); } -static int -linux_mmap_common(struct thread *td, l_uintptr_t addr, l_size_t len, l_int prot, - l_int flags, l_int fd, l_loff_t pos) -{ - struct proc *p = td->td_proc; - struct mmap_args /* { - caddr_t addr; - size_t len; - int prot; - int flags; - int fd; - long pad; - off_t pos; - } */ bsd_args; - int error; - struct file *fp; - cap_rights_t rights; - - error = 0; - bsd_args.flags = 0; - fp = NULL; - - /* - * Linux mmap(2): - * You must specify exactly one of MAP_SHARED and MAP_PRIVATE - */ - if (!((flags & LINUX_MAP_SHARED) ^ (flags & LINUX_MAP_PRIVATE))) - return (EINVAL); - - if (flags & LINUX_MAP_SHARED) - bsd_args.flags |= MAP_SHARED; - if (flags & LINUX_MAP_PRIVATE) - bsd_args.flags |= MAP_PRIVATE; - if (flags & LINUX_MAP_FIXED) - bsd_args.flags |= MAP_FIXED; - if (flags & LINUX_MAP_ANON) { - /* Enforce pos to be on page boundary, then ignore. */ - if ((pos & PAGE_MASK) != 0) - return (EINVAL); - pos = 0; - bsd_args.flags |= MAP_ANON; - } else - bsd_args.flags |= MAP_NOSYNC; - if (flags & LINUX_MAP_GROWSDOWN) - bsd_args.flags |= MAP_STACK; - - /* - * PROT_READ, PROT_WRITE, or PROT_EXEC implies PROT_READ and PROT_EXEC - * on Linux/i386. We do this to ensure maximum compatibility. - * Linux/ia64 does the same in i386 emulation mode. - */ - bsd_args.prot = prot; - if (bsd_args.prot & (PROT_READ | PROT_WRITE | PROT_EXEC)) - bsd_args.prot |= PROT_READ | PROT_EXEC; - - /* Linux does not check file descriptor when MAP_ANONYMOUS is set. */ - bsd_args.fd = (bsd_args.flags & MAP_ANON) ? -1 : fd; - if (bsd_args.fd != -1) { - /* - * Linux follows Solaris mmap(2) description: - * The file descriptor fildes is opened with - * read permission, regardless of the - * protection options specified. - */ - - error = fget(td, bsd_args.fd, - cap_rights_init(&rights, CAP_MMAP), &fp); - if (error != 0) - return (error); - if (fp->f_type != DTYPE_VNODE) { - fdrop(fp, td); - return (EINVAL); - } - - /* Linux mmap() just fails for O_WRONLY files */ - if (!(fp->f_flag & FREAD)) { - fdrop(fp, td); - return (EACCES); - } - - fdrop(fp, td); - } - - if (flags & LINUX_MAP_GROWSDOWN) { - /* - * The Linux MAP_GROWSDOWN option does not limit auto - * growth of the region. Linux mmap with this option - * takes as addr the inital BOS, and as len, the initial - * region size. It can then grow down from addr without - * limit. However, Linux threads has an implicit internal - * limit to stack size of STACK_SIZE. Its just not - * enforced explicitly in Linux. But, here we impose - * a limit of (STACK_SIZE - GUARD_SIZE) on the stack - * region, since we can do this with our mmap. - * - * Our mmap with MAP_STACK takes addr as the maximum - * downsize limit on BOS, and as len the max size of - * the region. It then maps the top SGROWSIZ bytes, - * and auto grows the region down, up to the limit - * in addr. - * - * If we don't use the MAP_STACK option, the effect - * of this code is to allocate a stack region of a - * fixed size of (STACK_SIZE - GUARD_SIZE). - */ - - if ((caddr_t)PTRIN(addr) + len > p->p_vmspace->vm_maxsaddr) { - /* - * Some Linux apps will attempt to mmap - * thread stacks near the top of their - * address space. If their TOS is greater - * than vm_maxsaddr, vm_map_growstack() - * will confuse the thread stack with the - * process stack and deliver a SEGV if they - * attempt to grow the thread stack past their - * current stacksize rlimit. To avoid this, - * adjust vm_maxsaddr upwards to reflect - * the current stacksize rlimit rather - * than the maximum possible stacksize. - * It would be better to adjust the - * mmap'ed region, but some apps do not check - * mmap's return value. - */ - PROC_LOCK(p); - p->p_vmspace->vm_maxsaddr = (char *)LINUX32_USRSTACK - - lim_cur(p, RLIMIT_STACK); - PROC_UNLOCK(p); - } - - /* - * This gives us our maximum stack size and a new BOS. - * If we're using VM_STACK, then mmap will just map - * the top SGROWSIZ bytes, and let the stack grow down - * to the limit at BOS. If we're not using VM_STACK - * we map the full stack, since we don't have a way - * to autogrow it. - */ - if (len > STACK_SIZE - GUARD_SIZE) { - bsd_args.addr = (caddr_t)PTRIN(addr); - bsd_args.len = len; - } else { - bsd_args.addr = (caddr_t)PTRIN(addr) - - (STACK_SIZE - GUARD_SIZE - len); - bsd_args.len = STACK_SIZE - GUARD_SIZE; - } - } else { - bsd_args.addr = (caddr_t)PTRIN(addr); - bsd_args.len = len; - } - bsd_args.pos = pos; - -#ifdef DEBUG - if (ldebug(mmap)) - printf("-> %s(%p, %d, %d, 0x%08x, %d, 0x%x)\n", - __func__, - (void *)bsd_args.addr, (int)bsd_args.len, bsd_args.prot, - bsd_args.flags, bsd_args.fd, (int)bsd_args.pos); -#endif - error = sys_mmap(td, &bsd_args); -#ifdef DEBUG - if (ldebug(mmap)) - printf("-> %s() return: 0x%x (0x%08x)\n", - __func__, error, (u_int)td->td_retval[0]); -#endif - return (error); -} - int linux_mprotect(struct thread *td, struct linux_mprotect_args *uap) { - struct mprotect_args bsd_args; - bsd_args.addr = uap->addr; - bsd_args.len = uap->len; - bsd_args.prot = uap->prot; - if (bsd_args.prot & (PROT_READ | PROT_WRITE | PROT_EXEC)) - bsd_args.prot |= PROT_READ | PROT_EXEC; - return (sys_mprotect(td, &bsd_args)); + return (linux_mprotect_common(td, PTROUT(uap->addr), uap->len, uap->prot)); } int Copied and modified: stable/10/sys/compat/linux/linux_mmap.c (from r302517, head/sys/compat/linux/linux_mmap.c) ============================================================================== --- head/sys/compat/linux/linux_mmap.c Sun Jul 10 08:22:04 2016 (r302517, copy source) +++ stable/10/sys/compat/linux/linux_mmap.c Sun Jul 17 15:23:32 2016 (r302964) @@ -193,7 +193,7 @@ linux_mmap_common(struct thread *td, uin */ PROC_LOCK(p); vms->vm_maxsaddr = (char *)p->p_sysent->sv_usrstack - - lim_cur_proc(p, RLIMIT_STACK); + lim_cur(p, RLIMIT_STACK); PROC_UNLOCK(p); } Copied: stable/10/sys/compat/linux/linux_mmap.h (from r302517, head/sys/compat/linux/linux_mmap.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/sys/compat/linux/linux_mmap.h Sun Jul 17 15:23:32 2016 (r302964, copy of r302517, head/sys/compat/linux/linux_mmap.h) @@ -0,0 +1,49 @@ +/*- + * Copyright (c) 2004 Tim J. Robbins + * Copyright (c) 2002 Doug Rabson + * Copyright (c) 2000 Marcel Moolenaar + * Copyright (c) 1994-1995 Søren Schmidt + * 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 + * in this position and unchanged. + * 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. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * 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 _LINUX_MMAP_H_ +#define _LINUX_MMAP_H_ + +/* mmap options */ +#define LINUX_MAP_SHARED 0x0001 +#define LINUX_MAP_PRIVATE 0x0002 +#define LINUX_MAP_FIXED 0x0010 +#define LINUX_MAP_ANON 0x0020 +#define LINUX_MAP_GROWSDOWN 0x0100 + + +int linux_mmap_common(struct thread *, uintptr_t, size_t, int, int, + int, off_t); +int linux_mprotect_common(struct thread *, uintptr_t, size_t, int); + +#endif /* _LINUX_MMAP_H_ */ Modified: stable/10/sys/conf/files.amd64 ============================================================================== --- stable/10/sys/conf/files.amd64 Sun Jul 17 15:11:23 2016 (r302963) +++ stable/10/sys/conf/files.amd64 Sun Jul 17 15:23:32 2016 (r302964) @@ -544,6 +544,7 @@ compat/linux/linux_ioctl.c optional comp compat/linux/linux_ipc.c optional compat_linux32 compat/linux/linux_mib.c optional compat_linux32 compat/linux/linux_misc.c optional compat_linux32 +compat/linux/linux_mmap.c optional compat_linux32 compat/linux/linux_signal.c optional compat_linux32 compat/linux/linux_socket.c optional compat_linux32 compat/linux/linux_stats.c optional compat_linux32 Modified: stable/10/sys/conf/files.i386 ============================================================================== --- stable/10/sys/conf/files.i386 Sun Jul 17 15:11:23 2016 (r302963) +++ stable/10/sys/conf/files.i386 Sun Jul 17 15:23:32 2016 (r302964) @@ -102,6 +102,7 @@ compat/linux/linux_ioctl.c optional comp compat/linux/linux_ipc.c optional compat_linux compat/linux/linux_mib.c optional compat_linux compat/linux/linux_misc.c optional compat_linux +compat/linux/linux_mmap.c optional compat_linux compat/linux/linux_signal.c optional compat_linux compat/linux/linux_socket.c optional compat_linux compat/linux/linux_stats.c optional compat_linux Modified: stable/10/sys/conf/files.pc98 ============================================================================== --- stable/10/sys/conf/files.pc98 Sun Jul 17 15:11:23 2016 (r302963) +++ stable/10/sys/conf/files.pc98 Sun Jul 17 15:23:32 2016 (r302964) @@ -63,6 +63,7 @@ compat/linux/linux_ioctl.c optional comp compat/linux/linux_ipc.c optional compat_linux compat/linux/linux_mib.c optional compat_linux compat/linux/linux_misc.c optional compat_linux +compat/linux/linux_mmap.c optional compat_linux compat/linux/linux_signal.c optional compat_linux compat/linux/linux_socket.c optional compat_linux compat/linux/linux_stats.c optional compat_linux Modified: stable/10/sys/i386/linux/linux.h ============================================================================== --- stable/10/sys/i386/linux/linux.h Sun Jul 17 15:11:23 2016 (r302963) +++ stable/10/sys/i386/linux/linux.h Sun Jul 17 15:23:32 2016 (r302964) @@ -140,13 +140,6 @@ struct l_rlimit { l_ulong rlim_max; }; -/* mmap options */ -#define LINUX_MAP_SHARED 0x0001 -#define LINUX_MAP_PRIVATE 0x0002 -#define LINUX_MAP_FIXED 0x0010 -#define LINUX_MAP_ANON 0x0020 -#define LINUX_MAP_GROWSDOWN 0x0100 - struct l_mmap_argv { l_uintptr_t addr; l_size_t len; Modified: stable/10/sys/i386/linux/linux_machdep.c ============================================================================== --- stable/10/sys/i386/linux/linux_machdep.c Sun Jul 17 15:11:23 2016 (r302963) +++ stable/10/sys/i386/linux/linux_machdep.c Sun Jul 17 15:23:32 2016 (r302964) @@ -65,6 +65,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -95,10 +96,6 @@ struct l_old_select_argv { struct l_timeval *timeout; }; -static int linux_mmap_common(struct thread *td, l_uintptr_t addr, - l_size_t len, l_int prot, l_int flags, l_int fd, - l_loff_t pos); - int linux_execve(struct thread *td, struct linux_execve_args *args) @@ -340,9 +337,6 @@ linux_set_upcall_kse(struct thread *td, return (0); } -#define STACK_SIZE (2 * 1024 * 1024) -#define GUARD_SIZE (4 * PAGE_SIZE) - int linux_mmap2(struct thread *td, struct linux_mmap2_args *args) { @@ -381,187 +375,11 @@ linux_mmap(struct thread *td, struct lin (uint32_t)linux_args.pgoff)); } -static int -linux_mmap_common(struct thread *td, l_uintptr_t addr, l_size_t len, l_int prot, - l_int flags, l_int fd, l_loff_t pos) -{ - struct proc *p = td->td_proc; - struct mmap_args /* { - caddr_t addr; - size_t len; - int prot; - int flags; - int fd; - long pad; - off_t pos; - } */ bsd_args; - int error; - struct file *fp; - cap_rights_t rights; - - error = 0; - bsd_args.flags = 0; - fp = NULL; - - /* - * Linux mmap(2): - * You must specify exactly one of MAP_SHARED and MAP_PRIVATE - */ - if (!((flags & LINUX_MAP_SHARED) ^ (flags & LINUX_MAP_PRIVATE))) - return (EINVAL); - - if (flags & LINUX_MAP_SHARED) - bsd_args.flags |= MAP_SHARED; - if (flags & LINUX_MAP_PRIVATE) - bsd_args.flags |= MAP_PRIVATE; - if (flags & LINUX_MAP_FIXED) - bsd_args.flags |= MAP_FIXED; - if (flags & LINUX_MAP_ANON) { - /* Enforce pos to be on page boundary, then ignore. */ - if ((pos & PAGE_MASK) != 0) - return (EINVAL); - pos = 0; - bsd_args.flags |= MAP_ANON; - } else - bsd_args.flags |= MAP_NOSYNC; - if (flags & LINUX_MAP_GROWSDOWN) - bsd_args.flags |= MAP_STACK; - - /* - * PROT_READ, PROT_WRITE, or PROT_EXEC implies PROT_READ and PROT_EXEC - * on Linux/i386. We do this to ensure maximum compatibility. - * Linux/ia64 does the same in i386 emulation mode. - */ - bsd_args.prot = prot; - if (bsd_args.prot & (PROT_READ | PROT_WRITE | PROT_EXEC)) - bsd_args.prot |= PROT_READ | PROT_EXEC; - - /* Linux does not check file descriptor when MAP_ANONYMOUS is set. */ - bsd_args.fd = (bsd_args.flags & MAP_ANON) ? -1 : fd; - if (bsd_args.fd != -1) { - /* - * Linux follows Solaris mmap(2) description: - * The file descriptor fildes is opened with - * read permission, regardless of the - * protection options specified. - * - * Checking just CAP_MMAP is fine here, since the real work - * is done in the FreeBSD mmap(). - */ - - error = fget(td, bsd_args.fd, - cap_rights_init(&rights, CAP_MMAP), &fp); - if (error != 0) - return (error); - if (fp->f_type != DTYPE_VNODE) { - fdrop(fp, td); - return (EINVAL); - } - - /* Linux mmap() just fails for O_WRONLY files */ - if (!(fp->f_flag & FREAD)) { - fdrop(fp, td); - return (EACCES); - } - - fdrop(fp, td); - } - - if (flags & LINUX_MAP_GROWSDOWN) { - /* - * The Linux MAP_GROWSDOWN option does not limit auto - * growth of the region. Linux mmap with this option - * takes as addr the inital BOS, and as len, the initial - * region size. It can then grow down from addr without - * limit. However, linux threads has an implicit internal - * limit to stack size of STACK_SIZE. Its just not - * enforced explicitly in linux. But, here we impose - * a limit of (STACK_SIZE - GUARD_SIZE) on the stack - * region, since we can do this with our mmap. - * - * Our mmap with MAP_STACK takes addr as the maximum - * downsize limit on BOS, and as len the max size of - * the region. It them maps the top SGROWSIZ bytes, - * and auto grows the region down, up to the limit - * in addr. - * - * If we don't use the MAP_STACK option, the effect - * of this code is to allocate a stack region of a - * fixed size of (STACK_SIZE - GUARD_SIZE). - */ - - if ((caddr_t)PTRIN(addr) + len > p->p_vmspace->vm_maxsaddr) { - /* - * Some linux apps will attempt to mmap - * thread stacks near the top of their - * address space. If their TOS is greater - * than vm_maxsaddr, vm_map_growstack() - * will confuse the thread stack with the - * process stack and deliver a SEGV if they - * attempt to grow the thread stack past their - * current stacksize rlimit. To avoid this, - * adjust vm_maxsaddr upwards to reflect - * the current stacksize rlimit rather - * than the maximum possible stacksize. - * It would be better to adjust the - * mmap'ed region, but some apps do not check - * mmap's return value. - */ - PROC_LOCK(p); - p->p_vmspace->vm_maxsaddr = (char *)USRSTACK - - lim_cur(p, RLIMIT_STACK); - PROC_UNLOCK(p); - } - - /* - * This gives us our maximum stack size and a new BOS. - * If we're using VM_STACK, then mmap will just map - * the top SGROWSIZ bytes, and let the stack grow down - * to the limit at BOS. If we're not using VM_STACK - * we map the full stack, since we don't have a way - * to autogrow it. - */ - if (len > STACK_SIZE - GUARD_SIZE) { - bsd_args.addr = (caddr_t)PTRIN(addr); - bsd_args.len = len; - } else { - bsd_args.addr = (caddr_t)PTRIN(addr) - - (STACK_SIZE - GUARD_SIZE - len); - bsd_args.len = STACK_SIZE - GUARD_SIZE; - } - } else { - bsd_args.addr = (caddr_t)PTRIN(addr); - bsd_args.len = len; - } - bsd_args.pos = pos; - -#ifdef DEBUG - if (ldebug(mmap)) - printf("-> %s(%p, %d, %d, 0x%08x, %d, 0x%x)\n", - __func__, - (void *)bsd_args.addr, bsd_args.len, bsd_args.prot, - bsd_args.flags, bsd_args.fd, (int)bsd_args.pos); -#endif - error = sys_mmap(td, &bsd_args); -#ifdef DEBUG - if (ldebug(mmap)) - printf("-> %s() return: 0x%x (0x%08x)\n", - __func__, error, (u_int)td->td_retval[0]); -#endif - return (error); -} - int linux_mprotect(struct thread *td, struct linux_mprotect_args *uap) { - struct mprotect_args bsd_args; - bsd_args.addr = uap->addr; - bsd_args.len = uap->len; - bsd_args.prot = uap->prot; - if (bsd_args.prot & (PROT_READ | PROT_WRITE | PROT_EXEC)) - bsd_args.prot |= PROT_READ | PROT_EXEC; - return (sys_mprotect(td, &bsd_args)); + return (linux_mprotect_common(td, PTROUT(uap->addr), uap->len, uap->prot)); } int Modified: stable/10/sys/modules/linux/Makefile ============================================================================== --- stable/10/sys/modules/linux/Makefile Sun Jul 17 15:11:23 2016 (r302963) +++ stable/10/sys/modules/linux/Makefile Sun Jul 17 15:23:32 2016 (r302964) @@ -30,7 +30,7 @@ SRCS+= opt_apic.h OBJS= ${VDSO}.so .if ${MACHINE_CPUARCH} == "i386" -SRCS+= linux_ptrace.c imgact_linux.c linux_util.c linux_mib.c \ +SRCS+= linux_ptrace.c imgact_linux.c linux_util.c linux_mib.c linux_mmap.c \ linux_emul.c opt_cpu.h linux.c .endif Modified: stable/10/sys/modules/linux_common/Makefile ============================================================================== --- stable/10/sys/modules/linux_common/Makefile Sun Jul 17 15:11:23 2016 (r302963) +++ stable/10/sys/modules/linux_common/Makefile Sun Jul 17 15:23:32 2016 (r302964) @@ -3,7 +3,7 @@ .PATH: ${.CURDIR}/../../compat/linux KMOD= linux_common -SRCS= linux_common.c linux_mib.c linux_util.c linux_emul.c \ +SRCS= linux_common.c linux_mib.c linux_mmap.c linux_util.c linux_emul.c \ linux.c opt_compat.h device_if.h vnode_if.h bus_if.h EXPORT_SYMS= From owner-svn-src-stable-10@freebsd.org Sun Jul 17 18:32:35 2016 Return-Path: Delivered-To: svn-src-stable-10@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 E8B76B9C98E; Sun, 17 Jul 2016 18:32:34 +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 8863F1D54; Sun, 17 Jul 2016 18:32:34 +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 u6HIWX02033974; Sun, 17 Jul 2016 18:32:33 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6HIWXGC033972; Sun, 17 Jul 2016 18:32:33 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201607171832.u6HIWXGC033972@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Sun, 17 Jul 2016 18:32:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r302968 - stable/10/usr.bin/mail X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Jul 2016 18:32:35 -0000 Author: pfg Date: Sun Jul 17 18:32:33 2016 New Revision: 302968 URL: https://svnweb.freebsd.org/changeset/base/302968 Log: MFC r302511, r302771, r302845: mail(1): check for out of memory conditions when calling calloc(3). Modified: stable/10/usr.bin/mail/cmd3.c stable/10/usr.bin/mail/vars.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.bin/mail/cmd3.c ============================================================================== --- stable/10/usr.bin/mail/cmd3.c Sun Jul 17 18:23:20 2016 (r302967) +++ stable/10/usr.bin/mail/cmd3.c Sun Jul 17 18:32:33 2016 (r302968) @@ -463,7 +463,8 @@ group(char **argv) gname = *argv; h = hash(gname); if ((gh = findgroup(gname)) == NULL) { - gh = calloc(sizeof(*gh), 1); + if ((gh = calloc(1, sizeof(*gh))) == NULL) + err(1, "Out of memory"); gh->g_name = vcopy(gname); gh->g_list = NULL; gh->g_link = groups[h]; @@ -477,7 +478,8 @@ group(char **argv) */ for (ap = argv+1; *ap != NULL; ap++) { - gp = calloc(sizeof(*gp), 1); + if ((gp = calloc(1, sizeof(*gp))) == NULL) + err(1, "Out of memory"); gp->ge_name = vcopy(*ap); gp->ge_link = gh->g_list; gh->g_list = gp; @@ -702,7 +704,8 @@ alternates(char **namelist) } if (altnames != 0) (void)free(altnames); - altnames = calloc((unsigned)c, sizeof(char *)); + if ((altnames = calloc((unsigned)c, sizeof(char *))) == NULL) + err(1, "Out of memory"); for (ap = namelist, ap2 = altnames; *ap != NULL; ap++, ap2++) { cp = calloc((unsigned)strlen(*ap) + 1, sizeof(char)); strcpy(cp, *ap); Modified: stable/10/usr.bin/mail/vars.c ============================================================================== --- stable/10/usr.bin/mail/vars.c Sun Jul 17 18:23:20 2016 (r302967) +++ stable/10/usr.bin/mail/vars.c Sun Jul 17 18:32:33 2016 (r302968) @@ -56,7 +56,8 @@ assign(const char *name, const char *val h = hash(name); vp = lookup(name); if (vp == NULL) { - vp = calloc(sizeof(*vp), 1); + if ((vp = calloc(1, sizeof(*vp))) == NULL) + err(1, "Out of memory"); vp->v_name = vcopy(name); vp->v_link = variables[h]; variables[h] = vp; From owner-svn-src-stable-10@freebsd.org Mon Jul 18 04:34:43 2016 Return-Path: Delivered-To: svn-src-stable-10@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 99D4BB9CC08; Mon, 18 Jul 2016 04:34:43 +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 5EB691730; Mon, 18 Jul 2016 04:34:43 +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 u6I4YguN056322; Mon, 18 Jul 2016 04:34:42 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6I4Yg73056321; Mon, 18 Jul 2016 04:34:42 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201607180434.u6I4Yg73056321@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 18 Jul 2016 04:34:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r302983 - stable/10/sys/i386/i386 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jul 2016 04:34:43 -0000 Author: kib Date: Mon Jul 18 04:34:42 2016 New Revision: 302983 URL: https://svnweb.freebsd.org/changeset/base/302983 Log: MFC r302573: Fill tf_trapno for trap frames created for syscall. Modified: stable/10/sys/i386/i386/exception.s Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/i386/i386/exception.s ============================================================================== --- stable/10/sys/i386/i386/exception.s Mon Jul 18 04:33:12 2016 (r302982) +++ stable/10/sys/i386/i386/exception.s Mon Jul 18 04:34:42 2016 (r302983) @@ -235,7 +235,7 @@ IDTVEC(lcall_syscall) pushfl /* save eflags */ popl 8(%esp) /* shuffle into tf_eflags */ pushl $7 /* sizeof "lcall 7,0" */ - subl $4,%esp /* skip over tf_trapno */ + pushl $0 /* tf_trapno */ pushal pushl $0 movw %ds,(%esp) @@ -264,7 +264,7 @@ IDTVEC(lcall_syscall) SUPERALIGN_TEXT IDTVEC(int0x80_syscall) pushl $2 /* sizeof "int 0x80" */ - subl $4,%esp /* skip over tf_trapno */ + pushl $0 /* tf_trapno */ pushal pushl $0 movw %ds,(%esp) From owner-svn-src-stable-10@freebsd.org Mon Jul 18 06:09:54 2016 Return-Path: Delivered-To: svn-src-stable-10@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 03990B9CC51; Mon, 18 Jul 2016 06:09:54 +0000 (UTC) (envelope-from truckman@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 CC4071E42; Mon, 18 Jul 2016 06:09:53 +0000 (UTC) (envelope-from truckman@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6I69q96089412; Mon, 18 Jul 2016 06:09:52 GMT (envelope-from truckman@FreeBSD.org) Received: (from truckman@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6I69qrU089411; Mon, 18 Jul 2016 06:09:52 GMT (envelope-from truckman@FreeBSD.org) Message-Id: <201607180609.u6I69qrU089411@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: truckman set sender to truckman@FreeBSD.org using -f From: Don Lewis Date: Mon, 18 Jul 2016 06:09:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r302987 - stable/10/sys/netpfil/ipfw X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jul 2016 06:09:54 -0000 Author: truckman Date: Mon Jul 18 06:09:52 2016 New Revision: 302987 URL: https://svnweb.freebsd.org/changeset/base/302987 Log: MFC r302667 Fix problems in the FQ-PIE AQM cleanup code that could leak memory or cause a crash. Because dummynet calls pie_cleanup() while holding a mutex, pie_cleanup() is not able to use callout_drain() to make sure that all callouts are finished before it returns, and callout_stop() is not sufficient to make that guarantee. After pie_cleanup() returns, dummynet will free a structure that any remaining callouts will want to access. Fix these problems by allocating a separate structure to contain the data used by the callouts. In pie_cleanup(), call callout_reset_sbt() to replace the normal callout with a cleanup callout that does the cleanup work for each sub-queue. The instance of the cleanup callout that destroys the last flow will also free the extra allocated block of memory. Protect the reference count manipulation in the cleanup callout with DN_BH_WLOCK() to be consistent with all of the other usage of the reference count where this lock is held by the dummynet code. Submitted by: Rasool Al-Saadi Differential Revision: https://reviews.freebsd.org/D7174 Modified: stable/10/sys/netpfil/ipfw/dn_sched_fq_pie.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/netpfil/ipfw/dn_sched_fq_pie.c ============================================================================== --- stable/10/sys/netpfil/ipfw/dn_sched_fq_pie.c Mon Jul 18 05:36:31 2016 (r302986) +++ stable/10/sys/netpfil/ipfw/dn_sched_fq_pie.c Mon Jul 18 06:09:52 2016 (r302987) @@ -111,7 +111,7 @@ struct fq_pie_flow { int deficit; int active; /* 1: flow is active (in a list) */ struct pie_status pst; /* pie status variables */ - struct fq_pie_si *psi; /* parent scheduler instance */ + struct fq_pie_si_extra *psi_extra; STAILQ_ENTRY(fq_pie_flow) flowchain; }; @@ -120,23 +120,30 @@ struct fq_pie_schk { struct dn_sch_fq_pie_parms cfg; }; + +/* fq_pie scheduler instance extra state vars. + * The purpose of separation this structure is to preserve number of active + * sub-queues and the flows array pointer even after the scheduler instance + * is destroyed. + * Preserving these varaiables allows freeing the allocated memory by + * fqpie_callout_cleanup() independently from fq_pie_free_sched(). + */ +struct fq_pie_si_extra { + uint32_t nr_active_q; /* number of active queues */ + struct fq_pie_flow *flows; /* array of flows (queues) */ + }; + /* fq_pie scheduler instance */ struct fq_pie_si { - struct dn_sch_inst _si; /* standard scheduler instance */ + struct dn_sch_inst _si; /* standard scheduler instance. SHOULD BE FIRST */ struct dn_queue main_q; /* main queue is after si directly */ - uint32_t nr_active_q; - struct fq_pie_flow *flows; /* array of flows (queues) */ uint32_t perturbation; /* random value */ struct fq_pie_list newflows; /* list of new queues */ struct fq_pie_list oldflows; /* list of old queues */ + struct fq_pie_si_extra *si_extra; /* extra state vars*/ }; -struct mem_to_free { - void *mem_flows; - void *mem_callout; -}; -static struct mtx freemem_mtx; static struct dn_alg fq_pie_desc; /* Default FQ-PIE parameters including PIE */ @@ -371,22 +378,6 @@ fq_calculate_drop_prob(void *x) int64_t p, prob, oldprob; aqm_time_t now; - /* dealing with race condition */ - if (callout_pending(&pst->aqm_pie_callout)) { - /* callout was reset */ - mtx_unlock(&pst->lock_mtx); - return; - } - - if (!callout_active(&pst->aqm_pie_callout)) { - /* callout was stopped */ - mtx_unlock(&pst->lock_mtx); - mtx_destroy(&pst->lock_mtx); - q->psi->nr_active_q--; - return; - } - callout_deactivate(&pst->aqm_pie_callout); - now = AQM_UNOW; pprms = pst->parms; prob = pst->drop_prob; @@ -524,20 +515,17 @@ fq_deactivate_pie(struct pie_status *pst * Initialize PIE for sub-queue 'q' */ static int -pie_init(struct fq_pie_flow *q) +pie_init(struct fq_pie_flow *q, struct fq_pie_schk *fqpie_schk) { struct pie_status *pst=&q->pst; struct dn_aqm_pie_parms *pprms = pst->parms; - struct fq_pie_schk *fqpie_schk; - - fqpie_schk = (struct fq_pie_schk *)(q->psi->_si.sched+1); - int err = 0; + int err = 0; if (!pprms){ D("AQM_PIE is not configured"); err = EINVAL; } else { - q->psi->nr_active_q++; + q->psi_extra->nr_active_q++; /* For speed optimization, we caculate 1/3 queue size once here */ // XXX limit divided by number of queues divided by 3 ??? @@ -553,8 +541,36 @@ pie_init(struct fq_pie_flow *q) } /* + * callout function to destroy PIE lock, and free fq_pie flows and fq_pie si + * extra memory when number of active sub-queues reaches zero. + * 'x' is a fq_pie_flow to be destroyed + */ +static void +fqpie_callout_cleanup(void *x) +{ + struct fq_pie_flow *q = x; + struct pie_status *pst = &q->pst; + struct fq_pie_si_extra *psi_extra; + + mtx_unlock(&pst->lock_mtx); + mtx_destroy(&pst->lock_mtx); + psi_extra = q->psi_extra; + + DN_BH_WLOCK(); + psi_extra->nr_active_q--; + + /* when all sub-queues are destroyed, free flows fq_pie extra vars memory */ + if (!psi_extra->nr_active_q) { + free(psi_extra->flows, M_DUMMYNET); + free(psi_extra, M_DUMMYNET); + fq_pie_desc.ref_count--; + } + DN_BH_WUNLOCK(); +} + +/* * Clean up PIE status for sub-queue 'q' - * Stop callout timer and destroy mtx + * Stop callout timer and destroy mtx using fqpie_callout_cleanup() callout. */ static int pie_cleanup(struct fq_pie_flow *q) @@ -562,14 +578,9 @@ pie_cleanup(struct fq_pie_flow *q) struct pie_status *pst = &q->pst; mtx_lock(&pst->lock_mtx); - if (callout_stop(&pst->aqm_pie_callout) || !(pst->sflags & PIE_ACTIVE)) { - mtx_unlock(&pst->lock_mtx); - mtx_destroy(&pst->lock_mtx); - q->psi->nr_active_q--; - } else { - mtx_unlock(&pst->lock_mtx); - return EBUSY; - } + callout_reset_sbt(&pst->aqm_pie_callout, + SBT_1US, 0, fqpie_callout_cleanup, q, 0); + mtx_unlock(&pst->lock_mtx); return 0; } @@ -831,10 +842,12 @@ fq_pie_enqueue(struct dn_sch_inst *_si, struct fq_pie_schk *schk; struct dn_sch_fq_pie_parms *param; struct dn_queue *mainq; + struct fq_pie_flow *flows; int idx, drop, i, maxidx; mainq = (struct dn_queue *)(_si + 1); si = (struct fq_pie_si *)_si; + flows = si->si_extra->flows; schk = (struct fq_pie_schk *)(si->_si.sched+1); param = &schk->cfg; @@ -844,7 +857,7 @@ fq_pie_enqueue(struct dn_sch_inst *_si, /* enqueue packet into appropriate queue using PIE AQM. * Note: 'pie_enqueue' function returns 1 only when it unable to * add timestamp to packet (no limit check)*/ - drop = pie_enqueue(&si->flows[idx], m, si); + drop = pie_enqueue(&flows[idx], m, si); /* pie unable to timestamp a packet */ if (drop) @@ -853,11 +866,11 @@ fq_pie_enqueue(struct dn_sch_inst *_si, /* If the flow (sub-queue) is not active ,then add it to tail of * new flows list, initialize and activate it. */ - if (!si->flows[idx].active) { - STAILQ_INSERT_TAIL(&si->newflows, &si->flows[idx], flowchain); - si->flows[idx].deficit = param->quantum; - fq_activate_pie(&si->flows[idx]); - si->flows[idx].active = 1; + if (!flows[idx].active) { + STAILQ_INSERT_TAIL(&si->newflows, &flows[idx], flowchain); + flows[idx].deficit = param->quantum; + fq_activate_pie(&flows[idx]); + flows[idx].active = 1; } /* check the limit for all queues and remove a packet from the @@ -866,15 +879,15 @@ fq_pie_enqueue(struct dn_sch_inst *_si, if (mainq->ni.length > schk->cfg.limit) { /* find first active flow */ for (maxidx = 0; maxidx < schk->cfg.flows_cnt; maxidx++) - if (si->flows[maxidx].active) + if (flows[maxidx].active) break; if (maxidx < schk->cfg.flows_cnt) { /* find the largest sub- queue */ for (i = maxidx + 1; i < schk->cfg.flows_cnt; i++) - if (si->flows[i].active && si->flows[i].stats.length > - si->flows[maxidx].stats.length) + if (flows[i].active && flows[i].stats.length > + flows[maxidx].stats.length) maxidx = i; - pie_drop_head(&si->flows[maxidx], si); + pie_drop_head(&flows[maxidx], si); drop = 1; } } @@ -974,12 +987,13 @@ fq_pie_new_sched(struct dn_sch_inst *_si struct fq_pie_si *si; struct dn_queue *q; struct fq_pie_schk *schk; + struct fq_pie_flow *flows; int i; si = (struct fq_pie_si *)_si; schk = (struct fq_pie_schk *)(_si->sched+1); - if(si->flows) { + if(si->si_extra) { D("si already configured!"); return 0; } @@ -990,17 +1004,27 @@ fq_pie_new_sched(struct dn_sch_inst *_si q->_si = _si; q->fs = _si->sched->fs; + /* allocate memory for scheduler instance extra vars */ + si->si_extra = malloc(sizeof(struct fq_pie_si_extra), + M_DUMMYNET, M_NOWAIT | M_ZERO); + if (si->si_extra == NULL) { + D("cannot allocate memory for fq_pie si extra vars"); + return ENOMEM ; + } /* allocate memory for flows array */ - si->flows = malloc(schk->cfg.flows_cnt * sizeof(struct fq_pie_flow), + si->si_extra->flows = malloc(schk->cfg.flows_cnt * sizeof(struct fq_pie_flow), M_DUMMYNET, M_NOWAIT | M_ZERO); - if (si->flows == NULL) { - D("cannot allocate memory for fq_pie configuration parameters"); + flows = si->si_extra->flows; + if (flows == NULL) { + free(si->si_extra, M_DUMMYNET); + si->si_extra = NULL; + D("cannot allocate memory for fq_pie flows"); return ENOMEM ; } /* init perturbation for this si */ si->perturbation = random(); - si->nr_active_q = 0; + si->si_extra->nr_active_q = 0; /* init the old and new flows lists */ STAILQ_INIT(&si->newflows); @@ -1008,45 +1032,16 @@ fq_pie_new_sched(struct dn_sch_inst *_si /* init the flows (sub-queues) */ for (i = 0; i < schk->cfg.flows_cnt; i++) { - si->flows[i].pst.parms = &schk->cfg.pcfg; - si->flows[i].psi = si; - pie_init(&si->flows[i]); - } - - /* init mtx lock and callout function for free memory */ - if (!fq_pie_desc.ref_count) { - mtx_init(&freemem_mtx, "mtx_pie", NULL, MTX_DEF); + flows[i].pst.parms = &schk->cfg.pcfg; + flows[i].psi_extra = si->si_extra; + pie_init(&flows[i], schk); } - mtx_lock(&freemem_mtx); fq_pie_desc.ref_count++; - mtx_unlock(&freemem_mtx); return 0; } -/* - * Free FQ-PIE flows memory callout function. - * This function is scheduled when a flow or more still active and - * the scheduer is about to be destroyed, to prevent memory leak. - */ -static void -free_flows(void *_mem) -{ - struct mem_to_free *mem = _mem; - - free(mem->mem_flows, M_DUMMYNET); - free(mem->mem_callout, M_DUMMYNET); - free(_mem, M_DUMMYNET); - - fq_pie_desc.ref_count--; - if (!fq_pie_desc.ref_count) { - mtx_unlock(&freemem_mtx); - mtx_destroy(&freemem_mtx); - } else - mtx_unlock(&freemem_mtx); - //D("mem freed ok!"); -} /* * Free fq_pie scheduler instance. @@ -1056,61 +1051,17 @@ fq_pie_free_sched(struct dn_sch_inst *_s { struct fq_pie_si *si; struct fq_pie_schk *schk; + struct fq_pie_flow *flows; int i; si = (struct fq_pie_si *)_si; schk = (struct fq_pie_schk *)(_si->sched+1); - + flows = si->si_extra->flows; for (i = 0; i < schk->cfg.flows_cnt; i++) { - pie_cleanup(&si->flows[i]); - } - - /* if there are still some queues have a callout going to start, - * we cannot free flows memory. If we do so, a panic can happen - * as prob calculate callout function uses flows memory. - */ - if (!si->nr_active_q) { - /* free the flows array */ - free(si->flows , M_DUMMYNET); - si->flows = NULL; - mtx_lock(&freemem_mtx); - fq_pie_desc.ref_count--; - if (!fq_pie_desc.ref_count) { - mtx_unlock(&freemem_mtx); - mtx_destroy(&freemem_mtx); - } else - mtx_unlock(&freemem_mtx); - //D("ok!"); - return 0; - } else { - /* memory leak happens here. So, we register a callout function to free - * flows memory later. - */ - D("unable to stop all fq_pie sub-queues!"); - mtx_lock(&freemem_mtx); - - struct callout *mem_callout; - struct mem_to_free *mem; - - mem = malloc(sizeof(*mem), M_DUMMYNET, - M_NOWAIT | M_ZERO); - mem_callout = malloc(sizeof(*mem_callout), M_DUMMYNET, - M_NOWAIT | M_ZERO); - - callout_init_mtx(mem_callout, &freemem_mtx, - CALLOUT_RETURNUNLOCKED); - - mem->mem_flows = si->flows; - mem->mem_callout = mem_callout; - callout_reset_sbt(mem_callout, - (uint64_t)(si->flows[0].pst.parms->tupdate + 1000) * SBT_1US, - 0, free_flows, mem, 0); - - si->flows = NULL; - mtx_unlock(&freemem_mtx); - - return EBUSY; + pie_cleanup(&flows[i]); } + si->si_extra = NULL; + return 0; } /* From owner-svn-src-stable-10@freebsd.org Mon Jul 18 06:46:50 2016 Return-Path: Delivered-To: svn-src-stable-10@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 CBF8EB9C42B; Mon, 18 Jul 2016 06:46:50 +0000 (UTC) (envelope-from avg@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 981B61271; Mon, 18 Jul 2016 06:46:50 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6I6knqS004619; Mon, 18 Jul 2016 06:46:49 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6I6knKX004618; Mon, 18 Jul 2016 06:46:49 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201607180646.u6I6knKX004618@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Mon, 18 Jul 2016 06:46:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r302989 - stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jul 2016 06:46:50 -0000 Author: avg Date: Mon Jul 18 06:46:49 2016 New Revision: 302989 URL: https://svnweb.freebsd.org/changeset/base/302989 Log: MFC r302772: re-apply r299908: zfsctl_snapdir_lookup: clear VV_ROOT of snapshot's root Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c Mon Jul 18 06:35:40 2016 (r302988) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c Mon Jul 18 06:46:49 2016 (r302989) @@ -1125,6 +1125,7 @@ domount: */ ASSERT(VTOZ(*vpp)->z_zfsvfs != zfsvfs); VTOZ(*vpp)->z_zfsvfs->z_parent = zfsvfs; + (*vpp)->v_flag &= ~VROOT; } ZFS_EXIT(zfsvfs); From owner-svn-src-stable-10@freebsd.org Mon Jul 18 08:20:33 2016 Return-Path: Delivered-To: svn-src-stable-10@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 35726B9C1E9; Mon, 18 Jul 2016 08:20:33 +0000 (UTC) (envelope-from jch@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 DD404141A; Mon, 18 Jul 2016 08:20:32 +0000 (UTC) (envelope-from jch@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6I8KWX0037799; Mon, 18 Jul 2016 08:20:32 GMT (envelope-from jch@FreeBSD.org) Received: (from jch@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6I8KVfd037797; Mon, 18 Jul 2016 08:20:31 GMT (envelope-from jch@FreeBSD.org) Message-Id: <201607180820.u6I8KVfd037797@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jch set sender to jch@FreeBSD.org using -f From: Julien Charbon Date: Mon, 18 Jul 2016 08:20:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r302995 - stable/10/sys/netinet X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jul 2016 08:20:33 -0000 Author: jch Date: Mon Jul 18 08:20:31 2016 New Revision: 302995 URL: https://svnweb.freebsd.org/changeset/base/302995 Log: MFC r261242: Decrease lock contention within the TCP accept case by removing the INP_INFO lock from tcp_usr_accept. As the PR/patch states this was following the advice already in the code. See the PR below for a full discussion of this change and its measured effects. PR: 183659 Submitted by: Julien Charbon Reviewed by: jhb Modified: stable/10/sys/netinet/tcp_syncache.c stable/10/sys/netinet/tcp_usrreq.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/netinet/tcp_syncache.c ============================================================================== --- stable/10/sys/netinet/tcp_syncache.c Mon Jul 18 07:06:44 2016 (r302994) +++ stable/10/sys/netinet/tcp_syncache.c Mon Jul 18 08:20:31 2016 (r302995) @@ -683,7 +683,7 @@ syncache_socket(struct syncache *sc, str * connection when the SYN arrived. If we can't create * the connection, abort it. */ - so = sonewconn(lso, SS_ISCONNECTED); + so = sonewconn(lso, 0); if (so == NULL) { /* * Drop the connection; we will either send a RST or @@ -922,6 +922,8 @@ syncache_socket(struct syncache *sc, str INP_WUNLOCK(inp); + soisconnected(so); + TCPSTAT_INC(tcps_accepts); return (so); Modified: stable/10/sys/netinet/tcp_usrreq.c ============================================================================== --- stable/10/sys/netinet/tcp_usrreq.c Mon Jul 18 07:06:44 2016 (r302994) +++ stable/10/sys/netinet/tcp_usrreq.c Mon Jul 18 08:20:31 2016 (r302995) @@ -643,13 +643,6 @@ out: /* * Accept a connection. Essentially all the work is done at higher levels; * just return the address of the peer, storing through addr. - * - * The rationale for acquiring the tcbinfo lock here is somewhat complicated, - * and is described in detail in the commit log entry for r175612. Acquiring - * it delays an accept(2) racing with sonewconn(), which inserts the socket - * before the inpcb address/port fields are initialized. A better fix would - * prevent the socket from being placed in the listen queue until all fields - * are fully initialized. */ static int tcp_usr_accept(struct socket *so, struct sockaddr **nam) @@ -666,7 +659,6 @@ tcp_usr_accept(struct socket *so, struct inp = sotoinpcb(so); KASSERT(inp != NULL, ("tcp_usr_accept: inp == NULL")); - INP_INFO_RLOCK(&V_tcbinfo); INP_WLOCK(inp); if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { error = ECONNABORTED; @@ -686,7 +678,6 @@ tcp_usr_accept(struct socket *so, struct out: TCPDEBUG2(PRU_ACCEPT); INP_WUNLOCK(inp); - INP_INFO_RUNLOCK(&V_tcbinfo); if (error == 0) *nam = in_sockaddr(port, &addr); return error; From owner-svn-src-stable-10@freebsd.org Wed Jul 20 00:51:10 2016 Return-Path: Delivered-To: svn-src-stable-10@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 D829AB9DCB3; Wed, 20 Jul 2016 00:51:10 +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 A487718AD; Wed, 20 Jul 2016 00:51:10 +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 u6K0p97n050966; Wed, 20 Jul 2016 00:51:09 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6K0p9Pc050965; Wed, 20 Jul 2016 00:51:09 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201607200051.u6K0p9Pc050965@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Wed, 20 Jul 2016 00:51:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303056 - stable/10/share/man/man4 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jul 2016 00:51:11 -0000 Author: markj Date: Wed Jul 20 00:51:09 2016 New Revision: 303056 URL: https://svnweb.freebsd.org/changeset/base/303056 Log: MFC r302797: Document DDB's "alltrace" and "show all trace" commands. Modified: stable/10/share/man/man4/ddb.4 Directory Properties: stable/10/ (props changed) Modified: stable/10/share/man/man4/ddb.4 ============================================================================== --- stable/10/share/man/man4/ddb.4 Wed Jul 20 00:43:26 2016 (r303055) +++ stable/10/share/man/man4/ddb.4 Wed Jul 20 00:51:09 2016 (r303056) @@ -60,7 +60,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 5, 2015 +.Dd July 13, 2016 .Dt DDB 4 .Os .Sh NAME @@ -547,6 +547,11 @@ modifier will alter the display to show addresses for the process and not show other information. .\" .Pp +.It Ic show Cm all trace +.It Ic alltrace +.Xc +Show a stack trace for every thread in the system. +.Pp .It Ic show Cm all ttys Show all TTY's within the system. Output is similar to From owner-svn-src-stable-10@freebsd.org Wed Jul 20 00:52:13 2016 Return-Path: Delivered-To: svn-src-stable-10@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 00804B9DD28; Wed, 20 Jul 2016 00:52:13 +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 C6E2A1BC1; Wed, 20 Jul 2016 00:52:12 +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 u6K0qC30051054; Wed, 20 Jul 2016 00:52:12 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6K0qCNC051053; Wed, 20 Jul 2016 00:52:12 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201607200052.u6K0qCNC051053@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Wed, 20 Jul 2016 00:52:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303057 - stable/10/sys/geom/mirror X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jul 2016 00:52:13 -0000 Author: markj Date: Wed Jul 20 00:52:11 2016 New Revision: 303057 URL: https://svnweb.freebsd.org/changeset/base/303057 Log: MFC r302091: Do not complete pending gmirror BIOs when tearing down the provider. Modified: stable/10/sys/geom/mirror/g_mirror.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/geom/mirror/g_mirror.c ============================================================================== --- stable/10/sys/geom/mirror/g_mirror.c Wed Jul 20 00:51:09 2016 (r303056) +++ stable/10/sys/geom/mirror/g_mirror.c Wed Jul 20 00:52:11 2016 (r303057) @@ -2127,8 +2127,21 @@ g_mirror_destroy_provider(struct g_mirro g_topology_lock(); g_error_provider(sc->sc_provider, ENXIO); mtx_lock(&sc->sc_queue_mtx); - while ((bp = bioq_takefirst(&sc->sc_queue)) != NULL) - g_io_deliver(bp, ENXIO); + while ((bp = bioq_takefirst(&sc->sc_queue)) != NULL) { + /* + * Abort any pending I/O that wasn't generated by us. + * Synchronization requests and requests destined for individual + * mirror components can be destroyed immediately. + */ + if (bp->bio_to == sc->sc_provider && + bp->bio_from->geom != sc->sc_sync.ds_geom) { + g_io_deliver(bp, ENXIO); + } else { + if ((bp->bio_cflags & G_MIRROR_BIO_FLAG_SYNC) != 0) + free(bp->bio_data, M_MIRROR); + g_destroy_bio(bp); + } + } mtx_unlock(&sc->sc_queue_mtx); G_MIRROR_DEBUG(0, "Device %s: provider %s destroyed.", sc->sc_name, sc->sc_provider->name); From owner-svn-src-stable-10@freebsd.org Wed Jul 20 00:53:22 2016 Return-Path: Delivered-To: svn-src-stable-10@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 B0B44B9DDE3; Wed, 20 Jul 2016 00:53:22 +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 7A3681D62; Wed, 20 Jul 2016 00:53:22 +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 u6K0rLbA051148; Wed, 20 Jul 2016 00:53:21 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6K0rL5A051147; Wed, 20 Jul 2016 00:53:21 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201607200053.u6K0rL5A051147@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Wed, 20 Jul 2016 00:53:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303058 - stable/10/usr.bin/gcore X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jul 2016 00:53:22 -0000 Author: markj Date: Wed Jul 20 00:53:21 2016 New Revision: 303058 URL: https://svnweb.freebsd.org/changeset/base/303058 Log: MFC r302179: gcore: Forward pending signals when detaching from the target. Modified: stable/10/usr.bin/gcore/elfcore.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.bin/gcore/elfcore.c ============================================================================== --- stable/10/usr.bin/gcore/elfcore.c Wed Jul 20 00:52:11 2016 (r303057) +++ stable/10/usr.bin/gcore/elfcore.c Wed Jul 20 00:53:21 2016 (r303058) @@ -123,6 +123,7 @@ static vm_map_entry_t readmap(pid_t); static void *procstat_sysctl(void *, int, size_t, size_t *sizep); static pid_t g_pid; /* Pid being dumped, global for elf_detach */ +static int g_status; /* proc status after ptrace attach */ static int elf_ident(int efd, pid_t pid __unused, char *binfile __unused) @@ -156,9 +157,18 @@ elf_ident(int efd, pid_t pid __unused, c static void elf_detach(void) { + int sig; - if (g_pid != 0) - ptrace(PT_DETACH, g_pid, (caddr_t)1, 0); + if (g_pid != 0) { + /* + * Forward any pending signals. SIGSTOP is generated by ptrace + * itself, so ignore it. + */ + sig = WIFSTOPPED(g_status) ? WSTOPSIG(g_status) : 0; + if (sig == SIGSTOP) + sig = 0; + ptrace(PT_DETACH, g_pid, (caddr_t)1, sig); + } } /* @@ -184,7 +194,7 @@ elf_coredump(int efd __unused, int fd, p ptrace(PT_ATTACH, pid, NULL, 0); if (errno) err(1, "PT_ATTACH"); - if (waitpid(pid, NULL, 0) == -1) + if (waitpid(pid, &g_status, 0) == -1) err(1, "waitpid"); /* Get the program's memory map. */ From owner-svn-src-stable-10@freebsd.org Wed Jul 20 04:49:03 2016 Return-Path: Delivered-To: svn-src-stable-10@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 177F0B9F103; Wed, 20 Jul 2016 04:49:03 +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 DADD81E2B; Wed, 20 Jul 2016 04:49:02 +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 u6K4n27R036640; Wed, 20 Jul 2016 04:49:02 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6K4n2CU036639; Wed, 20 Jul 2016 04:49:02 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201607200449.u6K4n2CU036639@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Wed, 20 Jul 2016 04:49:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303065 - stable/10/usr.bin/sed X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jul 2016 04:49:03 -0000 Author: pfg Date: Wed Jul 20 04:49:01 2016 New Revision: 303065 URL: https://svnweb.freebsd.org/changeset/base/303065 Log: MFC r302973: sed(1): Fix off by one introduced in r299211. Detected by running the gsed tests. Submitted by: Mikhail Teterin PR: 195929 Modified: stable/10/usr.bin/sed/process.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.bin/sed/process.c ============================================================================== --- stable/10/usr.bin/sed/process.c Wed Jul 20 04:45:59 2016 (r303064) +++ stable/10/usr.bin/sed/process.c Wed Jul 20 04:49:01 2016 (r303065) @@ -440,7 +440,7 @@ substitute(struct s_command *cp) regexec_e(re, ps, REG_NOTBOL, 0, le, psl)); /* Did not find the requested number of matches. */ - if (n > 1) + if (n > 0) return (0); /* Copy the trailing retained string. */ From owner-svn-src-stable-10@freebsd.org Wed Jul 20 07:33:49 2016 Return-Path: Delivered-To: svn-src-stable-10@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 48AC9B9C8DB; Wed, 20 Jul 2016 07:33:49 +0000 (UTC) (envelope-from gahr@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 265A019E0; Wed, 20 Jul 2016 07:33:49 +0000 (UTC) (envelope-from gahr@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6K7XmB4099395; Wed, 20 Jul 2016 07:33:48 GMT (envelope-from gahr@FreeBSD.org) Received: (from gahr@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6K7Xmos099394; Wed, 20 Jul 2016 07:33:48 GMT (envelope-from gahr@FreeBSD.org) Message-Id: <201607200733.u6K7Xmos099394@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gahr set sender to gahr@FreeBSD.org using -f From: Pietro Cerutti Date: Wed, 20 Jul 2016 07:33:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303075 - stable/10/usr.bin/ul X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jul 2016 07:33:49 -0000 Author: gahr (ports committer) Date: Wed Jul 20 07:33:48 2016 New Revision: 303075 URL: https://svnweb.freebsd.org/changeset/base/303075 Log: MFC r302558: Do not truncate lines longer than 512 chars. PR: 210344 Differential Revision: https://reviews.freebsd.org/D6881 Modified: stable/10/usr.bin/ul/ul.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.bin/ul/ul.c ============================================================================== --- stable/10/usr.bin/ul/ul.c Wed Jul 20 07:30:44 2016 (r303074) +++ stable/10/usr.bin/ul/ul.c Wed Jul 20 07:33:48 2016 (r303075) @@ -78,7 +78,9 @@ struct CHAR { int c_width; /* width or -1 if multi-column char. filler */ } ; -static struct CHAR obuf[MAXBUF]; +static struct CHAR sobuf[MAXBUF]; /* static output buffer */ +static struct CHAR *obuf = sobuf; +static int buflen = MAXBUF; static int col, maxcol; static int mode; static int halfpos; @@ -155,6 +157,9 @@ main(int argc, char **argv) else filter(f); } + if (obuf != sobuf) { + free(obuf); + } exit(0); } @@ -170,128 +175,148 @@ filter(FILE *f) { wint_t c; int i, w; + int copy; + + copy = 0; + + while ((c = getwc(f)) != WEOF) { + if (col == buflen) { + if (obuf == sobuf) { + obuf = NULL; + copy = 1; + } + obuf = realloc(obuf, sizeof(*obuf) * 2 * buflen); + if (obuf == NULL) { + obuf = sobuf; + break; + } else if (copy) { + memcpy(obuf, sobuf, sizeof(*obuf) * buflen); + copy = 0; + } + bzero((char *)(obuf + buflen), sizeof(*obuf) * buflen); + buflen *= 2; + } + switch(c) { + case '\b': + if (col > 0) + col--; + continue; - while ((c = getwc(f)) != WEOF && col < MAXBUF) switch(c) { + case '\t': + col = (col+8) & ~07; + if (col > maxcol) + maxcol = col; + continue; - case '\b': - if (col > 0) - col--; - continue; - - case '\t': - col = (col+8) & ~07; - if (col > maxcol) - maxcol = col; - continue; - - case '\r': - col = 0; - continue; - - case SO: - mode |= ALTSET; - continue; - - case SI: - mode &= ~ALTSET; - continue; - - case IESC: - switch (c = getwc(f)) { - - case HREV: - if (halfpos == 0) { - mode |= SUPERSC; - halfpos--; - } else if (halfpos > 0) { - mode &= ~SUBSC; - halfpos--; - } else { - halfpos = 0; - reverse(); - } + case '\r': + col = 0; continue; - case HFWD: - if (halfpos == 0) { - mode |= SUBSC; - halfpos++; - } else if (halfpos < 0) { - mode &= ~SUPERSC; - halfpos++; - } else { - halfpos = 0; - fwd(); - } + case SO: + mode |= ALTSET; continue; - case FREV: - reverse(); + case SI: + mode &= ~ALTSET; continue; - default: - errx(1, "unknown escape sequence in input: %o, %o", IESC, c); - } - continue; + case IESC: + switch (c = getwc(f)) { - case '_': - if (obuf[col].c_char || obuf[col].c_width < 0) { - while (col > 0 && obuf[col].c_width < 0) - col--; - w = obuf[col].c_width; - for (i = 0; i < w; i++) - obuf[col++].c_mode |= UNDERL | mode; + case HREV: + if (halfpos == 0) { + mode |= SUPERSC; + halfpos--; + } else if (halfpos > 0) { + mode &= ~SUBSC; + halfpos--; + } else { + halfpos = 0; + reverse(); + } + continue; + + case HFWD: + if (halfpos == 0) { + mode |= SUBSC; + halfpos++; + } else if (halfpos < 0) { + mode &= ~SUPERSC; + halfpos++; + } else { + halfpos = 0; + fwd(); + } + continue; + + case FREV: + reverse(); + continue; + + default: + errx(1, "unknown escape sequence in input: %o, %o", IESC, c); + } + continue; + + case '_': + if (obuf[col].c_char || obuf[col].c_width < 0) { + while (col > 0 && obuf[col].c_width < 0) + col--; + w = obuf[col].c_width; + for (i = 0; i < w; i++) + obuf[col++].c_mode |= UNDERL | mode; + if (col > maxcol) + maxcol = col; + continue; + } + obuf[col].c_char = '_'; + obuf[col].c_width = 1; + /* FALLTHROUGH */ + case ' ': + col++; if (col > maxcol) maxcol = col; continue; - } - obuf[col].c_char = '_'; - obuf[col].c_width = 1; - /* FALLTHROUGH */ - case ' ': - col++; - if (col > maxcol) - maxcol = col; - continue; - case '\n': - flushln(); - continue; + case '\n': + flushln(); + continue; - case '\f': - flushln(); - putwchar('\f'); - continue; + case '\f': + flushln(); + putwchar('\f'); + continue; - default: - if ((w = wcwidth(c)) <= 0) /* non printing */ + default: + if ((w = wcwidth(c)) <= 0) /* non printing */ + continue; + if (obuf[col].c_char == '\0') { + obuf[col].c_char = c; + for (i = 0; i < w; i++) + obuf[col + i].c_mode = mode; + obuf[col].c_width = w; + for (i = 1; i < w; i++) + obuf[col + i].c_width = -1; + } else if (obuf[col].c_char == '_') { + obuf[col].c_char = c; + for (i = 0; i < w; i++) + obuf[col + i].c_mode |= UNDERL|mode; + obuf[col].c_width = w; + for (i = 1; i < w; i++) + obuf[col + i].c_width = -1; + } else if ((wint_t)obuf[col].c_char == c) { + for (i = 0; i < w; i++) + obuf[col + i].c_mode |= BOLD|mode; + } else { + w = obuf[col].c_width; + for (i = 0; i < w; i++) + obuf[col + i].c_mode = mode; + } + col += w; + if (col > maxcol) + maxcol = col; continue; - if (obuf[col].c_char == '\0') { - obuf[col].c_char = c; - for (i = 0; i < w; i++) - obuf[col + i].c_mode = mode; - obuf[col].c_width = w; - for (i = 1; i < w; i++) - obuf[col + i].c_width = -1; - } else if (obuf[col].c_char == '_') { - obuf[col].c_char = c; - for (i = 0; i < w; i++) - obuf[col + i].c_mode |= UNDERL|mode; - obuf[col].c_width = w; - for (i = 1; i < w; i++) - obuf[col + i].c_width = -1; - } else if ((wint_t)obuf[col].c_char == c) { - for (i = 0; i < w; i++) - obuf[col + i].c_mode |= BOLD|mode; - } else { - w = obuf[col].c_width; - for (i = 0; i < w; i++) - obuf[col + i].c_mode = mode; } - col += w; - if (col > maxcol) - maxcol = col; - continue; } if (ferror(f)) err(1, NULL); @@ -409,7 +434,7 @@ static void initbuf(void) { - bzero((char *)obuf, sizeof (obuf)); /* depends on NORMAL == 0 */ + bzero((char *)obuf, buflen * sizeof(*obuf)); /* depends on NORMAL == 0 */ col = 0; maxcol = 0; mode &= ALTSET; From owner-svn-src-stable-10@freebsd.org Wed Jul 20 14:38:04 2016 Return-Path: Delivered-To: svn-src-stable-10@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 A2F43B9ECDF; Wed, 20 Jul 2016 14:38:04 +0000 (UTC) (envelope-from slm@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 70E0A1563; Wed, 20 Jul 2016 14:38:04 +0000 (UTC) (envelope-from slm@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6KEc3fX057047; Wed, 20 Jul 2016 14:38:03 GMT (envelope-from slm@FreeBSD.org) Received: (from slm@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6KEc2eV057039; Wed, 20 Jul 2016 14:38:02 GMT (envelope-from slm@FreeBSD.org) Message-Id: <201607201438.u6KEc2eV057039@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: slm set sender to slm@FreeBSD.org using -f From: Stephen McConnell Date: Wed, 20 Jul 2016 14:38:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303089 - in stable/10: share/man/man4 sys/dev/mpr sys/dev/mps X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jul 2016 14:38:04 -0000 Author: slm Date: Wed Jul 20 14:38:02 2016 New Revision: 303089 URL: https://svnweb.freebsd.org/changeset/base/303089 Log: MFC r302673 Use real values to calculate Max I/O size instead of guessing. Reviewed by: ken, scottl Approved by: ken, scottl, ambrisko (mentors) Differential Revision: https://reviews.freebsd.org/D7043 Modified: stable/10/share/man/man4/mpr.4 stable/10/share/man/man4/mps.4 stable/10/sys/dev/mpr/mpr.c stable/10/sys/dev/mpr/mpr_sas.c stable/10/sys/dev/mpr/mprvar.h stable/10/sys/dev/mps/mps.c stable/10/sys/dev/mps/mps_sas.c stable/10/sys/dev/mps/mpsvar.h Directory Properties: stable/10/ (props changed) Modified: stable/10/share/man/man4/mpr.4 ============================================================================== --- stable/10/share/man/man4/mpr.4 Wed Jul 20 12:46:21 2016 (r303088) +++ stable/10/share/man/man4/mpr.4 Wed Jul 20 14:38:02 2016 (r303089) @@ -29,7 +29,7 @@ .\" 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. -.\" +.\" .\" mpr driver man page. .\" .\" Author: Ken Merry @@ -38,7 +38,7 @@ .\" $Id$ .\" $FreeBSD$ .\" -.Dd April 29, 2016 +.Dd July 6, 2016 .Dt MPR 4 .Os .Sh NAME @@ -156,6 +156,29 @@ The current number of active I/O command dev.mpr.X.io_cmds_active .Xr sysctl 8 variable. +.Ed +.Pp +To set the maximum number of pages that will be used per I/O for all adapters, +set this tunable in +.Xr loader.conf 5 : +.Bd -literal -offset indent +hw.mpr.max_io_pages=NNNN +.Ed +.Pp +To set the maximum number of pages that will be used per I/O for a specific +adapter, set this tunable in +.Xr loader.conf 5 : +.Bd -literal -offset indent +dev.mpr.X.max_io_pages=NNNN +.Ed +.Pp +The default max_io_pages value is -1, meaning that the maximum I/O size that +will be used per I/O will be calculated using the IOCFacts values stored in +the controller. +The lowest value that the driver will use for max_io_pages is 1, otherwise +IOCFacts will be used to calculate the maximum I/O size. +The smaller I/O size calculated from either max_io_pages or IOCFacts will be the +maximum I/O size used by the driver. .Pp The highest number of active I/O commands seen since boot is stored in the dev.mpr.X.io_cmds_highwater @@ -220,7 +243,7 @@ SATA disks that take several seconds to command might not be discovered by the driver. This problem can sometimes be overcome by increasing the value of the spinup wait time in -.Xr loader.conf 5 : +.Xr loader.conf 5 with the .Bd -literal -offset indent hw.mpr.spinup_wait_time=NNNN @@ -250,7 +273,7 @@ hw.mpr.X.debug_level .Pp tunable, either in .Xr loader.conf 5 -or by using +or by using .Xr sysctl 8 . These bits have the described effects: .Bd -literal -offset indent Modified: stable/10/share/man/man4/mps.4 ============================================================================== --- stable/10/share/man/man4/mps.4 Wed Jul 20 12:46:21 2016 (r303088) +++ stable/10/share/man/man4/mps.4 Wed Jul 20 14:38:02 2016 (r303089) @@ -1,5 +1,8 @@ .\" .\" Copyright (c) 2010 Spectra Logic Corporation +.\" Copyright (c) 2014 LSI Corp +.\" Copyright (c) 2016 Avago Technologies +.\" Copyright (c) 2016 Broadcom Ltd. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -30,25 +33,27 @@ .\" mps driver man page. .\" .\" Author: Ken Merry +.\" Author: Stephen McConnell .\" .\" $Id: //depot/SpectraBSD/head/share/man/man4/mps.4#6 $ .\" $FreeBSD$ .\" -.Dd December 9, 2015 +.Dd July 5, 2016 .Dt MPS 4 .Os .Sh NAME .Nm mps -.Nd LSI Fusion-MPT 2 Serial Attached SCSI driver +.Nd "LSI Fusion-MPT 2 IT/IR 6Gb/s Serial Attached SCSI/SATA driver" .Sh SYNOPSIS -To compile this driver into your kernel, -place the following lines in your kernel configuration file: +To compile this driver into the kernel, place these lines in the kernel +configuration file: .Bd -ragged -offset indent +.Cd "device pci" .Cd "device scbus" .Cd "device mps" .Ed .Pp -Or, to load the driver as a module at boot, place the following line in +The driver can be loaded as a module at boot time by placing this line in .Xr loader.conf 5 : .Bd -literal -offset indent mps_load="YES" @@ -56,35 +61,30 @@ mps_load="YES" .Sh DESCRIPTION The .Nm -driver provides support for LSI Logic Fusion-MPT 2 +driver provides support for Broadcom Ltd./Avago Tech (LSI) +Fusion-MPT 2 IT/IR .Tn SAS controllers and WarpDrive solid state storage cards. .Sh HARDWARE -The +These controllers are supported by the .Nm -driver supports the following hardware: +driver: .Pp .Bl -bullet -compact .It -LSI Logic SAS2004 (4 Port -.Tn SAS ) +Broadcom Ltd./Avago Tech (LSI) SAS 2004 (4 Port SAS) .It -LSI Logic SAS2008 (8 Port -.Tn SAS ) +Broadcom Ltd./Avago Tech (LSI) SAS 2008 (8 Port SAS) .It -LSI Logic SAS2108 (8 Port -.Tn SAS ) +Broadcom Ltd./Avago Tech (LSI) SAS 2108 (8 Port SAS) .It -LSI Logic SAS2116 (16 Port -.Tn SAS ) +Broadcom Ltd./Avago Tech (LSI) SAS 2116 (16 Port SAS) .It -LSI Logic SAS2208 (8 Port -.Tn SAS ) +Broadcom Ltd./Avago Tech (LSI) SAS 2208 (8 Port SAS) .It -LSI Logic SAS2308 (8 Port -.Tn SAS ) +Broadcom Ltd./Avago Tech (LSI) SAS 2308 (8 Port SAS) .It -LSI Logic SSS6200 Solid State Storage +Broadcom Ltd./Avago Tech (LSI) SSS6200 Solid State Storage .It Intel Integrated RAID Module RMS25JB040 .It @@ -95,9 +95,12 @@ Intel Integrated RAID Module RMS25KB040 Intel Integrated RAID Module RMS25KB080 .El .Sh CONFIGURATION +.Pp +In all tunable descriptions below, X represents the adapter number. +.Pp To disable MSI interrupts for all .Nm -driver instances, set the following tunable value in +driver instances, set this tunable value in .Xr loader.conf 5 : .Bd -literal -offset indent hw.mps.disable_msi=1 @@ -105,17 +108,15 @@ hw.mps.disable_msi=1 .Pp To disable MSI interrupts for a specific .Nm -driver instance, set the following tunable value in +driver instance, set this tunable value in .Xr loader.conf 5 : .Bd -literal -offset indent dev.mps.X.disable_msi=1 .Ed .Pp -where X is the adapter number. -.Pp To disable MSI-X interrupts for all .Nm -driver instances, set the following tunable value in +driver instances, set this tunable value in .Xr loader.conf 5 : .Bd -literal -offset indent hw.mps.disable_msix=1 @@ -123,84 +124,157 @@ hw.mps.disable_msix=1 .Pp To disable MSI-X interrupts for a specific .Nm -driver instance, set the following tunable value in +driver instance, set this tunable value in .Xr loader.conf 5 : .Bd -literal -offset indent dev.mps.X.disable_msix=1 .Ed .Pp -where X is the adapter number. -.Pp -To set the maximum number of DMA chains allocated for all adapters, -set the following variable in +To set the maximum number of DMA chains allocated for all adapters, set this +tunable in .Xr loader.conf 5 : .Bd -literal -offset indent hw.mps.max_chains=NNNN .Ed .Pp To set the maximum number of DMA chains allocated for a specific adapter, -set the following variable in +set this tunable in .Xr loader.conf 5 : .Bd -literal -offset indent dev.mps.X.max_chains=NNNN .Ed .Pp -This variable may also be viewed via -.Xr sysctl 8 -to see the maximum set for a given adapter. +The default max_chains value is 2048. .Pp -The current number of free chain frames may be seen via the +The current number of free chain frames is stored in the dev.mps.X.chain_free .Xr sysctl 8 variable. .Pp -The lowest number of free chain frames may be seen via the +The lowest number of free chain frames seen since boot is stored in the dev.mps.X.chain_free_lowwater .Xr sysctl 8 variable. .Pp +The number of times that chain frame allocations have failed since boot is +stored in the +dev.mps.X.chain_alloc_fail +.Xr sysctl 8 +variable. +This can be used to determine whether the max_chains tunable should be +increased to help performance. +.Pp The current number of active I/O commands is shown in the dev.mps.X.io_cmds_active .Xr sysctl 8 variable. +.Ed +.Pp +To set the maximum number of pages that will be used per I/O for all adapters, +set this tunable in +.Xr loader.conf 5 : +.Bd -literal -offset indent +hw.mps.max_io_pages=NNNN +.Ed .Pp -The maximum number of active I/O command seen since boot is shown in the +To set the maximum number of pages that will be used per I/O for a specific +adapter, set this tunable in +.Xr loader.conf 5 : +.Bd -literal -offset indent +dev.mps.X.max_io_pages=NNNN +.Ed +.Pp +The default max_io_pages value is -1, meaning that the maximum I/O size that +will be used per I/O will be calculated using the IOCFacts values stored in +the controller. +The lowest value that the driver will use for max_io_pages is 1, otherwise +IOCFacts will be used to calculate the maximum I/O size. +The smaller I/O size calculated from either max_io_pages or IOCFacts will be the +maximum I/O size used by the driver. +.Pp +The highest number of active I/O commands seen since boot is stored in the dev.mps.X.io_cmds_highwater .Xr sysctl 8 variable. .Pp +Devices can be excluded from +.Nm +control for all adapters by setting this tunable in +.Xr loader.conf 5 : +.Bd -literal -offset indent +hw.mps.exclude_ids=Y +.Ed +.Pp +Y represents the target ID of the device. +If more than one device is to be excluded, target IDs are separated by commas. +.Pp +Devices can be excluded from +.Nm +control for a specific adapter by setting this tunable in +.Xr loader.conf 5 : +.Bd -literal -offset indent +dev.mps.X.exclude_ids=Y +.Ed +.Pp +Y represents the target ID of the device. +If more than one device is to be excluded, target IDs are separated by commas. +.Pp The adapter can issue the .Sy StartStopUnit -SCSI command to SATA direct-access devices during shutdown, to allow the -device to quiesce before being powered down. +SCSI command to SATA direct-access devices during shutdown. +This allows the device to quiesce powering down. To control this feature for all adapters, set the .Bd -literal -offset indent hw.mps.enable_ssu .Ed .Pp -tunable value in +tunable in .Xr loader.conf 5 -to one of the following values: +to one of these values: .Bl -tag -width 6n -offset indent .It 0 Do not send SSU to either HDDs or SSDs. .It 1 -Send SSU to SSDs, but not to HDDs; this is the default value. +Send SSU to SSDs, but not to HDDs. +This is the default value. .It 2 Send SSU to HDDs, but not to SSDs. .It 3 Send SSU to both HDDs and SSDs. .El .Pp -To control the feature for a specific adapter, set the following tunable -value in +To control the feature for a specific adapter, set this tunable value in .Xr loader.conf 5 : .Bd -literal -offset indent dev.mps.X.enable_ssu .Ed .Pp -where X is the adapter number. -The same set of values are valid as for all adapters. +The same set of values are valid when setting this tunable for all adapters. +.Pp +SATA disks that take several seconds to spin up and fail the SATA Identify +command might not be discovered by the driver. +This problem can sometimes be overcome by increasing the value of the spinup +wait time in +.Xr loader.conf 5 +with the +.Bd -literal -offset indent +hw.mps.spinup_wait_time=NNNN +.Ed +.Pp +tunable. +NNNN represents the number of seconds to wait for SATA devices to spin up when +the device fails the initial SATA Identify command. +.Pp +Spinup wait times can be set for specific adapters in +.Xr loader.conf 5 : +with the +.Bd -literal -offset indent +dev.mps.X.spinup_wait_time=NNNN +.Ed +.Pp +tunable. +NNNN is the number of seconds to wait for SATA devices to spin up when they fail +the initial SATA Identify command. .Sh DEBUGGING To enable debugging prints from the .Nm @@ -209,25 +283,30 @@ driver, set the hw.mps.X.debug_level .Ed .Pp -variable, where X is the adapter number, either in +tunable, either in .Xr loader.conf 5 -or via +or by using .Xr sysctl 8 . -The following bits have the described effects: -.Bl -tag -width 6n -offset indent -.It 0x01 -Enable informational prints. -.It 0x02 -Enable tracing prints. -.It 0x04 -Enable prints for driver faults. -.It 0x08 -Enable prints for controller events. -.El +These bits have the described effects: +.Bd -literal -offset indent +0x0001 Enable informational prints (set by default). +0x0002 Enable prints for driver faults (set by default). +0x0004 Enable prints for controller events. +0x0008 Enable prints for controller logging. +0x0010 Enable prints for tracing recovery operations. +0x0020 Enable prints for parameter errors and programming bugs. +0x0040 Enable prints for system initialization operations. +0x0080 Enable prints for more detailed information. +0x0100 Enable prints for user-generated commands (IOCTL). +0x0200 Enable prints for device mapping. +0x0400 Enable prints for tracing through driver functions. +.Ed .Sh SEE ALSO +.Xr cam 4 , .Xr cd 4 , .Xr ch 4 , .Xr da 4 , +.Xr mpr 4 , .Xr mpt 4 , .Xr pci 4 , .Xr sa 4 , @@ -238,24 +317,17 @@ Enable prints for controller events. .Sh HISTORY The .Nm -driver first appeared in -.Fx 9.0 . +driver first appeared in FreeBSD 9.3. .Sh AUTHORS -.An -nosplit The .Nm driver was originally written by -.An Scott Long Aq scottl@FreeBSD.org . -It has been improved and tested by LSI Logic Corporation. +.An -nosplit +.An Scott Long Aq Mt scottl@FreeBSD.org . +It has been improved and tested by LSI Corporation, +Avago Technologies (formally LSI), and Broadcom Ltd. (formally Avago). +.Pp This man page was written by -.An Ken Merry Aq ken@FreeBSD.org . -.Sh BUGS -This driver has a couple of known shortcomings: -.Bl -bullet -compact -.It -No userland utility available (e.g., -.Xr mptutil 8 ) . -.It -The driver probes devices sequentially. -If your system has a large number of devices, the probe will take a while. -.El +.An Ken Merry Aq Mt ken@FreeBSD.org +with additional input from +.An Stephen McConnell Aq Mt slm@FreeBSD.org . Modified: stable/10/sys/dev/mpr/mpr.c ============================================================================== --- stable/10/sys/dev/mpr/mpr.c Wed Jul 20 12:46:21 2016 (r303088) +++ stable/10/sys/dev/mpr/mpr.c Wed Jul 20 14:38:02 2016 (r303089) @@ -1373,6 +1373,7 @@ mpr_get_tunables(struct mpr_softc *sc) sc->disable_msix = 0; sc->disable_msi = 0; sc->max_chains = MPR_CHAIN_FRAMES; + sc->max_io_pages = MPR_MAXIO_PAGES; sc->enable_ssu = MPR_SSU_ENABLE_SSD_DISABLE_HDD; sc->spinup_wait_time = DEFAULT_SPINUP_WAIT; @@ -1383,6 +1384,7 @@ mpr_get_tunables(struct mpr_softc *sc) TUNABLE_INT_FETCH("hw.mpr.disable_msix", &sc->disable_msix); TUNABLE_INT_FETCH("hw.mpr.disable_msi", &sc->disable_msi); TUNABLE_INT_FETCH("hw.mpr.max_chains", &sc->max_chains); + TUNABLE_INT_FETCH("hw.mpr.max_io_pages", &sc->max_io_pages); TUNABLE_INT_FETCH("hw.mpr.enable_ssu", &sc->enable_ssu); TUNABLE_INT_FETCH("hw.mpr.spinup_wait_time", &sc->spinup_wait_time); @@ -1403,6 +1405,10 @@ mpr_get_tunables(struct mpr_softc *sc) device_get_unit(sc->mpr_dev)); TUNABLE_INT_FETCH(tmpstr, &sc->max_chains); + snprintf(tmpstr, sizeof(tmpstr), "dev.mpr.%d.max_io_pages", + device_get_unit(sc->mpr_dev)); + TUNABLE_INT_FETCH(tmpstr, &sc->max_io_pages); + bzero(sc->exclude_ids, sizeof(sc->exclude_ids)); snprintf(tmpstr, sizeof(tmpstr), "dev.mpr.%d.exclude_ids", device_get_unit(sc->mpr_dev)); @@ -1488,6 +1494,11 @@ mpr_setup_sysctl(struct mpr_softc *sc) &sc->max_chains, 0,"maximum chain frames that will be allocated"); SYSCTL_ADD_INT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), + OID_AUTO, "max_io_pages", CTLFLAG_RD, + &sc->max_io_pages, 0,"maximum pages to allow per I/O (if <1 use " + "IOCFacts)"); + + SYSCTL_ADD_INT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), OID_AUTO, "enable_ssu", CTLFLAG_RW, &sc->enable_ssu, 0, "enable SSU to SATA SSD/HDD at shutdown"); Modified: stable/10/sys/dev/mpr/mpr_sas.c ============================================================================== --- stable/10/sys/dev/mpr/mpr_sas.c Wed Jul 20 12:46:21 2016 (r303088) +++ stable/10/sys/dev/mpr/mpr_sas.c Wed Jul 20 14:38:02 2016 (r303089) @@ -971,6 +971,8 @@ mprsas_action(struct cam_sim *sim, union case XPT_PATH_INQ: { struct ccb_pathinq *cpi = &ccb->cpi; + struct mpr_softc *sc = sassc->sc; + uint8_t sges_per_frame; cpi->version_num = 1; cpi->hba_inquiry = PI_SDTR_ABLE|PI_TAG_ABLE|PI_WIDE_16; @@ -999,13 +1001,23 @@ mprsas_action(struct cam_sim *sim, union cpi->transport_version = 0; cpi->protocol = PROTO_SCSI; cpi->protocol_version = SCSI_REV_SPC; -#if __FreeBSD_version >= 800001 + /* - * XXXSLM-probably need to base this number on max SGL's and - * page size. - */ - cpi->maxio = 256 * 1024; -#endif + * Max IO Size is Page Size * the following: + * ((SGEs per frame - 1 for chain element) * + * Max Chain Depth) + 1 for no chain needed in last frame + * + * If user suggests a Max IO size to use, use the smaller of the + * user's value and the calculated value as long as the user's + * value is larger than 0. The user's value is in pages. + */ + sges_per_frame = (sc->chain_frame_size / + sizeof(MPI2_IEEE_SGE_SIMPLE64)) - 1; + cpi->maxio = (sges_per_frame * sc->facts->MaxChainDepth) + 1; + cpi->maxio *= PAGE_SIZE; + if ((sc->max_io_pages > 0) && (sc->max_io_pages * PAGE_SIZE < + cpi->maxio)) + cpi->maxio = sc->max_io_pages * PAGE_SIZE; mprsas_set_ccbstatus(ccb, CAM_REQ_CMP); break; } Modified: stable/10/sys/dev/mpr/mprvar.h ============================================================================== --- stable/10/sys/dev/mpr/mprvar.h Wed Jul 20 12:46:21 2016 (r303088) +++ stable/10/sys/dev/mpr/mprvar.h Wed Jul 20 14:38:02 2016 (r303089) @@ -33,7 +33,7 @@ #ifndef _MPRVAR_H #define _MPRVAR_H -#define MPR_DRIVER_VERSION "13.00.00.00-fbsd" +#define MPR_DRIVER_VERSION "13.01.00.00-fbsd" #define MPR_DB_MAX_WAIT 2500 @@ -41,6 +41,7 @@ #define MPR_EVT_REPLY_FRAMES 32 #define MPR_REPLY_FRAMES MPR_REQ_FRAMES #define MPR_CHAIN_FRAMES 2048 +#define MPR_MAXIO_PAGES (-1) #define MPR_SENSE_LEN SSD_FULL_SIZE #define MPR_MSI_COUNT 1 #define MPR_SGE64_SIZE 12 @@ -264,6 +265,7 @@ struct mpr_softc { int io_cmds_highwater; int chain_free; int max_chains; + int max_io_pages; int chain_free_lowwater; uint32_t chain_frame_size; uint16_t chain_seg_size; Modified: stable/10/sys/dev/mps/mps.c ============================================================================== --- stable/10/sys/dev/mps/mps.c Wed Jul 20 12:46:21 2016 (r303088) +++ stable/10/sys/dev/mps/mps.c Wed Jul 20 14:38:02 2016 (r303089) @@ -1350,6 +1350,7 @@ mps_get_tunables(struct mps_softc *sc) sc->disable_msix = 0; sc->disable_msi = 0; sc->max_chains = MPS_CHAIN_FRAMES; + sc->max_io_pages = MPS_MAXIO_PAGES; sc->enable_ssu = MPS_SSU_ENABLE_SSD_DISABLE_HDD; sc->spinup_wait_time = DEFAULT_SPINUP_WAIT; @@ -1360,6 +1361,7 @@ mps_get_tunables(struct mps_softc *sc) TUNABLE_INT_FETCH("hw.mps.disable_msix", &sc->disable_msix); TUNABLE_INT_FETCH("hw.mps.disable_msi", &sc->disable_msi); TUNABLE_INT_FETCH("hw.mps.max_chains", &sc->max_chains); + TUNABLE_INT_FETCH("hw.mps.max_io_pages", &sc->max_io_pages); TUNABLE_INT_FETCH("hw.mps.enable_ssu", &sc->enable_ssu); TUNABLE_INT_FETCH("hw.mps.spinup_wait_time", &sc->spinup_wait_time); @@ -1380,6 +1382,10 @@ mps_get_tunables(struct mps_softc *sc) device_get_unit(sc->mps_dev)); TUNABLE_INT_FETCH(tmpstr, &sc->max_chains); + snprintf(tmpstr, sizeof(tmpstr), "dev.mps.%d.max_io_pages", + device_get_unit(sc->mps_dev)); + TUNABLE_INT_FETCH(tmpstr, &sc->max_io_pages); + bzero(sc->exclude_ids, sizeof(sc->exclude_ids)); snprintf(tmpstr, sizeof(tmpstr), "dev.mps.%d.exclude_ids", device_get_unit(sc->mps_dev)); @@ -1465,6 +1471,11 @@ mps_setup_sysctl(struct mps_softc *sc) &sc->max_chains, 0,"maximum chain frames that will be allocated"); SYSCTL_ADD_INT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), + OID_AUTO, "max_io_pages", CTLFLAG_RD, + &sc->max_io_pages, 0,"maximum pages to allow per I/O (if <1 use " + "IOCFacts)"); + + SYSCTL_ADD_INT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), OID_AUTO, "enable_ssu", CTLFLAG_RW, &sc->enable_ssu, 0, "enable SSU to SATA SSD/HDD at shutdown"); Modified: stable/10/sys/dev/mps/mps_sas.c ============================================================================== --- stable/10/sys/dev/mps/mps_sas.c Wed Jul 20 12:46:21 2016 (r303088) +++ stable/10/sys/dev/mps/mps_sas.c Wed Jul 20 14:38:02 2016 (r303089) @@ -928,6 +928,8 @@ mpssas_action(struct cam_sim *sim, union case XPT_PATH_INQ: { struct ccb_pathinq *cpi = &ccb->cpi; + struct mps_softc *sc = sassc->sc; + uint8_t sges_per_frame; cpi->version_num = 1; cpi->hba_inquiry = PI_SDTR_ABLE|PI_TAG_ABLE|PI_WIDE_16; @@ -951,12 +953,23 @@ mpssas_action(struct cam_sim *sim, union cpi->transport_version = 0; cpi->protocol = PROTO_SCSI; cpi->protocol_version = SCSI_REV_SPC; -#if __FreeBSD_version >= 800001 + /* - * XXX KDM where does this number come from? - */ - cpi->maxio = 256 * 1024; -#endif + * Max IO Size is Page Size * the following: + * ((SGEs per frame - 1 for chain element) * + * Max Chain Depth) + 1 for no chain needed in last frame + * + * If user suggests a Max IO size to use, use the smaller of the + * user's value and the calculated value as long as the user's + * value is larger than 0. The user's value is in pages. + */ + sges_per_frame = ((sc->facts->IOCRequestFrameSize * 4) / + sizeof(MPI2_SGE_SIMPLE64)) - 1; + cpi->maxio = (sges_per_frame * sc->facts->MaxChainDepth) + 1; + cpi->maxio *= PAGE_SIZE; + if ((sc->max_io_pages > 0) && (sc->max_io_pages * PAGE_SIZE < + cpi->maxio)) + cpi->maxio = sc->max_io_pages * PAGE_SIZE; mpssas_set_ccbstatus(ccb, CAM_REQ_CMP); break; } Modified: stable/10/sys/dev/mps/mpsvar.h ============================================================================== --- stable/10/sys/dev/mps/mpsvar.h Wed Jul 20 12:46:21 2016 (r303088) +++ stable/10/sys/dev/mps/mpsvar.h Wed Jul 20 14:38:02 2016 (r303089) @@ -33,7 +33,7 @@ #ifndef _MPSVAR_H #define _MPSVAR_H -#define MPS_DRIVER_VERSION "21.00.00.00-fbsd" +#define MPS_DRIVER_VERSION "21.01.00.00-fbsd" #define MPS_DB_MAX_WAIT 2500 @@ -41,6 +41,7 @@ #define MPS_EVT_REPLY_FRAMES 32 #define MPS_REPLY_FRAMES MPS_REQ_FRAMES #define MPS_CHAIN_FRAMES 2048 +#define MPS_MAXIO_PAGES (-1) #define MPS_SENSE_LEN SSD_FULL_SIZE #define MPS_MSI_COUNT 1 #define MPS_SGE64_SIZE 12 @@ -280,6 +281,7 @@ struct mps_softc { int io_cmds_highwater; int chain_free; int max_chains; + int max_io_pages; int chain_free_lowwater; u_int enable_ssu; int spinup_wait_time; From owner-svn-src-stable-10@freebsd.org Wed Jul 20 15:07:53 2016 Return-Path: Delivered-To: svn-src-stable-10@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 DD428B9FA80; Wed, 20 Jul 2016 15:07:53 +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 B51DE1F80; Wed, 20 Jul 2016 15:07:53 +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 u6KF7qYp068222; Wed, 20 Jul 2016 15:07:52 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6KF7qp4068218; Wed, 20 Jul 2016 15:07:52 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201607201507.u6KF7qp4068218@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 20 Jul 2016 15:07:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303093 - in stable/10: sys/kern sys/sys usr.bin/kdump X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jul 2016 15:07:54 -0000 Author: kib Date: Wed Jul 20 15:07:52 2016 New Revision: 303093 URL: https://svnweb.freebsd.org/changeset/base/303093 Log: MFC r302770: Trace timeval parameters to the getitimer(2) and setitimer(2) syscalls. Modified: stable/10/sys/kern/kern_time.c stable/10/sys/sys/ktrace.h stable/10/usr.bin/kdump/kdump.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/kern_time.c ============================================================================== --- stable/10/sys/kern/kern_time.c Wed Jul 20 15:02:37 2016 (r303092) +++ stable/10/sys/kern/kern_time.c Wed Jul 20 15:07:52 2016 (r303093) @@ -32,6 +32,8 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_ktrace.h" + #include #include #include @@ -54,6 +56,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#ifdef KTRACE +#include +#endif #include #include @@ -699,6 +704,10 @@ kern_getitimer(struct thread *td, u_int *aitv = p->p_stats->p_timer[which]; PROC_ITIMUNLOCK(p); } +#ifdef KTRACE + if (KTRPOINT(td, KTR_STRUCT)) + ktritimerval(aitv); +#endif return (0); } @@ -740,6 +749,10 @@ kern_setitimer(struct thread *td, u_int if (which > ITIMER_PROF) return (EINVAL); +#ifdef KTRACE + if (KTRPOINT(td, KTR_STRUCT)) + ktritimerval(aitv); +#endif if (itimerfix(&aitv->it_value) || aitv->it_value.tv_sec > INT32_MAX / 2) return (EINVAL); @@ -784,6 +797,10 @@ kern_setitimer(struct thread *td, u_int p->p_stats->p_timer[which] = *aitv; PROC_ITIMUNLOCK(p); } +#ifdef KTRACE + if (KTRPOINT(td, KTR_STRUCT)) + ktritimerval(oitv); +#endif return (0); } Modified: stable/10/sys/sys/ktrace.h ============================================================================== --- stable/10/sys/sys/ktrace.h Wed Jul 20 15:02:37 2016 (r303092) +++ stable/10/sys/sys/ktrace.h Wed Jul 20 15:07:52 2016 (r303093) @@ -270,6 +270,8 @@ void ktrcapfail(enum ktr_cap_fail_type, const cap_rights_t *); #define ktrcaprights(s) \ ktrstruct("caprights", (s), sizeof(cap_rights_t)) +#define ktritimerval(s) \ + ktrstruct("itimerval", (s), sizeof(struct itimerval)) #define ktrsockaddr(s) \ ktrstruct("sockaddr", (s), ((struct sockaddr *)(s))->sa_len) #define ktrstat(s) \ Modified: stable/10/usr.bin/kdump/kdump.c ============================================================================== --- stable/10/usr.bin/kdump/kdump.c Wed Jul 20 15:02:37 2016 (r303092) +++ stable/10/usr.bin/kdump/kdump.c Wed Jul 20 15:07:52 2016 (r303093) @@ -106,6 +106,7 @@ void ktruser_malloc(void *); void ktruser_rtld(int, void *); void ktruser(int, void *); void ktrcaprights(cap_rights_t *); +void ktritimerval(struct itimerval *it); void ktrsockaddr(struct sockaddr *); void ktrstat(struct stat *); void ktrstruct(char *, size_t); @@ -1616,6 +1617,24 @@ ktrcaprights(cap_rights_t *rightsp) printf("\n"); } +static void +ktrtimeval(struct timeval *tv) +{ + + printf("{%ld, %ld}", (long)tv->tv_sec, tv->tv_usec); +} + +void +ktritimerval(struct itimerval *it) +{ + + printf("itimerval { .interval = "); + ktrtimeval(&it->it_interval); + printf(", .value = "); + ktrtimeval(&it->it_value); + printf(" }\n"); +} + void ktrsockaddr(struct sockaddr *sa) { @@ -1799,6 +1818,7 @@ ktrstruct(char *buf, size_t buflen) size_t namelen, datalen; int i; cap_rights_t rights; + struct itimerval it; struct stat sb; struct sockaddr_storage ss; @@ -1823,6 +1843,11 @@ ktrstruct(char *buf, size_t buflen) goto invalid; memcpy(&rights, data, datalen); ktrcaprights(&rights); + } else if (strcmp(name, "itimerval") == 0) { + if (datalen != sizeof(struct itimerval)) + goto invalid; + memcpy(&it, data, datalen); + ktritimerval(&it); } else if (strcmp(name, "stat") == 0) { if (datalen != sizeof(struct stat)) goto invalid; From owner-svn-src-stable-10@freebsd.org Wed Jul 20 16:36:20 2016 Return-Path: Delivered-To: svn-src-stable-10@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 187D2B9F6D3; Wed, 20 Jul 2016 16:36:20 +0000 (UTC) (envelope-from sobomax@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 D5DBC11CC; Wed, 20 Jul 2016 16:36:19 +0000 (UTC) (envelope-from sobomax@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6KGaJBJ003155; Wed, 20 Jul 2016 16:36:19 GMT (envelope-from sobomax@FreeBSD.org) Received: (from sobomax@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6KGaHbC003138; Wed, 20 Jul 2016 16:36:17 GMT (envelope-from sobomax@FreeBSD.org) Message-Id: <201607201636.u6KGaHbC003138@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sobomax set sender to sobomax@FreeBSD.org using -f From: Maxim Sobolev Date: Wed, 20 Jul 2016 16:36:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303095 - stable/10/usr.bin/mkuzip X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jul 2016 16:36:20 -0000 Author: sobomax Date: Wed Jul 20 16:36:17 2016 New Revision: 303095 URL: https://svnweb.freebsd.org/changeset/base/303095 Log: MFC: merge in all new features and improvements into mkuzip(8) from current, which includes: o LZMA compression; o block de-duplication; o performance improvements; o multi-thread support. This includes the following revisions: r295943,r296626,r296628,r296810,r298504,r298505,r298577 Suggested by: emaste Added: stable/10/usr.bin/mkuzip/mkuz_blk.c (contents, props changed) stable/10/usr.bin/mkuzip/mkuz_blk.h (contents, props changed) stable/10/usr.bin/mkuzip/mkuz_blk_chain.h (contents, props changed) stable/10/usr.bin/mkuzip/mkuz_blockcache.c (contents, props changed) stable/10/usr.bin/mkuzip/mkuz_blockcache.h (contents, props changed) stable/10/usr.bin/mkuzip/mkuz_cfg.h (contents, props changed) stable/10/usr.bin/mkuzip/mkuz_cloop.h (contents, props changed) stable/10/usr.bin/mkuzip/mkuz_conveyor.c (contents, props changed) stable/10/usr.bin/mkuzip/mkuz_conveyor.h (contents, props changed) stable/10/usr.bin/mkuzip/mkuz_format.h (contents, props changed) stable/10/usr.bin/mkuzip/mkuz_fqueue.c (contents, props changed) stable/10/usr.bin/mkuzip/mkuz_fqueue.h (contents, props changed) stable/10/usr.bin/mkuzip/mkuz_lzma.c (contents, props changed) stable/10/usr.bin/mkuzip/mkuz_lzma.h (contents, props changed) stable/10/usr.bin/mkuzip/mkuz_time.c (contents, props changed) stable/10/usr.bin/mkuzip/mkuz_time.h (contents, props changed) stable/10/usr.bin/mkuzip/mkuz_zlib.c (contents, props changed) stable/10/usr.bin/mkuzip/mkuz_zlib.h (contents, props changed) stable/10/usr.bin/mkuzip/mkuzip.h (contents, props changed) Modified: stable/10/usr.bin/mkuzip/Makefile stable/10/usr.bin/mkuzip/mkuzip.8 stable/10/usr.bin/mkuzip/mkuzip.c Modified: stable/10/usr.bin/mkuzip/Makefile ============================================================================== --- stable/10/usr.bin/mkuzip/Makefile Wed Jul 20 15:59:37 2016 (r303094) +++ stable/10/usr.bin/mkuzip/Makefile Wed Jul 20 16:36:17 2016 (r303095) @@ -2,9 +2,10 @@ PROG= mkuzip MAN= mkuzip.8 +SRCS= mkuzip.c mkuz_blockcache.c mkuz_lzma.c mkuz_zlib.c mkuz_conveyor.c \ + mkuz_blk.c mkuz_fqueue.c mkuz_time.c -DPADD= ${LIBZ} -LDADD= -lz - +DPADD= ${LIBZ} ${LIBMD} ${LIBLZMA} ${LIBPTHREAD} +LDADD= -lz -lmd -llzma -lpthread .include Added: stable/10/usr.bin/mkuzip/mkuz_blk.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/usr.bin/mkuzip/mkuz_blk.c Wed Jul 20 16:36:17 2016 (r303095) @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2004-2016 Maxim Sobolev + * 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$"); + +#include +#include + +#include "mkuzip.h" +#include "mkuz_blk.h" + +struct mkuz_blk * +mkuz_blk_ctor(size_t blen) +{ + struct mkuz_blk *rval; + + rval = mkuz_safe_zmalloc(sizeof(struct mkuz_blk) + blen); + rval->alen = blen; + rval->br_offset = OFFSET_UNDEF; + return (rval); +} Added: stable/10/usr.bin/mkuzip/mkuz_blk.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/usr.bin/mkuzip/mkuz_blk.h Wed Jul 20 16:36:17 2016 (r303095) @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2004-2016 Maxim Sobolev + * 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. + * + * $FreeBSD$ + */ + +#define OFFSET_UNDEF UINT64_MAX + +struct mkuz_blk_info { + uint64_t offset; + size_t len; + uint32_t blkno; + unsigned char digest[16]; +}; + +#define MKUZ_BLK_EOF (void *)0x1 +#define MKUZ_BLK_MORE (void *)0x2 + +struct mkuz_blk { + struct mkuz_blk_info info; + size_t alen; + uint64_t br_offset; + unsigned char data[]; +}; + +struct mkuz_blk *mkuz_blk_ctor(size_t); Added: stable/10/usr.bin/mkuzip/mkuz_blk_chain.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/usr.bin/mkuzip/mkuz_blk_chain.h Wed Jul 20 16:36:17 2016 (r303095) @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2016 Maxim Sobolev + * 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. + * + * $FreeBSD$ + */ + +struct mkuz_blk; +struct mkuz_bchain_link; + +struct mkuz_bchain_link { + struct mkuz_blk *this; + struct mkuz_bchain_link *prev; +}; Added: stable/10/usr.bin/mkuzip/mkuz_blockcache.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/usr.bin/mkuzip/mkuz_blockcache.c Wed Jul 20 16:36:17 2016 (r303095) @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2016 Maxim Sobolev + * 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$"); + +#include +#include +#include +#include +#include + +#if defined(MKUZ_DEBUG) +# include +# include +#endif + +#include "mkuz_blockcache.h" +#include "mkuz_blk.h" + +struct mkuz_blkcache_itm { + struct mkuz_blk_info hit; + struct mkuz_blkcache_itm *next; +}; + +static struct mkuz_blkcache { + struct mkuz_blkcache_itm first[256]; +} blkcache; + +static int +verify_match(int fd, const struct mkuz_blk *cbp, struct mkuz_blkcache_itm *bcep) +{ + void *vbuf; + ssize_t rlen; + int rval; + + rval = -1; + vbuf = malloc(cbp->info.len); + if (vbuf == NULL) { + goto e0; + } + if (lseek(fd, bcep->hit.offset, SEEK_SET) < 0) { + goto e1; + } + rlen = read(fd, vbuf, cbp->info.len); + if (rlen < 0 || (unsigned)rlen != cbp->info.len) { + goto e2; + } + rval = (memcmp(cbp->data, vbuf, cbp->info.len) == 0) ? 1 : 0; +e2: + lseek(fd, cbp->info.offset, SEEK_SET); +e1: + free(vbuf); +e0: + return (rval); +} + +#define I2J(x) ((intmax_t)(x)) +#define U2J(x) ((uintmax_t)(x)) + +static unsigned char +digest_fold(const unsigned char *mdigest) +{ + int i; + unsigned char rval; + + rval = mdigest[0]; + for (i = 1; i < 16; i++) { + rval = rval ^ mdigest[i]; + } + return (rval); +} + +struct mkuz_blk_info * +mkuz_blkcache_regblock(int fd, const struct mkuz_blk *bp) +{ + struct mkuz_blkcache_itm *bcep; + int rval; + unsigned char h; + +#if defined(MKUZ_DEBUG) + assert((unsigned)lseek(fd, 0, SEEK_CUR) == bp->info.offset); +#endif + h = digest_fold(bp->info.digest); + if (blkcache.first[h].hit.len == 0) { + bcep = &blkcache.first[h]; + } else { + for (bcep = &blkcache.first[h]; bcep != NULL; bcep = bcep->next) { + if (bcep->hit.len != bp->info.len) + continue; + if (memcmp(bp->info.digest, bcep->hit.digest, + sizeof(bp->info.digest)) == 0) { + break; + } + } + if (bcep != NULL) { + rval = verify_match(fd, bp, bcep); + if (rval == 1) { +#if defined(MKUZ_DEBUG) + fprintf(stderr, "cache hit %jd, %jd, %jd, %jd\n", + I2J(bcep->hit.blkno), I2J(bcep->hit.offset), + I2J(bp->info.offset), I2J(bp->info.len)); +#endif + return (&bcep->hit); + } + if (rval == 0) { +#if defined(MKUZ_DEBUG) + fprintf(stderr, "block MD5 collision, you should try lottery, " + "man!\n"); +#endif + return (NULL); + } + warn("verify_match"); + return (NULL); + } + bcep = malloc(sizeof(struct mkuz_blkcache_itm)); + if (bcep == NULL) + return (NULL); + memset(bcep, '\0', sizeof(struct mkuz_blkcache_itm)); + bcep->next = blkcache.first[h].next; + blkcache.first[h].next = bcep; + } + bcep->hit = bp->info; + return (NULL); +} Added: stable/10/usr.bin/mkuzip/mkuz_blockcache.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/usr.bin/mkuzip/mkuz_blockcache.h Wed Jul 20 16:36:17 2016 (r303095) @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2016 Maxim Sobolev + * 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. + * + * $FreeBSD$ + */ + +struct mkuz_blk; + +struct mkuz_blk_info *mkuz_blkcache_regblock(int, const struct mkuz_blk *); Added: stable/10/usr.bin/mkuzip/mkuz_cfg.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/usr.bin/mkuzip/mkuz_cfg.h Wed Jul 20 16:36:17 2016 (r303095) @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2016 Maxim Sobolev + * 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. + * + * $FreeBSD$ + */ + +struct mkuz_conveyor; + +struct mkuz_cfg { + int fdr; + int fdw; + int verbose; + int no_zcomp; + int en_dedup; + int nworkers; + int blksz; + const struct mkuz_format *handler; +}; Added: stable/10/usr.bin/mkuzip/mkuz_cloop.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/usr.bin/mkuzip/mkuz_cloop.h Wed Jul 20 16:36:17 2016 (r303095) @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2004-2016 Maxim Sobolev + * 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. + * + * $FreeBSD$ + */ + +/* CLOOP format and related constants */ + +/* + * Integer values (block size, number of blocks, offsets) + * are stored in big-endian (network) order on disk. + */ + +#define CLOOP_MAGIC_LEN 128 +#define CLOOP_OFS_COMPR 0x0b +#define CLOOP_OFS_VERSN (CLOOP_OFS_COMPR + 1) + +#define CLOOP_MAJVER_2 '2' +#define CLOOP_MAJVER_3 '3' + +#define CLOOP_COMP_LIBZ 'V' +#define CLOOP_COMP_LZMA 'L' + +struct cloop_header { + char magic[CLOOP_MAGIC_LEN]; /* cloop magic */ + uint32_t blksz; /* block size */ + uint32_t nblocks; /* number of blocks */ +}; Added: stable/10/usr.bin/mkuzip/mkuz_conveyor.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/usr.bin/mkuzip/mkuz_conveyor.c Wed Jul 20 16:36:17 2016 (r303095) @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2004-2016 Maxim Sobolev + * 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$"); + +#include +#include +#include +#include +#include +#include +#include + +#if defined(MKUZ_DEBUG) +# include +#endif + +#include "mkuz_conveyor.h" +#include "mkuz_cfg.h" +#include "mkuzip.h" +#include "mkuz_format.h" +#include "mkuz_blk.h" +#include "mkuz_fqueue.h" +#include "mkuz_blk_chain.h" + +static void compute_digest(struct mkuz_blk *); + +struct cw_args { + struct mkuz_conveyor *cvp; + struct mkuz_cfg *cfp; +}; + +static void * +cworker(void *p) +{ + struct cw_args *cwp; + struct mkuz_cfg *cfp; + struct mkuz_blk *oblk, *iblk; + struct mkuz_conveyor *cvp; + void *c_ctx; + + cwp = (struct cw_args *)p; + cfp = cwp->cfp; + cvp = cwp->cvp; + free(cwp); + c_ctx = cfp->handler->f_init(cfp->blksz); + for (;;) { + iblk = mkuz_fqueue_deq(cvp->wrk_queue); + if (iblk == MKUZ_BLK_EOF) { + /* Let other threads to see the EOF block */ + mkuz_fqueue_enq(cvp->wrk_queue, iblk); + break; + } + if (cfp->no_zcomp == 0 && + mkuz_memvcmp(iblk->data, '\0', iblk->info.len) != 0) { + /* All zeroes block */ + oblk = mkuz_blk_ctor(0); + } else { + oblk = cfp->handler->f_compress(c_ctx, iblk); + if (cfp->en_dedup != 0) { + compute_digest(oblk); + } + } + oblk->info.blkno = iblk->info.blkno; + mkuz_fqueue_enq(cvp->results, oblk); + free(iblk); + } + return (NULL); +} + +static void +compute_digest(struct mkuz_blk *bp) +{ + MD5_CTX mcontext; + + MD5Init(&mcontext); + MD5Update(&mcontext, bp->data, bp->info.len); + MD5Final(bp->info.digest, &mcontext); +} + +struct mkuz_conveyor * +mkuz_conveyor_ctor(struct mkuz_cfg *cfp) +{ + struct mkuz_conveyor *cp; + struct cw_args *cwp; + int i, r; + + cp = mkuz_safe_zmalloc(sizeof(struct mkuz_conveyor) + + (sizeof(pthread_t) * cfp->nworkers)); + + cp->wrk_queue = mkuz_fqueue_ctor(1); + cp->results = mkuz_fqueue_ctor(1); + + for (i = 0; i < cfp->nworkers; i++) { + cwp = mkuz_safe_zmalloc(sizeof(struct cw_args)); + cwp->cfp = cfp; + cwp->cvp = cp; + r = pthread_create(&cp->wthreads[i], NULL, cworker, (void *)cwp); + if (r != 0) { + errx(1, "mkuz_conveyor_ctor: pthread_create() failed"); + /* Not reached */ + } + } + return (cp); +} Added: stable/10/usr.bin/mkuzip/mkuz_conveyor.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/usr.bin/mkuzip/mkuz_conveyor.h Wed Jul 20 16:36:17 2016 (r303095) @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016 Maxim Sobolev + * 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. + * + * $FreeBSD$ + */ + +struct mkuz_fifo_queue; + +#define ITEMS_PER_WORKER 4 + +#define MAX_WORKERS_AUTO 24 + +struct mkuz_conveyor { + /* + * Work items are places in here, and picked up by workers in a FIFO + * fashion. + */ + struct mkuz_fifo_queue *wrk_queue; + /* + * Results are dropped into this FIFO and consumer is buzzed to pick them + * up + */ + struct mkuz_fifo_queue *results; + + pthread_t wthreads[]; +}; + +struct mkuz_cfg; + +struct mkuz_conveyor *mkuz_conveyor_ctor(struct mkuz_cfg *); Added: stable/10/usr.bin/mkuzip/mkuz_format.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/usr.bin/mkuzip/mkuz_format.h Wed Jul 20 16:36:17 2016 (r303095) @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2016 Maxim Sobolev + * 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. + * + * $FreeBSD$ + */ + +DEFINE_RAW_METHOD(f_init, void *, uint32_t); +DEFINE_RAW_METHOD(f_compress, struct mkuz_blk *, void *, const struct mkuz_blk *); + +struct mkuz_format { + const char *magic; + const char *default_sufx; + f_init_t f_init; + f_compress_t f_compress; +}; Added: stable/10/usr.bin/mkuzip/mkuz_fqueue.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/usr.bin/mkuzip/mkuz_fqueue.c Wed Jul 20 16:36:17 2016 (r303095) @@ -0,0 +1,214 @@ +/* + * Copyright (c) 2004-2016 Maxim Sobolev + * 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$"); + +#include +#include +#include +#include + +#if defined(MKUZ_DEBUG) +# include +#endif + +#include "mkuzip.h" +#include "mkuz_fqueue.h" +#include "mkuz_conveyor.h" +#include "mkuz_blk.h" +#include "mkuz_blk_chain.h" + +struct mkuz_fifo_queue * +mkuz_fqueue_ctor(int wakeup_len) +{ + struct mkuz_fifo_queue *fqp; + + fqp = mkuz_safe_zmalloc(sizeof(struct mkuz_fifo_queue)); + fqp->wakeup_len = wakeup_len; + if (pthread_mutex_init(&fqp->mtx, NULL) != 0) { + errx(1, "pthread_mutex_init() failed"); + } + if (pthread_cond_init(&fqp->cvar, NULL) != 0) { + errx(1, "pthread_cond_init() failed"); + } + return (fqp); +} + +void +mkuz_fqueue_enq(struct mkuz_fifo_queue *fqp, struct mkuz_blk *bp) +{ + struct mkuz_bchain_link *ip; + + ip = mkuz_safe_zmalloc(sizeof(struct mkuz_bchain_link)); + ip->this = bp; + + pthread_mutex_lock(&fqp->mtx); + if (fqp->first != NULL) { + fqp->first->prev = ip; + } else { + fqp->last = ip; + } + fqp->first = ip; + fqp->length += 1; + if (fqp->length >= fqp->wakeup_len) { + pthread_cond_signal(&fqp->cvar); + } + pthread_mutex_unlock(&fqp->mtx); +} + +#if defined(NOTYET) +int +mkuz_fqueue_enq_all(struct mkuz_fifo_queue *fqp, struct mkuz_bchain_link *cip_f, + struct mkuz_bchain_link *cip_l, int clen) +{ + int rval; + + pthread_mutex_lock(&fqp->mtx); + if (fqp->first != NULL) { + fqp->first->prev = cip_l; + } else { + fqp->last = cip_l; + } + fqp->first = cip_f; + fqp->length += clen; + rval = fqp->length; + if (fqp->length >= fqp->wakeup_len) { + pthread_cond_signal(&fqp->cvar); + } + pthread_mutex_unlock(&fqp->mtx); + return (rval); +} +#endif + +static int +mkuz_fqueue_check(struct mkuz_fifo_queue *fqp, cmp_cb_t cmp_cb, void *cap) +{ + struct mkuz_bchain_link *ip; + + for (ip = fqp->last; ip != NULL; ip = ip->prev) { + if (cmp_cb(ip->this, cap)) { + return (1); + } + } + return (0); +} + +struct mkuz_blk * +mkuz_fqueue_deq_when(struct mkuz_fifo_queue *fqp, cmp_cb_t cmp_cb, void *cap) +{ + struct mkuz_bchain_link *ip, *newlast, *newfirst, *mip; + struct mkuz_blk *bp; + + pthread_mutex_lock(&fqp->mtx); + while (fqp->last == NULL || !mkuz_fqueue_check(fqp, cmp_cb, cap)) { + pthread_cond_wait(&fqp->cvar, &fqp->mtx); + } + if (cmp_cb(fqp->last->this, cap)) { + mip = fqp->last; + fqp->last = mip->prev; + if (fqp->last == NULL) { +#if defined(MKUZ_DEBUG) + assert(fqp->length == 1); +#endif + fqp->first = NULL; + } + } else { +#if defined(MKUZ_DEBUG) + assert(fqp->length > 1); +#endif + newfirst = newlast = fqp->last; + mip = NULL; + for (ip = fqp->last->prev; ip != NULL; ip = ip->prev) { + if (cmp_cb(ip->this, cap)) { + mip = ip; + continue; + } + newfirst->prev = ip; + newfirst = ip; + } + newfirst->prev = NULL; + fqp->first = newfirst; + fqp->last = newlast; + } + fqp->length -= 1; + pthread_mutex_unlock(&fqp->mtx); + bp = mip->this; + free(mip); + + return bp; +} + +struct mkuz_blk * +mkuz_fqueue_deq(struct mkuz_fifo_queue *fqp) +{ + struct mkuz_bchain_link *ip; + struct mkuz_blk *bp; + + pthread_mutex_lock(&fqp->mtx); + while (fqp->last == NULL) { + pthread_cond_wait(&fqp->cvar, &fqp->mtx); + } +#if defined(MKUZ_DEBUG) + assert(fqp->length > 0); +#endif + ip = fqp->last; + fqp->last = ip->prev; + if (fqp->last == NULL) { +#if defined(MKUZ_DEBUG) + assert(fqp->length == 1); +#endif + fqp->first = NULL; + } + fqp->length -= 1; + pthread_mutex_unlock(&fqp->mtx); + bp = ip->this; + free(ip); + + return bp; +} + +#if defined(NOTYET) +struct mkuz_bchain_link * +mkuz_fqueue_deq_all(struct mkuz_fifo_queue *fqp, int *rclen) +{ + struct mkuz_bchain_link *rchain; + + pthread_mutex_lock(&fqp->mtx); + while (fqp->last == NULL) { + pthread_cond_wait(&fqp->cvar, &fqp->mtx); + } +#if defined(MKUZ_DEBUG) + assert(fqp->length > 0); +#endif + rchain = fqp->last; + fqp->first = fqp->last = NULL; + *rclen = fqp->length; + fqp->length = 0; + pthread_mutex_unlock(&fqp->mtx); + return (rchain); +} +#endif Added: stable/10/usr.bin/mkuzip/mkuz_fqueue.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/usr.bin/mkuzip/mkuz_fqueue.h Wed Jul 20 16:36:17 2016 (r303095) @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2004-2016 Maxim Sobolev + * 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. + * + * $FreeBSD$ + */ + +struct mkuz_fifo_queue { + pthread_mutex_t mtx; + pthread_cond_t cvar; + struct mkuz_bchain_link *first; + struct mkuz_bchain_link *last; + int length; + int wakeup_len; +}; + +struct mkuz_blk; +struct mkuz_bchain_link; + +DEFINE_RAW_METHOD(cmp_cb, int, const struct mkuz_blk *, void *); + +struct mkuz_fifo_queue *mkuz_fqueue_ctor(int); +void mkuz_fqueue_enq(struct mkuz_fifo_queue *, struct mkuz_blk *); +struct mkuz_blk *mkuz_fqueue_deq(struct mkuz_fifo_queue *); +struct mkuz_blk *mkuz_fqueue_deq_when(struct mkuz_fifo_queue *, cmp_cb_t, void *); +#if defined(NOTYET) +struct mkuz_bchain_link *mkuz_fqueue_deq_all(struct mkuz_fifo_queue *, int *); +int mkuz_fqueue_enq_all(struct mkuz_fifo_queue *, struct mkuz_bchain_link *, + struct mkuz_bchain_link *, int); +#endif Added: stable/10/usr.bin/mkuzip/mkuz_lzma.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/usr.bin/mkuzip/mkuz_lzma.c Wed Jul 20 16:36:17 2016 (r303095) @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2004-2016 Maxim Sobolev + * Copyright (c) 2011 Aleksandr Rybalko + * 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$"); + +#include +#include +#include + +#include + +#include "mkuzip.h" +#include "mkuz_lzma.h" +#include "mkuz_blk.h" + +#define USED_BLOCKSIZE DEV_BSIZE + +struct mkuz_lzma { + lzma_filter filters[2]; + lzma_options_lzma opt_lzma; + lzma_stream strm; + uint32_t blksz; +}; + +static const lzma_stream lzma_stream_init = LZMA_STREAM_INIT; + +void * +mkuz_lzma_init(uint32_t blksz) +{ + struct mkuz_lzma *ulp; + + if (blksz % USED_BLOCKSIZE != 0) { + errx(1, "cluster size should be multiple of %d", + USED_BLOCKSIZE); + /* Not reached */ + } + if (blksz > MAXPHYS) { + errx(1, "cluster size is too large"); + /* Not reached */ + } *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-10@freebsd.org Wed Jul 20 18:26:50 2016 Return-Path: Delivered-To: svn-src-stable-10@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 0DB37B9F951; Wed, 20 Jul 2016 18:26:50 +0000 (UTC) (envelope-from sbruno@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 C5A9013B9; Wed, 20 Jul 2016 18:26:49 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6KIQn91044225; Wed, 20 Jul 2016 18:26:49 GMT (envelope-from sbruno@FreeBSD.org) Received: (from sbruno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6KIQm2t044217; Wed, 20 Jul 2016 18:26:48 GMT (envelope-from sbruno@FreeBSD.org) Message-Id: <201607201826.u6KIQm2t044217@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sbruno set sender to sbruno@FreeBSD.org using -f From: Sean Bruno Date: Wed, 20 Jul 2016 18:26:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303107 - in stable/10/sys/dev: e1000 ixgb ixgbe ixl X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jul 2016 18:26:50 -0000 Author: sbruno Date: Wed Jul 20 18:26:48 2016 New Revision: 303107 URL: https://svnweb.freebsd.org/changeset/base/303107 Log: MFC - r302384 to 10-STABLE Do not initialize the adapter on MTU change when adapter status is down. This fixes long-standing problems when changing settings of the adapter. Discussed in: https://lists.freebsd.org/pipermail/freebsd-net/2016-June/045509.html Differential Revision: https://reviews.freebsd.org/D7254 Modified: stable/10/sys/dev/e1000/if_em.c stable/10/sys/dev/e1000/if_igb.c stable/10/sys/dev/e1000/if_lem.c stable/10/sys/dev/ixgb/if_ixgb.c stable/10/sys/dev/ixgbe/if_ix.c stable/10/sys/dev/ixgbe/if_ixv.c stable/10/sys/dev/ixl/if_ixl.c stable/10/sys/dev/ixl/if_ixlv.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/e1000/if_em.c ============================================================================== --- stable/10/sys/dev/e1000/if_em.c Wed Jul 20 18:16:58 2016 (r303106) +++ stable/10/sys/dev/e1000/if_em.c Wed Jul 20 18:26:48 2016 (r303107) @@ -1220,7 +1220,8 @@ em_ioctl(struct ifnet *ifp, u_long comma ifp->if_mtu = ifr->ifr_mtu; adapter->hw.mac.max_frame_size = ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN; - em_init_locked(adapter); + if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) + em_init_locked(adapter); EM_CORE_UNLOCK(adapter); break; } Modified: stable/10/sys/dev/e1000/if_igb.c ============================================================================== --- stable/10/sys/dev/e1000/if_igb.c Wed Jul 20 18:16:58 2016 (r303106) +++ stable/10/sys/dev/e1000/if_igb.c Wed Jul 20 18:26:48 2016 (r303107) @@ -1090,7 +1090,8 @@ igb_ioctl(struct ifnet *ifp, u_long comm ifp->if_mtu = ifr->ifr_mtu; adapter->max_frame_size = ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN; - igb_init_locked(adapter); + if ((ifp->if_drv_flags & IFF_DRV_RUNNING)) + igb_init_locked(adapter); IGB_CORE_UNLOCK(adapter); break; } Modified: stable/10/sys/dev/e1000/if_lem.c ============================================================================== --- stable/10/sys/dev/e1000/if_lem.c Wed Jul 20 18:16:58 2016 (r303106) +++ stable/10/sys/dev/e1000/if_lem.c Wed Jul 20 18:26:48 2016 (r303107) @@ -1047,7 +1047,8 @@ lem_ioctl(struct ifnet *ifp, u_long comm ifp->if_mtu = ifr->ifr_mtu; adapter->max_frame_size = ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN; - lem_init_locked(adapter); + if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING)) + lem_init_locked(adapter); EM_CORE_UNLOCK(adapter); break; } Modified: stable/10/sys/dev/ixgb/if_ixgb.c ============================================================================== --- stable/10/sys/dev/ixgb/if_ixgb.c Wed Jul 20 18:16:58 2016 (r303106) +++ stable/10/sys/dev/ixgb/if_ixgb.c Wed Jul 20 18:26:48 2016 (r303107) @@ -538,7 +538,8 @@ ixgb_ioctl(struct ifnet * ifp, IOCTL_CMD adapter->hw.max_frame_size = ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN; - ixgb_init_locked(adapter); + if (ifp->if_drv_flags & IFF_DRV_RUNNING) + ixgb_init_locked(adapter); IXGB_UNLOCK(adapter); } break; Modified: stable/10/sys/dev/ixgbe/if_ix.c ============================================================================== --- stable/10/sys/dev/ixgbe/if_ix.c Wed Jul 20 18:16:58 2016 (r303106) +++ stable/10/sys/dev/ixgbe/if_ix.c Wed Jul 20 18:26:48 2016 (r303107) @@ -900,7 +900,8 @@ ixgbe_ioctl(struct ifnet * ifp, u_long c ifp->if_mtu = ifr->ifr_mtu; adapter->max_frame_size = ifp->if_mtu + IXGBE_MTU_HDR; - ixgbe_init_locked(adapter); + if (ifp->if_drv_flags & IFF_DRV_RUNNING) + ixgbe_init_locked(adapter); #ifdef PCI_IOV ixgbe_recalculate_max_frame(adapter); #endif Modified: stable/10/sys/dev/ixgbe/if_ixv.c ============================================================================== --- stable/10/sys/dev/ixgbe/if_ixv.c Wed Jul 20 18:16:58 2016 (r303106) +++ stable/10/sys/dev/ixgbe/if_ixv.c Wed Jul 20 18:26:48 2016 (r303107) @@ -587,7 +587,8 @@ ixv_ioctl(struct ifnet * ifp, u_long com ifp->if_mtu = ifr->ifr_mtu; adapter->max_frame_size = ifp->if_mtu + IXGBE_MTU_HDR; - ixv_init_locked(adapter); + if (ifp->if_drv_flags & IFF_DRV_RUNNING) + ixv_init_locked(adapter); IXGBE_CORE_UNLOCK(adapter); } break; Modified: stable/10/sys/dev/ixl/if_ixl.c ============================================================================== --- stable/10/sys/dev/ixl/if_ixl.c Wed Jul 20 18:16:58 2016 (r303106) +++ stable/10/sys/dev/ixl/if_ixl.c Wed Jul 20 18:26:48 2016 (r303107) @@ -1024,7 +1024,8 @@ ixl_ioctl(struct ifnet * ifp, u_long com vsi->max_frame_size = ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN + ETHER_VLAN_ENCAP_LEN; - ixl_init_locked(pf); + if (ifp->if_drv_flags & IFF_DRV_RUNNING) + ixl_init_locked(pf); IXL_PF_UNLOCK(pf); } break; Modified: stable/10/sys/dev/ixl/if_ixlv.c ============================================================================== --- stable/10/sys/dev/ixl/if_ixlv.c Wed Jul 20 18:16:58 2016 (r303106) +++ stable/10/sys/dev/ixl/if_ixlv.c Wed Jul 20 18:26:48 2016 (r303107) @@ -675,7 +675,8 @@ ixlv_ioctl(struct ifnet *ifp, u_long com vsi->max_frame_size = ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN + ETHER_VLAN_ENCAP_LEN; - ixlv_init_locked(sc); + if (ifp->if_drv_flags & IFF_DRV_RUNNING) + ixlv_init_locked(sc); } mtx_unlock(&sc->mtx); break; From owner-svn-src-stable-10@freebsd.org Wed Jul 20 22:28:27 2016 Return-Path: Delivered-To: svn-src-stable-10@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 E9B1BBA00C3; Wed, 20 Jul 2016 22:28:27 +0000 (UTC) (envelope-from sbruno@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 B30D819B6; Wed, 20 Jul 2016 22:28:27 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6KMSQub035314; Wed, 20 Jul 2016 22:28:26 GMT (envelope-from sbruno@FreeBSD.org) Received: (from sbruno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6KMSQSW035313; Wed, 20 Jul 2016 22:28:26 GMT (envelope-from sbruno@FreeBSD.org) Message-Id: <201607202228.u6KMSQSW035313@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sbruno set sender to sbruno@FreeBSD.org using -f From: Sean Bruno Date: Wed, 20 Jul 2016 22:28:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303116 - stable/10/sys/dev/e1000 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jul 2016 22:28:28 -0000 Author: sbruno Date: Wed Jul 20 22:28:26 2016 New Revision: 303116 URL: https://svnweb.freebsd.org/changeset/base/303116 Log: Fix em(4) build after r303107 Reported by: Jason Wolf Modified: stable/10/sys/dev/e1000/if_em.c Modified: stable/10/sys/dev/e1000/if_em.c ============================================================================== --- stable/10/sys/dev/e1000/if_em.c Wed Jul 20 22:05:44 2016 (r303115) +++ stable/10/sys/dev/e1000/if_em.c Wed Jul 20 22:28:26 2016 (r303116) @@ -1220,7 +1220,7 @@ em_ioctl(struct ifnet *ifp, u_long comma ifp->if_mtu = ifr->ifr_mtu; adapter->hw.mac.max_frame_size = ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN; - if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) + if (ifp->if_drv_flags & IFF_DRV_RUNNING) em_init_locked(adapter); EM_CORE_UNLOCK(adapter); break; From owner-svn-src-stable-10@freebsd.org Wed Jul 20 22:32:20 2016 Return-Path: Delivered-To: svn-src-stable-10@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 C6B91BA02D1; Wed, 20 Jul 2016 22:32:20 +0000 (UTC) (envelope-from sbruno@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 994AE1EFB; Wed, 20 Jul 2016 22:32:20 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6KMWJKa038844; Wed, 20 Jul 2016 22:32:19 GMT (envelope-from sbruno@FreeBSD.org) Received: (from sbruno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6KMWJc1038843; Wed, 20 Jul 2016 22:32:19 GMT (envelope-from sbruno@FreeBSD.org) Message-Id: <201607202232.u6KMWJc1038843@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sbruno set sender to sbruno@FreeBSD.org using -f From: Sean Bruno Date: Wed, 20 Jul 2016 22:32:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303117 - stable/10/sys/dev/e1000 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jul 2016 22:32:20 -0000 Author: sbruno Date: Wed Jul 20 22:32:19 2016 New Revision: 303117 URL: https://svnweb.freebsd.org/changeset/base/303117 Log: Fix lem(4) build after r303107 Submitted by: Jason Wolfe Modified: stable/10/sys/dev/e1000/if_lem.c Modified: stable/10/sys/dev/e1000/if_lem.c ============================================================================== --- stable/10/sys/dev/e1000/if_lem.c Wed Jul 20 22:28:26 2016 (r303116) +++ stable/10/sys/dev/e1000/if_lem.c Wed Jul 20 22:32:19 2016 (r303117) @@ -1047,7 +1047,7 @@ lem_ioctl(struct ifnet *ifp, u_long comm ifp->if_mtu = ifr->ifr_mtu; adapter->max_frame_size = ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN; - if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING)) + if (ifp->if_drv_flags & IFF_DRV_RUNNING) lem_init_locked(adapter); EM_CORE_UNLOCK(adapter); break; From owner-svn-src-stable-10@freebsd.org Thu Jul 21 00:52:54 2016 Return-Path: Delivered-To: svn-src-stable-10@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 98B68B83B4F; Thu, 21 Jul 2016 00:52:54 +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 6297F1A58; Thu, 21 Jul 2016 00:52:54 +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 u6L0qrjI090240; Thu, 21 Jul 2016 00:52:53 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6L0qrot090239; Thu, 21 Jul 2016 00:52:53 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <201607210052.u6L0qrot090239@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Thu, 21 Jul 2016 00:52:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303121 - stable/10/release X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jul 2016 00:52:54 -0000 Author: gjb Date: Thu Jul 21 00:52:53 2016 New Revision: 303121 URL: https://svnweb.freebsd.org/changeset/base/303121 Log: MFC r303003: Make sure we clean up the rdoc and reldoc directories if NODOC is not set. Sponsored by: The FreeBSD Foundation Modified: stable/10/release/Makefile Directory Properties: stable/10/ (props changed) Modified: stable/10/release/Makefile ============================================================================== --- stable/10/release/Makefile Wed Jul 20 22:51:33 2016 (r303120) +++ stable/10/release/Makefile Thu Jul 21 00:52:53 2016 (r303121) @@ -137,6 +137,9 @@ CLEANFILES+= ${I}.xz CLEANFILES+= pkg-stage .endif CLEANDIRS= dist ftp disc1 bootonly dvd +.if !defined(NODOC) +CLEANDIRS+= reldoc rdoc +.endif beforeclean: chflags -R noschg . .include From owner-svn-src-stable-10@freebsd.org Thu Jul 21 11:41:28 2016 Return-Path: Delivered-To: svn-src-stable-10@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 EFF96BA0D3C; Thu, 21 Jul 2016 11:41:28 +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 A2DF21987; Thu, 21 Jul 2016 11:41:28 +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 u6LBfRFE027715; Thu, 21 Jul 2016 11:41:27 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6LBfRtL027714; Thu, 21 Jul 2016 11:41:27 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201607211141.u6LBfRtL027714@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 21 Jul 2016 11:41:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303137 - stable/10/sys/dev/vmware/vmxnet3 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jul 2016 11:41:29 -0000 Author: mav Date: Thu Jul 21 11:41:27 2016 New Revision: 303137 URL: https://svnweb.freebsd.org/changeset/base/303137 Log: MFC r303000: Update if_hwassist when interface options are changed. In particular for me this fixes checksum problem when if_bridge attached to the interface requests TXCSUM to be disabled, but effectively ignored. Modified: stable/10/sys/dev/vmware/vmxnet3/if_vmx.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/vmware/vmxnet3/if_vmx.c ============================================================================== --- stable/10/sys/dev/vmware/vmxnet3/if_vmx.c Thu Jul 21 11:39:43 2016 (r303136) +++ stable/10/sys/dev/vmware/vmxnet3/if_vmx.c Thu Jul 21 11:41:27 2016 (r303137) @@ -128,6 +128,7 @@ static int vmxnet3_alloc_queue_data(stru static void vmxnet3_free_queue_data(struct vmxnet3_softc *); static int vmxnet3_alloc_mcast_table(struct vmxnet3_softc *); static void vmxnet3_init_shared_data(struct vmxnet3_softc *); +static void vmxnet3_init_hwassist(struct vmxnet3_softc *); static void vmxnet3_reinit_interface(struct vmxnet3_softc *); static void vmxnet3_reinit_rss_shared_data(struct vmxnet3_softc *); static void vmxnet3_reinit_shared_data(struct vmxnet3_softc *); @@ -1584,6 +1585,24 @@ vmxnet3_init_shared_data(struct vmxnet3_ } static void +vmxnet3_init_hwassist(struct vmxnet3_softc *sc) +{ + struct ifnet *ifp = sc->vmx_ifp; + uint64_t hwassist; + + hwassist = 0; + if (ifp->if_capenable & IFCAP_TXCSUM) + hwassist |= VMXNET3_CSUM_OFFLOAD; + if (ifp->if_capenable & IFCAP_TXCSUM_IPV6) + hwassist |= VMXNET3_CSUM_OFFLOAD_IPV6; + if (ifp->if_capenable & IFCAP_TSO4) + hwassist |= CSUM_IP_TSO; + if (ifp->if_capenable & IFCAP_TSO6) + hwassist |= CSUM_IP6_TSO; + ifp->if_hwassist = hwassist; +} + +static void vmxnet3_reinit_interface(struct vmxnet3_softc *sc) { struct ifnet *ifp; @@ -1594,15 +1613,7 @@ vmxnet3_reinit_interface(struct vmxnet3_ bcopy(IF_LLADDR(sc->vmx_ifp), sc->vmx_lladdr, ETHER_ADDR_LEN); vmxnet3_set_lladdr(sc); - ifp->if_hwassist = 0; - if (ifp->if_capenable & IFCAP_TXCSUM) - ifp->if_hwassist |= VMXNET3_CSUM_OFFLOAD; - if (ifp->if_capenable & IFCAP_TXCSUM_IPV6) - ifp->if_hwassist |= VMXNET3_CSUM_OFFLOAD_IPV6; - if (ifp->if_capenable & IFCAP_TSO4) - ifp->if_hwassist |= CSUM_IP_TSO; - if (ifp->if_capenable & IFCAP_TSO6) - ifp->if_hwassist |= CSUM_IP6_TSO; + vmxnet3_init_hwassist(sc); } static void @@ -3284,6 +3295,8 @@ vmxnet3_ioctl(struct ifnet *ifp, u_long if (reinit && (ifp->if_drv_flags & IFF_DRV_RUNNING)) { ifp->if_drv_flags &= ~IFF_DRV_RUNNING; vmxnet3_init_locked(sc); + } else { + vmxnet3_init_hwassist(sc); } VMXNET3_CORE_UNLOCK(sc); From owner-svn-src-stable-10@freebsd.org Thu Jul 21 11:58:48 2016 Return-Path: Delivered-To: svn-src-stable-10@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 DCB00BA0FDD; Thu, 21 Jul 2016 11:58: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 AF3311314; Thu, 21 Jul 2016 11:58: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 u6LBwlta034532; Thu, 21 Jul 2016 11:58:47 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6LBwlsr034531; Thu, 21 Jul 2016 11:58:47 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201607211158.u6LBwlsr034531@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 21 Jul 2016 11:58:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303139 - stable/10/usr.sbin/bhyve X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jul 2016 11:58:49 -0000 Author: mav Date: Thu Jul 21 11:58:47 2016 New Revision: 303139 URL: https://svnweb.freebsd.org/changeset/base/303139 Log: MFC r302957: Fix NCQ TRIM emulation. When this code was written, there was no guests using it to test. Modified: stable/10/usr.sbin/bhyve/pci_ahci.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- stable/10/usr.sbin/bhyve/pci_ahci.c Thu Jul 21 11:57:41 2016 (r303138) +++ stable/10/usr.sbin/bhyve/pci_ahci.c Thu Jul 21 11:58:47 2016 (r303139) @@ -788,7 +788,15 @@ next: done += 8; if (elen == 0) { if (done >= len) { - ahci_write_fis_d2h(p, slot, cfis, ATA_S_READY | ATA_S_DSC); + if (ncq) { + if (first) + ahci_write_fis_d2h_ncq(p, slot); + ahci_write_fis_sdb(p, slot, cfis, + ATA_S_READY | ATA_S_DSC); + } else { + ahci_write_fis_d2h(p, slot, cfis, + ATA_S_READY | ATA_S_DSC); + } p->pending &= ~(1 << slot); ahci_check_stopped(p); if (!first) @@ -1672,7 +1680,7 @@ ahci_handle_cmd(struct ahci_port *p, int case ATA_SEND_FPDMA_QUEUED: if ((cfis[13] & 0x1f) == ATA_SFPDMA_DSM && cfis[17] == 0 && cfis[16] == ATA_DSM_TRIM && - cfis[11] == 0 && cfis[13] == 1) { + cfis[11] == 0 && cfis[3] == 1) { ahci_handle_dsm_trim(p, slot, cfis, 0); break; } From owner-svn-src-stable-10@freebsd.org Thu Jul 21 23:49:28 2016 Return-Path: Delivered-To: svn-src-stable-10@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 A3B8DB9FC26; Thu, 21 Jul 2016 23:49:28 +0000 (UTC) (envelope-from sobomax@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 35502167B; Thu, 21 Jul 2016 23:49:28 +0000 (UTC) (envelope-from sobomax@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6LNnRZI099323; Thu, 21 Jul 2016 23:49:27 GMT (envelope-from sobomax@FreeBSD.org) Received: (from sobomax@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6LNnR2J099317; Thu, 21 Jul 2016 23:49:27 GMT (envelope-from sobomax@FreeBSD.org) Message-Id: <201607212349.u6LNnR2J099317@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sobomax set sender to sobomax@FreeBSD.org using -f From: Maxim Sobolev Date: Thu, 21 Jul 2016 23:49:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303167 - in stable/10/sys: conf geom/uzip modules/geom/geom_uzip X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jul 2016 23:49:28 -0000 Author: sobomax Date: Thu Jul 21 23:49:26 2016 New Revision: 303167 URL: https://svnweb.freebsd.org/changeset/base/303167 Log: MFC: merge in all new features and improvements into geom_uzip(8) from current, which includes: o LZMA compression; o block de-duplication; o performance improvements; o pop out worker kthread to do extraction. This includes the following revisions: r295943,r295952,r298502,r298619,r299195,r302284 Suggested by: emaste Added: stable/10/sys/geom/uzip/g_uzip.h (contents, props changed) stable/10/sys/geom/uzip/g_uzip_cloop.h (contents, props changed) stable/10/sys/geom/uzip/g_uzip_dapi.h (contents, props changed) stable/10/sys/geom/uzip/g_uzip_lzma.c (contents, props changed) stable/10/sys/geom/uzip/g_uzip_lzma.h (contents, props changed) stable/10/sys/geom/uzip/g_uzip_softc.h (contents, props changed) stable/10/sys/geom/uzip/g_uzip_wrkthr.c (contents, props changed) stable/10/sys/geom/uzip/g_uzip_wrkthr.h (contents, props changed) stable/10/sys/geom/uzip/g_uzip_zlib.c (contents, props changed) stable/10/sys/geom/uzip/g_uzip_zlib.h (contents, props changed) Modified: stable/10/sys/conf/files stable/10/sys/geom/uzip/g_uzip.c stable/10/sys/modules/geom/geom_uzip/Makefile Modified: stable/10/sys/conf/files ============================================================================== --- stable/10/sys/conf/files Thu Jul 21 23:29:16 2016 (r303166) +++ stable/10/sys/conf/files Thu Jul 21 23:49:26 2016 (r303167) @@ -2912,21 +2912,24 @@ geom/shsec/g_shsec.c optional geom_shse geom/stripe/g_stripe.c optional geom_stripe geom/uncompress/g_uncompress.c optional geom_uncompress contrib/xz-embedded/freebsd/xz_malloc.c \ - optional xz_embedded | geom_uncompress \ + optional xz_embedded | geom_uncompress | geom_uzip \ compile-with "${NORMAL_C} -I$S/contrib/xz-embedded/freebsd/ -I$S/contrib/xz-embedded/linux/lib/xz/ -I$S/contrib/xz-embedded/linux/include/linux/" contrib/xz-embedded/linux/lib/xz/xz_crc32.c \ - optional xz_embedded | geom_uncompress \ + optional xz_embedded | geom_uncompress | geom_uzip \ compile-with "${NORMAL_C} -I$S/contrib/xz-embedded/freebsd/ -I$S/contrib/xz-embedded/linux/lib/xz/ -I$S/contrib/xz-embedded/linux/include/linux/" contrib/xz-embedded/linux/lib/xz/xz_dec_bcj.c \ - optional xz_embedded | geom_uncompress \ + optional xz_embedded | geom_uncompress | geom_uzip \ compile-with "${NORMAL_C} -I$S/contrib/xz-embedded/freebsd/ -I$S/contrib/xz-embedded/linux/lib/xz/ -I$S/contrib/xz-embedded/linux/include/linux/" contrib/xz-embedded/linux/lib/xz/xz_dec_lzma2.c \ - optional xz_embedded | geom_uncompress \ + optional xz_embedded | geom_uncompress | geom_uzip \ compile-with "${NORMAL_C} -I$S/contrib/xz-embedded/freebsd/ -I$S/contrib/xz-embedded/linux/lib/xz/ -I$S/contrib/xz-embedded/linux/include/linux/" contrib/xz-embedded/linux/lib/xz/xz_dec_stream.c \ - optional xz_embedded | geom_uncompress \ + optional xz_embedded | geom_uncompress | geom_uzip \ compile-with "${NORMAL_C} -I$S/contrib/xz-embedded/freebsd/ -I$S/contrib/xz-embedded/linux/lib/xz/ -I$S/contrib/xz-embedded/linux/include/linux/" geom/uzip/g_uzip.c optional geom_uzip +geom/uzip/g_uzip_lzma.c optional geom_uzip +geom/uzip/g_uzip_wrkthr.c optional geom_uzip +geom/uzip/g_uzip_zlib.c optional geom_uzip geom/vinum/geom_vinum.c optional geom_vinum geom/vinum/geom_vinum_create.c optional geom_vinum geom/vinum/geom_vinum_drive.c optional geom_vinum Modified: stable/10/sys/geom/uzip/g_uzip.c ============================================================================== --- stable/10/sys/geom/uzip/g_uzip.c Thu Jul 21 23:29:16 2016 (r303166) +++ stable/10/sys/geom/uzip/g_uzip.c Thu Jul 21 23:49:26 2016 (r303167) @@ -1,6 +1,7 @@ /*- * Copyright (c) 2004 Max Khon * Copyright (c) 2014 Juniper Networks, Inc. + * Copyright (c) 2006-2016 Maxim Sobolev * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -38,91 +39,129 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include -#include -FEATURE(geom_uzip, "GEOM uzip read-only compressed disks support"); +#include +#include +#include +#include +#include +#include +#include + +#include "opt_geom.h" + +MALLOC_DEFINE(M_GEOM_UZIP, "geom_uzip", "GEOM UZIP data structures"); + +FEATURE(geom_uzip, "GEOM read-only compressed disks support"); + +struct g_uzip_blk { + uint64_t offset; + uint32_t blen; + unsigned char last:1; + unsigned char padded:1; +#define BLEN_UNDEF UINT32_MAX +}; + +#ifndef ABS +#define ABS(a) ((a) < 0 ? -(a) : (a)) +#endif + +#define BLK_IN_RANGE(mcn, bcn, ilen) \ + (((bcn) != BLEN_UNDEF) && ( \ + ((ilen) >= 0 && (mcn >= bcn) && (mcn <= ((intmax_t)(bcn) + (ilen)))) || \ + ((ilen) < 0 && (mcn <= bcn) && (mcn >= ((intmax_t)(bcn) + (ilen)))) \ + )) -#undef GEOM_UZIP_DEBUG #ifdef GEOM_UZIP_DEBUG -#define DPRINTF(a) printf a +# define GEOM_UZIP_DBG_DEFAULT 3 #else -#define DPRINTF(a) +# define GEOM_UZIP_DBG_DEFAULT 0 #endif -static MALLOC_DEFINE(M_GEOM_UZIP, "geom_uzip", "GEOM UZIP data structures"); +#define GUZ_DBG_ERR 1 +#define GUZ_DBG_INFO 2 +#define GUZ_DBG_IO 3 +#define GUZ_DBG_TOC 4 + +#define GUZ_DEV_SUFX ".uzip" +#define GUZ_DEV_NAME(p) (p GUZ_DEV_SUFX) + +static char g_uzip_attach_to[MAXPATHLEN] = {"*"}; +static char g_uzip_noattach_to[MAXPATHLEN] = {GUZ_DEV_NAME("*")}; +TUNABLE_STR("kern.geom.uzip.attach_to", g_uzip_attach_to, + sizeof(g_uzip_attach_to)); +TUNABLE_STR("kern.geom.uzip.noattach_to", g_uzip_noattach_to, + sizeof(g_uzip_noattach_to)); + +SYSCTL_DECL(_kern_geom); +SYSCTL_NODE(_kern_geom, OID_AUTO, uzip, CTLFLAG_RW, 0, "GEOM_UZIP stuff"); +static u_int g_uzip_debug = GEOM_UZIP_DBG_DEFAULT; +SYSCTL_UINT(_kern_geom_uzip, OID_AUTO, debug, CTLFLAG_RWTUN, &g_uzip_debug, 0, + "Debug level (0-4)"); +static u_int g_uzip_debug_block = BLEN_UNDEF; +SYSCTL_UINT(_kern_geom_uzip, OID_AUTO, debug_block, CTLFLAG_RWTUN, + &g_uzip_debug_block, 0, "Debug operations around specific cluster#"); + +#define DPRINTF(lvl, a) \ + if ((lvl) <= g_uzip_debug) { \ + printf a; \ + } +#define DPRINTF_BLK(lvl, cn, a) \ + if ((lvl) <= g_uzip_debug || \ + BLK_IN_RANGE(cn, g_uzip_debug_block, 8) || \ + BLK_IN_RANGE(cn, g_uzip_debug_block, -8)) { \ + printf a; \ + } +#define DPRINTF_BRNG(lvl, bcn, ecn, a) \ + KASSERT(bcn < ecn, ("DPRINTF_BRNG: invalid range (%ju, %ju)", \ + (uintmax_t)bcn, (uintmax_t)ecn)); \ + if (((lvl) <= g_uzip_debug) || \ + BLK_IN_RANGE(g_uzip_debug_block, bcn, \ + (intmax_t)ecn - (intmax_t)bcn)) { \ + printf a; \ + } #define UZIP_CLASS_NAME "UZIP" /* * Maximum allowed valid block size (to prevent foot-shooting) */ -#define MAX_BLKSZ (MAXPHYS - MAXPHYS / 1000 - 12) - -/* - * Integer values (block size, number of blocks, offsets) - * are stored in big-endian (network) order on disk and struct cloop_header - * and in native order in struct g_uzip_softc - */ +#define MAX_BLKSZ (MAXPHYS) -#define CLOOP_MAGIC_LEN 128 static char CLOOP_MAGIC_START[] = "#!/bin/sh\n"; -struct cloop_header { - char magic[CLOOP_MAGIC_LEN]; /* cloop magic */ - uint32_t blksz; /* block size */ - uint32_t nblocks; /* number of blocks */ -}; - -struct g_uzip_softc { - uint32_t blksz; /* block size */ - uint32_t nblocks; /* number of blocks */ - uint64_t *offsets; - - struct mtx last_mtx; - uint32_t last_blk; /* last blk no */ - char *last_buf; /* last blk data */ - int req_total; /* total requests */ - int req_cached; /* cached requests */ -}; - -static void g_uzip_done(struct bio *bp); +static void g_uzip_read_done(struct bio *bp); +static void g_uzip_do(struct g_uzip_softc *, struct bio *bp); static void g_uzip_softc_free(struct g_uzip_softc *sc, struct g_geom *gp) { if (gp != NULL) { - DPRINTF(("%s: %d requests, %d cached\n", + DPRINTF(GUZ_DBG_INFO, ("%s: %d requests, %d cached\n", gp->name, sc->req_total, sc->req_cached)); } - if (sc->offsets != NULL) { - free(sc->offsets, M_GEOM_UZIP); - sc->offsets = NULL; - } + + mtx_lock(&sc->queue_mtx); + sc->wrkthr_flags |= GUZ_SHUTDOWN; + wakeup(sc); + while (!(sc->wrkthr_flags & GUZ_EXITING)) { + msleep(sc->procp, &sc->queue_mtx, PRIBIO, "guzfree", + hz / 10); + } + mtx_unlock(&sc->queue_mtx); + + sc->dcp->free(sc->dcp); + free(sc->toc, M_GEOM_UZIP); + mtx_destroy(&sc->queue_mtx); mtx_destroy(&sc->last_mtx); free(sc->last_buf, M_GEOM_UZIP); free(sc, M_GEOM_UZIP); } -static void * -z_alloc(void *nil, u_int type, u_int size) -{ - void *ptr; - - ptr = malloc(type * size, M_GEOM_UZIP, M_NOWAIT); - - return (ptr); -} - -static void -z_free(void *nil, void *ptr) -{ - - free(ptr, M_GEOM_UZIP); -} - static int g_uzip_cached(struct g_geom *gp, struct bio *bp) { @@ -144,8 +183,9 @@ g_uzip_cached(struct g_geom *gp, struct sc->req_cached++; mtx_unlock(&sc->last_mtx); - DPRINTF(("%s/%s: %p: offset=%jd: got %jd bytes from cache\n", - __func__, gp->name, bp, (intmax_t)ofs, (intmax_t)usz)); + DPRINTF(GUZ_DBG_IO, ("%s/%s: %p: offset=%jd: got %jd bytes " + "from cache\n", __func__, gp->name, bp, (intmax_t)ofs, + (intmax_t)usz)); bp->bio_completed += usz; bp->bio_resid -= usz; @@ -160,6 +200,19 @@ g_uzip_cached(struct g_geom *gp, struct return (0); } +#define BLK_ENDS(sc, bi) ((sc)->toc[(bi)].offset + \ + (sc)->toc[(bi)].blen) + +#define BLK_IS_CONT(sc, bi) (BLK_ENDS((sc), (bi) - 1) == \ + (sc)->toc[(bi)].offset) +#define BLK_IS_NIL(sc, bi) ((sc)->toc[(bi)].blen == 0) + +#define TOFF_2_BOFF(sc, pp, bi) ((sc)->toc[(bi)].offset - \ + (sc)->toc[(bi)].offset % (pp)->sectorsize) +#define TLEN_2_BLEN(sc, pp, bp, ei) ((BLK_ENDS((sc), (ei)) - \ + (bp)->bio_offset + (pp)->sectorsize - 1) / \ + (pp)->sectorsize * (pp)->sectorsize) + static int g_uzip_request(struct g_geom *gp, struct bio *bp) { @@ -167,21 +220,14 @@ g_uzip_request(struct g_geom *gp, struct struct bio *bp2; struct g_consumer *cp; struct g_provider *pp; - off_t ofs; - size_t start_blk, end_blk; + off_t ofs, start_blk_ofs; + size_t i, start_blk, end_blk, zsize; if (g_uzip_cached(gp, bp) != 0) return (1); sc = gp->softc; - bp2 = g_clone_bio(bp); - if (bp2 == NULL) { - g_io_deliver(bp, ENOMEM); - return (1); - } - bp2->bio_done = g_uzip_done; - cp = LIST_FIRST(&gp->consumer); pp = cp->provider; @@ -191,23 +237,68 @@ g_uzip_request(struct g_geom *gp, struct end_blk = (ofs + bp->bio_resid + sc->blksz - 1) / sc->blksz; KASSERT(end_blk <= sc->nblocks, ("end_blk out of range")); - DPRINTF(("%s/%s: %p: start=%u (%jd), end=%u (%jd)\n", - __func__, gp->name, bp, - (u_int)start_blk, (intmax_t)sc->offsets[start_blk], - (u_int)end_blk, (intmax_t)sc->offsets[end_blk])); + for (; BLK_IS_NIL(sc, start_blk) && start_blk < end_blk; start_blk++) { + /* Fill in any leading Nil blocks */ + start_blk_ofs = ofs % sc->blksz; + zsize = MIN(sc->blksz - start_blk_ofs, bp->bio_resid); + DPRINTF_BLK(GUZ_DBG_IO, start_blk, ("%s/%s: %p/%ju: " + "filling %ju zero bytes\n", __func__, gp->name, gp, + (uintmax_t)bp->bio_completed, (uintmax_t)zsize)); + bzero(bp->bio_data + bp->bio_completed, zsize); + bp->bio_completed += zsize; + bp->bio_resid -= zsize; + ofs += zsize; + } + + if (start_blk == end_blk) { + KASSERT(bp->bio_resid == 0, ("bp->bio_resid is invalid")); + /* + * No non-Nil data is left, complete request immediately. + */ + DPRINTF(GUZ_DBG_IO, ("%s/%s: %p: all done returning %ju " + "bytes\n", __func__, gp->name, gp, + (uintmax_t)bp->bio_completed)); + g_io_deliver(bp, 0); + return (1); + } - bp2->bio_offset = sc->offsets[start_blk] - - sc->offsets[start_blk] % pp->sectorsize; - while (1) { - bp2->bio_length = sc->offsets[end_blk] - bp2->bio_offset; - bp2->bio_length = (bp2->bio_length + pp->sectorsize - 1) / - pp->sectorsize * pp->sectorsize; - if (bp2->bio_length <= MAXPHYS) + for (i = start_blk + 1; i < end_blk; i++) { + /* Trim discontinuous areas if any */ + if (!BLK_IS_CONT(sc, i)) { + end_blk = i; break; + } + } + + DPRINTF_BRNG(GUZ_DBG_IO, start_blk, end_blk, ("%s/%s: %p: " + "start=%u (%ju[%jd]), end=%u (%ju)\n", __func__, gp->name, bp, + (u_int)start_blk, (uintmax_t)sc->toc[start_blk].offset, + (intmax_t)sc->toc[start_blk].blen, + (u_int)end_blk, (uintmax_t)BLK_ENDS(sc, end_blk - 1))); + + bp2 = g_clone_bio(bp); + if (bp2 == NULL) { + g_io_deliver(bp, ENOMEM); + return (1); + } + bp2->bio_done = g_uzip_read_done; + bp2->bio_offset = TOFF_2_BOFF(sc, pp, start_blk); + while (1) { + bp2->bio_length = TLEN_2_BLEN(sc, pp, bp2, end_blk - 1); + if (bp2->bio_length <= MAXPHYS) { + break; + } + if (end_blk == (start_blk + 1)) { + break; + } end_blk--; } + DPRINTF(GUZ_DBG_IO, ("%s/%s: bp2->bio_length = %jd, " + "bp2->bio_offset = %jd\n", __func__, gp->name, + (intmax_t)bp2->bio_length, (intmax_t)bp2->bio_offset)); + bp2->bio_data = malloc(bp2->bio_length, M_GEOM_UZIP, M_NOWAIT); if (bp2->bio_data == NULL) { g_destroy_bio(bp2); @@ -215,8 +306,8 @@ g_uzip_request(struct g_geom *gp, struct return (1); } - DPRINTF(("%s/%s: %p: reading %jd bytes from offset %jd\n", - __func__, gp->name, bp, + DPRINTF_BRNG(GUZ_DBG_IO, start_blk, end_blk, ("%s/%s: %p: " + "reading %jd bytes from offset %jd\n", __func__, gp->name, bp, (intmax_t)bp2->bio_length, (intmax_t)bp2->bio_offset)); g_io_request(bp2, cp); @@ -224,21 +315,45 @@ g_uzip_request(struct g_geom *gp, struct } static void -g_uzip_done(struct bio *bp) +g_uzip_read_done(struct bio *bp) +{ + struct bio *bp2; + struct g_geom *gp; + struct g_uzip_softc *sc; + + bp2 = bp->bio_parent; + gp = bp2->bio_to->geom; + sc = gp->softc; + + mtx_lock(&sc->queue_mtx); + bioq_disksort(&sc->bio_queue, bp); + mtx_unlock(&sc->queue_mtx); + wakeup(sc); +} + +static int +g_uzip_memvcmp(const void *memory, unsigned char val, size_t size) +{ + const u_char *mm; + + mm = (const u_char *)memory; + return (*mm == val) && memcmp(mm, mm + 1, size - 1) == 0; +} + +static void +g_uzip_do(struct g_uzip_softc *sc, struct bio *bp) { - z_stream zs; struct bio *bp2; struct g_provider *pp; struct g_consumer *cp; struct g_geom *gp; - struct g_uzip_softc *sc; char *data, *data2; off_t ofs; - size_t blk, blkofs, len, ulen; + size_t blk, blkofs, len, ulen, firstblk; + int err; bp2 = bp->bio_parent; gp = bp2->bio_to->geom; - sc = gp->softc; cp = LIST_FIRST(&gp->consumer); pp = cp->provider; @@ -253,46 +368,62 @@ g_uzip_done(struct bio *bp) goto done; } - zs.zalloc = z_alloc; - zs.zfree = z_free; - if (inflateInit(&zs) != Z_OK) { - bp2->bio_error = EILSEQ; - goto done; - } - ofs = bp2->bio_offset + bp2->bio_completed; - blk = ofs / sc->blksz; + firstblk = blk = ofs / sc->blksz; blkofs = ofs % sc->blksz; - data = bp->bio_data + sc->offsets[blk] % pp->sectorsize; + data = bp->bio_data + sc->toc[blk].offset % pp->sectorsize; data2 = bp2->bio_data + bp2->bio_completed; while (bp->bio_completed && bp2->bio_resid) { + if (blk > firstblk && !BLK_IS_CONT(sc, blk)) { + DPRINTF_BLK(GUZ_DBG_IO, blk, ("%s/%s: %p: backref'ed " + "cluster #%u requested, looping around\n", + __func__, gp->name, bp2, (u_int)blk)); + goto done; + } ulen = MIN(sc->blksz - blkofs, bp2->bio_resid); - len = sc->offsets[blk + 1] - sc->offsets[blk]; - DPRINTF(("%s/%s: %p/%ju: data2=%p, ulen=%u, data=%p, len=%u\n", - __func__, gp->name, gp, bp->bio_completed, - data2, (u_int)ulen, data, (u_int)len)); + len = sc->toc[blk].blen; + DPRINTF(GUZ_DBG_IO, ("%s/%s: %p/%ju: data2=%p, ulen=%u, " + "data=%p, len=%u\n", __func__, gp->name, gp, + bp->bio_completed, data2, (u_int)ulen, data, (u_int)len)); if (len == 0) { /* All zero block: no cache update */ +zero_block: bzero(data2, ulen); } else if (len <= bp->bio_completed) { - zs.next_in = data; - zs.avail_in = len; - zs.next_out = sc->last_buf; - zs.avail_out = sc->blksz; mtx_lock(&sc->last_mtx); - if (inflate(&zs, Z_FINISH) != Z_STREAM_END) { + err = sc->dcp->decompress(sc->dcp, gp->name, data, + len, sc->last_buf); + if (err != 0 && sc->toc[blk].last != 0) { + /* + * Last block decompression has failed, check + * if it's just zero padding. + */ + if (g_uzip_memvcmp(data, '\0', len) == 0) { + sc->toc[blk].blen = 0; + sc->last_blk = -1; + mtx_unlock(&sc->last_mtx); + len = 0; + goto zero_block; + } + } + if (err != 0) { sc->last_blk = -1; mtx_unlock(&sc->last_mtx); - inflateEnd(&zs); bp2->bio_error = EILSEQ; + DPRINTF(GUZ_DBG_ERR, ("%s/%s: decompress" + "(%p, %ju, %ju) failed\n", __func__, + gp->name, sc->dcp, (uintmax_t)blk, + (uintmax_t)len)); goto done; } sc->last_blk = blk; memcpy(data2, sc->last_buf + blkofs, ulen); mtx_unlock(&sc->last_mtx); - if (inflateReset(&zs) != Z_OK) { - inflateEnd(&zs); + err = sc->dcp->rewind(sc->dcp, gp->name); + if (err != 0) { bp2->bio_error = EILSEQ; + DPRINTF(GUZ_DBG_ERR, ("%s/%s: rewind(%p) " + "failed\n", __func__, gp->name, sc->dcp)); goto done; } data += len; @@ -307,9 +438,6 @@ g_uzip_done(struct bio *bp) blk++; } - if (inflateEnd(&zs) != Z_OK) - bp2->bio_error = EILSEQ; - done: /* Finish processing the request. */ free(bp->bio_data, M_GEOM_UZIP); @@ -330,9 +458,9 @@ g_uzip_start(struct bio *bp) pp = bp->bio_to; gp = pp->geom; - DPRINTF(("%s/%s: %p: cmd=%d, offset=%jd, length=%jd, buffer=%p\n", - __func__, gp->name, bp, bp->bio_cmd, (intmax_t)bp->bio_offset, - (intmax_t)bp->bio_length, bp->bio_data)); + DPRINTF(GUZ_DBG_IO, ("%s/%s: %p: cmd=%d, offset=%jd, length=%jd, " + "buffer=%p\n", __func__, gp->name, bp, bp->bio_cmd, + (intmax_t)bp->bio_offset, (intmax_t)bp->bio_length, bp->bio_data)); sc = gp->softc; sc->req_total++; @@ -383,6 +511,7 @@ g_uzip_spoiled(struct g_consumer *cp) { struct g_geom *gp; + G_VALID_CONSUMER(cp); gp = cp->geom; g_trace(G_T_TOPOLOGY, "%s(%p/%s)", __func__, cp, gp->name); g_topology_assert(); @@ -392,6 +521,114 @@ g_uzip_spoiled(struct g_consumer *cp) g_wither_geom(gp, ENXIO); } +static int +g_uzip_parse_toc(struct g_uzip_softc *sc, struct g_provider *pp, + struct g_geom *gp) +{ + uint32_t i, j, backref_to; + uint64_t max_offset, min_offset; + struct g_uzip_blk *last_blk; + + min_offset = sizeof(struct cloop_header) + + (sc->nblocks + 1) * sizeof(uint64_t); + max_offset = sc->toc[0].offset - 1; + last_blk = &sc->toc[0]; + for (i = 0; i < sc->nblocks; i++) { + /* First do some bounds checking */ + if ((sc->toc[i].offset < min_offset) || + (sc->toc[i].offset > pp->mediasize)) { + goto error_offset; + } + DPRINTF_BLK(GUZ_DBG_IO, i, ("%s: cluster #%u " + "offset=%ju max_offset=%ju\n", gp->name, + (u_int)i, (uintmax_t)sc->toc[i].offset, + (uintmax_t)max_offset)); + backref_to = BLEN_UNDEF; + if (sc->toc[i].offset < max_offset) { + /* + * For the backref'ed blocks search already parsed + * TOC entries for the matching offset and copy the + * size from matched entry. + */ + for (j = 0; j <= i; j++) { + if (sc->toc[j].offset == sc->toc[i].offset && + !BLK_IS_NIL(sc, j)) { + break; + } + if (j != i) { + continue; + } + DPRINTF(GUZ_DBG_ERR, ("%s: cannot match " + "backref'ed offset at cluster #%u\n", + gp->name, i)); + return (-1); + } + sc->toc[i].blen = sc->toc[j].blen; + backref_to = j; + } else { + last_blk = &sc->toc[i]; + /* + * For the "normal blocks" seek forward until we hit + * block whose offset is larger than ours and assume + * it's going to be the next one. + */ + for (j = i + 1; j < sc->nblocks; j++) { + if (sc->toc[j].offset > max_offset) { + break; + } + } + sc->toc[i].blen = sc->toc[j].offset - + sc->toc[i].offset; + if (BLK_ENDS(sc, i) > pp->mediasize) { + DPRINTF(GUZ_DBG_ERR, ("%s: cluster #%u " + "extends past media boundary (%ju > %ju)\n", + gp->name, (u_int)i, + (uintmax_t)BLK_ENDS(sc, i), + (intmax_t)pp->mediasize)); + return (-1); + } + KASSERT(max_offset <= sc->toc[i].offset, ( + "%s: max_offset is incorrect: %ju", + gp->name, (uintmax_t)max_offset)); + max_offset = BLK_ENDS(sc, i) - 1; + } + DPRINTF_BLK(GUZ_DBG_TOC, i, ("%s: cluster #%u, original %u " + "bytes, in %u bytes", gp->name, i, sc->blksz, + sc->toc[i].blen)); + if (backref_to != BLEN_UNDEF) { + DPRINTF_BLK(GUZ_DBG_TOC, i, (" (->#%u)", + (u_int)backref_to)); + } + DPRINTF_BLK(GUZ_DBG_TOC, i, ("\n")); + } + last_blk->last = 1; + /* Do a second pass to validate block lengths */ + for (i = 0; i < sc->nblocks; i++) { + if (sc->toc[i].blen > sc->dcp->max_blen) { + if (sc->toc[i].last == 0) { + DPRINTF(GUZ_DBG_ERR, ("%s: cluster #%u " + "length (%ju) exceeds " + "max_blen (%ju)\n", gp->name, i, + (uintmax_t)sc->toc[i].blen, + (uintmax_t)sc->dcp->max_blen)); + return (-1); + } + DPRINTF(GUZ_DBG_INFO, ("%s: cluster #%u extra " + "padding is detected, trimmed to %ju\n", + gp->name, i, (uintmax_t)sc->dcp->max_blen)); + sc->toc[i].blen = sc->dcp->max_blen; + sc->toc[i].padded = 1; + } + } + return (0); + +error_offset: + DPRINTF(GUZ_DBG_ERR, ("%s: cluster #%u: invalid offset %ju, " + "min_offset=%ju mediasize=%jd\n", gp->name, (u_int)i, + sc->toc[i].offset, min_offset, pp->mediasize)); + return (-1); +} + static struct g_geom * g_uzip_taste(struct g_class *mp, struct g_provider *pp, int flags) { @@ -403,6 +640,10 @@ g_uzip_taste(struct g_class *mp, struct struct g_geom *gp; struct g_provider *pp2; struct g_uzip_softc *sc; + enum { + G_UZIP = 1, + G_ULZMA + } type; g_trace(G_T_TOPOLOGY, "%s(%s,%s)", __func__, mp->name, pp->name); g_topology_assert(); @@ -411,21 +652,25 @@ g_uzip_taste(struct g_class *mp, struct if (pp->acw > 0) return (NULL); + if ((fnmatch(g_uzip_attach_to, pp->name, 0) != 0) || + (fnmatch(g_uzip_noattach_to, pp->name, 0) == 0)) { + DPRINTF(GUZ_DBG_INFO, ("%s(%s,%s), ignoring\n", __func__, + mp->name, pp->name)); + return (NULL); + } + buf = NULL; /* * Create geom instance. */ - gp = g_new_geomf(mp, "%s.uzip", pp->name); + gp = g_new_geomf(mp, GUZ_DEV_NAME("%s"), pp->name); cp = g_new_consumer(gp); error = g_attach(cp, pp); if (error == 0) error = g_access(cp, 1, 0, 0); if (error) { - g_detach(cp); - g_destroy_consumer(cp); - g_destroy_geom(gp); - return (NULL); + goto e1; } g_topology_unlock(); @@ -433,22 +678,47 @@ g_uzip_taste(struct g_class *mp, struct * Read cloop header, look for CLOOP magic, perform * other validity checks. */ - DPRINTF(("%s: media sectorsize %u, mediasize %jd\n", + DPRINTF(GUZ_DBG_INFO, ("%s: media sectorsize %u, mediasize %jd\n", gp->name, pp->sectorsize, (intmax_t)pp->mediasize)); buf = g_read_data(cp, 0, pp->sectorsize, NULL); if (buf == NULL) - goto err; + goto e2; header = (struct cloop_header *) buf; if (strncmp(header->magic, CLOOP_MAGIC_START, sizeof(CLOOP_MAGIC_START) - 1) != 0) { - DPRINTF(("%s: no CLOOP magic\n", gp->name)); - goto err; - } - if (header->magic[0x0b] != 'V' || header->magic[0x0c] < '2') { - DPRINTF(("%s: image version too old\n", gp->name)); - goto err; + DPRINTF(GUZ_DBG_ERR, ("%s: no CLOOP magic\n", gp->name)); + goto e3; } + switch (header->magic[CLOOP_OFS_COMPR]) { + case CLOOP_COMP_LZMA: + case CLOOP_COMP_LZMA_DDP: + type = G_ULZMA; + if (header->magic[CLOOP_OFS_VERSN] < CLOOP_MINVER_LZMA) { + DPRINTF(GUZ_DBG_ERR, ("%s: image version too old\n", + gp->name)); + goto e3; + } + DPRINTF(GUZ_DBG_INFO, ("%s: GEOM_UZIP_LZMA image found\n", + gp->name)); + break; + case CLOOP_COMP_LIBZ: + case CLOOP_COMP_LIBZ_DDP: + type = G_UZIP; + if (header->magic[CLOOP_OFS_VERSN] < CLOOP_MINVER_ZLIB) { + DPRINTF(GUZ_DBG_ERR, ("%s: image version too old\n", + gp->name)); + goto e3; + } + DPRINTF(GUZ_DBG_INFO, ("%s: GEOM_UZIP_ZLIB image found\n", + gp->name)); + break; + default: + DPRINTF(GUZ_DBG_ERR, ("%s: unsupported image type\n", + gp->name)); + goto e3; + } + /* * Initialize softc and read offsets. */ @@ -459,7 +729,7 @@ g_uzip_taste(struct g_class *mp, struct if (sc->blksz % 512 != 0) { printf("%s: block size (%u) should be multiple of 512.\n", gp->name, sc->blksz); - goto err; + goto e4; } if (sc->blksz > MAX_BLKSZ) { printf("%s: block size (%u) should not be larger than %d.\n", @@ -470,15 +740,17 @@ g_uzip_taste(struct g_class *mp, struct total_offsets * sizeof(uint64_t) > pp->mediasize) { printf("%s: media too small for %u blocks\n", gp->name, sc->nblocks); - goto err; + goto e4; } - sc->offsets = malloc( - total_offsets * sizeof(uint64_t), M_GEOM_UZIP, M_WAITOK); + sc->toc = malloc(total_offsets * sizeof(struct g_uzip_blk), + M_GEOM_UZIP, M_WAITOK | M_ZERO); offsets_read = MIN(total_offsets, (pp->sectorsize - sizeof(*header)) / sizeof(uint64_t)); - for (i = 0; i < offsets_read; i++) - sc->offsets[i] = be64toh(((uint64_t *) (header + 1))[i]); - DPRINTF(("%s: %u offsets in the first sector\n", + for (i = 0; i < offsets_read; i++) { + sc->toc[i].offset = be64toh(((uint64_t *) (header + 1))[i]); + sc->toc[i].blen = BLEN_UNDEF; + } + DPRINTF(GUZ_DBG_INFO, ("%s: %u offsets in the first sector\n", gp->name, offsets_read)); for (blk = 1; offsets_read < total_offsets; blk++) { uint32_t nread; @@ -487,25 +759,65 @@ g_uzip_taste(struct g_class *mp, struct buf = g_read_data( cp, blk * pp->sectorsize, pp->sectorsize, NULL); if (buf == NULL) - goto err; + goto e5; nread = MIN(total_offsets - offsets_read, pp->sectorsize / sizeof(uint64_t)); - DPRINTF(("%s: %u offsets read from sector %d\n", + DPRINTF(GUZ_DBG_TOC, ("%s: %u offsets read from sector %d\n", gp->name, nread, blk)); for (i = 0; i < nread; i++) { - sc->offsets[offsets_read + i] = + sc->toc[offsets_read + i].offset = be64toh(((uint64_t *) buf)[i]); + sc->toc[offsets_read + i].blen = BLEN_UNDEF; } offsets_read += nread; } free(buf, M_GEOM); - DPRINTF(("%s: done reading offsets\n", gp->name)); + buf = NULL; + offsets_read -= 1; + DPRINTF(GUZ_DBG_INFO, ("%s: done reading %u block offsets from %u " + "sectors\n", gp->name, offsets_read, blk)); + if (sc->nblocks != offsets_read) { + DPRINTF(GUZ_DBG_ERR, ("%s: read %s offsets than expected " + "blocks\n", gp->name, + sc->nblocks < offsets_read ? "more" : "less")); + goto e5; + } + + if (type == G_UZIP) { + sc->dcp = g_uzip_zlib_ctor(sc->blksz); + } else { + sc->dcp = g_uzip_lzma_ctor(sc->blksz); + } + if (sc->dcp == NULL) { + goto e5; + } + + /* + * "Fake" last+1 block, to make it easier for the TOC parser to + * iterate without making the last element a special case. + */ + sc->toc[sc->nblocks].offset = pp->mediasize; + /* Massage TOC (table of contents), make sure it is sound */ + if (g_uzip_parse_toc(sc, pp, gp) != 0) { + DPRINTF(GUZ_DBG_ERR, ("%s: TOC error\n", gp->name)); + goto e6; + } mtx_init(&sc->last_mtx, "geom_uzip cache", NULL, MTX_DEF); + mtx_init(&sc->queue_mtx, "geom_uzip wrkthread", NULL, MTX_DEF); + bioq_init(&sc->bio_queue); sc->last_blk = -1; sc->last_buf = malloc(sc->blksz, M_GEOM_UZIP, M_WAITOK); sc->req_total = 0; sc->req_cached = 0; + sc->uzip_do = &g_uzip_do; + + error = kproc_create(g_uzip_wrkthr, sc, &sc->procp, 0, 0, "%s", + gp->name); + if (error != 0) { + goto e7; + } + g_topology_lock(); pp2 = g_new_providerf(gp, "%s", gp->name); pp2->sectorsize = 512; @@ -515,22 +827,31 @@ g_uzip_taste(struct g_class *mp, struct g_error_provider(pp2, 0); g_access(cp, -1, 0, 0); - DPRINTF(("%s: taste ok (%d, %jd), (%d, %d), %x\n", - gp->name, - pp2->sectorsize, (intmax_t)pp2->mediasize, + DPRINTF(GUZ_DBG_INFO, ("%s: taste ok (%d, %jd), (%d, %d), %x\n", + gp->name, pp2->sectorsize, (intmax_t)pp2->mediasize, pp2->stripeoffset, pp2->stripesize, pp2->flags)); - DPRINTF(("%s: %u x %u blocks\n", gp->name, sc->nblocks, sc->blksz)); + DPRINTF(GUZ_DBG_INFO, ("%s: %u x %u blocks\n", gp->name, sc->nblocks, + sc->blksz)); return (gp); -err: - g_topology_lock(); - g_access(cp, -1, 0, 0); - if (buf != NULL) +e7: + free(sc->last_buf, M_GEOM); + mtx_destroy(&sc->queue_mtx); + mtx_destroy(&sc->last_mtx); +e6: + sc->dcp->free(sc->dcp); +e5: + free(sc->toc, M_GEOM); +e4: + free(gp->softc, M_GEOM_UZIP); +e3: + if (buf != NULL) { free(buf, M_GEOM); - if (gp->softc != NULL) { - g_uzip_softc_free(gp->softc, NULL); - gp->softc = NULL; } +e2: + g_topology_lock(); + g_access(cp, -1, 0, 0); +e1: g_detach(cp); g_destroy_consumer(cp); g_destroy_geom(gp); @@ -547,7 +868,8 @@ g_uzip_destroy_geom(struct gctl_req *req g_topology_assert(); if (gp->softc == NULL) { - DPRINTF(("%s(%s): gp->softc == NULL\n", __func__, gp->name)); + DPRINTF(GUZ_DBG_ERR, ("%s(%s): gp->softc == NULL\n", __func__, + gp->name)); return (ENXIO); } Added: stable/10/sys/geom/uzip/g_uzip.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/sys/geom/uzip/g_uzip.h Thu Jul 21 23:49:26 2016 (r303167) @@ -0,0 +1,37 @@ +/*- + * Copyright (c) 2004 Max Khon + * Copyright (c) 2014 Juniper Networks, Inc. + * Copyright (c) 2006-2016 Maxim Sobolev + * 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. + * + * $FreeBSD$ + */ +#ifndef __GEOM_G_UZIP_H__ +#define __GEOM_G_UZIP_H__ + +MALLOC_DECLARE(M_GEOM_UZIP); + +#define DEFINE_RAW_METHOD(func, rval, args...) typedef rval (*func##_t)(args) + +#endif /* __GEOM_G_UZIP_H__ */ Added: stable/10/sys/geom/uzip/g_uzip_cloop.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/sys/geom/uzip/g_uzip_cloop.h Thu Jul 21 23:49:26 2016 (r303167) @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2004-2016 Maxim Sobolev + * 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. + * + * $FreeBSD$ + */ + +/* CLOOP format and related constants */ + +/* + * Integer values (block size, number of blocks, offsets) + * are stored in big-endian (network) order on disk. + */ + +#define CLOOP_MAGIC_LEN 128 +#define CLOOP_OFS_COMPR 0x0b +#define CLOOP_OFS_VERSN (CLOOP_OFS_COMPR + 1) + +#define CLOOP_MAJVER_2 '2' +#define CLOOP_MAJVER_3 '3' + +#define CLOOP_COMP_LIBZ 'V' +#define CLOOP_COMP_LIBZ_DDP 'v' +#define CLOOP_COMP_LZMA 'L' +#define CLOOP_COMP_LZMA_DDP 'l' + +#define CLOOP_MINVER_LZMA CLOOP_MAJVER_3 *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-10@freebsd.org Fri Jul 22 00:43:33 2016 Return-Path: Delivered-To: svn-src-stable-10@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 C5D61BA0BDC; Fri, 22 Jul 2016 00:43:33 +0000 (UTC) (envelope-from bdrewery@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 8EE5412A3; Fri, 22 Jul 2016 00:43:33 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6M0hWli021478; Fri, 22 Jul 2016 00:43:32 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6M0hWDe021477; Fri, 22 Jul 2016 00:43:32 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201607220043.u6M0hWDe021477@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Fri, 22 Jul 2016 00:43:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303169 - stable/10/libexec/rtld-elf X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jul 2016 00:43:33 -0000 Author: bdrewery Date: Fri Jul 22 00:43:32 2016 New Revision: 303169 URL: https://svnweb.freebsd.org/changeset/base/303169 Log: MFC r302908: Fix dlsym(RTLD_NEXT) handling to only return the next library in last library cases. Modified: stable/10/libexec/rtld-elf/rtld.c Directory Properties: stable/10/ (props changed) Modified: stable/10/libexec/rtld-elf/rtld.c ============================================================================== --- stable/10/libexec/rtld-elf/rtld.c Fri Jul 22 00:00:09 2016 (r303168) +++ stable/10/libexec/rtld-elf/rtld.c Fri Jul 22 00:43:32 2016 (r303169) @@ -3181,7 +3181,7 @@ do_dlsym(void *handle, const char *name, handle == RTLD_SELF) { /* ... caller included */ if (handle == RTLD_NEXT) obj = globallist_next(obj); - TAILQ_FOREACH_FROM(obj, &obj_list, next) { + for (; obj != NULL; obj = TAILQ_NEXT(obj, next)) { if (obj->marker) continue; res = symlook_obj(&req, obj); From owner-svn-src-stable-10@freebsd.org Fri Jul 22 01:16:57 2016 Return-Path: Delivered-To: svn-src-stable-10@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 AC85BBA0325; Fri, 22 Jul 2016 01:16:57 +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 7BD6C1E3E; Fri, 22 Jul 2016 01:16:57 +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 u6M1Gu8g032736; Fri, 22 Jul 2016 01:16:56 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6M1Guvf032735; Fri, 22 Jul 2016 01:16:56 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201607220116.u6M1Guvf032735@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Fri, 22 Jul 2016 01:16:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303170 - stable/10/contrib/llvm/tools/clang/lib/Driver X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jul 2016 01:16:57 -0000 Author: emaste Date: Fri Jul 22 01:16:56 2016 New Revision: 303170 URL: https://svnweb.freebsd.org/changeset/base/303170 Log: MFC r303031: clang++: Always use --eh-frame-hdr on FreeBSD, even for -static FreeBSD uses LLVM's libunwind on FreeBSD/arm64 today (and we expect to use it more widely in the future) and it requires the EH frame segment in static binaries. Modified: stable/10/contrib/llvm/tools/clang/lib/Driver/Tools.cpp Directory Properties: stable/10/ (props changed) Modified: stable/10/contrib/llvm/tools/clang/lib/Driver/Tools.cpp ============================================================================== --- stable/10/contrib/llvm/tools/clang/lib/Driver/Tools.cpp Fri Jul 22 00:43:32 2016 (r303169) +++ stable/10/contrib/llvm/tools/clang/lib/Driver/Tools.cpp Fri Jul 22 01:16:56 2016 (r303170) @@ -5848,12 +5848,12 @@ void freebsd::Link::ConstructJob(Compila if (Args.hasArg(options::OPT_pie)) CmdArgs.push_back("-pie"); + CmdArgs.push_back("--eh-frame-hdr"); if (Args.hasArg(options::OPT_static)) { CmdArgs.push_back("-Bstatic"); } else { if (Args.hasArg(options::OPT_rdynamic)) CmdArgs.push_back("-export-dynamic"); - CmdArgs.push_back("--eh-frame-hdr"); if (Args.hasArg(options::OPT_shared)) { CmdArgs.push_back("-Bshareable"); } else { From owner-svn-src-stable-10@freebsd.org Fri Jul 22 03:03:54 2016 Return-Path: Delivered-To: svn-src-stable-10@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 32A6BBA1908; Fri, 22 Jul 2016 03:03:54 +0000 (UTC) (envelope-from sbruno@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 E318715BB; Fri, 22 Jul 2016 03:03:53 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6M33quY074158; Fri, 22 Jul 2016 03:03:52 GMT (envelope-from sbruno@FreeBSD.org) Received: (from sbruno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6M33qdk074157; Fri, 22 Jul 2016 03:03:52 GMT (envelope-from sbruno@FreeBSD.org) Message-Id: <201607220303.u6M33qdk074157@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sbruno set sender to sbruno@FreeBSD.org using -f From: Sean Bruno Date: Fri, 22 Jul 2016 03:03:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303172 - stable/10/sys/dev/hptmv X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jul 2016 03:03:54 -0000 Author: sbruno Date: Fri Jul 22 03:03:52 2016 New Revision: 303172 URL: https://svnweb.freebsd.org/changeset/base/303172 Log: MFC r298231 hptmv(4) Fix potential buffer overflow in hpt_set_info. While here, adjust some whitespace and yeild some useful debug info. This is untested on this hardware, testing requests to -scsi went unanswered. Modified: stable/10/sys/dev/hptmv/hptproc.c Modified: stable/10/sys/dev/hptmv/hptproc.c ============================================================================== --- stable/10/sys/dev/hptmv/hptproc.c Fri Jul 22 02:11:49 2016 (r303171) +++ stable/10/sys/dev/hptmv/hptproc.c Fri Jul 22 03:03:52 2016 (r303172) @@ -290,7 +290,9 @@ hpt_set_info(int length) /* * map buffer to kernel. */ - if (piop->nInBufferSize+piop->nOutBufferSize > PAGE_SIZE) { + if (piop->nInBufferSize > PAGE_SIZE || + piop->nOutBufferSize > PAGE_SIZE || + piop->nInBufferSize+piop->nOutBufferSize > PAGE_SIZE) { KdPrintE(("User buffer too large\n")); return -EINVAL; } @@ -301,8 +303,13 @@ hpt_set_info(int length) return -EINVAL; } - if (piop->nInBufferSize) - copyin((void*)(ULONG_PTR)piop->lpInBuffer, ke_area, piop->nInBufferSize); + if (piop->nInBufferSize) { + if (copyin((void*)(ULONG_PTR)piop->lpInBuffer, ke_area, piop->nInBufferSize) != 0) { + KdPrintE(("Failed to copyin from lpInBuffer\n")); + free(ke_area, M_DEVBUF); + return -EFAULT; + } + } /* * call kernel handler. @@ -324,7 +331,7 @@ hpt_set_info(int length) else KdPrintW(("Kernel_ioctl(): return %d\n", err)); free(ke_area, M_DEVBUF); - return -EINVAL; + return -EINVAL; } else { KdPrintW(("Wrong signature: %x\n", piop->Magic)); return -EINVAL; From owner-svn-src-stable-10@freebsd.org Fri Jul 22 03:09:48 2016 Return-Path: Delivered-To: svn-src-stable-10@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 7AECDBA1A01; Fri, 22 Jul 2016 03:09:48 +0000 (UTC) (envelope-from sbruno@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 4BA6F189C; Fri, 22 Jul 2016 03:09:48 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6M39lhB074551; Fri, 22 Jul 2016 03:09:47 GMT (envelope-from sbruno@FreeBSD.org) Received: (from sbruno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6M39loU074550; Fri, 22 Jul 2016 03:09:47 GMT (envelope-from sbruno@FreeBSD.org) Message-Id: <201607220309.u6M39loU074550@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sbruno set sender to sbruno@FreeBSD.org using -f From: Sean Bruno Date: Fri, 22 Jul 2016 03:09:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303173 - stable/10/sys/nlm X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jul 2016 03:09:48 -0000 Author: sbruno Date: Fri Jul 22 03:09:47 2016 New Revision: 303173 URL: https://svnweb.freebsd.org/changeset/base/303173 Log: MFC r298351 Avoid a possible heap overflow in our nlm code by limiting the number of service to the arbitrary value of 256. Log an appropriate message that indicates the hard limit. Modified: stable/10/sys/nlm/nlm_prot_impl.c Modified: stable/10/sys/nlm/nlm_prot_impl.c ============================================================================== --- stable/10/sys/nlm/nlm_prot_impl.c Fri Jul 22 03:03:52 2016 (r303172) +++ stable/10/sys/nlm/nlm_prot_impl.c Fri Jul 22 03:09:47 2016 (r303173) @@ -1439,6 +1439,12 @@ nlm_register_services(SVCPOOL *pool, int return (EINVAL); } + if (addr_count < 0 || addr_count > 256 ) { + NLM_ERR("NLM: too many service addresses (%d) given, " + "max 256 - can't start server\n", addr_count); + return (EINVAL); + } + xprts = malloc(addr_count * sizeof(SVCXPRT *), M_NLM, M_WAITOK|M_ZERO); for (i = 0; i < version_count; i++) { for (j = 0; j < addr_count; j++) { From owner-svn-src-stable-10@freebsd.org Fri Jul 22 03:16:38 2016 Return-Path: Delivered-To: svn-src-stable-10@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 E6079BA1B9C; Fri, 22 Jul 2016 03:16:38 +0000 (UTC) (envelope-from sbruno@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 B5C821D14; Fri, 22 Jul 2016 03:16:38 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6M3GbSZ078477; Fri, 22 Jul 2016 03:16:37 GMT (envelope-from sbruno@FreeBSD.org) Received: (from sbruno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6M3GbVZ078476; Fri, 22 Jul 2016 03:16:37 GMT (envelope-from sbruno@FreeBSD.org) Message-Id: <201607220316.u6M3GbVZ078476@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sbruno set sender to sbruno@FreeBSD.org using -f From: Sean Bruno Date: Fri, 22 Jul 2016 03:16:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303174 - stable/10/sys/dev/e1000 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jul 2016 03:16:39 -0000 Author: sbruno Date: Fri Jul 22 03:16:37 2016 New Revision: 303174 URL: https://svnweb.freebsd.org/changeset/base/303174 Log: MFC r299182 If ALTQ is defined in the kern conf, switch to Legacy Mode. PR: 208409 Modified: stable/10/sys/dev/e1000/if_igb.h Modified: stable/10/sys/dev/e1000/if_igb.h ============================================================================== --- stable/10/sys/dev/e1000/if_igb.h Fri Jul 22 03:09:47 2016 (r303173) +++ stable/10/sys/dev/e1000/if_igb.h Fri Jul 22 03:16:37 2016 (r303174) @@ -35,6 +35,10 @@ #ifndef _IF_IGB_H_ #define _IF_IGB_H_ +#ifdef ALTQ +#define IGB_LEGACY_TX +#endif + #include #include #ifndef IGB_LEGACY_TX From owner-svn-src-stable-10@freebsd.org Fri Jul 22 03:19:51 2016 Return-Path: Delivered-To: svn-src-stable-10@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 1C771BA1C78; Fri, 22 Jul 2016 03:19:51 +0000 (UTC) (envelope-from sbruno@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 E04A61F8D; Fri, 22 Jul 2016 03:19:50 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6M3JoDo078666; Fri, 22 Jul 2016 03:19:50 GMT (envelope-from sbruno@FreeBSD.org) Received: (from sbruno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6M3Jo13078665; Fri, 22 Jul 2016 03:19:50 GMT (envelope-from sbruno@FreeBSD.org) Message-Id: <201607220319.u6M3Jo13078665@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sbruno set sender to sbruno@FreeBSD.org using -f From: Sean Bruno Date: Fri, 22 Jul 2016 03:19:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303175 - stable/10/sys/dev/e1000 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jul 2016 03:19:51 -0000 Author: sbruno Date: Fri Jul 22 03:19:49 2016 New Revision: 303175 URL: https://svnweb.freebsd.org/changeset/base/303175 Log: MFC r299188 Since igb_detach() cleans up all the data structures that will be free'd by the functions following its call, we can simply return instead of crashing and burning in the event of igb_detach() failing. PR: 197139 Modified: stable/10/sys/dev/e1000/if_igb.c Modified: stable/10/sys/dev/e1000/if_igb.c ============================================================================== --- stable/10/sys/dev/e1000/if_igb.c Fri Jul 22 03:16:37 2016 (r303174) +++ stable/10/sys/dev/e1000/if_igb.c Fri Jul 22 03:19:49 2016 (r303175) @@ -664,7 +664,8 @@ igb_attach(device_t dev) return (0); err_late: - igb_detach(dev); + if (igb_detach(dev) == 0) /* igb_detach() already did the cleanup */ + return(error); igb_free_transmit_structures(adapter); igb_free_receive_structures(adapter); igb_release_hw_control(adapter); From owner-svn-src-stable-10@freebsd.org Fri Jul 22 03:21:48 2016 Return-Path: Delivered-To: svn-src-stable-10@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 8814FBA1D04; Fri, 22 Jul 2016 03:21:48 +0000 (UTC) (envelope-from sbruno@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 3A7F61342; Fri, 22 Jul 2016 03:21:48 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6M3Ll9h082046; Fri, 22 Jul 2016 03:21:47 GMT (envelope-from sbruno@FreeBSD.org) Received: (from sbruno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6M3Llqt082045; Fri, 22 Jul 2016 03:21:47 GMT (envelope-from sbruno@FreeBSD.org) Message-Id: <201607220321.u6M3Llqt082045@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sbruno set sender to sbruno@FreeBSD.org using -f From: Sean Bruno Date: Fri, 22 Jul 2016 03:21:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303176 - stable/10/sys/dev/ciss X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jul 2016 03:21:48 -0000 Author: sbruno Date: Fri Jul 22 03:21:47 2016 New Revision: 303176 URL: https://svnweb.freebsd.org/changeset/base/303176 Log: MFC r300551 Update some of the TBD entries in ciss(4) to match what's in the pci IDS data. Modified: stable/10/sys/dev/ciss/ciss.c Modified: stable/10/sys/dev/ciss/ciss.c ============================================================================== --- stable/10/sys/dev/ciss/ciss.c Fri Jul 22 03:19:49 2016 (r303175) +++ stable/10/sys/dev/ciss/ciss.c Fri Jul 22 03:21:47 2016 (r303176) @@ -345,21 +345,22 @@ static struct { 0x103C, 0x1928, CISS_BOARD_SA5, "HP Smart Array P230i" }, { 0x103C, 0x1929, CISS_BOARD_SA5, "HP Smart Array P530" }, { 0x103C, 0x192A, CISS_BOARD_SA5, "HP Smart Array P531" }, - { 0x103C, 0x21BD, CISS_BOARD_SA5, "HP Smart Array TBD" }, - { 0x103C, 0x21BE, CISS_BOARD_SA5, "HP Smart Array TBD" }, - { 0x103C, 0x21BF, CISS_BOARD_SA5, "HP Smart Array TBD" }, - { 0x103C, 0x21C0, CISS_BOARD_SA5, "HP Smart Array TBD" }, - { 0x103C, 0x21C2, CISS_BOARD_SA5, "HP Smart Array TBD" }, - { 0x103C, 0x21C3, CISS_BOARD_SA5, "HP Smart Array TBD" }, - { 0x103C, 0x21C5, CISS_BOARD_SA5, "HP Smart Array TBD" }, - { 0x103C, 0x21C6, CISS_BOARD_SA5, "HP Smart Array TBD" }, - { 0x103C, 0x21C7, CISS_BOARD_SA5, "HP Smart Array TBD" }, - { 0x103C, 0x21C8, CISS_BOARD_SA5, "HP Smart Array TBD" }, - { 0x103C, 0x21CA, CISS_BOARD_SA5, "HP Smart Array TBD" }, - { 0x103C, 0x21CB, CISS_BOARD_SA5, "HP Smart Array TBD" }, + { 0x103C, 0x21BD, CISS_BOARD_SA5, "HP Smart Array P244br" }, + { 0x103C, 0x21BE, CISS_BOARD_SA5, "HP Smart Array P741m" }, + { 0x103C, 0x21BF, CISS_BOARD_SA5, "HP Smart Array H240ar" }, + { 0x103C, 0x21C0, CISS_BOARD_SA5, "HP Smart Array P440ar" }, + { 0x103C, 0x21C1, CISS_BOARD_SA5, "HP Smart Array P840ar" }, + { 0x103C, 0x21C2, CISS_BOARD_SA5, "HP Smart Array P440" }, + { 0x103C, 0x21C3, CISS_BOARD_SA5, "HP Smart Array P441" }, + { 0x103C, 0x21C5, CISS_BOARD_SA5, "HP Smart Array P841" }, + { 0x103C, 0x21C6, CISS_BOARD_SA5, "HP Smart Array H244br" }, + { 0x103C, 0x21C7, CISS_BOARD_SA5, "HP Smart Array H240" }, + { 0x103C, 0x21C8, CISS_BOARD_SA5, "HP Smart Array H241" }, + { 0x103C, 0x21CA, CISS_BOARD_SA5, "HP Smart Array P246br" }, + { 0x103C, 0x21CB, CISS_BOARD_SA5, "HP Smart Array P840" }, { 0x103C, 0x21CC, CISS_BOARD_SA5, "HP Smart Array TBD" }, - { 0x103C, 0x21CD, CISS_BOARD_SA5, "HP Smart Array TBD" }, - { 0x103C, 0x21CE, CISS_BOARD_SA5, "HP Smart Array TBD" }, + { 0x103C, 0x21CD, CISS_BOARD_SA5, "HP Smart Array P240nr" }, + { 0x103C, 0x21CE, CISS_BOARD_SA5, "HP Smart Array H240nr" }, { 0, 0, 0, NULL } }; From owner-svn-src-stable-10@freebsd.org Fri Jul 22 03:26:03 2016 Return-Path: Delivered-To: svn-src-stable-10@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 4B202BA1E3E; Fri, 22 Jul 2016 03:26:03 +0000 (UTC) (envelope-from sbruno@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 14A3016D2; Fri, 22 Jul 2016 03:26:02 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6M3Q2Iu082277; Fri, 22 Jul 2016 03:26:02 GMT (envelope-from sbruno@FreeBSD.org) Received: (from sbruno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6M3Q2Xp082276; Fri, 22 Jul 2016 03:26:02 GMT (envelope-from sbruno@FreeBSD.org) Message-Id: <201607220326.u6M3Q2Xp082276@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sbruno set sender to sbruno@FreeBSD.org using -f From: Sean Bruno Date: Fri, 22 Jul 2016 03:26:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303177 - stable/10/sys/dev/an X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jul 2016 03:26:03 -0000 Author: sbruno Date: Fri Jul 22 03:26:01 2016 New Revision: 303177 URL: https://svnweb.freebsd.org/changeset/base/303177 Log: MFC r300612 Reject ioctl commands for FLSHGCHR and FLSHPCHR if the size is greater than sc->areq. This is a bounds check to ensure we're not just cramming arbitrarily sized nonsense into the driver and overflowing the heap. PR: 209545 Modified: stable/10/sys/dev/an/if_an.c Modified: stable/10/sys/dev/an/if_an.c ============================================================================== --- stable/10/sys/dev/an/if_an.c Fri Jul 22 03:21:47 2016 (r303176) +++ stable/10/sys/dev/an/if_an.c Fri Jul 22 03:26:01 2016 (r303177) @@ -3777,6 +3777,9 @@ flashcard(struct ifnet *ifp, struct airo return ENOBUFS; break; case AIROFLSHGCHR: /* Get char from aux */ + if (l_ioctl->len > sizeof(sc->areq)) { + return -EINVAL; + } AN_UNLOCK(sc); status = copyin(l_ioctl->data, &sc->areq, l_ioctl->len); AN_LOCK(sc); @@ -3788,6 +3791,9 @@ flashcard(struct ifnet *ifp, struct airo else return -1; case AIROFLSHPCHR: /* Send char to card. */ + if (l_ioctl->len > sizeof(sc->areq)) { + return -EINVAL; + } AN_UNLOCK(sc); status = copyin(l_ioctl->data, &sc->areq, l_ioctl->len); AN_LOCK(sc); From owner-svn-src-stable-10@freebsd.org Fri Jul 22 03:34:16 2016 Return-Path: Delivered-To: svn-src-stable-10@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 DC15BBA016C; Fri, 22 Jul 2016 03:34:16 +0000 (UTC) (envelope-from sbruno@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 A5E311E26; Fri, 22 Jul 2016 03:34:16 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6M3YFmc086033; Fri, 22 Jul 2016 03:34:15 GMT (envelope-from sbruno@FreeBSD.org) Received: (from sbruno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6M3YF34086032; Fri, 22 Jul 2016 03:34:15 GMT (envelope-from sbruno@FreeBSD.org) Message-Id: <201607220334.u6M3YF34086032@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sbruno set sender to sbruno@FreeBSD.org using -f From: Sean Bruno Date: Fri, 22 Jul 2016 03:34:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303179 - stable/10/sys/cam/scsi X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jul 2016 03:34:17 -0000 Author: sbruno Date: Fri Jul 22 03:34:15 2016 New Revision: 303179 URL: https://svnweb.freebsd.org/changeset/base/303179 Log: MFC r302281 Correct PERSISTENT RESERVE OUT command and populate scsi_cmd->length. PR: 202625 Modified: stable/10/sys/cam/scsi/scsi_all.c Modified: stable/10/sys/cam/scsi/scsi_all.c ============================================================================== --- stable/10/sys/cam/scsi/scsi_all.c Fri Jul 22 03:30:00 2016 (r303178) +++ stable/10/sys/cam/scsi/scsi_all.c Fri Jul 22 03:34:15 2016 (r303179) @@ -8539,6 +8539,7 @@ scsi_persistent_reserve_out(struct ccb_s scsi_cmd->opcode = PERSISTENT_RES_OUT; scsi_cmd->action = service_action; scsi_cmd->scope_type = scope | res_type; + scsi_ulto4b(dxfer_len, scsi_cmd->length); cam_fill_csio(csio, retries, From owner-svn-src-stable-10@freebsd.org Fri Jul 22 03:48:45 2016 Return-Path: Delivered-To: svn-src-stable-10@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 4B91EBA05DA; Fri, 22 Jul 2016 03:48:45 +0000 (UTC) (envelope-from sbruno@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 1AFD0178D; Fri, 22 Jul 2016 03:48:45 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6M3miPW090019; Fri, 22 Jul 2016 03:48:44 GMT (envelope-from sbruno@FreeBSD.org) Received: (from sbruno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6M3miFF090018; Fri, 22 Jul 2016 03:48:44 GMT (envelope-from sbruno@FreeBSD.org) Message-Id: <201607220348.u6M3miFF090018@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sbruno set sender to sbruno@FreeBSD.org using -f From: Sean Bruno Date: Fri, 22 Jul 2016 03:48:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303181 - stable/10/sys/dev/e1000 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jul 2016 03:48:45 -0000 Author: sbruno Date: Fri Jul 22 03:48:44 2016 New Revision: 303181 URL: https://svnweb.freebsd.org/changeset/base/303181 Log: MFC r303110 Remove uneeded parens. Modified: stable/10/sys/dev/e1000/if_igb.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/e1000/if_igb.c ============================================================================== --- stable/10/sys/dev/e1000/if_igb.c Fri Jul 22 03:42:32 2016 (r303180) +++ stable/10/sys/dev/e1000/if_igb.c Fri Jul 22 03:48:44 2016 (r303181) @@ -1091,7 +1091,7 @@ igb_ioctl(struct ifnet *ifp, u_long comm ifp->if_mtu = ifr->ifr_mtu; adapter->max_frame_size = ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN; - if ((ifp->if_drv_flags & IFF_DRV_RUNNING)) + if (ifp->if_drv_flags & IFF_DRV_RUNNING) igb_init_locked(adapter); IGB_CORE_UNLOCK(adapter); break; From owner-svn-src-stable-10@freebsd.org Fri Jul 22 14:24:19 2016 Return-Path: Delivered-To: svn-src-stable-10@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 60FA5BA0FB9; Fri, 22 Jul 2016 14:24:19 +0000 (UTC) (envelope-from ache@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 35953151F; Fri, 22 Jul 2016 14:24:19 +0000 (UTC) (envelope-from ache@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6MEOI0s025891; Fri, 22 Jul 2016 14:24:18 GMT (envelope-from ache@FreeBSD.org) Received: (from ache@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6MEOHmM025885; Fri, 22 Jul 2016 14:24:17 GMT (envelope-from ache@FreeBSD.org) Message-Id: <201607221424.u6MEOHmM025885@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ache set sender to ache@FreeBSD.org using -f From: "Andrey A. Chernov" Date: Fri, 22 Jul 2016 14:24:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303185 - in stable/10/lib/libc: gen locale regex stdio X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jul 2016 14:24:19 -0000 Author: ache Date: Fri Jul 22 14:24:17 2016 New Revision: 303185 URL: https://svnweb.freebsd.org/changeset/base/303185 Log: MFC: r302824 1) Eliminate possibility to call __*collate_range_cmp() with inclomplete locale (which cause core dump) by removing whole 'table' argument by which it passed. 2) Restore __collate_range_cmp() in __sccl(). 3) Collating [a-z] range in regcomp() works for single byte locales only (we can't do it for other ones). In previous state only first 256 wide chars are considered and all others are just silently dropped from the range. Modified: stable/10/lib/libc/gen/fnmatch.c stable/10/lib/libc/gen/glob.c stable/10/lib/libc/locale/collate.h stable/10/lib/libc/locale/collcmp.c stable/10/lib/libc/regex/regcomp.c stable/10/lib/libc/stdio/vfscanf.c Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libc/gen/fnmatch.c ============================================================================== --- stable/10/lib/libc/gen/fnmatch.c Fri Jul 22 12:55:31 2016 (r303184) +++ stable/10/lib/libc/gen/fnmatch.c Fri Jul 22 14:24:17 2016 (r303185) @@ -304,8 +304,8 @@ rangematch(pattern, test, flags, newp, p if (table->__collate_load_error ? c <= test && test <= c2 : - __collate_range_cmp(table, c, test) <= 0 - && __collate_range_cmp(table, test, c2) <= 0 + __wcollate_range_cmp(c, test) <= 0 + && __wcollate_range_cmp(test, c2) <= 0 ) ok = 1; } else if (c == test) Modified: stable/10/lib/libc/gen/glob.c ============================================================================== --- stable/10/lib/libc/gen/glob.c Fri Jul 22 12:55:31 2016 (r303184) +++ stable/10/lib/libc/gen/glob.c Fri Jul 22 14:24:17 2016 (r303185) @@ -836,8 +836,8 @@ match(Char *name, Char *pat, Char *paten if ((*pat & M_MASK) == M_RNG) { if (table->__collate_load_error ? CHAR(c) <= CHAR(k) && CHAR(k) <= CHAR(pat[1]) : - __collate_range_cmp(table, CHAR(c), CHAR(k)) <= 0 - && __collate_range_cmp(table, CHAR(k), CHAR(pat[1])) <= 0 + __wcollate_range_cmp(CHAR(c), CHAR(k)) <= 0 + && __wcollate_range_cmp(CHAR(k), CHAR(pat[1])) <= 0 ) ok = 1; pat += 2; Modified: stable/10/lib/libc/locale/collate.h ============================================================================== --- stable/10/lib/libc/locale/collate.h Fri Jul 22 12:55:31 2016 (r303184) +++ stable/10/lib/libc/locale/collate.h Fri Jul 22 14:24:17 2016 (r303185) @@ -72,7 +72,8 @@ u_char *__collate_strdup(u_char *); u_char *__collate_substitute(struct xlocale_collate *, const u_char *); int __collate_load_tables(const char *); void __collate_lookup(struct xlocale_collate *, const u_char *, int *, int *, int *); -int __collate_range_cmp(struct xlocale_collate *, int, int); +int __collate_range_cmp(char, char); +int __wcollate_range_cmp(wchar_t, wchar_t); #ifdef COLLATE_DEBUG void __collate_print_tables(void); #endif Modified: stable/10/lib/libc/locale/collcmp.c ============================================================================== --- stable/10/lib/libc/locale/collcmp.c Fri Jul 22 12:55:31 2016 (r303184) +++ stable/10/lib/libc/locale/collcmp.c Fri Jul 22 14:24:17 2016 (r303185) @@ -33,20 +33,29 @@ __FBSDID("$FreeBSD$"); #include -#include +#include #include "collate.h" /* * Compare two characters using collate */ -int __collate_range_cmp(struct xlocale_collate *table, int c1, int c2) +int __collate_range_cmp(char c1, char c2) { static char s1[2], s2[2]; s1[0] = c1; s2[0] = c2; - struct _xlocale l = {{0}}; - l.components[XLC_COLLATE] = (struct xlocale_component *)table; - return (strcoll_l(s1, s2, &l)); + return (strcoll(s1, s2)); +} + +int __wcollate_range_cmp(wchar_t c1, wchar_t c2) +{ + wchar_t s1[2], s2[2]; + + s1[0] = c1; + s1[1] = L'\0'; + s2[0] = c2; + s2[1] = L'\0'; + return (wcscoll(s1, s2)); } Modified: stable/10/lib/libc/regex/regcomp.c ============================================================================== --- stable/10/lib/libc/regex/regcomp.c Fri Jul 22 12:55:31 2016 (r303184) +++ stable/10/lib/libc/regex/regcomp.c Fri Jul 22 14:24:17 2016 (r303185) @@ -51,7 +51,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include @@ -817,14 +816,14 @@ p_b_term(struct parse *p, cset *cs) if (start == finish) CHadd(p, cs, start); else { - if (table->__collate_load_error) { - (void)REQUIRE((uch)start <= (uch)finish, REG_ERANGE); + if (table->__collate_load_error || MB_CUR_MAX > 1) { + (void)REQUIRE(start <= finish, REG_ERANGE); CHaddrange(p, cs, start, finish); } else { - (void)REQUIRE(__collate_range_cmp(table, start, finish) <= 0, REG_ERANGE); + (void)REQUIRE(__wcollate_range_cmp(start, finish) <= 0, REG_ERANGE); for (i = 0; i <= UCHAR_MAX; i++) { - if ( __collate_range_cmp(table, start, i) <= 0 - && __collate_range_cmp(table, i, finish) <= 0 + if ( __wcollate_range_cmp(start, i) <= 0 + && __wcollate_range_cmp(i, finish) <= 0 ) CHadd(p, cs, i); } Modified: stable/10/lib/libc/stdio/vfscanf.c ============================================================================== --- stable/10/lib/libc/stdio/vfscanf.c Fri Jul 22 12:55:31 2016 (r303184) +++ stable/10/lib/libc/stdio/vfscanf.c Fri Jul 22 14:24:17 2016 (r303185) @@ -873,7 +873,7 @@ doswitch: n = *fmt; if (n == ']' || (table->__collate_load_error ? n < c : - __collate_range_cmp (table, n, c) < 0 + __collate_range_cmp(n, c) < 0 ) ) { c = '-'; @@ -887,8 +887,8 @@ doswitch: } while (c < n); } else { for (i = 0; i < 256; i ++) - if ( __collate_range_cmp (table, c, i) < 0 - && __collate_range_cmp (table, i, n) <= 0 + if (__collate_range_cmp(c, i) <= 0 && + __collate_range_cmp(i, n) <= 0 ) tab[i] = v; } From owner-svn-src-stable-10@freebsd.org Fri Jul 22 16:48:41 2016 Return-Path: Delivered-To: svn-src-stable-10@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 0607BBA14FF; Fri, 22 Jul 2016 16:48:41 +0000 (UTC) (envelope-from ache@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 CAAA1157A; Fri, 22 Jul 2016 16:48:40 +0000 (UTC) (envelope-from ache@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6MGmeFC077497; Fri, 22 Jul 2016 16:48:40 GMT (envelope-from ache@FreeBSD.org) Received: (from ache@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6MGmejo077496; Fri, 22 Jul 2016 16:48:40 GMT (envelope-from ache@FreeBSD.org) Message-Id: <201607221648.u6MGmejo077496@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ache set sender to ache@FreeBSD.org using -f From: "Andrey A. Chernov" Date: Fri, 22 Jul 2016 16:48:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303191 - stable/10/lib/libc/locale X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jul 2016 16:48:41 -0000 Author: ache Date: Fri Jul 22 16:48:39 2016 New Revision: 303191 URL: https://svnweb.freebsd.org/changeset/base/303191 Log: Forget to merge this changes in prev. MFC Modified: stable/10/lib/libc/locale/collcmp.c Modified: stable/10/lib/libc/locale/collcmp.c ============================================================================== --- stable/10/lib/libc/locale/collcmp.c Fri Jul 22 16:15:35 2016 (r303190) +++ stable/10/lib/libc/locale/collcmp.c Fri Jul 22 16:48:39 2016 (r303191) @@ -42,10 +42,12 @@ __FBSDID("$FreeBSD$"); int __collate_range_cmp(char c1, char c2) { - static char s1[2], s2[2]; + char s1[2], s2[2]; s1[0] = c1; + s1[1] = '\0'; s2[0] = c2; + s2[1] = '\0'; return (strcoll(s1, s2)); } From owner-svn-src-stable-10@freebsd.org Fri Jul 22 17:25:29 2016 Return-Path: Delivered-To: svn-src-stable-10@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 6651EBA1FFF; Fri, 22 Jul 2016 17:25:29 +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 2F56C11C3; Fri, 22 Jul 2016 17:25:29 +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 u6MHPSLM092859; Fri, 22 Jul 2016 17:25:28 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6MHPS2b092858; Fri, 22 Jul 2016 17:25:28 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201607221725.u6MHPS2b092858@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 22 Jul 2016 17:25:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303194 - stable/10/sys/kern X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jul 2016 17:25:29 -0000 Author: kib Date: Fri Jul 22 17:25:28 2016 New Revision: 303194 URL: https://svnweb.freebsd.org/changeset/base/303194 Log: MFC r302893: Do not allow creation of char or block special nodes with VNOVAL dev_t. Modified: stable/10/sys/kern/vfs_syscalls.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/vfs_syscalls.c ============================================================================== --- stable/10/sys/kern/vfs_syscalls.c Fri Jul 22 17:24:36 2016 (r303193) +++ stable/10/sys/kern/vfs_syscalls.c Fri Jul 22 17:25:28 2016 (r303194) @@ -1269,6 +1269,8 @@ kern_mknodat(struct thread *td, int fd, case S_IFCHR: case S_IFBLK: error = priv_check(td, PRIV_VFS_MKNOD_DEV); + if (error == 0 && dev == VNOVAL) + error = EINVAL; break; case S_IFMT: error = priv_check(td, PRIV_VFS_MKNOD_BAD); From owner-svn-src-stable-10@freebsd.org Fri Jul 22 17:36:42 2016 Return-Path: Delivered-To: svn-src-stable-10@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 2CBB8BA146D; Fri, 22 Jul 2016 17:36:42 +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 F1B731C08; Fri, 22 Jul 2016 17:36:41 +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 u6MHaf2x096717; Fri, 22 Jul 2016 17:36:41 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6MHafiS096716; Fri, 22 Jul 2016 17:36:41 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201607221736.u6MHafiS096716@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 22 Jul 2016 17:36:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303198 - stable/10/sys/kern X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jul 2016 17:36:42 -0000 Author: kib Date: Fri Jul 22 17:36:40 2016 New Revision: 303198 URL: https://svnweb.freebsd.org/changeset/base/303198 Log: MFC r302919: In ptrace_vm_entry(), do not call vmspace_free() while owning a vm object lock. Modified: stable/10/sys/kern/sys_process.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/sys_process.c ============================================================================== --- stable/10/sys/kern/sys_process.c Fri Jul 22 17:34:58 2016 (r303197) +++ stable/10/sys/kern/sys_process.c Fri Jul 22 17:36:40 2016 (r303198) @@ -389,7 +389,6 @@ ptrace_vm_entry(struct thread *td, struc } while (0); vm_map_unlock_read(map); - vmspace_free(vm); pve->pve_fsid = VNOVAL; pve->pve_fileid = VNOVAL; @@ -434,6 +433,7 @@ ptrace_vm_entry(struct thread *td, struc free(freepath, M_TEMP); } } + vmspace_free(vm); if (error == 0) CTR3(KTR_PTRACE, "PT_VM_ENTRY: pid %d, entry %d, start %p", p->p_pid, pve->pve_entry, pve->pve_start); From owner-svn-src-stable-10@freebsd.org Fri Jul 22 19:34:44 2016 Return-Path: Delivered-To: svn-src-stable-10@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 4F14ABA2067; Fri, 22 Jul 2016 19:34:44 +0000 (UTC) (envelope-from ache@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 1B72119C1; Fri, 22 Jul 2016 19:34:44 +0000 (UTC) (envelope-from ache@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6MJYhkB040726; Fri, 22 Jul 2016 19:34:43 GMT (envelope-from ache@FreeBSD.org) Received: (from ache@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6MJYhxj040725; Fri, 22 Jul 2016 19:34:43 GMT (envelope-from ache@FreeBSD.org) Message-Id: <201607221934.u6MJYhxj040725@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ache set sender to ache@FreeBSD.org using -f From: "Andrey A. Chernov" Date: Fri, 22 Jul 2016 19:34:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303200 - stable/10/usr.bin/tr X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jul 2016 19:34:44 -0000 Author: ache Date: Fri Jul 22 19:34:43 2016 New Revision: 303200 URL: https://svnweb.freebsd.org/changeset/base/303200 Log: MFC: r302826 Document incomplete support of [=equiv=] and collation for ranges. Modified: stable/10/usr.bin/tr/tr.1 Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.bin/tr/tr.1 ============================================================================== --- stable/10/usr.bin/tr/tr.1 Fri Jul 22 19:28:23 2016 (r303199) +++ stable/10/usr.bin/tr/tr.1 Fri Jul 22 19:34:43 2016 (r303200) @@ -334,6 +334,10 @@ should be used instead of explicit chara and .Dq Li A-Z . .Pp +.Dq Li [=equiv=] +expression and collation for ranges +are implemented for single byte locales only. +.Pp System V has historically implemented character ranges using the syntax .Dq Li [c-c] instead of the From owner-svn-src-stable-10@freebsd.org Fri Jul 22 19:36:12 2016 Return-Path: Delivered-To: svn-src-stable-10@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 BFCD5BA215F; Fri, 22 Jul 2016 19:36:12 +0000 (UTC) (envelope-from ache@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 923641C12; Fri, 22 Jul 2016 19:36:12 +0000 (UTC) (envelope-from ache@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6MJaBxm040953; Fri, 22 Jul 2016 19:36:11 GMT (envelope-from ache@FreeBSD.org) Received: (from ache@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6MJaBC6040952; Fri, 22 Jul 2016 19:36:11 GMT (envelope-from ache@FreeBSD.org) Message-Id: <201607221936.u6MJaBC6040952@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ache set sender to ache@FreeBSD.org using -f From: "Andrey A. Chernov" Date: Fri, 22 Jul 2016 19:36:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303201 - stable/10/usr.bin/tr X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jul 2016 19:36:12 -0000 Author: ache Date: Fri Jul 22 19:36:11 2016 New Revision: 303201 URL: https://svnweb.freebsd.org/changeset/base/303201 Log: MFC: r302827 Optimize [Cc]flag case: don't repeatedly add the last character of string2 to squeeze cset when string2 reach its EOS state. Modified: stable/10/usr.bin/tr/tr.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.bin/tr/tr.c ============================================================================== --- stable/10/usr.bin/tr/tr.c Fri Jul 22 19:34:43 2016 (r303200) +++ stable/10/usr.bin/tr/tr.c Fri Jul 22 19:36:11 2016 (r303201) @@ -272,10 +272,11 @@ endloop: if (Cflag && !iswrune(cnt)) continue; if (cmap_lookup(map, cnt) == OOBCH) { - if (next(&s2)) + if (next(&s2)) { cmap_add(map, cnt, s2.lastch); - if (sflag) - cset_add(squeeze, s2.lastch); + if (sflag) + cset_add(squeeze, s2.lastch); + } } else cmap_add(map, cnt, cnt); if ((s2.state == EOS || s2.state == INFINITE) && From owner-svn-src-stable-10@freebsd.org Sat Jul 23 08:02:47 2016 Return-Path: Delivered-To: svn-src-stable-10@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 22BBABA2CCF; Sat, 23 Jul 2016 08:02:47 +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 E6B0E1885; Sat, 23 Jul 2016 08:02:46 +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 u6N82kXj028394; Sat, 23 Jul 2016 08:02:46 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6N82k8X028393; Sat, 23 Jul 2016 08:02:46 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201607230802.u6N82k8X028393@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sat, 23 Jul 2016 08:02:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303214 - stable/10/sys/kern X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Jul 2016 08:02:47 -0000 Author: kib Date: Sat Jul 23 08:02:45 2016 New Revision: 303214 URL: https://svnweb.freebsd.org/changeset/base/303214 Log: MFC r302936: Explicitely check for the valid range of file descriptor values. Modified: stable/10/sys/kern/kern_event.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/kern_event.c ============================================================================== --- stable/10/sys/kern/kern_event.c Sat Jul 23 06:30:00 2016 (r303213) +++ stable/10/sys/kern/kern_event.c Sat Jul 23 08:02:45 2016 (r303214) @@ -1083,8 +1083,11 @@ kqueue_register(struct kqueue *kq, struc findkn: if (fops->f_isfd) { KASSERT(td != NULL, ("td is NULL")); - error = fget(td, kev->ident, - cap_rights_init(&rights, CAP_EVENT), &fp); + if (kev->ident > INT_MAX) + error = EBADF; + else + error = fget(td, kev->ident, + cap_rights_init(&rights, CAP_EVENT), &fp); if (error) goto done; From owner-svn-src-stable-10@freebsd.org Sat Jul 23 17:41:48 2016 Return-Path: Delivered-To: svn-src-stable-10@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 CFC11BA1CB3; Sat, 23 Jul 2016 17:41:48 +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 AD7341E44; Sat, 23 Jul 2016 17:41:48 +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 u6NHfl4o045571; Sat, 23 Jul 2016 17:41:47 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6NHflan045567; Sat, 23 Jul 2016 17:41:47 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201607231741.u6NHflan045567@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Sat, 23 Jul 2016 17:41:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303229 - stable/10/sys/dev/acpica X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Jul 2016 17:41:48 -0000 Author: jhb Date: Sat Jul 23 17:41:47 2016 New Revision: 303229 URL: https://svnweb.freebsd.org/changeset/base/303229 Log: MFC 298370,298372,298377,298379,298380,298484: Abstract out _OSC handling and invoke it for PCI bridges. r298370: Add a wrapper for evaluating _OSC methods. This wrapper does not translate errors in the first word to ACPI error status returns. Use this wrapper in the acpi_cpu(4) driver in place of the existing _OSC code. While here, fix a bug where the wrong count of words was passed when invoking _OSC. r298372: Invoke _OSC on Host-PCI bridges. Tell the firmware that we support PCI-express config space access and MSI. r298377: Remove query flag from acpi_EvaluateOSC(). This function does not support return buffer (yet). r298379: There is no need to use array any more. No functional change. r298380: Prefer sizeof(*pointer) over sizeof(type). No funtional change. r298484: Optionally return the output capabilities list from _OSC. Both of the callers were expecting the input cap_set to be modified. This fixes them to request cap_set to be updated with the returned buffer. Modified: stable/10/sys/dev/acpica/acpi.c stable/10/sys/dev/acpica/acpi_cpu.c stable/10/sys/dev/acpica/acpi_pcib_acpi.c stable/10/sys/dev/acpica/acpivar.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/acpica/acpi.c ============================================================================== --- stable/10/sys/dev/acpica/acpi.c Sat Jul 23 17:37:59 2016 (r303228) +++ stable/10/sys/dev/acpica/acpi.c Sat Jul 23 17:41:47 2016 (r303229) @@ -2451,6 +2451,46 @@ acpi_AppendBufferResource(ACPI_BUFFER *b return (AE_OK); } +ACPI_STATUS +acpi_EvaluateOSC(ACPI_HANDLE handle, uint8_t *uuid, int revision, int count, + uint32_t *caps_in, uint32_t *caps_out, bool query) +{ + ACPI_OBJECT arg[4], *ret; + ACPI_OBJECT_LIST arglist; + ACPI_BUFFER buf; + ACPI_STATUS status; + + arglist.Pointer = arg; + arglist.Count = 4; + arg[0].Type = ACPI_TYPE_BUFFER; + arg[0].Buffer.Length = ACPI_UUID_LENGTH; + arg[0].Buffer.Pointer = uuid; + arg[1].Type = ACPI_TYPE_INTEGER; + arg[1].Integer.Value = revision; + arg[2].Type = ACPI_TYPE_INTEGER; + arg[2].Integer.Value = count; + arg[3].Type = ACPI_TYPE_BUFFER; + arg[3].Buffer.Length = count * sizeof(*caps_in); + arg[3].Buffer.Pointer = (uint8_t *)caps_in; + caps_in[0] = query ? 1 : 0; + buf.Pointer = NULL; + buf.Length = ACPI_ALLOCATE_BUFFER; + status = AcpiEvaluateObjectTyped(handle, "_OSC", &arglist, &buf, + ACPI_TYPE_BUFFER); + if (ACPI_FAILURE(status)) + return (status); + if (caps_out != NULL) { + ret = buf.Pointer; + if (ret->Buffer.Length != count * sizeof(*caps_out)) { + AcpiOsFree(buf.Pointer); + return (AE_BUFFER_OVERFLOW); + } + bcopy(ret->Buffer.Pointer, caps_out, ret->Buffer.Length); + } + AcpiOsFree(buf.Pointer); + return (status); +} + /* * Set interrupt model. */ Modified: stable/10/sys/dev/acpica/acpi_cpu.c ============================================================================== --- stable/10/sys/dev/acpica/acpi_cpu.c Sat Jul 23 17:37:59 2016 (r303228) +++ stable/10/sys/dev/acpica/acpi_cpu.c Sat Jul 23 17:41:47 2016 (r303229) @@ -275,7 +275,7 @@ static int acpi_cpu_attach(device_t dev) { ACPI_BUFFER buf; - ACPI_OBJECT arg[4], *obj; + ACPI_OBJECT arg, *obj; ACPI_OBJECT_LIST arglist; struct pcpu *pcpu_data; struct acpi_cpu_softc *sc; @@ -359,31 +359,19 @@ acpi_cpu_attach(device_t dev) * Intel Processor Vendor-Specific ACPI Interface Specification. */ if (sc->cpu_features) { - arglist.Pointer = arg; - arglist.Count = 4; - arg[0].Type = ACPI_TYPE_BUFFER; - arg[0].Buffer.Length = sizeof(cpu_oscuuid); - arg[0].Buffer.Pointer = cpu_oscuuid; /* UUID */ - arg[1].Type = ACPI_TYPE_INTEGER; - arg[1].Integer.Value = 1; /* revision */ - arg[2].Type = ACPI_TYPE_INTEGER; - arg[2].Integer.Value = 1; /* count */ - arg[3].Type = ACPI_TYPE_BUFFER; - arg[3].Buffer.Length = sizeof(cap_set); /* Capabilities buffer */ - arg[3].Buffer.Pointer = (uint8_t *)cap_set; - cap_set[0] = 0; /* status */ cap_set[1] = sc->cpu_features; - status = AcpiEvaluateObject(sc->cpu_handle, "_OSC", &arglist, NULL); + status = acpi_EvaluateOSC(sc->cpu_handle, cpu_oscuuid, 1, 2, cap_set, + cap_set, false); if (ACPI_SUCCESS(status)) { if (cap_set[0] != 0) device_printf(dev, "_OSC returned status %#x\n", cap_set[0]); } else { - arglist.Pointer = arg; + arglist.Pointer = &arg; arglist.Count = 1; - arg[0].Type = ACPI_TYPE_BUFFER; - arg[0].Buffer.Length = sizeof(cap_set); - arg[0].Buffer.Pointer = (uint8_t *)cap_set; + arg.Type = ACPI_TYPE_BUFFER; + arg.Buffer.Length = sizeof(cap_set); + arg.Buffer.Pointer = (uint8_t *)cap_set; cap_set[0] = 1; /* revision */ cap_set[1] = 1; /* number of capabilities integers */ cap_set[2] = sc->cpu_features; Modified: stable/10/sys/dev/acpica/acpi_pcib_acpi.c ============================================================================== --- stable/10/sys/dev/acpica/acpi_pcib_acpi.c Sat Jul 23 17:37:59 2016 (r303228) +++ stable/10/sys/dev/acpica/acpi_pcib_acpi.c Sat Jul 23 17:41:47 2016 (r303229) @@ -295,6 +295,39 @@ first_decoded_bus(struct acpi_hpcib_soft } #endif +static void +acpi_pcib_osc(struct acpi_hpcib_softc *sc) +{ + ACPI_STATUS status; + uint32_t cap_set[3]; + + static uint8_t pci_host_bridge_uuid[ACPI_UUID_LENGTH] = { + 0x5b, 0x4d, 0xdb, 0x33, 0xf7, 0x1f, 0x1c, 0x40, + 0x96, 0x57, 0x74, 0x41, 0xc0, 0x3d, 0xd7, 0x66 + }; + + /* Support Field: Extended PCI Config Space, MSI */ + cap_set[1] = 0x11; + + /* Control Field */ + cap_set[2] = 0; + + status = acpi_EvaluateOSC(sc->ap_handle, pci_host_bridge_uuid, 1, + nitems(cap_set), cap_set, cap_set, false); + if (ACPI_FAILURE(status)) { + if (status == AE_NOT_FOUND) + return; + device_printf(sc->ap_dev, "_OSC failed: %s\n", + AcpiFormatException(status)); + return; + } + + if (cap_set[0] != 0) { + device_printf(sc->ap_dev, "_OSC returned error %#x\n", + cap_set[0]); + } +} + static int acpi_pcib_acpi_attach(device_t dev) { @@ -321,6 +354,8 @@ acpi_pcib_acpi_attach(device_t dev) if (!acpi_DeviceIsPresent(dev)) return (ENXIO); + acpi_pcib_osc(sc); + /* * Get our segment number by evaluating _SEG. * It's OK for this to not exist. Modified: stable/10/sys/dev/acpica/acpivar.h ============================================================================== --- stable/10/sys/dev/acpica/acpivar.h Sat Jul 23 17:37:59 2016 (r303228) +++ stable/10/sys/dev/acpica/acpivar.h Sat Jul 23 17:41:47 2016 (r303229) @@ -335,6 +335,9 @@ ACPI_STATUS acpi_FindIndexedResource(ACP ACPI_RESOURCE **resp); ACPI_STATUS acpi_AppendBufferResource(ACPI_BUFFER *buf, ACPI_RESOURCE *res); +ACPI_STATUS acpi_EvaluateOSC(ACPI_HANDLE handle, uint8_t *uuid, + int revision, int count, uint32_t *caps_in, + uint32_t *caps_out, bool query); ACPI_STATUS acpi_OverrideInterruptLevel(UINT32 InterruptNumber); ACPI_STATUS acpi_SetIntrModel(int model); int acpi_ReqSleepState(struct acpi_softc *sc, int state); From owner-svn-src-stable-10@freebsd.org Sat Jul 23 21:15:42 2016 Return-Path: Delivered-To: svn-src-stable-10@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 16952BA257E; Sat, 23 Jul 2016 21:15:42 +0000 (UTC) (envelope-from alc@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 D7AF413CC; Sat, 23 Jul 2016 21:15:41 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6NLFfwg023958; Sat, 23 Jul 2016 21:15:41 GMT (envelope-from alc@FreeBSD.org) Received: (from alc@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6NLFfLs023957; Sat, 23 Jul 2016 21:15:41 GMT (envelope-from alc@FreeBSD.org) Message-Id: <201607232115.u6NLFfLs023957@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: alc set sender to alc@FreeBSD.org using -f From: Alan Cox Date: Sat, 23 Jul 2016 21:15:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303246 - stable/10/sys/vm X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Jul 2016 21:15:42 -0000 Author: alc Date: Sat Jul 23 21:15:40 2016 New Revision: 303246 URL: https://svnweb.freebsd.org/changeset/base/303246 Log: MFC r303101 Add a comment describing the 'fast path' that was introduced in r270011. Modified: stable/10/sys/vm/vm_fault.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/vm/vm_fault.c ============================================================================== --- stable/10/sys/vm/vm_fault.c Sat Jul 23 21:04:53 2016 (r303245) +++ stable/10/sys/vm/vm_fault.c Sat Jul 23 21:15:40 2016 (r303246) @@ -353,6 +353,15 @@ RetryFault:; KASSERT((fault_flags & VM_FAULT_WIRE) == 0, ("!wired && VM_FAULT_WIRE")); + /* + * Try to avoid lock contention on the top-level object through + * special-case handling of some types of page faults, specifically, + * those that are both (1) mapping an existing page from the top- + * level object and (2) not having to mark that object as containing + * dirty pages. Under these conditions, a read lock on the top-level + * object suffices, allowing multiple page faults of a similar type to + * run in parallel on the same top-level object. + */ if (fs.vp == NULL /* avoid locked vnode leak */ && (fault_flags & (VM_FAULT_WIRE | VM_FAULT_DIRTY)) == 0 && /* avoid calling vm_object_set_writeable_dirty() */ From owner-svn-src-stable-10@freebsd.org Sat Jul 23 22:51:00 2016 Return-Path: Delivered-To: svn-src-stable-10@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 6827ABA39DE; Sat, 23 Jul 2016 22:51:00 +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 205F31195; Sat, 23 Jul 2016 22:51:00 +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 u6NMoxPA061468; Sat, 23 Jul 2016 22:50:59 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6NMoxrp061467; Sat, 23 Jul 2016 22:50:59 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201607232250.u6NMoxrp061467@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Sat, 23 Jul 2016 22:50:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303252 - in stable: 10/sys/dev/acpica/Osd 9/sys/dev/acpica/Osd X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Jul 2016 22:51:00 -0000 Author: jhb Date: Sat Jul 23 22:50:59 2016 New Revision: 303252 URL: https://svnweb.freebsd.org/changeset/base/303252 Log: MFC 299977: Use polling spin loops for timeouts during early boot. Some ACPI operations such as mutex acquires and event waits accept a timeout. The ACPI OSD layer implements these timeouts by using regular sleep timeouts. However, this doesn't work during early boot before event timers are setup. Instead, use polling combined with DELAY() to spin. This fixes booting on upcoming Intel systems with Kaby Lake processors. Modified: stable/10/sys/dev/acpica/Osd/OsdSynch.c Directory Properties: stable/10/ (props changed) Changes in other areas also in this revision: Modified: stable/9/sys/dev/acpica/Osd/OsdSynch.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/10/sys/dev/acpica/Osd/OsdSynch.c ============================================================================== --- stable/10/sys/dev/acpica/Osd/OsdSynch.c Sat Jul 23 21:56:52 2016 (r303251) +++ stable/10/sys/dev/acpica/Osd/OsdSynch.c Sat Jul 23 22:50:59 2016 (r303252) @@ -188,6 +188,23 @@ AcpiOsWaitSemaphore(ACPI_SEMAPHORE Handl } break; default: + if (cold) { + /* + * Just spin polling the semaphore once a + * millisecond. + */ + while (!ACPISEM_AVAIL(as, Units)) { + if (Timeout == 0) { + status = AE_TIME; + break; + } + Timeout--; + mtx_unlock(&as->as_lock); + DELAY(1000); + mtx_lock(&as->as_lock); + } + break; + } tmo = timeout2hz(Timeout); while (!ACPISEM_AVAIL(as, Units)) { prevtick = ticks; @@ -381,6 +398,23 @@ AcpiOsAcquireMutex(ACPI_MUTEX Handle, UI } break; default: + if (cold) { + /* + * Just spin polling the mutex once a + * millisecond. + */ + while (!ACPIMTX_AVAIL(am)) { + if (Timeout == 0) { + status = AE_TIME; + break; + } + Timeout--; + mtx_unlock(&am->am_lock); + DELAY(1000); + mtx_lock(&am->am_lock); + } + break; + } tmo = timeout2hz(Timeout); while (!ACPIMTX_AVAIL(am)) { prevtick = ticks;